]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add in the 1st version of ECP.
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Jun 2007 07:00:39 +0000 (07:00 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Jun 2007 07:00:39 +0000 (07:00 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524

1433 files changed:
EdkCompatibilityPkg/EDK_Snapshot.txt [new file with mode: 0644]
EdkCompatibilityPkg/EdkCompatibilityPkg.dec [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Itanium/Include/CpuIa64.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiCommon.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiDebug.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiDepex.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiPci.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiPerf.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiPxe.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiSpec.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiTpm.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiVariable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/Tiano.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/TianoApi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/TianoCommon.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/TianoError.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/TianoTypes.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Event.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EbcCache.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/CpuBreakpoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SetJumpLongJump.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SwitchStack.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuBreakpoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuFlushTlb.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuPause.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/FlushCacheRange.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/GetInterruptState.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange32.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange64.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Non-existing.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/PalCallStatic.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ReadItc.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/SwitchStack.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Synchronization.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Unaligned.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/asm.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ia_64gen.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/longjmp.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ebc/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ipf/IpfTimerLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/ReadKr1.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/WriteKr1.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/asm.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/efijump.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/math.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/efijump.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h [new file with mode: 0644]
EdkCompatibilityPkg/License.txt [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c [new file with mode: 0644]
EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/CommonTools.env [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Include/EfiWinNt.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Sample/LocalTools.env [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Common.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/EdkLib32.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidList.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Version.env [new file with mode: 0644]

diff --git a/EdkCompatibilityPkg/EDK_Snapshot.txt b/EdkCompatibilityPkg/EDK_Snapshot.txt
new file mode 100644 (file)
index 0000000..231c73e
--- /dev/null
@@ -0,0 +1,6 @@
+Notes:\r
+  This EDK Compatibility Package is based on the EDK 1.03 release found at http://edk.tianocore.org.\r
+  It is compatibile with EDK 1.01 with the following exception:\r
+  \r
+  \r
+  
\ No newline at end of file
diff --git a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
new file mode 100644 (file)
index 0000000..8a6d4db
--- /dev/null
@@ -0,0 +1,49 @@
+#/** @file\r
+# EDK Compatibility Package\r
+#\r
+# This Package provides headers and libraries that allow a EDK Module (https://edk.tianocore.org)\r
+# to be used in the context of EDK II environment.\r
+#\r
+# All rights reserved.\r
+#    This program and the accompanying materials are licensed and made available under\r
+#    the terms and conditions of the BSD License which accompanies this distribution.\r
+#    The full text of the license may be found at\r
+#    http://opensource.org/licenses/bsd-license.php\r
+#\r
+#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+\r
+[Defines]\r
+  DEC_SPECIFICATION              = 0x00010005\r
+  PACKAGE_NAME                   = EdkCompatibilityPkg\r
+  PACKAGE_GUID                   = 98EDD7B0-2A6C-4b4a-AC72-4AAE0F95A3F8\r
+  PACKAGE_VERSION                = 0.1\r
+  \r
+  \r
+################################################################################\r
+#\r
+# Include Section - list of Include Paths that are provided by this package.\r
+#                   Comments are used for Keywords and Module Types.\r
+#\r
+# Supported Module Types:\r
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
+#\r
+################################################################################\r
+[Includes.common]\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Header section - list of Library Class header files that are\r
+#                                provided by this package.\r
+#\r
+################################################################################\r
+[LibraryClasses.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf
new file mode 100644 (file)
index 0000000..84b0afd
--- /dev/null
@@ -0,0 +1,65 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    ArchProtocolLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the Architectural Protocol Library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME      = ArchProtocolLib\r
+COMPONENT_TYPE = LIBRARY\r
+\r
+[sources.common]\r
+  Bds\Bds.c\r
+  Bds\Bds.h\r
+  Capsule\Capsule.c\r
+  Capsule\Capsule.h\r
+  Cpu\Cpu.c\r
+  Cpu\Cpu.h\r
+  Metronome\Metronome.c\r
+  Metronome\Metronome.h\r
+  MonotonicCounter\MonotonicCounter.c\r
+  MonotonicCounter\MonotonicCounter.h\r
+  RealTimeClock\RealTimeClock.c\r
+  RealTimeClock\RealTimeClock.h\r
+  Reset\Reset.c\r
+  Reset\Reset.h\r
+  Runtime\Runtime.c\r
+  Runtime\Runtime.h\r
+  Security\Security.c\r
+  Security\Security.h\r
+  StatusCode\StatusCode.c\r
+  StatusCode\StatusCode.h\r
+  Timer\Timer.c\r
+  Timer\Timer.h\r
+  Variable\Variable.c\r
+  Variable\Variable.h\r
+  VariableWrite\VariableWrite.c\r
+  VariableWrite\VariableWrite.h\r
+  WatchdogTimer\WatchdogTimer.c\r
+  WatchdogTimer\WatchdogTimer.h\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c
new file mode 100644 (file)
index 0000000..adb5682
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bds.c\r
+\r
+Abstract:\r
+\r
+  Boot Device Selection Architectural Protocol GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Bds)\r
+\r
+EFI_GUID  gEfiBdsArchProtocolGuid = EFI_BDS_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiBdsArchProtocolGuid, "BDS", "BDS Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h
new file mode 100644 (file)
index 0000000..ac8560a
--- /dev/null
@@ -0,0 +1,100 @@
+/*++ \r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bds.h\r
+\r
+Abstract:\r
+\r
+  Boot Device Selection Architectural Protocol as defined in Tiano\r
+\r
+  When the DXE core is done it calls the BDS via this protocol.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_BDS_H_\r
+#define _ARCH_PROTOCOL_BDS_H_\r
+\r
+//\r
+// Global ID for the BDS Architectural Protocol\r
+//\r
+#define EFI_BDS_ARCH_PROTOCOL_GUID \\r
+  { 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+\r
+//\r
+// Declare forward reference for the BDS Architectural Protocol\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_BDS_ARCH_PROTOCOL);\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_BDS_ENTRY) (\r
+  IN EFI_BDS_ARCH_PROTOCOL  * This\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function uses policy data from the platform to determine what operating \r
+  system or system utility should be loaded and invoked.  This function call \r
+  also optionally make the use of user input to determine the operating system \r
+  or system utility to be loaded and invoked.  When the DXE Core has dispatched \r
+  all the drivers on the dispatch queue, this function is called.  This \r
+  function will attempt to connect the boot devices required to load and invoke \r
+  the selected operating system or system utility.  During this process, \r
+  additional firmware volumes may be discovered that may contain addition DXE \r
+  drivers that can be dispatched by the DXE Core.   If a boot device cannot be \r
+  fully connected, this function calls the DXE Service Dispatch() to allow the \r
+  DXE drivers from any newly discovered firmware volumes to be dispatched.  \r
+  Then the boot device connection can be attempted again.  If the same boot \r
+  device connection operation fails twice in a row, then that boot device has \r
+  failed, and should be skipped.  This function should never return.\r
+\r
+Arguments:\r
+\r
+  This - The EFI_BDS_ARCH_PROTOCOL instance.\r
+\r
+Returns: \r
+\r
+  None.\r
+\r
+--*/\r
+\r
+//\r
+// Interface stucture for the BDS Architectural Protocol\r
+//\r
+typedef struct _EFI_BDS_ARCH_PROTOCOL {\r
+  EFI_BDS_ENTRY Entry;\r
+} EFI_BDS_ARCH_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    The EFI_BDS_ARCH_PROTOCOL transfers control from DXE to an operating \r
+    system or a system utility.  If there are not enough drivers initialized \r
+    when this protocol is used to access the required boot device(s), then \r
+    this protocol should add drivers to the dispatch queue and return control \r
+    back to the dispatcher.  Once the required boot devices are available, then \r
+    the boot device can be used to load and invoke an OS or a system utility.\r
+\r
+  Parameters:\r
+\r
+    Entry - The entry point to BDS.  This call does not take any parameters, \r
+            and the return value can be ignored.  If it returns, then the \r
+            dispatcher must be invoked again, if it never returns, then an \r
+            operating system or a system utility have been invoked.\r
+\r
+--*/\r
+\r
+extern EFI_GUID gEfiBdsArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c
new file mode 100644 (file)
index 0000000..b9aa9f6
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Capsule.c\r
+\r
+Abstract:\r
+\r
+  Capsule Architectural Protocol is used to produce the UEFI 2.0 capsule runtime services\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Capsule)\r
+\r
+EFI_GUID  gEfiCapsuleArchProtocolGuid = EFI_CAPSULE_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCapsuleArchProtocolGuid, "Capsule", "Capsule Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h
new file mode 100644 (file)
index 0000000..043a1b3
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Capsule.h\r
+\r
+Abstract:\r
+\r
+  Capsule Architectural Protocol is newly added to produce UEFI2.0 capsule runtime services.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_CAPSULE_ARCH_H_\r
+#define _ARCH_PROTOCOL_CAPSULE_ARCH_H_\r
+\r
+//\r
+// Global ID for the Capsule Architectural Protocol\r
+//\r
+#define EFI_CAPSULE_ARCH_PROTOCOL_GUID \\r
+  { 0x5053697e, 0x2cbc, 0x4819, 0x90, 0xd9, 0x5, 0x80, 0xde, 0xee, 0x57, 0x54 }\r
+\r
+extern EFI_GUID gEfiCapsuleArchProtocolGuid;\r
+\r
+#endif \r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c
new file mode 100644 (file)
index 0000000..3eca19b
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Cpu.c\r
+\r
+Abstract:\r
+\r
+  CPU Architectural Protocol GUID as defined in Tiano\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)\r
+\r
+EFI_GUID  gEfiCpuArchProtocolGuid = EFI_CPU_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCpuArchProtocolGuid, "CPU", "CPU Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h
new file mode 100644 (file)
index 0000000..7b17969
--- /dev/null
@@ -0,0 +1,361 @@
+/*++ \r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Cpu.h\r
+\r
+Abstract:\r
+\r
+  CPU Architectural Protocol as defined in Tiano\r
+\r
+  This code abstracts the DXE core from processor implementation details.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_CPU_H_\r
+#define _ARCH_PROTOCOL_CPU_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)\r
+\r
+#define EFI_CPU_ARCH_PROTOCOL_GUID \\r
+  { 0x26baccb1, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_CPU_ARCH_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiCpuFlushTypeWriteBackInvalidate,\r
+  EfiCpuFlushTypeWriteBack,\r
+  EfiCpuFlushTypeInvalidate,\r
+  EfiCpuMaxFlushType\r
+} EFI_CPU_FLUSH_TYPE;\r
+\r
+typedef enum {\r
+  EfiCpuInit,\r
+  EfiCpuMaxInitType\r
+} EFI_CPU_INIT_TYPE;\r
+\r
+typedef\r
+VOID\r
+(*EFI_CPU_INTERRUPT_HANDLER) (\r
+  IN EFI_EXCEPTION_TYPE                 InterruptType,\r
+  IN EFI_SYSTEM_CONTEXT                 SystemContext\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_FLUSH_DATA_CACHE) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  IN EFI_PHYSICAL_ADDRESS               Start,\r
+  IN UINT64                             Length,\r
+  IN EFI_CPU_FLUSH_TYPE                 FlushType\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function flushes the range of addresses from Start to Start+Length \r
+  from the processor's data cache. If Start is not aligned to a cache line \r
+  boundary, then the bytes before Start to the preceding cache line boundary \r
+  are also flushed. If Start+Length is not aligned to a cache line boundary, \r
+  then the bytes past Start+Length to the end of the next cache line boundary \r
+  are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be \r
+  supported. If the data cache is fully coherent with all DMA operations, then \r
+  this function can just return EFI_SUCCESS. If the processor does not support \r
+  flushing a range of the data cache, then the entire data cache can be flushed.\r
+\r
+Arguments:\r
+\r
+  This       - The EFI_CPU_ARCH_PROTOCOL instance.\r
+  Start      - The beginning physical address to flush from the processor's data \r
+               cache. \r
+  Length     - The number of bytes to flush from the processor's data cache. This \r
+               function may flush more bytes than Length specifies depending upon \r
+               the granularity of the flush operation that the processor supports.\r
+  FlushType  - Specifies the type of flush operation to perform.\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       -  The address range from Start to Start+Length was flushed from \r
+                       the processor's data cache.\r
+  EFI_UNSUPPORTEDT  -  The processor does not support the cache flush type specified \r
+                       by FlushType.\r
+  EFI_DEVICE_ERROR  -  The address range from Start to Start+Length could not be flushed \r
+                       from the processor's data cache.\r
+                       \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_ENABLE_INTERRUPT) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function enables interrupt processing by the processor. \r
+\r
+Arguments:\r
+\r
+  This  - The EFI_CPU_ARCH_PROTOCOL instance.\r
+    \r
+Returns: \r
+\r
+  EFI_SUCCESS       -  Interrupts are enabled on the processor.\r
+  EFI_DEVICE_ERROR  -  Interrupts could not be enabled on the processor.\r
+                       \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_DISABLE_INTERRUPT) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function disables interrupt processing by the processor.\r
+\r
+Arguments:\r
+\r
+  This  -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+    \r
+Returns: \r
+\r
+  EFI_SUCCESS       -  Interrupts are disabled on the processor.\r
+  EFI_DEVICE_ERROR  -  Interrupts could not be disabled on the processor.\r
+                       \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_GET_INTERRUPT_STATE) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  OUT BOOLEAN                           *State\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function retrieves the processor's current interrupt state a returns it in \r
+  State. If interrupts are currently enabled, then TRUE is returned. If interrupts \r
+  are currently disabled, then FALSE is returned.\r
+\r
+Arguments:\r
+\r
+  This  -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+  State -  A pointer to the processor's current interrupt state. Set to TRUE if \r
+           interrupts are enabled and FALSE if interrupts are disabled.  \r
+Returns: \r
+\r
+  EFI_SUCCESS             -  The processor's current interrupt state was returned in State.\r
+  EFI_INVALID_PARAMETER   -  State is NULL.\r
+                       \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_INIT) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  IN EFI_CPU_INIT_TYPE                  InitType\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generates an INIT on the processor. If this function succeeds, then the\r
+  processor will be reset, and control will not be returned to the caller. If InitType is \r
+  not supported by this processor, or the processor cannot programmatically generate an \r
+  INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error \r
+  occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.\r
+\r
+Arguments:\r
+\r
+  This     -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+  InitType -  The type of processor INIT to perform.  \r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS         -  The processor INIT was performed. This return code should never be seen.\r
+  EFI_UNSUPPORTED     -  The processor INIT operation specified by InitType is not supported \r
+                         by this processor.\r
+  EFI_DEVICE_ERROR    -  The processor INIT failed.   \r
+                       \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_REGISTER_INTERRUPT_HANDLER) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  IN EFI_EXCEPTION_TYPE                 InterruptType,\r
+  IN EFI_CPU_INTERRUPT_HANDLER          InterruptHandler\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers and enables the handler specified by InterruptHandler for a processor \r
+  interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the \r
+  handler for the processor interrupt or exception type specified by InterruptType is uninstalled. \r
+  The installed handler is called once for each processor interrupt or exception.\r
+  \r
+Arguments:\r
+\r
+  This              -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+  InterruptType     -  A pointer to the processor's current interrupt state. Set to TRUE if interrupts \r
+                       are enabled and FALSE if interrupts are disabled.  \r
+  InterruptHandler  -  A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
+                       when a processor interrupt occurs. If this parameter is NULL, then the handler \r
+                       will be uninstalled.\r
+Returns: \r
+\r
+  EFI_SUCCESS           -  The handler for the processor interrupt was successfully installed or uninstalled.\r
+  EFI_ALREADY_STARTED   -  InterruptHandler is not NULL, and a handler for InterruptType was \r
+                           previously installed.\r
+  EFI_INVALID_PARAMETER -  InterruptHandler is NULL, and a handler for InterruptType was not \r
+                           previously installed.\r
+  EFI_UNSUPPORTED       -  The interrupt specified by InterruptType is not supported.\r
+                    \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_GET_TIMER_VALUE) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  IN UINT32                             TimerIndex,\r
+  OUT UINT64                            *TimerValue,\r
+  OUT UINT64                            *TimerPeriod OPTIONAL\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads the processor timer specified by TimerIndex and returns it in TimerValue.\r
+  \r
+Arguments:\r
+\r
+  This        -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+  TimerIndex  -  Specifies which processor timer is to be returned in TimerValue. This parameter\r
+                 must be between 0 and NumberOfTimers-1.\r
+  TimerValue  -  Pointer to the returned timer value.\r
+  TimerPeriod -  A pointer to the amount of time that passes in femtoseconds for each increment \r
+                 of TimerValue.\r
+Returns: \r
+\r
+  EFI_SUCCESS           -  The processor timer value specified by TimerIndex was returned in TimerValue.\r
+  EFI_DEVICE_ERROR      -  An error occurred attempting to read one of the processor's timers.\r
+  EFI_INVALID_PARAMETER -  TimerValue is NULL or TimerIndex is not valid.\r
+  EFI_UNSUPPORTED       -  The processor does not have any readable timers.\r
+                    \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES) (\r
+  IN EFI_CPU_ARCH_PROTOCOL              * This,\r
+  IN  EFI_PHYSICAL_ADDRESS              BaseAddress,\r
+  IN  UINT64                            Length,\r
+  IN  UINT64                            Attributes\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function modifies the attributes for the memory region specified by BaseAddress and\r
+  Length from their current attributes to the attributes specified by Attributes.\r
+  \r
+Arguments:\r
+\r
+  This          -  The EFI_CPU_ARCH_PROTOCOL instance.\r
+  BaseAddress   -  The physical address that is the start address of a memory region.\r
+  Length        -  The size in bytes of the memory region.\r
+  Attributes    -  The bit mask of attributes to set for the memory region. \r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS           -  The attributes were set for the memory region.\r
+  EFI_ACCESS_DENIED     -  The attributes for the memory resource range specified by \r
+                           BaseAddress and Length cannot be modified.\r
+  EFI_INVALID_PARAMETER -  Length is zero.\r
+  EFI_OUT_OF_RESOURCES  -  There are not enough system resources to modify the attributes of\r
+                           the memory resource range.   \r
+  EFI_UNSUPPORTED       -  The processor does not support one or more bytes of the memory \r
+                           resource range specified by BaseAddress and Length. \r
+                           The bit mask of attributes is not support for the memory resource\r
+                           range specified by BaseAddress and Length.\r
+                                          \r
+--*/\r
+\r
+typedef struct _EFI_CPU_ARCH_PROTOCOL {\r
+  EFI_CPU_FLUSH_DATA_CACHE            FlushDataCache;\r
+  EFI_CPU_ENABLE_INTERRUPT            EnableInterrupt;\r
+  EFI_CPU_DISABLE_INTERRUPT           DisableInterrupt;\r
+  EFI_CPU_GET_INTERRUPT_STATE         GetInterruptState;\r
+  EFI_CPU_INIT                        Init;\r
+  EFI_CPU_REGISTER_INTERRUPT_HANDLER  RegisterInterruptHandler;\r
+  EFI_CPU_GET_TIMER_VALUE             GetTimerValue;\r
+  EFI_CPU_SET_MEMORY_ATTRIBUTES       SetMemoryAttributes;\r
+  UINT32                              NumberOfTimers;\r
+  UINT32                              DmaBufferAlignment;\r
+} EFI_CPU_ARCH_PROTOCOL;\r
+\r
+/*++\r
+\r
+Protocol Description:\r
+  \r
+  The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE\r
+  Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt\r
+  vectors and exception vectors, reading internal processor timers, resetting the processor, and\r
+  determining the processor frequency.\r
+\r
+Parameters:\r
+\r
+  FlushDataCache            -  Flushes a range of the processor's data cache. If the processor does \r
+                               not contain a data cache, or the data cache is fully coherent, then this \r
+                               function can just return EFI_SUCCESS. If the processor does not support \r
+                               flushing a range of addresses from the data cache, then the entire data \r
+                               cache must be flushed. \r
+  EnableInterrupt           -  Enables interrupt processing by the processor. \r
+  DisableInterrupt          -  Disables interrupt processing by the processor.\r
+  GetInterruptState         -  Retrieves the processor's current interrupt state.\r
+  Init                      -  Generates an INIT on the processor. If a processor cannot programmatically \r
+                               generate an INIT without help from external hardware, then this function \r
+                               returns EFI_UNSUPPORTED.\r
+  RegisterInterruptHandler  -  Associates an interrupt service routine with one of the processor's interrupt \r
+                               vectors. This function is typically used by the EFI_TIMER_ARCH_PROTOCOL to \r
+                               hook the timer interrupt in a system. It can also be used by the debugger to \r
+                               hook exception vectors.\r
+  GetTimerValue             -  Returns the value of one of the processor's internal timers.\r
+  SetMemoryAttributes       -  Attempts to set the attributes of a memory region.\r
+  NumberOfTimers            -  The number of timers that are available in a processor. The value in this \r
+                               field is a constant that must not be modified after the CPU Architectural \r
+                               Protocol is installed. All consumers must treat this as a read-only field.\r
+  DmaBufferAlignment        -  The size, in bytes, of the alignment required for DMA buffer allocations. \r
+                               This is typically the size of the largest data cache line in the platform. \r
+                               The value in this field is a constant that must not be modified after the \r
+                               CPU Architectural Protocol is installed. All consumers must treat this as \r
+                               a read-only field.\r
+  \r
+--*/\r
+\r
+extern EFI_GUID gEfiCpuArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c
new file mode 100644 (file)
index 0000000..27b286c
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Metronome.c\r
+\r
+Abstract:\r
+\r
+  Metronome Architectural Protocol as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome)\r
+\r
+EFI_GUID  gEfiMetronomeArchProtocolGuid = EFI_METRONOME_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiMetronomeArchProtocolGuid, "Metronome", "Metronome Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h
new file mode 100644 (file)
index 0000000..88de406
--- /dev/null
@@ -0,0 +1,109 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Metronome.h\r
+\r
+Abstract:\r
+\r
+  Metronome Architectural Protocol as defined in DXE CIS\r
+\r
+  This code abstracts the DXE core to provide delay services.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_METRONOME_H_\r
+#define _ARCH_PROTOCOL_METRONOME_H_\r
+\r
+//\r
+// Global ID for the Metronome Architectural Protocol\r
+//\r
+#define EFI_METRONOME_ARCH_PROTOCOL_GUID \\r
+  { 0x26baccb2, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r
+\r
+//\r
+// Declare forward reference for the Metronome Architectural Protocol\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_METRONOME_ARCH_PROTOCOL);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_METRONOME_WAIT_FOR_TICK) (\r
+   IN EFI_METRONOME_ARCH_PROTOCOL   *This,\r
+   IN UINT32                        TickNumber\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The WaitForTick() function waits for the number of ticks specified by \r
+  TickNumber from a known time source in the platform.  If TickNumber of \r
+  ticks are detected, then EFI_SUCCESS is returned.  The actual time passed \r
+  between entry of this function and the first tick is between 0 and \r
+  TickPeriod 100 nS units.  If you want to guarantee that at least TickPeriod \r
+  time has elapsed, wait for two ticks.  This function waits for a hardware \r
+  event to determine when a tick occurs.  It is possible for interrupt \r
+  processing, or exception processing to interrupt the execution of the \r
+  WaitForTick() function.  Depending on the hardware source for the ticks, it \r
+  is possible for a tick to be missed.  This function cannot guarantee that \r
+  ticks will not be missed.  If a timeout occurs waiting for the specified \r
+  number of ticks, then EFI_TIMEOUT is returned.\r
+\r
+Arguments:\r
+\r
+  This       - The EFI_METRONOME_ARCH_PROTOCOL instance.\r
+\r
+  TickNumber - Number of ticks to wait.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - The wait for the number of ticks specified by TickNumber \r
+                succeeded.\r
+\r
+  EFI_TIMEOUT - A timeout occurred waiting for the specified number of ticks.\r
+\r
+--*/\r
+\r
+//\r
+// Interface stucture for the Metronome Architectural Protocol\r
+//\r
+typedef struct _EFI_METRONOME_ARCH_PROTOCOL {\r
+  EFI_METRONOME_WAIT_FOR_TICK  WaitForTick;\r
+  UINT32                       TickPeriod;\r
+} EFI_METRONOME_ARCH_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    This protocol provides access to a known time source in the platform to the\r
+    core.  The core uses this known time source to produce core services that \r
+    require calibrated delays.  \r
+\r
+  Parameters:\r
+\r
+    WaitForTick - Waits for a specified number of ticks from a known time source \r
+                  in the platform.  The actual time passed between entry of this \r
+                  function and the first tick is between 0 and TickPeriod 100 nS \r
+                  units.  If you want to guarantee that at least TickPeriod time \r
+                  has elapsed, wait for two ticks.\r
+\r
+    TickPeriod  - The period of platform's known time source in 100 nS units.  \r
+                  This value on any platform must be at least 10 uS, and must not \r
+                  exceed 200 uS.  The value in this field is a constant that must \r
+                  not be modified after the Metronome architectural protocol is \r
+                  installed.  All consumers must treat this as a read-only field.\r
+    \r
+--*/\r
+\r
+extern EFI_GUID gEfiMetronomeArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c
new file mode 100644 (file)
index 0000000..633db95
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MonotonicCounter.c\r
+\r
+Abstract:\r
+\r
+  Monotonic Counter Architectural Protocol GUID as defined in the DXE CIS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION(MonotonicCounter)\r
+\r
+EFI_GUID gEfiMonotonicCounterArchProtocolGuid = EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter", "Monotonic Counter Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h
new file mode 100644 (file)
index 0000000..d4b87e6
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MonotonicCounter.h\r
+\r
+Abstract:\r
+\r
+  Monotonic Counter Architectural Protocol as defined in DXE CIS\r
+\r
+  This code provides the services required to access the systems monotonic counter\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_MONTONIC_COUNTER_H_\r
+#define _ARCH_PROTOCOL_MONTONIC_COUNTER_H_\r
+\r
+//\r
+// Global ID for the Monotonic Counter Architectural Protocol\r
+//\r
+#define EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID \\r
+  {0x1da97072, 0xbddc, 0x4b30, 0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a}\r
+  \r
+extern EFI_GUID gEfiMonotonicCounterArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c
new file mode 100644 (file)
index 0000000..74846e3
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RealTimeClock.c\r
+\r
+Abstract:\r
+\r
+  Real Time clock Architectural Protocol GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock)\r
+\r
+EFI_GUID  gEfiRealTimeClockArchProtocolGuid = EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiRealTimeClockArchProtocolGuid, "RTC", "Real Time Clock Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h
new file mode 100644 (file)
index 0000000..c17eaf6
--- /dev/null
@@ -0,0 +1,43 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RealTimeClock.h\r
+\r
+Abstract:\r
+\r
+  Real Time clock Architectural Protocol as defined in Tiano\r
+\r
+  This code abstracts time and data functions. Used to provide\r
+  Time and date related EFI runtime services.\r
+\r
+  The GetTime (), SetTime (), GetWakeupTime (), and SetWakeupTime () EFI 1.0\r
+  services are added to the EFI system table and the \r
+  EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID protocol is registered with a NULL \r
+  pointer.\r
+\r
+  No CRC of the EFI system table is required, as it is done in the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_\r
+#define _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_\r
+\r
+//\r
+// Global ID for the Real Time Clock Architectural Protocol\r
+//\r
+#define EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID \\r
+  { 0x27CFAC87, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+\r
+extern EFI_GUID gEfiRealTimeClockArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c
new file mode 100644 (file)
index 0000000..74569bb
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Reset.c\r
+\r
+Abstract:\r
+\r
+  Reset Architectural Protocol GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Reset)\r
+\r
+EFI_GUID  gEfiResetArchProtocolGuid = EFI_RESET_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiResetArchProtocolGuid, "Reset", "Reset Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h
new file mode 100644 (file)
index 0000000..0854b03
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Reset.h\r
+\r
+Abstract:\r
+\r
+  Reset Architectural Protocol as defined in the DXE CIS\r
+\r
+  Used to provide ResetSystem runtime services\r
+\r
+  The ResetSystem () EFI 1.0 service is added to the EFI system table and the \r
+  EFI_RESET_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.\r
+\r
+  No CRC of the EFI system table is required, as it is done in the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_RESET_H_\r
+#define _ARCH_PROTOCOL_RESET_H_\r
+\r
+//\r
+// Global ID for the Reset Architectural Protocol\r
+//\r
+#define EFI_RESET_ARCH_PROTOCOL_GUID  \\r
+  { 0x27CFAC88, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+\r
+extern EFI_GUID gEfiResetArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c
new file mode 100644 (file)
index 0000000..655e784
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Runtime.c\r
+\r
+Abstract:\r
+\r
+  Runtime Architectural Protocol as defined in Tiano\r
+\r
+  This code is used to produce the EFI 1.0 runtime virtual switch over\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime)\r
+\r
+EFI_GUID  gEfiRuntimeArchProtocolGuid = EFI_RUNTIME_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiRuntimeArchProtocolGuid, "Runtime", "Runtime Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h
new file mode 100644 (file)
index 0000000..62ea8b3
--- /dev/null
@@ -0,0 +1,114 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Runtime.h\r
+\r
+Abstract:\r
+\r
+  Runtime Architectural Protocol as defined in DXE CIS.\r
+\r
+\r
+  This code is used to produce the EFI runtime services that are callable\r
+  only in physical mode. \r
+\r
+  This driver must add SetVirtualAddressMap () and ConvertPointer () to\r
+  the EFI system table. This driver is not responcible for CRCing the \r
+  EFI system table.\r
+\r
+  This driver will add EFI_RUNTIME_ARCH_PROTOCOL_GUID protocol with a \r
+  pointer to the Runtime Arch Protocol instance structure. The protocol\r
+  member functions are used by the DXE core to export information needed\r
+  by this driver to produce the runtime transition of runtime drivers from\r
+  physical mode calling to virtual mode calling.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_RUNTIME_H_\r
+#define _ARCH_PROTOCOL_RUNTIME_H_\r
+\r
+#include "LinkedList.h"\r
+\r
+//\r
+// Global ID for the Runtime Architectural Protocol\r
+//\r
+#define EFI_RUNTIME_ARCH_PROTOCOL_GUID \\r
+  { 0xb7dfb4e1, 0x52f, 0x449f, 0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33 }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_RUNTIME_ARCH_PROTOCOL);\r
+\r
+typedef struct _EFI_RUNTIME_IMAGE_ENTRY {\r
+  VOID                    *ImageBase;\r
+  UINT64                  ImageSize;\r
+  VOID                    *RelocationData;\r
+  EFI_HANDLE              Handle;\r
+  EFI_LIST_ENTRY          Link;\r
+} EFI_RUNTIME_IMAGE_ENTRY;\r
+\r
+typedef struct _EFI_RUNTIME_EVENT_ENTRY {\r
+  UINT32                  Type;\r
+  EFI_TPL                 NotifyTpl;\r
+  EFI_EVENT_NOTIFY        NotifyFunction;\r
+  VOID                    *NotifyContext;\r
+  EFI_EVENT               *Event;\r
+  EFI_LIST_ENTRY          Link;\r
+} EFI_RUNTIME_EVENT_ENTRY;\r
+\r
+//\r
+// Interface stucture for the Runtime Architectural Protocol\r
+//\r
+typedef struct _EFI_RUNTIME_ARCH_PROTOCOL {\r
+  EFI_LIST_ENTRY          ImageHead;\r
+  EFI_LIST_ENTRY          EventHead;\r
+  UINTN                   MemoryDescriptorSize;\r
+  UINT32                  MemoryDesciptorVersion;\r
+  UINTN                   MemoryMapSize;\r
+  EFI_MEMORY_DESCRIPTOR   *MemoryMapPhysical;\r
+  EFI_MEMORY_DESCRIPTOR   *MemoryMapVirtual;\r
+  BOOLEAN                 VirtualMode;\r
+  BOOLEAN                 AtRuntime;\r
+} EFI_RUNTIME_ARCH_PROTOCOL;\r
+/*++\r
+\r
+Protocol Description:\r
+\r
+  Allows the runtime functionality of the DXE Foundation to be contained in a \r
+  separate driver. It also provides hooks for the DXE Foundation to export \r
+  information that is needed at runtime. As such, this protocol allows the DXE \r
+  Foundation to manage runtime drivers and events. This protocol also implies \r
+  that the runtime services required to transition to virtual mode, \r
+  SetVirtualAddressMap() and ConvertPointer(), have been registered into the \r
+  EFI Runtime Table in the EFI System Partition.  This protocol must be produced \r
+  by a runtime DXE driver and may only be consumed by the DXE Foundation.\r
+\r
+Parameters:\r
+  \r
+  ImageHead               - A list of type EFI_RUNTIME_IMAGE_ENTRY.\r
+  EventHead               - A list of type EFI_RUNTIME_EVENT_ENTRY.\r
+  MemoryDescriptorSize    - Size of a memory descriptor that is return by \r
+                            GetMemoryMap().\r
+  MemoryDescriptorVersion - Version of a memory descriptor that is return by \r
+                            GetMemoryMap().\r
+  MemoryMapSize           - Size of the memory map in bytes contained in \r
+                            MemoryMapPhysical and MemoryMapVirtual. \r
+  MemoryMapPhysical       - Pointer to a runtime buffer that contains a copy of the \r
+                            memory map returned via GetMemoryMap().\r
+  MemoryMapVirtual        - Pointer to MemoryMapPhysical that is updated to virtual mode \r
+                            after SetVirtualAddressMap(). \r
+  VirtualMode             - Boolean that is TRUE if SetVirtualAddressMap() has been called. \r
+  AtRuntime               - Boolean that is TRUE if ExitBootServices () has been called.\r
+  \r
+--*/\r
+\r
+extern EFI_GUID gEfiRuntimeArchProtocolGuid;\r
+\r
+#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 (file)
index 0000000..70026c1
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Security.c\r
+\r
+Abstract:\r
+\r
+  Security Architectural Protocol GUID as defined in DXE CIS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION(Security)\r
+\r
+EFI_GUID gEfiSecurityArchProtocolGuid = EFI_SECURITY_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSecurityArchProtocolGuid, "Security", "Security Arch Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h
new file mode 100644 (file)
index 0000000..483bc53
--- /dev/null
@@ -0,0 +1,146 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Security.h\r
+\r
+Abstract:\r
+\r
+  Security Architectural Protocol as defined in the DXE CIS\r
+\r
+  Used to provide Security services.  Specifically, dependening upon the \r
+  authentication state of a discovered driver in a Firmware Volume, the \r
+  portable DXE Core Dispatcher will call into the Security Architectural \r
+  Protocol (SAP) with the authentication state of the driver.\r
+\r
+  This call-out allows for OEM-specific policy decisions to be made, such\r
+  as event logging for attested boots, locking flash in response to discovering\r
+  an unsigned driver or failed signature check, or other exception response.\r
+\r
+  The SAP can also change system behavior by having the DXE core put a driver\r
+  in the Schedule-On-Request (SOR) state.  This will allow for later disposition \r
+  of the driver by platform agent, such as Platform BDS.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_SECURITY_H_\r
+#define _ARCH_PROTOCOL_SECURITY_H_\r
+\r
+//\r
+// Global ID for the Security Code Architectural Protocol\r
+//\r
+#define EFI_SECURITY_ARCH_PROTOCOL_GUID  \\r
+  { 0xA46423E3, 0x4617, 0x49f1, 0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SECURITY_ARCH_PROTOCOL);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_SECURITY_FILE_AUTHENTICATION_STATE) (\r
+  IN EFI_SECURITY_ARCH_PROTOCOL  *This,\r
+  IN  UINT32                              AuthenticationStatus,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL            *File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific \r
+  policy from the DXE core response to an attempt to use a file that returns a \r
+  given status for the authentication check from the section extraction protocol.  \r
+\r
+  The possible responses in a given SAP implementation may include locking \r
+  flash upon failure to authenticate, attestation logging for all signed drivers, \r
+  and other exception operations.  The File parameter allows for possible logging \r
+  within the SAP of the driver.\r
+\r
+  If File is NULL, then EFI_INVALID_PARAMETER is returned.\r
+\r
+  If the file specified by File with an authentication status specified by \r
+  AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r
+\r
+  If the file specified by File with an authentication status specified by \r
+  AuthenticationStatus is not safe for the DXE Core to use under any circumstances, \r
+  then EFI_ACCESS_DENIED is returned.\r
+\r
+  If the file specified by File with an authentication status specified by \r
+  AuthenticationStatus is not safe for the DXE Core to use right now, but it \r
+  might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is \r
+  returned.\r
+\r
+Arguments:\r
+\r
+  This                 - The EFI_SECURITY_ARCH_PROTOCOL instance.\r
+\r
+  AuthenticationStatus - This is the authentication type returned from the Section \r
+                         Extraction protocol.  See the Section Extraction Protocol \r
+                         Specification for details on this type.\r
+\r
+  File                 - This is a pointer to the device path of the file that is \r
+                         being dispatched.  This will optionally be used for logging.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            - The file specified by File did authenticate, and the \r
+                           platform policy dictates that the DXE Core may use File.\r
+\r
+  EFI_INVALID_PARAMETER  - Driver is NULL.\r
+\r
+  EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and \r
+                           the platform policy dictates that File should be placed \r
+                           in the untrusted state.   A file may be promoted from \r
+                           the untrusted to the trusted state at a future time \r
+                           with a call to the Trust() DXE Service.\r
+\r
+  EFI_ACCESS_DENIED      - The file specified by File did not authenticate, and \r
+                           the platform policy dictates that File should not be \r
+                           used for any purpose. \r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Interface stucture for the Timer Architectural Protocol\r
+//\r
+typedef struct _EFI_SECURITY_ARCH_PROTOCOL {\r
+  EFI_SECURITY_FILE_AUTHENTICATION_STATE  FileAuthenticationState;\r
+} EFI_SECURITY_ARCH_PROTOCOL;\r
+/*++\r
+\r
+  Protocol Description:\r
+\r
+    The EFI_SECURITY_ARCH_PROTOCOL is used to abstract platform-specific policy\r
+    from the DXE core.  This includes locking flash upon failure to authenticate, \r
+    attestation logging, and other exception operations.\r
+\r
+    The driver that produces the EFI_SECURITY_ARCH_PROTOCOL may also optionally \r
+    install the EFI_SECURITY_POLICY_PROTOCOL_GUID onto a new handle with a NULL \r
+    interface.  The existence of this GUID in the protocol database means that \r
+    the GUIDed Section Extraction Protocol should authenticate the contents of \r
+    an Authentication Section.  The expectation is that the GUIDed Section \r
+    Extraction protocol will look for the existence of the EFI_SECURITY_POLICY_ \r
+    PROTOCOL_GUID in the protocol database.  If it exists, then the publication \r
+    thereof is taken as an injunction to attempt an authentication of any section \r
+    wrapped in an Authentication Section.  See the Firmware File System \r
+    Specification for details on the GUIDed Section Extraction Protocol and \r
+    Authentication Sections.\r
+  \r
+  Parameters:\r
+    \r
+    FileAuthenticationState - This service is called upon fault with respect to \r
+                              the authentication of a section of a file.\r
+\r
+--*/\r
+\r
+extern EFI_GUID gEfiSecurityArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c
new file mode 100644 (file)
index 0000000..ad32cfe
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCode.c\r
+\r
+Abstract:\r
+\r
+  Status code Architectural Protocol as defined in Tiano\r
+\r
+  This code abstracts Status Code reporting.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+EFI_GUID  gEfiStatusCodeRuntimeProtocolGuid = EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID;\r
+\r
+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 (file)
index 0000000..86b7c66
--- /dev/null
@@ -0,0 +1,100 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCode.h\r
+\r
+Abstract:\r
+\r
+  Status code Architectural Protocol as defined in the DXE CIS\r
+\r
+  This code abstracts Status Code reporting.\r
+\r
+  The StatusCode () Tiano service is added to the EFI system table and the \r
+  EFI_STATUS_CODE_ARCH_PROTOCOL_GUID protocol is registered with a NULL \r
+  pointer.\r
+\r
+  No CRC of the EFI system table is required, as it is done in the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef __STATUS_CODE_RUNTIME_PROTOCOL_H__\r
+#define __STATUS_CODE_RUNTIME_PROTOCOL_H__\r
+\r
+#define EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID  \\r
+  { 0xd2b2b828, 0x826, 0x48a7, 0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0}\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+typedef\r
+EFI_STATUS \r
+(EFIAPI *EFI_REPORT_STATUS_CODE) (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId  OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+/*++\r
+Routine Description: \r
+\r
+  Provides an interface that a software module can call to report a status code.\r
+\r
+Arguments:\r
+\r
+  Type     - Indicates the type of status code being reported.\r
+  \r
+  Value    - Describes the current status of a hardware or software entity.\r
+             This included information about the class and subclass that is \r
+             used to classify the entity as well as an operation.\r
+  \r
+  Instance - The enumeration of a hardware or software entity within \r
+             the system. Valid instance numbers start with 1.\r
+  \r
+  CallerId - This optional parameter may be used to identify the caller.\r
+             This parameter allows the status code driver to apply different \r
+             rules to different callers.\r
+  \r
+  Data     - This optional parameter may be used to pass additional data.\r
+\r
+Returns: \r
+  \r
+  EFI_SUCCESS      - The function completed successfully\r
+  \r
+  EFI_DEVICE_ERROR - The function should not be completed due to a device error.\r
+\r
+--*/\r
+;\r
+#endif\r
+\r
+//\r
+// Interface stucture for the STATUS CODE Architectural Protocol\r
+//\r
+typedef struct _EFI_STATUS_CODE_PROTOCOL {\r
+  EFI_REPORT_STATUS_CODE         ReportStatusCode;\r
+} EFI_STATUS_CODE_PROTOCOL;\r
+\r
+/*++\r
+//  Protocol Description:\r
+//\r
+//    Provides the service required to report a status code to the platform firmware.\r
+//    This protocol must be produced by a runtime DXE driver and may be consumed \r
+//    only by the DXE Foundation.\r
+//\r
+//  Parameter:\r
+//\r
+//    ReportStatusCode - Emit a status code.\r
+--*/\r
+\r
+\r
+extern EFI_GUID gEfiStatusCodeRuntimeProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c
new file mode 100644 (file)
index 0000000..0d1d2ec
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Timer.c\r
+\r
+Abstract:\r
+\r
+  Timer Architectural Protocol GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Timer)\r
+\r
+EFI_GUID  gEfiTimerArchProtocolGuid = EFI_TIMER_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTimerArchProtocolGuid, "Timer", "Timer Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h
new file mode 100644 (file)
index 0000000..76ec85a
--- /dev/null
@@ -0,0 +1,260 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Timer.h\r
+\r
+Abstract:\r
+\r
+  Timer Architectural Protocol as defined in the DXE CIS\r
+\r
+  This code is used to provide the timer tick for the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_TIMER_H_\r
+#define _ARCH_PROTOCOL_TIMER_H_\r
+\r
+//\r
+// Global ID for the Timer Architectural Protocol\r
+//\r
+#define EFI_TIMER_ARCH_PROTOCOL_GUID \\r
+  { 0x26baccb3, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r
+\r
+//\r
+// Declare forward reference for the Timer Architectural Protocol\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_TIMER_ARCH_PROTOCOL);\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_TIMER_NOTIFY) (\r
+  IN UINT64  Time\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function of this type is called when a timer interrupt fires.  This \r
+  function executes at TPL_HIGH_LEVEL.  The DXE Core will register a funtion\r
+  of tyis type to be called for the timer interrupt, so it can know how much \r
+  time has passed.  This information is used to signal timer based events.  \r
+\r
+Arguments:\r
+\r
+  Time - Time since the last timer interrupt in 100 ns units.  This will \r
+         typically be TimerPeriod, but if a timer interrupt is missed, and the \r
+         EFI_TIMER_ARCH_PROTOCOL driver can detect missed interrupts, then Time \r
+         will contain the actual amount of time since the last interrupt.\r
+\r
+Returns: \r
+\r
+  None.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TIMER_REGISTER_HANDLER) (\r
+  IN EFI_TIMER_ARCH_PROTOCOL    *This,\r
+  IN EFI_TIMER_NOTIFY           NotifyFunction\r
+);\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers the handler NotifyFunction so it is called every time \r
+  the timer interrupt fires.  It also passes the amount of time since the last \r
+  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the \r
+  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is \r
+  returned.  If the CPU does not support registering a timer interrupt handler, \r
+  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler \r
+  when a handler is already registered, then EFI_ALREADY_STARTED is returned.  \r
+  If an attempt is made to unregister a handler when a handler is not registered, \r
+  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to \r
+  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR \r
+  is returned.\r
+\r
+Arguments:\r
+\r
+  This           - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  NotifyFunction - The function to call when a timer interrupt fires.  This \r
+                   function executes at TPL_HIGH_LEVEL.  The DXE Core will \r
+                   register a handler for the timer interrupt, so it can know \r
+                   how much time has passed.  This information is used to \r
+                   signal timer based events.  NULL will unregister the handler.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - The timer handler was registered.\r
+\r
+  EFI_UNSUPPORTED       - The platform does not support timer interrupts.\r
+\r
+  EFI_ALREADY_STARTED   - NotifyFunction is not NULL, and a handler is already \r
+                          registered.\r
+\r
+  EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not \r
+                          previously registered.\r
+\r
+  EFI_DEVICE_ERROR      - The timer handler could not be registered.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TIMER_SET_TIMER_PERIOD) (\r
+  IN EFI_TIMER_ARCH_PROTOCOL    *This,\r
+  IN UINT64                     TimerPeriod\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adjusts the period of timer interrupts to the value specified \r
+  by TimerPeriod.  If the timer period is updated, then the selected timer \r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If \r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.  \r
+  If an error occurs while attempting to update the timer period, then the \r
+  timer hardware will be put back in its state prior to this call, and \r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt \r
+  is disabled.  This is not the same as disabling the CPU's interrupts.  \r
+  Instead, it must either turn off the timer hardware, or it must adjust the \r
+  interrupt controller so that a CPU interrupt is not generated when the timer \r
+  interrupt fires. \r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - The rate to program the timer interrupt in 100 nS units.  If \r
+                the timer hardware is not programmable, then EFI_UNSUPPORTED is \r
+                returned.  If the timer is programmable, then the timer period \r
+                will be rounded up to the nearest timer period that is supported \r
+                by the timer hardware.  If TimerPeriod is set to 0, then the \r
+                timer interrupts will be disabled.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS      - The timer period was changed.\r
+\r
+  EFI_UNSUPPORTED  - The platform cannot change the period of the timer interrupt.\r
+\r
+  EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TIMER_GET_TIMER_PERIOD) (\r
+  IN EFI_TIMER_ARCH_PROTOCOL    *This,\r
+  OUT UINT64                     *TimerPeriod\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function retrieves the period of timer interrupts in 100 ns units, \r
+  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod \r
+  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is \r
+  returned, then the timer is currently disabled.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - A pointer to the timer period to retrieve in 100 ns units.  If \r
+                0 is returned, then the timer is currently disabled.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - The timer period was returned in TimerPeriod.\r
+\r
+  EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TIMER_GENERATE_SOFT_INTERRUPT) (\r
+  IN EFI_TIMER_ARCH_PROTOCOL    *This\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generates a soft timer interrupt. If the platform does not support soft \r
+  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned. \r
+  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() \r
+  service, then a soft timer interrupt will be generated. If the timer interrupt is \r
+  enabled when this service is called, then the registered handler will be invoked. The \r
+  registered handler should not be able to distinguish a hardware-generated timer \r
+  interrupt from a software-generated timer interrupt.\r
+\r
+Arguments:\r
+\r
+  This  -  The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS       - The soft timer interrupt was generated.\r
+\r
+  EFI_UNSUPPORTEDT  - The platform does not support the generation of soft timer interrupts.\r
+\r
+--*/\r
+\r
+//\r
+// Interface stucture for the Timer Architectural Protocol\r
+//\r
+typedef struct _EFI_TIMER_ARCH_PROTOCOL {\r
+  EFI_TIMER_REGISTER_HANDLER          RegisterHandler;\r
+  EFI_TIMER_SET_TIMER_PERIOD          SetTimerPeriod;\r
+  EFI_TIMER_GET_TIMER_PERIOD          GetTimerPeriod;\r
+  EFI_TIMER_GENERATE_SOFT_INTERRUPT   GenerateSoftInterrupt;\r
+} EFI_TIMER_ARCH_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    This protocol provides the services to initialize a periodic timer \r
+    interrupt, and to register a handler that is called each time the timer\r
+    interrupt fires.  It may also provide a service to adjust the rate of the\r
+    periodic timer interrupt.  When a timer interrupt occurs, the handler is \r
+    passed the amount of time that has passed since the previous timer \r
+    interrupt.\r
+  \r
+  Parameters:\r
+    \r
+    RegisterHandler - Registers a handler that will be called each time the \r
+                      timer interrupt fires.  TimerPeriod defines the minimum \r
+                      time between timer interrupts, so TimerPeriod will also \r
+                      be the minimum time between calls to the registered \r
+                      handler.\r
+    \r
+    SetTimerPeriod  - Sets the period of the timer interrupt in 100 nS units.  \r
+                      This function is optional, and may return EFI_UNSUPPORTED.  \r
+                      If this function is supported, then the timer period will \r
+                      be rounded up to the nearest supported timer period.\r
+    \r
+    GetTimerPeriod  - Retrieves the period of the timer interrupt in 100 nS units.\r
+    \r
+    GenerateSoftInterrupt - \r
+                      Generates a soft timer interrupt that simulates the firing of \r
+                      the timer interrupt. This service can be used to invoke the \r
+                      registered handler if the timer interrupt has been masked for \r
+                      a period of time.\r
+\r
+--*/\r
+\r
+extern EFI_GUID gEfiTimerArchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c
new file mode 100644 (file)
index 0000000..eb6ddb0
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  Variable Architectural Protocol as defined in Tiano\r
+\r
+  This code is used to produce the EFI 1.0 runtime variable services\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)\r
+\r
+EFI_GUID  gEfiVariableArchProtocolGuid = EFI_VARIABLE_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiVariableArchProtocolGuid, "Variable", "Variable Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h
new file mode 100644 (file)
index 0000000..bee321d
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable.h\r
+\r
+Abstract:\r
+\r
+  Variable Architectural Protocol as defined in the DXE CIS\r
+\r
+  This code is used to produce the EFI 1.0 runtime variable services\r
+\r
+  The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0 \r
+  services are added to the EFI system table and the \r
+  EFI_VARIABLE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.\r
+\r
+  No CRC of the EFI system table is required, as it is done in the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_VARIABLE_ARCH_H_\r
+#define _ARCH_PROTOCOL_VARIABLE_ARCH_H_\r
+\r
+//\r
+// Global ID for the Variable Architectural Protocol\r
+//\r
+#define EFI_VARIABLE_ARCH_PROTOCOL_GUID \\r
+  { 0x1e5668e2, 0x8481, 0x11d4, 0xbc, 0xf1, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r
+\r
+extern EFI_GUID gEfiVariableArchProtocolGuid;\r
+\r
+#endif \r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c
new file mode 100644 (file)
index 0000000..449b205
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VariableWrite.c\r
+\r
+Abstract:\r
+\r
+  Variable Write Architectural Protocol as defined in DXE CIS\r
+\r
+  This code is used to indicate the EFI 1.0 runtime variable services\r
+  support writting to variables.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (VariableWrite)\r
+\r
+EFI_GUID  gEfiVariableWriteArchProtocolGuid = EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiVariableWriteArchProtocolGuid, "VariableWrite", "Variable Write Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h
new file mode 100644 (file)
index 0000000..2a1237d
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VariableWrite.h\r
+\r
+Abstract:\r
+\r
+  Variable Write Architectural Protocol as defined in the DXE CIS\r
+\r
+  This code is used to produce the EFI 1.0 runtime variable services\r
+\r
+  The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0 \r
+  services are added to the EFI system table and the \r
+  EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.\r
+\r
+  No CRC of the EFI system table is required, as it is done in the DXE core.\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_\r
+#define _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_\r
+\r
+//\r
+// Global ID for the Variable Write Architectural Protocol\r
+//\r
+#define EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID \\r
+  { 0x6441f818, 0x6362, 0x4e44, 0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53 }\r
+\r
+extern EFI_GUID gEfiVariableWriteArchProtocolGuid;\r
+\r
+#endif \r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c
new file mode 100644 (file)
index 0000000..9560847
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WatchdogTimer.c\r
+\r
+Abstract:\r
+\r
+  Watchdog Timer Architectural Protocol GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer)\r
+\r
+EFI_GUID  gEfiWatchdogTimerArchProtocolGuid = EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiWatchdogTimerArchProtocolGuid, "Watchdog Timer", "Watchdog Timer Arch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h
new file mode 100644 (file)
index 0000000..4ebecfa
--- /dev/null
@@ -0,0 +1,206 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WatchdogTimer.h\r
+\r
+Abstract:\r
+\r
+  Watchdog Timer Architectural Protocol as defined in the DXE CIS\r
+\r
+  Used to provide system watchdog timer services\r
+\r
+--*/\r
+\r
+#ifndef _ARCH_PROTOCOL_WATCHDOG_TIMER_H_\r
+#define _ARCH_PROTOCOL_WATCHDOG_TIMER_H_\r
+\r
+//\r
+// Global ID for the Watchdog Timer Architectural Protocol\r
+//\r
+#define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \\r
+  { 0x665E3FF5, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+\r
+//\r
+// Declare forward reference for the Timer Architectural Protocol\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_WATCHDOG_TIMER_ARCH_PROTOCOL);\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_WATCHDOG_TIMER_NOTIFY) (\r
+  IN UINT64  Time\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  A function of this type is called when the watchdog timer fires if a \r
+  handler has been registered.\r
+\r
+Arguments:\r
+\r
+  Time - The time in 100 ns units that has passed since the watchdog \r
+         timer was armed.  For the notify function to be called, this \r
+         must be greater than TimerPeriod.\r
+  \r
+Returns: \r
+\r
+  None.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_WATCHDOG_TIMER_REGISTER_HANDLER) (\r
+  IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_WATCHDOG_TIMER_NOTIFY                 NotifyFunction\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers a handler that is to be invoked when the watchdog \r
+  timer fires.  By default, the EFI_WATCHDOG_TIMER protocol will call the \r
+  Runtime Service ResetSystem() when the watchdog timer fires.  If a \r
+  NotifyFunction is registered, then the NotifyFunction will be called before \r
+  the Runtime Service ResetSystem() is called.  If NotifyFunction is NULL, then \r
+  the watchdog handler is unregistered.  If a watchdog handler is registered, \r
+  then EFI_SUCCESS is returned.  If an attempt is made to register a handler \r
+  when a handler is already registered, then EFI_ALREADY_STARTED is returned.  \r
+  If an attempt is made to uninstall a handler when a handler is not installed, \r
+  then return EFI_INVALID_PARAMETER.\r
+\r
+Arguments:\r
+\r
+  This           - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  NotifyFunction - The function to call when the watchdog timer fires.  If this\r
+                   is NULL, then the handler will be unregistered.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - The watchdog timer handler was registered or \r
+                          unregistered.\r
+\r
+  EFI_ALREADY_STARTED   - NotifyFunction is not NULL, and a handler is already \r
+                          registered.\r
+\r
+  EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not \r
+                          previously registered.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD) (\r
+  IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                                    TimerPeriod\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function sets the amount of time to wait before firing the watchdog \r
+  timer to TimerPeriod 100 nS units.  If TimerPeriod is 0, then the watchdog \r
+  timer is disabled.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - The amount of time in 100 nS units to wait before the watchdog \r
+                timer is fired.  If TimerPeriod is zero, then the watchdog \r
+                timer is disabled.\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS      - The watchdog timer has been programmed to fire in Time \r
+                     100 nS units.\r
+\r
+  EFI_DEVICE_ERROR - A watchdog timer could not be programmed due to a device \r
+                     error.\r
+\r
+--*/\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD) (\r
+  IN  EFI_WATCHDOG_TIMER_ARCH_PROTOCOL  *This,\r
+  OUT UINT64                            *TimerPeriod\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function retrieves the amount of time the system will wait before firing \r
+  the watchdog timer.  This period is returned in TimerPeriod, and EFI_SUCCESS \r
+  is returned.  If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - A pointer to the amount of time in 100 nS units that the system \r
+                will wait before the watchdog timer is fired.  If TimerPeriod of\r
+                zero is returned, then the watchdog timer is disabled.\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS           - The amount of time that the system will wait before \r
+                          firing the watchdog timer was returned in TimerPeriod.\r
+\r
+  EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
+\r
+--*/\r
+\r
+//\r
+// Interface stucture for the Watchdog Timer Architectural Protocol\r
+//\r
+typedef struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL {\r
+  EFI_WATCHDOG_TIMER_REGISTER_HANDLER  RegisterHandler;\r
+  EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD  SetTimerPeriod;\r
+  EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD  GetTimerPeriod;\r
+} EFI_WATCHDOG_TIMER_ARCH_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    This protocol provides the services required to implement the Boot Service \r
+    SetWatchdogTimer().  It provides a service to set the amount of time to wait \r
+    before firing the watchdog timer, and it also provides a service to register \r
+    a handler that is invoked when the watchdog timer fires.  This protocol can \r
+    implement the watchdog timer by using the event and timer Boot Services, or \r
+    it can make use of custom hardware.  When the watchdog timer fires, control \r
+    will be passed to a handler if one has been registered.  If no handler has \r
+    been registered, or the registered handler returns, then the system will be \r
+    reset by calling the Runtime Service ResetSystem().\r
+  \r
+  Parameters:\r
+\r
+    RegisterHandler - Registers a handler that is invoked when the watchdog \r
+                      timer fires.\r
+\r
+    SetTimerPeriod  - Sets the amount of time in 100 ns units to wait before the \r
+                      watchdog timer is fired.  If this function is supported, \r
+                      then the watchdog timer period will be rounded up to the \r
+                      nearest supported watchdog timer period.\r
+\r
+    GetTimerPeriod  - Retrieves the amount of time in 100 ns units that the \r
+                      system will wait before the watchdog timer is fired.\r
+\r
+--*/\r
+\r
+extern EFI_GUID gEfiWatchdogTimerArchProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf
new file mode 100644 (file)
index 0000000..62a3c49
--- /dev/null
@@ -0,0 +1,37 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#   Module Name:\r
+#\r
+#     CpuIA64Lib.inf\r
+#\r
+#   Abstract:\r
+#\r
+#     Component description file for the Cpu IA64 library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = CpuIA64Lib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ipf]\r
+  Ipf\CpuIA64.s\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Cpu\Itanium\Include\r
+  $(EDK_SOURCE)\Foundation\include\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s
new file mode 100644 (file)
index 0000000..ddf5984
--- /dev/null
@@ -0,0 +1,33 @@
+//****************************************************************************\r
+//\r
+//   Copyright (c) 2004, Intel Corporation                                                         \r
+//   All rights reserved. This program and the accompanying materials                          \r
+//   are licensed and made available under the terms and conditions of the BSD License         \r
+//   which accompanies this distribution.  The full text of the license may be found at        \r
+//   http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                             \r
+//   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+//   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+//   \r
+//   Module Name:\r
+//\r
+//     CpuIA64.s\r
+//  \r
+//   Abstract: \r
+//   \r
+//     Contains basic assembly procedures to support IPF CPU.\r
+//  \r
+//****************************************************************************\r
+\r
+.file  "CpuIA64.s"\r
+\r
+#include  "IpfMacro.i"\r
+#include  "IpfDefines.h"\r
+\r
+\r
+PROCEDURE_ENTRY (EfiReadTsc)\r
+  \r
+  mov r8 = ar.itc   \r
+  br.ret.dpnt  b0;;\r
+\r
+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 (file)
index 0000000..c90cfe7
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIA64.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _CPU_IA64_H\r
+#define _CPU_IA64_H\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+EfiReadTsc (\r
+  VOID\r
+  )\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Read Time stamp\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+   Return the read data                                                \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf
new file mode 100644 (file)
index 0000000..09a464b
--- /dev/null
@@ -0,0 +1,42 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#   Module Name:\r
+#\r
+#     CpuIA32Lib.inf\r
+#\r
+#   Abstract:\r
+#\r
+#     Component description file for the Cpu IA32 library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = CpuIA32Lib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  EfiCpuVersion.c\r
+\r
+[sources.ia32]\r
+  Ia32\CpuIA32.c\r
+\r
+[sources.x64]\r
+  x64\Cpu.asm\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Include\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c
new file mode 100644 (file)
index 0000000..192469f
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCpuVersion.c\r
+  \r
+Abstract:\r
+  \r
+  Provide cpu version extract considering extended family & model ID.\r
+--*/\r
+\r
+#include "CpuIA32.h"\r
+\r
+VOID\r
+EfiCpuVersion (\r
+  IN  OUT UINT16  *FamilyId,    OPTIONAL\r
+  IN  OUT UINT8   *Model,       OPTIONAL\r
+  IN  OUT UINT8   *SteppingId,  OPTIONAL\r
+  IN  OUT UINT8   *Processor    OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract CPU detail version infomation\r
+\r
+Arguments:\r
+  FamilyId   - FamilyId, including ExtendedFamilyId\r
+  Model      - Model, including ExtendedModel\r
+  SteppingId - SteppingId\r
+  Processor  - Processor\r
+\r
+--*/\r
+{\r
+  EFI_CPUID_REGISTER Register;\r
+  UINT8              TempFamilyId;\r
+  \r
+  EfiCpuid (EFI_CPUID_VERSION_INFO, &Register);\r
+  \r
+  if (SteppingId != NULL) {\r
+    *SteppingId = (UINT8) (Register.RegEax & 0xF);\r
+  }\r
+\r
+  if (Processor != NULL) {\r
+    *Processor = (UINT8) ((Register.RegEax >> 12) & 0x3);\r
+  }\r
+\r
+  if (Model != NULL || FamilyId != NULL) {\r
+    TempFamilyId = (UINT8) ((Register.RegEax >> 8) & 0xF);\r
+  \r
+    if (Model != NULL) {\r
+      *Model = (UINT8) ((Register.RegEax >> 4) & 0xF);\r
+      if (TempFamilyId == 0x6 || TempFamilyId == 0xF) {\r
+        *Model |= (Register.RegEax >> 12) & 0xF0;\r
+      }\r
+    }\r
+  \r
+    if (FamilyId != NULL) {\r
+      *FamilyId = TempFamilyId;\r
+      if (TempFamilyId == 0xF) {\r
+        *FamilyId = *FamilyId + (UINT16) ((Register.RegEax >> 20) & 0xFF);\r
+      }\r
+    }\r
+  } \r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
new file mode 100644 (file)
index 0000000..4956179
--- /dev/null
@@ -0,0 +1,179 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIA32.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "CpuIA32.h"\r
+\r
+VOID\r
+EfiHalt (VOID)\r
+{\r
+  __asm {\r
+    hlt\r
+  }\r
+}\r
+\r
+VOID\r
+EfiWbinvd (VOID)\r
+{\r
+  __asm {\r
+    wbinvd\r
+  }\r
+}\r
+\r
+VOID\r
+EfiInvd (VOID)\r
+{\r
+  __asm {\r
+    invd\r
+  }\r
+}\r
+\r
+VOID\r
+EfiCpuid (IN UINT32 RegisterInEax,\r
+          OUT EFI_CPUID_REGISTER *Reg OPTIONAL)\r
+{\r
+  __asm {\r
+    pushad\r
+\r
+    mov    eax, RegisterInEax\r
+    cpuid\r
+    cmp    Reg, 0\r
+    je     _Exit\r
+    mov    edi, DWORD PTR Reg \r
+\r
+    mov    DWORD PTR [edi].RegEax, eax   ; Reg->RegEax\r
+    mov    DWORD PTR [edi].RegEbx, ebx   ; Reg->RegEbx\r
+    mov    DWORD PTR [edi].RegEcx, ecx   ; Reg->RegEcx\r
+    mov    DWORD PTR [edi].RegEdx, edx   ; Reg->RegEdx\r
+\r
+_Exit:\r
+     popad\r
+  }\r
+}\r
+\r
+UINT64\r
+EfiReadMsr (IN UINT32 Index)\r
+{\r
+  __asm {\r
+    mov    ecx, Index\r
+    rdmsr\r
+  }\r
+}\r
+\r
+VOID\r
+EfiWriteMsr (\r
+  IN   UINT32  Index,\r
+  IN   UINT64  Value\r
+  )\r
+{\r
+  __asm {\r
+    mov    ecx, Index\r
+    mov    eax, DWORD PTR Value[0]\r
+    mov    edx, DWORD PTR Value[4]\r
+    wrmsr            \r
+  }\r
+}\r
+\r
+UINT64\r
+EfiReadTsc (VOID)\r
+{\r
+  __asm {\r
+    rdtsc\r
+  }\r
+}\r
+\r
+VOID\r
+EfiDisableCache (VOID)\r
+{\r
+  __asm {\r
+    mov   eax, cr0\r
+    bswap eax\r
+    and   al, 60h\r
+    cmp   al, 60h\r
+    je    Exit\r
+    wbinvd\r
+    mov   eax, cr0\r
+    or    eax, 060000000h     \r
+    mov   cr0, eax\r
+Exit:\r
+  }\r
+}\r
+\r
+VOID\r
+EfiEnableCache (VOID)\r
+{\r
+  __asm {\r
+    invd\r
+    mov   eax, cr0\r
+    and   eax, 09fffffffh         \r
+    mov   cr0, eax\r
+  }\r
+}\r
+\r
+UINT32\r
+EfiGetEflags (\r
+  VOID\r
+  )\r
+{\r
+  __asm {\r
+    pushfd\r
+    pop  eax\r
+  }\r
+}\r
+\r
+VOID\r
+EfiDisableInterrupts (VOID)\r
+{\r
+  __asm {\r
+    cli\r
+  }\r
+}\r
+\r
+VOID\r
+EfiEnableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  __asm {\r
+    sti\r
+  }\r
+}\r
+\r
+VOID\r
+EfiCpuidExt (\r
+  IN   UINT32              RegisterInEax,\r
+  IN   UINT32              CacheLevel,\r
+  OUT  EFI_CPUID_REGISTER  *Regs              \r
+  )\r
+{\r
+  __asm {\r
+    pushad\r
+\r
+    mov    eax, RegisterInEax\r
+    mov    ecx, CacheLevel\r
+    cpuid\r
+    mov    edi, DWORD PTR Regs \r
+\r
+    mov    DWORD PTR [edi].RegEax, eax   ; Reg->RegEax\r
+    mov    DWORD PTR [edi].RegEbx, ebx   ; Reg->RegEbx\r
+    mov    DWORD PTR [edi].RegEcx, ecx   ; Reg->RegEcx\r
+    mov    DWORD PTR [edi].RegEdx, edx   ; Reg->RegEdx\r
+\r
+    popad\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm
new file mode 100644 (file)
index 0000000..8e46f9b
--- /dev/null
@@ -0,0 +1,215 @@
+TITLE   Cpu.asm: Assembly code for the x64 resources\r
+\r
+;------------------------------------------------------------------------------\r
+;*\r
+;*   Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
+;*   All rights reserved. This program and the accompanying materials                          \r
+;*   are licensed and made available under the terms and conditions of the BSD License         \r
+;*   which accompanies this distribution.  The full text of the license may be found at        \r
+;*   http://opensource.org/licenses/bsd-license.php                                            \r
+;*                                                                                             \r
+;*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;*   \r
+;*   Module Name:\r
+;*\r
+;*    Cpu.asm\r
+;*  \r
+;*   Abstract:\r
+;*  \r
+;------------------------------------------------------------------------------\r
+\r
+text    SEGMENT\r
+\r
\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiHalt (\r
+;    VOID\r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiHalt PROC    PUBLIC\r
+    hlt\r
+    ret\r
+EfiHalt ENDP\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiWbinvd (\r
+;    VOID\r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiWbinvd PROC    PUBLIC\r
+    wbinvd\r
+    ret\r
+EfiWbinvd ENDP\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiInvd (\r
+;    VOID\r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiInvd PROC    PUBLIC\r
+    invd\r
+    ret\r
+EfiInvd ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiCpuid (\r
+;    IN   UINT32              RegisterInEax,          // rcx   \r
+;    OUT  EFI_CPUID_REGISTER  *Reg           OPTIONAL // rdx  \r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiCpuid PROC   PUBLIC\r
+    push  rbx\r
+    \r
+    mov   r8,   rdx         ; r8 = *Reg\r
+    mov   rax,  rcx         ; RegisterInEax\r
+    cpuid\r
+    cmp   r8,   0\r
+    je    _Exit\r
+    mov   [r8 +  0], eax    ; Reg->RegEax\r
+    mov   [r8 +  4], ebx    ; Reg->RegEbx\r
+    mov   [r8 +  8], ecx    ; Reg->RegEcx\r
+    mov   [r8 + 12], edx    ; Reg->RegEdx\r
+    \r
+_Exit:\r
+    pop   rbx\r
+    ret\r
+EfiCpuid  ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+;  UINT64\r
+;  EfiReadMsr (\r
+;    IN   UINT32  Index,  // rcx\r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiReadMsr PROC  PUBLIC \r
+    rdmsr\r
+    sal     rdx, 32   ; edx:eax -> rax\r
+    or      rax, rdx  ; rax = edx:eax\r
+    ret\r
+EfiReadMsr  ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiWriteMsr (\r
+;    IN   UINT32  Index,  // rcx\r
+;    IN   UINT64  Value   // rdx\r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiWriteMsr PROC   PUBLIC\r
+    mov     rax,  rdx   ; rdx = Value\r
+    sar     rdx,  32    ; convert rdx to edx upper 32-bits    \r
+    wrmsr               ; wrmsr[ecx] result = edx:eax\r
+    ret\r
+EfiWriteMsr  ENDP\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EfiReadTsc (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiReadTsc PROC    PUBLIC\r
+    rdtsc\r
+    shl     rax, 32\r
+    shrd    rax, rdx, 32\r
+    ret\r
+EfiReadTsc  ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiDisableCache (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiDisableCache PROC    PUBLIC\r
+; added a check to see if cache is already disabled. If it is, then skip.\r
+    mov   rax, cr0\r
+    and   rax, 060000000h     \r
+    cmp   rax, 0\r
+    jne   @f\r
+    wbinvd\r
+    mov   rax, cr0\r
+    or    rax, 060000000h     \r
+    mov   cr0, rax\r
+@@:\r
+    ret\r
+EfiDisableCache ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiEnableCache (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiEnableCache PROC    PUBLIC\r
+    invd\r
+    mov   rax, cr0\r
+    and   rax, 09fffffffh         \r
+    mov   cr0, rax\r
+    ret\r
+EfiEnableCache ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EfiGetEflags (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiGetEflags PROC    PUBLIC\r
+    pushfq\r
+    pop   rax\r
+    ret\r
+EfiGetEflags  ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiDisableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiDisableInterrupts PROC    PUBLIC\r
+    cli\r
+    ret\r
+EfiDisableInterrupts  ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiEnableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiEnableInterrupts PROC    PUBLIC\r
+    sti\r
+    ret\r
+EfiEnableInterrupts  ENDP\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiCpuidExt (\r
+;    IN   UINT32              RegisterInEax,\r
+;    IN   UINT32              CacheLevel,\r
+;    OUT  EFI_CPUID_REGISTER  *Regs              \r
+;    )\r
+;------------------------------------------------------------------------------\r
+EfiCpuidExt PROC    PUBLIC\r
+     push   rbx\r
+     mov    rax, rcx          ; rax = RegisterInEax\r
+     mov    rcx, rdx          ; rcx = CacheLevel\r
+     \r
+     cpuid\r
+     mov    [r8 + 0 ],  eax   ; Reg->RegEax\r
+     mov    [r8 + 4 ],  ebx   ; Reg->RegEbx\r
+     mov    [r8 + 8 ],  ecx   ; Reg->RegEcx\r
+     mov    [r8 + 12],  edx   ; Reg->RegEdx\r
+    \r
+     pop rbx\r
+     ret\r
+EfiCpuidExt  ENDP\r
+END\r
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h
new file mode 100644 (file)
index 0000000..a7fe8b0
--- /dev/null
@@ -0,0 +1,372 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIA32.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _CPU_IA32_H\r
+#define _CPU_IA32_H\r
+\r
+#include "Tiano.h"\r
+\r
+#define IA32API __cdecl\r
+\r
+typedef struct {\r
+  UINT32  RegEax;\r
+  UINT32  RegEbx;\r
+  UINT32  RegEcx;\r
+  UINT32  RegEdx;\r
+} EFI_CPUID_REGISTER;\r
+\r
+typedef struct {\r
+  UINT32  HeaderVersion;\r
+  UINT32  UpdateRevision;\r
+  UINT32  Date;\r
+  UINT32  ProcessorId;\r
+  UINT32  Checksum;\r
+  UINT32  LoaderRevision;\r
+  UINT32  ProcessorFlags;\r
+  UINT32  DataSize;\r
+  UINT32  TotalSize;\r
+  UINT8   Reserved[12];\r
+} EFI_CPU_MICROCODE_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  ExtendedSignatureCount;\r
+  UINT32  ExtendedTableChecksum;  \r
+  UINT8   Reserved[12];\r
+} EFI_CPU_MICROCODE_EXTENDED_TABLE_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  ProcessorSignature;\r
+  UINT32  ProcessorFlag;\r
+  UINT32  ProcessorChecksum;\r
+} EFI_CPU_MICROCODE_EXTENDED_TABLE;\r
+\r
+typedef struct {\r
+  UINT32  Stepping       : 4;\r
+  UINT32  Model          : 4;\r
+  UINT32  Family         : 4;\r
+  UINT32  Type           : 2;\r
+  UINT32  Reserved1      : 2;\r
+  UINT32  ExtendedModel  : 4;\r
+  UINT32  ExtendedFamily : 8;\r
+  UINT32  Reserved2      : 4;\r
+} EFI_CPU_VERSION;\r
+\r
+#define EFI_CPUID_SIGNATURE                   0x0\r
+#define EFI_CPUID_VERSION_INFO                0x1\r
+#define EFI_CPUID_CACHE_INFO                  0x2\r
+#define EFI_CPUID_SERIAL_NUMBER               0x3\r
+#define EFI_CPUID_EXTENDED_FUNCTION           0x80000000\r
+#define EFI_CPUID_EXTENDED_CPU_SIG            0x80000001\r
+#define EFI_CPUID_BRAND_STRING1               0x80000002\r
+#define EFI_CPUID_BRAND_STRING2               0x80000003\r
+#define EFI_CPUID_BRAND_STRING3               0x80000004\r
+\r
+#define EFI_MSR_IA32_PLATFORM_ID              0x17\r
+#define EFI_MSR_IA32_APIC_BASE                0x1B\r
+#define EFI_MSR_EBC_HARD_POWERON              0x2A\r
+#define EFI_MSR_EBC_SOFT_POWERON              0x2B\r
+#define BINIT_DRIVER_DISABLE                  0x40\r
+#define INTERNAL_MCERR_DISABLE                0x20\r
+#define INITIATOR_MCERR_DISABLE               0x10\r
+#define EFI_MSR_EBC_FREQUENCY_ID              0x2C\r
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG           0x79\r
+#define EFI_MSR_IA32_BIOS_SIGN_ID             0x8B\r
+#define EFI_MSR_PSB_CLOCK_STATUS              0xCD\r
+#define EFI_APIC_GLOBAL_ENABLE                0x800\r
+#define EFI_MSR_IA32_MISC_ENABLE              0x1A0\r
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT         0x00400000\r
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT  0x00000008\r
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT      0x00000004\r
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002\r
+#define FAST_STRING_ENABLE_BIT                0x00000001\r
+\r
+#define EFI_CACHE_VARIABLE_MTRR_BASE          0x200\r
+#define EFI_CACHE_VARIABLE_MTRR_END           0x20F\r
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE          0x2FF\r
+#define EFI_CACHE_MTRR_VALID                  0x800\r
+#define EFI_CACHE_FIXED_MTRR_VALID            0x400\r
+#define EFI_CACHE_VALID_ADDRESS               0xFFFFFF000\r
+#define EFI_MSR_VALID_MASK                    0xFFFFFFFFF\r
+#define EFI_CACHE_VALID_EXTENDED_ADDRESS      0xFFFFFFFFFF000\r
+#define EFI_MSR_VALID_EXTENDED_MASK           0xFFFFFFFFFFFFF\r
+\r
+#define EFI_IA32_MTRR_FIX64K_00000            0x250\r
+#define EFI_IA32_MTRR_FIX16K_80000            0x258\r
+#define EFI_IA32_MTRR_FIX16K_A0000            0x259\r
+#define EFI_IA32_MTRR_FIX4K_C0000             0x268\r
+#define EFI_IA32_MTRR_FIX4K_C8000             0x269\r
+#define EFI_IA32_MTRR_FIX4K_D0000             0x26A\r
+#define EFI_IA32_MTRR_FIX4K_D8000             0x26B\r
+#define EFI_IA32_MTRR_FIX4K_E0000             0x26C\r
+#define EFI_IA32_MTRR_FIX4K_E8000             0x26D\r
+#define EFI_IA32_MTRR_FIX4K_F0000             0x26E\r
+#define EFI_IA32_MTRR_FIX4K_F8000             0x26F\r
+\r
+#define EFI_IA32_MCG_CAP                      0x179\r
+#define EFI_IA32_MCG_CTL                      0x17B\r
+#define EFI_IA32_MC0_CTL                      0x400\r
+#define EFI_IA32_MC0_STATUS                   0x401\r
+\r
+#define EFI_IA32_PERF_STATUS                  0x198\r
+#define EFI_IA32_PERF_CTL                     0x199\r
+\r
+#define EFI_CACHE_UNCACHEABLE                 0\r
+#define EFI_CACHE_WRITECOMBINING              1\r
+#define EFI_CACHE_WRITETHROUGH                4\r
+#define EFI_CACHE_WRITEPROTECTED              5\r
+#define EFI_CACHE_WRITEBACK                   6\r
+\r
+//\r
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number\r
+//\r
+#define EfiMakeCpuVersion(f, m, s)         \\r
+  (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))\r
+\r
+VOID\r
+IA32API\r
+EfiHalt (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                               \r
+Routine Description:                                                \r
+  Halt the Cpu    \r
+Arguments:                \r
+   None                                                          \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+VOID\r
+IA32API\r
+EfiWbinvd (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                               \r
+Routine Description:                                                \r
+  Write back and invalidate the Cpu cache\r
+Arguments:                \r
+   None                                                          \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+VOID\r
+IA32API\r
+EfiInvd (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Invalidate the Cpu cache\r
+Arguments:                \r
+   None                                                          \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+VOID\r
+IA32API\r
+EfiCpuid (\r
+  IN  UINT32                 RegisterInEax,\r
+  OUT EFI_CPUID_REGISTER     *Regs\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Get the Cpu info by excute the CPUID instruction\r
+Arguments:                \r
+   RegisterInEax: -The input value to put into register EAX\r
+   Regs:          -The Output value                      \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+\r
+VOID\r
+IA32API\r
+EfiCpuidExt (\r
+  IN  UINT32                 RegisterInEax,\r
+  IN  UINT32                 CacheLevel,\r
+  OUT EFI_CPUID_REGISTER     *Regs\r
+  )\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  When RegisterInEax != 4, the functionality is the same as EfiCpuid.\r
+  When RegisterInEax == 4, the function return the deterministic cache\r
+  parameters by excuting the CPUID instruction\r
+Arguments:                \r
+   RegisterInEax: - The input value to put into register EAX\r
+   CacheLevel:      - The deterministic cache level\r
+   Regs:          - The Output value                      \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+;\r
+\r
+UINT64\r
+IA32API\r
+EfiReadMsr (\r
+  IN UINT32     Index\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Read Cpu MSR\r
+Arguments:                \r
+  Index: -The index value to select the register\r
+                       \r
+Returns:                                                            \r
+   Return the read data                                                \r
+--*/\r
+VOID\r
+IA32API\r
+EfiWriteMsr (\r
+  IN UINT32     Index,\r
+  IN UINT64     Value\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Write Cpu MSR\r
+Arguments:                \r
+  Index: -The index value to select the register\r
+  Value: -The value to write to the selected register                      \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+UINT64\r
+IA32API\r
+EfiReadTsc (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Read Time stamp\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+   Return the read data                                                \r
+--*/\r
+VOID\r
+IA32API\r
+EfiDisableCache (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Writing back and invalidate the cache,then diable it\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+  None                                               \r
+--*/\r
+VOID\r
+IA32API\r
+EfiEnableCache (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Invalidate the cache,then Enable it\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+  None                                               \r
+--*/\r
+UINT32\r
+IA32API\r
+EfiGetEflags (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Get Eflags\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+  Return the Eflags value                                               \r
+--*/\r
+VOID\r
+IA32API\r
+EfiDisableInterrupts (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Disable Interrupts\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+  None\r
+--*/\r
+VOID\r
+IA32API\r
+EfiEnableInterrupts (\r
+  VOID\r
+  )\r
+;\r
+\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  Enable Interrupts\r
+Arguments:                \r
+  None                 \r
+Returns:                                                            \r
+  None                                               \r
+--*/\r
+\r
+\r
+VOID\r
+IA32API\r
+EfiCpuVersion (\r
+  IN   UINT16  *FamilyId,    OPTIONAL\r
+  IN   UINT8   *Model,       OPTIONAL\r
+  IN   UINT8   *SteppingId,  OPTIONAL\r
+  IN   UINT8   *Processor    OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract CPU detail version infomation\r
+\r
+Arguments:\r
+  FamilyId   - FamilyId, including ExtendedFamilyId\r
+  Model      - Model, including ExtendedModel\r
+  SteppingId - SteppingId\r
+  Processor  - Processor\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c
new file mode 100644 (file)
index 0000000..b39a173
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Acpi.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for ACPI entries in the EFI 1.0 system table\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (Acpi)\r
+\r
+EFI_GUID  gEfiAcpiTableGuid = EFI_ACPI_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpiTableGuid, "ACPI Table", "ACPI 1.0 Table GUID in EFI System Table");\r
+\r
+EFI_GUID  gEfiAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpi20TableGuid, "ACPI 2.0 Table", "ACPI 2.0 Table GUID in EFI System Table");\r
+\r
+EFI_GUID  gEfiAcpi30TableGuid = EFI_ACPI_30_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpi30TableGuid, "ACPI 3.0 Table", "ACPI 3.0 Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h
new file mode 100644 (file)
index 0000000..866ad63
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Acpi.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for ACPI entries in the in the EFI 1.0 system table\r
+\r
+  These GUIDs point the ACPI tables as defined in the ACPI specifications.\r
+  ACPI 2.0 specification defines the ACPI 2.0 GUID. EFI 1.0 defines the \r
+  ACPI 1.0 GUID.\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_GUID_H_\r
+#define _ACPI_GUID_H_\r
+\r
+#define EFI_ACPI_TABLE_GUID \\r
+  { \\r
+    0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+#define EFI_ACPI_20_TABLE_GUID \\r
+  { \\r
+    0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define EFI_ACPI_30_TABLE_GUID EFI_ACPI_20_TABLE_GUID\r
+\r
+extern EFI_GUID gEfiAcpiTableGuid;\r
+extern EFI_GUID gEfiAcpi20TableGuid;\r
+extern EFI_GUID gEfiAcpi30TableGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c
new file mode 100644 (file)
index 0000000..2afb834
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugImageInfoTable.c\r
+    \r
+Abstract:\r
+\r
+  GUID used to locate the Debug Image Info table in the EFI 1.0 system table.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (DebugImageInfoTable)\r
+\r
+EFI_GUID  gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiDebugImageInfoTableGuid, "Debug Image Info Table", "Debug Image Info Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h
new file mode 100644 (file)
index 0000000..e81ebb0
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                          \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugImageInfoTable.h\r
+    \r
+Abstract:\r
+\r
+  GUID and related data structures used with the Debug Image Info Table.\r
+\r
+--*/\r
+\r
+#ifndef _DEBUG_IMAGE_INFO_GUID_H_\r
+#define _DEBUG_IMAGE_INFO_GUID_H_\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)\r
+\r
+#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \\r
+  { \\r
+    0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b \\r
+  }\r
+\r
+extern EFI_GUID gEfiDebugImageInfoTableGuid;\r
+\r
+#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01\r
+#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED     0x02\r
+#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE       (EFI_PAGE_SIZE / sizeof (UINTN))\r
+#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL        0x01\r
+\r
+typedef struct {\r
+  UINT64                Signature;\r
+  EFI_PHYSICAL_ADDRESS  EfiSystemTableBase;\r
+  UINT32                Crc32;\r
+} EFI_SYSTEM_TABLE_POINTER;\r
+\r
+typedef struct {\r
+  UINT32                    ImageInfoType;\r
+  EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance;\r
+  EFI_HANDLE                *ImageHandle;\r
+} EFI_DEBUG_IMAGE_INFO_NORMAL;\r
+\r
+typedef union {\r
+  UINT32                      *ImageInfoType;\r
+  EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage;\r
+} EFI_DEBUG_IMAGE_INFO;\r
+\r
+typedef struct {  \r
+  volatile UINT32       UpdateStatus;\r
+  UINT32                TableSize;\r
+  EFI_DEBUG_IMAGE_INFO  *EfiDebugImageInfoTable;\r
+} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf b/EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf
new file mode 100644 (file)
index 0000000..cd43d9d
--- /dev/null
@@ -0,0 +1,59 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EfiGuidLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EfiGuidLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+  Acpi\Acpi.h\r
+  Acpi\Acpi.c\r
+  DebugImageInfoTable\DebugImageInfoTable.h\r
+  DebugImageInfoTable\DebugImageInfoTable.c\r
+  EventGroup\EventGroup.h\r
+  EventGroup\EventGroup.c\r
+  GlobalVariable\GlobalVariable.h\r
+  GlobalVariable\GlobalVariable.c\r
+  Gpt\Gpt.h\r
+  Gpt\Gpt.c\r
+  HardwareErrorVariable\HardwareErrorVariable.h\r
+  HardwareErrorVariable\HardwareErrorVariable.c\r
+  Mps\Mps.h\r
+  Mps\Mps.c\r
+  PcAnsi\PcAnsi.h\r
+  PcAnsi\PcAnsi.c\r
+  SmBios\SmBios.h\r
+  SmBios\SmBios.c\r
+[sources.ipf]\r
+  SalSystemTable\SalSystemTable.h\r
+  SalSystemTable\SalSystemTable.c\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c
new file mode 100644 (file)
index 0000000..fe8a53c
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiGroup.c\r
+    \r
+--*/\r
+#include "Tiano.h"\r
+\r
+#include EFI_GUID_DEFINITION (EventGroup)\r
+\r
+EFI_GUID gEfiEventExitBootServicesGuid = EFI_EVENT_GROUP_EXIT_BOOT_SERVICES;\r
+EFI_GUID gEfiEventVirtualAddressChangeGuid = EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE;\r
+EFI_GUID gEfiEventMemoryMapChangeGuid = EFI_EVENT_GROUP_MEMORY_MAP_CHANGE;\r
+EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT;\r
+\r
+EFI_GUID_STRING (&gEfiEventExitBootServicesGuid, "EventExitBS", "Event Exit Boot Service GUID");\r
+EFI_GUID_STRING (&gEfiEventVirtualAddressChangeGuid, "EventVirtualAddrChange", "Event Virtual Addr Change GUID");\r
+EFI_GUID_STRING (&gEfiEventMemoryMapChangeGuid, "EventMemMapChange", "Event Memory Map Change GUID");\r
+EFI_GUID_STRING (&gEfiEventReadyToBootGuid, "EventReadyToBoot", "Efi Ready To Boot GUID");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h
new file mode 100644 (file)
index 0000000..ac034a4
--- /dev/null
@@ -0,0 +1,45 @@
+/** @file\r
+       GUIDs for gBS->CreateEventEx Event Groups. Defined in UEFI 2.0.\r
+\r
+       Copyright (c) 2006, Intel Corporation                                                         \r
+       All rights reserved. This program and the accompanying materials                          \r
+       are licensed and made available under the terms and conditions of the BSD License         \r
+       which accompanies this distribution.  The full text of the license may be found at        \r
+       http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+       Module Name:    EventGroup.h\r
+\r
+**/\r
+\r
+#ifndef __EVENT_GROUP_GUID__\r
+#define __EVENT_GROUP_GUID__\r
+\r
+                                             \r
+#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \\r
+  { 0x27abf055, 0xb1b8, 0x4c26, { 0x80, 0x48, 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf } }\r
+\r
+extern EFI_GUID gEfiEventExitBootServicesGuid;\r
+\r
+\r
+#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \\r
+  { 0x13fa7698, 0xc831, 0x49c7, { 0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96 } }\r
+\r
+extern EFI_GUID gEfiEventVirtualAddressChangeGuid;\r
+\r
+\r
+#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \\r
+  { 0x78bee926, 0x692f, 0x48fd, { 0x9e, 0xdb, 0x1, 0x42, 0x2e, 0xf0, 0xd7, 0xab } }\r
+\r
+extern EFI_GUID gEfiEventMemoryMapChangeGuid;\r
+\r
+\r
+#define EFI_EVENT_GROUP_READY_TO_BOOT \\r
+  { 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } }\r
+\r
+extern EFI_GUID gEfiEventReadyToBootGuid;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c
new file mode 100644 (file)
index 0000000..1f492c7
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GlobalVariable.c\r
+    \r
+Abstract:\r
+\r
+  GUID for EFI (NVRAM) Variables. Defined in EFI 1.0.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (GlobalVariable)\r
+\r
+EFI_GUID  gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiGlobalVariableGuid, "Efi", "Efi Variable GUID")\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h
new file mode 100644 (file)
index 0000000..c97a51f
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GlobalVariable.h\r
+    \r
+Abstract:\r
+\r
+  GUID for EFI (NVRAM) Variables. Defined in EFI 1.0.\r
+\r
+--*/\r
+\r
+#ifndef _GLOBAL_VARIABLE_GUID_H_\r
+#define _GLOBAL_VARIABLE_GUID_H_\r
+\r
+#define EFI_GLOBAL_VARIABLE_GUID \\r
+  { \\r
+    0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C \\r
+  }\r
+\r
+extern EFI_GUID gEfiGlobalVariableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c
new file mode 100644 (file)
index 0000000..ffd432f
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Gpt.c\r
+    \r
+Abstract:\r
+\r
+  Guids used for the GPT as defined in EFI 1.0\r
+\r
+  GPT defines a new disk partitioning scheme and also describes \r
+  usage of the legacy Master Boot Record (MBR) partitioning scheme. \r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (Gpt)\r
+\r
+EFI_GUID  gEfiPartTypeUnusedGuid = EFI_PART_TYPE_UNUSED_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPartTypeUnusedGuid, "G0", "Null Partition Type GUID");\r
+\r
+EFI_GUID  gEfiPartTypeSystemPartGuid = EFI_PART_TYPE_EFI_SYSTEM_PART_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPartTypeSystemPartGuid, "ESP", "EFI System Partition GUID");\r
+\r
+EFI_GUID  gEfiPartTypeLegacyMbrGuid = EFI_PART_TYPE_LEGACY_MBR_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPartTypeLegacyMbrGuid, "Legacy MBR", "Legacy Master Boot Record Partition GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h
new file mode 100644 (file)
index 0000000..7733067
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Gpt.h\r
+    \r
+Abstract:\r
+\r
+  Guids used for the GPT as defined in EFI 1.0\r
+\r
+  GPT defines a new disk partitioning scheme and also describes \r
+  usage of the legacy Master Boot Record (MBR) partitioning scheme. \r
+\r
+--*/\r
+\r
+#ifndef _GPT_GUID_H_\r
+#define _GPT_GUID_H_\r
+\r
+#define EFI_PART_TYPE_UNUSED_GUID \\r
+  { \\r
+    0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \\r
+  }\r
+\r
+#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \\r
+  { \\r
+    0xc12a7328, 0xf81f, 0x11d2, 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b \\r
+  }\r
+\r
+#define EFI_PART_TYPE_LEGACY_MBR_GUID \\r
+  { \\r
+    0x024dee41, 0x33e7, 0x11d3, 0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f \\r
+  }\r
+\r
+extern EFI_GUID gEfiPartTypeUnusedGuid;\r
+extern EFI_GUID gEfiPartTypeSystemPartGuid;\r
+extern EFI_GUID gEfiPartTypeLegacyMbrGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c
new file mode 100644 (file)
index 0000000..57dbb83
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HardwareErrorVariable.c\r
+\r
+Abstract:\r
+\r
+  GUID for hardware error record variables. Defined in UEFI 2.1.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (HardwareErrorVariable)\r
+\r
+EFI_GUID  gEfiHardwareErrorVariableGuid = EFI_HARDWARE_ERROR_VARIABLE_GUID;\r
+\r
+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 (file)
index 0000000..fae3fd1
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HardwareErrorVariable.h\r
+\r
+Abstract:\r
+\r
+  GUID for hardware error record variables. Defined in UEFI 2.1.\r
+\r
+--*/\r
+\r
+#ifndef _HARDWARE_ERROR_VARIABLE_GUID_H_\r
+#define _HARDWARE_ERROR_VARIABLE_GUID_H_\r
+\r
+#define EFI_HARDWARE_ERROR_VARIABLE_GUID \\r
+  { \\r
+    0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16} \\r
+  }\r
+\r
+extern EFI_GUID gEfiHardwareErrorVariableGuid;\r
+\r
+#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 (file)
index 0000000..b645562
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Mps.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for MPS entries in the in the EFI 1.0 system table\r
+\r
+  These GUIDs point the MPS tables as defined in the MPS 1.4 specifications.\r
+\r
+  ACPI is the primary means of exporting MP information to the OS. MPS obly was\r
+  included to support Itanium-based platform power on. So don't use it if you don't have too.\r
+\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (Mps)\r
+\r
+EFI_GUID  gEfiMpsTableGuid = EFI_MPS_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiMpsTableGuid, "MPS Table", "MPS Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h
new file mode 100644 (file)
index 0000000..3417c69
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Mps.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for MPS entries in the in the EFI 1.0 system table\r
+\r
+  These GUIDs point the MPS tables as defined in the MPS 1.4 specifications.\r
+\r
+  ACPI is the primary means of exporting MP information to the OS. MPS obly was\r
+  included to support Itanium-based platform power on. So don't use it if you don't have too.\r
+\r
+\r
+--*/\r
+\r
+#ifndef _MPS_GUID_H_\r
+#define _MPS_GUID_H_\r
+\r
+#define EFI_MPS_TABLE_GUID \\r
+  { \\r
+    0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+extern EFI_GUID gEfiMpsTableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c
new file mode 100644 (file)
index 0000000..76132fb
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SalSystemTable.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for SAL system table entries in the in the EFI 1.0 system table.\r
+\r
+  SAL System Table contains Itanium-based processor centric information about\r
+  the system.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (SalSystemTable)\r
+\r
+EFI_GUID  gEfiSalSystemTableGuid = EFI_SAL_SYSTEM_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSalSystemTableGuid, "SAL System Table", "SAL System Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h
new file mode 100644 (file)
index 0000000..1bc0c72
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SalSystemTable.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for SAL system table entries in the in the EFI 1.0 system table.\r
+\r
+  SAL System Table contains Itanium-based processor centric information about\r
+  the system.\r
+\r
+--*/\r
+\r
+#ifndef _SAL_SYSTEM_TABLE_GUID_H_\r
+\r
+#define EFI_SAL_SYSTEM_TABLE_GUID \\r
+  { \\r
+    0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+extern EFI_GUID gEfiSalSystemTableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c
new file mode 100644 (file)
index 0000000..a7db5a2
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SmBios.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table.\r
+\r
+  This GUID in the system table is the only legal way to search for and \r
+  locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS\r
+  tables.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (Smbios)\r
+\r
+EFI_GUID  gEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmbiosTableGuid, "SMBIOS Table", "SMBIOS Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h
new file mode 100644 (file)
index 0000000..4d53bb3
--- /dev/null
@@ -0,0 +1,70 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SmBios.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table.\r
+\r
+  This GUID in the system table is the only legal way to search for and \r
+  locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS\r
+  tables.\r
+\r
+--*/\r
+\r
+#ifndef _SMBIOS_GUID_H_\r
+#define _SMBIOS_GUID_H_\r
+\r
+#define EFI_SMBIOS_TABLE_GUID \\r
+  { \\r
+    0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+extern EFI_GUID gEfiSmbiosTableGuid;\r
+\r
+//\r
+// Smbios Table Entry Point Structure\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8   AnchorString[4];\r
+  UINT8   EntryPointStructureChecksum;\r
+  UINT8   EntryPointLength;\r
+  UINT8   MajorVersion;\r
+  UINT8   MinorVersion;\r
+  UINT16  MaxStructureSize;\r
+  UINT8   EntryPointRevision;\r
+  UINT8   FormattedArea[5];\r
+  UINT8   IntermediateAnchorString[5];\r
+  UINT8   IntermediateChecksum;\r
+  UINT16  TableLength;\r
+  UINT32  TableAddress;\r
+  UINT16  NumberOfSmbiosStructures;\r
+  UINT8   SmbiosBcdRevision;\r
+} SMBIOS_TABLE_ENTRY_POINT;\r
+#pragma pack()\r
+//\r
+// The Smbios structure header\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Handle;\r
+\r
+} SMBIOS_STRUCTURE;\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c
new file mode 100644 (file)
index 0000000..b3fe35f
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PcAnsi.c\r
+    \r
+Abstract:\r
+\r
+  Terminal Device Path Vendor Guid. Defined in EFI 1.0.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+\r
+#include EFI_GUID_DEFINITION (PcAnsi)\r
+\r
+EFI_GUID  gEfiPcAnsiGuid    = EFI_PC_ANSI_GUID;\r
+EFI_GUID  gEfiVT100Guid     = EFI_VT_100_GUID;\r
+EFI_GUID  gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID;\r
+EFI_GUID  gEfiVTUTF8Guid    = EFI_VT_UTF8_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPcAnsiGuid, "Efi", "Efi PC ANSI Device Path Vendor GUID")\r
+EFI_GUID_STRING(&gEfiVT100Guid, "Efi", "Efi VT100 Device Path Vendor GUID")\r
+EFI_GUID_STRING(&gEfiVT100PlusGuid, "Efi", "Efi VT100Plus Device Path Vendor GUID")\r
+EFI_GUID_STRING(&gEfiVTUTF8Guid, "Efi", "Efi VTUTF8 Device Path Vendor GUID")\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h
new file mode 100644 (file)
index 0000000..6113690
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PcAnsi.h\r
+    \r
+Abstract:\r
+\r
+  Terminal Device Path Vendor Guid. Defined in EFI 1.0.\r
+\r
+--*/\r
+\r
+#ifndef _PC_ANSI_H_\r
+#define _PC_ANSI_H_\r
+\r
+#define EFI_PC_ANSI_GUID \\r
+  { \\r
+    0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+#define EFI_VT_100_GUID \\r
+  { \\r
+    0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+#define EFI_VT_100_PLUS_GUID \\r
+  { \\r
+    0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 \\r
+  }\r
+\r
+#define EFI_VT_UTF8_GUID \\r
+  { \\r
+    0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 \\r
+  }\r
+\r
+extern EFI_GUID gEfiPcAnsiGuid;\r
+extern EFI_GUID gEfiVT100Guid;\r
+extern EFI_GUID gEfiVT100PlusGuid;\r
+extern EFI_GUID gEfiVTUTF8Guid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h
new file mode 100644 (file)
index 0000000..87ecd7b
--- /dev/null
@@ -0,0 +1,1114 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiApi.h\r
+\r
+Abstract:\r
+\r
+  EFI intrinsic definitions. This includes all EFI 1.0 boot and runtime\r
+  services APIs.\r
+\r
+  Drivers and applications are passed in a pointer to the EFI system table.\r
+  The EFI system table contains pointers to the boot and runtime services\r
+  tables.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_API_H_\r
+#define _EFI_API_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#include "EfiCapsule.h"\r
+#else\r
+#include "EfiStatusCode.h"\r
+#endif\r
+\r
+//\r
+// Declare forward referenced data structures\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_SYSTEM_TABLE);\r
+\r
+//\r
+// EFI Memory\r
+//\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ALLOCATE_PAGES) (\r
+  IN EFI_ALLOCATE_TYPE            Type,\r
+  IN EFI_MEMORY_TYPE              MemoryType,\r
+  IN UINTN                        NoPages,\r
+  OUT EFI_PHYSICAL_ADDRESS        * Memory\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_FREE_PAGES) (\r
+  IN EFI_PHYSICAL_ADDRESS         Memory,\r
+  IN UINTN                        NoPages\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_MEMORY_MAP) (\r
+  IN OUT UINTN                    *MemoryMapSize,\r
+  IN OUT EFI_MEMORY_DESCRIPTOR    * MemoryMap,\r
+  OUT UINTN                       *MapKey,\r
+  OUT UINTN                       *DescriptorSize,\r
+  OUT UINT32                      *DescriptorVersion\r
+  );\r
+\r
+#define NextMemoryDescriptor(_Ptr, _Size)   ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) (_Ptr)) + (_Size)))\r
+#define NEXT_MEMORY_DESCRIPTOR(_Ptr, _Size) NextMemoryDescriptor (_Ptr, _Size)\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ALLOCATE_POOL) (\r
+  IN EFI_MEMORY_TYPE              PoolType,\r
+  IN UINTN                        Size,\r
+  OUT VOID                        **Buffer\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_FREE_POOL) (\r
+  IN VOID                         *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (\r
+  IN UINTN                        MemoryMapSize,\r
+  IN UINTN                        DescriptorSize,\r
+  IN UINT32                       DescriptorVersion,\r
+  IN EFI_MEMORY_DESCRIPTOR        * VirtualMap\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_CONNECT_CONTROLLER) (\r
+  IN  EFI_HANDLE                    ControllerHandle,\r
+  IN  EFI_HANDLE                    * DriverImageHandle OPTIONAL,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      * RemainingDevicePath OPTIONAL,\r
+  IN  BOOLEAN                       Recursive\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISCONNECT_CONTROLLER) (\r
+  IN EFI_HANDLE                              ControllerHandle,\r
+  IN EFI_HANDLE                              DriverImageHandle, OPTIONAL\r
+  IN EFI_HANDLE                              ChildHandle        OPTIONAL\r
+  );\r
+\r
+//\r
+// ConvertPointer DebugDisposition type.\r
+//\r
+#define EFI_OPTIONAL_POINTER  0x00000001\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CONVERT_POINTER) (\r
+  IN UINTN                        DebugDisposition,\r
+  IN OUT VOID                     **Address\r
+  );\r
+\r
+//\r
+// EFI Event Types\r
+//\r
+#define EFI_EVENT_TIMER                         0x80000000\r
+#define EFI_EVENT_RUNTIME                       0x40000000\r
+#define EFI_EVENT_RUNTIME_CONTEXT               0x20000000\r
+\r
+#define EFI_EVENT_NOTIFY_WAIT                   0x00000100\r
+#define EFI_EVENT_NOTIFY_SIGNAL                 0x00000200\r
+\r
+#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES     0x00000201\r
+#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202\r
+\r
+#define EFI_EVENT_EFI_SIGNAL_MASK               0x000000FF\r
+#define EFI_EVENT_EFI_SIGNAL_MAX                4\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_EVENT_NOTIFY) (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CREATE_EVENT) (\r
+  IN UINT32                       Type,\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   * Event\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CREATE_EVENT_EX) (\r
+  IN UINT32                 Type,\r
+  IN EFI_TPL                NotifyTpl      OPTIONAL,\r
+  IN EFI_EVENT_NOTIFY       NotifyFunction OPTIONAL,\r
+  IN CONST VOID             *NotifyContext OPTIONAL,\r
+  IN CONST EFI_GUID         *EventGroup    OPTIONAL,\r
+  OUT EFI_EVENT             *Event\r
+  );\r
+\r
+typedef enum {\r
+  TimerCancel,\r
+  TimerPeriodic,\r
+  TimerRelative,\r
+  TimerTypeMax\r
+} EFI_TIMER_DELAY;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_TIMER) (\r
+  IN EFI_EVENT                Event,\r
+  IN EFI_TIMER_DELAY          Type,\r
+  IN UINT64                   TriggerTime\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIGNAL_EVENT) (\r
+  IN EFI_EVENT                Event\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_WAIT_FOR_EVENT) (\r
+  IN UINTN                    NumberOfEvents,\r
+  IN EFI_EVENT                * Event,\r
+  OUT UINTN                   *Index\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLOSE_EVENT) (\r
+  IN EFI_EVENT                Event\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CHECK_EVENT) (\r
+  IN EFI_EVENT                Event\r
+  );\r
+\r
+//\r
+// Task priority level\r
+//\r
+#define EFI_TPL_APPLICATION 4\r
+#define EFI_TPL_CALLBACK    8\r
+#define EFI_TPL_NOTIFY      16\r
+#define EFI_TPL_HIGH_LEVEL  31\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_TPL\r
+(EFIAPI *EFI_RAISE_TPL) (\r
+  IN EFI_TPL      NewTpl\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+VOID\r
+(EFIAPI *EFI_RESTORE_TPL) (\r
+  IN EFI_TPL      OldTpl\r
+  );\r
+\r
+//\r
+// Variable attributes\r
+//\r
+#define EFI_VARIABLE_NON_VOLATILE       0x00000001\r
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002\r
+#define EFI_VARIABLE_RUNTIME_ACCESS     0x00000004\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008\r
+#endif\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_VARIABLE) (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 * VendorGuid\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_VARIABLE) (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  );\r
+\r
+//\r
+// EFI Time\r
+//\r
+typedef struct {\r
+  UINT32  Resolution;\r
+  UINT32  Accuracy;\r
+  BOOLEAN SetsToZero;\r
+} EFI_TIME_CAPABILITIES;\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_TIME) (\r
+  OUT EFI_TIME                    * Time,\r
+  OUT EFI_TIME_CAPABILITIES       * Capabilities OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_TIME) (\r
+  IN EFI_TIME                     * Time\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_WAKEUP_TIME) (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    * Time\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_WAKEUP_TIME) (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     * Time OPTIONAL\r
+  );\r
+\r
+//\r
+// Image Entry prototype\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IMAGE_ENTRY_POINT) (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN EFI_SYSTEM_TABLE             * SystemTable\r
+  );\r
+\r
+//\r
+// Image functions\r
+//\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_IMAGE_LOAD) (\r
+  IN BOOLEAN                      BootPolicy,\r
+  IN EFI_HANDLE                   ParentImageHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * FilePath,\r
+  IN VOID                         *SourceBuffer OPTIONAL,\r
+  IN UINTN                        SourceSize,\r
+  OUT EFI_HANDLE                  * ImageHandle\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_IMAGE_START) (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  OUT UINTN                       *ExitDataSize,\r
+  OUT CHAR16                      **ExitData OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXIT) (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN EFI_STATUS                   ExitStatus,\r
+  IN UINTN                        ExitDataSize,\r
+  IN CHAR16                       *ExitData OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_IMAGE_UNLOAD) (\r
+  IN EFI_HANDLE                   ImageHandle\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXIT_BOOT_SERVICES) (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN UINTN                        MapKey\r
+  );\r
+\r
+//\r
+// Misc\r
+//\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_STALL) (\r
+  IN UINTN                    Microseconds\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_WATCHDOG_TIMER) (\r
+  IN UINTN                    Timeout,\r
+  IN UINT64                   WatchdogCode,\r
+  IN UINTN                    DataSize,\r
+  IN CHAR16                   *WatchdogData OPTIONAL\r
+  );\r
+\r
+typedef enum {\r
+  EfiResetCold,\r
+  EfiResetWarm,\r
+  EfiResetShutdown,\r
+\r
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
+  EfiResetUpdate\r
+#endif\r
+\r
+} EFI_RESET_TYPE;\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+VOID\r
+(EFIAPI *EFI_RESET_SYSTEM) (\r
+  IN EFI_RESET_TYPE           ResetType,\r
+  IN EFI_STATUS               ResetStatus,\r
+  IN UINTN                    DataSize,\r
+  IN CHAR16                   *ResetData OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (\r
+  OUT UINT64                  *Count\r
+  );\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (\r
+  OUT UINT32                  *HighCount\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_CALCULATE_CRC32) (\r
+  IN  VOID                              *Data,\r
+  IN  UINTN                             DataSize,\r
+  OUT UINT32                            *Crc32\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+VOID\r
+(EFIAPI *EFI_COPY_MEM) (\r
+  IN VOID     *Destination,\r
+  IN VOID     *Source,\r
+  IN UINTN    Length\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+VOID\r
+(EFIAPI *EFI_SET_MEM) (\r
+  IN VOID     *Buffer,\r
+  IN UINTN    Size,\r
+  IN UINT8    Value\r
+  );\r
+\r
+//\r
+// Protocol handler functions\r
+//\r
+typedef enum {\r
+  EFI_NATIVE_INTERFACE\r
+} EFI_INTERFACE_TYPE;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (\r
+  IN OUT EFI_HANDLE           * Handle,\r
+  IN EFI_GUID                 * Protocol,\r
+  IN EFI_INTERFACE_TYPE       InterfaceType,\r
+  IN VOID                     *Interface\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (\r
+  IN OUT EFI_HANDLE           * Handle,\r
+  ...\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (\r
+  IN EFI_HANDLE               Handle,\r
+  IN EFI_GUID                 * Protocol,\r
+  IN VOID                     *OldInterface,\r
+  IN VOID                     *NewInterface\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (\r
+  IN EFI_HANDLE               Handle,\r
+  IN EFI_GUID                 * Protocol,\r
+  IN VOID                     *Interface\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (\r
+  IN EFI_HANDLE           Handle,\r
+  ...\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_HANDLE_PROTOCOL) (\r
+  IN EFI_HANDLE               Handle,\r
+  IN EFI_GUID                 * Protocol,\r
+  OUT VOID                    **Interface\r
+  );\r
+\r
+#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001\r
+#define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002\r
+#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004\r
+#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008\r
+#define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010\r
+#define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020\r
+\r
+//\r
+// ///////////////////////////////////////////////////////////////////////////////////////////////\r
+// OpenProtocol() Attribute Values\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// BY_HANDLE_PROTOCOL    - Used by EFI 1.0 Drivers and Applications\r
+//                         May not actually add an elemnt to the open list in a production build\r
+//\r
+// GET_PROTOCOL          - Used by EFI 1.1 Drivers to get a protocol interface\r
+//                         May not actually add an elemnt to the open list in a production build\r
+//\r
+// TEST_PROTOCOL         - Used by EFI 1.1 Drivers to test for the existence of a protocol interface\r
+//                         The interface is not returned, and it is an optional parameter tham may be NULL.\r
+//                         May not actually add an elemnt to the open list in a production build\r
+//\r
+// BY_DRIVER             - Used by EFI 1.1 Drivers that are able to share a protocol with other\r
+//                         agents other than its children.  A driver is always able to share\r
+//                         a protocol with its children, since the driver is in control of the\r
+//                         parent controller's and the child controller's use of the protocol.\r
+//\r
+// BY_DRIVER | EXCLUSIVE - Used by EFI 1.1 Drivers that will not share a protocol with any other\r
+//                         agents except its children.  A driver is always able to share\r
+//                         a protocol with its children, since the driver is in control of the\r
+//                         parent controller's and the child controller's use of the protocol.\r
+//                         This attribute will force all other drivers to disconnect from the protocol\r
+//                         before this driver attaches.  When this driver closes the handle, the other\r
+//                         drivers will reconnect to the protocol.\r
+//\r
+//\r
+// BY_CHILD_CONTROLLER   - Used by EFI 1.1 Driver to show that a protocol is consumed by a child\r
+//                         of the driver.  This is information used by DisconnectController() to\r
+//                         determine the list of children that a protocol has.  It has\r
+//                         no affect on the OpenProtocol()/ClosePrototocol() behavior.\r
+//\r
+// EXCLUSIVE             - Used by EFI 1.1 Applications to gain exclusive access to a protocol.\r
+//                         All drivers are disconnected from the handle while the application has\r
+//                         the handle open.  These drivers are reconnected when the application\r
+//                         closes the handle.\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// OpenProtocol() behavior based on Attribute values\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// OpenProtocol (Handle, Protocol, Interface, ImageHandle, DeviceHandle, Attributes)\r
+// * EFI_UNSUPPORTED        if Protocol does not exist on Handle\r
+// * EFI_INVALID_PARAMETER  if Handle is not a valid handle.\r
+// * EFI_INVALID_PARAMETER  if Protocol is NULL or not a valid GUID\r
+// * EFI_INVALID_PARAMETER  if Interface is NULL\r
+// * EFI_INVALID_PARAMETER  if Attributes is not one of the following values:\r
+//                            BY_HANDLE_PROTOCOL\r
+//                            GET_PROTOCOL\r
+//                            TEST_PROTOCOL\r
+//                            BY_CHILD_CONTROLLER\r
+//                            BY_DRIVER\r
+//                            BY_DRIVER | EXCLUSIVE\r
+//                            EXCLUSIVE\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_CHILD_CONTROLLER and ImageHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_CHILD_CONTROLLER and DeviceHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_CHILD_CONTROLLER and Handle == DeviceHandle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_DRIVER and ImageHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_DRIVER and DeviceHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_DRIVER | EXCLUSIVE and ImageHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes BY_DRIVER | EXCLUSIVE and DeviceHandle is not a valid handle\r
+// * EFI_INVALID_PARAMETER  if Attributes EXCLUSIVE and ImageHandle is not a valid handle\r
+//\r
+// OpenProtocol() Attributes = BY_HANDLE_PROTOCOL, GET_PROTOCOL, TEST_PROTOCOL, BY_CHILD_CONTROLLER\r
+// * EFI_SUCCESS      if Protocol exists on the Handle\r
+//\r
+// OpenProtocol() Attributes = BY_DRIVER\r
+// * EFI_SUCCESS        if there are no items in the Open List for (Handle, Protocol)\r
+// * EFI_SUCCESS        if there are only items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_HANDLE_PROTOCOL\r
+//                        GET_PROTOCOL\r
+//                        TEST_PROTOCOL\r
+//                        BY_CHILD_CONTROLLER\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER\r
+//                      AND ImageHandle != OpenListItem.IH\r
+// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol)\r
+//                       that have the one of the following Attributes\r
+//                         BY_DRIVER\r
+//                       AND ImageHandle == OpenListItem.IH\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER | EXCLUSIVE\r
+//                        EXCLUSIVE\r
+//\r
+// OpenProtocol() Attributes = BY_DRIVER | EXCLUSIVE\r
+// * EFI_SUCCESS        if there are no items in the Open List for (Handle, Protocol)\r
+// * EFI_SUCCESS        if there are only items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_HANDLE_PROTOCOL\r
+//                        GET_PROTOCOL\r
+//                        TEST_PROTOCOL\r
+//                        BY_CHILD_CONTROLLER\r
+// * EFI_SUCCESS        if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER\r
+//                      AND the driver is removed by DisconnectController(IH,DH)\r
+// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol)\r
+//                       that have the one of the following Attributes\r
+//                         BY_DRIVER | EXCLUSIVE\r
+//                       AND ImageHandle == OpenListItem.IH\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER\r
+//                      AND the driver can not be removed by DisconnectController(IH,DH)\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER | EXCLUSIVE\r
+//                        EXCLUSIVE\r
+//\r
+// OpenProtocol() Attributes = EXCLUSIVE\r
+// * EFI_SUCCESS        if there are no items in the Open List for (Handle, Protocol)\r
+// * EFI_SUCCESS        if there are only items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_HANDLE_PROTOCOL\r
+//                        GET_PROTOCOL\r
+//                        TEST_PROTOCOL\r
+//                        BY_CHILD_CONTROLLER\r
+// * EFI_SUCCESS        if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER\r
+//                      AND the driver is removed by DisconnectController(IH,DH)\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER\r
+//                      AND the driver can not be removed by DisconnectController(IH,DH)\r
+// * EFI_ACCESS_DENIED  if there are any items in the Open List for (Handle, Protocol)\r
+//                      that have the one of the following Attributes\r
+//                        BY_DRIVER | EXCLUSIVE\r
+//                        EXCLUSIVE\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// CloseProtocol() Behavior based on the Attributes of the item being closed and the items\r
+//                 remaining on the Open List\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// CloseProtocol(Handle, Protocol, ImageHandle, DeviceHandle)\r
+// CloseProtocol() Attributes of item = BY_HANDLE_PROTOCOL,\r
+//                                      GET_PROTOCOL\r
+//                                      TEST_PROTOCOL\r
+//                                      BY_CHILD_CONTROLLER,\r
+//                                      BY_DRIVER\r
+//                                      BY_DRIVER | EXCLUSIVE\r
+//                                      EXCLUSIVE\r
+//   EFI_NOT_FOUND          if Protocol does not exist on Handle\r
+//   EFI_INVALID_PARAMETER  if Handle is not a valid handle.\r
+//   EFI_INVALID_PARAMETER  if Protocol is NULL or not a valid GUID\r
+//   EFI_INVALID_PARAMETER  if ImageHandle is not a valid handle\r
+//   EFI_INVALID_PARAMETER  if DeviceHandle is not a valid handle\r
+//   EFI_NOT_FOUND      if (ImageHandle, DeviceHandle) is not present in the Open List\r
+//                      for (Handle, Protocol)\r
+//   EFI_ACCESS_DENIED  if (ImageHandle, DeviceHandle) is present in the Open List\r
+//                      for (Handle, Protocol), but the item can not be removed.\r
+//   EFI_SUCCESS        if (ImageHandle, DeviceHandle) is present in the Open List\r
+//                      for (Handle, Protocol), and the item can be removed.\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+// UninstallProtocolInterface() behavior\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// UninstallProtocolInterface (Handle, Protocol, Interface)\r
+//\r
+//   EFI_INVALID_PARAMETER if Handle is not a valid handle.\r
+//   EFI_INVALID_PARAMETER if Protocol is not a vlaid GUID\r
+//   EFI_NOT_FOUND         if Handle doe not support Protocol\r
+//   EFI_NOT_FOUND         if the interface for (Handle, Protocol) does not match Interface\r
+//   EFI_ACCESS_DENIED     if the list of Open Items for (Handle, Protocol) can not be removed\r
+//   EFI_SUCCESS           if the list of Open Items is empty, and Protocol is removed from Handle\r
+//\r
+// Algorithm to remove Open Item List:\r
+//\r
+// Loop through all Open Item List entries\r
+//   if (OpenItem.Attributes & BY_DRIVER) then\r
+//     DisconnectController (OpenItem.IH, OpenItem.DH)\r
+//   end if\r
+// end loop\r
+// Loop through all Open Item List entries\r
+//   if (OpenItem.Attributes & BY_HANDLE_PROTOCOL or GET_PROTOCOL or TEST_PROTOCOL) then\r
+//     CloseProtocol (Handle, Protocol, OpenItem.IH, OpenItem.DH)\r
+//   end if\r
+// end loop\r
+// if Open Item List is empty then remove Protocol from Handle and return EFI_SUCCESS\r
+// if Open Item List is not empty then return EFI_ACCESS_DENIED\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////////////\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_OPEN_PROTOCOL) (\r
+  IN EFI_HANDLE                 Handle,\r
+  IN EFI_GUID                   * Protocol,\r
+  OUT VOID                      **Interface,\r
+  IN  EFI_HANDLE                ImageHandle,\r
+  IN  EFI_HANDLE                ControllerHandle, OPTIONAL\r
+  IN  UINT32                    Attributes\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLOSE_PROTOCOL) (\r
+  IN EFI_HANDLE               Handle,\r
+  IN EFI_GUID                 * Protocol,\r
+  IN EFI_HANDLE               ImageHandle,\r
+  IN EFI_HANDLE               DeviceHandle\r
+  );\r
+\r
+typedef struct {\r
+  EFI_HANDLE  AgentHandle;\r
+  EFI_HANDLE  ControllerHandle;\r
+  UINT32      Attributes;\r
+  UINT32      OpenCount;\r
+} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (\r
+  IN  EFI_HANDLE                          UserHandle,\r
+  IN  EFI_GUID                            * Protocol,\r
+  IN  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,\r
+  OUT UINTN                               *EntryCount\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (\r
+  IN EFI_HANDLE       UserHandle,\r
+  OUT EFI_GUID        ***ProtocolBuffer,\r
+  OUT UINTN           *ProtocolBufferCount\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (\r
+  IN EFI_GUID                 * Protocol,\r
+  IN EFI_EVENT                Event,\r
+  OUT VOID                    **Registration\r
+  );\r
+\r
+typedef enum {\r
+  AllHandles,\r
+  ByRegisterNotify,\r
+  ByProtocol\r
+} EFI_LOCATE_SEARCH_TYPE;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_LOCATE_HANDLE) (\r
+  IN EFI_LOCATE_SEARCH_TYPE   SearchType,\r
+  IN EFI_GUID                 * Protocol OPTIONAL,\r
+  IN VOID                     *SearchKey OPTIONAL,\r
+  IN OUT UINTN                *BufferSize,\r
+  OUT EFI_HANDLE              * Buffer\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_LOCATE_DEVICE_PATH) (\r
+  IN EFI_GUID                         * Protocol,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL     **DevicePath,\r
+  OUT EFI_HANDLE                      * Device\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (\r
+  IN EFI_GUID                 * Guid,\r
+  IN VOID                     *Table\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_RESERVED_SERVICE) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (\r
+  IN EFI_LOCATE_SEARCH_TYPE       SearchType,\r
+  IN EFI_GUID                     * Protocol OPTIONAL,\r
+  IN VOID                         *SearchKey OPTIONAL,\r
+  IN OUT UINTN                    *NumberHandles,\r
+  OUT EFI_HANDLE                  **Buffer\r
+  );\r
+\r
+typedef\r
+EFI_BOOTSERVICE11\r
+EFI_STATUS\r
+(EFIAPI *EFI_LOCATE_PROTOCOL) (\r
+  EFI_GUID  * Protocol,\r
+  VOID      *Registration, OPTIONAL\r
+  VOID      **Interface\r
+  );\r
+\r
+//\r
+// Definition of Status Code extended data header\r
+//\r
+//  HeaderSize    The size of the architecture. This is specified to enable\r
+//                the future expansion\r
+//\r
+//  Size          The size of the data in bytes. This does not include the size\r
+//                of the header structure.\r
+//\r
+//  Type          A GUID defining the type of the data\r
+//\r
+//\r
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_REPORT_STATUS_CODE) (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  );\r
+\r
+#endif\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_UPDATE_CAPSULE) (\r
+  IN EFI_CAPSULE_HEADER     **CapsuleHeaderArray,\r
+  IN UINTN                  CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS   ScatterGatherList OPTIONAL\r
+ );\r
+\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (\r
+  IN  EFI_CAPSULE_HEADER   **CapsuleHeaderArray,\r
+  IN  UINTN                CapsuleCount,\r
+  OUT UINT64               *MaxiumCapsuleSize,\r
+  OUT EFI_RESET_TYPE       *ResetType\r
+);\r
+\r
+typedef\r
+EFI_RUNTIMESERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_QUERY_VARIABLE_INFO) (\r
+  IN UINT32           Attributes,\r
+  OUT UINT64          *MaximumVariableStorageSize,\r
+  OUT UINT64          *RemainingVariableStorageSize,\r
+  OUT UINT64          *MaximumVariableSize\r
+  );\r
+\r
+#endif\r
+\r
+//\r
+// EFI Runtime Services Table\r
+//\r
+#define EFI_RUNTIME_SERVICES_SIGNATURE  0x56524553544e5552\r
+#define EFI_RUNTIME_SERVICES_REVISION   EFI_SPECIFICATION_VERSION\r
+\r
+typedef struct {\r
+  EFI_TABLE_HEADER              Hdr;\r
+\r
+  //\r
+  // Time services\r
+  //\r
+  EFI_GET_TIME                  GetTime;\r
+  EFI_SET_TIME                  SetTime;\r
+  EFI_GET_WAKEUP_TIME           GetWakeupTime;\r
+  EFI_SET_WAKEUP_TIME           SetWakeupTime;\r
+\r
+  //\r
+  // Virtual memory services\r
+  //\r
+  EFI_SET_VIRTUAL_ADDRESS_MAP   SetVirtualAddressMap;\r
+  EFI_CONVERT_POINTER           ConvertPointer;\r
+\r
+  //\r
+  // Variable services\r
+  //\r
+  EFI_GET_VARIABLE              GetVariable;\r
+  EFI_GET_NEXT_VARIABLE_NAME    GetNextVariableName;\r
+  EFI_SET_VARIABLE              SetVariable;\r
+\r
+  //\r
+  // Misc\r
+  //\r
+  EFI_GET_NEXT_HIGH_MONO_COUNT  GetNextHighMonotonicCount;\r
+  EFI_RESET_SYSTEM              ResetSystem;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // New Boot Service added by UEFI 2.0\r
+  //\r
+  EFI_UPDATE_CAPSULE             UpdateCapsule;\r
+  EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities;\r
+  EFI_QUERY_VARIABLE_INFO        QueryVariableInfo;\r
+#elif (TIANO_RELEASE_VERSION != 0)\r
+  //\r
+  // Tiano extension to EFI 1.10 runtime table\r
+  // It was moved to a protocol to not conflict with UEFI 2.0\r
+  // If Tiano is disabled, this item is not enabled for EFI1.10\r
+  //\r
+  EFI_REPORT_STATUS_CODE        ReportStatusCode;\r
+#endif\r
+\r
+} EFI_RUNTIME_SERVICES;\r
+\r
+//\r
+// EFI Boot Services Table\r
+//\r
+#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42\r
+#define EFI_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_VERSION\r
+\r
+typedef struct {\r
+  EFI_TABLE_HEADER                            Hdr;\r
+\r
+  //\r
+  // Task priority functions\r
+  //\r
+  EFI_RAISE_TPL                               RaiseTPL;\r
+  EFI_RESTORE_TPL                             RestoreTPL;\r
+\r
+  //\r
+  // Memory functions\r
+  //\r
+  EFI_ALLOCATE_PAGES                          AllocatePages;\r
+  EFI_FREE_PAGES                              FreePages;\r
+  EFI_GET_MEMORY_MAP                          GetMemoryMap;\r
+  EFI_ALLOCATE_POOL                           AllocatePool;\r
+  EFI_FREE_POOL                               FreePool;\r
+\r
+  //\r
+  // Event & timer functions\r
+  //\r
+  EFI_CREATE_EVENT                            CreateEvent;\r
+  EFI_SET_TIMER                               SetTimer;\r
+  EFI_WAIT_FOR_EVENT                          WaitForEvent;\r
+  EFI_SIGNAL_EVENT                            SignalEvent;\r
+  EFI_CLOSE_EVENT                             CloseEvent;\r
+  EFI_CHECK_EVENT                             CheckEvent;\r
+\r
+  //\r
+  // Protocol handler functions\r
+  //\r
+  EFI_INSTALL_PROTOCOL_INTERFACE              InstallProtocolInterface;\r
+  EFI_REINSTALL_PROTOCOL_INTERFACE            ReinstallProtocolInterface;\r
+  EFI_UNINSTALL_PROTOCOL_INTERFACE            UninstallProtocolInterface;\r
+  EFI_HANDLE_PROTOCOL                         HandleProtocol;\r
+  VOID                                        *Reserved;\r
+  EFI_REGISTER_PROTOCOL_NOTIFY                RegisterProtocolNotify;\r
+  EFI_LOCATE_HANDLE                           LocateHandle;\r
+  EFI_LOCATE_DEVICE_PATH                      LocateDevicePath;\r
+  EFI_INSTALL_CONFIGURATION_TABLE             InstallConfigurationTable;\r
+\r
+  //\r
+  // Image functions\r
+  //\r
+  EFI_IMAGE_LOAD                              LoadImage;\r
+  EFI_IMAGE_START                             StartImage;\r
+  EFI_EXIT                                    Exit;\r
+  EFI_IMAGE_UNLOAD                            UnloadImage;\r
+  EFI_EXIT_BOOT_SERVICES                      ExitBootServices;\r
+\r
+  //\r
+  // Misc functions\r
+  //\r
+  EFI_GET_NEXT_MONOTONIC_COUNT                GetNextMonotonicCount;\r
+  EFI_STALL                                   Stall;\r
+  EFI_SET_WATCHDOG_TIMER                      SetWatchdogTimer;\r
+\r
+  //\r
+  // ////////////////////////////////////////////////////\r
+  // EFI 1.1 Services\r
+    //////////////////////////////////////////////////////\r
+  //\r
+  // DriverSupport Services\r
+  //\r
+  EFI_CONNECT_CONTROLLER                      ConnectController;\r
+  EFI_DISCONNECT_CONTROLLER                   DisconnectController;\r
+\r
+  //\r
+  // Added Open and Close protocol for the new driver model\r
+  //\r
+  EFI_OPEN_PROTOCOL                           OpenProtocol;\r
+  EFI_CLOSE_PROTOCOL                          CloseProtocol;\r
+  EFI_OPEN_PROTOCOL_INFORMATION               OpenProtocolInformation;\r
+\r
+  //\r
+  // Added new services to EFI 1.1 as Lib to reduce code size.\r
+  //\r
+  EFI_PROTOCOLS_PER_HANDLE                    ProtocolsPerHandle;\r
+  EFI_LOCATE_HANDLE_BUFFER                    LocateHandleBuffer;\r
+  EFI_LOCATE_PROTOCOL                         LocateProtocol;\r
+\r
+  EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES    InstallMultipleProtocolInterfaces;\r
+  EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES  UninstallMultipleProtocolInterfaces;\r
+\r
+  //\r
+  // CRC32 services\r
+  //\r
+  EFI_CALCULATE_CRC32                         CalculateCrc32;\r
+\r
+  //\r
+  // Memory Utility Services\r
+  //\r
+  EFI_COPY_MEM                                CopyMem;\r
+  EFI_SET_MEM                                 SetMem;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // UEFI 2.0 Extension to the table\r
+  //\r
+  EFI_CREATE_EVENT_EX                         CreateEventEx;\r
+#endif\r
+\r
+} EFI_BOOT_SERVICES;\r
+\r
+//\r
+// EFI Configuration Table\r
+//\r
+typedef struct {\r
+  EFI_GUID  VendorGuid;\r
+  VOID      *VendorTable;\r
+} EFI_CONFIGURATION_TABLE;\r
+\r
+//\r
+// EFI System Table\r
+//\r
+#define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249\r
+#define EFI_SYSTEM_TABLE_REVISION       EFI_SPECIFICATION_VERSION\r
+#define EFI_1_02_SYSTEM_TABLE_REVISION  ((1 << 16) | 02)\r
+#define EFI_1_10_SYSTEM_TABLE_REVISION  ((1 << 16) | 10)\r
+#define EFI_2_00_SYSTEM_TABLE_REVISION  ((2 << 16) | 00)\r
+#define EFI_2_10_SYSTEM_TABLE_REVISION  ((2 << 16) | 10)\r
+\r
+typedef struct _EFI_SYSTEM_TABLE {\r
+  EFI_TABLE_HEADER              Hdr;\r
+\r
+  CHAR16                        *FirmwareVendor;\r
+  UINT32                        FirmwareRevision;\r
+\r
+  EFI_HANDLE                    ConsoleInHandle;\r
+  EFI_SIMPLE_TEXT_IN_PROTOCOL   *ConIn;\r
+\r
+  EFI_HANDLE                    ConsoleOutHandle;\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *ConOut;\r
+\r
+  EFI_HANDLE                    StandardErrorHandle;\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *StdErr;\r
+\r
+  EFI_RUNTIME_SERVICES          *RuntimeServices;\r
+  EFI_BOOT_SERVICES             *BootServices;\r
+\r
+  UINTN                         NumberOfTableEntries;\r
+  EFI_CONFIGURATION_TABLE       *ConfigurationTable;\r
+\r
+} EFI_SYSTEM_TABLE;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
new file mode 100644 (file)
index 0000000..bab0d4e
--- /dev/null
@@ -0,0 +1,555 @@
+/*++\r
\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDevicePath.h\r
+\r
+Abstract:\r
+\r
+  EFI Device Path definitions\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DEVICE_PATH_H\r
+#define _EFI_DEVICE_PATH_H\r
+\r
+\r
+\r
+#pragma pack(1)\r
+\r
+\r
+//\r
+// Device Path defines and macros\r
+//\r
+#define EFI_DP_TYPE_MASK                    0x7F\r
+#define EFI_DP_TYPE_UNPACKED                0x80\r
+#define END_DEVICE_PATH_TYPE                0x7f\r
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE      0xff\r
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE    0x01\r
+#define END_DEVICE_PATH_LENGTH              (sizeof(EFI_DEVICE_PATH_PROTOCOL))\r
+\r
+#define DP_IS_END_TYPE(a)\r
+#define DP_IS_END_SUBTYPE(a)        ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )\r
+\r
+#define DevicePathType(a)           ( ((a)->Type) & EFI_DP_TYPE_MASK )\r
+#define DevicePathSubType(a)        ( (a)->SubType )\r
+#define DevicePathNodeLength(a)     ( ((a)->Length[0]) | ((a)->Length[1] << 8) )\r
+#define NextDevicePathNode(a)       ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))\r
+#define IsDevicePathEndType(a)      ( DevicePathType(a) == END_DEVICE_PATH_TYPE )\r
+#define IsDevicePathEndSubType(a)   ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )\r
+#define IsDevicePathEnd(a)          ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )\r
+#define IsDevicePathUnpacked(a)     ( (a)->Type & EFI_DP_TYPE_UNPACKED )\r
+\r
+\r
+#define SetDevicePathNodeLength(a,l) {                \\r
+          (a)->Length[0] = (UINT8) (l);               \\r
+          (a)->Length[1] = (UINT8) ((l) >> 8);        \\r
+          }\r
+\r
+#define SetDevicePathEndNode(a)  {                       \\r
+          (a)->Type = END_DEVICE_PATH_TYPE;              \\r
+          (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \\r
+          (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL);      \\r
+          (a)->Length[1] = 0;                            \\r
+          }\r
+\r
+//\r
+// Hardware Device Paths\r
+//\r
+#define HARDWARE_DEVICE_PATH      0x01\r
+\r
+#define HW_PCI_DP                 0x01\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT8                           Function;\r
+  UINT8                           Device;\r
+} PCI_DEVICE_PATH;\r
+\r
+#define HW_PCCARD_DP              0x02\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT8                           FunctionNumber;\r
+} PCCARD_DEVICE_PATH;\r
+\r
+#define HW_MEMMAP_DP              0x03\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          MemoryType;\r
+  EFI_PHYSICAL_ADDRESS            StartingAddress;\r
+  EFI_PHYSICAL_ADDRESS            EndingAddress;\r
+} MEMMAP_DEVICE_PATH;\r
+\r
+#define HW_VENDOR_DP              0x04\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_GUID                        Guid;\r
+} VENDOR_DEVICE_PATH;\r
+\r
+#define HW_CONTROLLER_DP          0x05\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          Controller;\r
+} CONTROLLER_DEVICE_PATH;\r
+\r
+//\r
+// ACPI Device Paths\r
+//\r
+#define ACPI_DEVICE_PATH          0x02\r
+\r
+#define ACPI_DP                   0x01\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          HID;\r
+  UINT32                          UID;\r
+} ACPI_HID_DEVICE_PATH;\r
+\r
+#define ACPI_EXTENDED_DP          0x02\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          HID;\r
+  UINT32                          UID;\r
+  UINT32                          CID;\r
+  //\r
+  // Optional variable length _HIDSTR\r
+  // Optional variable length _UIDSTR\r
+  //\r
+} ACPI_EXTENDED_HID_DEVICE_PATH;\r
+\r
+#define ACPI_ADR_DP               0x03\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          ADR;\r
+} ACPI_ADR_DEVICE_PATH;\r
+\r
+#define ACPI_ADR_DISPLAY_TYPE_OTHER             0\r
+#define ACPI_ADR_DISPLAY_TYPE_VGA               1\r
+#define ACPI_ADR_DISPLAY_TYPE_TV                2\r
+#define ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL  3\r
+#define ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL  4\r
+\r
+#define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \\r
+          ((UINT32) ( (((_DeviceIdScheme) & 0x1) << 31) |  \\r
+                      (((_HeadId)         & 0x7) << 18) |  \\r
+                      (((_NonVgaOutput)   & 0x1) << 17) |  \\r
+                      (((_BiosCanDetect)  & 0x1) << 16) |  \\r
+                      (((_VendorInfo)     & 0xf) << 12) |  \\r
+                      (((_Type)           & 0xf) << 8)  |  \\r
+                      (((_Port)           & 0xf) << 4)  |  \\r
+                       ((_Index)          & 0xf) ))\r
+\r
+// \r
+//  EISA ID Macro\r
+//  EISA ID Definition 32-bits\r
+//   bits[15:0] - three character compressed ASCII EISA ID.\r
+//   bits[31:16] - binary number\r
+//    Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'\r
+//\r
+#define PNP_EISA_ID_CONST         0x41d0    \r
+#define EISA_ID(_Name, _Num)      ((UINT32) ((_Name) | (_Num) << 16))   \r
+#define EISA_PNP_ID(_PNPId)       (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))\r
+#define EFI_PNP_ID(_PNPId)        (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))\r
+\r
+#define PNP_EISA_ID_MASK          0xffff\r
+#define EISA_ID_TO_NUM(_Id)       ((_Id) >> 16)\r
+\r
+//\r
+// Messaging Device Paths\r
+//\r
+#define MESSAGING_DEVICE_PATH     0x03\r
+\r
+#define MSG_ATAPI_DP              0x01\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT8                           PrimarySecondary;\r
+  UINT8                           SlaveMaster;\r
+  UINT16                          Lun;\r
+} ATAPI_DEVICE_PATH;\r
+\r
+#define MSG_SCSI_DP               0x02\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          Pun;\r
+  UINT16                          Lun;\r
+} SCSI_DEVICE_PATH;\r
+\r
+#define MSG_FIBRECHANNEL_DP       0x03\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          Reserved;\r
+  UINT64                          WWN;\r
+  UINT64                          Lun;\r
+} FIBRECHANNEL_DEVICE_PATH;\r
+\r
+#define MSG_1394_DP               0x04\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          Reserved;\r
+  UINT64                          Guid;\r
+} F1394_DEVICE_PATH;\r
+\r
+#define MSG_USB_DP                0x05\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT8                           ParentPortNumber;\r
+  UINT8                           InterfaceNumber;\r
+} USB_DEVICE_PATH;\r
+\r
+#define MSG_USB_CLASS_DP          0x0f\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          VendorId;\r
+  UINT16                          ProductId;\r
+  UINT8                           DeviceClass;\r
+  UINT8                           DeviceSubClass;\r
+  UINT8                           DeviceProtocol;\r
+} USB_CLASS_DEVICE_PATH;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#define MSG_USB_WWID_DP           0x10\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          InterfaceNumber;\r
+  UINT16                          VendorId;\r
+  UINT16                          ProductId;\r
+  //\r
+  // CHAR16                     SerialNumber[];\r
+  //\r
+} USB_WWID_DEVICE_PATH;\r
+\r
+#define MSG_DEVICE_LOGICAL_UNIT_DP  0x11\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT8                           Lun;\r
+} DEVICE_LOGICAL_UNIT_DEVICE_PATH;\r
+#endif\r
+\r
+#define MSG_SATA_DP               0x12\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          HBAPortNumber;\r
+  UINT16                          PortMultiplierPortNumber;\r
+  UINT16                          Lun;\r
+} SATA_DEVICE_PATH;\r
+\r
+#define MSG_I2O_DP                0x06\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          Tid;\r
+} I2O_DEVICE_PATH;\r
+\r
+#define MSG_MAC_ADDR_DP           0x0b\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_MAC_ADDRESS                 MacAddress;\r
+  UINT8                           IfType;\r
+} MAC_ADDR_DEVICE_PATH;\r
+\r
+#define MSG_IPv4_DP               0x0c\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_IPv4_ADDRESS                LocalIpAddress;\r
+  EFI_IPv4_ADDRESS                RemoteIpAddress;\r
+  UINT16                          LocalPort;\r
+  UINT16                          RemotePort;\r
+  UINT16                          Protocol;\r
+  BOOLEAN                         StaticIpAddress;\r
+} IPv4_DEVICE_PATH;\r
+\r
+#define MSG_IPv6_DP               0x0d\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_IPv6_ADDRESS                LocalIpAddress;\r
+  EFI_IPv6_ADDRESS                RemoteIpAddress;\r
+  UINT16                          LocalPort;\r
+  UINT16                          RemotePort;\r
+  UINT16                          Protocol;\r
+  BOOLEAN                         StaticIpAddress;\r
+} IPv6_DEVICE_PATH;\r
+\r
+#define MSG_INFINIBAND_DP         0x09\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          ResourceFlags;\r
+  UINT8                           PortGid[16];\r
+  UINT64                          ServiceId;\r
+  UINT64                          TargetPortId;\r
+  UINT64                          DeviceId;\r
+} INFINIBAND_DEVICE_PATH;\r
+\r
+#define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE                0x01\r
+#define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT  0x02\r
+#define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL           0x04\r
+#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL           0x08\r
+#define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL           0x10\r
+\r
+#define MSG_UART_DP               0x0e\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          Reserved;\r
+  UINT64                          BaudRate;\r
+  UINT8                           DataBits;\r
+  UINT8                           Parity;\r
+  UINT8                           StopBits;\r
+} UART_DEVICE_PATH;\r
+\r
+//\r
+// Use VENDOR_DEVICE_PATH struct\r
+//\r
+#define MSG_VENDOR_DP             0x0a\r
+\r
+#define DEVICE_PATH_MESSAGING_PC_ANSI \\r
+    { 0xe0c14753, 0xf9be, 0x11d2,  0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d  }\r
+\r
+#define DEVICE_PATH_MESSAGING_VT_100 \\r
+    { 0xdfa66065, 0xb419, 0x11d3,  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d  }\r
+\r
+#define DEVICE_PATH_MESSAGING_VT_100_PLUS \\r
+    { 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43  }\r
+\r
+#define DEVICE_PATH_MESSAGING_VT_UTF8 \\r
+    { 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 }\r
+\r
+#define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL \\r
+    { 0x37499a9d, 0x542f, 0x4c89, 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 }\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_GUID                        Guid;\r
+  UINT32                          FlowControlMap;\r
+} UART_FLOW_CONTROL_DEVICE_PATH;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+#define DEVICE_PATH_MESSAGING_SAS \\r
+    { 0xd487ddb4, 0x008b, 0x11d9, 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_GUID                        Guid;\r
+  UINT32                          Reserved;\r
+  UINT64                          SasAddress;\r
+  UINT64                          Lun;\r
+  UINT16                          DeviceTopology;\r
+  UINT16                          RelativeTargetPort;\r
+} SAS_DEVICE_PATH;\r
+\r
+#define MSG_ISCSI_DP              0x13\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          NetworkProtocol;\r
+  UINT16                          LoginOption;\r
+  UINT64                          Lun;\r
+  UINT16                          TargetPortalGroupTag;\r
+  // CHAR8                        iSCSI Target Name\r
+} ISCSI_DEVICE_PATH;\r
+\r
+#define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST             0x0000\r
+#define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C   0x0002\r
+#define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST               0x0000\r
+#define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C     0x0008\r
+#define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP              0x0000\r
+#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON               0x1000\r
+#define ISCSI_LOGIN_OPTION_CHAP_BI                      0x0000\r
+#define ISCSI_LOGIN_OPTION_CHAP_UNI                     0x2000\r
+\r
+#endif\r
+\r
+//\r
+// Media Device Path\r
+//\r
+#define MEDIA_DEVICE_PATH         0x04\r
+\r
+#define MEDIA_HARDDRIVE_DP        0x01\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          PartitionNumber;\r
+  UINT64                          PartitionStart;\r
+  UINT64                          PartitionSize;\r
+  UINT8                           Signature[16];\r
+  UINT8                           MBRType;\r
+  UINT8                           SignatureType;\r
+} HARDDRIVE_DEVICE_PATH;\r
+\r
+#define MBR_TYPE_PCAT             0x01\r
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02\r
+\r
+#define SIGNATURE_TYPE_MBR        0x01\r
+#define SIGNATURE_TYPE_GUID       0x02\r
+\r
+#define MEDIA_CDROM_DP            0x02\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT32                          BootEntry;\r
+  UINT64                          PartitionStart;\r
+  UINT64                          PartitionSize;\r
+} CDROM_DEVICE_PATH;\r
+\r
+//\r
+// Use VENDOR_DEVICE_PATH struct\r
+//\r
+#define MEDIA_VENDOR_DP           0x03\r
+\r
+#define MEDIA_FILEPATH_DP         0x04\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  CHAR16                          PathName[1];\r
+} FILEPATH_DEVICE_PATH;\r
+\r
+#define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)\r
+\r
+#define MEDIA_PROTOCOL_DP         0x05\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  EFI_GUID                        Protocol;\r
+} MEDIA_PROTOCOL_DEVICE_PATH;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+\r
+#define MEDIA_FV_DP  0x06\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  NameGuid;\r
+} MEDIA_FW_VOL_DEVICE_PATH;\r
+\r
+#define MEDIA_FV_FILEPATH_DP  0x07\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  NameGuid;\r
+} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;\r
+\r
+#endif\r
+\r
+//\r
+// BBS Device Path\r
+//\r
+#define BBS_DEVICE_PATH           0x05\r
+#define BBS_BBS_DP                0x01\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  UINT16                          DeviceType;\r
+  UINT16                          StatusFlag;\r
+  CHAR8                           String[1];\r
+} BBS_BBS_DEVICE_PATH;\r
+\r
+//\r
+// DeviceType definitions - from BBS specification\r
+//\r
+#define BBS_TYPE_FLOPPY           0x01\r
+#define BBS_TYPE_HARDDRIVE        0x02\r
+#define BBS_TYPE_CDROM            0x03\r
+#define BBS_TYPE_PCMCIA           0x04\r
+#define BBS_TYPE_USB              0x05\r
+#define BBS_TYPE_EMBEDDED_NETWORK 0x06\r
+#define BBS_TYPE_BEV              0x80\r
+#define BBS_TYPE_UNKNOWN          0xFF\r
+\r
+#define UNKNOWN_DEVICE_GUID \\r
+  { 0xcf31fac5, 0xc24e, 0x11d2,  0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b  }\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              DevicePath;\r
+  UINT8                           LegacyDriveLetter;\r
+} UNKNOWN_DEVICE_VENDOR_DEVICE_PATH;\r
+\r
+\r
+//\r
+// Union of all possible Device Paths and pointers to Device Paths\r
+//\r
+\r
+typedef union {\r
+  EFI_DEVICE_PATH_PROTOCOL             DevPath;\r
+  PCI_DEVICE_PATH                      Pci;\r
+  PCCARD_DEVICE_PATH                   PcCard;\r
+  MEMMAP_DEVICE_PATH                   MemMap;\r
+  VENDOR_DEVICE_PATH                   Vendor;\r
+\r
+  UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    UnknownVendor;\r
+\r
+  CONTROLLER_DEVICE_PATH               Controller;\r
+  ACPI_HID_DEVICE_PATH                 Acpi;\r
+\r
+  ATAPI_DEVICE_PATH                    Atapi;\r
+  SCSI_DEVICE_PATH                     Scsi;\r
+  FIBRECHANNEL_DEVICE_PATH             FibreChannel;\r
+  SATA_DEVICE_PATH                     Sata;\r
+\r
+  F1394_DEVICE_PATH                    F1394;\r
+  USB_DEVICE_PATH                      Usb;\r
+  USB_CLASS_DEVICE_PATH                UsbClass;\r
+  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  USB_WWID_DEVICE_PATH                 UsbWwid;\r
+  #endif\r
+  I2O_DEVICE_PATH                      I2O;\r
+  MAC_ADDR_DEVICE_PATH                 MacAddr;\r
+  IPv4_DEVICE_PATH                     Ipv4;\r
+  IPv6_DEVICE_PATH                     Ipv6;\r
+  INFINIBAND_DEVICE_PATH               InfiniBand;\r
+  UART_DEVICE_PATH                     Uart;\r
+  UART_FLOW_CONTROL_DEVICE_PATH        UartFlowControl;\r
+  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  SAS_DEVICE_PATH                      Sas;\r
+  ISCSI_DEVICE_PATH                    Iscsi;\r
+  #endif\r
+  HARDDRIVE_DEVICE_PATH                HardDrive;\r
+  CDROM_DEVICE_PATH                    CD;\r
+\r
+  FILEPATH_DEVICE_PATH                 FilePath;\r
+  MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;\r
+\r
+  BBS_BBS_DEVICE_PATH                  Bbs;\r
+} EFI_DEV_PATH;\r
+\r
+\r
+\r
+typedef union {\r
+  EFI_DEVICE_PATH_PROTOCOL             *DevPath;\r
+  PCI_DEVICE_PATH                      *Pci;\r
+  PCCARD_DEVICE_PATH                   *PcCard;\r
+  MEMMAP_DEVICE_PATH                   *MemMap;\r
+  VENDOR_DEVICE_PATH                   *Vendor;\r
+\r
+  UNKNOWN_DEVICE_VENDOR_DEVICE_PATH    *UnknownVendor;\r
+\r
+  CONTROLLER_DEVICE_PATH               *Controller;\r
+  ACPI_HID_DEVICE_PATH                 *Acpi;\r
+  ACPI_EXTENDED_HID_DEVICE_PATH        *ExtendedAcpi;\r
+\r
+  ATAPI_DEVICE_PATH                    *Atapi;\r
+  SCSI_DEVICE_PATH                     *Scsi;\r
+  FIBRECHANNEL_DEVICE_PATH             *FibreChannel;\r
+  SATA_DEVICE_PATH                     *Sata;\r
+\r
+  F1394_DEVICE_PATH                    *F1394;\r
+  USB_DEVICE_PATH                      *Usb;\r
+  USB_CLASS_DEVICE_PATH                *UsbClass;\r
+  I2O_DEVICE_PATH                      *I2O;\r
+  MAC_ADDR_DEVICE_PATH                 *MacAddr;\r
+  IPv4_DEVICE_PATH                     *Ipv4;\r
+  IPv6_DEVICE_PATH                     *Ipv6;\r
+  INFINIBAND_DEVICE_PATH               *InfiniBand;\r
+  UART_DEVICE_PATH                     *Uart;\r
+\r
+  HARDDRIVE_DEVICE_PATH                *HardDrive;\r
+  CDROM_DEVICE_PATH                    *CD;\r
+\r
+  FILEPATH_DEVICE_PATH                 *FilePath;\r
+  MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;\r
+\r
+  BBS_BBS_DEVICE_PATH                  *Bbs;\r
+  UINT8                                *Raw;\r
+} EFI_DEV_PATH_PTR;\r
+\r
+#pragma pack()\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h
new file mode 100644 (file)
index 0000000..be2b628
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiError.h\r
+\r
+Abstract:\r
+\r
+  EFI error levels and thier associated defines\r
+\r
+--*/\r
+\r
+#ifndef _EFI_ERROR_H_\r
+#define _EFI_ERROR_H_\r
+\r
+//\r
+// Set the upper bit to indicate EFI Error.\r
+//\r
+#define EFIERR(a)                 (EFI_MAX_BIT | (a))\r
+\r
+#define EFIWARN(a)                (a)\r
+#define EFI_ERROR(a)              (((INTN) (a)) < 0)\r
+\r
+#define EFI_SUCCESS               0\r
+#define EFI_LOAD_ERROR            EFIERR (1)\r
+#define EFI_INVALID_PARAMETER     EFIERR (2)\r
+#define EFI_UNSUPPORTED           EFIERR (3)\r
+#define EFI_BAD_BUFFER_SIZE       EFIERR (4)\r
+#define EFI_BUFFER_TOO_SMALL      EFIERR (5)\r
+#define EFI_NOT_READY             EFIERR (6)\r
+#define EFI_DEVICE_ERROR          EFIERR (7)\r
+#define EFI_WRITE_PROTECTED       EFIERR (8)\r
+#define EFI_OUT_OF_RESOURCES      EFIERR (9)\r
+#define EFI_VOLUME_CORRUPTED      EFIERR (10)\r
+#define EFI_VOLUME_FULL           EFIERR (11)\r
+#define EFI_NO_MEDIA              EFIERR (12)\r
+#define EFI_MEDIA_CHANGED         EFIERR (13)\r
+#define EFI_NOT_FOUND             EFIERR (14)\r
+#define EFI_ACCESS_DENIED         EFIERR (15)\r
+#define EFI_NO_RESPONSE           EFIERR (16)\r
+#define EFI_NO_MAPPING            EFIERR (17)\r
+#define EFI_TIMEOUT               EFIERR (18)\r
+#define EFI_NOT_STARTED           EFIERR (19)\r
+#define EFI_ALREADY_STARTED       EFIERR (20)\r
+#define EFI_ABORTED               EFIERR (21)\r
+#define EFI_ICMP_ERROR            EFIERR (22)\r
+#define EFI_TFTP_ERROR            EFIERR (23)\r
+#define EFI_PROTOCOL_ERROR        EFIERR (24)\r
+#define EFI_INCOMPATIBLE_VERSION  EFIERR (25)\r
+#define EFI_SECURITY_VIOLATION    EFIERR (26)\r
+#define EFI_CRC_ERROR             EFIERR (27)\r
+\r
+#define EFI_WARN_UNKNOWN_GLYPH    EFIWARN (1)\r
+#define EFI_WARN_DELETE_FAILURE   EFIWARN (2)\r
+#define EFI_WARN_WRITE_FAILURE    EFIWARN (3)\r
+#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h
new file mode 100644 (file)
index 0000000..e151697
--- /dev/null
@@ -0,0 +1,661 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiImage.h\r
+\r
+Abstract:\r
+\r
+  EFI image format for PE32+. Please note some data structures are different\r
+  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
+\r
+  BugBug: Fix text - doc as defined in MSFT EFI specification\r
+\r
+--*/\r
+\r
+#ifndef _EFI_IMAGE_H_\r
+#define _EFI_IMAGE_H_\r
+\r
+//\r
+// PE32+ Subsystem type for EFI images\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12\r
+\r
+//\r
+// BugBug: Need to get a real answer for this problem. This is not in the\r
+//         PE specification.\r
+//\r
+//         A SAL runtime driver does not get fixed up when a transition to\r
+//         virtual mode is made. In all other cases it should be treated\r
+//         like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13\r
+\r
+//\r
+// PE32+ Machine type for EFI images\r
+//\r
+#define EFI_IMAGE_MACHINE_IA32      0x014c\r
+#define EFI_IMAGE_MACHINE_IA64      0x0200\r
+#define EFI_IMAGE_MACHINE_X64       0x8664\r
+//\r
+// #define EFI_IMAGE_MACHINE_FCODE     0xfc0d\r
+//\r
+#define EFI_IMAGE_MACHINE_EBC       0x0EBC\r
+\r
+#define EFI_IMAGE_DOS_SIGNATURE     0x5A4D      // MZ\r
+#define EFI_IMAGE_OS2_SIGNATURE     0x454E      // NE\r
+#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C      // LE\r
+#define EFI_IMAGE_NT_SIGNATURE      0x00004550  // PE00\r
+#define EFI_IMAGE_EDOS_SIGNATURE    0x44454550  // PEED\r
+//\r
+// PE images can start with an optional DOS header, so if an image is run\r
+//  under DOS it can print an error message.\r
+//\r
+typedef struct {\r
+  UINT16  e_magic;    // Magic number\r
+  UINT16  e_cblp;     // Bytes on last page of file\r
+  UINT16  e_cp;       // Pages in file\r
+  UINT16  e_crlc;     // Relocations\r
+  UINT16  e_cparhdr;  // Size of header in paragraphs\r
+  UINT16  e_minalloc; // Minimum extra paragraphs needed\r
+  UINT16  e_maxalloc; // Maximum extra paragraphs needed\r
+  UINT16  e_ss;       // Initial (relative) SS value\r
+  UINT16  e_sp;       // Initial SP value\r
+  UINT16  e_csum;     // Checksum\r
+  UINT16  e_ip;       // Initial IP value\r
+  UINT16  e_cs;       // Initial (relative) CS value\r
+  UINT16  e_lfarlc;   // File address of relocation table\r
+  UINT16  e_ovno;     // Overlay number\r
+  UINT16  e_res[4];   // Reserved words\r
+  UINT16  e_oemid;    // OEM identifier (for e_oeminfo)\r
+  UINT16  e_oeminfo;  // OEM information; e_oemid specific\r
+  UINT16  e_res2[10]; // Reserved words\r
+  UINT32  e_lfanew;   // File address of new exe header\r
+} EFI_IMAGE_DOS_HEADER;\r
+\r
+//\r
+// File header format.\r
+//\r
+typedef struct {\r
+  UINT16  Machine;\r
+  UINT16  NumberOfSections;\r
+  UINT32  TimeDateStamp;\r
+  UINT32  PointerToSymbolTable;\r
+  UINT32  NumberOfSymbols;\r
+  UINT16  SizeOfOptionalHeader;\r
+  UINT16  Characteristics;\r
+} EFI_IMAGE_FILE_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_FILE_HEADER        20\r
+\r
+#define EFI_IMAGE_FILE_RELOCS_STRIPPED      0x0001  // Relocation info stripped from file.\r
+#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     0x0002  // File is executable  (i.e. no unresolved externel references).\r
+#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004  // Line nunbers stripped from file.\r
+#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008  // Local symbols stripped from file.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    0x0080  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_32BIT_MACHINE        0x0100  // 32 bit word machine.\r
+#define EFI_IMAGE_FILE_DEBUG_STRIPPED       0x0200  // Debugging info stripped from file in .DBG file\r
+#define EFI_IMAGE_FILE_SYSTEM               0x1000  // System File.\r
+#define EFI_IMAGE_FILE_DLL                  0x2000  // File is a DLL.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_HI    0x8000  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_MACHINE_UNKNOWN      0\r
+#define EFI_IMAGE_FILE_MACHINE_I386         0x14c   // Intel 386.\r
+#define EFI_IMAGE_FILE_MACHINE_R3000        0x162   // MIPS* little-endian, 0540 big-endian\r
+#define EFI_IMAGE_FILE_MACHINE_R4000        0x166   // MIPS* little-endian\r
+#define EFI_IMAGE_FILE_MACHINE_ALPHA        0x184   // Alpha_AXP*\r
+#define EFI_IMAGE_FILE_MACHINE_POWERPC      0x1F0   // IBM* PowerPC Little-Endian\r
+#define EFI_IMAGE_FILE_MACHINE_TAHOE        0x7cc   // Intel EM machine\r
+//\r
+// * Other names and brands may be claimed as the property of others.\r
+//\r
+//\r
+// Directory format.\r
+//\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  Size;\r
+} EFI_IMAGE_DATA_DIRECTORY;\r
+\r
+#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
+\r
+typedef struct {\r
+  UINT16  Magic;\r
+  UINT8   MajorLinkerVersion;\r
+  UINT8   MinorLinkerVersion;\r
+  UINT32  SizeOfCode;\r
+  UINT32  SizeOfInitializedData;\r
+  UINT32  SizeOfUninitializedData;\r
+  UINT32  AddressOfEntryPoint;\r
+  UINT32  BaseOfCode;\r
+  UINT32  BaseOfData;\r
+  UINT32  BaseOfBss;\r
+  UINT32  GprMask;\r
+  UINT32  CprMask[4];\r
+  UINT32  GpValue;\r
+} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
+\r
+#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC      0x107\r
+#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER  sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
+\r
+typedef struct {\r
+  EFI_IMAGE_FILE_HEADER         FileHeader;\r
+  EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
+} EFI_IMAGE_ROM_HEADERS;\r
+\r
+//\r
+// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+// are for use ONLY by tools.  All proper EFI code MUST use\r
+// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+//\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT32                    BaseOfData;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT32                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT32                    SizeOfStackReserve;\r
+  UINT32                    SizeOfStackCommit;\r
+  UINT32                    SizeOfHeapReserve;\r
+  UINT32                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER32;\r
+\r
+//\r
+// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+// are for use ONLY by tools.  All proper EFI code MUST use\r
+// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+//\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT64                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT64                    SizeOfStackReserve;\r
+  UINT64                    SizeOfStackCommit;\r
+  UINT64                    SizeOfHeapReserve;\r
+  UINT64                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER64;\r
+\r
+//\r
+// ATTENTION!!! EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
+// by tools.  All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
+//\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS32;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
+\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS64;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
+\r
+//\r
+// Include processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
+// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build.  Same for\r
+// EFI_IMAGE_NT_HEADERS.  These definitions MUST be used by ALL EFI code.\r
+//\r
+#include "EfiPeOptionalHeader.h"\r
+\r
+#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
+    ( \\r
+      (EFI_IMAGE_SECTION_HEADER *) \\r
+        ( \\r
+          (UINT32) ntheader + \\r
+          FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
+          ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
+        ) \\r
+    )\r
+\r
+//\r
+// Subsystem Values\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_UNKNOWN     0\r
+#define EFI_IMAGE_SUBSYSTEM_NATIVE      1\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
+#define EFI_IMAGE_SUBSYSTEM_OS2_CUI     5\r
+#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI   7\r
+\r
+//\r
+// Directory Entries\r
+//\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT      0\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT      1\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE    2\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION   3\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY    4\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC   5\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG       6\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT   7\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR   8\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_TLS         9\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
+\r
+//\r
+// Section header format.\r
+//\r
+#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
+\r
+typedef struct {\r
+  UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
+  union {\r
+    UINT32  PhysicalAddress;\r
+    UINT32  VirtualSize;\r
+  } Misc;\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfRawData;\r
+  UINT32  PointerToRawData;\r
+  UINT32  PointerToRelocations;\r
+  UINT32  PointerToLinenumbers;\r
+  UINT16  NumberOfRelocations;\r
+  UINT16  NumberOfLinenumbers;\r
+  UINT32  Characteristics;\r
+} EFI_IMAGE_SECTION_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_SECTION_HEADER       40\r
+\r
+#define EFI_IMAGE_SCN_TYPE_NO_PAD             0x00000008  // Reserved.\r
+#define EFI_IMAGE_SCN_CNT_CODE                0x00000020\r
+#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA    0x00000040\r
+#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080\r
+\r
+#define EFI_IMAGE_SCN_LNK_OTHER               0x00000100  // Reserved.\r
+#define EFI_IMAGE_SCN_LNK_INFO                0x00000200  // Section contains comments or some other type of information.\r
+#define EFI_IMAGE_SCN_LNK_REMOVE              0x00000800  // Section contents will not become part of image.\r
+#define EFI_IMAGE_SCN_LNK_COMDAT              0x00001000\r
+\r
+#define EFI_IMAGE_SCN_ALIGN_1BYTES            0x00100000\r
+#define EFI_IMAGE_SCN_ALIGN_2BYTES            0x00200000\r
+#define EFI_IMAGE_SCN_ALIGN_4BYTES            0x00300000\r
+#define EFI_IMAGE_SCN_ALIGN_8BYTES            0x00400000\r
+#define EFI_IMAGE_SCN_ALIGN_16BYTES           0x00500000\r
+#define EFI_IMAGE_SCN_ALIGN_32BYTES           0x00600000\r
+#define EFI_IMAGE_SCN_ALIGN_64BYTES           0x00700000\r
+\r
+#define EFI_IMAGE_SCN_MEM_DISCARDABLE         0x02000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_CACHED          0x04000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_PAGED           0x08000000\r
+#define EFI_IMAGE_SCN_MEM_SHARED              0x10000000\r
+#define EFI_IMAGE_SCN_MEM_EXECUTE             0x20000000\r
+#define EFI_IMAGE_SCN_MEM_READ                0x40000000\r
+#define EFI_IMAGE_SCN_MEM_WRITE               0x80000000\r
+\r
+//\r
+// Symbol format.\r
+//\r
+#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
+\r
+//\r
+// Section values.\r
+//\r
+// Symbols have a section number of the section in which they are\r
+// defined. Otherwise, section numbers have the following meanings:\r
+//\r
+#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0  // Symbol is undefined or is common.\r
+#define EFI_IMAGE_SYM_ABSOLUTE  (UINT16) -1 // Symbol is an absolute value.\r
+#define EFI_IMAGE_SYM_DEBUG     (UINT16) -2 // Symbol is a special debug item.\r
+//\r
+// Type (fundamental) values.\r
+//\r
+#define EFI_IMAGE_SYM_TYPE_NULL   0   // no type.\r
+#define EFI_IMAGE_SYM_TYPE_VOID   1   //\r
+#define EFI_IMAGE_SYM_TYPE_CHAR   2   // type character.\r
+#define EFI_IMAGE_SYM_TYPE_SHORT  3   // type short integer.\r
+#define EFI_IMAGE_SYM_TYPE_INT    4\r
+#define EFI_IMAGE_SYM_TYPE_LONG   5\r
+#define EFI_IMAGE_SYM_TYPE_FLOAT  6\r
+#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
+#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
+#define EFI_IMAGE_SYM_TYPE_UNION  9\r
+#define EFI_IMAGE_SYM_TYPE_ENUM   10  // enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_MOE    11  // member of enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_BYTE   12\r
+#define EFI_IMAGE_SYM_TYPE_WORD   13\r
+#define EFI_IMAGE_SYM_TYPE_UINT   14\r
+#define EFI_IMAGE_SYM_TYPE_DWORD  15\r
+\r
+//\r
+// Type (derived) values.\r
+//\r
+#define EFI_IMAGE_SYM_DTYPE_NULL      0 // no derived type.\r
+#define EFI_IMAGE_SYM_DTYPE_POINTER   1\r
+#define EFI_IMAGE_SYM_DTYPE_FUNCTION  2\r
+#define EFI_IMAGE_SYM_DTYPE_ARRAY     3\r
+\r
+//\r
+// Storage classes.\r
+//\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION   (UINT8) -1\r
+#define EFI_IMAGE_SYM_CLASS_NULL              0\r
+#define EFI_IMAGE_SYM_CLASS_AUTOMATIC         1\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL          2\r
+#define EFI_IMAGE_SYM_CLASS_STATIC            3\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER          4\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF      5\r
+#define EFI_IMAGE_SYM_CLASS_LABEL             6\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL   7\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT  8\r
+#define EFI_IMAGE_SYM_CLASS_ARGUMENT          9\r
+#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG        10\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION   11\r
+#define EFI_IMAGE_SYM_CLASS_UNION_TAG         12\r
+#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION   13\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC  14\r
+#define EFI_IMAGE_SYM_CLASS_ENUM_TAG          15\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM    16\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM    17\r
+#define EFI_IMAGE_SYM_CLASS_BIT_FIELD         18\r
+#define EFI_IMAGE_SYM_CLASS_BLOCK             100\r
+#define EFI_IMAGE_SYM_CLASS_FUNCTION          101\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT     102\r
+#define EFI_IMAGE_SYM_CLASS_FILE              103\r
+#define EFI_IMAGE_SYM_CLASS_SECTION           104\r
+#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL     105\r
+\r
+//\r
+// type packing constants\r
+//\r
+#define EFI_IMAGE_N_BTMASK  017\r
+#define EFI_IMAGE_N_TMASK   060\r
+#define EFI_IMAGE_N_TMASK1  0300\r
+#define EFI_IMAGE_N_TMASK2  0360\r
+#define EFI_IMAGE_N_BTSHFT  4\r
+#define EFI_IMAGE_N_TSHIFT  2\r
+\r
+//\r
+// Communal selection types.\r
+//\r
+#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES    1\r
+#define EFI_IMAGE_COMDAT_SELECT_ANY             2\r
+#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE       3\r
+#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH     4\r
+#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE     5\r
+\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3\r
+\r
+//\r
+// Relocation format.\r
+//\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SymbolTableIndex;\r
+  UINT16  Type;\r
+} EFI_IMAGE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
+\r
+//\r
+// I386 relocation types.\r
+//\r
+#define EFI_IMAGE_REL_I386_ABSOLUTE 0   // Reference is absolute, no relocation is necessary\r
+#define EFI_IMAGE_REL_I386_DIR16    01  // Direct 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_REL16    02  // PC-relative 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32    06  // Direct 32-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32NB  07  // Direct 32-bit reference to the symbols virtual address, base not included\r
+#define EFI_IMAGE_REL_I386_SEG12    011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
+#define EFI_IMAGE_REL_I386_SECTION  012\r
+#define EFI_IMAGE_REL_I386_SECREL   013\r
+#define EFI_IMAGE_REL_I386_REL32    024 // PC-relative 32-bit reference to the symbols virtual address\r
+//\r
+// Based relocation format.\r
+//\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfBlock;\r
+} EFI_IMAGE_BASE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_BASE_RELOCATION  8\r
+\r
+//\r
+// Based relocation types.\r
+//\r
+#define EFI_IMAGE_REL_BASED_ABSOLUTE      0\r
+#define EFI_IMAGE_REL_BASED_HIGH          1\r
+#define EFI_IMAGE_REL_BASED_LOW           2\r
+#define EFI_IMAGE_REL_BASED_HIGHLOW       3\r
+#define EFI_IMAGE_REL_BASED_HIGHADJ       4\r
+#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR  5\r
+#define EFI_IMAGE_REL_BASED_IA64_IMM64    9\r
+#define EFI_IMAGE_REL_BASED_DIR64         10\r
+\r
+//\r
+// Line number format.\r
+//\r
+typedef struct {\r
+  union {\r
+    UINT32  SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
+    UINT32  VirtualAddress;   // Virtual address of line number.\r
+  } Type;\r
+  UINT16  Linenumber;         // Line number.\r
+} EFI_IMAGE_LINENUMBER;\r
+\r
+#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
+\r
+//\r
+// Archive format.\r
+//\r
+#define EFI_IMAGE_ARCHIVE_START_SIZE        8\r
+#define EFI_IMAGE_ARCHIVE_START             "!<arch>\n"\r
+#define EFI_IMAGE_ARCHIVE_END               "`\n"\r
+#define EFI_IMAGE_ARCHIVE_PAD               "\n"\r
+#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER     "/               "\r
+#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER  "//              "\r
+\r
+typedef struct {\r
+  UINT8 Name[16];     // File member name - `/' terminated.\r
+  UINT8 Date[12];     // File member date - decimal.\r
+  UINT8 UserID[6];    // File member user id - decimal.\r
+  UINT8 GroupID[6];   // File member group id - decimal.\r
+  UINT8 Mode[8];      // File member mode - octal.\r
+  UINT8 Size[10];     // File member size - decimal.\r
+  UINT8 EndHeader[2]; // String to end header.\r
+} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
+\r
+//\r
+// DLL support.\r
+//\r
+//\r
+// Export Format\r
+//\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Name;\r
+  UINT32  Base;\r
+  UINT32  NumberOfFunctions;\r
+  UINT32  NumberOfNames;\r
+  UINT32  AddressOfFunctions;\r
+  UINT32  AddressOfNames;\r
+  UINT32  AddressOfNameOrdinals;\r
+} EFI_IMAGE_EXPORT_DIRECTORY;\r
+\r
+//\r
+// Import Format\r
+//\r
+typedef struct {\r
+  UINT16  Hint;\r
+  UINT8   Name[1];\r
+} EFI_IMAGE_IMPORT_BY_NAME;\r
+\r
+typedef struct {\r
+  union {\r
+    UINT32                    Function;\r
+    UINT32                    Ordinal;\r
+    EFI_IMAGE_IMPORT_BY_NAME  *AddressOfData;\r
+  } u1;\r
+} EFI_IMAGE_THUNK_DATA;\r
+\r
+#define EFI_IMAGE_ORDINAL_FLAG              0x80000000\r
+#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
+#define EFI_IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)\r
+\r
+typedef struct {\r
+  UINT32                Characteristics;\r
+  UINT32                TimeDateStamp;\r
+  UINT32                ForwarderChain;\r
+  UINT32                Name;\r
+  EFI_IMAGE_THUNK_DATA  *FirstThunk;\r
+} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
+\r
+//\r
+// Debug Format\r
+//\r
+#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
+\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Type;\r
+  UINT32  SizeOfData;\r
+  UINT32  RVA;\r
+  UINT32  FileOffset;\r
+} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_NB10 0x3031424E  // "NB10"\r
+typedef struct {\r
+  UINT32  Signature;                        // "NB10"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_RSDS 0x53445352  // "RSDS"\r
+typedef struct {\r
+  UINT32  Signature;                        // "RSDS"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  UINT32  Unknown4;\r
+  UINT32  Unknown5;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
+\r
+//\r
+// Header format for TE images\r
+//\r
+typedef struct {\r
+  UINT16                    Signature;            // signature for TE format = "VZ"\r
+  UINT16                    Machine;              // from the original file header\r
+  UINT8                     NumberOfSections;     // from the original file header\r
+  UINT8                     Subsystem;            // from original optional header\r
+  UINT16                    StrippedSize;         // how many bytes we removed from the header\r
+  UINT32                    AddressOfEntryPoint;  // offset to entry point -- from original optional header\r
+  UINT32                    BaseOfCode;           // from original image -- required for ITP debug\r
+  UINT64                    ImageBase;            // from original file header\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[2];     // only base relocation and debug directory\r
+} EFI_TE_IMAGE_HEADER;\r
+\r
+#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56      // "VZ"\r
+//\r
+// Data directory indexes in our TE image header\r
+//\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC  0\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG      1\r
+\r
+//\r
+// Union of PE32, PE32+, and TE headers\r
+//\r
+typedef union {\r
+  EFI_IMAGE_NT_HEADERS32   Pe32;\r
+  EFI_IMAGE_NT_HEADERS64   Pe32Plus;\r
+  EFI_TE_IMAGE_HEADER      Te;\r
+} EFI_IMAGE_OPTIONAL_HEADER_UNION;\r
+\r
+typedef union {\r
+  EFI_IMAGE_NT_HEADERS32            *Pe32;\r
+  EFI_IMAGE_NT_HEADERS64            *Pe32Plus;\r
+  EFI_TE_IMAGE_HEADER               *Te;\r
+  EFI_IMAGE_OPTIONAL_HEADER_UNION   *Union;\r
+} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
new file mode 100644 (file)
index 0000000..25a6e02
--- /dev/null
@@ -0,0 +1,292 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiTypes.h\r
+\r
+Abstract:\r
+\r
+  EFI defined types. Use these types when ever possible!\r
+\r
+--*/\r
+\r
+#ifndef _EFI_TYPES_H_\r
+#define _EFI_TYPES_H_\r
+\r
+//\r
+// EFI Data Types based on ANSI C integer types in EfiBind.h\r
+//\r
+typedef uint8_t BOOLEAN;\r
+typedef intn_t INTN;\r
+typedef uintn_t UINTN;\r
+typedef int8_t INT8;\r
+typedef uint8_t UINT8;\r
+typedef int16_t INT16;\r
+typedef uint16_t UINT16;\r
+typedef int32_t INT32;\r
+typedef uint32_t UINT32;\r
+typedef int64_t INT64;\r
+typedef uint64_t UINT64;\r
+typedef uint8_t CHAR8;\r
+typedef uint16_t CHAR16;\r
+typedef UINT64 EFI_LBA;\r
+\r
+//\r
+// Modifiers for EFI Data Types used to self document code.\r
+// Please see EFI coding convention for proper usage.\r
+//\r
+#ifndef IN\r
+//\r
+// Some other envirnments use this construct, so #ifndef to prevent\r
+// mulitple definition.\r
+//\r
+#define IN\r
+#define OUT\r
+#define OPTIONAL\r
+#endif\r
+#define UNALIGNED\r
+\r
+//\r
+// Modifiers for EFI Runtime and Boot Services\r
+//\r
+#define EFI_RUNTIMESERVICE\r
+#define EFI_BOOTSERVICE\r
+\r
+//\r
+// Boot Service add in EFI 1.1\r
+//\r
+#define EFI_BOOTSERVICE11\r
+\r
+//\r
+// Modifiers to absract standard types to aid in debug of problems\r
+//\r
+#define CONST     const\r
+#define STATIC    static\r
+#define VOID      void\r
+#define VOLATILE  volatile\r
+\r
+//\r
+// Modifier to ensure that all protocol member functions and EFI intrinsics\r
+// use the correct C calling convention. All protocol member functions and\r
+// EFI intrinsics are required to modify thier member functions with EFIAPI.\r
+//\r
+#define EFIAPI  _EFIAPI\r
+\r
+//\r
+// EFI Constants. They may exist in other build structures, so #ifndef them.\r
+//\r
+#ifndef TRUE\r
+#define TRUE  ((BOOLEAN) 1 == 1)\r
+#endif\r
+\r
+#ifndef FALSE\r
+#define FALSE ((BOOLEAN) 0 == 1)\r
+#endif\r
+\r
+#ifndef NULL\r
+#define NULL  ((VOID *) 0)\r
+#endif\r
+//\r
+// EFI Data Types derived from other EFI data types.\r
+//\r
+typedef UINTN EFI_STATUS;\r
+\r
+typedef VOID *EFI_HANDLE;\r
+#define NULL_HANDLE ((VOID *) 0)\r
+\r
+typedef VOID *EFI_EVENT;\r
+typedef UINTN EFI_TPL;\r
+\r
+typedef struct {\r
+  UINT32  Data1;\r
+  UINT16  Data2;\r
+  UINT16  Data3;\r
+  UINT8   Data4[8];\r
+} EFI_GUID;\r
+\r
+typedef union {\r
+  EFI_GUID  Guid;\r
+  UINT8     Raw[16];\r
+} EFI_GUID_UNION;\r
+\r
+//\r
+// EFI Time Abstraction:\r
+//  Year:       2000 - 20XX\r
+//  Month:      1 - 12\r
+//  Day:        1 - 31\r
+//  Hour:       0 - 23\r
+//  Minute:     0 - 59\r
+//  Second:     0 - 59\r
+//  Nanosecond: 0 - 999,999,999\r
+//  TimeZone:   -1440 to 1440 or 2047\r
+//\r
+typedef struct {\r
+  UINT16  Year;\r
+  UINT8   Month;\r
+  UINT8   Day;\r
+  UINT8   Hour;\r
+  UINT8   Minute;\r
+  UINT8   Second;\r
+  UINT8   Pad1;\r
+  UINT32  Nanosecond;\r
+  INT16   TimeZone;\r
+  UINT8   Daylight;\r
+  UINT8   Pad2;\r
+} EFI_TIME;\r
+\r
+//\r
+// Bit definitions for EFI_TIME.Daylight\r
+//\r
+#define EFI_TIME_ADJUST_DAYLIGHT  0x01\r
+#define EFI_TIME_IN_DAYLIGHT      0x02\r
+\r
+//\r
+// Value definition for EFI_TIME.TimeZone\r
+//\r
+#define EFI_UNSPECIFIED_TIMEZONE  0x07FF\r
+\r
+//\r
+// Networking\r
+//\r
+typedef struct {\r
+  UINT8 Addr[4];\r
+} EFI_IPv4_ADDRESS;\r
+\r
+typedef struct {\r
+  UINT8 Addr[16];\r
+} EFI_IPv6_ADDRESS;\r
+\r
+typedef struct {\r
+  UINT8 Addr[32];\r
+} EFI_MAC_ADDRESS;\r
+\r
+typedef union {\r
+  UINT32            Addr[4];\r
+  EFI_IPv4_ADDRESS  v4;\r
+  EFI_IPv6_ADDRESS  v6;\r
+} EFI_IP_ADDRESS;\r
+\r
+typedef enum {\r
+  EfiReservedMemoryType,\r
+  EfiLoaderCode,\r
+  EfiLoaderData,\r
+  EfiBootServicesCode,\r
+  EfiBootServicesData,\r
+  EfiRuntimeServicesCode,\r
+  EfiRuntimeServicesData,\r
+  EfiConventionalMemory,\r
+  EfiUnusableMemory,\r
+  EfiACPIReclaimMemory,\r
+  EfiACPIMemoryNVS,\r
+  EfiMemoryMappedIO,\r
+  EfiMemoryMappedIOPortSpace,\r
+  EfiPalCode,\r
+  EfiMaxMemoryType\r
+} EFI_MEMORY_TYPE;\r
+\r
+typedef enum {\r
+  AllocateAnyPages,\r
+  AllocateMaxAddress,\r
+  AllocateAddress,\r
+  MaxAllocateType\r
+} EFI_ALLOCATE_TYPE;\r
+\r
+typedef struct {\r
+  UINT64  Signature;\r
+  UINT32  Revision;\r
+  UINT32  HeaderSize;\r
+  UINT32  CRC32;\r
+  UINT32  Reserved;\r
+} EFI_TABLE_HEADER;\r
+\r
+//\r
+// possible caching types for the memory range\r
+//\r
+#define EFI_MEMORY_UC   0x0000000000000001\r
+#define EFI_MEMORY_WC   0x0000000000000002\r
+#define EFI_MEMORY_WT   0x0000000000000004\r
+#define EFI_MEMORY_WB   0x0000000000000008\r
+#define EFI_MEMORY_UCE  0x0000000000000010\r
+\r
+//\r
+// physical memory protection on range\r
+//\r
+#define EFI_MEMORY_WP 0x0000000000001000\r
+#define EFI_MEMORY_RP 0x0000000000002000\r
+#define EFI_MEMORY_XP 0x0000000000004000\r
+\r
+//\r
+// range requires a runtime mapping\r
+//\r
+#define EFI_MEMORY_RUNTIME  0x8000000000000000\r
+\r
+typedef UINT64  EFI_PHYSICAL_ADDRESS;\r
+typedef UINT64  EFI_VIRTUAL_ADDRESS;\r
+\r
+#define EFI_MEMORY_DESCRIPTOR_VERSION 1\r
+typedef struct {\r
+  UINT32                Type;\r
+  UINT32                Pad;\r
+  EFI_PHYSICAL_ADDRESS  PhysicalStart;\r
+  EFI_VIRTUAL_ADDRESS   VirtualStart;\r
+  UINT64                NumberOfPages;\r
+  UINT64                Attribute;\r
+} EFI_MEMORY_DESCRIPTOR;\r
+\r
+//\r
+// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
+// 4K. This should in no way be confused with the page size of the processor.\r
+// An EFI_PAGE is just the quanta of memory in EFI.\r
+//\r
+#define EFI_PAGE_SIZE         4096\r
+#define EFI_PAGE_MASK         0xFFF\r
+#define EFI_PAGE_SHIFT        12\r
+\r
+#define EFI_SIZE_TO_PAGES(a)  (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
+\r
+#define EFI_PAGES_TO_SIZE(a)   ( (a) << EFI_PAGE_SHIFT)\r
+\r
+//\r
+//  ALIGN_POINTER - aligns a pointer to the lowest boundry\r
+//\r
+#define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))\r
+\r
+//\r
+//  ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
+//\r
+#define ALIGN_VARIABLE(Value, Adjustment) \\r
+  (UINTN) Adjustment = 0; \\r
+  if ((UINTN) Value % sizeof (UINTN)) { \\r
+    (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \\r
+  } \\r
+  Value = (UINTN) Value + (UINTN) Adjustment\r
+\r
+//\r
+//  EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
+//\r
+#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
+\r
+//\r
+//  CONTAINING_RECORD - returns a pointer to the structure\r
+//      from one of it's elements.\r
+//\r
+#define _CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
+\r
+//\r
+// Define macros to build data structure signatures from characters.\r
+//\r
+#define EFI_SIGNATURE_16(A, B)        ((A) | (B << 8))\r
+#define EFI_SIGNATURE_32(A, B, C, D)  (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r
+#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
+    (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h b/EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h
new file mode 100644 (file)
index 0000000..ee0ca1f
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    pxe.h\r
+\r
+Abstract:\r
+\r
+    PXE 2.1 Common Structures\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PXE_H\r
+#define _PXE_H\r
+\r
+//\r
+// Packet definitions\r
+//\r
+typedef struct {\r
+  UINT8   BootpOpcode;\r
+  UINT8   BootpHwType;\r
+  UINT8   BootpHwAddrLen;\r
+  UINT8   BootpGateHops;\r
+  UINT32  BootpIdent;\r
+  UINT16  BootpSeconds;\r
+  UINT16  BootpFlags;\r
+  UINT8   BootpCiAddr[4];\r
+  UINT8   BootpYiAddr[4];\r
+  UINT8   BootpSiAddr[4];\r
+  UINT8   BootpGiAddr[4];\r
+  UINT8   BootpHwAddr[16];\r
+  UINT8   BootpSrvName[64];\r
+  UINT8   BootpBootFile[128];\r
+  UINT32  DhcpMagik;\r
+  UINT8   DhcpOptions[56];\r
+} EFI_PXE_BASE_CODE_DHCPV4_PACKET;\r
+\r
+typedef union {\r
+  UINT8                           Raw[1472];\r
+  EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4;\r
+\r
+  //\r
+  //  EFI_PXE_BASE_CODE_DHCPV6_PACKET     Dhcpv6;\r
+  //\r
+} EFI_PXE_BASE_CODE_PACKET;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c
new file mode 100644 (file)
index 0000000..0ab1f70
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                     \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiTable.c\r
+\r
+Abstract:\r
+\r
+  ACPI Table Protocol from the UEFI 2.1 specification.\r
+\r
+  This protocol may be used to install or remove an ACPI table from a platform.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (AcpiTable)\r
+\r
+EFI_GUID  gEfiAcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpiTableProtocolGuid, "UEFI ACPI Table Protocol", "UEFI ACPI Table Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h
new file mode 100644 (file)
index 0000000..2b7d27f
--- /dev/null
@@ -0,0 +1,112 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                     \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI Table Protocol from the UEFI 2.1 specification.\r
+\r
+  This protocol may be used to install or remove an ACPI table from a platform.\r
+\r
+--*/\r
+\r
+#ifndef __ACPI_TABLE_H__\r
+#define __ACPI_TABLE_H__\r
+\r
+#include "Acpi.h"\r
+\r
+//\r
+// Global ID for the Acpi Table Protocol\r
+//\r
+#define EFI_ACPI_TABLE_PROTOCOL_GUID \\r
+  { \\r
+    0xffe06bdd, 0x6107, 0x46a6, 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_ACPI_TABLE_PROTOCOL);\r
+\r
+#define UEFI_ACPI_TABLE_SIGNATURE    EFI_SIGNATURE_32 ('U', 'E', 'F', 'I')\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER  Header;\r
+  EFI_GUID                     Identifier;\r
+  UINT16                       DataOffset;\r
+} EFI_ACPI_TABLE;\r
+\r
+#pragma pack()\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ACPI_TABLE_INSTALL_ACPI_TABLE) (\r
+  IN EFI_ACPI_TABLE_PROTOCOL                    *This,\r
+  IN VOID                                       *AcpiTableBuffer,\r
+  IN UINTN                                      AcpiTableBufferSize,\r
+  OUT UINTN                                     *TableKey\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Installs an ACPI table into the RSDT/XSDT.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    AcpiTableBuffer       - A pointer to a buffer containing the ACPI table to be installed.\r
+    AcpiTableBufferSize   - Specifies the size, in bytes, of the AcpiTableBuffer buffer.\r
+    TableKey              - Reurns a key to refer to the ACPI table.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The table was successfully inserted.\r
+    EFI_INVALID_PARAMETER - Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize \r
+                            and the size field embedded in the ACPI table pointed to by AcpiTableBuffer\r
+                            are not in sync.\r
+    EFI_OUT_OF_RESOURCES  - Insufficient resources exist to complete the request.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE) (\r
+  IN EFI_ACPI_TABLE_PROTOCOL                    *This,\r
+  IN UINTN                                      TableKey\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Removes an ACPI table from the RSDT/XSDT.\r
+\r
+  Arguments:\r
+    This          - Protocol instance pointer.\r
+    TableKey      - Specifies the table to uninstall.  The key was returned from InstallAcpiTable().\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - The table was successfully uninstalled.\r
+    EFI_NOT_FOUND - TableKey does not refer to a valid key for a table entry.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Interface structure for the ACPI Table Protocol\r
+//\r
+typedef struct _EFI_ACPI_TABLE_PROTOCOL {\r
+  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE    InstallAcpiTable;\r
+  EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE  UninstallAcpiTable;\r
+} EFI_ACPI_TABLE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiAcpiTableProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c
new file mode 100644 (file)
index 0000000..9b6af4c
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Arp.c\r
+\r
+Abstract:\r
+\r
+  UEFI Arp protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Arp)\r
+\r
+EFI_GUID gEfiArpServiceBindingProtocolGuid  = EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID;\r
+EFI_GUID gEfiArpProtocolGuid                = EFI_ARP_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiArpServiceBindingProtocolGuid, "ARP Service Binding Protocol", "ARP Service Binding Protocol");\r
+EFI_GUID_STRING (&gEfiArpProtocolGuid,               "ARP Protocol",                 "ARP Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h
new file mode 100644 (file)
index 0000000..2a7e81f
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Arp.h\r
+\r
+Abstract:\r
+\r
+  UEFI Arp protocol definition.\r
+\r
+--*/\r
+\r
+#ifndef _ARP_H_\r
+#define _ARP_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+\r
+#define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \\r
+  { 0xf44c00ee, 0x1f2c, 0x4a00, 0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 }\r
+\r
+#define EFI_ARP_PROTOCOL_GUID \\r
+  { 0xf4b427bb, 0xba21, 0x4f16, 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_ARP_PROTOCOL);\r
+\r
+typedef struct _EFI_ARP_FIND_DATA {\r
+UINT32               Size;\r
+BOOLEAN              DenyFlag;\r
+BOOLEAN              StaticFlag;\r
+UINT16               HwAddressType;\r
+UINT16               SwAddressType;\r
+UINT8                HwAddressLength;\r
+UINT8                SwAddressLength;\r
+} EFI_ARP_FIND_DATA;\r
+\r
+\r
+//****************************************************\r
+// EFI_ARP_CONFIG_DATA\r
+//****************************************************\r
+typedef struct EFI_ARP_CONFIG_DATA {\r
+  UINT16                    SwAddressType;      // Host byte order\r
+  UINT8                     SwAddressLength;\r
+  VOID                      *StationAddress;    // Network byte order\r
+  UINT32                    EntryTimeOut;\r
+  UINT32                    RetryCount;\r
+  UINT32                    RetryTimeOut;\r
+} EFI_ARP_CONFIG_DATA;\r
+\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_CONFIGURE) (\r
+  IN EFI_ARP_PROTOCOL          *This,\r
+  IN EFI_ARP_CONFIG_DATA       *ConfigData   OPTIONAL\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_ADD) (\r
+  IN EFI_ARP_PROTOCOL  *This,\r
+  IN BOOLEAN           DenyFlag,\r
+  IN VOID              *TargetSwAddress  OPTIONAL,\r
+  IN VOID              *TargetHwAddress  OPTIONAL,\r
+  IN UINT32            TimeoutValue,\r
+  IN BOOLEAN           Overwrite\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_FIND) (\r
+  IN EFI_ARP_PROTOCOL     *This,\r
+  IN BOOLEAN              BySwAddress,\r
+  IN VOID                 *AddressBuffer    OPTIONAL,\r
+  OUT UINT32              *EntryLength      OPTIONAL,\r
+  OUT UINT32              *EntryCount       OPTIONAL,\r
+  OUT EFI_ARP_FIND_DATA   **Entries         OPTIONAL,\r
+  IN BOOLEAN              Refresh\r
+);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_DELETE) (\r
+  IN EFI_ARP_PROTOCOL      *This,\r
+  IN BOOLEAN               BySwAddress,\r
+  IN VOID                  *AddressBuffer   OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_FLUSH) (\r
+  IN EFI_ARP_PROTOCOL  *This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_REQUEST) (\r
+  IN EFI_ARP_PROTOCOL  *This, \r
+  IN VOID              *TargetSwAddress  OPTIONAL,\r
+  IN EFI_EVENT         ResolvedEvent     OPTIONAL,\r
+  OUT VOID             *TargetHwAddress  \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ARP_CANCEL) (\r
+IN EFI_ARP_PROTOCOL  *This, \r
+IN VOID              *TargetSwAddress  OPTIONAL,\r
+IN EFI_EVENT         ResolvedEvent     OPTIONAL\r
+);\r
+\r
+typedef struct _EFI_ARP_PROTOCOL {\r
+  EFI_ARP_CONFIGURE         Configure;\r
+  EFI_ARP_ADD               Add;\r
+  EFI_ARP_FIND              Find;\r
+  EFI_ARP_DELETE            Delete;\r
+  EFI_ARP_FLUSH             Flush;\r
+  EFI_ARP_REQUEST           Request;\r
+  EFI_ARP_CANCEL            Cancel;\r
+} EFI_ARP_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiArpServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiArpProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c
new file mode 100644 (file)
index 0000000..649f51c
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bis.c\r
+\r
+Abstract:\r
+\r
+  This file defines the Bis protocol\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Bis)\r
+\r
+EFI_GUID  gEfiBisProtocolGuid = EFI_BIS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiBisProtocolGuid, "BIS Base Protocol", "BIS Base protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h
new file mode 100644 (file)
index 0000000..71d5fb3
--- /dev/null
@@ -0,0 +1,233 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bis.h\r
+\r
+Abstract:\r
+\r
+  This file defines the BIS protocol.\r
+\r
+--*/\r
+\r
+#ifndef _BIS_H_\r
+#define _BIS_H_\r
+\r
+#include <EfiSpec.h>\r
+\r
+//\r
+// Basic types\r
+//\r
+typedef VOID    *BIS_APPLICATION_HANDLE;\r
+typedef UINT16  BIS_ALG_ID;\r
+typedef UINT32  BIS_CERT_ID;\r
+\r
+//\r
+// EFI_BIS_DATA type.\r
+//\r
+// EFI_BIS_DATA instances obtained from BIS must be freed by calling Free( ).\r
+//\r
+typedef struct _EFI_BIS_DATA {\r
+  UINT32  Length; // Length of Data in 8 bit bytes.\r
+  UINT8   *Data;  // 32 Bit Flat Address of data.\r
+} EFI_BIS_DATA;\r
+\r
+//\r
+// EFI_BIS_VERSION type.\r
+//\r
+typedef struct _EFI_BIS_VERSION {\r
+  UINT32  Major;  // BIS Interface version number.\r
+  UINT32  Minor;  // Build number.\r
+} EFI_BIS_VERSION;\r
+\r
+//\r
+// ----------------------------------------------------//\r
+// Use these values to initialize EFI_BIS_VERSION.Major\r
+// and to interpret results of Initialize.\r
+// ----------------------------------------------------//\r
+//\r
+#define BIS_CURRENT_VERSION_MAJOR BIS_VERSION_1\r
+#define BIS_VERSION_1             1\r
+\r
+//\r
+// EFI_BIS_SIGNATURE_INFO type.\r
+//\r
+typedef struct _EFI_BIS_SIGNATURE_INFO {\r
+  BIS_CERT_ID CertificateID;  // Truncated hash of platform Boot Object\r
+  //  authorization certificate.\r
+  //\r
+  BIS_ALG_ID  AlgorithmID;  // A signature algorithm number.\r
+  UINT16      KeyLength;    // Length of alg. keys in bits.\r
+} EFI_BIS_SIGNATURE_INFO;\r
+\r
+//\r
+// Currently defined values for EFI_BIS_SIGNATURE_INFO.AlgorithmID.\r
+// The exact numeric values come from\r
+//    "Common Data Security Architecture (CDSA) Specification".\r
+//\r
+#define BIS_ALG_DSA     (41)  // CSSM_ALGID_DSA\r
+#define BIS_ALG_RSA_MD5 (42)  // CSSM_ALGID_MD5_WITH_RSA\r
+// Currently defined values for EFI_BIS_SIGNATURE_INFO.CertificateId.\r
+//\r
+#define BIS_CERT_ID_DSA     BIS_ALG_DSA     // CSSM_ALGID_DSA\r
+#define BIS_CERT_ID_RSA_MD5 BIS_ALG_RSA_MD5 // CSSM_ALGID_MD5_WITH_RSA\r
+// The  following  is a mask value that gets applied to the truncated hash of a\r
+// platform  Boot Object Authorization Certificate to create the certificateID.\r
+// A certificateID must not have any bits set to the value 1 other than bits in\r
+// this mask.\r
+//\r
+#define BIS_CERT_ID_MASK  (0xFF7F7FFF)\r
+\r
+//\r
+// Macros for dealing with the EFI_BIS_DATA object obtained\r
+// from BIS_GetSignatureInfo()\r
+// BIS_GET_SIGINFO_COUNT - tells how many EFI_BIS_SIGNATURE_INFO\r
+//  elements are contained in a EFI_BIS_DATA struct pointed to\r
+//  by the provided EFI_BIS_DATA*.\r
+//\r
+#define BIS_GET_SIGINFO_COUNT(BisDataPtr) ((BisDataPtr)->Length / sizeof (EFI_BIS_SIGNATURE_INFO))\r
+\r
+//\r
+// BIS_GET_SIGINFO_ARRAY - produces a EFI_BIS_SIGNATURE_INFO*\r
+//  from a given EFI_BIS_DATA*.\r
+//\r
+#define BIS_GET_SIGINFO_ARRAY(BisDataPtr) ((EFI_BIS_SIGNATURE_INFO *) (BisDataPtr)->Data)\r
+\r
+//\r
+// Binary Value of "X-Intel-BIS-ParameterSet" Attribute.\r
+// (Value is Base64 encoded in actual signed manifest).\r
+// {EDD35E31-07B9-11d2-83A3-00A0C91FADCF}\r
+//\r
+#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE \\r
+  { \\r
+    0xedd35e31, 0x7b9, 0x11d2, \\r
+    { \\r
+      0x83, 0xa3, 0x0, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \\r
+    } \\r
+  }\r
+\r
+//\r
+// -----------------------------------//\r
+//  EFI_BIS_PROTOCOL\r
+// -----------------------------------//\r
+//\r
+#define EFI_BIS_PROTOCOL_GUID \\r
+  { \\r
+    0x0b64aab0, 0x5429, 0x11d4, 0x98, 0x16, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \\r
+  }\r
+\r
+typedef struct _EFI_BIS_PROTOCOL  EFI_BIS_PROTOCOL;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_INITIALIZE) (\r
+  IN     EFI_BIS_PROTOCOL        * This,              // this\r
+  OUT    BIS_APPLICATION_HANDLE  * AppHandle,         // Application handle.\r
+  IN OUT EFI_BIS_VERSION         * InterfaceVersion,  // ver needed/available.\r
+  IN     EFI_BIS_DATA            * TargetAddress      // Address of BIS platform.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_FREE) (\r
+  IN BIS_APPLICATION_HANDLE  AppHandle,               // From Initialize( ).\r
+  IN EFI_BIS_DATA            * ToFree                 // EFI_BIS_DATA being freed.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_SHUTDOWN) (\r
+  IN BIS_APPLICATION_HANDLE  AppHandle                // From Initialize( ).\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE) (\r
+  IN  BIS_APPLICATION_HANDLE  AppHandle,              // From Initialize( ).\r
+  OUT EFI_BIS_DATA            **Certificate           // Pointer to certificate.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_VERIFY_BOOT_OBJECT) (\r
+  IN  BIS_APPLICATION_HANDLE AppHandle,               // From Initialize( ).\r
+  IN  EFI_BIS_DATA           * Credentials,           // Verification signed manifest.\r
+  IN  EFI_BIS_DATA           * DataObject,            // Boot object to verify.\r
+  OUT BOOLEAN                *IsVerified              // Result of verifcation.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG) (\r
+  IN  BIS_APPLICATION_HANDLE  AppHandle,              // From Initialize( ).\r
+  OUT BOOLEAN                 *CheckIsRequired        // Value of check flag.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN) (\r
+  IN  BIS_APPLICATION_HANDLE  AppHandle,              // From Initialize( ).\r
+  OUT EFI_BIS_DATA            **UpdateToken           // Value of update token.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION) (\r
+  IN  BIS_APPLICATION_HANDLE AppHandle,               // From Initialize( ).\r
+  IN  EFI_BIS_DATA           * RequestCredential,     // Update Request Manifest.\r
+  OUT EFI_BIS_DATA           **NewUpdateToken         // Next update token.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL) (\r
+  IN  BIS_APPLICATION_HANDLE AppHandle,               //  From Initialize( ).\r
+  IN  EFI_BIS_DATA           * Credentials,           //  Verification signed manifest.\r
+  IN  EFI_BIS_DATA           * DataObject,            //  Boot object to verify.\r
+  IN  EFI_BIS_DATA           * SectionName,           //  Name of credential section to use.\r
+  IN  EFI_BIS_DATA           * AuthorityCertificate,  // Certificate for credentials.\r
+  OUT BOOLEAN                *IsVerified              // Result of verifcation.\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BIS_GET_SIGNATURE_INFO) (\r
+  IN  BIS_APPLICATION_HANDLE  AppHandle,              //  From Initialize( ).\r
+  OUT EFI_BIS_DATA            **SignatureInfo         // Signature info struct.\r
+  );\r
+\r
+#define EFI_BIS_PROTOCOL_REVISION 0x00010000\r
+\r
+typedef struct _EFI_BIS_PROTOCOL {\r
+  //\r
+  // member vars\r
+  //\r
+  UINT64                                              Revision;\r
+\r
+  //\r
+  // methods\r
+  //\r
+  EFI_BIS_INITIALIZE                                  Initialize;\r
+  EFI_BIS_SHUTDOWN                                    Shutdown;\r
+  EFI_BIS_FREE                                        Free;\r
+  EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE   GetBootObjectAuthorizationCertificate;\r
+  EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG     GetBootObjectAuthorizationCheckFlag;\r
+  EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN  GetBootObjectAuthorizationUpdateToken;\r
+  EFI_BIS_GET_SIGNATURE_INFO                          GetSignatureInfo;\r
+  EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION            UpdateBootObjectAuthorization;\r
+  EFI_BIS_VERIFY_BOOT_OBJECT                          VerifyBootObject;\r
+  EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL               VerifyObjectWithCredential;\r
+} EFI_BIS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiBisProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c
new file mode 100644 (file)
index 0000000..5b7ac39
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BlockIo.c\r
+\r
+Abstract:\r
+\r
+  Block IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  The Block IO protocol is used to abstract block devices like hard drives,\r
+  DVD-ROMs and floppy drives.\r
+\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (BlockIo)\r
+\r
+EFI_GUID  gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiBlockIoProtocolGuid, "BlockIo Protocol", "EFI 1.0 Block IO protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h
new file mode 100644 (file)
index 0000000..740b58d
--- /dev/null
@@ -0,0 +1,206 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BlockIo.h\r
+\r
+Abstract:\r
+\r
+  Block IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  The Block IO protocol is used to abstract block devices like hard drives,\r
+  DVD-ROMs and floppy drives.\r
+\r
\r
+--*/\r
+\r
+#ifndef __BLOCK_IO_H__\r
+#define __BLOCK_IO_H__\r
+\r
+#define EFI_BLOCK_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_BLOCK_IO_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BLOCK_RESET) (\r
+  IN EFI_BLOCK_IO_PROTOCOL          * This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the Block Device.\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BLOCK_READ) (\r
+  IN EFI_BLOCK_IO_PROTOCOL          * This,\r
+  IN UINT32                         MediaId,\r
+  IN EFI_LBA                        Lba,\r
+  IN UINTN                          BufferSize,\r
+  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Read BufferSize bytes from Lba into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced.\r
+    Lba        - The starting Logical Block Address to read from\r
+    BufferSize - Size of Buffer, must be a multiple of device block size.\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was read correctly from the device.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the read.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHANGED     - The MediaId does not matched the current device.\r
+    EFI_BAD_BUFFER_SIZE   - The Buffer was not a multiple of the block size of the \r
+                            device.\r
+    EFI_INVALID_PARAMETER - The read request contains device addresses that are not \r
+                            valid for the device.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BLOCK_WRITE) (\r
+  IN EFI_BLOCK_IO_PROTOCOL          * This,\r
+  IN UINT32                         MediaId,\r
+  IN EFI_LBA                        Lba,\r
+  IN UINTN                          BufferSize,\r
+  IN VOID                           *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Write BufferSize bytes from Lba into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced.\r
+    Lba        - The starting Logical Block Address to read from\r
+    BufferSize - Size of Buffer, must be a multiple of device block size.\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was written correctly to the device.\r
+    EFI_WRITE_PROTECTED   - The device can not be written to.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the write.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHNAGED     - The MediaId does not matched the current device.\r
+    EFI_BAD_BUFFER_SIZE   - The Buffer was not a multiple of the block size of the \r
+                            device.\r
+    EFI_INVALID_PARAMETER - The write request contains a LBA that is not \r
+                            valid for the device.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BLOCK_FLUSH) (\r
+  IN EFI_BLOCK_IO_PROTOCOL  * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Flush the Block Device.\r
+\r
+  Arguments:\r
+    This             - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - All outstanding data was written to the device\r
+    EFI_DEVICE_ERROR - The device reported an error while writting back the data\r
+    EFI_NO_MEDIA     - There is no media in the device.\r
+\r
+--*/\r
+;\r
+\r
+/*++\r
+\r
+  Block IO read only mode data and updated only via members of BlockIO\r
+\r
+  MediaId - The curent media Id. If the media changes, this value is changed.\r
+  RemovableMedia - TRUE if the media is removable; otherwise, FALSE.\r
+  MediaPresent   -  TRUE if there is a media currently present in the device;\r
+                    othersise, FALSE. THis field shows the media present status\r
+                    as of the most recent ReadBlocks() or WriteBlocks() call.\r
+  LogicalPartition - TRUE if LBA 0 is the first block of a partition; otherwise\r
+                     FALSE. For media with only one partition this would be TRUE.\r
+  ReadOnly         - TRUE if the media is marked read-only otherwise, FALSE. This\r
+                     field shows the read-only status as of the most recent \r
+                     WriteBlocks () call.\r
+  WriteCaching     - TRUE if the WriteBlock () function caches write data.\r
+  BlockSize - The intrinsic block size of the device. If the media changes, then\r
+               this field is updated.\r
+  IoAlign   - Supplies the alignment requirement for any buffer to read or write\r
+               block(s).\r
+  LastBlock - The last logical block address on the device. If the media changes,\r
+               then this field is updated.\r
+\r
+--*/\r
+typedef struct {\r
+  UINT32  MediaId;\r
+  BOOLEAN RemovableMedia;\r
+  BOOLEAN MediaPresent;\r
+\r
+  BOOLEAN LogicalPartition;\r
+  BOOLEAN ReadOnly;\r
+  BOOLEAN WriteCaching;\r
+\r
+  UINT32  BlockSize;\r
+  UINT32  IoAlign;\r
+\r
+  EFI_LBA LastBlock;\r
+} EFI_BLOCK_IO_MEDIA;\r
+\r
+#define EFI_BLOCK_IO_PROTOCOL_REVISION  0x00010000\r
+\r
+typedef struct _EFI_BLOCK_IO_PROTOCOL {\r
+  UINT64              Revision;\r
+\r
+  EFI_BLOCK_IO_MEDIA  *Media;\r
+\r
+  EFI_BLOCK_RESET     Reset;\r
+  EFI_BLOCK_READ      ReadBlocks;\r
+  EFI_BLOCK_WRITE     WriteBlocks;\r
+  EFI_BLOCK_FLUSH     FlushBlocks;\r
+\r
+} EFI_BLOCK_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiBlockIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c
new file mode 100644 (file)
index 0000000..4b4a44d
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BusSpecificDriverOverride.c\r
+\r
+Abstract:\r
+\r
+  Bus Specific Driver Override protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride)\r
+\r
+EFI_GUID  gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiBusSpecificDriverOverrideProtocolGuid, "Bus Specific Driver Override Protocol",\r
+      "EFI 1.1 Bus Specific Driver Override Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h
new file mode 100644 (file)
index 0000000..ad7eade
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BusSpecificDriverOverride.h\r
+\r
+Abstract:\r
+\r
+  Bus Specific Driver Override protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_\r
+#define _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_\r
+\r
+//\r
+// Global ID for the Bus Specific Driver Override Protocol\r
+//\r
+#define EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID \\r
+  { \\r
+    0x3bc1b285, 0x8a15, 0x4a82, 0xaa, 0xbf, 0x4d, 0x7d, 0x13, 0xfb, 0x32, 0x65 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL);\r
+\r
+//\r
+// Prototypes for the Bus Specific Driver Override Protocol\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER) (\r
+  IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL              * This,\r
+  IN OUT EFI_HANDLE                                         * DriverImageHandle\r
+  );\r
+\r
+//\r
+// Interface structure for the Bus Specific Driver Override Protocol\r
+//\r
+typedef struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL {\r
+  EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER GetDriver;\r
+} EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c
new file mode 100644 (file)
index 0000000..0d0d312
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ComponentName.c\r
+    \r
+Abstract:\r
+\r
+    EFI Component Name Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName)\r
+\r
+EFI_GUID  gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiComponentNameProtocolGuid, "Component Name Protocol", "EFI 1.1 Component Name Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h
new file mode 100644 (file)
index 0000000..9842523
--- /dev/null
@@ -0,0 +1,137 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ComponentName.h\r
+    \r
+Abstract:\r
+\r
+    EFI Component Name Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMPONENT_NAME_H_\r
+#define _EFI_COMPONENT_NAME_H_\r
+\r
+//\r
+// Global ID for the Component Name Protocol\r
+//\r
+#define EFI_COMPONENT_NAME_PROTOCOL_GUID \\r
+  { \\r
+    0x107a772c, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) (\r
+  IN EFI_COMPONENT_NAME_PROTOCOL           * This,\r
+  IN  CHAR8                                *Language,\r
+  OUT CHAR16                               **DriverName\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) (\r
+  IN EFI_COMPONENT_NAME_PROTOCOL                              * This,\r
+  IN  EFI_HANDLE                                              ControllerHandle,\r
+  IN  EFI_HANDLE                                              ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                   *Language,\r
+  OUT CHAR16                                                  **ControllerName\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the Component Name Protocol\r
+//\r
+typedef struct _EFI_COMPONENT_NAME_PROTOCOL {\r
+  EFI_COMPONENT_NAME_GET_DRIVER_NAME      GetDriverName;\r
+  EFI_COMPONENT_NAME_GET_CONTROLLER_NAME  GetControllerName;\r
+  CHAR8                                   *SupportedLanguages;\r
+} EFI_COMPONENT_NAME_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiComponentNameProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c
new file mode 100644 (file)
index 0000000..fee053e
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ComponentName.c\r
+    \r
+Abstract:\r
+\r
+    EFI Component Name Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)\r
+\r
+EFI_GUID  gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiComponentName2ProtocolGuid, "Component Name2 Protocol", "EFI 2.0 Component Name2 Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
new file mode 100644 (file)
index 0000000..4f6bb35
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ComponentName.h\r
+    \r
+Abstract:\r
+\r
+    EFI Component Name Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMPONENT_NAME2_H_\r
+#define _EFI_COMPONENT_NAME2_H_\r
+\r
+//\r
+// Global ID for the Component Name Protocol\r
+//\r
+\r
+#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \\r
+  { \\r
+    0x6a7a5cff, 0xe8d9, 0x4f70, 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME2_PROTOCOL);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_COMPONENT_NAME2_GET_DRIVER_NAME) (\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL          * This,\r
+  IN  CHAR8                                *Language,\r
+  OUT CHAR16                               **DriverName\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL or DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) (\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL                             * This,\r
+  IN  EFI_HANDLE                                              ControllerHandle,\r
+  IN  EFI_HANDLE                                              ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                   *Language,\r
+  OUT CHAR16                                                  **ControllerName\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE; ChildHandle \r
+                            is not NULL and it is not a valid EFI_HANDLE;Language \r
+                            is NULL;ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle;The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the Component Name Protocol\r
+//\r
+typedef struct _EFI_COMPONENT_NAME2_PROTOCOL {\r
+  EFI_COMPONENT_NAME2_GET_DRIVER_NAME      GetDriverName;\r
+  EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME  GetControllerName;\r
+  CHAR8                                    *SupportedLanguages;\r
+} EFI_COMPONENT_NAME2_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiComponentName2ProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c
new file mode 100644 (file)
index 0000000..f6db9ea
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugPort.c\r
+\r
+Abstract:\r
+\r
+  DebugPort protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DebugPort)\r
+\r
+EFI_GUID  gEfiDebugPortProtocolGuid = EFI_DEBUGPORT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDebugPortProtocolGuid, "DebugPort Protocol", "EFI 1.1 DebugPort Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h
new file mode 100644 (file)
index 0000000..af80b75
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DebugPort.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _DEBUG_PORT_H_\r
+#define _DEBUG_PORT_H_\r
+\r
+#include "EfiApi.h"\r
+\r
+//\r
+// DebugPortIo protocol {EBA4E8D2-3858-41EC-A281-2647BA9660D0}\r
+//\r
+#define EFI_DEBUGPORT_PROTOCOL_GUID \\r
+  { \\r
+    0xEBA4E8D2, 0x3858, 0x41EC, 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 \\r
+  }\r
+\r
+extern EFI_GUID gEfiDebugPortProtocolGuid;\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DEBUGPORT_PROTOCOL);\r
+\r
+//\r
+// DebugPort member functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUGPORT_RESET) (\r
+  IN EFI_DEBUGPORT_PROTOCOL               * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUGPORT_WRITE) (\r
+  IN EFI_DEBUGPORT_PROTOCOL               * This,\r
+  IN UINT32                               Timeout,\r
+  IN OUT UINTN                            *BufferSize,\r
+  IN VOID                                 *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUGPORT_READ) (\r
+  IN EFI_DEBUGPORT_PROTOCOL               * This,\r
+  IN UINT32                               Timeout,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUGPORT_POLL) (\r
+  IN EFI_DEBUGPORT_PROTOCOL               * This\r
+  );\r
+\r
+//\r
+// DebugPort protocol definition\r
+//\r
+typedef struct _EFI_DEBUGPORT_PROTOCOL {\r
+  EFI_DEBUGPORT_RESET Reset;\r
+  EFI_DEBUGPORT_WRITE Write;\r
+  EFI_DEBUGPORT_READ  Read;\r
+  EFI_DEBUGPORT_POLL  Poll;\r
+} EFI_DEBUGPORT_PROTOCOL;\r
+\r
+//\r
+// DEBUGPORT variable definitions...\r
+//\r
+#define EFI_DEBUGPORT_VARIABLE_NAME L"DEBUGPORT"\r
+#define EFI_DEBUGPORT_VARIABLE_GUID EFI_DEBUGPORT_PROTOCOL_GUID\r
+#define gEfiDebugPortVariableGuid   gEfiDebugPortProtocolGuid\r
+\r
+//\r
+// DebugPort device path definitions...\r
+//\r
+#define DEVICE_PATH_MESSAGING_DEBUGPORT EFI_DEBUGPORT_PROTOCOL_GUID\r
+#define gEfiDebugPortDevicePathGuid     gEfiDebugPortProtocolGuid\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+} DEBUGPORT_DEVICE_PATH;\r
+\r
+#endif /* _DEBUG_PORT_H_ */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c
new file mode 100644 (file)
index 0000000..b770ffb
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugSupport.c\r
+\r
+Abstract:\r
+\r
+  DebugSupport protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)\r
+\r
+EFI_GUID  gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDebugSupportProtocolGuid, "DebugSupport Protocol", "EFI 1.1 DebugSupport Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h
new file mode 100644 (file)
index 0000000..d5ed15f
--- /dev/null
@@ -0,0 +1,594 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugSupport.h\r
+\r
+Abstract:\r
+\r
+  DebugSupport protocol and supporting definitions as defined in the EFI 1.1\r
+  specification.\r
+  \r
+  The DebugSupport protocol is used by source level debuggers to abstract the\r
+  processor and handle context save and restore operations.\r
\r
+--*/\r
+\r
+#ifndef _DEBUG_SUPPORT_H_\r
+#define _DEBUG_SUPPORT_H_\r
+\r
+#include "EfiApi.h"\r
+#include "EfiImage.h"\r
+//\r
+// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25}\r
+//\r
+#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \\r
+  { \\r
+    0x2755590C, 0x6F3C, 0x42FA, 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 \\r
+  }\r
+\r
+//\r
+// Debug Support definitions\r
+//\r
+typedef INTN  EFI_EXCEPTION_TYPE;\r
+\r
+//\r
+//  IA-32 processor exception types\r
+//\r
+#define EXCEPT_IA32_DIVIDE_ERROR    0\r
+#define EXCEPT_IA32_DEBUG           1\r
+#define EXCEPT_IA32_NMI             2\r
+#define EXCEPT_IA32_BREAKPOINT      3\r
+#define EXCEPT_IA32_OVERFLOW        4\r
+#define EXCEPT_IA32_BOUND           5\r
+#define EXCEPT_IA32_INVALID_OPCODE  6\r
+#define EXCEPT_IA32_DOUBLE_FAULT    8\r
+#define EXCEPT_IA32_INVALID_TSS     10\r
+#define EXCEPT_IA32_SEG_NOT_PRESENT 11\r
+#define EXCEPT_IA32_STACK_FAULT     12\r
+#define EXCEPT_IA32_GP_FAULT        13\r
+#define EXCEPT_IA32_PAGE_FAULT      14\r
+#define EXCEPT_IA32_FP_ERROR        16\r
+#define EXCEPT_IA32_ALIGNMENT_CHECK 17\r
+#define EXCEPT_IA32_MACHINE_CHECK   18\r
+#define EXCEPT_IA32_SIMD            19\r
+\r
+//\r
+//  IA-32 processor context definition\r
+//\r
+//\r
+// FXSAVE_STATE\r
+// FP / MMX / XMM registers (see fxrstor instruction definition)\r
+//\r
+typedef struct {\r
+  UINT16  Fcw;\r
+  UINT16  Fsw;\r
+  UINT16  Ftw;\r
+  UINT16  Opcode;\r
+  UINT32  Eip;\r
+  UINT16  Cs;\r
+  UINT16  Reserved1;\r
+  UINT32  DataOffset;\r
+  UINT16  Ds;\r
+  UINT8   Reserved2[10];\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  UINT8   St0Mm0[10], Reserved3[6];\r
+  UINT8   St1Mm1[10], Reserved4[6];\r
+  UINT8   St2Mm2[10], Reserved5[6];\r
+  UINT8   St3Mm3[10], Reserved6[6];\r
+  UINT8   St4Mm4[10], Reserved7[6];\r
+  UINT8   St5Mm5[10], Reserved8[6];\r
+  UINT8   St6Mm6[10], Reserved9[6];\r
+  UINT8   St7Mm7[10], Reserved10[6];\r
+  UINT8   Xmm0[16];\r
+  UINT8   Xmm1[16];\r
+  UINT8   Xmm2[16];\r
+  UINT8   Xmm3[16];\r
+  UINT8   Xmm4[16];\r
+  UINT8   Xmm5[16];\r
+  UINT8   Xmm6[16];\r
+  UINT8   Xmm7[16];\r
+  UINT8   Reserved11[14 * 16];\r
+} EFI_FX_SAVE_STATE_IA32;\r
+#else\r
+  UINT8   St0Mm0[10], Reserved3[6];\r
+  UINT8   St0Mm1[10], Reserved4[6];\r
+  UINT8   St0Mm2[10], Reserved5[6];\r
+  UINT8   St0Mm3[10], Reserved6[6];\r
+  UINT8   St0Mm4[10], Reserved7[6];\r
+  UINT8   St0Mm5[10], Reserved8[6];\r
+  UINT8   St0Mm6[10], Reserved9[6];\r
+  UINT8   St0Mm7[10], Reserved10[6];\r
+  UINT8   Reserved11[22 * 16];\r
+} EFI_FX_SAVE_STATE;\r
+#endif\r
+\r
+typedef struct {\r
+  UINT32                 ExceptionData;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  EFI_FX_SAVE_STATE_IA32 FxSaveState;\r
+#else\r
+  EFI_FX_SAVE_STATE      FxSaveState;\r
+#endif\r
+  UINT32                 Dr0;\r
+  UINT32                 Dr1;\r
+  UINT32                 Dr2;\r
+  UINT32                 Dr3;\r
+  UINT32                 Dr6;\r
+  UINT32                 Dr7;\r
+  UINT32                 Cr0;\r
+  UINT32                 Cr1;  /* Reserved */\r
+  UINT32                 Cr2;\r
+  UINT32                 Cr3;\r
+  UINT32                 Cr4;\r
+  UINT32                 Eflags;\r
+  UINT32                 Ldtr;\r
+  UINT32                 Tr;\r
+  UINT32                 Gdtr[2];\r
+  UINT32                 Idtr[2];\r
+  UINT32                 Eip;\r
+  UINT32                 Gs;\r
+  UINT32                 Fs;\r
+  UINT32                 Es;\r
+  UINT32                 Ds;\r
+  UINT32                 Cs;\r
+  UINT32                 Ss;\r
+  UINT32                 Edi;\r
+  UINT32                 Esi;\r
+  UINT32                 Ebp;\r
+  UINT32                 Esp;\r
+  UINT32                 Ebx;\r
+  UINT32                 Edx;\r
+  UINT32                 Ecx;\r
+  UINT32                 Eax;\r
+} EFI_SYSTEM_CONTEXT_IA32;\r
+\r
+//\r
+//  X64 processor exception types\r
+//\r
+#define EXCEPT_X64_DIVIDE_ERROR    0\r
+#define EXCEPT_X64_DEBUG           1\r
+#define EXCEPT_X64_NMI             2\r
+#define EXCEPT_X64_BREAKPOINT      3\r
+#define EXCEPT_X64_OVERFLOW        4\r
+#define EXCEPT_X64_BOUND           5\r
+#define EXCEPT_X64_INVALID_OPCODE  6\r
+#define EXCEPT_X64_DOUBLE_FAULT    8\r
+#define EXCEPT_X64_INVALID_TSS     10\r
+#define EXCEPT_X64_SEG_NOT_PRESENT 11\r
+#define EXCEPT_X64_STACK_FAULT     12\r
+#define EXCEPT_X64_GP_FAULT        13\r
+#define EXCEPT_X64_PAGE_FAULT      14\r
+#define EXCEPT_X64_FP_ERROR        16\r
+#define EXCEPT_X64_ALIGNMENT_CHECK 17\r
+#define EXCEPT_X64_MACHINE_CHECK   18\r
+#define EXCEPT_X64_SIMD            19\r
+\r
+//\r
+//  X64 processor context definition\r
+//\r
+// FXSAVE_STATE\r
+// FP / MMX / XMM registers (see fxrstor instruction definition)\r
+//\r
+typedef struct {\r
+  UINT16  Fcw;\r
+  UINT16  Fsw;\r
+  UINT16  Ftw;\r
+  UINT16  Opcode;\r
+  UINT64  Rip;\r
+  UINT64  DataOffset;\r
+  UINT8   Reserved1[8];\r
+  UINT8   St0Mm0[10], Reserved2[6];\r
+  UINT8   St1Mm1[10], Reserved3[6];\r
+  UINT8   St2Mm2[10], Reserved4[6];\r
+  UINT8   St3Mm3[10], Reserved5[6];\r
+  UINT8   St4Mm4[10], Reserved6[6];\r
+  UINT8   St5Mm5[10], Reserved7[6];\r
+  UINT8   St6Mm6[10], Reserved8[6];\r
+  UINT8   St7Mm7[10], Reserved9[6];\r
+  UINT8   Xmm0[16];\r
+  UINT8   Xmm1[16];\r
+  UINT8   Xmm2[16];\r
+  UINT8   Xmm3[16];\r
+  UINT8   Xmm4[16];\r
+  UINT8   Xmm5[16];\r
+  UINT8   Xmm6[16];\r
+  UINT8   Xmm7[16];\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // NOTE: UEFI 2.0 spec definition as follows. It should be updated \r
+  // after spec update.\r
+  //\r
+  UINT8   Reserved11[14 * 16];\r
+#else\r
+  UINT8   Xmm8[16];\r
+  UINT8   Xmm9[16];\r
+  UINT8   Xmm10[16];\r
+  UINT8   Xmm11[16];\r
+  UINT8   Xmm12[16];\r
+  UINT8   Xmm13[16];\r
+  UINT8   Xmm14[16];\r
+  UINT8   Xmm15[16];\r
+  UINT8   Reserved10[6 * 16];\r
+#endif\r
+} EFI_FX_SAVE_STATE_X64;\r
+\r
+typedef struct {\r
+  UINT64                ExceptionData;\r
+  EFI_FX_SAVE_STATE_X64 FxSaveState;\r
+  UINT64                Dr0;\r
+  UINT64                Dr1;\r
+  UINT64                Dr2;\r
+  UINT64                Dr3;\r
+  UINT64                Dr6;\r
+  UINT64                Dr7;\r
+  UINT64                Cr0;\r
+  UINT64                Cr1;  /* Reserved */\r
+  UINT64                Cr2;\r
+  UINT64                Cr3;\r
+  UINT64                Cr4;\r
+  UINT64                Cr8;\r
+  UINT64                Rflags;\r
+  UINT64                Ldtr;\r
+  UINT64                Tr;\r
+  UINT64                Gdtr[2];\r
+  UINT64                Idtr[2];\r
+  UINT64                Rip;\r
+  UINT64                Gs;\r
+  UINT64                Fs;\r
+  UINT64                Es;\r
+  UINT64                Ds;\r
+  UINT64                Cs;\r
+  UINT64                Ss;\r
+  UINT64                Rdi;\r
+  UINT64                Rsi;\r
+  UINT64                Rbp;\r
+  UINT64                Rsp;\r
+  UINT64                Rbx;\r
+  UINT64                Rdx;\r
+  UINT64                Rcx;\r
+  UINT64                Rax;\r
+  UINT64                R8;\r
+  UINT64                R9;\r
+  UINT64                R10;\r
+  UINT64                R11;\r
+  UINT64                R12;\r
+  UINT64                R13;\r
+  UINT64                R14;\r
+  UINT64                R15;\r
+} EFI_SYSTEM_CONTEXT_X64;\r
+\r
+//\r
+//  IPF processor exception types\r
+//\r
+#define EXCEPT_IPF_VHTP_TRANSLATION       0\r
+#define EXCEPT_IPF_INSTRUCTION_TLB        1\r
+#define EXCEPT_IPF_DATA_TLB               2\r
+#define EXCEPT_IPF_ALT_INSTRUCTION_TLB    3\r
+#define EXCEPT_IPF_ALT_DATA_TLB           4\r
+#define EXCEPT_IPF_DATA_NESTED_TLB        5\r
+#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6\r
+#define EXCEPT_IPF_DATA_KEY_MISSED        7\r
+#define EXCEPT_IPF_DIRTY_BIT              8\r
+#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9\r
+#define EXCEPT_IPF_DATA_ACCESS_BIT        10\r
+#define EXCEPT_IPF_BREAKPOINT             11\r
+#define EXCEPT_IPF_EXTERNAL_INTERRUPT     12\r
+//\r
+// 13 - 19 reserved\r
+//\r
+#define EXCEPT_IPF_PAGE_NOT_PRESENT           20\r
+#define EXCEPT_IPF_KEY_PERMISSION             21\r
+#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS  22\r
+#define EXCEPT_IPF_DATA_ACCESS_RIGHTS         23\r
+#define EXCEPT_IPF_GENERAL_EXCEPTION          24\r
+#define EXCEPT_IPF_DISABLED_FP_REGISTER       25\r
+#define EXCEPT_IPF_NAT_CONSUMPTION            26\r
+#define EXCEPT_IPF_SPECULATION                27\r
+//\r
+// 28 reserved\r
+//\r
+#define EXCEPT_IPF_DEBUG                          29\r
+#define EXCEPT_IPF_UNALIGNED_REFERENCE            30\r
+#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE     31\r
+#define EXCEPT_IPF_FP_FAULT                       32\r
+#define EXCEPT_IPF_FP_TRAP                        33\r
+#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP  34\r
+#define EXCEPT_IPF_TAKEN_BRANCH                   35\r
+#define EXCEPT_IPF_SINGLE_STEP                    36\r
+//\r
+// 37 - 44 reserved\r
+//\r
+#define EXCEPT_IPF_IA32_EXCEPTION 45\r
+#define EXCEPT_IPF_IA32_INTERCEPT 46\r
+#define EXCEPT_IPF_IA32_INTERRUPT 47\r
+\r
+//\r
+//  IPF processor context definition\r
+//\r
+typedef struct {\r
+  //\r
+  // The first reserved field is necessary to preserve alignment for the correct\r
+  // bits in UNAT and to insure F2 is 16 byte aligned..\r
+  //\r
+  UINT64  Reserved;\r
+  UINT64  R1;\r
+  UINT64  R2;\r
+  UINT64  R3;\r
+  UINT64  R4;\r
+  UINT64  R5;\r
+  UINT64  R6;\r
+  UINT64  R7;\r
+  UINT64  R8;\r
+  UINT64  R9;\r
+  UINT64  R10;\r
+  UINT64  R11;\r
+  UINT64  R12;\r
+  UINT64  R13;\r
+  UINT64  R14;\r
+  UINT64  R15;\r
+  UINT64  R16;\r
+  UINT64  R17;\r
+  UINT64  R18;\r
+  UINT64  R19;\r
+  UINT64  R20;\r
+  UINT64  R21;\r
+  UINT64  R22;\r
+  UINT64  R23;\r
+  UINT64  R24;\r
+  UINT64  R25;\r
+  UINT64  R26;\r
+  UINT64  R27;\r
+  UINT64  R28;\r
+  UINT64  R29;\r
+  UINT64  R30;\r
+  UINT64  R31;\r
+\r
+  UINT64  F2[2];\r
+  UINT64  F3[2];\r
+  UINT64  F4[2];\r
+  UINT64  F5[2];\r
+  UINT64  F6[2];\r
+  UINT64  F7[2];\r
+  UINT64  F8[2];\r
+  UINT64  F9[2];\r
+  UINT64  F10[2];\r
+  UINT64  F11[2];\r
+  UINT64  F12[2];\r
+  UINT64  F13[2];\r
+  UINT64  F14[2];\r
+  UINT64  F15[2];\r
+  UINT64  F16[2];\r
+  UINT64  F17[2];\r
+  UINT64  F18[2];\r
+  UINT64  F19[2];\r
+  UINT64  F20[2];\r
+  UINT64  F21[2];\r
+  UINT64  F22[2];\r
+  UINT64  F23[2];\r
+  UINT64  F24[2];\r
+  UINT64  F25[2];\r
+  UINT64  F26[2];\r
+  UINT64  F27[2];\r
+  UINT64  F28[2];\r
+  UINT64  F29[2];\r
+  UINT64  F30[2];\r
+  UINT64  F31[2];\r
+\r
+  UINT64  Pr;\r
+\r
+  UINT64  B0;\r
+  UINT64  B1;\r
+  UINT64  B2;\r
+  UINT64  B3;\r
+  UINT64  B4;\r
+  UINT64  B5;\r
+  UINT64  B6;\r
+  UINT64  B7;\r
+\r
+  //\r
+  // application registers\r
+  //\r
+  UINT64  ArRsc;\r
+  UINT64  ArBsp;\r
+  UINT64  ArBspstore;\r
+  UINT64  ArRnat;\r
+\r
+  UINT64  ArFcr;\r
+\r
+  UINT64  ArEflag;\r
+  UINT64  ArCsd;\r
+  UINT64  ArSsd;\r
+  UINT64  ArCflg;\r
+  UINT64  ArFsr;\r
+  UINT64  ArFir;\r
+  UINT64  ArFdr;\r
+\r
+  UINT64  ArCcv;\r
+\r
+  UINT64  ArUnat;\r
+\r
+  UINT64  ArFpsr;\r
+\r
+  UINT64  ArPfs;\r
+  UINT64  ArLc;\r
+  UINT64  ArEc;\r
+\r
+  //\r
+  // control registers\r
+  //\r
+  UINT64  CrDcr;\r
+  UINT64  CrItm;\r
+  UINT64  CrIva;\r
+  UINT64  CrPta;\r
+  UINT64  CrIpsr;\r
+  UINT64  CrIsr;\r
+  UINT64  CrIip;\r
+  UINT64  CrIfa;\r
+  UINT64  CrItir;\r
+  UINT64  CrIipa;\r
+  UINT64  CrIfs;\r
+  UINT64  CrIim;\r
+  UINT64  CrIha;\r
+\r
+  //\r
+  // debug registers\r
+  //\r
+  UINT64  Dbr0;\r
+  UINT64  Dbr1;\r
+  UINT64  Dbr2;\r
+  UINT64  Dbr3;\r
+  UINT64  Dbr4;\r
+  UINT64  Dbr5;\r
+  UINT64  Dbr6;\r
+  UINT64  Dbr7;\r
+\r
+  UINT64  Ibr0;\r
+  UINT64  Ibr1;\r
+  UINT64  Ibr2;\r
+  UINT64  Ibr3;\r
+  UINT64  Ibr4;\r
+  UINT64  Ibr5;\r
+  UINT64  Ibr6;\r
+  UINT64  Ibr7;\r
+\r
+  //\r
+  // virtual registers - nat bits for R1-R31\r
+  //\r
+  UINT64  IntNat;\r
+\r
+} EFI_SYSTEM_CONTEXT_IPF;\r
+\r
+//\r
+//  EBC processor exception types\r
+//\r
+#define EXCEPT_EBC_UNDEFINED            0\r
+#define EXCEPT_EBC_DIVIDE_ERROR         1\r
+#define EXCEPT_EBC_DEBUG                2\r
+#define EXCEPT_EBC_BREAKPOINT           3\r
+#define EXCEPT_EBC_OVERFLOW             4\r
+#define EXCEPT_EBC_INVALID_OPCODE       5   // opcode out of range\r
+#define EXCEPT_EBC_STACK_FAULT          6\r
+#define EXCEPT_EBC_ALIGNMENT_CHECK      7\r
+#define EXCEPT_EBC_INSTRUCTION_ENCODING 8   // malformed instruction\r
+#define EXCEPT_EBC_BAD_BREAK            9   // BREAK 0 or undefined BREAK\r
+#define EXCEPT_EBC_STEP                 10  // to support debug stepping\r
+//\r
+// For coding convenience, define the maximum valid EBC exception.\r
+//\r
+#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP\r
+\r
+//\r
+//  EBC processor context definition\r
+//\r
+typedef struct {\r
+  UINT64  R0;\r
+  UINT64  R1;\r
+  UINT64  R2;\r
+  UINT64  R3;\r
+  UINT64  R4;\r
+  UINT64  R5;\r
+  UINT64  R6;\r
+  UINT64  R7;\r
+  UINT64  Flags;\r
+  UINT64  ControlFlags;\r
+  UINT64  Ip;\r
+} EFI_SYSTEM_CONTEXT_EBC;\r
+\r
+//\r
+// Universal EFI_SYSTEM_CONTEXT definition\r
+//\r
+typedef union {\r
+  EFI_SYSTEM_CONTEXT_EBC  *SystemContextEbc;\r
+  EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;\r
+  EFI_SYSTEM_CONTEXT_X64  *SystemContextX64;\r
+  EFI_SYSTEM_CONTEXT_IPF  *SystemContextIpf;\r
+} EFI_SYSTEM_CONTEXT;\r
+\r
+//\r
+// DebugSupport callback function prototypes\r
+//\r
+typedef\r
+VOID\r
+(*EFI_EXCEPTION_CALLBACK) (\r
+  IN     EFI_EXCEPTION_TYPE               ExceptionType,\r
+  IN OUT EFI_SYSTEM_CONTEXT               SystemContext\r
+  );\r
+\r
+typedef\r
+VOID\r
+(*EFI_PERIODIC_CALLBACK) (\r
+  IN OUT EFI_SYSTEM_CONTEXT               SystemContext\r
+  );\r
+\r
+//\r
+// Machine type definition\r
+//\r
+typedef enum {\r
+  IsaIa32 = EFI_IMAGE_MACHINE_IA32,\r
+  IsaX64  = EFI_IMAGE_MACHINE_X64,\r
+  IsaIpf  = EFI_IMAGE_MACHINE_IA64,\r
+  IsaEbc  = EFI_IMAGE_MACHINE_EBC\r
+} EFI_INSTRUCTION_SET_ARCHITECTURE;\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DEBUG_SUPPORT_PROTOCOL);\r
+\r
+//\r
+// DebugSupport member function definitions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX) (\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL          * This,\r
+  OUT UINTN                              *MaxProcessorIndex\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK) (\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL          * This,\r
+  IN UINTN                               ProcessorIndex,\r
+  IN EFI_PERIODIC_CALLBACK               PeriodicCallback\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK) (\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL          * This,\r
+  IN UINTN                               ProcessorIndex,\r
+  IN EFI_EXCEPTION_CALLBACK              ExceptionCallback,\r
+  IN EFI_EXCEPTION_TYPE                  ExceptionType\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE) (\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL          * This,\r
+  IN UINTN                               ProcessorIndex,\r
+  IN VOID                                *Start,\r
+  IN UINT64                              Length\r
+  );\r
+\r
+//\r
+// DebugSupport protocol definition\r
+//\r
+typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL {\r
+  EFI_INSTRUCTION_SET_ARCHITECTURE  Isa;\r
+  EFI_GET_MAXIMUM_PROCESSOR_INDEX   GetMaximumProcessorIndex;\r
+  EFI_REGISTER_PERIODIC_CALLBACK    RegisterPeriodicCallback;\r
+  EFI_REGISTER_EXCEPTION_CALLBACK   RegisterExceptionCallback;\r
+  EFI_INVALIDATE_INSTRUCTION_CACHE  InvalidateInstructionCache;\r
+} EFI_DEBUG_SUPPORT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDebugSupportProtocolGuid;\r
+\r
+#endif /* _DEBUG_SUPPORT_H_ */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c
new file mode 100644 (file)
index 0000000..366322e
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Decompress.c\r
+    \r
+Abstract:\r
+\r
+  The GUID for the EFI Decompress Protocol\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Decompress)\r
+\r
+EFI_GUID  gEfiDecompressProtocolGuid = EFI_DECOMPRESS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDecompressProtocolGuid, "Decompress", "Decompression Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h
new file mode 100644 (file)
index 0000000..93839a7
--- /dev/null
@@ -0,0 +1,140 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.h\r
+    \r
+Abstract:\r
+\r
+  The Decompress Protocol Interface\r
+\r
+--*/\r
+\r
+#ifndef _DECOMPRESS_H_\r
+#define _DECOMPRESS_H_\r
+\r
+#define EFI_DECOMPRESS_PROTOCOL_GUID \\r
+  { \\r
+    0xd8117cfe, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DECOMPRESS_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DECOMPRESS_GET_INFO) (\r
+  IN EFI_DECOMPRESS_PROTOCOL            * This,\r
+  IN   VOID                             *Source,\r
+  IN   UINT32                           SourceSize,\r
+  OUT  UINT32                           *DestinationSize,\r
+  OUT  UINT32                           *ScratchSize\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The GetInfo() function retrieves the size of the uncompressed buffer \r
+  and the temporary scratch buffer required to decompress the buffer \r
+  specified by Source and SourceSize.  If the size of the uncompressed\r
+  buffer or the size of the scratch buffer cannot be determined from \r
+  the compressed data specified by Source and SourceData, then \r
+  EFI_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
+  buffer is returned in DestinationSize, the size of the scratch buffer is \r
+  returned in ScratchSize, and EFI_SUCCESS is returned.\r
+  \r
+  The GetInfo() function does not have scratch buffer available to perform \r
+  a thorough checking of the validity of the source data. It just retrieves\r
+  the 'Original Size' field from the beginning bytes of the source data and\r
+  output it as DestinationSize.  And ScratchSize is specific to the decompression\r
+  implementation.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size, in bytes, of source buffer.\r
+  DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer\r
+                    that will be generated when the compressed buffer specified \r
+                    by Source and SourceSize is decompressed.\r
+  ScratchSize     - A pointer to the size, in bytes, of the scratch buffer that \r
+                    is required to decompress the compressed buffer specified by\r
+                    Source and SourceSize.\r
+\r
+Returns:\r
+  EFI_SUCCESS     - The size of the uncompressed data was returned in DestinationSize\r
+                    and the size of the scratch buffer was returned in ScratchSize.\r
+  EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch\r
+                  buffer cannot be determined from the compressed data specified by \r
+                  Source and SourceData.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DECOMPRESS_DECOMPRESS) (\r
+  IN EFI_DECOMPRESS_PROTOCOL              * This,\r
+  IN     VOID                             *Source,\r
+  IN     UINT32                           SourceSize,\r
+  IN OUT VOID                             *Destination,\r
+  IN     UINT32                           DestinationSize,\r
+  IN OUT VOID                             *Scratch,\r
+  IN     UINT32                           ScratchSize\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Decompress() function extracts decompressed data to its original form.\r
+  \r
+  This protocol is designed so that the decompression algorithm can be \r
+  implemented without using any memory services.  As a result, the \r
+  Decompress() function is not allowed to call AllocatePool() or \r
+  AllocatePages() in its implementation.  It is the caller's responsibility \r
+  to allocate and free the Destination and Scratch buffers.\r
+  \r
+  If the compressed source data specified by Source and SourceSize is \r
+  sucessfully decompressed into Destination, then EFI_SUCCESS is returned.  \r
+  If the compressed source data specified by Source and SourceSize is not in \r
+  a valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size of source data.\r
+  Destination     - On output, the destination buffer that contains \r
+                    the uncompressed data.\r
+  DestinationSize - The size of destination buffer. The size of destination\r
+                    buffer needed is obtained from GetInfo().\r
+  Scratch         - A temporary scratch buffer that is used to perform the \r
+                    decompression.\r
+  ScratchSize     - The size of scratch buffer. The size of scratch buffer needed\r
+                    is obtained from GetInfo().\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Decompression completed successfully, and the uncompressed \r
+                    buffer is returned in Destination.\r
+  EFI_INVALID_PARAMETER \r
+                  - The source buffer specified by Source and SourceSize is \r
+                    corrupted (not in a valid compressed format).\r
+\r
+--*/\r
+typedef struct _EFI_DECOMPRESS_PROTOCOL {\r
+  EFI_DECOMPRESS_GET_INFO   GetInfo;\r
+  EFI_DECOMPRESS_DECOMPRESS Decompress;\r
+} EFI_DECOMPRESS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDecompressProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c
new file mode 100644 (file)
index 0000000..34d90b7
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DeviceIo.c\r
+\r
+Abstract:\r
+\r
+  Device IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  Device IO is used to abstract hardware access to devices. It includes\r
+  memory mapped IO, IO, PCI Config space, and DMA.\r
+\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DeviceIo)\r
+\r
+EFI_GUID  gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDeviceIoProtocolGuid, "DeviceIo Protocol", "EFI 1.0 Device IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h
new file mode 100644 (file)
index 0000000..d0f4678
--- /dev/null
@@ -0,0 +1,132 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DeviceIo.h\r
+\r
+Abstract:\r
+\r
+  Device IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  Device IO is used to abstract hardware access to devices. It includes\r
+  memory mapped IO, IO, PCI Config space, and DMA.\r
+\r
\r
+--*/\r
+\r
+#ifndef _DEVICE_IO_H_\r
+#define _DEVICE_IO_H_\r
+\r
+#define EFI_DEVICE_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xaf6ac311, 0x84c3, 0x11d2, 0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DEVICE_IO_PROTOCOL);\r
+\r
+typedef enum {\r
+  IO_UINT8,\r
+  IO_UINT16,\r
+  IO_UINT32,\r
+  IO_UINT64,\r
+  MMIO_COPY_UINT8,\r
+  MMIO_COPY_UINT16,\r
+  MMIO_COPY_UINT32,\r
+  MMIO_COPY_UINT64\r
+} EFI_IO_WIDTH;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEVICE_IO) (\r
+  IN EFI_DEVICE_IO_PROTOCOL         * This,\r
+  IN EFI_IO_WIDTH                   Width,\r
+  IN UINT64                         Address,\r
+  IN UINTN                          Count,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_DEVICE_IO Read;\r
+  EFI_DEVICE_IO Write;\r
+} EFI_IO_ACCESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_DEVICE_PATH) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           * This,\r
+  IN UINT64                           Address,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL     **PciDevicePath\r
+  );\r
+\r
+typedef enum {\r
+  EfiBusMasterRead,\r
+  EfiBusMasterWrite,\r
+  EfiBusMasterCommonBuffer\r
+} EFI_IO_OPERATION_TYPE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_MAP) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           * This,\r
+  IN EFI_IO_OPERATION_TYPE            Operation,\r
+  IN EFI_PHYSICAL_ADDRESS             * HostAddress,\r
+  IN OUT UINTN                        *NumberOfBytes,\r
+  OUT EFI_PHYSICAL_ADDRESS            * DeviceAddress,\r
+  OUT VOID                            **Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_UNMAP) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           * This,\r
+  IN VOID                             *Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_ALLOCATE_BUFFER) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           * This,\r
+  IN EFI_ALLOCATE_TYPE                Type,\r
+  IN EFI_MEMORY_TYPE                  MemoryType,\r
+  IN UINTN                            Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS         * HostAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_FLUSH) (\r
+  IN EFI_DEVICE_IO_PROTOCOL  * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_FREE_BUFFER) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           * This,\r
+  IN UINTN                            Pages,\r
+  IN EFI_PHYSICAL_ADDRESS             HostAddress\r
+  );\r
+\r
+typedef struct _EFI_DEVICE_IO_PROTOCOL {\r
+  EFI_IO_ACCESS           Mem;\r
+  EFI_IO_ACCESS           Io;\r
+  EFI_IO_ACCESS           Pci;\r
+  EFI_IO_MAP              Map;\r
+  EFI_PCI_DEVICE_PATH     PciDevicePath;\r
+  EFI_IO_UNMAP            Unmap;\r
+  EFI_IO_ALLOCATE_BUFFER  AllocateBuffer;\r
+  EFI_IO_FLUSH            Flush;\r
+  EFI_IO_FREE_BUFFER      FreeBuffer;\r
+} EFI_DEVICE_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDeviceIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c
new file mode 100644 (file)
index 0000000..7cca985
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DevicePath.c\r
+\r
+Abstract:\r
+\r
+  The device path protocol as defined in EFI 1.0.\r
+\r
+  The device path represents a programatic path to a device. It's the view\r
+  from a software point of view. It also must persist from boot to boot, so \r
+  it can not contain things like PCI bus numbers that change from boot to boot.\r
+  \r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+\r
+EFI_GUID  gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDevicePathProtocolGuid, "Device Path Protocol", "EFI 1.0 Device Path protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h
new file mode 100644 (file)
index 0000000..4991e2b
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePath.h\r
+\r
+Abstract:\r
+\r
+  The device path protocol as defined in EFI 1.0.\r
+\r
+  The device path represents a programatic path to a device. It's the view\r
+  from a software point of view. It also must persist from boot to boot, so \r
+  it can not contain things like PCI bus numbers that change from boot to boot.\r
+  \r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_PATH_H_\r
+#define _DEVICE_PATH_H_\r
+\r
+//\r
+// Device Path protocol\r
+//\r
+#define EFI_DEVICE_PATH_PROTOCOL_GUID \\r
+  { \\r
+    0x9576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+#pragma pack(push, 1)\r
+\r
+typedef struct {\r
+  UINT8 Type;\r
+  UINT8 SubType;\r
+  UINT8 Length[2];\r
+} EFI_DEVICE_PATH_PROTOCOL;\r
+\r
+#pragma pack(pop)\r
+\r
+#define EFI_END_ENTIRE_DEVICE_PATH            0xff\r
+#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE    0xff\r
+#define EFI_END_INSTANCE_DEVICE_PATH          0x01\r
+#define EFI_END_DEVICE_PATH_LENGTH            (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
+\r
+#define EfiDevicePathNodeLength(a)            (((a)->Length[0]) | ((a)->Length[1] << 8))\r
+#define EfiNextDevicePathNode(a)              ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))\r
+\r
+#define EfiDevicePathType(a)                  (((a)->Type) & 0x7f)\r
+#define EfiIsDevicePathEndType(a)             (EfiDevicePathType (a) == 0x7f)\r
+\r
+#define EfiIsDevicePathEndSubType(a)          ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
+#define EfiIsDevicePathEndInstanceSubType(a)  ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)\r
+\r
+#define EfiIsDevicePathEnd(a)                 (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))\r
+#define EfiIsDevicePathEndInstance(a)         (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))\r
+\r
+extern EFI_GUID gEfiDevicePathProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c
new file mode 100644 (file)
index 0000000..ee4289b
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathFromText.c\r
+\r
+Abstract:\r
+\r
+  DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathFromText)\r
+\r
+EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDevicePathFromTextProtocolGuid, "Device Path From Text Protocol", "UEFI 2.0 Device Path From Text Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h
new file mode 100644 (file)
index 0000000..8218cfc
--- /dev/null
@@ -0,0 +1,82 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathFromText.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_\r
+#define _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_\r
+\r
+//\r
+// Device Path From Text protocol\r
+//\r
+#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \\r
+  { \\r
+    0x5c99a21, 0xc70f, 0x4ad2, 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e \\r
+  }\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) (\r
+  IN CONST CHAR16                 *TextDeviceNode\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Convert text to the binary representation of a device node.\r
+\r
+  Arguments:\r
+    TextDeviceNode   -   TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  Returns:\r
+    A pointer        -   Pointer to the EFI device node.\r
+    NULL             -   if TextDeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;    \r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) (\r
+  IN CONST CHAR16                 *TextDevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Convert text to the binary representation of a device path.\r
+\r
+  Arguments:\r
+    TextDevicePath   -   TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  Returns:\r
+    A pointer        -   Pointer to the allocated device path.\r
+    NULL             -   if TextDeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_FROM_TEXT_NODE  ConvertTextToDeviceNode;\r
+  EFI_DEVICE_PATH_FROM_TEXT_PATH  ConvertTextToDevicePath;\r
+} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDevicePathFromTextProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c
new file mode 100644 (file)
index 0000000..046a391
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathToText.c\r
+\r
+Abstract:\r
+\r
+  DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathToText)\r
+\r
+EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDevicePathToTextProtocolGuid, "Device Path To Text Protocol", "UEFI 2.0 Device Path To Text protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h
new file mode 100644 (file)
index 0000000..4d03aad
--- /dev/null
@@ -0,0 +1,95 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathToText.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+\r
+#ifndef _DEVICE_PATH_TO_TEXT_PROTOCOL_H_\r
+#define _DEVICE_PATH_TO_TEXT_PROTOCOL_H_\r
+\r
+//\r
+// Device Path To Text protocol\r
+//\r
+#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \\r
+  { \\r
+    0x8b843e20, 0x8132, 0x4852, 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c  \\r
+  }\r
+\r
+typedef\r
+CHAR16*\r
+(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DeviceNode,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Convert a device node to its text representation.\r
+\r
+  Arguments:\r
+    DeviceNode       -   Points to the device node to be converted.\r
+    DisplayOnly      -   If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+    AllowShortcuts   -   If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  Returns:\r
+    A pointer        -   a pointer to the allocated text representation of the device node.\r
+    NULL             -   if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;      \r
+\r
+typedef\r
+CHAR16*\r
+(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Convert a device path to its text representation.\r
+\r
+  Arguments:\r
+    DeviceNode       -   Points to the device path to be converted.\r
+    DisplayOnly      -   If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+    AllowShortcuts   -   If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  Returns:\r
+    A pointer        -   a pointer to the allocated text representation of the device path.\r
+    NULL             -   if DeviceNode is NULL or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_TO_TEXT_NODE        ConvertDeviceNodeToText;\r
+  EFI_DEVICE_PATH_TO_TEXT_PATH        ConvertDevicePathToText;\r
+} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDevicePathToTextProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c
new file mode 100644 (file)
index 0000000..d23b9a6
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathUtilities.c\r
+\r
+Abstract:\r
+\r
+  DevicePathUtilities protocol as defined in the UEFI 2.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities)\r
+\r
+EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDevicePathUtilitiesProtocolGuid, "Device Path Utilities Protocol", "UEFI 2.0 Device Path Utilities protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h
new file mode 100644 (file)
index 0000000..6cf2c69
--- /dev/null
@@ -0,0 +1,225 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                              \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePathUtilities.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_PATH_UTILITIES_PROTOCOL_H_\r
+#define _DEVICE_PATH_UTILITIES_PROTOCOL_H_\r
+\r
+//\r
+// Device Path Utilities protocol\r
+//\r
+#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \\r
+  { \\r
+    0x379be4e, 0xd706, 0x437d, 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4  \\r
+  }\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns the size of the device path, in bytes.\r
+\r
+  Arguments:\r
+    DevicePath  -   Points to the start of the EFI device path.\r
+\r
+  Returns:\r
+    Size        -   Size of the specified device path, in bytes, including the end-of-path tag.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Create a duplicate of the specified path.\r
+\r
+  Arguments:\r
+    DevicePath  -   Points to the source EFI device path.\r
+\r
+  Returns:\r
+    Pointer     -   A pointer to the duplicate device path.\r
+    NULL        -   Insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Create a new path by appending the second device path to the first.\r
+\r
+  Arguments:\r
+    Src1      -   Points to the first device path. If NULL, then it is ignored.\r
+    Src2      -   Points to the second device path. If NULL, then it is ignored.\r
+\r
+  Returns:\r
+    Pointer   -   A pointer to the newly created device path.\r
+    NULL      -   Memory could not be allocated\r
+                  or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Creates a new path by appending the device node to the device path.\r
+\r
+  Arguments:\r
+    DevicePath   -   Points to the device path.\r
+    DeviceNode   -   Points to the device node.\r
+\r
+  Returns:\r
+    Pointer      -   A pointer to the allocated device node.\r
+    NULL         -   Memory could not be allocated\r
+                     or either DevicePath or DeviceNode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Creates a new path by appending the specified device path instance to the specified device path.\r
+\r
+  Arguments:\r
+    DevicePath           -   Points to the device path. If NULL, then ignored.\r
+    DevicePathInstance   -   Points to the device path instance.\r
+\r
+  Returns:\r
+    Pointer              -   A pointer to the newly created device path\r
+    NULL                 -   Memory could not be allocated or DevicePathInstance is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) (\r
+  IN  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathInstance,\r
+  OUT UINTN                         *DevicePathInstanceSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
+\r
+  Arguments:\r
+    DevicePathInstance       -   On input, this holds the pointer to the current device path\r
+                                 instance. On output, this holds the pointer to the next\r
+                                 device path instance or NULL if there are no more device\r
+                                 path instances in the device path.\r
+    DevicePathInstanceSize   -   On output, this holds the size of the device path instance,\r
+                                 in bytes or zero, if DevicePathInstance is zero.\r
+\r
+  Returns:\r
+    Pointer                  -   A pointer to the copy of the current device path instance.\r
+    NULL                     -   DevicePathInstace was NULL on entry or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL         *DevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns whether a device path is multi-instance.\r
+\r
+  Arguments:\r
+    DevicePath  -   Points to the device path. If NULL, then ignored.\r
+\r
+  Returns:\r
+    TRUE        -   The device path has more than one instance\r
+    FALSE       -   The device path is empty or contains only a single instance.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL*\r
+(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) (\r
+  IN UINT8                          NodeType,\r
+  IN UINT8                          NodeSubType,\r
+  IN UINT16                         NodeLength\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Creates a device node\r
+\r
+  Arguments:\r
+    NodeType     -    NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
+                      the new device node.\r
+    NodeSubType  -    NodeSubType is the device node sub-type\r
+                      EFI_DEVICE_PATH.SubType) for the new device node.\r
+    NodeLength   -    NodeLength is the length of the device node\r
+                      (EFI_DEVICE_PATH.Length) for the new device node.\r
+\r
+  Returns:\r
+    Pointer      -    A pointer to the newly created device node.\r
+    NULL         -    NodeLength is less than\r
+                      the size of the header or there was insufficient memory.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;\r
+  EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH      DuplicateDevicePath;\r
+  EFI_DEVICE_PATH_UTILS_APPEND_PATH          AppendDevicePath;\r
+  EFI_DEVICE_PATH_UTILS_APPEND_NODE          AppendDeviceNode;\r
+  EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE      AppendDevicePathInstance;\r
+  EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE    GetNextDevicePathInstance;\r
+  EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE    IsDevicePathMultiInstance;\r
+  EFI_DEVICE_PATH_UTILS_CREATE_NODE          CreateDeviceNode;\r
+} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c
new file mode 100644 (file)
index 0000000..d2775cf
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Dhcp4.c\r
+\r
+Abstract:\r
+\r
+  UEFI Dynamic Host Configuration Protocol 4.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Dhcp4)\r
+\r
+EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid \r
+           = EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID;\r
+\r
+EFI_GUID gEfiDhcp4ProtocolGuid             \r
+           = EFI_DHCP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiDhcp4ServiceBindingProtocolGuid, \r
+  "DHCP4 Service Binding Protocol", \r
+  "DHCP4 Service Binding Protocol"\r
+  );\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiDhcp4ProtocolGuid,             \r
+  "DHCP4 Protocol",             \r
+  "DHCP4 Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h
new file mode 100644 (file)
index 0000000..3409ca0
--- /dev/null
@@ -0,0 +1,237 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Dhcp4.h\r
+\r
+Abstract:\r
+\r
+  UEFI Dynamic Host Configuration Protocol 4 Definition\r
+\r
+--*/\r
+\r
+#ifndef _DHCP4_H_\r
+#define _DHCP4_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+#include EFI_PROTOCOL_DEFINITION (Udp4)\r
+\r
+//GUID definitions\r
+#define EFI_DHCP4_PROTOCOL_GUID \\r
+  {0x8a219718, 0x4ef5, 0x4761, 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56}\r
+\r
+#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+  {0x9d9a39d8, 0xbd42, 0x4a73, 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80}\r
+  \r
+extern EFI_GUID gEfiDhcp4ProtocolGuid;\r
+extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DHCP4_PROTOCOL);\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8               OpCode;\r
+  UINT8               Length;\r
+  UINT8               Data[1];\r
+} EFI_DHCP4_PACKET_OPTION;\r
+\r
+typedef struct{\r
+    UINT8             OpCode;\r
+    UINT8             HwType;\r
+    UINT8             HwAddrLen;\r
+    UINT8             Hops;\r
+    UINT32            Xid;\r
+    UINT16            Seconds;\r
+    UINT16            Reserved;\r
+    EFI_IPv4_ADDRESS  ClientAddr;      \r
+    EFI_IPv4_ADDRESS  YourAddr;        \r
+    EFI_IPv4_ADDRESS  ServerAddr;      \r
+    EFI_IPv4_ADDRESS  GwAddr;           \r
+    UINT8             ClientHwAddr[16]; \r
+    CHAR8             ServerName[64];   \r
+    CHAR8             BootFileName[128];\r
+}EFI_DHCP4_HEADER;\r
+\r
+typedef struct {\r
+  UINT32              Size;\r
+  UINT32              Length;\r
+  struct {\r
+    EFI_DHCP4_HEADER  Header;\r
+    UINT32            Magik;\r
+    UINT8             Option[1];\r
+  } Dhcp4;\r
+} EFI_DHCP4_PACKET;\r
+#pragma pack()\r
+\r
+typedef enum {\r
+  Dhcp4Stopped        = 0x0,\r
+  Dhcp4Init           = 0x1,\r
+  Dhcp4Selecting      = 0x2,\r
+  Dhcp4Requesting     = 0x3,\r
+  Dhcp4Bound          = 0x4,\r
+  Dhcp4Renewing       = 0x5,\r
+  Dhcp4Rebinding      = 0x6,\r
+  Dhcp4InitReboot     = 0x7,\r
+  Dhcp4Rebooting      = 0x8\r
+} EFI_DHCP4_STATE;\r
+\r
+typedef enum{\r
+  Dhcp4SendDiscover   = 0x01,\r
+  Dhcp4RcvdOffer      = 0x02,\r
+  Dhcp4SelectOffer    = 0x03,\r
+  Dhcp4SendRequest    = 0x05,\r
+  Dhcp4RcvdAck        = 0x06,\r
+  Dhcp4RcvdNak        = 0x07,\r
+  Dhcp4SendDecline    = 0x08,\r
+  Dhcp4BoundCompleted = 0x09,\r
+  Dhcp4EnterRenewing  = 0x0a,\r
+  Dhcp4EnterRebinding = 0x0b,\r
+  Dhcp4AddressLost    = 0x0c,\r
+  Dhcp4Fail           = 0x0d\r
+} EFI_DHCP4_EVENT;\r
+\r
+typedef EFI_STATUS (*EFI_DHCP4_CALLBACK)(\r
+  IN EFI_DHCP4_PROTOCOL   *This,\r
+  IN VOID                 *Context,\r
+  IN EFI_DHCP4_STATE      CurrentState,\r
+  IN EFI_DHCP4_EVENT      Dhcp4Event,\r
+  IN EFI_DHCP4_PACKET     *Packet       OPTIONAL, \r
+  OUT EFI_DHCP4_PACKET    **NewPacket   OPTIONAL\r
+);\r
+\r
+typedef struct {\r
+  UINT32                  DiscoverTryCount;\r
+  UINT32                  *DiscoverTimeout;\r
+  UINT32                  RequestTryCount;\r
+  UINT32                  *RequestTimeout;\r
+  EFI_IPv4_ADDRESS        ClientAddress;\r
+  EFI_DHCP4_CALLBACK      Dhcp4Callback;\r
+  VOID                    *CallbackContext;\r
+  UINT32                  OptionCount;\r
+  EFI_DHCP4_PACKET_OPTION **OptionList;\r
+}EFI_DHCP4_CONFIG_DATA;\r
+\r
+typedef struct {\r
+  EFI_DHCP4_STATE         State;\r
+  EFI_DHCP4_CONFIG_DATA   ConfigData;\r
+  EFI_IPv4_ADDRESS        ClientAddress;\r
+  EFI_MAC_ADDRESS         ClientMacAddress;\r
+  EFI_IPv4_ADDRESS        ServerAddress;\r
+  EFI_IPv4_ADDRESS        RouterAddress;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+  UINT32                  LeaseTime;\r
+  EFI_DHCP4_PACKET        *ReplyPacket;\r
+ } EFI_DHCP4_MODE_DATA;\r
+\r
+typedef struct {\r
+  EFI_IPv4_ADDRESS        ListenAddress;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+  UINT16                  ListenPort;\r
+} EFI_DHCP4_LISTEN_POINT;\r
+\r
+typedef struct {\r
+  OUT EFI_STATUS            Status;\r
+  IN EFI_EVENT              CompletionEvent;\r
+  IN EFI_IPv4_ADDRESS       RemoteAddress;\r
+  IN UINT16                 RemotePort;\r
+  IN EFI_IPv4_ADDRESS       GatewayAddress;\r
+  IN UINT32                 ListenPointCount;\r
+  IN EFI_DHCP4_LISTEN_POINT *ListenPoints;\r
+  IN UINT32                 TimeoutValue;\r
+  IN EFI_DHCP4_PACKET       *Packet;\r
+  OUT UINT32                ResponseCount;\r
+  OUT EFI_DHCP4_PACKET      *ResponseList;   \r
+}EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_DHCP4_GET_MODE_DATA)(\r
+  IN EFI_DHCP4_PROTOCOL     *This,\r
+  OUT EFI_DHCP4_MODE_DATA   *Dhcp4ModeData\r
+);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_CONFIGURE) (\r
+  IN EFI_DHCP4_PROTOCOL     *This,\r
+  IN EFI_DHCP4_CONFIG_DATA  *Dhcp4CfgData  OPTIONAL\r
+);\r
+\r
+\r
+typedef EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_START) (\r
+  IN EFI_DHCP4_PROTOCOL     *This,\r
+  IN EFI_EVENT              CompletionEvent    OPTIONAL\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_RENEW) (\r
+  IN EFI_DHCP4_PROTOCOL      *This,\r
+  IN BOOLEAN                RebindRequest,\r
+  IN EFI_EVENT              CompletionEvent    OPTIONAL\r
+);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_RELEASE) (\r
+  IN EFI_DHCP4_PROTOCOL     *This\r
+);\r
+\r
+typedef EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_STOP) (\r
+  IN EFI_DHCP4_PROTOCOL     *This\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_BUILD) (\r
+  IN EFI_DHCP4_PROTOCOL       *This,\r
+  IN EFI_DHCP4_PACKET         *SeedPacket,\r
+  IN UINT32                   DeleteCount,\r
+  IN UINT8                    *DeleteList        OPTIONAL,\r
+  IN UINT32                   AppendCount,\r
+  IN EFI_DHCP4_PACKET_OPTION  *AppendList[]       OPTIONAL,\r
+  OUT EFI_DHCP4_PACKET        **NewPacket\r
+);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE) (\r
+  IN EFI_DHCP4_PROTOCOL                *This,\r
+  IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN  *Token\r
+);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DHCP4_PARSE) (\r
+  IN EFI_DHCP4_PROTOCOL        *This,\r
+  IN EFI_DHCP4_PACKET          *Packet,\r
+  IN OUT UINT32                *OptionCount,\r
+  OUT EFI_DHCP4_PACKET_OPTION  *PacketOptionList[]  OPTIONAL\r
+);\r
+\r
+typedef struct _EFI_DHCP4_PROTOCOL {\r
+  EFI_DHCP4_GET_MODE_DATA      GetModeData;\r
+  EFI_DHCP4_CONFIGURE          Configure;\r
+  EFI_DHCP4_START              Start;\r
+  EFI_DHCP4_RENEW              RenewRebind;\r
+  EFI_DHCP4_RELEASE            Release;\r
+  EFI_DHCP4_STOP               Stop;\r
+  EFI_DHCP4_BUILD              Build;\r
+  EFI_DHCP4_TRANSMIT_RECEIVE   TransmitReceive;\r
+  EFI_DHCP4_PARSE              Parse;\r
+} EFI_DHCP4_PROTOCOL;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c
new file mode 100644 (file)
index 0000000..223ac64
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DiskIo.c\r
+\r
+Abstract:\r
+\r
+  Disk IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  The Disk IO protocol is used to convert block oriented devices into byte\r
+  oriented devices. The Disk IO protocol is intended to layer on top of the\r
+  Block IO protocol.\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DiskIo)\r
+\r
+EFI_GUID  gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDiskIoProtocolGuid, "DiskIo Protocol", "EFI 1.0 Disk IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h
new file mode 100644 (file)
index 0000000..fee3034
--- /dev/null
@@ -0,0 +1,111 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DiskIo.h\r
+\r
+Abstract:\r
+\r
+  Disk IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  The Disk IO protocol is used to convert block oriented devices into byte\r
+  oriented devices. The Disk IO protocol is intended to layer on top of the\r
+  Block IO protocol.\r
\r
+--*/\r
+\r
+#ifndef __DISK_IO_H__\r
+#define __DISK_IO_H__\r
+\r
+#define EFI_DISK_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DISK_IO_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_READ) (\r
+  IN EFI_DISK_IO_PROTOCOL         * This,\r
+  IN UINT32                       MediaId,\r
+  IN UINT64                       Offset,\r
+  IN UINTN                        BufferSize,\r
+  OUT VOID                        *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Read BufferSize bytes from Offset into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced.\r
+    Offset     - The starting byte offset to read from\r
+    BufferSize - Size of Buffer\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was read correctly from the device.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the read.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHNAGED     - The MediaId does not matched the current device.\r
+    EFI_INVALID_PARAMETER - The read request contains device addresses that are not \r
+                            valid for the device.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_WRITE) (\r
+  IN EFI_DISK_IO_PROTOCOL         * This,\r
+  IN UINT32                       MediaId,\r
+  IN UINT64                       Offset,\r
+  IN UINTN                        BufferSize,\r
+  IN VOID                         *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Read BufferSize bytes from Offset into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced. \r
+    Offset     - The starting byte offset to read from\r
+    BufferSize - Size of Buffer\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was written correctly to the device.\r
+    EFI_WRITE_PROTECTED   - The device can not be written to.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the write.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHNAGED     - The MediaId does not matched the current device.\r
+    EFI_INVALID_PARAMETER - The write request contains device addresses that are not \r
+                            valid for the device.\r
+\r
+--*/\r
+;\r
+\r
+#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000\r
+\r
+typedef struct _EFI_DISK_IO_PROTOCOL {\r
+  UINT64          Revision;\r
+  EFI_DISK_READ   ReadDisk;\r
+  EFI_DISK_WRITE  WriteDisk;\r
+} EFI_DISK_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDiskIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c
new file mode 100644 (file)
index 0000000..4bdc436
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverBinding.c\r
+    \r
+Abstract:\r
+\r
+    EFI Controller Driver Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)\r
+\r
+EFI_GUID  gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDriverBindingProtocolGuid, "Controller Driver Protocol", "EFI 1.1 Controller Driver Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h
new file mode 100644 (file)
index 0000000..2f30df6
--- /dev/null
@@ -0,0 +1,130 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverBinding.h\r
+    \r
+Abstract:\r
+\r
+    EFI ControllerHandle Driver Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DRIVER_BINDING_H_\r
+#define _EFI_DRIVER_BINDING_H_\r
+\r
+//\r
+// Global ID for the ControllerHandle Driver Protocol\r
+//\r
+#define EFI_DRIVER_BINDING_PROTOCOL_GUID \\r
+  { \\r
+    0x18a031ab, 0xb443, 0x4d1a, 0xa5, 0xc0, 0xc, 0x9, 0x26, 0x1e, 0x9f, 0x71 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DRIVER_BINDING_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_BINDING_SUPPORTED) (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL            * This,\r
+  IN EFI_HANDLE                             ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL               * RemainingDevicePath OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Test to see if this driver supports ControllerHandle. \r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    ControllerHandle    - Handle of device to test\r
+    RemainingDevicePath - Optional parameter use to pick a specific child \r
+                          device to start.\r
+\r
+  Returns:\r
+    EFI_SUCCESS         - This driver supports this device\r
+    EFI_ALREADY_STARTED - This driver is already running on this device\r
+    other               - This driver does not support this device\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_BINDING_START) (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL            * This,\r
+  IN EFI_HANDLE                             ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL               * RemainingDevicePath OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Start this driver on ControllerHandle.\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    ControllerHandle    - Handle of device to bind driver to\r
+    RemainingDevicePath - Optional parameter use to pick a specific child \r
+                          device to start.\r
+\r
+  Returns:\r
+    EFI_SUCCESS         - This driver is added to ControllerHandle\r
+    EFI_ALREADY_STARTED - This driver is already running on ControllerHandle\r
+    other               - This driver does not support this device\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_BINDING_STOP) (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL            * This,\r
+  IN  EFI_HANDLE                            ControllerHandle,\r
+  IN  UINTN                                 NumberOfChildren,\r
+  IN  EFI_HANDLE                            * ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Stop this driver on ControllerHandle.\r
+\r
+  Arguments:\r
+    This              - Protocol instance pointer.\r
+    ControllerHandle  - Handle of device to stop driver on \r
+    NumberOfChildren  - Number of Handles in ChildHandleBuffer. If number of \r
+                        children is zero stop the entire bus driver.\r
+    ChildHandleBuffer - List of Child Handles to Stop.\r
+\r
+  Returns:\r
+    EFI_SUCCESS         - This driver is removed ControllerHandle\r
+    other               - This driver was not removed from this device\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Interface structure for the ControllerHandle Driver Protocol\r
+//\r
+typedef struct _EFI_DRIVER_BINDING_PROTOCOL {\r
+  EFI_DRIVER_BINDING_SUPPORTED  Supported;\r
+  EFI_DRIVER_BINDING_START      Start;\r
+  EFI_DRIVER_BINDING_STOP       Stop;\r
+  UINT32                        Version;\r
+  EFI_HANDLE                    ImageHandle;\r
+  EFI_HANDLE                    DriverBindingHandle;\r
+} EFI_DRIVER_BINDING_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDriverBindingProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c
new file mode 100644 (file)
index 0000000..697e489
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverConfiguration.c\r
+    \r
+Abstract:\r
+\r
+    EFI Driver Configuration Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)\r
+\r
+EFI_GUID  gEfiDriverConfigurationProtocolGuid = EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiDriverConfigurationProtocolGuid, "Driver Configuration Protocol", "EFI 1.1 Driver Configuration Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h
new file mode 100644 (file)
index 0000000..f43b816
--- /dev/null
@@ -0,0 +1,211 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverConfiguration.h\r
+    \r
+Abstract:\r
+\r
+    EFI Driver Configuration Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DRIVER_CONFIGURATION_H_\r
+#define _EFI_DRIVER_CONFIGURATION_H_\r
+\r
+//\r
+// Global ID for the Driver Configuration Protocol\r
+//\r
+#define EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID \\r
+  { \\r
+    0x107a772b, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DRIVER_CONFIGURATION_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiDriverConfigurationActionNone              = 0,\r
+  EfiDriverConfigurationActionStopController    = 1,\r
+  EfiDriverConfigurationActionRestartController = 2,\r
+  EfiDriverConfigurationActionRestartPlatform   = 3,\r
+  EfiDriverConfigurationActionMaximum\r
+} EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED;\r
+\r
+#define EFI_DRIVER_CONFIGURATION_SAFE_DEFAULTS          0x00000000\r
+#define EFI_DRIVER_CONFIGURATION_MANUFACTURING_DEFAULTS 0x00000001\r
+#define EFI_DRIVER_CONFIGURATION_CUSTOM_DEFAULTS        0x00000002\r
+#define EFI_DRIVER_CONFIGURATION_PERORMANCE_DEFAULTS    0x00000003\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_CONFIGURATION_SET_OPTIONS) (\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL                        * This,\r
+  IN  EFI_HANDLE                                              ControllerHandle,\r
+  IN  EFI_HANDLE                                              ChildHandle  OPTIONAL,\r
+  IN  CHAR8                                                   *Language,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED                * ActionRequired\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Allows the user to set controller specific options for a controller that a \r
+    driver is currently managing.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to set options on.\r
+    ChildHandle      - The handle of the child controller to set options on.  This\r
+                       is an optional parameter that may be NULL.  It will be NULL \r
+                       for device drivers, and for a bus drivers that wish to set \r
+                       options for the bus controller.  It will not be NULL for a \r
+                       bus driver that wishes to set options for one of its child \r
+                       controllers.\r
+    Language         - A pointer to a three character ISO 639-2 language identifier.\r
+                       This is the language of the user interface that should be \r
+                       presented to the user, and it must match one of the languages \r
+                       specified in SupportedLanguages.  The number of languages \r
+                       supported by a driver is up to the driver writer.\r
+    ActionRequired   - A pointer to the action that the calling agent is required \r
+                       to perform when this function returns.  See "Related \r
+                       Definitions" for a list of the actions that the calling \r
+                       agent is required to perform prior to accessing \r
+                       ControllerHandle again.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle..\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support setting \r
+                            configuration options for the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_CONFIGURATION_OPTIONS_VALID) (\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL                        * This,\r
+  IN  EFI_HANDLE                                              ControllerHandle,\r
+  IN  EFI_HANDLE                                              ChildHandle  OPTIONAL\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Tests to see if a controller's current configuration options are valid.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to test if it's current \r
+                       configuration options are valid.\r
+    ChildHandle      - The handle of the child controller to test if it's current\r
+                       configuration options are valid.  This is an optional \r
+                       parameter that may be NULL.  It will be NULL for device \r
+                       drivers.  It will also be NULL for a bus drivers that wish\r
+                       to test the configuration options for the bus controller.\r
+                       It will not be NULL for a bus driver that wishes to test \r
+                       configuration options for one of its child controllers.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has a valid set of  configuration\r
+                            options.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by ControllerHandle \r
+                            and ChildHandle.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has an invalid set of configuration \r
+                            options.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS) (\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL                        * This,\r
+  IN  EFI_HANDLE                                              ControllerHandle,\r
+  IN  EFI_HANDLE                                              ChildHandle  OPTIONAL,\r
+  IN  UINT32                                                  DefaultType,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED                * ActionRequired\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Forces a driver to set the default configuration options for a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to force default configuration options on.\r
+    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.\r
+    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.\r
+    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.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the configuration type specified by DefaultType.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to force the default configuration options on the controller specified by  ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the Driver Configuration Protocol\r
+//\r
+typedef struct _EFI_DRIVER_CONFIGURATION_PROTOCOL {\r
+  EFI_DRIVER_CONFIGURATION_SET_OPTIONS    SetOptions;\r
+  EFI_DRIVER_CONFIGURATION_OPTIONS_VALID  OptionsValid;\r
+  EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS ForceDefaults;\r
+  CHAR8                                   *SupportedLanguages;\r
+} EFI_DRIVER_CONFIGURATION_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    Used to set configuration options for a controller that an EFI Driver is managing.\r
+\r
+  Parameters:\r
+    SetOptions         - Allows the use to set drivers specific configuration \r
+                         options for a controller that the driver is currently \r
+                         managing.\r
+    OptionsValid       - Tests to see if a controller's current configuration \r
+                         options are valid. \r
+    ForceDefaults      - Forces a driver to set the default configuration options \r
+                         for a controller.\r
+    SupportedLanguages - A Null-terminated ASCII string that contains one or more \r
+                         ISO 639-2 language codes.  This is the list of language \r
+                         codes that this protocol supports.\r
+\r
+--*/\r
+extern EFI_GUID gEfiDriverConfigurationProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c
new file mode 100644 (file)
index 0000000..2b20c2b
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverDiagnostics.c\r
+    \r
+Abstract:\r
+\r
+    EFI Driver Diagnostics Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)\r
+\r
+EFI_GUID  gEfiDriverDiagnosticsProtocolGuid = EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiDriverDiagnosticsProtocolGuid, "Driver Diagnostics Protocol", "EFI 1.1 Driver Diagnostics Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h
new file mode 100644 (file)
index 0000000..9a96f47
--- /dev/null
@@ -0,0 +1,138 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DriverDiagnostics.h\r
+    \r
+Abstract:\r
+\r
+    EFI Driver Diagnostics Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DRIVER_DIAGNOSTICS_H_\r
+#define _EFI_DRIVER_DIAGNOSTICS_H_\r
+\r
+//\r
+// Global ID for the Driver Diagnostics Protocol\r
+//\r
+#define EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID \\r
+  { \\r
+    0x0784924f, 0xe296, 0x11d4, 0x9a, 0x49, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DRIVER_DIAGNOSTICS_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiDriverDiagnosticTypeStandard     = 0,\r
+  EfiDriverDiagnosticTypeExtended     = 1,\r
+  EfiDriverDiagnosticTypeManufacturing= 2,\r
+  EfiDriverDiagnosticTypeMaximum\r
+} EFI_DRIVER_DIAGNOSTIC_TYPE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS) (\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL                        * This,\r
+  IN  EFI_HANDLE                                            ControllerHandle,\r
+  IN  EFI_HANDLE                                            ChildHandle  OPTIONAL,\r
+  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                            DiagnosticType,\r
+  IN  CHAR8                                                 *Language,\r
+  OUT EFI_GUID                                              **ErrorType,\r
+  OUT UINTN                                                 *BufferSize,\r
+  OUT CHAR16                                                **Buffer\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Runs diagnostics on a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to run diagnostics on.\r
+    ChildHandle      - The handle of the child controller to run diagnostics on  \r
+                       This is an optional parameter that may be NULL.  It will \r
+                       be NULL for device drivers.  It will also be NULL for a \r
+                       bus drivers that wish to run diagnostics on the bus \r
+                       controller.  It will not be NULL for a bus driver that \r
+                       wishes to run diagnostics on one of its child controllers.\r
+    DiagnosticType   - Indicates type of diagnostics to perform on the controller \r
+                       specified by ControllerHandle and ChildHandle.   See \r
+                       "Related Definitions" for the list of supported types.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language in which the optional \r
+                       error message should be returned in Buffer, and it must \r
+                       match one of the languages specified in SupportedLanguages.\r
+                       The number of languages supported by a driver is up to \r
+                       the driver writer.  \r
+    ErrorType        - A GUID that defines the format of the data returned in \r
+                       Buffer.  \r
+    BufferSize       - The size, in bytes, of the data returned in Buffer.  \r
+    Buffer           - A buffer that contains a Null-terminated Unicode string \r
+                       plus some additional data whose format is defined by \r
+                       ErrorType.  Buffer is allocated by this function with \r
+                       AllocatePool(), and it is the caller's responsibility \r
+                       to free it with a call to FreePool().  \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle passed the diagnostic.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ErrorType is NULL.\r
+    EFI_INVALID_PARAMETER - BufferType is NULL.\r
+    EFI_INVALID_PARAMETER - Buffer is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support \r
+                            running diagnostics for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            type of diagnostic specified by DiagnosticType.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to complete\r
+                            the diagnostics.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to return\r
+                            the status information in ErrorType, BufferSize, \r
+                            and Buffer.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle did not pass the diagnostic.\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the Driver Diagnostics Protocol\r
+//\r
+typedef struct _EFI_DRIVER_DIAGNOSTICS_PROTOCOL {\r
+  EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS  RunDiagnostics;\r
+  CHAR8                                   *SupportedLanguages;\r
+} EFI_DRIVER_DIAGNOSTICS_PROTOCOL;\r
+\r
+/*++\r
+\r
+  Protocol Description:\r
+    Used to perform diagnostics on a controller that an EFI Driver is managing.\r
+\r
+  Parameters:\r
+    RunDiagnostics     - Runs diagnostics on a controller.\r
+    SupportedLanguages - A Null-terminated ASCII string that contains one or more\r
+                         ISO 639-2 language codes.  This is the list of language \r
+                         codes that this protocol supports.\r
+\r
+--*/\r
+extern EFI_GUID gEfiDriverDiagnosticsProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c
new file mode 100644 (file)
index 0000000..6ce94a0
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Ebc.c\r
+\r
+Abstract:\r
+\r
+  EBC protocol as defined in the EFI 1.1 specification.\r
+\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Ebc)\r
+\r
+EFI_GUID  gEfiEbcProtocolGuid = EFI_EBC_INTERPRETER_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiEbcProtocolGuid, "EBC Protocol", "EFI 1.1 EBC protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h
new file mode 100644 (file)
index 0000000..35c4221
--- /dev/null
@@ -0,0 +1,183 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+  \r
+    Ebc.h\r
+  \r
+Abstract:\r
+\r
+  Describes the protocol interface to the EBC interpreter.\r
+  \r
+--*/\r
+\r
+#ifndef _EBC_H_\r
+#define _EBC_H_\r
+\r
+#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \\r
+  { \\r
+    0x13AC6DD1, 0x73D0, 0x11D4, 0xB0, 0x6B, 0x00, 0xAA, 0x00, 0xBD, 0x6D, 0xE7 \\r
+  }\r
+\r
+//\r
+// Define for forward reference.\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_EBC_PROTOCOL);\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Create a thunk for an image entry point. In short, given the physical address\r
+  of the entry point for a loaded image, create a thunk that does some \r
+  fixup of arguments (and perform any other necessary overhead) and then\r
+  calls the original entry point. The caller can then use the returned pointer\r
+  to the created thunk as the new entry point to image.\r
+\r
+Arguments:\r
+\r
+  This          - protocol instance pointer\r
+  ImageHandle   - handle to the image. The EBC interpreter may use this to keep\r
+                  track of any resource allocations performed in loading and\r
+                  executing the image.\r
+  EbcEntryPoint - the entry point for the image (as defined in the file header)\r
+  Thunk         - pointer to thunk pointer where the address of the created\r
+                  thunk is returned.\r
+\r
+Returns:\r
+\r
+  Standard EFI_STATUS\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EBC_CREATE_THUNK) (\r
+  IN EFI_EBC_PROTOCOL           * This,\r
+  IN EFI_HANDLE                 ImageHandle,\r
+  IN VOID                       *EbcEntryPoint,\r
+  OUT VOID                      **Thunk\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Perform any cleanup necessary when an image is unloaded. Basically it gives\r
+  the EBC interpreter the chance to free up any resources allocated during\r
+  load and execution of an EBC image.\r
+\r
+Arguments:\r
+\r
+  This          - protocol instance pointer\r
+  ImageHandle   - the handle of the image being unloaded.\r
+\r
+Returns:\r
+\r
+  Standard EFI_STATUS.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EBC_UNLOAD_IMAGE) (\r
+  IN EFI_EBC_PROTOCOL           * This,\r
+  IN EFI_HANDLE                 ImageHandle\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  The I-Cache-flush registration service takes a pointer to a function to\r
+  call to flush the I-Cache. Here's the prototype for that function pointer.\r
+\r
+Arguments:\r
+\r
+  Start         - physical start address of CPU instruction cache to flush.\r
+  Length        - how many bytes to flush of the instruction cache.\r
+\r
+Returns:\r
+\r
+  Standard EFI_STATUS.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EBC_ICACHE_FLUSH) (\r
+  IN EFI_PHYSICAL_ADDRESS     Start,\r
+  IN UINT64                   Length\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This routine is called by the core firmware to provide the EBC driver with\r
+  a function to call to flush the CPU's instruction cache following creation\r
+  of a thunk. It is not required.\r
+\r
+Arguments:\r
+\r
+  This      - protocol instance pointer\r
+  Flush     - pointer to the function to call to flush the CPU instruction\r
+              cache.\r
+\r
+Returns:\r
+\r
+  Standard EFI_STATUS.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EBC_REGISTER_ICACHE_FLUSH) (\r
+  IN EFI_EBC_PROTOCOL           * This,\r
+  IN EBC_ICACHE_FLUSH           Flush\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This routine can be called to get the VM revision. It returns the same\r
+  value as the EBC BREAK 1 instruction returns.\r
+\r
+Arguments:\r
+\r
+  This      - protocol instance pointer\r
+  Version   - pointer to where to return the VM version\r
+\r
+Returns:\r
+\r
+  Standard EFI_STATUS.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EBC_GET_VERSION) (\r
+  IN EFI_EBC_PROTOCOL           * This,\r
+  IN OUT UINT64                 *Version\r
+  );\r
+\r
+//\r
+// Prototype for the actual EBC protocol interface\r
+//\r
+typedef struct _EFI_EBC_PROTOCOL {\r
+  EFI_EBC_CREATE_THUNK          CreateThunk;\r
+  EFI_EBC_UNLOAD_IMAGE          UnloadImage;\r
+  EFI_EBC_REGISTER_ICACHE_FLUSH RegisterICacheFlush;\r
+  EFI_EBC_GET_VERSION           GetVersion;\r
+} EFI_EBC_PROTOCOL;\r
+\r
+//\r
+// Extern the global EBC protocol GUID\r
+//\r
+extern EFI_GUID gEfiEbcProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c
new file mode 100644 (file)
index 0000000..43a4144
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidActive.c\r
+\r
+Abstract:\r
+\r
+  EDID Active Protocol from the UEFI 2.0 specification.\r
+\r
+  Placed on the video output device child handle that are actively displaying output.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (EdidActive)\r
+\r
+EFI_GUID  gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiEdidActiveProtocolGuid, "EFI EDID Active Protocol", "UEFI EDID Active Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h
new file mode 100644 (file)
index 0000000..50b325d
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidActive.h\r
+\r
+Abstract:\r
+\r
+  EDID Active Protocol from the UEFI 2.0 specification.\r
+\r
+  Placed on the video output device child handle that are actively displaying output.\r
+\r
+--*/\r
+\r
+#ifndef __EDID_ACTIVE_H__\r
+#define __EDID_ACTIVE_H__\r
+\r
+#define EFI_EDID_ACTIVE_PROTOCOL_GUID \\r
+  { \\r
+    0xbd8c1056, 0x9f36, 0x44ec, 0x92, 0xa8, 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 \\r
+  }\r
+\r
+typedef struct {\r
+  UINT32   SizeOfEdid;\r
+  UINT8    *Edid;\r
+} EFI_EDID_ACTIVE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiEdidActiveProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c
new file mode 100644 (file)
index 0000000..babfa51
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidDiscovered.c\r
+\r
+Abstract:\r
+\r
+  EDID Discovered Protocol from the UEFI 2.0 specification.\r
+\r
+  This protocol is placed on the video output device child handle and it represents\r
+  the EDID information being used for output device represented by the child handle.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)\r
+\r
+EFI_GUID  gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiEdidDiscoveredProtocolGuid, "EFI EDID Discovered Protocol", "UEFI EDID Discovered Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h
new file mode 100644 (file)
index 0000000..36061f6
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidDiscovered.h\r
+\r
+Abstract:\r
+\r
+  EDID Discovered Protocol from the UEFI 2.0 specification.\r
+\r
+  This protocol is placed on the video output device child handle and it represents\r
+  the EDID information being used for output device represented by the child handle.\r
+\r
+--*/\r
+\r
+#ifndef __EDID_DISCOVERED_H__\r
+#define __EDID_DISCOVERED_H__\r
+\r
+#define EFI_EDID_DISCOVERED_PROTOCOL_GUID \\r
+  { \\r
+    0x1c0c34f6, 0xd380, 0x41fa, 0xa0, 0x49, 0x8a, 0xd0, 0x6c,0x1a, 0x66, 0xaa \\r
+  }\r
+\r
+typedef struct {\r
+  UINT32   SizeOfEdid;\r
+  UINT8    *Edid;\r
+} EFI_EDID_DISCOVERED_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiEdidDiscoveredProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c
new file mode 100644 (file)
index 0000000..fae77a7
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidOverride.c\r
+\r
+Abstract:\r
+\r
+  EDID Override Protocol from the UEFI 2.0 specification.\r
+\r
+  Allow platform to provide EDID information to producer of the Graphics Output\r
+  protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (EdidOverride)\r
+\r
+EFI_GUID  gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiEdidOverrideProtocolGuid, "EFI EDID Override Protocol", "UEFI EDID Override Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h
new file mode 100644 (file)
index 0000000..d720a78
--- /dev/null
@@ -0,0 +1,78 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EdidOverride.h\r
+\r
+Abstract:\r
+\r
+  EDID Override Protocol from the UEFI 2.0 specification.\r
+\r
+  Allow platform to provide EDID information to producer of the Graphics Output\r
+  protocol.\r
+\r
+--*/\r
+\r
+#ifndef __EDID_OVERRIDE_H__\r
+#define __EDID_OVERRIDE_H__\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)\r
+\r
+#define EFI_EDID_OVERRIDE_PROTOCOL_GUID \\r
+  { \\r
+    0x48ecb431, 0xfb72, 0x45c0, 0xa9, 0x22, 0xf4, 0x58, 0xfe, 0x4, 0xb, 0xd5 \\r
+  }\r
+\r
+typedef struct _EFI_EDID_OVERRIDE_PROTOCOL EFI_EDID_OVERRIDE_PROTOCOL;\r
+\r
+#define EFI_EDID_OVERRIDE_DONT_OVERRIDE   0x01\r
+#define EFI_EDID_OVERRIDE_ENABLE_HOT_PLUG 0x02\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID) (\r
+  IN  EFI_EDID_OVERRIDE_PROTOCOL                  *This,\r
+  IN  EFI_HANDLE                                  *ChildHandle,\r
+  OUT UINT32                                      *Attributes,\r
+  IN OUT UINTN                                    *EdidSize,\r
+  IN OUT UINT8                                    **Edid\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ChildHandle           - A child handle produced by the Graphics Output EFI\r
+                            driver that represents a video output device. \r
+    Attributes            - The attributes associated with ChildHandle video output device.\r
+    EdidSize              - A pointer to the size, in bytes, of the Edid buffer.\r
+    Edid                  - A pointer to callee allocated buffer that contains the EDID that\r
+                            should be used for ChildHandle. A value of NULL \r
+                            represents no EDID override for ChildHandle.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Valid overrides returned for ChildHandle.\r
+    EFI_UNSUPPORTED       - ChildHandle has no overrides.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_EDID_OVERRIDE_PROTOCOL {\r
+  EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID   GetEdid;\r
+} EFI_EDID_OVERRIDE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiEdidOverrideProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c
new file mode 100644 (file)
index 0000000..c37e9c6
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiNetworkInterfaceIdentifier.c\r
+\r
+Abstract:\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier)\r
+\r
+EFI_GUID  gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiNetworkInterfaceIdentifierProtocolGuid, "Network Interface Identifier Protocol",\r
+      "EFI Network Interface Identifier Protocol"\r
+  );\r
+\r
+EFI_GUID  gEfiNetworkInterfaceIdentifierProtocolGuid_31 = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiNetworkInterfaceIdentifierProtocolGuid_31, "Network Interface Identifier Protocol_31",\r
+      "EFI1.1 Network Interface Identifier Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h
new file mode 100644 (file)
index 0000000..5a6bedd
--- /dev/null
@@ -0,0 +1,102 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module name:\r
+  \r
+    EfiNetworkInterfaceIdentifier.h\r
+\r
+Abstract:\r
+\r
+Revision history:\r
+    2000-Feb-18 M(f)J   GUID updated.\r
+                Structure order changed for machine word alignment.\r
+                Added StringId[4] to structure.\r
+                \r
+    2000-Feb-14 M(f)J   Genesis.\r
+--*/\r
+#ifndef _EFI_NETWORKINTERFACEIDENTIFER_H\r
+#define _EFI_NETWORKINTERFACEIDENTIFER_H\r
+\r
+\r
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \\r
+  { \\r
+    0xE18541CD, 0xF755, 0x4f73, 0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29 \\r
+  }\r
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31 \\r
+  { \\r
+    0x1ACED566, 0x76ED, 0x4218, 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 \\r
+  }\r
+\r
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION    0x00010000\r
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiNetworkInterfaceUndi = 1\r
+} EFI_NETWORK_PROTOCOL_TYPE;\r
+\r
+typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL {\r
+\r
+  UINT64  Revision;\r
+  //\r
+  // Revision of the network interface identifier protocol interface.\r
+  //\r
+  UINT64  ID;\r
+  //\r
+  // Address of the first byte of the identifying structure for this\r
+  // network interface.  This is set to zero if there is no structure.\r
+  //\r
+  // For PXE/UNDI this is the first byte of the !PXE structure.\r
+  //\r
+  UINT64  ImageAddr;\r
+  //\r
+  // Address of the UNrelocated driver/ROM image.  This is set\r
+  // to zero if there is no driver/ROM image.\r
+  //\r
+  // For 16-bit UNDI, this is the first byte of the option ROM in\r
+  // upper memory.\r
+  //\r
+  // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM\r
+  // image.\r
+  //\r
+  // For H/W UNDI, this is set to zero.\r
+  //\r
+  UINT32  ImageSize;\r
+  //\r
+  // Size of the UNrelocated driver/ROM image of this network interface.\r
+  // This is set to zero if there is no driver/ROM image.\r
+  //\r
+  CHAR8   StringId[4];\r
+  //\r
+  // 4 char ASCII string to go in class identifier (option 60) in DHCP\r
+  // and Boot Server discover packets.\r
+  // For EfiNetworkInterfaceUndi this field is "UNDI".\r
+  // For EfiNetworkInterfaceSnp this field is "SNPN".\r
+  //\r
+  UINT8   Type;\r
+  UINT8   MajorVer;\r
+  UINT8   MinorVer;\r
+  //\r
+  // Information to be placed into the PXE DHCP and Discover packets.\r
+  // This is the network interface type and version number that will\r
+  // be placed into DHCP option 94 (client network interface identifier).\r
+  //\r
+  BOOLEAN Ipv6Supported;\r
+  UINT8   IfNum;  // interface number to be used with pxeid structure\r
+} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid;\r
+extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid_31;\r
+\r
+#endif // _EFI_NII_H\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf
new file mode 100644 (file)
index 0000000..f1add5c
--- /dev/null
@@ -0,0 +1,158 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EfiProtocolLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EfiProtocolLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+  AcpiTable\AcpiTable.h\r
+  AcpiTable\AcpiTable.c\r
+  Arp\Arp.h\r
+  Arp\Arp.c\r
+  Bis\Bis.h\r
+  Bis\Bis.c\r
+  BlockIo\BlockIo.h\r
+  BlockIo\BlockIo.c\r
+  BusSpecificDriverOverride\BusSpecificDriverOverride.h\r
+  BusSpecificDriverOverride\BusSpecificDriverOverride.c\r
+  ComponentName\ComponentName.h\r
+  ComponentName\ComponentName.c\r
+  ComponentName2\ComponentName2.h\r
+  ComponentName2\ComponentName2.c\r
+  DebugPort\DebugPort.h\r
+  DebugPort\DebugPort.c\r
+  DebugSupport\DebugSupport.h\r
+  DebugSupport\DebugSupport.c\r
+  Decompress\Decompress.h\r
+  Decompress\Decompress.c\r
+  DeviceIo\DeviceIo.h\r
+  DeviceIo\DeviceIo.c\r
+  DevicePath\DevicePath.h\r
+  DevicePath\DevicePath.c\r
+  DevicePathFromText\DevicePathFromText.h\r
+  DevicePathFromText\DevicePathFromText.c\r
+  DevicePathToText\DevicePathToText.h\r
+  DevicePathToText\DevicePathToText.c\r
+  DevicePathUtilities\DevicePathUtilities.h\r
+  DevicePathUtilities\DevicePathUtilities.c\r
+  Dhcp4\Dhcp4.h\r
+  Dhcp4\Dhcp4.c\r
+  DiskIo\DiskIo.h\r
+  DiskIo\DiskIo.c\r
+  DriverBinding\DriverBinding.h\r
+  DriverBinding\DriverBinding.c\r
+  DriverConfiguration\DriverConfiguration.h\r
+  DriverConfiguration\DriverConfiguration.c\r
+  DriverDiagnostics\DriverDiagnostics.h\r
+  DriverDiagnostics\DriverDiagnostics.c\r
+  Ebc\Ebc.h\r
+  Ebc\Ebc.c\r
+  EdidActive\EdidActive.h\r
+  EdidActive\EdidActive.c\r
+  EdidDiscovered\EdidDiscovered.h\r
+  EdidDiscovered\EdidDiscovered.c\r
+  EdidOverride\EdidOverride.h\r
+  EdidOverride\EdidOverride.c\r
+  EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.h\r
+  EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.c\r
+  FileInfo\FileInfo.h\r
+  FileInfo\FileInfo.c\r
+  FileSystemInfo\FileSystemInfo.h\r
+  FileSystemInfo\FileSystemInfo.c\r
+  FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.h\r
+  FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.c\r
+  GraphicsOutput\GraphicsOutput.h\r
+  GraphicsOutput\GraphicsOutput.c\r
+  Ip4\Ip4.h\r
+  Ip4\Ip4.c\r
+  Ip4Config\Ip4Config.h\r
+  Ip4Config\Ip4Config.c\r
+  LoadedImage\LoadedImage.h\r
+  LoadedImage\LoadedImage.c\r
+  LoadFile\LoadFile.h\r
+  LoadFile\LoadFile.c\r
+  ManagedNetwork\ManagedNetwork.h\r
+  ManagedNetwork\ManagedNetwork.c\r
+  Mtftp4\Mtftp4.h\r
+  Mtftp4\Mtftp4.c\r
+  PciIo\PciIo.h\r
+  PciIo\PciIo.c\r
+  PciRootBridgeIo\PciRootBridgeIo.h\r
+  PciRootBridgeIo\PciRootBridgeIo.c\r
+  PlatformDriverOverride\PlatformDriverOverride.h\r
+  PlatformDriverOverride\PlatformDriverOverride.c\r
+  PxeBaseCode\PxeBaseCode.h\r
+  PxeBaseCode\PxeBaseCode.c\r
+  PxeBaseCodeCallBack\PxeBaseCodeCallBack.h\r
+  PxeBaseCodeCallBack\PxeBaseCodeCallBack.c\r
+  ScsiPassThru\ScsiPassThru.h\r
+  ScsiPassThru\ScsiPassThru.c\r
+  SerialIo\SerialIo.h\r
+  SerialIo\SerialIo.c\r
+  SimpleFileSystem\SimpleFileSystem.h\r
+  SimpleFileSystem\SimpleFileSystem.c\r
+  SimpleNetwork\SimpleNetwork.h\r
+  SimpleNetwork\SimpleNetwork.c\r
+  SimplePointer\SimplePointer.h\r
+  SimplePointer\SimplePointer.c\r
+  SimpleTextIn\SimpleTextIn.h\r
+  SimpleTextIn\SimpleTextIn.c\r
+  SimpleTextOut\SimpleTextOut.h\r
+  SimpleTextOut\SimpleTextOut.c\r
+  Udp4\Udp4.h\r
+  Udp4\Udp4.c\r
+  UgaDraw\UgaDraw.h\r
+  UgaDraw\UgaDraw.c\r
+  UgaIo\UgaIo.h\r
+  UgaIo\UgaIo.c\r
+  UnicodeCollation\UnicodeCollation.h\r
+  UnicodeCollation\UnicodeCollation.c\r
+  UsbHostController\UsbHostController.h\r
+  UsbHostController\UsbHostController.c\r
+  UsbIo\UsbIo.h\r
+  UsbIo\UsbIo.c\r
+  Hash\Hash.h\r
+  Hash\Hash.c\r
+  ServiceBinding\ServiceBinding.h\r
+  ScsiPassThruExt\ScsiPassThruExt.h\r
+  ScsiPassThruExt\ScsiPassThruExt.c\r
+  ScsiIo\ScsiIo.h\r
+  ScsiIo\ScsiIo.c\r
+  TapeIo\TapeIo.h\r
+  TapeIo\TapeIo.c\r
+  Tcp4\Tcp4.h\r
+  Tcp4\Tcp4.c\r
+  IScsiInitiatorName\IScsiInitiatorName.h\r
+  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 (file)
index 0000000..60bf39a
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileInfo.c\r
+\r
+Abstract:\r
+\r
+  FileInfo protocol as defined in the EFI 1.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (FileInfo)\r
+\r
+EFI_GUID  gEfiFileInfoGuid = EFI_FILE_INFO_ID;\r
+\r
+EFI_GUID_STRING(&gEfiFileInfoGuid, "File System Info", "EFI File System Info GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h
new file mode 100644 (file)
index 0000000..6400c0f
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileInfo.c\r
+\r
+Abstract:\r
+\r
+  SimpleFileSystem protocol as defined in the EFI 1.0 specification.\r
+\r
+  The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) \r
+  file system specified in EFI 1.0. It can also be used to abstract any \r
+  file system other than FAT.\r
+\r
+  EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem\r
\r
+--*/\r
+\r
+#ifndef _FILE_INFO_H_\r
+#define _FILE_INFO_H_\r
+\r
+#define EFI_FILE_INFO_ID \\r
+  { \\r
+    0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+typedef struct {\r
+  UINT64    Size;\r
+  UINT64    FileSize;\r
+  UINT64    PhysicalSize;\r
+  EFI_TIME  CreateTime;\r
+  EFI_TIME  LastAccessTime;\r
+  EFI_TIME  ModificationTime;\r
+  UINT64    Attribute;\r
+  CHAR16    FileName[1];\r
+} EFI_FILE_INFO;\r
+\r
+//\r
+// The FileName field of the EFI_FILE_INFO data structure is variable length.\r
+// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to\r
+// be the size of the data structure without the FileName field.  The following macro\r
+// computes this size correctly no matter how big the FileName array is declared.\r
+// This is required to make the EFI_FILE_INFO data structure ANSI compilant.\r
+//\r
+#define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET (EFI_FILE_INFO, FileName)\r
+\r
+extern EFI_GUID gEfiFileInfoGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c
new file mode 100644 (file)
index 0000000..fe7a1b0
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileSystemInfo.c\r
+\r
+Abstract:\r
+\r
+  FileSystemInfo protocol as defined in the EFI 1.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (FileSystemInfo)\r
+\r
+EFI_GUID  gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFileSystemInfoGuid, "File System Info ID", "EFI File System Info ID GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h
new file mode 100644 (file)
index 0000000..fd3c737
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileSystemInfo.h\r
+\r
+Abstract:\r
+\r
+  FileSystemInfo protocol as defined in the EFI 1.0 specification.\r
+\r
\r
+--*/\r
+\r
+#ifndef _FILE_SYSTEM_INFO_H_\r
+#define _FILE_SYSTEM_INFO_H_\r
+\r
+#define EFI_FILE_SYSTEM_INFO_ID_GUID \\r
+  { \\r
+    0x9576e93, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+typedef struct {\r
+  UINT64  Size;\r
+  BOOLEAN ReadOnly;\r
+  UINT64  VolumeSize;\r
+  UINT64  FreeSpace;\r
+  UINT32  BlockSize;\r
+  CHAR16  VolumeLabel[1];\r
+} EFI_FILE_SYSTEM_INFO;\r
+\r
+//\r
+// The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length.\r
+// Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs\r
+// to be the size of the data structure without the VolumeLable field.  The following macro\r
+// computes this size correctly no matter how big the VolumeLable array is declared.\r
+// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant.\r
+//\r
+#define SIZE_OF_EFI_FILE_SYSTEM_INFO  EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_INFO, VolumeLabel)\r
+\r
+extern EFI_GUID gEfiFileSystemInfoGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c
new file mode 100644 (file)
index 0000000..021e19a
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileSystemVolumeLabelInfo.c\r
+\r
+Abstract:\r
+\r
+  SimpleFileSystem protocol as defined in the EFI 1.0 specification.\r
+\r
+  The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) \r
+  file system specified in EFI 1.0. It can also be used to abstract any \r
+  file system other than FAT.\r
+\r
+  EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo)\r
+\r
+EFI_GUID  gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiFileSystemVolumeLabelInfoIdGuid, "File System Vol Label ID", "EFI File System Volume Label Info ID GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h
new file mode 100644 (file)
index 0000000..a831d3a
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileSystemVolumeLabelInfo.h\r
+\r
+Abstract:\r
+\r
+  FileSystemVolumeLabelInfo protocol as defined in the EFI 1.0 specification.\r
+\r
+--*/\r
+\r
+#ifndef _FILE_SYSTEM_VOLUME_LABEL_INFO_H_\r
+#define _FILE_SYSTEM_VOLUME_LABEL_INFO_H_\r
+\r
+#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID \\r
+  { \\r
+    0xDB47D7D3, 0xFE81, 0x11d3, 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \\r
+  }\r
+\r
+typedef struct {\r
+  CHAR16  VolumeLabel[1];\r
+} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO;\r
+\r
+#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_VOLUME_LABEL_INFO, VolumeLabel)\r
+\r
+extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c
new file mode 100644 (file)
index 0000000..fd498f0
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GraphicsOutput.c\r
+\r
+Abstract:\r
+\r
+  Graphics Output Protocol from the UEFI 2.0 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)\r
+\r
+EFI_GUID  gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiGraphicsOutputProtocolGuid, "EFI Graphics Output Protocol", "UEFI Graphics Output Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h
new file mode 100644 (file)
index 0000000..6afb558
--- /dev/null
@@ -0,0 +1,206 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GraphicsOutput.h\r
+\r
+Abstract:\r
+\r
+  Graphics Output Protocol from the UEFI 2.0 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#ifndef __GRAPHICS_OUTPUT_H__\r
+#define __GRAPHICS_OUTPUT_H__\r
+\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+\r
+#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \\r
+  { \\r
+    0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a \\r
+  }\r
+\r
+typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;\r
+\r
+typedef struct {\r
+  UINT32            RedMask;\r
+  UINT32            GreenMask;\r
+  UINT32            BlueMask;\r
+  UINT32            ReservedMask;\r
+} EFI_PIXEL_BITMASK;\r
+\r
+typedef enum {\r
+  PixelRedGreenBlueReserved8BitPerColor,\r
+  PixelBlueGreenRedReserved8BitPerColor,\r
+  PixelBitMask,\r
+  PixelBltOnly,\r
+  PixelFormatMax\r
+} EFI_GRAPHICS_PIXEL_FORMAT;\r
+\r
+typedef struct {\r
+  UINT32                     Version;\r
+  UINT32                     HorizontalResolution;\r
+  UINT32                     VerticalResolution;\r
+  EFI_GRAPHICS_PIXEL_FORMAT  PixelFormat;\r
+  EFI_PIXEL_BITMASK          PixelInformation;\r
+  UINT32                     PixelsPerScanLine;\r
+} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) (\r
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,\r
+  IN  UINT32                                ModeNumber,\r
+  OUT UINTN                                 *SizeOfInfo,\r
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ModeNumber            - The mode number to return information on.\r
+    SizeOfInfo            - A pointer to the size, in bytes, of the Info buffer.\r
+    Info                  - A pointer to callee allocated buffer that returns information about ModeNumber.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Mode information returned.\r
+    EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\r
+    EFI_NOT_STARTED       - Video display is not initialized. Call SetMode () \r
+    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) (\r
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
+  IN  UINT32                       ModeNumber\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This             - Protocol instance pointer.\r
+    ModeNumber       - The mode number to be set.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - Graphics mode was changed.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
+\r
+--*/\r
+;\r
+\r
+typedef EFI_UGA_PIXEL EFI_GRAPHICS_OUTPUT_BLT_PIXEL;\r
+\r
+typedef union {\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;\r
+  UINT32                        Raw;\r
+} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;\r
+\r
+typedef enum {\r
+  EfiBltVideoFill,\r
+  EfiBltVideoToBltBuffer,\r
+  EfiBltBufferToVideo, \r
+  EfiBltVideoToVideo,\r
+  EfiGraphicsOutputBltOperationMax\r
+} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) (\r
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL            * This,\r
+  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL           * BltBuffer, OPTIONAL\r
+  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION       BltOperation,\r
+  IN  UINTN                                   SourceX,\r
+  IN  UINTN                                   SourceY,\r
+  IN  UINTN                                   DestinationX,\r
+  IN  UINTN                                   DestinationY,\r
+  IN  UINTN                                   Width,\r
+  IN  UINTN                                   Height,\r
+  IN  UINTN                                   Delta         OPTIONAL\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    The following table defines actions for BltOperations:\r
+    EfiBltVideoFill - Write data from the  BltBuffer pixel (SourceX, SourceY) \r
+      directly to every pixel of the video display rectangle \r
+      (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+      Only one pixel will be used from the BltBuffer. Delta is NOT used.\r
+    EfiBltVideoToBltBuffer - Read data from the video display rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in \r
+      the BltBuffer rectangle (DestinationX, DestinationY ) \r
+      (DestinationX + Width, DestinationY + Height). If DestinationX or \r
+      DestinationY is not zero then Delta must be set to the length in bytes \r
+      of a row in the BltBuffer.\r
+    EfiBltBufferToVideo - Write data from the  BltBuffer rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the \r
+      video display rectangle (DestinationX, DestinationY) \r
+      (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is \r
+      not zero then Delta must be set to the length in bytes of a row in the \r
+      BltBuffer.\r
+    EfiBltVideoToVideo - Copy from the video display rectangle (SourceX, SourceY)\r
+     (SourceX + Width, SourceY + Height) .to the video display rectangle \r
+     (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+     The BltBuffer and Delta  are not used in this mode.\r
+\r
+  Arguments:\r
+    This          - Protocol instance pointer.\r
+    BltBuffer     - Buffer containing data to blit into video buffer. This \r
+                    buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+    BltOperation  - Operation to perform on BlitBuffer and video memory\r
+    SourceX       - X coordinate of source for the BltBuffer.\r
+    SourceY       - Y coordinate of source for the BltBuffer.\r
+    DestinationX  - X coordinate of destination for the BltBuffer.\r
+    DestinationY  - Y coordinate of destination for the BltBuffer.\r
+    Width         - Width of rectangle in BltBuffer in pixels.\r
+    Height        - Hight of rectangle in BltBuffer in pixels.\r
+    Delta         -\r
+  \r
+  Returns:\r
+    EFI_SUCCESS           - The Blt operation completed.\r
+    EFI_INVALID_PARAMETER - BltOperation is not valid.\r
+    EFI_DEVICE_ERROR      - A hardware error occured writting to the video \r
+                             buffer.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+  UINT32                                 MaxMode;\r
+  UINT32                                 Mode;\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION   *Info;\r
+  UINTN                                  SizeOfInfo;\r
+  EFI_PHYSICAL_ADDRESS                   FrameBufferBase;\r
+  UINTN                                  FrameBufferSize;\r
+} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;\r
+\r
+typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE  QueryMode;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE    SetMode;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT         Blt;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE        *Mode;\r
+} EFI_GRAPHICS_OUTPUT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiGraphicsOutputProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c
new file mode 100644 (file)
index 0000000..feba9e6
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Hash.c\r
+    \r
+Abstract: \r
+  EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.\r
+  EFI_HASH_PROTOCOL as defined in UEFI 2.0.\r
+  The EFI Hash Service Binding Protocol is used to locate hashing services support \r
+  provided by a driver and create and destroy instances of the EFI Hash Protocol \r
+  so that a multiple drivers can use the underlying hashing services.\r
+  The EFI Service Binding Protocol defines the generic Service Binding Protocol functions.\r
+\r
+Revision History\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Hash)\r
+\r
+EFI_GUID  gEfiHashServiceBindingProtocolGuid = EFI_HASH_SERVICE_BINDING_PROTOCOL;\r
+EFI_GUID  gEfiHashProtocolGuid               = EFI_HASH_PROTOCOL_GUID;\r
+EFI_GUID  gEfiHashAlgorithmSha1Guid          = EFI_HASH_ALGORITHM_SHA1_GUID;\r
+EFI_GUID  gEfiHashAlgorithmSha224Guid        = EFI_HASH_ALGORITHM_SHA224_GUID;\r
+EFI_GUID  gEfiHashAlgorithmSha256Guid        = EFI_HASH_ALGORITHM_SHA256_GUID;\r
+EFI_GUID  gEfiHashAlgorithmSha384Guid        = EFI_HASH_ALGORITHM_SHA384_GUID;\r
+EFI_GUID  gEfiHashAlgorithmSha512Guid        = EFI_HASH_ALGORITHM_SHA512_GUID;\r
+EFI_GUID  gEfiHashAlgorithmMD5Guid           = EFI_HASH_ALGORTIHM_MD5_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHashProtocolGuid, "Hash protoco", "UEFI 2.0 Hash protocol");\r
+EFI_GUID_STRING(&gEfiHashServiceBindingProtocolGuid, "Hash service binding protoco", "UEFI 2.0 Hash service binding protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h
new file mode 100644 (file)
index 0000000..1fa9afb
--- /dev/null
@@ -0,0 +1,161 @@
+/*++\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Hash.h\r
+    \r
+Abstract: \r
+  EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.\r
+  EFI_HASH_PROTOCOL as defined in UEFI 2.0.\r
+  The EFI Hash Service Binding Protocol is used to locate hashing services support \r
+  provided by a driver and create and destroy instances of the EFI Hash Protocol \r
+  so that a multiple drivers can use the underlying hashing services.\r
+  The EFI Service Binding Protocol defines the generic Service Binding Protocol functions.\r
+\r
+Revision History\r
+--*/\r
+\r
+#ifndef __EFI_HASH_PROTOCOL_H__\r
+#define __EFI_HASH_PROTOCOL_H__\r
+\r
+#define EFI_HASH_SERVICE_BINDING_PROTOCOL \\r
+  { \\r
+    0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \\r
+  }\r
+  \r
+#define EFI_HASH_PROTOCOL_GUID \\r
+  { \\r
+    0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \\r
+  }\r
+\r
+#define EFI_HASH_ALGORITHM_SHA1_GUID \\r
+  { \\r
+    0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \\r
+  }\r
+\r
+#define EFI_HASH_ALGORITHM_SHA224_GUID \\r
+  { \\r
+    0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \\r
+  } \r
+\r
+#define EFI_HASH_ALGORITHM_SHA256_GUID \\r
+  { \\r
+    0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \\r
+  } \r
+\r
+#define EFI_HASH_ALGORITHM_SHA384_GUID \\r
+  { \\r
+    0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \\r
+  } \r
+\r
+#define EFI_HASH_ALGORITHM_SHA512_GUID \\r
+  { \\r
+    0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \\r
+  }\r
+\r
+#define EFI_HASH_ALGORTIHM_MD5_GUID \\r
+  { \\r
+    0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \\r
+  }\r
+\r
+typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL;\r
+\r
+typedef UINT8  EFI_MD5_HASH[16];\r
+typedef UINT8  EFI_SHA1_HASH[20];\r
+typedef UINT8  EFI_SHA224_HASH[28];\r
+typedef UINT8  EFI_SHA256_HASH[32];\r
+typedef UINT8  EFI_SHA384_HASH[48];\r
+typedef UINT8  EFI_SHA512_HASH[64];\r
+\r
+typedef union {\r
+  EFI_MD5_HASH     *Md5Hash;\r
+  EFI_SHA1_HASH    *Sha1Hash;\r
+  EFI_SHA224_HASH  *Sha224Hash;\r
+  EFI_SHA256_HASH  *Sha256Hash;\r
+  EFI_SHA384_HASH  *Sha384Hash;\r
+  EFI_SHA512_HASH  *Sha512Hash;\r
+} EFI_HASH_OUTPUT;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH_GET_HASH_SIZE) (\r
+  IN  CONST EFI_HASH_PROTOCOL     *This,\r
+  IN  CONST EFI_GUID              *HashAlgorithm,\r
+  OUT UINTN                       *HashSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns the size of the hash which results from a specific algorithm.\r
+\r
+  Arguments:\r
+    This             -  Points to this instance of EFI_HASH_PROTOCOL.\r
+    HashAlgorithm    -  Points to the EFI_GUID which identifies the algorithm to use.\r
+    HashSize         -  Holds the returned size of the algorithm¡¯s hash.\r
+  \r
+  Returns:\r
+    EFI_SUCCESS            - Hash size returned successfully.\r
+    EFI_INVALID_PARAMETER  - HashSize is NULL\r
+    EFI_UNSUPPORTED        - The algorithm specified by HashAlgorithm is not supported \r
+                             by this driver.\r
+--*/\r
+;      \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH_HASH) (\r
+  IN CONST EFI_HASH_PROTOCOL      *This,\r
+  IN CONST EFI_GUID               *HashAlgorithm,\r
+  IN BOOLEAN                      Extend,\r
+  IN CONST UINT8                  *Message,\r
+  IN UINT64                       MessageSize,\r
+  IN OUT EFI_HASH_OUTPUT          *Hash\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns the size of the hash which results from a specific algorithm.\r
+\r
+  Arguments:\r
+    This           -  Points to this instance of EFI_HASH_PROTOCOL.\r
+    HashAlgorithm  -  Points to the EFI_GUID which identifies the algorithm to use.\r
+    Extend         -  Specifies whether to create a new hash (FALSE) or extend the specified\r
+                      existing hash (TRUE).\r
+    Message        -  Points to the start of the message.\r
+    MessageSize    -  The size of Message, in bytes.\r
+    Hash           -  On input, if Extend is TRUE, then this holds the hash to extend. On\r
+                      output, holds the resulting hash computed from the message.\r
+\r
+  Returns:\r
+    EFI_SUCCESS            - Hash returned successfully.\r
+    EFI_INVALID_PARAMETER  - Message or Hash is NULL\r
+    EFI_UNSUPPORTED        - The algorithm specified by HashAlgorithm is not supported by this\r
+                             driver. Or extend is TRUE and the algorithm doesn¡¯t support extending the hash.\r
+\r
+--*/\r
+;    \r
+\r
+struct _EFI_HASH_PROTOCOL {\r
+  EFI_HASH_GET_HASH_SIZE          GetHashSize;\r
+  EFI_HASH_HASH                   Hash;\r
+};\r
+\r
+extern EFI_GUID gEfiHashServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiHashProtocolGuid;\r
+extern EFI_GUID gEfiHashAlgorithmSha1Guid;\r
+extern EFI_GUID gEfiHashAlgorithmSha224Guid;\r
+extern EFI_GUID gEfiHashAlgorithmSha256Guid;\r
+extern EFI_GUID gEfiHashAlgorithmSha384Guid;\r
+extern EFI_GUID gEfiHashAlgorithmSha512Guid;\r
+extern EFI_GUID gEfiHashAlgorithmMD5Guid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c
new file mode 100644 (file)
index 0000000..d268b43
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IScsiInitatorName.c\r
+    \r
+Abstract: \r
+  EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0.\r
+  It rovides the ability to get and set the iSCSI Initiator Name.                                                  \r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName)\r
+\r
+EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID;\r
+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 (file)
index 0000000..65ef0f7
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IScsiInitatorName.h\r
+    \r
+Abstract: \r
+  EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0.\r
+  It rovides the ability to get and set the iSCSI Initiator Name.                                                  \r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef __ISCSI_INITIATOR_NAME_H__\r
+#define __ISCSI_INITIATOR_NAME_H__\r
+\r
+#define EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID \\r
+{ \\r
+  0x59324945, 0xec44, 0x4c0d, {0xb1, 0xcd, 0x9d, 0xb1, 0x39, 0xdf, 0x7, 0xc } \\r
+}\r
+\r
+typedef struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL EFI_ISCSI_INITIATOR_NAME_PROTOCOL;\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_ISCSI_INITIATOR_NAME_GET) (\r
+  IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r
+  IN OUT UINTN                         *BufferSize,\r
+  OUT VOID                             *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the current set value of iSCSI Initiator Name.\r
+  \r
+  Arguments:\r
+    This         - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r
+    BufferSize   - Size of the buffer in bytes pointed to by Buffer / Actual size of the\r
+                   variable data buffer.\r
+    Buffer       - Pointer to the buffer for data to be read.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Data was successfully retrieved into the provided buffer and the\r
+                            BufferSize was sufficient to handle the iSCSI initiator name\r
+    EFI_BUFFER_TOO_SMALL  - BufferSize is too small for the result.\r
+    EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL.\r
+    EFI_DEVICE_ERROR      - The iSCSI initiator name could not be retrieved due to a hardware error.\r
+    \r
+--*/\r
+;\r
+\r
+  \r
+\r
+typedef EFI_STATUS\r
+(EFIAPI *EFI_ISCSI_INITIATOR_NAME_SET) (\r
+  IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r
+  IN OUT UINTN                         *BufferSize,\r
+  IN VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the iSCSI Initiator Name.\r
+\r
+  Arguments:\r
+    This       - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r
+    BufferSize - Size of the buffer in bytes pointed to by Buffer.\r
+    Buffer     - Pointer to the buffer for data to be written.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Data was successfully stored by the protocol.\r
+    EFI_UNSUPPORTED       - Platform policies do not allow for data to be written.\r
+    EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit.\r
+    EFI_DEVICE_ERROR      - The data could not be stored due to a hardware error.\r
+    EFI_OUT_OF_RESOURCES  - Not enough storage is available to hold the data.\r
+    EFI_PROTOCOL_ERROR    - Input iSCSI initiator name does not adhere to RFC 3720\r
+                            (and other related protocols)\r
+    \r
+--*/\r
+;  \r
+\r
+struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL {\r
+  EFI_ISCSI_INITIATOR_NAME_GET         Get;\r
+  EFI_ISCSI_INITIATOR_NAME_SET         Set;\r
+};\r
+\r
+extern EFI_GUID gEfiIScsiInitiatorNameProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c
new file mode 100644 (file)
index 0000000..b1e6389
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+\r
+Module Name:\r
+\r
+  Ip4.c\r
+\r
+Abstract:\r
+\r
+  UEFI IPv4 protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Ip4)\r
+\r
+EFI_GUID gEfiIp4ServiceBindingProtocolGuid \r
+           = EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID;\r
+\r
+EFI_GUID gEfiIp4ProtocolGuid = EFI_IP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiIp4ServiceBindingProtocolGuid, \r
+  "IP4 Service Binding Protocol", \r
+  "IP4 Service Binding Protocol"\r
+  );\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiIp4ProtocolGuid,               \r
+  "IP4 Protocol",                 \r
+  "IP4 Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h
new file mode 100644 (file)
index 0000000..a2daf6f
--- /dev/null
@@ -0,0 +1,241 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Ip4.h\r
+\r
+Abstract:\r
+\r
+  UEFI IPv4 protocol.\r
+\r
+--*/\r
+\r
+#ifndef _IP4_H_\r
+#define _IP4_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+\r
+//\r
+//GUID definitions\r
+//\r
+#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+   {0xc51711e7, 0xb4bf, 0x404a, 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4}\r
+\r
+#define EFI_IP4_PROTOCOL_GUID \\r
+   {0x41d94cd2, 0x35b6, 0x455a, 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_IP4_PROTOCOL);\r
+\r
+typedef struct {\r
+  EFI_HANDLE              InstanceHandle;\r
+  EFI_IPv4_ADDRESS        Ip4Address;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+} EFI_IP4_ADDRESS_PAIR; \r
+\r
+typedef struct {\r
+  EFI_HANDLE              DriverHandle;\r
+  UINT32                  AddressCount;\r
+  EFI_IP4_ADDRESS_PAIR    AddressPairs[1];\r
+} EFI_IP4_VARIABLE_DATA;\r
+\r
+typedef struct {\r
+  UINT8                   DefaultProtocol;\r
+  BOOLEAN                 AcceptAnyProtocol;\r
+  BOOLEAN                 AcceptIcmpErrors;\r
+  BOOLEAN                 AcceptBroadcast;\r
+  BOOLEAN                 AcceptPromiscuous;\r
+  BOOLEAN                 UseDefaultAddress;\r
+  EFI_IPv4_ADDRESS        StationAddress;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+  UINT8                   TypeOfService;\r
+  UINT8                   TimeToLive;\r
+  BOOLEAN                 DoNotFragment;\r
+  BOOLEAN                 RawData;\r
+  UINT32                  ReceiveTimeout;\r
+  UINT32                  TransmitTimeout;\r
+} EFI_IP4_CONFIG_DATA;\r
+\r
+\r
+typedef struct _EFI_IP4_ROUTE_TABLE {\r
+  EFI_IPv4_ADDRESS        SubnetAddress;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+  EFI_IPv4_ADDRESS        GatewayAddress;\r
+} EFI_IP4_ROUTE_TABLE;\r
+\r
+typedef struct _EFI_IP4_ICMP_TYPE {\r
+  UINT8                   Type;\r
+  UINT8                   Code;\r
+} EFI_IP4_ICMP_TYPE;\r
+\r
+typedef struct {\r
+  BOOLEAN                 IsStarted;\r
+\r
+  EFI_IP4_CONFIG_DATA     ConfigData;\r
+  BOOLEAN                 IsConfigured;\r
+\r
+  UINT32                  GroupCount;\r
+  EFI_IPv4_ADDRESS        *GroupTable;\r
+\r
+  UINT32                  RouteCount;\r
+  EFI_IP4_ROUTE_TABLE     *RouteTable;\r
+\r
+  UINT32                  IcmpTypeCount;\r
+  EFI_IP4_ICMP_TYPE       *IcmpTypeList;\r
+} EFI_IP4_MODE_DATA;\r
+\r
+#pragma pack(1)\r
+typedef struct _EFI_IP4_HEADER {\r
+  UINT8                   HeaderLength:4;\r
+  UINT8                   Version:4;\r
+  UINT8                   TypeOfService;\r
+  UINT16                  TotalLength;\r
+  UINT16                  Identification;\r
+  UINT16                  Fragmentation;\r
+  UINT8                   TimeToLive;\r
+  UINT8                   Protocol;\r
+  UINT16                  Checksum;\r
+  EFI_IPv4_ADDRESS        SourceAddress;\r
+  EFI_IPv4_ADDRESS        DestinationAddress;\r
+} EFI_IP4_HEADER;\r
+#pragma pack()\r
+\r
+typedef struct _EFI_IP4_FRAGMENT_DATA {\r
+  UINT32                  FragmentLength;\r
+  VOID                    *FragmentBuffer;\r
+} EFI_IP4_FRAGMENT_DATA;\r
+\r
+\r
+typedef struct _EFI_IP4_OVERRIDE_DATA {\r
+  EFI_IPv4_ADDRESS        SourceAddress;\r
+  EFI_IPv4_ADDRESS        GatewayAddress;\r
+\r
+  UINT8                   Protocol;\r
+  UINT8                   TypeOfService;\r
+  UINT8                   TimeToLive;\r
+  BOOLEAN                 DoNotFragment;\r
+} EFI_IP4_OVERRIDE_DATA;\r
+\r
+typedef struct _EFI_IP4_TRANSMIT_DATA {\r
+  EFI_IPv4_ADDRESS        DestinationAddress;\r
+\r
+  EFI_IP4_OVERRIDE_DATA   *OverrideData;\r
+  UINT32                  OptionsLength;\r
+  VOID                    *OptionsBuffer;\r
+\r
+  UINT32                  TotalDataLength;\r
+  UINT32                  FragmentCount;\r
+  EFI_IP4_FRAGMENT_DATA   FragmentTable[1];\r
+} EFI_IP4_TRANSMIT_DATA;\r
+\r
+typedef struct _EFI_IP4_RECEIVE_DATA {\r
+  EFI_TIME                TimeStamp;\r
+  EFI_EVENT               RecycleSignal;\r
+\r
+  UINT32                  HeaderLength;\r
+  EFI_IP4_HEADER          *Header;\r
+\r
+  UINT32                  OptionsLength;\r
+  VOID                    *Options;\r
+\r
+  UINT32                  DataLength;\r
+  UINT32                  FragmentCount;\r
+  EFI_IP4_FRAGMENT_DATA   FragmentTable[1];\r
+} EFI_IP4_RECEIVE_DATA;\r
+\r
+typedef struct _EFI_IP4_COMPLETION_TOKEN {\r
+  EFI_EVENT               Event;\r
+  EFI_STATUS              Status;\r
+\r
+  union {\r
+    EFI_IP4_RECEIVE_DATA  *RxData;\r
+    EFI_IP4_TRANSMIT_DATA *TxData;\r
+  } Packet;\r
+} EFI_IP4_COMPLETION_TOKEN;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_GET_MODE_DATA) (\r
+  IN EFI_IP4_PROTOCOL                 *This,\r
+  OUT EFI_IP4_MODE_DATA               *Ip4ModeData     OPTIONAL,\r
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData   OPTIONAL,\r
+  OUT EFI_SIMPLE_NETWORK_MODE         *SnpModeData     OPTIONAL\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_CONFIGURE) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN EFI_IP4_CONFIG_DATA        *IpConfigData  OPTIONAL\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_GROUPS) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN BOOLEAN                    JoinFlag,\r
+  IN EFI_IPv4_ADDRESS           *GroupAddress  OPTIONAL\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_ROUTES) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN BOOLEAN                    DeleteRoute,\r
+  IN EFI_IPv4_ADDRESS           *SubnetAddress,\r
+  IN EFI_IPv4_ADDRESS           *SubnetMask,\r
+  IN EFI_IPv4_ADDRESS           *GatewayAddress  \r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_TRANSMIT) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN EFI_IP4_COMPLETION_TOKEN   *Token\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_RECEIVE) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN EFI_IP4_COMPLETION_TOKEN   *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_CANCEL) (\r
+  IN EFI_IP4_PROTOCOL           *This,\r
+  IN EFI_IP4_COMPLETION_TOKEN   *Token OPTIONAL\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_POLL) (\r
+  IN EFI_IP4_PROTOCOL           *This\r
+  );\r
+\r
+typedef struct _EFI_IP4_PROTOCOL {\r
+  EFI_IP4_GET_MODE_DATA         GetModeData;\r
+  EFI_IP4_CONFIGURE             Configure;\r
+  EFI_IP4_GROUPS                Groups;\r
+  EFI_IP4_ROUTES                Routes;\r
+  EFI_IP4_TRANSMIT              Transmit;\r
+  EFI_IP4_RECEIVE               Receive;\r
+  EFI_IP4_CANCEL                Cancel;\r
+  EFI_IP4_POLL                  Poll;\r
+} EFI_IP4_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiIp4RegistryDataGuid;\r
+extern EFI_GUID gEfiIp4ProtocolGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c
new file mode 100644 (file)
index 0000000..453ca6f
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Ip4Config.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)\r
+\r
+EFI_GUID gEfiIp4ConfigProtocolGuid  = EFI_IP4_CONFIG_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiIp4ConfigProtocolGuid, \r
+  "Ip4Config Protocol",                 \r
+  "Ip4Config Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h
new file mode 100644 (file)
index 0000000..2b75268
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Ip4Config.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _IP4CONFIG_H_\r
+#define _IP4CONFIG_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Ip4)\r
+\r
+\r
+#define EFI_IP4_CONFIG_PROTOCOL_GUID \\r
+  {0x25c98279, 0x3d9c, 0x43f2, 0xa7, 0x0e, 0xe1, 0xea, 0x4e, 0x0d, 0xed, 0x1b}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_IP4_CONFIG_PROTOCOL);\r
+\r
+#define IP4_CONFIG_VARIABLE_ATTRIBUTES (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS )\r
+\r
+typedef struct {\r
+  EFI_IPv4_ADDRESS       StationAddress;\r
+  EFI_IPv4_ADDRESS       SubnetMask;\r
+  UINT32                 RouteTableSize;\r
+  EFI_IP4_ROUTE_TABLE    RouteTable[1];\r
+} EFI_IP4_IPCONFIG_DATA;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_CONFIG_START) (\r
+  IN EFI_IP4_CONFIG_PROTOCOL   *This,\r
+  IN EFI_EVENT                 DoneEvent,\r
+  IN EFI_EVENT                 ReconfigEvent \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_CONFIG_STOP) (\r
+  IN EFI_IP4_CONFIG_PROTOCOL  *This \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IP4_CONFIG_GET_DATA) (\r
+  IN EFI_IP4_CONFIG_PROTOCOL *This,\r
+  IN OUT UINTN               *ConfigDataSize,\r
+  OUT EFI_IP4_IPCONFIG_DATA  *ConfigData    OPTIONAL \r
+  );\r
+\r
+\r
+typedef struct _EFI_IP4_CONFIG_PROTOCOL {\r
+  EFI_IP4_CONFIG_START     Start;\r
+  EFI_IP4_CONFIG_STOP      Stop;\r
+  EFI_IP4_CONFIG_GET_DATA  GetData;\r
+} EFI_IP4_CONFIG_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiIp4ConfigProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c
new file mode 100644 (file)
index 0000000..33e7c52
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile.c\r
+\r
+Abstract:\r
+\r
+  Load File protocol as defined in the EFI 1.0 specification.\r
+\r
+  Load file protocol exists to supports the addition of new boot devices, \r
+  and to support booting from devices that do not map well to file system. \r
+  Network boot is done via a LoadFile protocol.\r
+\r
+  EFI 1.0 can boot from any device that produces a LoadFile protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (LoadFile)\r
+\r
+EFI_GUID  gEfiLoadFileProtocolGuid = LOAD_FILE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLoadFileProtocolGuid, "LoadFile Protocol", "EFI 1.0 Load File Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h
new file mode 100644 (file)
index 0000000..fc8aea5
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile.h\r
+\r
+Abstract:\r
+\r
+  Load File protocol as defined in the EFI 1.0 specification.\r
+\r
+  Load file protocol exists to supports the addition of new boot devices, \r
+  and to support booting from devices that do not map well to file system. \r
+  Network boot is done via a LoadFile protocol.\r
+\r
+  EFI 1.0 can boot from any device that produces a LoadFile protocol.\r
+\r
+--*/\r
+\r
+#ifndef _LOAD_FILE_H_\r
+#define _LOAD_FILE_H_\r
+\r
+#define LOAD_FILE_PROTOCOL_GUID \\r
+  { \\r
+    0x56EC3091, 0x954C, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LOAD_FILE_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LOAD_FILE) (\r
+  IN EFI_LOAD_FILE_PROTOCOL           * This,\r
+  IN EFI_DEVICE_PATH_PROTOCOL         * FilePath,\r
+  IN BOOLEAN                          BootPolicy,\r
+  IN OUT UINTN                        *BufferSize,\r
+  IN VOID                             *Buffer OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Causes the driver to load a specified file.\r
+\r
+  Arguments:\r
+    This     - Protocol instance pointer.\r
+    FilePath - The device specific path of the file to load.\r
+    BootPolicy - If TRUE, indicates that the request originates from the \r
+                 boot manager is attempting to load FilePath as a boot\r
+                 selection. If FALSE, then FilePath must match as exact file\r
+                 to be loaded.\r
+    BufferSize - On input the size of Buffer in bytes. On output with a return\r
+                  code of EFI_SUCCESS, the amount of data transferred to \r
+                  Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,\r
+                  the size of Buffer required to retrieve the requested file.\r
+    Buffer     - The memory buffer to transfer the file to. IF Buffer is NULL,\r
+                  then no the size of the requested file is returned in \r
+                  BufferSize.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The file was loaded.\r
+    EFI_UNSUPPORTED - The device does not support the provided BootPolicy\r
+    EFI_INVALID_PARAMETER - FilePath is not a valid device path, or \r
+                             BufferSize is NULL.\r
+    EFI_NO_MEDIA - No medium was present to load the file.\r
+    EFI_DEVICE_ERROR  - The file was not loaded due to a device error.\r
+    EFI_NO_RESPONSE - The remote system did not respond.\r
+    EFI_NOT_FOUND   - The file was not found\r
+    EFI_ABORTED - The file load process was manually cancelled.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_LOAD_FILE_PROTOCOL {\r
+  EFI_LOAD_FILE LoadFile;\r
+} EFI_LOAD_FILE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLoadFileProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c
new file mode 100644 (file)
index 0000000..961bc00
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ LoadedImage.c\r
+\r
+Abstract:\r
+\r
+  EFI 1.0 Loaded Image Protocol definition.\r
+\r
+  Every EFI driver and application is passed an image handle when it is loaded.\r
+  This image handle will contain a Loaded Image Protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)\r
+\r
+EFI_GUID  gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLoadedImageProtocolGuid, "LoadedImage Protocol", "EFI 1.0 Loaded Image Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h
new file mode 100644 (file)
index 0000000..07c62f1
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ LoadedImage.h\r
+\r
+Abstract:\r
+\r
+  EFI 1.0 Loaded image protocol definition.\r
+\r
+  Every EFI driver and application is passed an image handle when it is loaded.\r
+  This image handle will contain a Loaded Image Protocol.\r
+\r
+--*/\r
+\r
+#ifndef _LOADED_IMAGE_H_\r
+#define _LOADED_IMAGE_H_\r
+\r
+#define EFI_LOADED_IMAGE_PROTOCOL_GUID \\r
+  { \\r
+    0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \\r
+  }\r
+\r
+//\r
+// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h\r
+//\r
+#define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000\r
+\r
+typedef struct {\r
+  UINT32                    Revision;\r
+  EFI_HANDLE                ParentHandle;\r
+  EFI_SYSTEM_TABLE          *SystemTable;\r
+\r
+  //\r
+  // Source location of image\r
+  //\r
+  EFI_HANDLE                DeviceHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
+  VOID                      *Reserved;\r
+\r
+  //\r
+  // Images load options\r
+  //\r
+  UINT32                    LoadOptionsSize;\r
+  VOID                      *LoadOptions;\r
+\r
+  //\r
+  // Location of where image was loaded\r
+  //\r
+  VOID                      *ImageBase;\r
+  UINT64                    ImageSize;\r
+  EFI_MEMORY_TYPE           ImageCodeType;\r
+  EFI_MEMORY_TYPE           ImageDataType;\r
+\r
+  //\r
+  // If the driver image supports a dynamic unload request\r
+  //\r
+  EFI_IMAGE_UNLOAD          Unload;\r
+\r
+} EFI_LOADED_IMAGE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLoadedImageProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c
new file mode 100644 (file)
index 0000000..93b80f8
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ManagedNetwork.c\r
+\r
+Abstract:\r
+\r
+  UEFI Managed Network protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)\r
+\r
+EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID;\r
+EFI_GUID gEfiManagedNetworkProtocolGuid               = EFI_MANAGED_NETWORK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiManagedNetworkServiceBindingProtocolGuid, "Managed Network Service Binding Protocol", "Managed Network Service Binding Protocol");\r
+EFI_GUID_STRING (&gEfiManagedNetworkProtocolGuid, "Managed Network Protocol", "Managed Network Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h
new file mode 100644 (file)
index 0000000..274bb10
--- /dev/null
@@ -0,0 +1,164 @@
+/*++ \r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ManagedNetwork.h\r
+\r
+Abstract:\r
+\r
+  UEFI Managed Network protocol definition.\r
+\r
+--*/\r
+\r
+#ifndef _MANAGED_NETWORK_H_\r
+#define _MANAGED_NETWORK_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+\r
+#define EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID \\r
+  {0xf36ff770, 0xa7e1, 0x42cf, 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c}\r
+\r
+#define EFI_MANAGED_NETWORK_PROTOCOL_GUID \\r
+  { 0x3b95aa31, 0x3793, 0x434b, 0x86, 0x67, 0xc8, 0x7, 0x8, 0x92, 0xe0, 0x5e }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_MANAGED_NETWORK_PROTOCOL);\r
+\r
+typedef struct {\r
+  UINT32     ReceivedQueueTimeoutValue;\r
+  UINT32     TransmitQueueTimeoutValue;\r
+  UINT16     ProtocolTypeFilter;\r
+  BOOLEAN    EnableUnicastReceive;\r
+  BOOLEAN    EnableMulticastReceive;\r
+  BOOLEAN    EnableBroadcastReceive;\r
+  BOOLEAN    EnablePromiscuousReceive;\r
+  BOOLEAN    FlushQueuesOnReset;\r
+  BOOLEAN    EnableReceiveTimestamps;\r
+  BOOLEAN    DisableBackgroundPolling;\r
+} EFI_MANAGED_NETWORK_CONFIG_DATA;\r
+\r
+typedef struct {\r
+  EFI_TIME      Timestamp;\r
+  EFI_EVENT     RecycleEvent;\r
+  UINT32        PacketLength;\r
+  UINT32        HeaderLength;\r
+  UINT32        AddressLength;\r
+  UINT32        DataLength;\r
+  BOOLEAN       BroadcastFlag;\r
+  BOOLEAN       MulticastFlag;\r
+  BOOLEAN       PromiscuousFlag;\r
+  UINT16        ProtocolType;\r
+  VOID          *DestinationAddress;\r
+  VOID          *SourceAddress;\r
+  VOID          *MediaHeader;\r
+  VOID          *PacketData;\r
+} EFI_MANAGED_NETWORK_RECEIVE_DATA;\r
+\r
+typedef struct {\r
+  UINT32        FragmentLength;\r
+  VOID          *FragmentBuffer;\r
+} EFI_MANAGED_NETWORK_FRAGMENT_DATA;\r
+\r
+typedef struct {\r
+  EFI_MAC_ADDRESS                   *DestinationAddress;\r
+  EFI_MAC_ADDRESS                   *SourceAddress;\r
+  UINT16                            ProtocolType;\r
+  UINT32                            DataLength;\r
+  UINT16                            HeaderLength;\r
+  UINT16                            FragmentCount;\r
+  EFI_MANAGED_NETWORK_FRAGMENT_DATA FragmentTable[1];\r
+} EFI_MANAGED_NETWORK_TRANSMIT_DATA;\r
+\r
+\r
+typedef struct {\r
+  EFI_EVENT                             Event;\r
+  EFI_STATUS                            Status;\r
+  union {\r
+    EFI_MANAGED_NETWORK_RECEIVE_DATA    *RxData;\r
+    EFI_MANAGED_NETWORK_TRANSMIT_DATA   *TxData;\r
+  } Packet;\r
+} EFI_MANAGED_NETWORK_COMPLETION_TOKEN;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_GET_MODE_DATA) (\r
+  IN  EFI_MANAGED_NETWORK_PROTOCOL     *This,\r
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL,\r
+  OUT EFI_SIMPLE_NETWORK_MODE          *SnpModeData  OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_CONFIGURE) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL     *This,\r
+  IN EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC) (\r
+  IN  EFI_MANAGED_NETWORK_PROTOCOL  *This,\r
+  IN  BOOLEAN                       Ipv6Flag,\r
+  IN  EFI_IP_ADDRESS                *IpAddress,\r
+  OUT EFI_MAC_ADDRESS               *MacAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_GROUPS) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL  *This,\r
+  IN BOOLEAN                       JoinFlag,\r
+  IN EFI_MAC_ADDRESS               *MacAddress  OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_TRANSMIT) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,\r
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_RECEIVE) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,\r
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_CANCEL) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,\r
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token  OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MANAGED_NETWORK_POLL) (\r
+  IN EFI_MANAGED_NETWORK_PROTOCOL    *This\r
+  );\r
+\r
+typedef struct _EFI_MANAGED_NETWORK_PROTOCOL {\r
+  EFI_MANAGED_NETWORK_GET_MODE_DATA       GetModeData;\r
+  EFI_MANAGED_NETWORK_CONFIGURE           Configure;\r
+  EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC     McastIpToMac;\r
+  EFI_MANAGED_NETWORK_GROUPS              Groups;\r
+  EFI_MANAGED_NETWORK_TRANSMIT            Transmit;\r
+  EFI_MANAGED_NETWORK_RECEIVE             Receive;\r
+  EFI_MANAGED_NETWORK_CANCEL              Cancel;\r
+  EFI_MANAGED_NETWORK_POLL                Poll;\r
+} EFI_MANAGED_NETWORK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiManagedNetworkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c
new file mode 100644 (file)
index 0000000..d4f1dc2
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Mtftp4.c\r
+\r
+Abstract:\r
+\r
+  UEFI Multicast Trivial File Transfer Protocol GUID Declaration.\r
+  \r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Mtftp4)\r
+\r
+EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid  = EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID;\r
+EFI_GUID gEfiMtftp4ProtocolGuid                = EFI_MTFTP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiMtftp4ServiceBindingProtocolGuid, \r
+  "MTFTP4 Service Binding Protocol", \r
+  "MTFTP4 Service Binding Protocol"\r
+  );\r
+    \r
+EFI_GUID_STRING (\r
+  &gEfiMtftp4ProtocolGuid,               \r
+  "MTFTP4 Protocol",                 \r
+  "MTFTP4 Protocol"\r
+  );\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h
new file mode 100644 (file)
index 0000000..5c6d29f
--- /dev/null
@@ -0,0 +1,308 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Mtftp4.h\r
+\r
+Abstract:\r
+\r
+  UEFI Multicast Trivial File Tranfer Protocol Definition\r
+  \r
+--*/\r
+\r
+#ifndef __EFI_MTFTP4_H__\r
+#define __EFI_MTFTP4_H__\r
+\r
+#include EFI_PROTOCOL_DEFINITION(ServiceBinding)\r
+\r
+#define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+    { 0x2FE800BE, 0x8F01, 0x4aa6, 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F }\r
+\r
+#define EFI_MTFTP4_PROTOCOL_GUID \\r
+    { 0x78247c57, 0x63db, 0x4708, 0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_MTFTP4_PROTOCOL);\r
+EFI_FORWARD_DECLARATION (EFI_MTFTP4_TOKEN);\r
+\r
+extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiMtftp4ProtocolGuid;\r
+\r
+\r
+//\r
+//MTFTP4 packet opcode definition\r
+//\r
+#define EFI_MTFTP4_OPCODE_RRQ      1\r
+#define EFI_MTFTP4_OPCODE_WRQ      2\r
+#define EFI_MTFTP4_OPCODE_DATA     3\r
+#define EFI_MTFTP4_OPCODE_ACK      4\r
+#define EFI_MTFTP4_OPCODE_ERROR    5\r
+#define EFI_MTFTP4_OPCODE_OACK     6\r
+#define EFI_MTFTP4_OPCODE_DIR      7\r
+#define EFI_MTFTP4_OPCODE_DATA8    8\r
+#define EFI_MTFTP4_OPCODE_ACK8     9\r
+\r
+//\r
+//MTFTP4 error code definition\r
+//\r
+#define EFI_MTFTP4_ERRORCODE_NOT_DEFINED           0\r
+#define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND        1\r
+#define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION      2\r
+#define EFI_MTFTP4_ERRORCODE_DISK_FULL             3\r
+#define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION     4\r
+#define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID   5\r
+#define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS   6\r
+#define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER          7\r
+#define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED        8\r
+\r
+\r
+//\r
+//MTFTP4 pacekt definition\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT8     Filename[1];\r
+} EFI_MTFTP4_REQ_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT8     Data[1];\r
+} EFI_MTFTP4_OACK_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT16    Block;\r
+  UINT8     Data[1];\r
+} EFI_MTFTP4_DATA_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT16    Block[1];\r
+} EFI_MTFTP4_ACK_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT64    Block;\r
+  UINT8     Data[1];\r
+} EFI_MTFTP4_DATA8_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT64    Block[1];\r
+} EFI_MTFTP4_ACK8_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    OpCode;\r
+  UINT16    ErrorCode;\r
+  UINT8     ErrorMessage[1];\r
+} EFI_MTFTP4_ERROR_HEADER;\r
+\r
+typedef union {\r
+  UINT16                    OpCode;\r
+  EFI_MTFTP4_REQ_HEADER     Rrq;\r
+  EFI_MTFTP4_REQ_HEADER     Wrq;\r
+  EFI_MTFTP4_OACK_HEADER    Oack;\r
+  EFI_MTFTP4_DATA_HEADER    Data;\r
+  EFI_MTFTP4_ACK_HEADER     Ack;\r
+  EFI_MTFTP4_DATA8_HEADER   Data8;\r
+  EFI_MTFTP4_ACK8_HEADER    Ack8;\r
+  EFI_MTFTP4_ERROR_HEADER   Error;\r
+} EFI_MTFTP4_PACKET;\r
+\r
+#pragma pack()\r
+\r
+//\r
+//MTFTP4 option definition\r
+//\r
+typedef struct {\r
+  UINT8                   *OptionStr;\r
+  UINT8                   *ValueStr;\r
+} EFI_MTFTP4_OPTION;\r
+\r
+//\r
+//MTFTP4 config data\r
+//\r
+typedef struct {\r
+  BOOLEAN                 UseDefaultSetting;\r
+  EFI_IPv4_ADDRESS        StationIp;\r
+  EFI_IPv4_ADDRESS        SubnetMask;\r
+  UINT16                  LocalPort;\r
+  EFI_IPv4_ADDRESS        GatewayIp;\r
+  EFI_IPv4_ADDRESS        ServerIp;\r
+  UINT16                  InitialServerPort;\r
+  UINT16                  TryCount;\r
+  UINT16                  TimeoutValue;\r
+} EFI_MTFTP4_CONFIG_DATA;\r
+\r
+//\r
+//MTFTP4 Mode data\r
+//\r
+typedef struct {\r
+  EFI_MTFTP4_CONFIG_DATA  ConfigData;\r
+  UINT8                   SupportedOptionCount;  \r
+  UINT8                   **SupportedOptoins;\r
+  UINT8                   UnsupportedOptionCount;  \r
+  UINT8                   **UnsupportedOptoins;\r
+} EFI_MTFTP4_MODE_DATA;\r
+\r
+\r
+//\r
+//MTFTP4 override data\r
+//\r
+typedef struct {\r
+  EFI_IPv4_ADDRESS        GatewayIp;\r
+  EFI_IPv4_ADDRESS        ServerIp;\r
+  UINT16                  ServerPort;\r
+  UINT16                  TryCount;\r
+  UINT16                  TimeoutValue;\r
+} EFI_MTFTP4_OVERRIDE_DATA;\r
+\r
+\r
+//\r
+//Packet checking function\r
+//\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_CHECK_PACKET)( \r
+  IN EFI_MTFTP4_PROTOCOL  *This,\r
+  IN EFI_MTFTP4_TOKEN     *Token,\r
+  IN UINT16               PacketLen,\r
+  IN EFI_MTFTP4_PACKET    *Paket\r
+  );\r
+\r
+//\r
+//Timeout callback funtion\r
+//\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_TIMEOUT_CALLBACK) ( \r
+  IN EFI_MTFTP4_PROTOCOL  *This,\r
+  IN EFI_MTFTP4_TOKEN     *Token\r
+  );\r
+\r
+//\r
+//Packet needed function\r
+//\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_PACKET_NEEDED) ( \r
+  IN EFI_MTFTP4_PROTOCOL  *This,\r
+  IN EFI_MTFTP4_TOKEN     *Token,\r
+  IN OUT UINT16           *Length,\r
+  OUT VOID                **Buffer\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_GET_MODE_DATA) (\r
+  IN  EFI_MTFTP4_PROTOCOL     *This,\r
+  OUT EFI_MTFTP4_MODE_DATA    *ModeData\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_CONFIGURE) (\r
+  IN EFI_MTFTP4_PROTOCOL        *This,\r
+  IN EFI_MTFTP4_CONFIG_DATA      *MtftpConfigData OPTIONAL\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_GET_INFO) (\r
+  IN  EFI_MTFTP4_PROTOCOL       *This,\r
+  IN  EFI_MTFTP4_OVERRIDE_DATA  *OverrideData   OPTIONAL,\r
+  IN  UINT8                     *Filename,\r
+  IN  UINT8                     *ModeStr         OPTIONAL,\r
+  IN  UINT8                     OptionCount,\r
+  IN  EFI_MTFTP4_OPTION         *OptionList,\r
+  OUT UINT32                    *PacketLength,\r
+  OUT EFI_MTFTP4_PACKET         **Packet        OPTIONAL\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_PARSE_OPTIONS) (\r
+  IN  EFI_MTFTP4_PROTOCOL       *This,\r
+  IN  UINT32                    PacketLen,\r
+  IN  EFI_MTFTP4_PACKET         *Packet,\r
+  OUT UINT32                    *OptionCount,\r
+  OUT EFI_MTFTP4_OPTION         **OptionList OPTIONAL\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_READ_FILE) (\r
+  IN EFI_MTFTP4_PROTOCOL         *This,\r
+  IN EFI_MTFTP4_TOKEN            *Token\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_WRITE_FILE) (\r
+  IN EFI_MTFTP4_PROTOCOL         *This,\r
+  IN EFI_MTFTP4_TOKEN            *Token\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI *EFI_MTFTP4_READ_DIRECTORY) (\r
+  IN EFI_MTFTP4_PROTOCOL        *This,\r
+  IN EFI_MTFTP4_TOKEN           *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MTFTP4_POLL) (\r
+  IN EFI_MTFTP4_PROTOCOL        *This\r
+);\r
+\r
+\r
+typedef struct _EFI_MTFTP4_PROTOCOL {\r
+  EFI_MTFTP4_GET_MODE_DATA        GetModeData;\r
+  EFI_MTFTP4_CONFIGURE            Configure;\r
+  EFI_MTFTP4_GET_INFO             GetInfo;\r
+  EFI_MTFTP4_PARSE_OPTIONS        ParseOptions;\r
+  EFI_MTFTP4_READ_FILE            ReadFile;\r
+  EFI_MTFTP4_WRITE_FILE           WriteFile;\r
+  EFI_MTFTP4_READ_DIRECTORY       ReadDirectory;\r
+  EFI_MTFTP4_POLL                 Poll;\r
+} EFI_MTFTP4_PROTOCOL;\r
+\r
+//\r
+//MTFTP4 token data\r
+//\r
+typedef struct _EFI_MTFTP4_TOKEN{\r
+  IN OUT EFI_STATUS               Status;\r
+  IN EFI_EVENT                    Event;\r
+  IN EFI_MTFTP4_OVERRIDE_DATA     *OverrideData;\r
+  IN UINT8                        *Filename;\r
+  IN UINT8                        *ModeStr;\r
+  IN UINT32                       OptionCount;\r
+  IN EFI_MTFTP4_OPTION            *OptionList;\r
+  IN OUT UINT64                   BufferSize;\r
+  IN OUT VOID                     *Buffer;\r
+  IN VOID                         *Context;\r
+  IN EFI_MTFTP4_CHECK_PACKET      CheckPacket;\r
+  IN EFI_MTFTP4_TIMEOUT_CALLBACK  TimeoutCallback;\r
+  IN EFI_MTFTP4_PACKET_NEEDED     PacketNeeded;\r
+} EFI_MTFTP4_TOKEN;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c
new file mode 100644 (file)
index 0000000..873d77d
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PciIo.c\r
+    \r
+Abstract:\r
+\r
+    EFI PCI I/O Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PciIo)\r
+\r
+EFI_GUID  gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciIoProtocolGuid, "PCI IO Protocol", "EFI 1.1 PCI IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h
new file mode 100644 (file)
index 0000000..425dc5f
--- /dev/null
@@ -0,0 +1,275 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PciIo.h\r
+    \r
+Abstract:\r
+\r
+    EFI PCI I/O Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PCI_IO_H\r
+#define _EFI_PCI_IO_H\r
+\r
+//\r
+// Global ID for the PCI I/O Protocol\r
+//\r
+#define EFI_PCI_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PCI_IO_PROTOCOL);\r
+\r
+//\r
+// Prototypes for the PCI I/O Protocol\r
+//\r
+typedef enum {\r
+  EfiPciIoWidthUint8      = 0,\r
+  EfiPciIoWidthUint16,\r
+  EfiPciIoWidthUint32,\r
+  EfiPciIoWidthUint64,\r
+  EfiPciIoWidthFifoUint8,\r
+  EfiPciIoWidthFifoUint16,\r
+  EfiPciIoWidthFifoUint32,\r
+  EfiPciIoWidthFifoUint64,\r
+  EfiPciIoWidthFillUint8,\r
+  EfiPciIoWidthFillUint16,\r
+  EfiPciIoWidthFillUint32,\r
+  EfiPciIoWidthFillUint64,\r
+  EfiPciIoWidthMaximum\r
+} EFI_PCI_IO_PROTOCOL_WIDTH;\r
+\r
+//\r
+// Complete PCI address generater\r
+//\r
+#define EFI_PCI_IO_PASS_THROUGH_BAR               0xff    // Special BAR that passes a memory or I/O cycle through unchanged\r
+#define EFI_PCI_IO_ATTRIBUTE_MASK                 0x077f  // All the following I/O and Memory cycles\r
+#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO   0x0001  // I/O cycles 0x0000-0x00FF (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_ISA_IO               0x0002  // I/O cycles 0x0000-0x03FF (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO       0x0004  // I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY           0x0008  // MEM cycles 0xA0000-0xBFFFF (24 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_VGA_IO               0x0010  // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO       0x0020  // I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO     0x0040  // I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080  // Map a memory range so write are combined\r
+#define EFI_PCI_IO_ATTRIBUTE_IO                   0x0100  // Enable the I/O decode bit in the PCI Config Header\r
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY               0x0200  // Enable the Memory decode bit in the PCI Config Header\r
+#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER           0x0400  // Enable the DMA bit in the PCI Config Header\r
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED        0x0800  // Map a memory range so all r/w accesses are cached\r
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE       0x1000  // Disable a memory range\r
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE      0x2000  // Clear for an add-in PCI Device\r
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM         0x4000  // Clear for a physical PCI Option ROM accessed through ROM BAR\r
+#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE   0x8000  // Clear for PCI controllers that can not genrate a DAC\r
+//\r
+// The following definition is added in EFI1.1 spec update and UEFI2.0 spec.\r
+//\r
+#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16            0x10000 // I/O cycles 0x0100-0x03FF (16 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16    0x20000 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode)\r
+#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16            0x40000 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode)\r
+\r
+#define EFI_PCI_DEVICE_ENABLE                     (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER)\r
+#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)\r
+\r
+//\r
+// *******************************************************\r
+// EFI_PCI_IO_PROTOCOL_OPERATION\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  EfiPciIoOperationBusMasterRead,\r
+  EfiPciIoOperationBusMasterWrite,\r
+  EfiPciIoOperationBusMasterCommonBuffer,\r
+  EfiPciIoOperationMaximum\r
+} EFI_PCI_IO_PROTOCOL_OPERATION;\r
+\r
+//\r
+// *******************************************************\r
+// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  EfiPciIoAttributeOperationGet,\r
+  EfiPciIoAttributeOperationSet,\r
+  EfiPciIoAttributeOperationEnable,\r
+  EfiPciIoAttributeOperationDisable,\r
+  EfiPciIoAttributeOperationSupported,\r
+  EfiPciIoAttributeOperationMaximum\r
+} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) (\r
+  IN EFI_PCI_IO_PROTOCOL           * This,\r
+  IN  EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
+  IN  UINT8                        BarIndex,\r
+  IN  UINT64                       Offset,\r
+  IN  UINT64                       Mask,\r
+  IN  UINT64                       Value,\r
+  IN  UINT64                       Delay,\r
+  OUT UINT64                       *Result\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) (\r
+  IN EFI_PCI_IO_PROTOCOL              * This,\r
+  IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT8                        BarIndex,\r
+  IN     UINT64                       Offset,\r
+  IN     UINTN                        Count,\r
+  IN OUT VOID                         *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_PCI_IO_PROTOCOL_IO_MEM  Read;\r
+  EFI_PCI_IO_PROTOCOL_IO_MEM  Write;\r
+} EFI_PCI_IO_PROTOCOL_ACCESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) (\r
+  IN EFI_PCI_IO_PROTOCOL              * This,\r
+  IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT32                       Offset,\r
+  IN     UINTN                        Count,\r
+  IN OUT VOID                         *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_PCI_IO_PROTOCOL_CONFIG  Read;\r
+  EFI_PCI_IO_PROTOCOL_CONFIG  Write;\r
+} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) (\r
+  IN EFI_PCI_IO_PROTOCOL              * This,\r
+  IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT8                        DestBarIndex,\r
+  IN     UINT64                       DestOffset,\r
+  IN     UINT8                        SrcBarIndex,\r
+  IN     UINT64                       SrcOffset,\r
+  IN     UINTN                        Count\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) (\r
+  IN EFI_PCI_IO_PROTOCOL                * This,\r
+  IN     EFI_PCI_IO_PROTOCOL_OPERATION  Operation,\r
+  IN     VOID                           *HostAddress,\r
+  IN OUT UINTN                          *NumberOfBytes,\r
+  OUT    EFI_PHYSICAL_ADDRESS           * DeviceAddress,\r
+  OUT    VOID                           **Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) (\r
+  IN EFI_PCI_IO_PROTOCOL           * This,\r
+  IN  VOID                         *Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) (\r
+  IN EFI_PCI_IO_PROTOCOL           * This,\r
+  IN  EFI_ALLOCATE_TYPE            Type,\r
+  IN  EFI_MEMORY_TYPE              MemoryType,\r
+  IN  UINTN                        Pages,\r
+  OUT VOID                         **HostAddress,\r
+  IN  UINT64                       Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) (\r
+  IN EFI_PCI_IO_PROTOCOL           * This,\r
+  IN  UINTN                        Pages,\r
+  IN  VOID                         *HostAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) (\r
+  IN EFI_PCI_IO_PROTOCOL  * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) (\r
+  IN EFI_PCI_IO_PROTOCOL          * This,\r
+  OUT UINTN                       *SegmentNumber,\r
+  OUT UINTN                       *BusNumber,\r
+  OUT UINTN                       *DeviceNumber,\r
+  OUT UINTN                       *FunctionNumber\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) (\r
+  IN EFI_PCI_IO_PROTOCOL                       * This,\r
+  IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,\r
+  IN  UINT64                                   Attributes,\r
+  OUT UINT64                                   *Result OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) (\r
+  IN EFI_PCI_IO_PROTOCOL             * This,\r
+  IN  UINT8                          BarIndex,\r
+  OUT UINT64                         *Supports, OPTIONAL\r
+  OUT VOID                           **Resources OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) (\r
+  IN EFI_PCI_IO_PROTOCOL              * This,\r
+  IN     UINT64                       Attributes,\r
+  IN     UINT8                        BarIndex,\r
+  IN OUT UINT64                       *Offset,\r
+  IN OUT UINT64                       *Length\r
+  );\r
+\r
+//\r
+// Interface structure for the PCI I/O Protocol\r
+//\r
+typedef struct _EFI_PCI_IO_PROTOCOL {\r
+  EFI_PCI_IO_PROTOCOL_POLL_IO_MEM         PollMem;\r
+  EFI_PCI_IO_PROTOCOL_POLL_IO_MEM         PollIo;\r
+  EFI_PCI_IO_PROTOCOL_ACCESS              Mem;\r
+  EFI_PCI_IO_PROTOCOL_ACCESS              Io;\r
+  EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS       Pci;\r
+  EFI_PCI_IO_PROTOCOL_COPY_MEM            CopyMem;\r
+  EFI_PCI_IO_PROTOCOL_MAP                 Map;\r
+  EFI_PCI_IO_PROTOCOL_UNMAP               Unmap;\r
+  EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER     AllocateBuffer;\r
+  EFI_PCI_IO_PROTOCOL_FREE_BUFFER         FreeBuffer;\r
+  EFI_PCI_IO_PROTOCOL_FLUSH               Flush;\r
+  EFI_PCI_IO_PROTOCOL_GET_LOCATION        GetLocation;\r
+  EFI_PCI_IO_PROTOCOL_ATTRIBUTES          Attributes;\r
+  EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES  GetBarAttributes;\r
+  EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES  SetBarAttributes;\r
+  UINT64                                  RomSize;\r
+  VOID                                    *RomImage;\r
+} EFI_PCI_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPciIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c
new file mode 100644 (file)
index 0000000..7faecbb
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciRootBridgeIo.c\r
+\r
+Abstract:\r
+\r
+  PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification.\r
+\r
+  PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O, \r
+  and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform \r
+  defferent types of bus mastering DMA\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)\r
+\r
+EFI_GUID  gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciRootBridgeIoProtocolGuid, "PciRootBridgeIo Protocol", "EFI 1.1 Pci Root Bridge IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h
new file mode 100644 (file)
index 0000000..7773c9a
--- /dev/null
@@ -0,0 +1,220 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciRootBridgeIo.h\r
+\r
+Abstract:\r
+\r
+  PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification.\r
+\r
+  PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O, \r
+  and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform \r
+  defferent types of bus mastering DMA\r
+\r
+--*/\r
+\r
+#ifndef _PCI_ROOT_BRIDGE_IO_H_\r
+#define _PCI_ROOT_BRIDGE_IO_H_\r
+\r
+#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x2f707ebb, 0x4a1a, 0x11d4, 0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiPciWidthUint8,\r
+  EfiPciWidthUint16,\r
+  EfiPciWidthUint32,\r
+  EfiPciWidthUint64,\r
+  EfiPciWidthFifoUint8,\r
+  EfiPciWidthFifoUint16,\r
+  EfiPciWidthFifoUint32,\r
+  EfiPciWidthFifoUint64,\r
+  EfiPciWidthFillUint8,\r
+  EfiPciWidthFillUint16,\r
+  EfiPciWidthFillUint32,\r
+  EfiPciWidthFillUint64,\r
+  EfiPciWidthMaximum\r
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;\r
+\r
+typedef enum {\r
+  EfiPciOperationBusMasterRead,\r
+  EfiPciOperationBusMasterWrite,\r
+  EfiPciOperationBusMasterCommonBuffer,\r
+  EfiPciOperationBusMasterRead64,\r
+  EfiPciOperationBusMasterWrite64,\r
+  EfiPciOperationBusMasterCommonBuffer64,\r
+  EfiPciOperationMaximum\r
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;\r
+\r
+#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO          0x0001\r
+#define EFI_PCI_ATTRIBUTE_ISA_IO                      0x0002\r
+#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO              0x0004\r
+#define EFI_PCI_ATTRIBUTE_VGA_MEMORY                  0x0008\r
+#define EFI_PCI_ATTRIBUTE_VGA_IO                      0x0010\r
+#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO              0x0020\r
+#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO            0x0040\r
+#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE        0x0080\r
+#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED               0x0800\r
+#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE              0x1000\r
+#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE          0x8000\r
+//\r
+// The following definition is added in EFI1.1 spec update and UEFI2.0 spec.\r
+//\r
+#define EFI_PCI_ATTRIBUTE_ISA_IO_16                   0x10000\r
+#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16           0x20000\r
+#define EFI_PCI_ATTRIBUTE_VGA_IO_16                   0x40000\r
+\r
+#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)\r
+\r
+#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)\r
+\r
+#define EFI_PCI_ADDRESS(bus, dev, func, reg) \\r
+    ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))\r
+\r
+typedef struct {\r
+  UINT8   Register;\r
+  UINT8   Function;\r
+  UINT8   Device;\r
+  UINT8   Bus;\r
+  UINT32  ExtendedRegister;\r
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           * This,\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,\r
+  IN  UINT64                                   Address,\r
+  IN  UINT64                                   Mask,\r
+  IN  UINT64                                   Value,\r
+  IN  UINT64                                   Delay,\r
+  OUT UINT64                                   *Result\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT64                                   Address,\r
+  IN     UINTN                                    Count,\r
+  IN OUT VOID                                     *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM  Read;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM  Write;\r
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT64                                   DestAddress,\r
+  IN     UINT64                                   SrcAddress,\r
+  IN     UINTN                                    Count\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL                * This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation,\r
+  IN     VOID                                       *HostAddress,\r
+  IN OUT UINTN                                      *NumberOfBytes,\r
+  OUT    EFI_PHYSICAL_ADDRESS                       * DeviceAddress,\r
+  OUT    VOID                                       **Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           * This,\r
+  IN  VOID                                     *Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
+  IN     EFI_ALLOCATE_TYPE                        Type,\r
+  IN     EFI_MEMORY_TYPE                          MemoryType,\r
+  IN     UINTN                                    Pages,\r
+  IN OUT VOID                                     **HostAddress,\r
+  IN     UINT64                                   Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           * This,\r
+  IN  UINTN                                    Pages,\r
+  IN  VOID                                     *HostAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           * This,\r
+  OUT UINT64                                   *Supports,\r
+  OUT UINT64                                   *Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
+  IN     UINT64                                   Attributes,\r
+  IN OUT UINT64                                   *ResourceBase,\r
+  IN OUT UINT64                                   *ResourceLength\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL          * This,\r
+  OUT VOID                                     **Resources\r
+  );\r
+\r
+typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {\r
+  EFI_HANDLE                                      ParentHandle;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM     PollMem;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM     PollIo;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Mem;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Io;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS          Pci;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM        CopyMem;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP             Map;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP           Unmap;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER     FreeBuffer;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH           Flush;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES  GetAttributes;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES  SetAttributes;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION   Configuration;\r
+  UINT32                                          SegmentNumber;\r
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c
new file mode 100644 (file)
index 0000000..6fc13d8
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformDriverOverride.c\r
+\r
+Abstract:\r
+\r
+  Platform Driver Override protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)\r
+\r
+EFI_GUID  gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiPlatformDriverOverrideProtocolGuid, "Platform Driver Override Protocol",\r
+      "EFI 1.1 Platform Driver Override Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h
new file mode 100644 (file)
index 0000000..6d19d14
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformDriverOverride.h\r
+\r
+Abstract:\r
+\r
+  Platform Driver Override protocol as defined in the EFI 1.1 specification.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_\r
+#define _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_\r
+\r
+//\r
+// Global ID for the Platform Driver Override Protocol\r
+//\r
+#define EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID \\r
+  { \\r
+    0x6b30c738, 0xa391, 0x11d4, 0x9a, 0x3b, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL);\r
+\r
+//\r
+// Prototypes for the Platform Driver Override Protocol\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER) (\r
+  IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL              * This,\r
+  IN     EFI_HANDLE                                     ControllerHandle,\r
+  IN OUT EFI_HANDLE                                     * DriverImageHandle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH) (\r
+  IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL              * This,\r
+  IN     EFI_HANDLE                                     ControllerHandle,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL                       **DriverImagePath\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED) (\r
+  IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL          * This,\r
+  IN EFI_HANDLE                                     ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL                       * DriverImagePath,\r
+  IN EFI_HANDLE                                     DriverImageHandle\r
+  );\r
+\r
+//\r
+// Interface structure for the Platform Driver Override Protocol\r
+//\r
+typedef struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL {\r
+  EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER       GetDriver;\r
+  EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH  GetDriverPath;\r
+  EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED    DriverLoaded;\r
+} EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c
new file mode 100644 (file)
index 0000000..ea74514
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeBaseCode.c\r
+\r
+Abstract:\r
+  PxeBaseCode GUID declaration.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCode)\r
+\r
+EFI_GUID  gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPxeBaseCodeProtocolGuid, "PXE Base Code Protocol", "EFI PXE Base Code Protocol");\r
+\r
+/* EOF - PxeBaseCode.c */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h
new file mode 100644 (file)
index 0000000..7fc959d
--- /dev/null
@@ -0,0 +1,386 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeBaseCode.h\r
+\r
+Abstract:\r
+  EFI PXE Base Code Protocol definitions.\r
+\r
+--*/\r
+#ifndef _EFIPXEBC_H\r
+#define _EFIPXEBC_H\r
+\r
+#include "Pxe.h"\r
+\r
+//\r
+// PXE Base Code protocol\r
+//\r
+#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \\r
+  { \\r
+    0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_PROTOCOL);\r
+\r
+//\r
+// Default IP TTL and ToS.\r
+//\r
+#define DEFAULT_TTL 16\r
+#define DEFAULT_ToS 0\r
+\r
+//\r
+// ICMP error format\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Code;\r
+  UINT16  Checksum;\r
+  union {\r
+    UINT32  reserved;\r
+    UINT32  Mtu;\r
+    UINT32  Pointer;\r
+    struct {\r
+      UINT16  Identifier;\r
+      UINT16  Sequence;\r
+    } Echo;\r
+  } u;\r
+  UINT8 Data[494];\r
+} EFI_PXE_BASE_CODE_ICMP_ERROR;\r
+\r
+//\r
+// TFTP error format\r
+//\r
+typedef struct {\r
+  UINT8 ErrorCode;\r
+  CHAR8 ErrorString[127];\r
+} EFI_PXE_BASE_CODE_TFTP_ERROR;\r
+\r
+//\r
+// IP Receive Filter definitions\r
+//\r
+#define EFI_PXE_BASE_CODE_MAX_IPCNT 8\r
+\r
+typedef struct {\r
+  UINT8           Filters;\r
+  UINT8           IpCnt;\r
+  UINT16          reserved;\r
+  EFI_IP_ADDRESS  IpList[EFI_PXE_BASE_CODE_MAX_IPCNT];\r
+} EFI_PXE_BASE_CODE_IP_FILTER;\r
+\r
+#define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP            0x0001\r
+#define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST             0x0002\r
+#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS           0x0004\r
+#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008\r
+\r
+//\r
+// ARP Cache definitions\r
+//\r
+typedef struct {\r
+  EFI_IP_ADDRESS  IpAddr;\r
+  EFI_MAC_ADDRESS MacAddr;\r
+} EFI_PXE_BASE_CODE_ARP_ENTRY;\r
+\r
+typedef struct {\r
+  EFI_IP_ADDRESS  IpAddr;\r
+  EFI_IP_ADDRESS  SubnetMask;\r
+  EFI_IP_ADDRESS  GwAddr;\r
+} EFI_PXE_BASE_CODE_ROUTE_ENTRY;\r
+\r
+//\r
+// UDP definitions\r
+//\r
+typedef UINT16  EFI_PXE_BASE_CODE_UDP_PORT;\r
+\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP    0x0001\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT  0x0002\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP   0x0004\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER    0x0010\r
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT  0x0020\r
+\r
+//\r
+// Discover() definitions\r
+//\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP         0\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS      1\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM         2\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI           3\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO        4\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD          5\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM          6\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG  7\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW       8\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9         9\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10        10\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11        11\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12       12\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL    13\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT       14\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO             15\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT           16\r
+//\r
+// 17 through 32767 are reserved\r
+// 32768 through 65279 are for vendor use\r
+// 65280 through 65534 are reserved\r
+//\r
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST   65535\r
+\r
+#define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK     0x7FFF\r
+#define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL  0x0000\r
+\r
+//\r
+// Discover() server list structure.\r
+//\r
+typedef struct {\r
+  UINT16          Type;\r
+  BOOLEAN         AcceptAnyResponse;\r
+  UINT8           Reserved;\r
+  EFI_IP_ADDRESS  IpAddr;\r
+} EFI_PXE_BASE_CODE_SRVLIST;\r
+\r
+//\r
+// Discover() information override structure.\r
+//\r
+typedef struct {\r
+  BOOLEAN                   UseMCast;\r
+  BOOLEAN                   UseBCast;\r
+  BOOLEAN                   UseUCast;\r
+  BOOLEAN                   MustUseList;\r
+  EFI_IP_ADDRESS            ServerMCastIp;\r
+  UINT16                    IpCnt;\r
+  EFI_PXE_BASE_CODE_SRVLIST SrvList[1];\r
+} EFI_PXE_BASE_CODE_DISCOVER_INFO;\r
+\r
+//\r
+// Mtftp() definitions\r
+//\r
+typedef enum {\r
+  EFI_PXE_BASE_CODE_TFTP_FIRST,\r
+  EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,\r
+  EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r
+  EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,\r
+  EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY,\r
+  EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE,\r
+  EFI_PXE_BASE_CODE_MTFTP_READ_FILE,\r
+  EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY,\r
+  EFI_PXE_BASE_CODE_MTFTP_LAST\r
+} EFI_PXE_BASE_CODE_TFTP_OPCODE;\r
+\r
+typedef struct {\r
+  EFI_IP_ADDRESS              MCastIp;\r
+  EFI_PXE_BASE_CODE_UDP_PORT  CPort;\r
+  EFI_PXE_BASE_CODE_UDP_PORT  SPort;\r
+  UINT16                      ListenTimeout;\r
+  UINT16                      TransmitTimeout;\r
+} EFI_PXE_BASE_CODE_MTFTP_INFO;\r
+\r
+//\r
+// PXE Base Code Mode structure\r
+//\r
+#define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES   8\r
+#define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8\r
+\r
+typedef struct {\r
+  BOOLEAN                       Started;\r
+  BOOLEAN                       Ipv6Available;\r
+  BOOLEAN                       Ipv6Supported;\r
+  BOOLEAN                       UsingIpv6;\r
+  BOOLEAN                       BisSupported;\r
+  BOOLEAN                       BisDetected;\r
+  BOOLEAN                       AutoArp;\r
+  BOOLEAN                       SendGUID;\r
+  BOOLEAN                       DhcpDiscoverValid;\r
+  BOOLEAN                       DhcpAckReceived;\r
+  BOOLEAN                       ProxyOfferReceived;\r
+  BOOLEAN                       PxeDiscoverValid;\r
+  BOOLEAN                       PxeReplyReceived;\r
+  BOOLEAN                       PxeBisReplyReceived;\r
+  BOOLEAN                       IcmpErrorReceived;\r
+  BOOLEAN                       TftpErrorReceived;\r
+  BOOLEAN                       MakeCallbacks;\r
+  UINT8                         TTL;\r
+  UINT8                         ToS;\r
+  EFI_IP_ADDRESS                StationIp;\r
+  EFI_IP_ADDRESS                SubnetMask;\r
+  EFI_PXE_BASE_CODE_PACKET      DhcpDiscover;\r
+  EFI_PXE_BASE_CODE_PACKET      DhcpAck;\r
+  EFI_PXE_BASE_CODE_PACKET      ProxyOffer;\r
+  EFI_PXE_BASE_CODE_PACKET      PxeDiscover;\r
+  EFI_PXE_BASE_CODE_PACKET      PxeReply;\r
+  EFI_PXE_BASE_CODE_PACKET      PxeBisReply;\r
+  EFI_PXE_BASE_CODE_IP_FILTER   IpFilter;\r
+  UINT32                        ArpCacheEntries;\r
+  EFI_PXE_BASE_CODE_ARP_ENTRY   ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];\r
+  UINT32                        RouteTableEntries;\r
+  EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];\r
+  EFI_PXE_BASE_CODE_ICMP_ERROR  IcmpError;\r
+  EFI_PXE_BASE_CODE_TFTP_ERROR  TftpError;\r
+} EFI_PXE_BASE_CODE_MODE;\r
+\r
+//\r
+// PXE Base Code Interface Function definitions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_START) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN BOOLEAN                               UseIpv6\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_STOP) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL    * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_DHCP) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN BOOLEAN                               SortOffers\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL           * This,\r
+  IN UINT16                               Type,\r
+  IN UINT16                               *Layer,\r
+  IN BOOLEAN                              UseBis,\r
+  IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO  * Info OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_MTFTP) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL                * This,\r
+  IN EFI_PXE_BASE_CODE_TFTP_OPCODE             Operation,\r
+  IN OUT VOID                                  *BufferPtr OPTIONAL,\r
+  IN BOOLEAN                                   Overwrite,\r
+  IN OUT UINT64                                *BufferSize,\r
+  IN UINTN                                     *BlockSize OPTIONAL,\r
+  IN EFI_IP_ADDRESS                            * ServerIp,\r
+  IN UINT8                                     *Filename,\r
+  IN EFI_PXE_BASE_CODE_MTFTP_INFO              * Info OPTIONAL,\r
+  IN BOOLEAN                                   DontUseBuffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL                * This,\r
+  IN UINT16                                    OpFlags,\r
+  IN EFI_IP_ADDRESS                            * DestIp,\r
+  IN EFI_PXE_BASE_CODE_UDP_PORT                * DestPort,\r
+  IN EFI_IP_ADDRESS                            * GatewayIp, OPTIONAL\r
+  IN EFI_IP_ADDRESS                            * SrcIp, OPTIONAL\r
+  IN OUT EFI_PXE_BASE_CODE_UDP_PORT            * SrcPort, OPTIONAL\r
+  IN UINTN                                     *HeaderSize, OPTIONAL\r
+  IN VOID                                      *HeaderPtr, OPTIONAL\r
+  IN UINTN                                     *BufferSize,\r
+  IN VOID                                      *BufferPtr\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL                * This,\r
+  IN UINT16                                    OpFlags,\r
+  IN OUT EFI_IP_ADDRESS                        * DestIp, OPTIONAL\r
+  IN OUT EFI_PXE_BASE_CODE_UDP_PORT            * DestPort, OPTIONAL\r
+  IN OUT EFI_IP_ADDRESS                        * SrcIp, OPTIONAL\r
+  IN OUT EFI_PXE_BASE_CODE_UDP_PORT            * SrcPort, OPTIONAL\r
+  IN UINTN                                     *HeaderSize, OPTIONAL\r
+  IN VOID                                      *HeaderPtr, OPTIONAL\r
+  IN OUT UINTN                                 *BufferSize,\r
+  IN VOID                                      *BufferPtr\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN EFI_PXE_BASE_CODE_IP_FILTER           * NewFilter\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_ARP) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN EFI_IP_ADDRESS                        * IpAddr,\r
+  IN EFI_MAC_ADDRESS                       * MacAddr OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN BOOLEAN                               *NewAutoArp, OPTIONAL\r
+  IN BOOLEAN                               *NewSendGUID, OPTIONAL\r
+  IN UINT8                                 *NewTTL, OPTIONAL\r
+  IN UINT8                                 *NewToS, OPTIONAL\r
+  IN BOOLEAN                               *NewMakeCallback OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  IN EFI_IP_ADDRESS                        * NewStationIp, OPTIONAL\r
+  IN EFI_IP_ADDRESS                        * NewSubnetMask OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) (\r
+  IN EFI_PXE_BASE_CODE_PROTOCOL            * This,\r
+  BOOLEAN                                  *NewDhcpDiscoverValid, OPTIONAL\r
+  BOOLEAN                                  *NewDhcpAckReceived, OPTIONAL\r
+  BOOLEAN                                  *NewProxyOfferReceived, OPTIONAL\r
+  BOOLEAN                                  *NewPxeDiscoverValid, OPTIONAL\r
+  BOOLEAN                                  *NewPxeReplyReceived, OPTIONAL\r
+  BOOLEAN                                  *NewPxeBisReplyReceived, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewDhcpDiscover, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewDhcpAck, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewProxyOffer, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewPxeDiscover, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewPxeReply, OPTIONAL\r
+  IN EFI_PXE_BASE_CODE_PACKET              * NewPxeBisReply OPTIONAL\r
+  );\r
+\r
+//\r
+// PXE Base Code Protocol structure\r
+//\r
+#define EFI_PXE_BASE_CODE_INTERFACE_REVISION  0x00010000\r
+\r
+typedef struct _EFI_PXE_BASE_CODE_PROTOCOL {\r
+  UINT64                            Revision;\r
+  EFI_PXE_BASE_CODE_START           Start;\r
+  EFI_PXE_BASE_CODE_STOP            Stop;\r
+  EFI_PXE_BASE_CODE_DHCP            Dhcp;\r
+  EFI_PXE_BASE_CODE_DISCOVER        Discover;\r
+  EFI_PXE_BASE_CODE_MTFTP           Mtftp;\r
+  EFI_PXE_BASE_CODE_UDP_WRITE       UdpWrite;\r
+  EFI_PXE_BASE_CODE_UDP_READ        UdpRead;\r
+  EFI_PXE_BASE_CODE_SET_IP_FILTER   SetIpFilter;\r
+  EFI_PXE_BASE_CODE_ARP             Arp;\r
+  EFI_PXE_BASE_CODE_SET_PARAMETERS  SetParameters;\r
+  EFI_PXE_BASE_CODE_SET_STATION_IP  SetStationIp;\r
+  EFI_PXE_BASE_CODE_SET_PACKETS     SetPackets;\r
+  EFI_PXE_BASE_CODE_MODE            *Mode;\r
+} EFI_PXE_BASE_CODE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPxeBaseCodeProtocolGuid;\r
+\r
+#endif /* _EFIPXEBC_H */\r
+\r
+/* EOF - PxeBaseCode.h */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c
new file mode 100644 (file)
index 0000000..dcb7e26
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeBaseCodeCallBack.c\r
+\r
+Abstract:\r
+  PXE BaseCode Callback GUID declaration.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)\r
+\r
+EFI_GUID  gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiPxeBaseCodeCallbackProtocolGuid, "PXE Base Code Callback Protocol", "EFI PXE Base Code Callback Protocol");\r
+\r
+/* EOF - PxeBaseCodeCallBack.c */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h
new file mode 100644 (file)
index 0000000..bc93058
--- /dev/null
@@ -0,0 +1,82 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeBaseCodeCallBack.h\r
+\r
+Abstract:\r
+  EFI PXE Base Code CallBack Protocol\r
+\r
+--*/\r
+\r
+#ifndef _PXE_BASE_CODE_CALLBACK_H_\r
+#define _PXE_BASE_CODE_CALLBACK_H_\r
+\r
+#include "Pxe.h"\r
+\r
+//\r
+// Call Back Definitions\r
+//\r
+#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \\r
+  { \\r
+    0x245dca21, 0xfb7b, 0x11d3, 0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+//\r
+// Revision Number\r
+//\r
+#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION 0x00010000\r
+\r
+//\r
+// Protocol definition\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL);\r
+\r
+typedef enum {\r
+  EFI_PXE_BASE_CODE_FUNCTION_FIRST,\r
+  EFI_PXE_BASE_CODE_FUNCTION_DHCP,\r
+  EFI_PXE_BASE_CODE_FUNCTION_DISCOVER,\r
+  EFI_PXE_BASE_CODE_FUNCTION_MTFTP,\r
+  EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE,\r
+  EFI_PXE_BASE_CODE_FUNCTION_UDP_READ,\r
+  EFI_PXE_BASE_CODE_FUNCTION_ARP,\r
+  EFI_PXE_BASE_CODE_FUNCTION_IGMP,\r
+  EFI_PXE_BASE_CODE_FUNCTION_TCP_WRITE,\r
+  EFI_PXE_BASE_CODE_FUNCTION_TCP_READ,\r
+  EFI_PXE_BASE_CODE_PXE_FUNCTION_LAST\r
+} EFI_PXE_BASE_CODE_FUNCTION;\r
+\r
+typedef enum {\r
+  EFI_PXE_BASE_CODE_CALLBACK_STATUS_FIRST,\r
+  EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,\r
+  EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT,\r
+  EFI_PXE_BASE_CODE_CALLBACK_STATUS_LAST\r
+} EFI_PXE_BASE_CODE_CALLBACK_STATUS;\r
+\r
+typedef EFI_PXE_BASE_CODE_CALLBACK_STATUS (EFIAPI *EFI_PXE_CALLBACK)\r
+  (\r
+    IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL * This,\r
+    IN EFI_PXE_BASE_CODE_FUNCTION Function,\r
+    IN BOOLEAN Received,\r
+    IN UINT32 PacketLen,\r
+    IN EFI_PXE_BASE_CODE_PACKET * Packet OPTIONAL\r
+  );\r
+\r
+typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL {\r
+  UINT64            Revision;\r
+  EFI_PXE_CALLBACK  Callback;\r
+} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid;\r
+\r
+#endif /* _EFIPXEBC_H */\r
+\r
+/* EOF - PxeBaseCodeCallBack.h */\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c
new file mode 100644 (file)
index 0000000..c691a01
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ScsiIo.c\r
+    \r
+Abstract: \r
+  EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ScsiIo)\r
+\r
+EFI_GUID gEfiScsiIoProtocolGuid = EFI_SCSI_IO_PROTOCOL_GUID;\r
+EFI_GUID_STRING(&gEfiScsiIoProtocolGuid, "SCSI IO protoco", "UEFI 2.0 SCSI IO protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h
new file mode 100644 (file)
index 0000000..94aa06a
--- /dev/null
@@ -0,0 +1,256 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ScsiIo.h\r
+    \r
+Abstract: \r
+  EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef __EFI_SCSI_IO_PROTOCOL_H__\r
+#define __EFI_SCSI_IO_PROTOCOL_H__\r
+\r
+#define EFI_SCSI_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;\r
+\r
+//\r
+// SCSI Data Direction definition\r
+//\r
+#define EFI_SCSI_IO_DATA_DIRECTION_READ                        0\r
+#define EFI_SCSI_IO_DATA_DIRECTION_WRITE                       1\r
+#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL               2\r
+\r
+//\r
+// SCSI Host Adapter Status definition\r
+//\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK                     0x00\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND        0x09    // timeout when processing the command\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT                0x0b    // timeout when waiting for the command processing\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT         0x0d    // a message reject was received when processing command\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET              0x0e    // a bus reset was detected\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR           0x0f\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED   0x10    // the adapter failed in issuing request sense command\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT      0x11    // selection timeout\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN  0x12    // data overrun or data underrun\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE               0x13    // Unexepected bus free\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR            0x14    // Target bus phase sequence failure\r
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER                  0x7f\r
+\r
+\r
+//\r
+// SCSI Target Status definition\r
+//\r
+#define EFI_SCSI_IO_STATUS_TARGET_GOOD                         0x00\r
+#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION              0x02    // check condition\r
+#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET                0x04    // condition met\r
+#define EFI_SCSI_IO_STATUS_TARGET_BUSY                         0x08    // busy\r
+#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE                 0x10    // intermediate\r
+#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET   0x14    // intermediate-condition met\r
+#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT         0x18    // reservation conflict\r
+#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED           0x22    // command terminated\r
+#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL                   0x28    // queue full\r
+\r
+typedef struct {\r
+  UINT64                              Timeout;\r
+  VOID                                *InDataBuffer;\r
+  VOID                                *OutDataBuffer;\r
+  VOID                                *SenseData;\r
+  VOID                                *Cdb;\r
+  UINT32                              InTransferLength;\r
+  UINT32                              OutTransferLength;\r
+  UINT8                               CdbLength;\r
+  UINT8                               DataDirection;\r
+  UINT8                               HostAdapterStatus;\r
+  UINT8                               TargetStatus;\r
+  UINT8                               SenseDataLength;\r
+} EFI_SCSI_IO_SCSI_REQUEST_PACKET;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE) (\r
+  IN  EFI_SCSI_IO_PROTOCOL            *This,\r
+  OUT UINT8                           *DeviceType\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the device type information of the SCSI Controller.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    DeviceType - A pointer to the device type information\r
+                 retrieved from the SCSI Controller.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Retrieves the device type information successfully.\r
+    EFI_INVALID_PARAMETER - The DeviceType is NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION) (\r
+  IN EFI_SCSI_IO_PROTOCOL           *This,\r
+  IN OUT UINT8                      **Target,\r
+  OUT UINT64                        *Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the device location in the SCSI channel.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Target  - A pointer to the Target Array which represents ID of a SCSI device\r
+              on the SCSI channel.\r
+    Lun     - A pointer to the LUN of the SCSI device on\r
+              the SCSI channel.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Retrieves the device location successfully.\r
+    EFI_INVALID_PARAMETER - The Target or Lun is NULL.\r
+   \r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS) (\r
+  IN EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the SCSI Bus that the SCSI Controller is attached to.\r
+\r
+  Arguments:\r
+    This  - This Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The SCSI bus is reset successfully.\r
+    EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.\r
+    EFI_UNSUPPORTED  - The bus reset operation is not supported by the\r
+                       SCSI Host Controller.\r
+    EFI_TIMEOUT      - A timeout occurred while attempting to reset\r
+                       the SCSI bus.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE) (\r
+  IN EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the SCSI Controller that the device handle specifies.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - Reset the SCSI controller successfully.\r
+    EFI_DEVICE_ERROR  - Errors are encountered when resetting the\r
+                        SCSI Controller.\r
+    EFI_UNSUPPORTED   - The SCSI bus does not support a device\r
+                        reset operation.\r
+    EFI_TIMEOUT       - A timeout occurred while attempting to\r
+                        reset the SCSI Controller.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND) (\r
+  IN EFI_SCSI_IO_PROTOCOL                   *This,\r
+  IN OUT  EFI_SCSI_IO_SCSI_REQUEST_PACKET   *Packet,\r
+  IN EFI_EVENT                              Event  OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sends a SCSI Request Packet to the SCSI Controller for execution.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Packet  - The SCSI request packet to send to the SCSI\r
+              Controller specified by the device handle.\r
+    Event   - If the SCSI bus where the SCSI device is attached\r
+              does not support non-blocking I/O, then Event is\r
+              ignored, and blocking I/O is performed.\r
+              If Event is NULL, then blocking I/O is performed.\r
+              If Event is not NULL and non-blocking I/O is\r
+              supported, then non-blocking I/O is performed,\r
+              and Event will be signaled when the SCSI Request\r
+              Packet completes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS                - The SCSI Request Packet was sent by the host\r
+                                 successfully, and TransferLength bytes were\r
+                                 transferred to/from DataBuffer.See\r
+                                 HostAdapterStatus, TargetStatus,\r
+                                 SenseDataLength, and SenseData in that order\r
+                                 for additional status information.\r
+    EFI_BAD_BUFFER_SIZE        - The SCSI Request Packet was executed,\r
+                                 but the entire DataBuffer could not be transferred.\r
+                                 The actual number of bytes transferred is returned\r
+                                 in TransferLength. See HostAdapterStatus,\r
+                                 TargetStatus, SenseDataLength, and SenseData in\r
+                                 that order for additional status information.\r
+    EFI_NOT_READY              - The SCSI Request Packet could not be sent because\r
+                                 there are too many SCSI Command Packets already\r
+                                 queued.The caller may retry again later.\r
+    EFI_DEVICE_ERROR           - A device error occurred while attempting to send\r
+                                 the SCSI Request Packet. See HostAdapterStatus,\r
+                                 TargetStatus, SenseDataLength, and SenseData in\r
+                                 that order for additional status information.\r
+    EFI_INVALID_PARAMETER      - The contents of CommandPacket are invalid.\r
+                                 The SCSI Request Packet was not sent, so no\r
+                                 additional status information is available.\r
+    EFI_UNSUPPORTED            - The command described by the SCSI Request Packet\r
+                                 is not supported by the SCSI initiator(i.e., SCSI\r
+                                 Host Controller). The SCSI Request Packet was not\r
+                                 sent, so no additional status information is\r
+                                 available.\r
+    EFI_TIMEOUT                - A timeout occurred while waiting for the SCSI\r
+                                 Request Packet to execute. See HostAdapterStatus,\r
+                                 TargetStatus, SenseDataLength, and SenseData in\r
+                                 that order for additional status information.\r
+--*/\r
+;\r
+\r
+struct _EFI_SCSI_IO_PROTOCOL {\r
+  EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE      GetDeviceType;\r
+  EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION  GetDeviceLocation;\r
+  EFI_SCSI_IO_PROTOCOL_RESET_BUS            ResetBus;\r
+  EFI_SCSI_IO_PROTOCOL_RESET_DEVICE         ResetDevice;\r
+  EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND    ExecuteScsiCommand;    \r
+  UINT32                                    IoAlign;\r
+};\r
+\r
+extern EFI_GUID gEfiScsiIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c
new file mode 100644 (file)
index 0000000..f193015
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ScsiPassThru.c\r
+\r
+Abstract:\r
+\r
+  SCSI Pass Through protocol.\r
+   \r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThru)\r
+\r
+EFI_GUID  gEfiScsiPassThruProtocolGuid = EFI_SCSI_PASS_THRU_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiScsiPassThruProtocolGuid, "SCSI Pass Through Protocol", "EFI 1.0 SCSI Pass Through protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h
new file mode 100644 (file)
index 0000000..88887ae
--- /dev/null
@@ -0,0 +1,332 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ScsiPassThru.h\r
+\r
+Abstract:\r
+\r
+  SCSI Pass Through protocol.\r
+\r
+--*/\r
+\r
+#ifndef __SCSI_PT_H__\r
+#define __SCSI_PT_H__\r
+\r
+#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \\r
+  { \\r
+    0xa59e8fcf, 0xbda0, 0x43bb, 0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_SCSI_PASS_THRU_PROTOCOL);\r
+\r
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL    0x0001\r
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL     0x0002\r
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO  0x0004\r
+\r
+//\r
+// SCSI Host Adapter Status definition\r
+//\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_OK                     0x00\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND        0x09  // timeout when processing the command\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT                0x0b  // timeout when waiting for the command processing\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT         0x0d  // a message reject was received when processing command\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_RESET              0x0e  // a bus reset was detected\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR           0x0f\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED   0x10  // the adapter failed in issuing request sense command\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT      0x11  // selection timeout\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN  0x12  // data overrun or data underrun\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_FREE               0x13  // Unexepected bus free\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR            0x14  // Target bus phase sequence failure\r
+#define EFI_SCSI_STATUS_HOST_ADAPTER_OTHER                  0x7f\r
+\r
+//\r
+// SCSI Target Status definition\r
+//\r
+#define EFI_SCSI_STATUS_TARGET_GOOD                       0x00\r
+#define EFI_SCSI_STATUS_TARGET_CHECK_CONDITION            0x02  // check condition\r
+#define EFI_SCSI_STATUS_TARGET_CONDITION_MET              0x04  // condition met\r
+#define EFI_SCSI_STATUS_TARGET_BUSY                       0x08  // busy\r
+#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE               0x10  // intermediate\r
+#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14  // intermediate-condition met\r
+#define EFI_SCSI_STATUS_TARGET_RESERVATION_CONFLICT       0x18  // reservation conflict\r
+#define EFI_SCSI_STATUS_TARGET_COMMOND_TERMINATED         0x22  // command terminated\r
+#define EFI_SCSI_STATUS_TARGET_QUEUE_FULL                 0x28  // queue full\r
+typedef struct {\r
+  UINT64  Timeout;\r
+  VOID    *DataBuffer;\r
+  VOID    *SenseData;\r
+  VOID    *Cdb;\r
+  UINT32  TransferLength;\r
+  UINT8   CdbLength;\r
+  UINT8   DataDirection;\r
+  UINT8   HostAdapterStatus;\r
+  UINT8   TargetStatus;\r
+  UINT8   SenseDataLength;\r
+} EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;\r
+\r
+typedef struct {\r
+  CHAR16  *ControllerName;\r
+  CHAR16  *ChannelName;\r
+  UINT32  AdapterId;\r
+  UINT32  Attributes;\r
+  UINT32  IoAlign;\r
+} EFI_SCSI_PASS_THRU_MODE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_PASSTHRU) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL                          * This,\r
+  IN UINT32                                               Target,\r
+  IN UINT64                                               Lun,\r
+  IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET           * Packet,\r
+  IN EFI_EVENT                                            Event   OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sends a SCSI Request Packet to a SCSI device that is attached to \r
+    the SCSI channel. This function supports both blocking I/O and \r
+    non-blocking I/O.  The blocking I/O functionality is required, \r
+    and the non-blocking I/O functionality is optional.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Target                - The Target ID of the SCSI device to \r
+                            send the SCSI Request Packet.\r
+    Lun                   - The LUN of the SCSI device to send the \r
+                            SCSI Request Packet. \r
+    Packet                - A pointer to the SCSI Request Packet to send \r
+                            to the SCSI device specified by Target and Lun.\r
+    Event                 - If non-blocking I/O is not supported then Event \r
+                            is ignored, and blocking I/O is performed.  \r
+                            If Event is NULL, then blocking I/O is performed.\r
+                            If Event is not NULL and non blocking I/O is \r
+                            supported, then non-blocking I/O is performed, \r
+                            and Event will be signaled when the SCSI Request \r
+                            Packet completes\r
+\r
+  Returns:\r
+    EFI_SUCCESSThe        - SCSI Request Packet was sent by the host, and \r
+                            TransferLength bytes were transferred to/from \r
+                            DataBuffer.See HostAdapterStatus, TargetStatus,\r
+                            SenseDataLength,and SenseData in that order \r
+                            for additional status information.\r
+    EFI_BAD_BUFFER_SIZE   - The SCSI Request Packet was executed, but the \r
+                            entire DataBuffer could not be transferred.\r
+                            The actual number of bytes transferred is returned\r
+                            in TransferLength. See HostAdapterStatus, \r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+    EFI_NOT_READY          - The SCSI Request Packet could not be sent because\r
+                            there are too many SCSI Request Packets already \r
+                            queued.  The caller may retry again later.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
+                            the SCSI Request Packet. See HostAdapterStatus, \r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+    EFI_INVALID_PARAMETER  - Target, Lun, or the contents of ScsiRequestPacket\r
+                            are invalid. The SCSI Request Packet was not sent,\r
+                            so no additional status information is available.\r
+    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet \r
+                            is not supported by the host adapter. The SCSI \r
+                            Request Packet was not sent, so no additional \r
+                            status information is available.\r
+    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
+                            Request Packet to execute. See HostAdapterStatus,\r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL            * This,\r
+  IN OUT UINT32                             *Target,\r
+  IN OUT UINT64                             *Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to retrieve the list of legal Target IDs for SCSI devices \r
+    on a SCSI channel.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Target                - On input, a pointer to the Target ID of a \r
+                            SCSI device present on the SCSI channel.\r
+                            On output, a pointer to the Target ID of \r
+                            the next SCSI device present on a SCSI channel.\r
+                            An input value of 0xFFFFFFFF retrieves the \r
+                            Target ID of the first SCSI device present on \r
+                            a SCSI channel.\r
+    Lun                   - On input, a pointer to the LUN of a SCSI device\r
+                            present on the SCSI channel.On output, a pointer\r
+                            to the LUN of the next SCSI device present on a \r
+                            SCSI channel. \r
+  Returns:\r
+    EFI_SUCCESS            - The Target ID of the next SCSI device on the SCSI\r
+                            channel was returned in Target and Lun.\r
+    EFI_NOT_FOUND          - There are no more SCSI devices on this SCSI channel.\r
+    EFI_INVALID_PARAMETER  - Target is not 0xFFFFFFFF, and Target and Lun were \r
+                            not returned on a previous call to GetNextDevice().\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL            * This,\r
+  IN     UINT32                             Target,\r
+  IN     UINT64                             Lun,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL           **DevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to allocate and build a device path node for a SCSI device \r
+    on a SCSI channel.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Target                - The Target ID of the SCSI device for which\r
+                            a device path node is to be allocated and built.\r
+    Lun                    - The LUN of the SCSI device for which a device \r
+                            path node is to be allocated and built.\r
+    DevicePath            - A pointer to a single device path node that \r
+                            describes the SCSI device specified by \r
+                            Target and Lun. This function is responsible \r
+                            for allocating the buffer DevicePath with the boot\r
+                            service AllocatePool().  It is the caller's \r
+                            responsibility to free DevicePath when the caller\r
+                            is finished with DevicePath.    \r
+  Returns:\r
+    EFI_SUCCESS            - The device path node that describes the SCSI device\r
+                            specified by Target and Lun was allocated and \r
+                            returned in DevicePath.\r
+    EFI_NOT_FOUND          - The SCSI devices specified by Target and Lun does\r
+                            not exist on the SCSI channel.\r
+    EFI_INVALID_PARAMETER  - DevicePath is NULL.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate \r
+                            DevicePath.\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_GET_TARGET_LUN) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL            * This,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL              * DevicePath,\r
+  OUT UINT32                                *Target,\r
+  OUT UINT64                                *Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to translate a device path node to a Target ID and LUN.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DevicePath            - A pointer to the device path node that \r
+                            describes a SCSI device on the SCSI channel.\r
+    Target                - A pointer to the Target ID of a SCSI device \r
+                            on the SCSI channel. \r
+    Lun                    - A pointer to the LUN of a SCSI device on \r
+                            the SCSI channel.    \r
+  Returns:\r
+    EFI_SUCCESS            - DevicePath was successfully translated to a \r
+                            Target ID and LUN, and they were returned \r
+                            in Target and Lun.\r
+    EFI_INVALID_PARAMETER  - DevicePath is NULL.\r
+    EFI_INVALID_PARAMETER  - Target is NULL.\r
+    EFI_INVALID_PARAMETER  - Lun is NULL.\r
+    EFI_UNSUPPORTED        - This driver does not support the device path \r
+                            node type in DevicePath.\r
+    EFI_NOT_FOUND          - A valid translation from DevicePath to a \r
+                            Target ID and LUN does not exist.\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_RESET_CHANNEL) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL             * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets a SCSI channel.This operation resets all the \r
+    SCSI devices connected to the SCSI channel.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    \r
+  Returns:\r
+    EFI_SUCCESS            - The SCSI channel was reset.\r
+    EFI_UNSUPPORTED        - The SCSI channel does not support \r
+                            a channel reset operation.\r
+    EFI_DEVICE_ERROR      - A device error occurred while \r
+                            attempting to reset the SCSI channel.\r
+    EFI_TIMEOUT            - A timeout occurred while attempting \r
+                            to reset the SCSI channel.\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCSI_PASS_THRU_RESET_TARGET) (\r
+  IN EFI_SCSI_PASS_THRU_PROTOCOL             * This,\r
+  IN UINT32                                  Target,\r
+  IN UINT64                                  Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets a SCSI device that is connected to a SCSI channel.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Target                - The Target ID of the SCSI device to reset. \r
+    Lun                    - The LUN of the SCSI device to reset.\r
+        \r
+  Returns:\r
+    EFI_SUCCESS            - The SCSI device specified by Target and \r
+                            Lun was reset.\r
+    EFI_UNSUPPORTED        - The SCSI channel does not support a target\r
+                            reset operation.\r
+    EFI_INVALID_PARAMETER  - Target or Lun are invalid.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting \r
+                            to reset the SCSI device specified by Target \r
+                            and Lun.\r
+    EFI_TIMEOUT            - A timeout occurred while attempting to reset \r
+                            the SCSI device specified by Target and Lun.\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_SCSI_PASS_THRU_PROTOCOL {\r
+  EFI_SCSI_PASS_THRU_MODE               *Mode;\r
+  EFI_SCSI_PASS_THRU_PASSTHRU           PassThru;\r
+  EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE    GetNextDevice;\r
+  EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH  BuildDevicePath;\r
+  EFI_SCSI_PASS_THRU_GET_TARGET_LUN     GetTargetLun;\r
+  EFI_SCSI_PASS_THRU_RESET_CHANNEL      ResetChannel;\r
+  EFI_SCSI_PASS_THRU_RESET_TARGET       ResetTarget;\r
+} EFI_SCSI_PASS_THRU_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiScsiPassThruProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c
new file mode 100644 (file)
index 0000000..32007b3
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  \r
+Module Name:\r
+\r
+    ScsiPassThruExt.c\r
+\r
+Abstract:\r
+  EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt)\r
+\r
+EFI_GUID  gEfiExtScsiPassThruProtocolGuid = EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiExtScsiPassThruProtocolGuid, "Extended Scsi Pass Thru", "UEFI 2.0 Extended SCSI Pass Thru protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h
new file mode 100644 (file)
index 0000000..5c69f13
--- /dev/null
@@ -0,0 +1,365 @@
+/*++\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ScsiPassThruExt.h\r
+    \r
+Abstract: \r
+  EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__\r
+#define __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__\r
+\r
+#define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \\r
+  { \\r
+    0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe } \\r
+  }\r
+\r
+typedef struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL EFI_EXT_SCSI_PASS_THRU_PROTOCOL;\r
+\r
+#define TARGET_MAX_BYTES                             0x10\r
+\r
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL   0x0001\r
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL    0x0002\r
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004\r
+\r
+//\r
+// DataDirection\r
+//\r
+#define EFI_EXT_SCSI_DATA_DIRECTION_READ             0\r
+#define EFI_EXT_SCSI_DATA_DIRECTION_WRITE            1\r
+#define EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL    2\r
+//\r
+// HostAdapterStatus\r
+//\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK                    0x00\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND       0x09\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT               0x0b\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT        0x0d\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET             0x0e\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR          0x0f\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED  0x10\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT     0x11\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE              0x13\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR           0x14\r
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER                 0x7f\r
+//\r
+// TargetStatus\r
+//\r
+#define EFI_EXT_SCSI_STATUS_TARGET_GOOD                        0x00\r
+#define EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION             0x02\r
+#define EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET               0x04\r
+#define EFI_EXT_SCSI_STATUS_TARGET_BUSY                        0x08\r
+#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE                0x10\r
+#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET  0x14\r
+#define EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT        0x18\r
+#define EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL               0x28\r
+#define EFI_EXT_SCSI_STATUS_TARGET_ACA_ACTIVE                  0x30\r
+#define EFI_EXT_SCSI_STATUS_TARGET_TASK_ABORTED                0x40\r
+\r
+typedef struct {\r
+  UINT32 AdapterId;\r
+  UINT32 Attributes;\r
+  UINT32 IoAlign;\r
+} EFI_EXT_SCSI_PASS_THRU_MODE;\r
+\r
+typedef struct {\r
+  UINT64 Timeout;\r
+  VOID   *InDataBuffer;\r
+  VOID   *OutDataBuffer;\r
+  VOID   *SenseData;\r
+  VOID   *Cdb;\r
+  UINT32 InTransferLength;\r
+  UINT32 OutTransferLength;\r
+  UINT8  CdbLength;\r
+  UINT8  DataDirection;\r
+  UINT8  HostAdapterStatus;\r
+  UINT8  TargetStatus;\r
+  UINT8  SenseDataLength;\r
+} EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_PASSTHRU) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                *This,\r
+  IN UINT8                                          *Target,\r
+  IN UINT64                                         Lun,\r
+  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r
+  IN EFI_EVENT                                      Event     OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function   \r
+    supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r
+    nonblocking I/O functionality is optional.                                                             \r
+  \r
+  Arguments:\r
+    This   - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+    Target - The Target is an array of size TARGET_MAX_BYTES and it represents\r
+             the id of the SCSI device to send the SCSI Request Packet. Each\r
+             transport driver may chose to utilize a subset of this size to suit the needs\r
+             of transport target representation. For example, a Fibre Channel driver\r
+             may use only 8 bytes (WWN) to represent an FC target.\r
+    Lun    - The LUN of the SCSI device to send the SCSI Request Packet.\r
+    Packet - A pointer to the SCSI Request Packet to send to the SCSI device\r
+             specified by Target and Lun.\r
+    Event  - If nonblocking I/O is not supported then Event is ignored, and blocking\r
+             I/O is performed. If Event is NULL, then blocking I/O is performed. If\r
+             Event is not NULL and non blocking I/O is supported, then\r
+             nonblocking I/O is performed, and Event will be signaled when the\r
+             SCSI Request Packet completes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - The SCSI Request Packet was sent by the host. For bi-directional\r
+                           commands, InTransferLength bytes were transferred from\r
+                           InDataBuffer. For write and bi-directional commands,\r
+                           OutTransferLength bytes were transferred by\r
+                           OutDataBuffer.\r
+    EFI_BAD_BUFFER_SIZE  - The SCSI Request Packet was not executed. The number of bytes that\r
+                           could be transferred is returned in InTransferLength. For write\r
+                           and bi-directional commands, OutTransferLength bytes were\r
+                           transferred by OutDataBuffer.\r
+    EFI_NOT_READY        - The SCSI Request Packet could not be sent because there are too many\r
+                           SCSI Request Packets already queued. The caller may retry again later.\r
+    EFI_DEVICE_ERROR     - A device error occurred while attempting to send the SCSI Request\r
+                           Packet.\r
+    EFI_INVALID_PARAMETER- Target, Lun, or the contents of ScsiRequestPacket are invalid.\r
+    EFI_UNSUPPORTED      - The command described by the SCSI Request Packet is not supported\r
+                           by the host adapter. This includes the case of Bi-directional SCSI\r
+                           commands not supported by the implementation. The SCSI Request\r
+                           Packet was not sent, so no additional status information is available.\r
+    EFI_TIMEOUT          - A timeout occurred while waiting for the SCSI Request Packet to execute.\r
+\r
+--*/\r
+;      \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                *This,\r
+  IN OUT UINT8                                      **Target,\r
+  IN OUT UINT64                                     *Lun\r
+  )\r
+/*++\r
+  Routine Description:\r
+    Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These       \r
+    can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r
+    Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the       \r
+    Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI    \r
+    channel.                                                                                               \r
+  \r
+  Arguments:\r
+    This    - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance\r
+    Target  - On input, a pointer to the Target ID (an array of size\r
+              TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r
+              On output, a pointer to the Target ID (an array of\r
+              TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r
+              channel. An input value of 0xF(all bytes in the array are 0xF) in the\r
+              Target array retrieves the Target ID of the first SCSI device present on\r
+              a SCSI channel.\r
+    Lun     - On input, a pointer to the LUN of a SCSI device present on the SCSI\r
+              channel. On output, a pointer to the LUN of the next SCSI device present\r
+              on a SCSI channel.\r
+  \r
+  Returns:\r
+    EFI_SUCCESS           - The Target ID and LUN of the next SCSI device on the SCSI\r
+                            channel was returned in Target and Lun.\r
+    EFI_INVALID_PARAMETER - Target array is not all 0xF, and Target and Lun were\r
+                            not returned on a previous call to GetNextTargetLun().\r
+    EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
+\r
+--*/\r
+;   \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,\r
+  IN UINT8                                         *Target,\r
+  IN UINT64                                        Lun,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL                  **DevicePath\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to allocate and build a device path node for a SCSI device on a SCSI channel.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+    Target     - The Target is an array of size TARGET_MAX_BYTES and it specifies the\r
+                 Target ID of the SCSI device for which a device path node is to be\r
+                 allocated and built. Transport drivers may chose to utilize a subset of\r
+                 this size to suit the representation of targets. For example, a Fibre\r
+                 Channel driver may use only 8 bytes (WWN) in the array to represent a\r
+                 FC target.\r
+    Lun        - The LUN of the SCSI device for which a device path node is to be\r
+                 allocated and built.\r
+                 \r
+    DevicePath - A pointer to a single device path node that describes the SCSI device\r
+                 specified by Target and Lun. This function is responsible for\r
+                 allocating the buffer DevicePath with the boot service\r
+                 AllocatePool(). It is the caller's responsibility to free\r
+                 DevicePath when the caller is finished with DevicePath.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device path node that describes the SCSI device specified by\r
+                            Target and Lun was allocated and returned in\r
+                            DevicePath.\r
+    EFI_INVALID_PARAMETER - DevicePath is NULL.\r
+    EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does not exist\r
+                            on the SCSI channel.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate DevicePath.\r
+\r
+--*/\r
+;     \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,\r
+  IN EFI_DEVICE_PATH_PROTOCOL                      *DevicePath,\r
+  OUT UINT8                                        **Target,\r
+  OUT UINT64                                       *Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to translate a device path node to a Target ID and LUN.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+    DevicePath - A pointer to a single device path node that describes the SCSI device\r
+                 on the SCSI channel.\r
+    Target     - A pointer to the Target Array which represents the ID of a SCSI device\r
+                 on the SCSI channel.\r
+    Lun        - A pointer to the LUN of a SCSI device on the SCSI channel.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - DevicePath was successfully translated to a Target ID and\r
+                            LUN, and they were returned in Target and Lun.\r
+    EFI_INVALID_PARAMETER - DevicePath or Target or Lun is NULL.\r
+    EFI_NOT_FOUND         - A valid translation from DevicePath to a Target ID and LUN\r
+                            does not exist.\r
+    EFI_UNSUPPORTED       - This driver does not support the device path node type in\r
+                                    DevicePath.\r
+\r
+--*/\r
+;       \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.\r
+\r
+  Arguments:\r
+    This          - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The SCSI channel was reset.\r
+    EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI channel.\r
+    EFI_TIMEOUT      - A timeout occurred while attempting to reset the SCSI channel.\r
+    EFI_UNSUPPORTED  - The SCSI channel does not support a channel reset operation.\r
+\r
+--*/\r
+;    \r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,\r
+  IN UINT8                                         *Target,\r
+  IN UINT64                                        Lun\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets a SCSI logical unit that is connected to a SCSI channel.\r
+\r
+  Arguments:\r
+    This   A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+    Target The Target is an array of size TARGET_MAX_BYTE and it represents the\r
+           target port ID of the SCSI device containing the SCSI logical unit to\r
+           reset. Transport drivers may chose to utilize a subset of this array to suit\r
+           the representation of their targets.\r
+    Lun    The LUN of the SCSI device to reset.\r
+  \r
+  Returns:\r
+    EFI_SUCCESS           - The SCSI device specified by Target and Lun was reset.\r
+    EFI_INVALID_PARAMETER - Target or Lun is NULL.\r
+    EFI_TIMEOUT           - A timeout occurred while attempting to reset the SCSI device\r
+                            specified by Target and Lun.\r
+    EFI_UNSUPPORTED       - The SCSI channel does not support a target reset operation.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to reset the SCSI device\r
+                            specified by Target and Lun.\r
+   \r
+--*/\r
+;         \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET) (\r
+  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,\r
+  IN OUT UINT8                                     **Target\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either     \r
+    be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r
+    for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to     \r
+    see if a SCSI device is actually present at that location on the SCSI channel.                         \r
+\r
+  Arguments:\r
+    This   - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
+    Target - (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r
+             On output, a pointer to the Target ID (an array of\r
+             TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r
+             channel. An input value of 0xF(all bytes in the array are 0xF) in the\r
+             Target array retrieves the Target ID of the first SCSI device present on a\r
+             SCSI channel.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Target ID of the next SCSI device on the SCSI\r
+                            channel was returned in Target.\r
+    EFI_INVALID_PARAMETER - Target or Lun is NULL.\r
+    EFI_TIMEOUT           - Target array is not all 0xF, and Target were not\r
+                            returned on a previous call to GetNextTarget().\r
+    EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
+\r
+--*/\r
+;          \r
+  \r
+struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL {\r
+  EFI_EXT_SCSI_PASS_THRU_MODE                *Mode;\r
+  EFI_EXT_SCSI_PASS_THRU_PASSTHRU            PassThru;\r
+  EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun;\r
+  EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH   BuildDevicePath;\r
+  EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN      GetTargetLun;\r
+  EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL       ResetChannel;\r
+  EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN    ResetTargetLun;\r
+  EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET     GetNextTarget;\r
+};\r
+\r
+extern EFI_GUID gEfiExtScsiPassThruProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c
new file mode 100644 (file)
index 0000000..c77072a
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SerialIo.c\r
+\r
+Abstract:\r
+\r
+  Serial IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  Abstraction of a basic serial device. Targeted at 16550 UART, but\r
+  could be much more generic.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SerialIo)\r
+\r
+EFI_GUID  gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSerialIoProtocolGuid, "SerialIo Protocol", "EFI 1.0 Serial IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h
new file mode 100644 (file)
index 0000000..54a653a
--- /dev/null
@@ -0,0 +1,296 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SerialIo.h\r
+\r
+Abstract:\r
+\r
+  Serial IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  Abstraction of a basic serial device. Targeted at 16550 UART, but\r
+  could be much more generic.\r
+\r
+--*/\r
+\r
+#ifndef _SERIAL_IO_H_\r
+#define _SERIAL_IO_H_\r
+\r
+#define EFI_SERIAL_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xBB25CF6F, 0xF1D4, 0x11D2, 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SERIAL_IO_PROTOCOL);\r
+\r
+//\r
+// Serial IO Data structures\r
+//\r
+typedef enum {\r
+  DefaultParity,\r
+  NoParity,\r
+  EvenParity,\r
+  OddParity,\r
+  MarkParity,\r
+  SpaceParity\r
+} EFI_PARITY_TYPE;\r
+\r
+typedef enum {\r
+  DefaultStopBits,\r
+  OneStopBit,\r
+  OneFiveStopBits,\r
+  TwoStopBits\r
+} EFI_STOP_BITS_TYPE;\r
+\r
+//\r
+// define for Control bits, grouped by read only, write only, and read write\r
+//\r
+//\r
+// Read Only\r
+//\r
+#define EFI_SERIAL_CLEAR_TO_SEND        0x00000010\r
+#define EFI_SERIAL_DATA_SET_READY       0x00000020\r
+#define EFI_SERIAL_RING_INDICATE        0x00000040\r
+#define EFI_SERIAL_CARRIER_DETECT       0x00000080\r
+#define EFI_SERIAL_INPUT_BUFFER_EMPTY   0x00000100\r
+#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY  0x00000200\r
+\r
+//\r
+// Write Only\r
+//\r
+#define EFI_SERIAL_REQUEST_TO_SEND      0x00000002\r
+#define EFI_SERIAL_DATA_TERMINAL_READY  0x00000001\r
+\r
+//\r
+// Read Write\r
+//\r
+#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE     0x00001000\r
+#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE     0x00002000\r
+#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000\r
+\r
+//\r
+// Serial IO Member Functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_RESET) (\r
+  IN EFI_SERIAL_IO_PROTOCOL * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the serial device.\r
+\r
+  Arguments:\r
+    This     - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The device was reset.\r
+    EFI_DEVICE_ERROR - The serial device could not be reset.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) (\r
+  IN EFI_SERIAL_IO_PROTOCOL         * This,\r
+  IN UINT64                         BaudRate,\r
+  IN UINT32                         ReceiveFifoDepth,\r
+  IN UINT32                         Timeout,\r
+  IN EFI_PARITY_TYPE                Parity,\r
+  IN UINT8                          DataBits,\r
+  IN EFI_STOP_BITS_TYPE             StopBits\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, \r
+    data buts, and stop bits on a serial device.\r
+\r
+  Arguments:\r
+    This     - Protocol instance pointer.\r
+    BaudRate - The requested baud rate. A BaudRate value of 0 will use the the\r
+                device's default interface speed.\r
+    ReveiveFifoDepth - The requested depth of the FIFO on the receive side of the\r
+                       serial interface. A ReceiveFifoDepth value of 0 will use \r
+                       the device's dfault FIFO depth.\r
+    Timeout - The requested time out for a single character in microseconds. \r
+              This timeout applies to both the transmit and receive side of the\r
+              interface. A Timeout value of 0 will use the device's default time\r
+              out value.\r
+    Parity  - The type of parity to use on this serial device. A Parity value of\r
+               DefaultParity will use the device's default parity value. \r
+    DataBits - The number of data bits to use on the serial device. A DataBits\r
+                vaule of 0 will use the device's default data bit setting.\r
+    StopBits - The number of stop bits to use on this serial device. A StopBits\r
+                value of DefaultStopBits will use the device's default number of\r
+                stop bits. \r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The device was reset.\r
+    EFI_DEVICE_ERROR - The serial device could not be reset.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) (\r
+  IN EFI_SERIAL_IO_PROTOCOL         * This,\r
+  IN UINT32                         Control\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set the control bits on a serial device\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Control - Set the bits of Control that are settable.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The new control bits were set on the serial device.\r
+    EFI_UNSUPPORTED  - The serial device does not support this operation.\r
+    EFI_DEVICE_ERROR - The serial device is not functioning correctly.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) (\r
+  IN EFI_SERIAL_IO_PROTOCOL         * This,\r
+  OUT UINT32                        *Control\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the status of thecontrol bits on a serial device\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Control - A pointer to return the current Control signals from the serial\r
+               device.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The control bits were read from the serial device.\r
+    EFI_DEVICE_ERROR - The serial device is not functioning correctly.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_WRITE) (\r
+  IN EFI_SERIAL_IO_PROTOCOL         * This,\r
+  IN OUT UINTN                      *BufferSize,\r
+  IN VOID                           *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Writes data to a serial device.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    BufferSize - On input, the size of the Buffer. On output, the amount of \r
+                  data actually written.\r
+    Buffer - The buffer of data to write\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The data was written.\r
+    EFI_DEVICE_ERROR - The device reported an error.\r
+    EFI_TIMEOUT      - The data write was stopped due to a timeout.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERIAL_READ) (\r
+  IN EFI_SERIAL_IO_PROTOCOL         * This,\r
+  IN OUT UINTN                      *BufferSize,\r
+  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Writes data to a serial device.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    BufferSize - On input, the size of the Buffer. On output, the amount of \r
+                  data returned in Buffer.\r
+    Buffer - The buffer to return the data into.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The data was read.\r
+    EFI_DEVICE_ERROR - The device reported an error.\r
+    EFI_TIMEOUT      - The data write was stopped due to a timeout.\r
+\r
+--*/\r
+;\r
+\r
+/*++\r
+\r
+  The data values in SERIAL_IO_MODE are read-only and are updated by the code \r
+  that produces the SERIAL_IO_PROTOCOL member functions.\r
+\r
+  ControlMask - A mask fo the Control bits that the device supports. The device\r
+                 must always support the Input Buffer Empty control bit.\r
+  TimeOut  - If applicable, the number of microseconds to wait before timing out\r
+              a Read or Write operation.\r
+  BaudRate - If applicable, the current baud rate setting of the device; otherwise,\r
+              baud rate has the value of zero to indicate that device runs at the\r
+              device's designed speed.\r
+  ReceiveFifoDepth - The number of characters the device will buffer on input\r
+  DataBits - The number of characters the device will buffer on input\r
+  Parity   - If applicable, this is the EFI_PARITY_TYPE that is computed or \r
+             checked as each character is transmitted or reveived. If the device\r
+             does not support parity the value is the default parity value.\r
+  StopBits - If applicable, the EFI_STOP_BITS_TYPE number of stop bits per\r
+              character. If the device does not support stop bits the value is\r
+              the default stop bit values.\r
+\r
+--*/\r
+typedef struct {\r
+  UINT32  ControlMask;\r
+\r
+  //\r
+  // current Attributes\r
+  //\r
+  UINT32  Timeout;\r
+  UINT64  BaudRate;\r
+  UINT32  ReceiveFifoDepth;\r
+  UINT32  DataBits;\r
+  UINT32  Parity;\r
+  UINT32  StopBits;\r
+} EFI_SERIAL_IO_MODE;\r
+\r
+#define SERIAL_IO_INTERFACE_REVISION  0x00010000\r
+\r
+typedef struct _EFI_SERIAL_IO_PROTOCOL {\r
+  UINT32                      Revision;\r
+  EFI_SERIAL_RESET            Reset;\r
+  EFI_SERIAL_SET_ATTRIBUTES   SetAttributes;\r
+  EFI_SERIAL_SET_CONTROL_BITS SetControl;\r
+  EFI_SERIAL_GET_CONTROL_BITS GetControl;\r
+  EFI_SERIAL_WRITE            Write;\r
+  EFI_SERIAL_READ             Read;\r
+\r
+  EFI_SERIAL_IO_MODE          *Mode;\r
+} EFI_SERIAL_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSerialIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h
new file mode 100644 (file)
index 0000000..7751c83
--- /dev/null
@@ -0,0 +1,88 @@
+/*++ \r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ServiceBinding.h\r
+\r
+Abstract:\r
+\r
+  UEFI Service Binding protocol definition.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SERVICE_BINDING_H_\r
+#define _EFI_SERVICE_BINDING_H_\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_SERVICE_BINDING_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD) (\r
+  IN     EFI_SERVICE_BINDING_PROTOCOL  *This,\r
+  IN OUT EFI_HANDLE                    *ChildHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Creates a child handle with a set of I/O services.\r
+\r
+  Arguments:\r
+    This         - Protocol instance pointer.\r
+    ChildHandle  - Pointer to the handle of the child to create.  If it is NULL,\r
+                   then a new handle is created.  If it is not NULL, then the\r
+                   I/O services are added to the existing child handle.\r
+\r
+  Returns:\r
+    EFI_SUCCES           - The child handle was created with the I/O services.\r
+    EFI_OUT_OF_RESOURCES - There are not enough resources availabe to create\r
+                           the child.\r
+    other                - The child handle was not created.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD) (\r
+  IN struct _EFI_SERVICE_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                            ChildHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Destroys a child handle with a set of I/O services.\r
+\r
+  Arguments:\r
+    This         - Protocol instance pointer.\r
+    ChildHandle  - Handle of the child to destroy.\r
+\r
+  Returns:\r
+    EFI_SUCCES            - The I/O services were removed from the child handle.\r
+    EFI_UNSUPPORTED       - The child handle does not support the I/O services\r
+                            that are being removed.\r
+    EFI_INVALID_PARAMETER - Child handle is not a valid EFI Handle.\r
+    EFI_ACCESS_DENIED     - The child handle could not be destroyed because its\r
+                            I/O services are being used.\r
+    other                 - The child handle was not destroyed.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_SERVICE_BINDING_PROTOCOL {\r
+  EFI_SERVICE_BINDING_CREATE_CHILD   CreateChild;\r
+  EFI_SERVICE_BINDING_DESTROY_CHILD  DestroyChild;\r
+} EFI_SERVICE_BINDING_PROTOCOL;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c
new file mode 100644 (file)
index 0000000..20d5a2e
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileSystem.c\r
+\r
+Abstract:\r
+\r
+  SimpleFileSystem protocol as defined in the EFI 1.0 specification.\r
+\r
+  The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) \r
+  file system specified in EFI 1.0. It can also be used to abstract any \r
+  file system other than FAT.\r
+\r
+  EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem\r
\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SimpleFileSystem)\r
+\r
+EFI_GUID  gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSimpleFileSystemProtocolGuid, "Filesystem Protocol", "EFI 1.0 Simple FileSystem Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
new file mode 100644 (file)
index 0000000..da66ba5
--- /dev/null
@@ -0,0 +1,376 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileSystem.h\r
+\r
+Abstract:\r
+\r
+  SimpleFileSystem protocol as defined in the EFI 1.0 specification.\r
+\r
+  The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) \r
+  file system specified in EFI 1.0. It can also be used to abstract a file  \r
+  system other than FAT.\r
+\r
+  EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem\r
\r
+--*/\r
+\r
+#ifndef _SIMPLE_FILE_SYSTEM_H_\r
+#define _SIMPLE_FILE_SYSTEM_H_\r
+\r
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \\r
+  { \\r
+    0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL);\r
+EFI_FORWARD_DECLARATION (EFI_FILE);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_VOLUME_OPEN) (\r
+  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    * This,\r
+  OUT EFI_FILE                          **Root\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Open the root directory on a volume.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+    Root - Returns an Open file handle for the root directory\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - The device was opened.\r
+    EFI_UNSUPPORTED      - This volume does not suppor the file system.\r
+    EFI_NO_MEDIA         - The device has no media.\r
+    EFI_DEVICE_ERROR     - The device reported an error.\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_ACCESS_DENIED    - The service denied access to the file\r
+    EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources\r
+\r
+--*/\r
+;\r
+\r
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION  0x00010000\r
+\r
+typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {\r
+  UINT64          Revision;\r
+  EFI_VOLUME_OPEN OpenVolume;\r
+} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_OPEN) (\r
+  IN EFI_FILE                 * File,\r
+  OUT EFI_FILE                **NewHandle,\r
+  IN CHAR16                   *FileName,\r
+  IN UINT64                   OpenMode,\r
+  IN UINT64                   Attributes\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Open the root directory on a volume.\r
+\r
+  Arguments:\r
+    File       - Protocol instance pointer.\r
+    NewHandle  - Returns File Handle for FileName\r
+    FileName   - Null terminated string. "\", ".", and ".." are supported\r
+    OpenMode   - Open mode for file.\r
+    Attributes - Only used for EFI_FILE_MODE_CREATE\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - The device was opened.\r
+    EFI_NOT_FOUND        - The specified file could not be found on the device\r
+    EFI_NO_MEDIA         - The device has no media.\r
+    EFI_MEDIA_CHANGED    - The media has changed\r
+    EFI_DEVICE_ERROR     - The device reported an error.\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_ACCESS_DENIED    - The service denied access to the file\r
+    EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources\r
+    EFI_VOLUME_FULL      - The volume is full.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Open modes\r
+//\r
+#define EFI_FILE_MODE_READ    0x0000000000000001\r
+#define EFI_FILE_MODE_WRITE   0x0000000000000002\r
+#define EFI_FILE_MODE_CREATE  0x8000000000000000\r
+\r
+//\r
+// File attributes\r
+//\r
+#define EFI_FILE_READ_ONLY  0x0000000000000001\r
+#define EFI_FILE_HIDDEN     0x0000000000000002\r
+#define EFI_FILE_SYSTEM     0x0000000000000004\r
+#define EFI_FILE_RESERVED   0x0000000000000008\r
+#define EFI_FILE_DIRECTORY  0x0000000000000010\r
+#define EFI_FILE_ARCHIVE    0x0000000000000020\r
+#define EFI_FILE_VALID_ATTR 0x0000000000000037\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_CLOSE) (\r
+  IN EFI_FILE  * File\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Close the file handle\r
+\r
+  Arguments:\r
+    File       - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS- The device was opened.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_DELETE) (\r
+  IN EFI_FILE  * File\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Close and delete the file handle\r
+\r
+  Arguments:\r
+    File       - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The device was opened.\r
+    EFI_WARN_DELETE_FAILURE - The handle was closed but the file was not \r
+                              deleted\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_READ) (\r
+  IN EFI_FILE                 * File,\r
+  IN OUT UINTN                *BufferSize,\r
+  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Read data from the file.\r
+\r
+  Arguments:\r
+    File       - Protocol instance pointer.\r
+    BufferSize - On input size of buffer, on output amount of data in \r
+                 buffer.\r
+    Buffer     - The buffer in which data is read.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - Data was read.\r
+    EFI_NO_MEDIA         - The device has no media\r
+    EFI_DEVICE_ERROR     - The device reported an error\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_BUFFER_TO_SMALL  - BufferSize is too small. BufferSize contains \r
+                           required size\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_WRITE) (\r
+  IN EFI_FILE                 * File,\r
+  IN OUT UINTN                *BufferSize,\r
+  IN VOID                     *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Write data from to the file.\r
+\r
+  Arguments:\r
+    File       - Protocol instance pointer.\r
+    BufferSize - On input size of buffer, on output amount of data in buffer.\r
+    Buffer     - The buffer in which data to write.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - Data was written.\r
+    EFI_UNSUPPORT        - Writes to Open directory are not supported\r
+    EFI_NO_MEDIA         - The device has no media\r
+    EFI_DEVICE_ERROR     - The device reported an error\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_WRITE_PROTECTED  - The device is write protected\r
+    EFI_ACCESS_DENIED    - The file was open for read only\r
+    EFI_VOLUME_FULL      - The volume is full\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_SET_POSITION) (\r
+  IN EFI_FILE                 * File,\r
+  IN UINT64                   Position\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set a files current position\r
+\r
+  Arguments:\r
+    File     - Protocol instance pointer.\r
+    Position - Byte possition from the start of the file\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Data was written.\r
+    EFI_UNSUPPORTED - Seek request for non-zero is not valid on open.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_GET_POSITION) (\r
+  IN EFI_FILE                 * File,\r
+  OUT UINT64                  *Position\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Get a files current position\r
+\r
+  Arguments:\r
+    File     - Protocol instance pointer.\r
+    Position - Byte possition from the start of the file\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Data was written.\r
+    EFI_UNSUPPORTED - Seek request for non-zero is not valid on open.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_GET_INFO) (\r
+  IN EFI_FILE                 * File,\r
+  IN EFI_GUID                 * InformationType,\r
+  IN OUT UINTN                *BufferSize,\r
+  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Get information about a file\r
+\r
+  Arguments:\r
+    File            - Protocol instance pointer.\r
+    InformationType - Type of info to return in Buffer\r
+    BufferSize      - On input size of buffer, on output amount of data in\r
+                      buffer.\r
+    Buffer          - The buffer to return data.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - Data was returned.\r
+    EFI_UNSUPPORT        - InformationType is not supported\r
+    EFI_NO_MEDIA         - The device has no media\r
+    EFI_DEVICE_ERROR     - The device reported an error\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_WRITE_PROTECTED  - The device is write protected\r
+    EFI_ACCESS_DENIED    - The file was open for read only\r
+    EFI_BUFFER_TOO_SMALL - Buffer was too small, required size returned in \r
+                           BufferSize\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_SET_INFO) (\r
+  IN EFI_FILE                 * File,\r
+  IN EFI_GUID                 * InformationType,\r
+  IN UINTN                    BufferSize,\r
+  IN VOID                     *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set information about a file\r
+\r
+  Arguments:\r
+    File            - Protocol instance pointer.\r
+    InformationType - Type of info in Buffer\r
+    BufferSize      - Size of buffer.\r
+    Buffer          - The data to write.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - Data was returned.\r
+    EFI_UNSUPPORT        - InformationType is not supported\r
+    EFI_NO_MEDIA         - The device has no media\r
+    EFI_DEVICE_ERROR     - The device reported an error\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_WRITE_PROTECTED  - The device is write protected\r
+    EFI_ACCESS_DENIED    - The file was open for read only\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FILE_FLUSH) (\r
+  IN EFI_FILE  * File\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Flush data back for the file handle\r
+\r
+  Arguments:\r
+    File  - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS          - Data was written.\r
+    EFI_UNSUPPORT        - Writes to Open directory are not supported\r
+    EFI_NO_MEDIA         - The device has no media\r
+    EFI_DEVICE_ERROR     - The device reported an error\r
+    EFI_VOLUME_CORRUPTED - The file system structures are corrupted\r
+    EFI_WRITE_PROTECTED  - The device is write protected\r
+    EFI_ACCESS_DENIED    - The file was open for read only\r
+    EFI_VOLUME_FULL      - The volume is full\r
+\r
+--*/\r
+;\r
+\r
+#define EFI_FILE_HANDLE_REVISION  0x00010000\r
+typedef struct _EFI_FILE {\r
+  UINT64                Revision;\r
+  EFI_FILE_OPEN         Open;\r
+  EFI_FILE_CLOSE        Close;\r
+  EFI_FILE_DELETE       Delete;\r
+  EFI_FILE_READ         Read;\r
+  EFI_FILE_WRITE        Write;\r
+  EFI_FILE_GET_POSITION GetPosition;\r
+  EFI_FILE_SET_POSITION SetPosition;\r
+  EFI_FILE_GET_INFO     GetInfo;\r
+  EFI_FILE_SET_INFO     SetInfo;\r
+  EFI_FILE_FLUSH        Flush;\r
+}\r
+EFI_FILE, *EFI_FILE_HANDLE;\r
+\r
+extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c
new file mode 100644 (file)
index 0000000..3ea2429
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleNetwork.c\r
+\r
+Abstract:\r
+\r
+  Simple Network protocol as defined in the EFI 1.0 specification.\r
+\r
+  Basic network device abstraction.\r
+\r
+  Rx    - Received\r
+  Tx    - Transmit\r
+  MCast - MultiCast\r
+  ...\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)\r
+\r
+EFI_GUID  gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSimpleNetworkProtocolGuid, "Simple Network Protocol", "EFI 1.0 Simple Network Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h
new file mode 100644 (file)
index 0000000..8c79745
--- /dev/null
@@ -0,0 +1,639 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleNetwork.h\r
+\r
+Abstract:\r
+\r
+  Simple Network protocol as defined in the EFI 1.0 specification.\r
+\r
+  Basic network device abstraction.\r
+\r
+  Rx    - Received\r
+  Tx    - Transmit\r
+  MCast - MultiCast\r
+  ...\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_NETWORK_H_\r
+#define _SIMPLE_NETWORK_H_\r
+\r
+#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \\r
+  { \\r
+    0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_NETWORK_PROTOCOL);\r
+\r
+//\r
+// Simple Network Protocol data structures\r
+//\r
+typedef struct {\r
+  //\r
+  // Total number of frames received.  Includes frames with errors and\r
+  // dropped frames.\r
+  //\r
+  UINT64  RxTotalFrames;\r
+\r
+  //\r
+  // Number of valid frames received and copied into receive buffers.\r
+  //\r
+  UINT64  RxGoodFrames;\r
+\r
+  //\r
+  // Number of frames below the minimum length for the media.\r
+  // This would be <64 for ethernet.\r
+  //\r
+  UINT64  RxUndersizeFrames;\r
+\r
+  //\r
+  // Number of frames longer than the maxminum length for the\r
+  // media.  This would be >1500 for ethernet.\r
+  //\r
+  UINT64  RxOversizeFrames;\r
+\r
+  //\r
+  // Valid frames that were dropped because receive buffers were full.\r
+  //\r
+  UINT64  RxDroppedFrames;\r
+\r
+  //\r
+  // Number of valid unicast frames received and not dropped.\r
+  //\r
+  UINT64  RxUnicastFrames;\r
+\r
+  //\r
+  // Number of valid broadcast frames received and not dropped.\r
+  //\r
+  UINT64  RxBroadcastFrames;\r
+\r
+  //\r
+  // Number of valid mutlicast frames received and not dropped.\r
+  //\r
+  UINT64  RxMulticastFrames;\r
+\r
+  //\r
+  // Number of frames w/ CRC or alignment errors.\r
+  //\r
+  UINT64  RxCrcErrorFrames;\r
+\r
+  //\r
+  // Total number of bytes received.  Includes frames with errors\r
+  // and dropped frames.\r
+  //\r
+  UINT64  RxTotalBytes;\r
+\r
+  //\r
+  // Transmit statistics.\r
+  //\r
+  UINT64  TxTotalFrames;\r
+  UINT64  TxGoodFrames;\r
+  UINT64  TxUndersizeFrames;\r
+  UINT64  TxOversizeFrames;\r
+  UINT64  TxDroppedFrames;\r
+  UINT64  TxUnicastFrames;\r
+  UINT64  TxBroadcastFrames;\r
+  UINT64  TxMulticastFrames;\r
+  UINT64  TxCrcErrorFrames;\r
+  UINT64  TxTotalBytes;\r
+\r
+  //\r
+  // Number of collisions detection on this subnet.\r
+  //\r
+  UINT64  Collisions;\r
+\r
+  //\r
+  // Number of frames destined for unsupported protocol.\r
+  //\r
+  UINT64  UnsupportedProtocol;\r
+\r
+} EFI_NETWORK_STATISTICS;\r
+\r
+typedef enum {\r
+  EfiSimpleNetworkStopped,\r
+  EfiSimpleNetworkStarted,\r
+  EfiSimpleNetworkInitialized,\r
+  EfiSimpleNetworkMaxState\r
+} EFI_SIMPLE_NETWORK_STATE;\r
+\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST                0x01\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST              0x02\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST              0x04\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS            0x08\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST  0x10\r
+\r
+#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT              0x01\r
+#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT             0x02\r
+#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT              0x04\r
+#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT             0x08\r
+\r
+#define MAX_MCAST_FILTER_CNT                              16\r
+typedef struct {\r
+  UINT32          State;\r
+  UINT32          HwAddressSize;\r
+  UINT32          MediaHeaderSize;\r
+  UINT32          MaxPacketSize;\r
+  UINT32          NvRamSize;\r
+  UINT32          NvRamAccessSize;\r
+  UINT32          ReceiveFilterMask;\r
+  UINT32          ReceiveFilterSetting;\r
+  UINT32          MaxMCastFilterCount;\r
+  UINT32          MCastFilterCount;\r
+  EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT];\r
+  EFI_MAC_ADDRESS CurrentAddress;\r
+  EFI_MAC_ADDRESS BroadcastAddress;\r
+  EFI_MAC_ADDRESS PermanentAddress;\r
+  UINT8           IfType;\r
+  BOOLEAN         MacAddressChangeable;\r
+  BOOLEAN         MultipleTxSupported;\r
+  BOOLEAN         MediaPresentSupported;\r
+  BOOLEAN         MediaPresent;\r
+} EFI_SIMPLE_NETWORK_MODE;\r
+\r
+//\r
+// Protocol Member Functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_START) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Changes the state of a network interface from "stopped" to "started".\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS - The network interface was started.\r
+    EFI_ALREADY_STARTED   - The network interface is already in the started state.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_STOP) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Changes the state of a network interface from "started" to "stopped".\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS - The network interface was stopped.\r
+    EFI_ALREADY_STARTED   - The network interface is already in the stopped state.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL                    * This,\r
+  IN UINTN                                          ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                                          ExtraTxBufferSize  OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+   Resets a network adapter and allocates the transmit and receive buffers \r
+   required by the network interface; optionally, also requests allocation \r
+   of additional transmit and receive buffers.\r
+  \r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+    ExtraRxBufferSize - The size, in bytes, of the extra receive buffer space \r
+                        that the driver should allocate for the network interface. \r
+                        Some network interfaces will not be able to use the extra \r
+                        buffer, and the caller will not know if it is actually \r
+                        being used.\r
+    ExtraTxBufferSize - The size, in bytes, of the extra transmit buffer space \r
+                        that the driver should allocate for the network interface. \r
+                        Some network interfaces will not be able to use the extra \r
+                        buffer, and the caller will not know if it is actually \r
+                        being used.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The network interface was initialized.\r
+    EFI_NOT_STARTED - The network interface has not been started\r
+    EFI_OUT_OF_RESOURCES  - There was not enough memory for the transmit and \r
+                             receive buffers.   .\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_RESET) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL   * This,\r
+  IN BOOLEAN                       ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+   Resets a network adapter and re-initializes it with the parameters that were \r
+   provided in the previous call to Initialize().  \r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Indicates that the driver may perform a more \r
+                           exhaustive verification operation of the device\r
+                           during reset.\r
+                        \r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The network interface was reset.\r
+    EFI_NOT_STARTED - The network interface has not been started\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL  * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+   Resets a network adapter and leaves it in a state that is safe for \r
+   another driver to initialize.\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.                        \r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The network interface was shutdown.\r
+    EFI_NOT_STARTED - The network interface has not been started\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL                             * This,\r
+  IN UINT32                                                  Enable,\r
+  IN UINT32                                                  Disable,\r
+  IN BOOLEAN                                                 ResetMCastFilter,\r
+  IN UINTN                                                   MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                                         * MCastFilter OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Manages the multicast receive filters of a network interface.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.     \r
+    Enable  - A bit mask of receive filters to enable on the network interface.\r
+    Disable - A bit mask of receive filters to disable on the network interface.\r
+    ResetMCastFilter - Set to TRUE to reset the contents of the multicast receive \r
+                        filters on the network interface to their default values.\r
+    McastFilterCnt   - Number of multicast HW MAC addresses in the new\r
+                        MCastFilter list. This value must be less than or equal to \r
+                        the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This \r
+                        field is optional if ResetMCastFilter is TRUE.\r
+    MCastFilter      - A pointer to a list of new multicast receive filter HW MAC\r
+                        addresses. This list will replace any existing multicast\r
+                        HW MAC address list. This field is optional if \r
+                        ResetMCastFilter is TRUE.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The multicast receive filter list was updated.\r
+    EFI_NOT_STARTED - The network interface has not been started\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL            * This,\r
+  IN BOOLEAN                                Reset,\r
+  IN EFI_MAC_ADDRESS                        * New OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Modifies or resets the current station address, if supported.\r
+\r
+  Arguments:\r
+    This  - Protocol instance pointer.   \r
+    Reset - Flag used to reset the station address to the network interfaces\r
+             permanent address.\r
+    New   - New station address to be used for the network interface.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The network interfaces station address was updated.\r
+    EFI_NOT_STARTED - The network interface has not been started\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              * StatisticsTable OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets or collects the statistics on a network interface.\r
+\r
+  Arguments:\r
+    This  - Protocol instance pointer.   \r
+    Reset - Set to TRUE to reset the statistics for the network interface.\r
+    StatisticsSize  - On input the size, in bytes, of StatisticsTable. On \r
+                       output the size, in bytes, of the resulting table of \r
+                       statistics.\r
+    StatisticsTable - A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                       contains the statistics. \r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The statistics were collected from the network interface.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer \r
+                            size needed to hold the statistics is returned in \r
+                            StatisticsSize.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       * IP,\r
+  OUT EFI_MAC_ADDRESS                     * MAC\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.   \r
+    IPv6 - Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+            to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+    IP   - The multicast IP address that is to be converted to a multicast\r
+            HW MAC address.\r
+    MAC  - The multicast HW MAC address that is to be generated from IP.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The multicast IP address was mapped to the multicast \r
+                       HW MAC address.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer \r
+                            size needed to hold the statistics is returned in \r
+                            StatisticsSize.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Performs read and write operations on the NVRAM device attached to a \r
+    network interface.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.   \r
+    ReadWrite - TRUE for read operations, FALSE for write operations.\r
+    Offset    - Byte offset in the NVRAM device at which to start the read or\r
+                 write operation. This must be a multiple of NvRamAccessSize and \r
+                 less than NvRamSize.\r
+    BufferSize - The number of bytes to read or write from the NVRAM device.\r
+                  This must also be a multiple of NvramAccessSize.\r
+    Buffer     - A pointer to the data buffer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The NVRAM access was performed.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the current interrupt status and recycled transmit buffer status from \r
+    a network interface.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.   \r
+    InterruptStatus - A pointer to the bit mask of the currently active interrupts \r
+                       If this is NULL, the interrupt status will not be read from\r
+                       the device. If this is not NULL, the interrupt status will\r
+                       be read from the device. When the  interrupt status is read,\r
+                       it will also be cleared. Clearing the transmit  interrupt \r
+                       does not empty the recycled transmit buffer array.\r
+    TxBuf           - Recycled transmit buffer address. The network interface will \r
+                       not transmit if its internal recycled transmit buffer array \r
+                       is full. Reading the transmit buffer does not clear the \r
+                       transmit interrupt. If this is NULL, then the transmit buffer \r
+                       status will not be read. If there are no transmit buffers to\r
+                       recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The status of the network interface was retrieved.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      * SrcAddr OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      * DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Places a packet in the transmit queue of a network interface.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.   \r
+    HeaderSize - The size, in bytes, of the media header to be filled in by \r
+                  the Transmit() function. If HeaderSize is non-zero, then it\r
+                  must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                  and Protocol parameters must not be NULL.\r
+    BufferSize - The size, in bytes, of the entire packet (media header and \r
+                  data) to be transmitted through the network interface.\r
+    Buffer   - A pointer to the packet (media header followed by data) to be\r
+                transmitted. This parameter cannot be NULL. If HeaderSize is zero, \r
+                then the media header in Buffer must already be filled in by the \r
+                caller. If HeaderSize is non-zero, then the media header will be \r
+                filled in by the Transmit() function.\r
+    SrcAddr  - The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then \r
+                This->Mode->CurrentAddress is used for the source HW MAC address.\r
+    DsetAddr - The destination HW MAC address. If HeaderSize is zero, then this \r
+                parameter is ignored.\r
+    Protocol - The type of header to build. If HeaderSize is zero, then this \r
+                parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                examples.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The packet was placed on the transmit queue.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_NOT_READY   - The network interface is too busy to accept this transmit\r
+                       request.\r
+    EFI_BUFFER_TOO_SMALL  - The BufferSize parameter is too small.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL          * This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     * SrcAddr OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     * DestAddr OPTIONAL,\r
+  OUT UINT16                              *Protocol OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Receives a packet from a network interface.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.   \r
+    HeaderSize - The size, in bytes, of the media header received on the network\r
+                  interface. If this parameter is NULL, then the media header size\r
+                  will not be returned.\r
+    BufferSize - On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                  bytes, of the packet that was received on the network interface.\r
+    Buffer   - A pointer to the data buffer to receive both the media header and\r
+                the data.\r
+    SrcAddr  - The source HW MAC address. If this parameter is NULL, the\r
+                HW MAC source address will not be extracted from the media\r
+                header.\r
+    DsetAddr - The destination HW MAC address. If this parameter is NULL,\r
+                the HW MAC destination address will not be extracted from the\r
+                media header.\r
+    Protocol - The media header type. If this parameter is NULL, then the\r
+                protocol will not be extracted from the media header. See\r
+                RFC 1700 section "Ether Types" for examples.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The received data was stored in Buffer, and BufferSize has\r
+                       been updated to the number of bytes received.\r
+    EFI_NOT_STARTED - The network interface has not been started.\r
+    EFI_NOT_READY   - The network interface is too busy to accept this transmit\r
+                       request.\r
+    EFI_BUFFER_TOO_SMALL  - The BufferSize parameter is too small.\r
+    EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.\r
+    EFI_DEVICE_ERROR - The command could not be sent to the network interface.\r
+    EFI_UNSUPPORTED  - This function is not supported by the network interface.\r
+\r
+--*/\r
+;\r
+\r
+#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION  0x00010000\r
+\r
+typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL {\r
+  UINT64                              Revision;\r
+  EFI_SIMPLE_NETWORK_START            Start;\r
+  EFI_SIMPLE_NETWORK_STOP             Stop;\r
+  EFI_SIMPLE_NETWORK_INITIALIZE       Initialize;\r
+  EFI_SIMPLE_NETWORK_RESET            Reset;\r
+  EFI_SIMPLE_NETWORK_SHUTDOWN         Shutdown;\r
+  EFI_SIMPLE_NETWORK_RECEIVE_FILTERS  ReceiveFilters;\r
+  EFI_SIMPLE_NETWORK_STATION_ADDRESS  StationAddress;\r
+  EFI_SIMPLE_NETWORK_STATISTICS       Statistics;\r
+  EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC  MCastIpToMac;\r
+  EFI_SIMPLE_NETWORK_NVDATA           NvData;\r
+  EFI_SIMPLE_NETWORK_GET_STATUS       GetStatus;\r
+  EFI_SIMPLE_NETWORK_TRANSMIT         Transmit;\r
+  EFI_SIMPLE_NETWORK_RECEIVE          Receive;\r
+  EFI_EVENT                           WaitForPacket;\r
+  EFI_SIMPLE_NETWORK_MODE             *Mode;\r
+} EFI_SIMPLE_NETWORK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSimpleNetworkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c
new file mode 100644 (file)
index 0000000..aa5e1c9
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimplePointer.c\r
+\r
+Abstract:\r
+\r
+  Simple Pointer protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple pointer device like a mice or trackballs.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SimplePointer)\r
+\r
+EFI_GUID  gEfiSimplePointerProtocolGuid = EFI_SIMPLE_POINTER_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSimplePointerProtocolGuid, "Simple Pointer Protocol", "EFI 1.1 Simple Pointer Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h
new file mode 100644 (file)
index 0000000..35aed1d
--- /dev/null
@@ -0,0 +1,76 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimplePointer.h\r
+\r
+Abstract:\r
+\r
+  Simple Pointer protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple pointer device like a mice or tracekballs.\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_POINTER_H_\r
+#define _SIMPLE_POINTER_H_\r
+\r
+#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \\r
+  { \\r
+    0x31878c87, 0xb75, 0x11d5, 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_POINTER_PROTOCOL);\r
+\r
+//\r
+// Data structures\r
+//\r
+typedef struct {\r
+  INT32   RelativeMovementX;\r
+  INT32   RelativeMovementY;\r
+  INT32   RelativeMovementZ;\r
+  BOOLEAN LeftButton;\r
+  BOOLEAN RightButton;\r
+} EFI_SIMPLE_POINTER_STATE;\r
+\r
+typedef struct {\r
+  UINT64  ResolutionX;\r
+  UINT64  ResolutionY;\r
+  UINT64  ResolutionZ;\r
+  BOOLEAN LeftButton;\r
+  BOOLEAN RightButton;\r
+} EFI_SIMPLE_POINTER_MODE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_POINTER_RESET) (\r
+  IN EFI_SIMPLE_POINTER_PROTOCOL            * This,\r
+  IN BOOLEAN                                ExtendedVerification\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) (\r
+  IN EFI_SIMPLE_POINTER_PROTOCOL          * This,\r
+  IN OUT EFI_SIMPLE_POINTER_STATE         * State\r
+  );\r
+\r
+typedef struct _EFI_SIMPLE_POINTER_PROTOCOL {\r
+  EFI_SIMPLE_POINTER_RESET      Reset;\r
+  EFI_SIMPLE_POINTER_GET_STATE  GetState;\r
+  EFI_EVENT                     WaitForInput;\r
+  EFI_SIMPLE_POINTER_MODE       *Mode;\r
+} EFI_SIMPLE_POINTER_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSimplePointerProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c
new file mode 100644 (file)
index 0000000..89a6c26
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleTextIn.c\r
+\r
+Abstract:\r
+\r
+  Simple Text In protocol from the EFI 1.0 specification.\r
+\r
+  Abstraction of a very simple input device like a keyboard or serial\r
+  terminal.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)\r
+\r
+EFI_GUID  gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSimpleTextInProtocolGuid, "Simple Text In Protocol", "EFI 1.0 Simple Text In Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h
new file mode 100644 (file)
index 0000000..620acf6
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleTextIn.h\r
+\r
+Abstract:\r
+\r
+  Simple Text In protocol from the EFI 1.0 specification.\r
+\r
+  Abstraction of a very simple input device like a keyboard or serial\r
+  terminal.\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_TEXT_IN_H_\r
+#define _SIMPLE_TEXT_IN_H_\r
+\r
+#define EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID \\r
+  { \\r
+    0x387477c1, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_IN_PROTOCOL);\r
+\r
+//\r
+// Data structures\r
+//\r
+typedef struct {\r
+  UINT16  ScanCode;\r
+  CHAR16  UnicodeChar;\r
+} EFI_INPUT_KEY;\r
+\r
+//\r
+// Required unicode control chars\r
+//\r
+#define CHAR_NULL             0x0000\r
+#define CHAR_BACKSPACE        0x0008\r
+#define CHAR_TAB              0x0009\r
+#define CHAR_LINEFEED         0x000A\r
+#define CHAR_CARRIAGE_RETURN  0x000D\r
+\r
+//\r
+// EFI Scan codes\r
+//\r
+#define SCAN_NULL       0x0000\r
+#define SCAN_UP         0x0001\r
+#define SCAN_DOWN       0x0002\r
+#define SCAN_RIGHT      0x0003\r
+#define SCAN_LEFT       0x0004\r
+#define SCAN_HOME       0x0005\r
+#define SCAN_END        0x0006\r
+#define SCAN_INSERT     0x0007\r
+#define SCAN_DELETE     0x0008\r
+#define SCAN_PAGE_UP    0x0009\r
+#define SCAN_PAGE_DOWN  0x000A\r
+#define SCAN_F1         0x000B\r
+#define SCAN_F2         0x000C\r
+#define SCAN_F3         0x000D\r
+#define SCAN_F4         0x000E\r
+#define SCAN_F5         0x000F\r
+#define SCAN_F6         0x0010\r
+#define SCAN_F7         0x0011\r
+#define SCAN_F8         0x0012\r
+#define SCAN_F9         0x0013\r
+#define SCAN_F10        0x0014\r
+#define SCAN_F11        0x0015\r
+#define SCAN_F12        0x0016\r
+#define SCAN_ESC        0x0017\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_INPUT_RESET) (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          * This,\r
+  IN BOOLEAN                              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the input device and optionaly run diagnostics\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_INPUT_READ_KEY) (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          * This,\r
+  OUT EFI_INPUT_KEY                       * Key\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the next keystroke from the input device. The WaitForKey Event can \r
+    be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+  Arguments:\r
+    This   - Protocol instance pointer.\r
+    Key    - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - The keystroke information was returned.\r
+    EFI_NOT_READY     - There was no keystroke data availiable.\r
+    EFI_DEVICE_ERROR  - The keydtroke information was not returned due to \r
+                        hardware errors.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_SIMPLE_TEXT_IN_PROTOCOL {\r
+  EFI_INPUT_RESET     Reset;\r
+  EFI_INPUT_READ_KEY  ReadKeyStroke;\r
+  EFI_EVENT           WaitForKey;\r
+} EFI_SIMPLE_TEXT_IN_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSimpleTextInProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c
new file mode 100644 (file)
index 0000000..a5db213
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleTextOut.c\r
+\r
+Abstract:\r
+\r
+  Simple Text Out protocol from the EFI 1.0 specification.\r
+\r
+  Abstraction of a very simple text based output device like VGA text mode or\r
+  a serial terminal.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)\r
+\r
+EFI_GUID  gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSimpleTextOutProtocolGuid, "Simple Text Out Protocol", "EFI 1.0 Simple Text Out Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h
new file mode 100644 (file)
index 0000000..286ebda
--- /dev/null
@@ -0,0 +1,423 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleTextOut.h\r
+\r
+Abstract:\r
+\r
+  Simple Text Out protocol from the EFI 1.0 specification.\r
+\r
+  Abstraction of a very simple text based output device like VGA text mode or\r
+  a serial terminal. The Simple Text Out protocol instance can represent\r
+  a single hardware device or a virtual device that is an agregation\r
+  of multiple physical devices.\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_TEXT_OUT_H_\r
+#define _SIMPLE_TEXT_OUT_H_\r
+\r
+#define EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID \\r
+  { \\r
+    0x387477c2, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_OUT_PROTOCOL);\r
+\r
+//\r
+// Define's for required EFI Unicode Box Draw characters\r
+//\r
+#define BOXDRAW_HORIZONTAL                  0x2500\r
+#define BOXDRAW_VERTICAL                    0x2502\r
+#define BOXDRAW_DOWN_RIGHT                  0x250c\r
+#define BOXDRAW_DOWN_LEFT                   0x2510\r
+#define BOXDRAW_UP_RIGHT                    0x2514\r
+#define BOXDRAW_UP_LEFT                     0x2518\r
+#define BOXDRAW_VERTICAL_RIGHT              0x251c\r
+#define BOXDRAW_VERTICAL_LEFT               0x2524\r
+#define BOXDRAW_DOWN_HORIZONTAL             0x252c\r
+#define BOXDRAW_UP_HORIZONTAL               0x2534\r
+#define BOXDRAW_VERTICAL_HORIZONTAL         0x253c\r
+#define BOXDRAW_DOUBLE_HORIZONTAL           0x2550\r
+#define BOXDRAW_DOUBLE_VERTICAL             0x2551\r
+#define BOXDRAW_DOWN_RIGHT_DOUBLE           0x2552\r
+#define BOXDRAW_DOWN_DOUBLE_RIGHT           0x2553\r
+#define BOXDRAW_DOUBLE_DOWN_RIGHT           0x2554\r
+#define BOXDRAW_DOWN_LEFT_DOUBLE            0x2555\r
+#define BOXDRAW_DOWN_DOUBLE_LEFT            0x2556\r
+#define BOXDRAW_DOUBLE_DOWN_LEFT            0x2557\r
+#define BOXDRAW_UP_RIGHT_DOUBLE             0x2558\r
+#define BOXDRAW_UP_DOUBLE_RIGHT             0x2559\r
+#define BOXDRAW_DOUBLE_UP_RIGHT             0x255a\r
+#define BOXDRAW_UP_LEFT_DOUBLE              0x255b\r
+#define BOXDRAW_UP_DOUBLE_LEFT              0x255c\r
+#define BOXDRAW_DOUBLE_UP_LEFT              0x255d\r
+#define BOXDRAW_VERTICAL_RIGHT_DOUBLE       0x255e\r
+#define BOXDRAW_VERTICAL_DOUBLE_RIGHT       0x255f\r
+#define BOXDRAW_DOUBLE_VERTICAL_RIGHT       0x2560\r
+#define BOXDRAW_VERTICAL_LEFT_DOUBLE        0x2561\r
+#define BOXDRAW_VERTICAL_DOUBLE_LEFT        0x2562\r
+#define BOXDRAW_DOUBLE_VERTICAL_LEFT        0x2563\r
+#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE      0x2564\r
+#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL      0x2565\r
+#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL      0x2566\r
+#define BOXDRAW_UP_HORIZONTAL_DOUBLE        0x2567\r
+#define BOXDRAW_UP_DOUBLE_HORIZONTAL        0x2568\r
+#define BOXDRAW_DOUBLE_UP_HORIZONTAL        0x2569\r
+#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE  0x256a\r
+#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL  0x256b\r
+#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL  0x256c\r
+\r
+//\r
+// EFI Required Block Elements Code Chart\r
+//\r
+#define BLOCKELEMENT_FULL_BLOCK   0x2588\r
+#define BLOCKELEMENT_LIGHT_SHADE  0x2591\r
+\r
+//\r
+// EFI Required Geometric Shapes Code Chart\r
+//\r
+#define GEOMETRICSHAPE_UP_TRIANGLE    0x25b2\r
+#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba\r
+#define GEOMETRICSHAPE_DOWN_TRIANGLE  0x25bc\r
+#define GEOMETRICSHAPE_LEFT_TRIANGLE  0x25c4\r
+\r
+//\r
+// EFI Required Arrow shapes\r
+//\r
+#define ARROW_LEFT  0x2190\r
+#define ARROW_UP    0x2191\r
+#define ARROW_RIGHT 0x2192\r
+#define ARROW_DOWN  0x2193\r
+\r
+//\r
+// EFI Console Colours\r
+//\r
+#define EFI_BLACK                 0x00\r
+#define EFI_BLUE                  0x01\r
+#define EFI_GREEN                 0x02\r
+#define EFI_CYAN                  (EFI_BLUE | EFI_GREEN)\r
+#define EFI_RED                   0x04\r
+#define EFI_MAGENTA               (EFI_BLUE | EFI_RED)\r
+#define EFI_BROWN                 (EFI_GREEN | EFI_RED)\r
+#define EFI_LIGHTGRAY             (EFI_BLUE | EFI_GREEN | EFI_RED)\r
+#define EFI_BRIGHT                0x08\r
+#define EFI_DARKGRAY              (EFI_BRIGHT)\r
+#define EFI_LIGHTBLUE             (EFI_BLUE | EFI_BRIGHT)\r
+#define EFI_LIGHTGREEN            (EFI_GREEN | EFI_BRIGHT)\r
+#define EFI_LIGHTCYAN             (EFI_CYAN | EFI_BRIGHT)\r
+#define EFI_LIGHTRED              (EFI_RED | EFI_BRIGHT)\r
+#define EFI_LIGHTMAGENTA          (EFI_MAGENTA | EFI_BRIGHT)\r
+#define EFI_YELLOW                (EFI_BROWN | EFI_BRIGHT)\r
+#define EFI_WHITE                 (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)\r
+\r
+#define EFI_TEXT_ATTR(f, b)       ((f) | ((b) << 4))\r
+\r
+#define EFI_BACKGROUND_BLACK      0x00\r
+#define EFI_BACKGROUND_BLUE       0x10\r
+#define EFI_BACKGROUND_GREEN      0x20\r
+#define EFI_BACKGROUND_CYAN       (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)\r
+#define EFI_BACKGROUND_RED        0x40\r
+#define EFI_BACKGROUND_MAGENTA    (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)\r
+#define EFI_BACKGROUND_BROWN      (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)\r
+#define EFI_BACKGROUND_LIGHTGRAY  (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)\r
+\r
+//\r
+// We currently define attributes from 0 - 7F for color manipulations\r
+// To internally handle the local display characteristics for a particular character, we are defining\r
+// Bit 7 to signify the local glyph representation for a character.  If turned on, glyphs will be\r
+// pulled from the wide glyph database and will display locally as a wide character (16 X 19 versus 8 X 19)\r
+// If bit 7 is off, the narrow glyph database will be used.  This does NOT affect information that is sent to\r
+// non-local displays (e.g. serial or LAN consoles).\r
+//\r
+#define EFI_WIDE_ATTRIBUTE  0x80\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_RESET) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN BOOLEAN                                ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the text output device hardware and optionaly run diagnostics\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform more exhaustive verfication \r
+                           operation of the device during reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - The text output device was reset.\r
+    EFI_DEVICE_ERROR  - The text output device is not functioning correctly and\r
+                        could not be reset.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_OUTPUT_STRING) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN CHAR16                                 *String\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Write a Unicode string to the output device.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    String  - The NULL-terminated Unicode string to be displayed on the output\r
+              device(s). All output devices must also support the Unicode \r
+              drawing defined in this file.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - The string was output to the device.\r
+    EFI_DEVICE_ERROR  - The device reported an error while attempting to output\r
+                         the text.\r
+    EFI_UNSUPPORTED        - The output device's mode is not currently in a \r
+                              defined text mode.\r
+    EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the \r
+                              characters in the Unicode string could not be \r
+                              rendered and were skipped.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_TEST_STRING) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN CHAR16                                 *String\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Verifies that all characters in a Unicode string can be output to the \r
+    target device.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    String  - The NULL-terminated Unicode string to be examined for the output\r
+               device(s).\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - The device(s) are capable of rendering the output string.\r
+    EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be \r
+                       rendered by one or more of the output devices mapped \r
+                       by the EFI handle.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_QUERY_MODE) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN UINTN                                  ModeNumber,\r
+  OUT UINTN                                 *Columns,\r
+  OUT UINTN                                 *Rows\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns information for an available text mode that the output device(s)\r
+    supports.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    ModeNumber - The mode number to return information on.\r
+    Columns, Rows - Returns the geometry of the text output device for the\r
+                    requested ModeNumber.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The requested mode information was returned.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED - The mode number was not valid.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_SET_MODE) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN UINTN                                  ModeNumber\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the output device(s) to a specified mode.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    ModeNumber - The mode number to set.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The requested text mode was set.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED - The mode number was not valid.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN UINTN                                  Attribute\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the background and foreground colors for the OutputString () and\r
+    ClearScreen () functions.\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    Attribute - The attribute to set. Bits 0..3 are the foreground color, and\r
+                bits 4..6 are the background color. All other bits are undefined\r
+                and must be zero. The valid Attributes are defined in this file.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The attribute was set.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED - The attribute requested is not defined.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_CLEAR_SCREEN) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Clears the output device(s) display to the currently selected background \r
+    color.\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The operation completed successfully.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED - The output device is not in a valid text mode.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN UINTN                                  Column,\r
+  IN UINTN                                  Row\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the current coordinates of the cursor position\r
+\r
+  Arguments:\r
+    This        - Protocol instance pointer.\r
+    Column, Row - the position to set the cursor to. Must be greater than or\r
+                  equal to zero and less than the number of columns and rows\r
+                  by QueryMode ().\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The operation completed successfully.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+    EFI_UNSUPPORTED - The output device is not in a valid text mode, or the \r
+                       cursor position is invalid for the current mode.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TEXT_ENABLE_CURSOR) (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           * This,\r
+  IN BOOLEAN                                Enable\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Makes the cursor visible or invisible\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is\r
+              set to be invisible.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The operation completed successfully.\r
+    EFI_DEVICE_ERROR - The device had an error and could not complete the \r
+                        request, or the device does not support changing\r
+                        the cursor mode.\r
+    EFI_UNSUPPORTED - The output device is not in a valid text mode.\r
+\r
+--*/\r
+;\r
+\r
+/*++\r
+  Mode Structure pointed to by Simple Text Out protocol.\r
+\r
+  MaxMode   - The number of modes supported by QueryMode () and SetMode ().\r
+  Mode      - The text mode of the output device(s).\r
+  Attribute - The current character output attribute\r
+  CursorColumn  - The cursor's column.\r
+  CursorRow     - The cursor's row.\r
+  CursorVisible - The cursor is currently visbile or not.\r
+  \r
+--*/\r
+typedef struct {\r
+  INT32   MaxMode;\r
+\r
+  //\r
+  // current settings\r
+  //\r
+  INT32   Mode;\r
+  INT32   Attribute;\r
+  INT32   CursorColumn;\r
+  INT32   CursorRow;\r
+  BOOLEAN CursorVisible;\r
+} EFI_SIMPLE_TEXT_OUTPUT_MODE;\r
+\r
+typedef struct _EFI_SIMPLE_TEXT_OUT_PROTOCOL {\r
+  EFI_TEXT_RESET                Reset;\r
+\r
+  EFI_TEXT_OUTPUT_STRING        OutputString;\r
+  EFI_TEXT_TEST_STRING          TestString;\r
+\r
+  EFI_TEXT_QUERY_MODE           QueryMode;\r
+  EFI_TEXT_SET_MODE             SetMode;\r
+  EFI_TEXT_SET_ATTRIBUTE        SetAttribute;\r
+\r
+  EFI_TEXT_CLEAR_SCREEN         ClearScreen;\r
+  EFI_TEXT_SET_CURSOR_POSITION  SetCursorPosition;\r
+  EFI_TEXT_ENABLE_CURSOR        EnableCursor;\r
+\r
+  //\r
+  // Current mode\r
+  //\r
+  EFI_SIMPLE_TEXT_OUTPUT_MODE   *Mode;\r
+} EFI_SIMPLE_TEXT_OUT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSimpleTextOutProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c
new file mode 100644 (file)
index 0000000..b454e13
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    TapeIo.c\r
+    \r
+Abstract: \r
+  EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0.\r
+  Provide services to control and access a tape device.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (TapeIo)\r
+\r
+EFI_GUID gEfiTapeIoProtocolGuid = EFI_TAPE_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTapeIoProtocolGuid, "Tape IO protoco", "UEFI 2.0 Tape IO protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h
new file mode 100644 (file)
index 0000000..8d1bd63
--- /dev/null
@@ -0,0 +1,263 @@
+/*++\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    TapeIo.h\r
+    \r
+Abstract: \r
+  EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0.\r
+  Provide services to control and access a tape device.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef __EFI_TAPE_IO_PROTOCOL_H__\r
+#define __EFI_TAPE_IO_PROTOCOL_H__\r
+\r
+#define EFI_TAPE_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x1e93e633, 0xd65a, 0x459e, {0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \\r
+  }\r
+\r
+typedef struct _EFI_TAPE_IO_PROTOCOL EFI_TAPE_IO_PROTOCOL;\r
+\r
+typedef struct {\r
+  UINT64     Signature;\r
+  UINT32     Revision;\r
+  UINT32     BootDescSize;\r
+  UINT32     BootDescCRC;\r
+  EFI_GUID   TapeGUID;\r
+  EFI_GUID   TapeType;\r
+  EFI_GUID   TapeUnique;\r
+  UINT32     BLLocation;\r
+  UINT32     BLBlocksize;\r
+  UINT32     BLFilesize;\r
+  CHAR8      OSVersion[40];\r
+  CHAR8      AppVersion[40];\r
+  CHAR8      CreationDate[10];\r
+  CHAR8      CreationTime[10];\r
+  CHAR8      SystemName[256];  // UTF-8\r
+  CHAR8      TapeTitle[120];   // UTF-8\r
+  CHAR8      pad[468];         // pad to 1024\r
+} TAPE_HEADER;\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_READ) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This,\r
+  IN OUT UINTN            *BufferSize,\r
+  OUT VOID                *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads from the tape.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+    BufferSize - Size of the buffer in bytes pointed to by Buffer.\r
+    Buffer     - Pointer to the buffer for data to be read into.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Data was successfully transferred from the media.\r
+    EFI_END_OF_FILE       - A filemark was encountered which limited the data\r
+                            transferred by the read operation or the head is positioned\r
+                            just after a filemark.\r
+    EFI_NO_MEDIA          - No media is loaded in the device.\r
+    EFI_NOT_READY         - The transfer failed since the device was not ready (e.g. not\r
+                            online). The transfer may be retried at a later time.\r
+    EFI_UNSUPPORTED       - The device does not support this type of transfer.\r
+    EFI_TIMEOUT           - The transfer failed to complete within the timeout specified.\r
+    EFI_MEDIA_CHANGED     - The media in the device was changed since the last access.\r
+                            The transfer was aborted since the current position of the\r
+                            media may be incorrect.\r
+    EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero\r
+                            BufferSize or the device is operating in fixed block\r
+                            size mode and the BufferSize was not a multiple of\r
+                            device¡¯s fixed block size\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to transfer data\r
+                            from the media.\r
+    \r
+--*/\r
+;    \r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_WRITE) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This,\r
+  IN UINTN                *BufferSize,\r
+  IN VOID                 *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Writes to the tape.\r
+\r
+  Arguments:\r
+    This        - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+    BufferSize  - Size of the buffer in bytes pointed to by Buffer.\r
+    Buffer      - Pointer to the buffer for data to be written from.\r
+    \r
+  Returns:\r
+    EFI_SUCCESS         - Data was successfully transferred to the media.\r
+    EFI_END_OF_MEDIA    - The logical end of media has been reached. Data may have\r
+                          been successfully transferred to the media.\r
+    EFI_NO_MEDIA        - No media is loaded in the device.\r
+    EFI_NOT_READY       - The transfer failed since the device was not ready (e.g. not\r
+                          online). The transfer may be retried at a later time.\r
+    EFI_UNSUPPORTED     - The device does not support this type of transfer.\r
+    EFI_TIMEOUT         - The transfer failed to complete within the timeout specified.\r
+    EFI_MEDIA_CHANGED   - The media in the device was changed since the last access.\r
+                          The transfer was aborted since the current position of the\r
+                          media may be incorrect.\r
+    EFI_WRITE_PROTECTED - The media in the device is write-protected. The transfer\r
+                          was aborted since a write cannot be completed.\r
+    EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero\r
+                          BufferSize or the device is operating in fixed block\r
+                          size mode and the BufferSize was not a multiple of\r
+                          device¡¯s fixed block size\r
+    EFI_DEVICE_ERROR      A device error occurred while attempting to transfer data\r
+                          from the media.\r
+    \r
+--*/\r
+; \r
+  \r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_REWIND) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Rewinds the tape.\r
+\r
+  Arguments:\r
+    This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - The media was successfully repositioned.\r
+    EFI_NO_MEDIA     - No media is loaded in the device.\r
+    EFI_NOT_READY    - Repositioning the media failed since the device was not\r
+                       ready (e.g. not online). The transfer may be retried at a later time.\r
+    EFI_UNSUPPORTED  - The device does not support this type of media repositioning.\r
+    EFI_TIMEOUT      - Repositioning of the media did not complete within the timeout specified.\r
+    EFI_DEVICE_ERROR - A device error occurred while attempting to reposition the media.\r
+\r
+--*/\r
+;   \r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_SPACE) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This,\r
+  INTN                    Direction,\r
+  UINTN                   Type\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Positions the tape.\r
+\r
+  Arguments:\r
+    This      - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+    Direction - Direction and number of data blocks or filemarks to space over on media.\r
+    Type      - Type of mark to space over on media.\r
+    \r
+  Returns:\r
+    EFI_SUCCESS       - The media was successfully repositioned.\r
+    EFI_END_OF_MEDIA  - Beginning or end of media was reached before the\r
+                        indicated number of data blocks or filemarks were found.\r
+    EFI_NO_MEDIA      - No media is loaded in the device.\r
+    EFI_NOT_READY     - The reposition failed since the device was not ready (e.g. not\r
+                        online). The reposition may be retried at a later time.\r
+    EFI_UNSUPPORTED   - The device does not support this type of repositioning.\r
+    EFI_TIMEOUT       - The repositioning failed to complete within the timeout specified.\r
+    EFI_MEDIA_CHANGED - The media in the device was changed since the last access.\r
+                        Repositioning the media was aborted since the current\r
+                        position of the media may be incorrect.\r
+    EFI_DEVICE_ERROR  - A device error occurred while attempting to reposition the media.\r
+    \r
+--*/\r
+;   \r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_WRITEFM) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This,\r
+  IN UINTN                Count\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Writes filemarks to the media.\r
+\r
+  Arguments:\r
+    This    - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+    Count   - Number of filemarks to write to the media.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - Data was successfully transferred from the media.\r
+    EFI_NO_MEDIA      - No media is loaded in the device.\r
+    EFI_NOT_READY     - The transfer failed since the device was not ready (e.g. not\r
+                        online). The transfer may be retried at a later time.\r
+    EFI_UNSUPPORTED   - The device does not support this type of repositioning.\r
+    EFI_TIMEOUT       - The transfer failed to complete within the timeout specified.\r
+    EFI_MEDIA_CHANGED - The media in the device was changed since the last access.\r
+                        The transfer was aborted since the current position of the\r
+                        media may be incorrect.\r
+    EFI_DEVICE_ERROR  - A device error occurred while attempting to transfer data from the media.\r
+\r
+--*/\r
+;   \r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_TAPE_RESET) (\r
+  IN EFI_TAPE_IO_PROTOCOL *This,\r
+  IN BOOLEAN              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the tape device.\r
+\r
+  Arguments:\r
+    This                  - A pointer to the EFI_TAPE_IO_PROTOCOL instance.\r
+    ExtendedVerification  - Indicates whether the parent bus should also be reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - The bus and/or device were successfully reset.\r
+    EFI_NO_MEDIA      - No media is loaded in the device.\r
+    EFI_NOT_READY     - The reset failed since the device and/or bus was not ready.\r
+                        The reset may be retried at a later time.\r
+    EFI_UNSUPPORTED   - The device does not support this type of reset.\r
+    EFI_TIMEOUT       - The reset did not complete within the timeout allowed.\r
+    EFI_DEVICE_ERROR  - A device error occurred while attempting to reset the bus and/or device.\r
+\r
+--*/\r
+;    \r
+\r
+struct _EFI_TAPE_IO_PROTOCOL {\r
+  EFI_TAPE_READ           TapeRead;\r
+  EFI_TAPE_WRITE          TapeWrite;\r
+  EFI_TAPE_REWIND         TapeRewind;\r
+  EFI_TAPE_SPACE          TapeSpace;\r
+  EFI_TAPE_WRITEFM        TapeWriteFM;\r
+  EFI_TAPE_RESET          TapeReset;\r
+};\r
+\r
+extern EFI_GUID gEfiTapeIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c
new file mode 100644 (file)
index 0000000..54f75b9
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Tcp4.c\r
+\r
+Abstract:\r
+\r
+  UEFI TCPv4 Protocol\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Tcp4)\r
+\r
+EFI_GUID  gEfiTcp4ServiceBindingProtocolGuid = EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID;\r
+EFI_GUID  gEfiTcp4ProtocolGuid               = EFI_TCP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTcp4ServiceBindingProtocolGuid, "TCP4 Service Binding Protocol", "TCP4 Service Binding Protocol");\r
+EFI_GUID_STRING(&gEfiTcp4ProtocolGuid, "TCP4 Protocol", "TCP4 Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h
new file mode 100644 (file)
index 0000000..e4d1e3e
--- /dev/null
@@ -0,0 +1,247 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Tcp4.h\r
+\r
+Abstract:\r
+\r
+  UEFI TCPv4 Protocol Definition\r
+\r
+--*/\r
+\r
+#ifndef _TCP4_H_\r
+#define _TCP4_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+#include EFI_PROTOCOL_DEFINITION (Ip4)\r
+\r
+#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+  { \\r
+    0x00720665, 0x67EB, 0x4a99, 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 \\r
+  }\r
+\r
+extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;\r
+\r
+#define EFI_TCP4_PROTOCOL_GUID \\r
+  { \\r
+    0x65530BC7, 0xA359, 0x410f, 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 \\r
+  }\r
+\r
+extern EFI_GUID gEfiTcp4ProtocolGuid;\r
+\r
+EFI_FORWARD_DECLARATION (EFI_TCP4_PROTOCOL);\r
+\r
+typedef struct {\r
+  EFI_HANDLE        InstanceHandle;\r
+  EFI_IPv4_ADDRESS  LocalAddress;\r
+  UINT16            LocalPort;\r
+  EFI_IPv4_ADDRESS  RemoteAddress;\r
+  UINT16            RemotePort;\r
+} EFI_TCP4_SERVICE_POINT;\r
+\r
+typedef struct {\r
+  EFI_HANDLE              DriverHandle;\r
+  UINT32                  ServiceCount;\r
+  EFI_TCP4_SERVICE_POINT  Services[1];\r
+} EFI_TCP4_VARIABLE_DATA;\r
+\r
+typedef struct {\r
+  BOOLEAN           UseDefaultAddress;\r
+  EFI_IPv4_ADDRESS  StationAddress;\r
+  EFI_IPv4_ADDRESS  SubnetMask;\r
+  UINT16            StationPort;\r
+  EFI_IPv4_ADDRESS  RemoteAddress;\r
+  UINT16            RemotePort;\r
+  BOOLEAN           ActiveFlag;\r
+} EFI_TCP4_ACCESS_POINT;\r
+\r
+typedef struct {\r
+  UINT32   ReceiveBufferSize;\r
+  UINT32   SendBufferSize;\r
+  UINT32   MaxSynBackLog;\r
+  UINT32   ConnectionTimeout;\r
+  UINT32   DataRetries;\r
+  UINT32   FinTimeout;\r
+  UINT32   TimeWaitTimeout;\r
+  UINT32   KeepAliveProbes;\r
+  UINT32   KeepAliveTime;\r
+  UINT32   KeepAliveInterval;\r
+  BOOLEAN  EnableNagle;\r
+  BOOLEAN  EnableTimeStamp;\r
+  BOOLEAN  EnableWindowScaling;\r
+  BOOLEAN  EnableSelectiveAck;\r
+  BOOLEAN  EnablePathMtuDiscovery;\r
+} EFI_TCP4_OPTION;\r
+\r
+typedef struct {\r
+  UINT8                 TypeOfService;\r
+  UINT8                 TimeToLive;\r
+  EFI_TCP4_ACCESS_POINT AccessPoint;\r
+  EFI_TCP4_OPTION       *ControlOption;\r
+} EFI_TCP4_CONFIG_DATA;\r
+\r
+typedef enum {\r
+  Tcp4StateClosed     = 0,\r
+  Tcp4StateListen     = 1,\r
+  Tcp4StateSynSent    = 2,\r
+  Tcp4StateSynReceived= 3,\r
+  Tcp4StateEstablished= 4,\r
+  Tcp4StateFinWait1   = 5,\r
+  Tcp4StateFinWait2   = 6,\r
+  Tcp4StateClosing    = 7,\r
+  Tcp4StateTimeWait   = 8,\r
+  Tcp4StateCloseWait  = 9,\r
+  Tcp4StateLastAck    = 10\r
+} EFI_TCP4_CONNECTION_STATE;\r
+\r
+typedef struct {\r
+  EFI_EVENT   Event;\r
+  EFI_STATUS  Status;\r
+} EFI_TCP4_COMPLETION_TOKEN;\r
+\r
+typedef struct {\r
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+} EFI_TCP4_CONNECTION_TOKEN;\r
+\r
+typedef struct {\r
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+  EFI_HANDLE                NewChildHandle;\r
+} EFI_TCP4_LISTEN_TOKEN;\r
+\r
+typedef struct {\r
+  UINT32 FragmentLength;\r
+  VOID   *FragmentBuffer;\r
+} EFI_TCP4_FRAGMENT_DATA;\r
+\r
+typedef struct {\r
+  BOOLEAN                 UrgentFlag;\r
+  UINT32                  DataLength;\r
+  UINT32                  FragmentCount;\r
+  EFI_TCP4_FRAGMENT_DATA  FragmentTable[1];\r
+} EFI_TCP4_RECEIVE_DATA;\r
+\r
+typedef struct {\r
+  BOOLEAN                 Push;\r
+  BOOLEAN                 Urgent;\r
+  UINT32                  DataLength;\r
+  UINT32                  FragmentCount;\r
+  EFI_TCP4_FRAGMENT_DATA  FragmentTable[1];\r
+} EFI_TCP4_TRANSMIT_DATA;\r
+\r
+typedef struct {\r
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+  union {\r
+    EFI_TCP4_RECEIVE_DATA   *RxData;\r
+    EFI_TCP4_TRANSMIT_DATA  *TxData;\r
+  } Packet;\r
+} EFI_TCP4_IO_TOKEN;\r
+\r
+typedef struct {\r
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;\r
+  BOOLEAN                   AbortOnClose;\r
+} EFI_TCP4_CLOSE_TOKEN;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_GET_MODE_DATA) (\r
+  IN    EFI_TCP4_PROTOCOL                *This,\r
+  OUT EFI_TCP4_CONNECTION_STATE          *Tcp4State OPTIONAL,\r
+  OUT EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,\r
+  OUT EFI_IP4_MODE_DATA                  *Ip4ModeData OPTIONAL,\r
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData OPTIONAL,\r
+  OUT EFI_SIMPLE_NETWORK_MODE            *SnpModeData OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CONFIGURE) (\r
+  IN EFI_TCP4_PROTOCOL        *This,\r
+  IN EFI_TCP4_CONFIG_DATA     *TcpConfigData OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_ROUTES) (\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN BOOLEAN                     DeleteRoute,\r
+  IN EFI_IPv4_ADDRESS            *SubnetAddress,\r
+  IN EFI_IPv4_ADDRESS            *SubnetMask,\r
+  IN EFI_IPv4_ADDRESS            *GatewayAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CONNECT) (\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN EFI_TCP4_CONNECTION_TOKEN   *ConnectionToken\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_ACCEPT) (\r
+  IN EFI_TCP4_PROTOCOL             *This,\r
+  IN EFI_TCP4_LISTEN_TOKEN         *ListenToken\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_TRANSMIT) (\r
+  IN EFI_TCP4_PROTOCOL            *This,\r
+  IN EFI_TCP4_IO_TOKEN            *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_RECEIVE) (\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN EFI_TCP4_IO_TOKEN           *Token\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CLOSE) (\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN EFI_TCP4_CLOSE_TOKEN        *CloseToken\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_CANCEL) (\r
+  IN EFI_TCP4_PROTOCOL           *This,\r
+  IN EFI_TCP4_COMPLETION_TOKEN   *Token OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP4_POLL) (\r
+  IN EFI_TCP4_PROTOCOL        *This\r
+  );\r
+\r
+typedef struct _EFI_TCP4_PROTOCOL {\r
+  EFI_TCP4_GET_MODE_DATA  GetModeData;\r
+  EFI_TCP4_CONFIGURE      Configure;\r
+  EFI_TCP4_ROUTES         Routes;\r
+  EFI_TCP4_CONNECT        Connect;\r
+  EFI_TCP4_ACCEPT         Accept;\r
+  EFI_TCP4_TRANSMIT       Transmit;\r
+  EFI_TCP4_RECEIVE        Receive;\r
+  EFI_TCP4_CLOSE          Close;\r
+  EFI_TCP4_CANCEL         Cancel;\r
+  EFI_TCP4_POLL           Poll;\r
+} EFI_TCP4_PROTOCOL;\r
+\r
+#define EFI_CONNECTION_FIN      EFIERR (104)\r
+#define EFI_CONNECTION_RESET    EFIERR (105)\r
+#define EFI_CONNECTION_REFUSED  EFIERR (106)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c
new file mode 100644 (file)
index 0000000..1206b15
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Udp4.c\r
+\r
+Abstract:\r
+\r
+  UEFI UDPv4 protocol.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (Udp4)\r
+\r
+EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID;\r
+EFI_GUID gEfiUdp4ProtocolGuid               = EFI_UDP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiUdp4ServiceBindingProtocolGuid, "UDP4 Service Binding Protocol", "UDP4 Service Binding Protocol");\r
+EFI_GUID_STRING (&gEfiUdp4ProtocolGuid, "UDP4 Protocol", "UDP4 Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h
new file mode 100644 (file)
index 0000000..c8730a7
--- /dev/null
@@ -0,0 +1,214 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  Udp4.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _UDP4_H_\r
+#define _UDP4_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+#include EFI_PROTOCOL_DEFINITION (Ip4)\r
+\r
+//\r
+//GUID definitions\r
+//\r
+#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \\r
+  { 0x83f01464, 0x99bd, 0x45e5, 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 }\r
+\r
+#define EFI_UDP4_PROTOCOL_GUID \\r
+  { 0x3ad9df29, 0x4501, 0x478d, 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 }\r
+\r
+typedef struct {\r
+  EFI_HANDLE          InstanceHandle;\r
+  EFI_IPv4_ADDRESS    LocalAddress;\r
+  UINT16              LocalPort;\r
+  EFI_IPv4_ADDRESS    RemoteAddress;\r
+  UINT16              RemotePort;\r
+} EFI_UDP4_SERVICE_POINT; \r
+\r
+typedef struct {\r
+  EFI_HANDLE              DriverHandle;\r
+  UINT32                  ServiceCount;\r
+  EFI_UDP4_SERVICE_POINT  Services[1];\r
+} EFI_UDP4_VARIABLE_DATA;\r
+\r
+//\r
+//ICMP error definitions\r
+//\r
+#define EFI_NETWORK_UNREACHABLE      EFIERR(100)\r
+#define EFI_HOST_UNREACHABLE         EFIERR(101) \r
+#define EFI_PROTOCOL_UNREACHABLE     EFIERR(102)\r
+#define EFI_PORT_UNREACHABLE         EFIERR(103)\r
+\r
+EFI_FORWARD_DECLARATION (EFI_UDP4_PROTOCOL);\r
+\r
+//*************************************************\r
+//      EFI_UDP4_FRAGMENT_DATA                    *\r
+//*************************************************\r
+typedef struct {\r
+  UINT32        FragmentLength;\r
+  VOID         *FragmentBuffer;\r
+} EFI_UDP4_FRAGMENT_DATA;\r
+\r
+//*************************************************\r
+//      EFI_UDP4_SESSION_DATA                     *\r
+//*************************************************\r
+typedef struct {\r
+  EFI_IPv4_ADDRESS   SourceAddress;\r
+  UINT16             SourcePort;\r
+  EFI_IPv4_ADDRESS   DestinationAddress;\r
+  UINT16             DestinationPort;\r
+} EFI_UDP4_SESSION_DATA;\r
+\r
+//************************************************\r
+//      EFI_UDP4_CONFIG_DATA                     *\r
+//************************************************\r
+typedef struct {\r
+  //Receiving Filters\r
+  BOOLEAN        AcceptBroadcast;\r
+  BOOLEAN        AcceptPromiscuous;\r
+  BOOLEAN        AcceptAnyPort;\r
+  BOOLEAN        AllowDuplicatePort;\r
+  //I/O parameters\r
+  UINT8          TypeOfService;\r
+  UINT8          TimeToLive;\r
+  BOOLEAN        DoNotFragment;\r
+  UINT32         ReceiveTimeout;\r
+  UINT32         TransmitTimeout;\r
+  //Access Point\r
+  BOOLEAN           UseDefaultAddress;\r
+  EFI_IPv4_ADDRESS  StationAddress;\r
+  EFI_IPv4_ADDRESS  SubnetMask;\r
+  UINT16            StationPort;\r
+  EFI_IPv4_ADDRESS  RemoteAddress;\r
+  UINT16            RemotePort;\r
+} EFI_UDP4_CONFIG_DATA;\r
+\r
+//*******************************************************\r
+//               EFI_UDP4_TRANSMIT_DATA                 *\r
+//*******************************************************\r
+typedef struct {\r
+  EFI_UDP4_SESSION_DATA     *UdpSessionData;\r
+  EFI_IPv4_ADDRESS          *GatewayAddress;\r
+  UINT32                    DataLength;\r
+  UINT32                    FragmentCount; \r
+  EFI_UDP4_FRAGMENT_DATA    FragmentTable[1];\r
+} EFI_UDP4_TRANSMIT_DATA;\r
+\r
+//*******************************************************\r
+//           EFI_UDP4_RECEIVE_DATA                      *\r
+//*******************************************************\r
+typedef struct {\r
+  EFI_TIME                  TimeStamp;\r
+  EFI_EVENT                 RecycleSignal;\r
+  EFI_UDP4_SESSION_DATA     UdpSession;\r
+  UINT32                    DataLength;\r
+  UINT32                    FragmentCount;\r
+  EFI_UDP4_FRAGMENT_DATA    FragmentTable[1];\r
+} EFI_UDP4_RECEIVE_DATA;\r
+\r
+\r
+//*******************************************************\r
+//           EFI_UDP4_COMPLETION_TOKEN                  *\r
+//*******************************************************\r
+typedef struct {\r
+  EFI_EVENT                             Event;\r
+  EFI_STATUS                            Status;\r
+  union {\r
+    EFI_UDP4_RECEIVE_DATA               *RxData;\r
+    EFI_UDP4_TRANSMIT_DATA              *TxData;\r
+  }                                     Packet;\r
+} EFI_UDP4_COMPLETION_TOKEN;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_GET_MODE_DATA) (\r
+  IN EFI_UDP4_PROTOCOL                 *This,\r
+  OUT EFI_UDP4_CONFIG_DATA             *Udp4ConfigData OPTIONAL,\r
+  OUT EFI_IP4_MODE_DATA                *Ip4ModeData    OPTIONAL,\r
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL,\r
+  OUT EFI_SIMPLE_NETWORK_MODE          *SnpModeData    OPTIONAL\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_CONFIGURE) (\r
+  IN EFI_UDP4_PROTOCOL     *This,\r
+  IN EFI_UDP4_CONFIG_DATA  *UdpConfigData OPTIONAL\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_GROUPS) (\r
+  IN EFI_UDP4_PROTOCOL  *This,\r
+  IN BOOLEAN            JoinFlag,\r
+  IN EFI_IPv4_ADDRESS   *MulticastAddress OPTIONAL\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_ROUTES) (\r
+  IN EFI_UDP4_PROTOCOL  *This,\r
+  IN BOOLEAN            DeleteRoute,\r
+  IN EFI_IPv4_ADDRESS   *SubnetAddress,\r
+  IN EFI_IPv4_ADDRESS   *SubnetMask,\r
+  IN EFI_IPv4_ADDRESS   *GatewayAddress\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_TRANSMIT) (\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_RECEIVE) (\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_CANCEL)(\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token OPTIONAL\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UDP4_POLL) (\r
+  IN EFI_UDP4_PROTOCOL  *This\r
+);\r
+\r
+typedef struct _EFI_UDP4_PROTOCOL {\r
+  EFI_UDP4_GET_MODE_DATA  GetModeData;\r
+  EFI_UDP4_CONFIGURE      Configure;\r
+  EFI_UDP4_GROUPS         Groups;\r
+  EFI_UDP4_ROUTES         Routes;\r
+  EFI_UDP4_TRANSMIT       Transmit;\r
+  EFI_UDP4_RECEIVE        Receive;\r
+  EFI_UDP4_CANCEL         Cancel;\r
+  EFI_UDP4_POLL           Poll;\r
+} EFI_UDP4_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiUdp4ProtocolGuid;\r
+extern EFI_GUID gEfiUdp4RegistryDataGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c
new file mode 100644 (file)
index 0000000..dfd6ca8
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UgaDraw.c\r
+\r
+Abstract:\r
+\r
+  UGA Draw protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+\r
+EFI_GUID  gEfiUgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUgaDrawProtocolGuid, "UGA Draw Protocol", "EFI 1.1 UGA Draw Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h
new file mode 100644 (file)
index 0000000..cc7ca21
--- /dev/null
@@ -0,0 +1,181 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UgaDraw.h\r
+\r
+Abstract:\r
+\r
+  UGA Draw protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#ifndef __UGA_DRAW_H__\r
+#define __UGA_DRAW_H__\r
+\r
+#define EFI_UGA_DRAW_PROTOCOL_GUID \\r
+  { \\r
+    0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 \\r
+  }\r
+\r
+typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL * This,\r
+  OUT UINT32                *HorizontalResolution,\r
+  OUT UINT32                *VerticalResolution,\r
+  OUT UINT32                *ColorDepth,\r
+  OUT UINT32                *RefreshRate\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    HorizontalResolution  - Current video horizontal resolution in pixels\r
+    VerticalResolution    - Current video vertical resolution in pixels\r
+    ColorDepth            - Current video color depth in bits per pixel\r
+    RefreshRate           - Current video refresh rate in Hz.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+    EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r
+    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL * This,\r
+  IN  UINT32                HorizontalResolution,\r
+  IN  UINT32                VerticalResolution,\r
+  IN  UINT32                ColorDepth,\r
+  IN  UINT32                RefreshRate\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    HorizontalResolution  - Current video horizontal resolution in pixels\r
+    VerticalResolution    - Current video vertical resolution in pixels\r
+    ColorDepth            - Current video color depth in bits per pixel\r
+    RefreshRate           - Current video refresh rate in Hz.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+    EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r
+\r
+--*/\r
+;\r
+\r
+typedef struct {\r
+  UINT8 Blue;\r
+  UINT8 Green;\r
+  UINT8 Red;\r
+  UINT8 Reserved;\r
+} EFI_UGA_PIXEL;\r
+\r
+typedef union {\r
+  EFI_UGA_PIXEL Pixel;\r
+  UINT32        Raw;\r
+} EFI_UGA_PIXEL_UNION;\r
+\r
+typedef enum {\r
+  EfiUgaVideoFill,\r
+  EfiUgaVideoToBltBuffer,\r
+  EfiUgaBltBufferToVideo,\r
+  EfiUgaVideoToVideo,\r
+  EfiUgaBltMax\r
+} EFI_UGA_BLT_OPERATION;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL                   * This,\r
+  IN  EFI_UGA_PIXEL                           * BltBuffer, OPTIONAL\r
+  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+  IN  UINTN                                   SourceX,\r
+  IN  UINTN                                   SourceY,\r
+  IN  UINTN                                   DestinationX,\r
+  IN  UINTN                                   DestinationY,\r
+  IN  UINTN                                   Width,\r
+  IN  UINTN                                   Height,\r
+  IN  UINTN                                   Delta         OPTIONAL\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    The following table defines actions for BltOperations:\r
+    EfiUgaVideoFill - Write data from the  BltBuffer pixel (SourceX, SourceY) \r
+      directly to every pixel of the video display rectangle \r
+      (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+      Only one pixel will be used from the BltBuffer. Delta is NOT used.\r
+    EfiUgaVideoToBltBuffer - Read data from the video display rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in \r
+      the BltBuffer rectangle (DestinationX, DestinationY ) \r
+      (DestinationX + Width, DestinationY + Height). If DestinationX or \r
+      DestinationY is not zero then Delta must be set to the length in bytes \r
+      of a row in the BltBuffer.\r
+    EfiUgaBltBufferToVideo - Write data from the  BltBuffer rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the \r
+      video display rectangle (DestinationX, DestinationY) \r
+      (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is \r
+      not zero then Delta must be set to the length in bytes of a row in the \r
+      BltBuffer.\r
+    EfiUgaVideoToVideo - Copy from the video display rectangle (SourceX, SourceY)\r
+     (SourceX + Width, SourceY + Height) .to the video display rectangle \r
+     (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+     The BltBuffer and Delta  are not used in this mode.\r
+\r
+  Arguments:\r
+    This          - Protocol instance pointer.\r
+    BltBuffer     - Buffer containing data to blit into video buffer. This \r
+                    buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r
+    BltOperation  - Operation to perform on BlitBuffer and video memory\r
+    SourceX       - X coordinate of source for the BltBuffer.\r
+    SourceY       - Y coordinate of source for the BltBuffer.\r
+    DestinationX  - X coordinate of destination for the BltBuffer.\r
+    DestinationY  - Y coordinate of destination for the BltBuffer.\r
+    Width         - Width of rectangle in BltBuffer in pixels.\r
+    Height        - Hight of rectangle in BltBuffer in pixels.\r
+    Delta         -\r
+  \r
+  Returns:\r
+    EFI_SUCCESS           - The Blt operation completed.\r
+    EFI_INVALID_PARAMETER - BltOperation is not valid.\r
+    EFI_DEVICE_ERROR      - A hardware error occured writting to the video \r
+                             buffer.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_UGA_DRAW_PROTOCOL {\r
+  EFI_UGA_DRAW_PROTOCOL_GET_MODE  GetMode;\r
+  EFI_UGA_DRAW_PROTOCOL_SET_MODE  SetMode;\r
+  EFI_UGA_DRAW_PROTOCOL_BLT       Blt;\r
+} EFI_UGA_DRAW_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUgaDrawProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c
new file mode 100644 (file)
index 0000000..1248e5c
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UgaIo.c\r
+\r
+Abstract:\r
+\r
+  UGA IO protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (UgaIo)\r
+\r
+EFI_GUID  gEfiUgaIoProtocolGuid = EFI_UGA_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUgaIoProtocolGuid, "UGA Protocol", "EFI 1.1 UGA Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h
new file mode 100644 (file)
index 0000000..1bfb049
--- /dev/null
@@ -0,0 +1,236 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UgaIo.h\r
+\r
+Abstract:\r
+\r
+  UGA IO protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#ifndef __UGA_IO_H__\r
+#define __UGA_IO_H__\r
+\r
+#define EFI_UGA_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 \\r
+  }\r
+\r
+typedef struct _EFI_UGA_IO_PROTOCOL EFI_UGA_IO_PROTOCOL;\r
+\r
+typedef UINT32                      UGA_STATUS;\r
+\r
+typedef enum {\r
+  UgaDtParentBus          = 1,\r
+  UgaDtGraphicsController,\r
+  UgaDtOutputController,\r
+  UgaDtOutputPort,\r
+  UgaDtOther\r
+}\r
+UGA_DEVICE_TYPE, *PUGA_DEVICE_TYPE;\r
+\r
+typedef UINT32 UGA_DEVICE_ID, *PUGA_DEVICE_ID;\r
+\r
+typedef struct {\r
+  UGA_DEVICE_TYPE deviceType;\r
+  UGA_DEVICE_ID   deviceId;\r
+  UINT32          ui32DeviceContextSize;\r
+  UINT32          ui32SharedContextSize;\r
+}\r
+UGA_DEVICE_DATA, *PUGA_DEVICE_DATA;\r
+\r
+typedef struct _UGA_DEVICE {\r
+  VOID                *pvDeviceContext;\r
+  VOID                *pvSharedContext;\r
+  VOID                *pvRunTimeContext;\r
+  struct _UGA_DEVICE  *pParentDevice;\r
+  VOID                *pvBusIoServices;\r
+  VOID                *pvStdIoServices;\r
+  UGA_DEVICE_DATA     deviceData;\r
+}\r
+UGA_DEVICE, *PUGA_DEVICE;\r
+\r
+#ifndef UGA_IO_REQUEST_CODE\r
+//\r
+// Prevent conflicts with UGA typedefs.\r
+//\r
+typedef enum {\r
+  UgaIoGetVersion             = 1,\r
+  UgaIoGetChildDevice,\r
+  UgaIoStartDevice,\r
+  UgaIoStopDevice,\r
+  UgaIoFlushDevice,\r
+  UgaIoResetDevice,\r
+  UgaIoGetDeviceState,\r
+  UgaIoSetDeviceState,\r
+  UgaIoSetPowerState,\r
+  UgaIoGetMemoryConfiguration,\r
+  UgaIoSetVideoMode,\r
+  UgaIoCopyRectangle,\r
+  UgaIoGetEdidSegment,\r
+  UgaIoDeviceChannelOpen,\r
+  UgaIoDeviceChannelClose,\r
+  UgaIoDeviceChannelRead,\r
+  UgaIoDeviceChannelWrite,\r
+  UgaIoGetPersistentDataSize,\r
+  UgaIoGetPersistentData,\r
+  UgaIoSetPersistentData,\r
+  UgaIoGetDevicePropertySize,\r
+  UgaIoGetDeviceProperty,\r
+  UgaIoBtPrivateInterface\r
+}\r
+UGA_IO_REQUEST_CODE, *PUGA_IO_REQUEST_CODE;\r
+\r
+#endif\r
+\r
+typedef struct {\r
+  IN UGA_IO_REQUEST_CODE  ioRequestCode;\r
+  IN VOID                 *pvInBuffer;\r
+  IN UINT64               ui64InBufferSize;\r
+  OUT VOID                *pvOutBuffer;\r
+  IN UINT64               ui64OutBufferSize;\r
+  OUT UINT64              ui64BytesReturned;\r
+}\r
+UGA_IO_REQUEST, *PUGA_IO_REQUEST;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_IO_PROTOCOL_CREATE_DEVICE) (\r
+  IN  EFI_UGA_IO_PROTOCOL  * This,\r
+  IN  UGA_DEVICE           * ParentDevice,\r
+  IN  UGA_DEVICE_DATA      * DeviceData,\r
+  IN  VOID                 *RunTimeContext,\r
+  OUT UGA_DEVICE           **Device\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Dynamically allocate storage for a child UGA_DEVICE .\r
+\r
+  Arguments:\r
+\r
+    This           - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is \r
+                     defined in Section 10.7.\r
+\r
+    ParentDevice   - ParentDevice specifies a pointer to the parent device of Device.\r
+\r
+    DeviceData     - A pointer to UGA_DEVICE_DATA returned from a call to DispatchService()\r
+                     with a UGA_DEVICE of Parent and an IoRequest of type UgaIoGetChildDevice.\r
+\r
+    RuntimeContext - Context to associate with Device.\r
+\r
+    Device         - The Device returns a dynamically allocated child UGA_DEVICE object\r
+                     for ParentDevice. The caller is responsible for deleting Device.\r
+      \r
+  Returns:\r
+\r
+    EFI_SUCCESS           - Device was returned.\r
+\r
+    EFI_INVALID_PARAMETER - One of the arguments was not valid.\r
+\r
+    EFI_DEVICE_ERROR      - The device had an error and could not complete the request.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_IO_PROTOCOL_DELETE_DEVICE) (\r
+  IN EFI_UGA_IO_PROTOCOL  * This,\r
+  IN UGA_DEVICE           * Device\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Delete a dynamically allocated child UGA_DEVICE object that was allocated via\r
+    CreateDevice() .\r
+\r
+  Arguments:\r
+\r
+    This   - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is defined \r
+             in Section 10.7.\r
+\r
+    Device - The Device points to a UGA_DEVICE object that was dynamically\r
+             allocated via a CreateDevice() call.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS           - Device was deleted.\r
+\r
+    EFI_INVALID_PARAMETER - The Device was not allocated via CreateDevice()\r
+\r
+--*/\r
+typedef UGA_STATUS (EFIAPI *PUGA_FW_SERVICE_DISPATCH) (IN PUGA_DEVICE pDevice, IN OUT PUGA_IO_REQUEST pIoRequest);\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    This is the main UGA service dispatch routine for all UGA_IO_REQUEST s.\r
+\r
+  Arguments:\r
+\r
+    pDevice    - pDevice specifies a pointer to a device object associated with a \r
+                 device enumerated by a pIoRequest->ioRequestCode of type \r
+                 UgaIoGetChildDevice. The root device for the EFI_UGA_IO_PROTOCOL \r
+                 is represented by pDevice being set to NULL.\r
+\r
+    pIoRequest - pIoRequest points to a caller allocated buffer that contains data\r
+                 defined by pIoRequest->ioRequestCode. See Related Definitions for\r
+                 a definition of UGA_IO_REQUEST_CODE s and their associated data \r
+                 structures.\r
+\r
+  Returns:\r
+\r
+  Varies depending on pIoRequest.\r
+\r
+--*/\r
+typedef struct _EFI_UGA_IO_PROTOCOL {\r
+  EFI_UGA_IO_PROTOCOL_CREATE_DEVICE CreateDevice;\r
+  EFI_UGA_IO_PROTOCOL_DELETE_DEVICE DeleteDevice;\r
+  PUGA_FW_SERVICE_DISPATCH          DispatchService;\r
+} EFI_UGA_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUgaIoProtocolGuid;\r
+\r
+//\r
+// Data structure that is stored in the EFI Configuration Table with the\r
+// EFI_UGA_IO_PROTOCOL_GUID.  The option ROMs listed in this table may have\r
+// EBC UGA drivers.\r
+//\r
+typedef struct {\r
+  UINT32  Version;\r
+  UINT32  HeaderSize;\r
+  UINT32  SizeOfEntries;\r
+  UINT32  NumberOfEntries;\r
+} EFI_DRIVER_OS_HANDOFF_HEADER;\r
+\r
+typedef enum {\r
+  EfiUgaDriverFromPciRom,\r
+  EfiUgaDriverFromSystem,\r
+  EfiDriverHandoffMax\r
+} EFI_DRIVER_HANOFF_ENUM;\r
+\r
+typedef struct {\r
+  EFI_DRIVER_HANOFF_ENUM    Type;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  VOID                      *PciRomImage;\r
+  UINT64                    PciRomSize;\r
+} EFI_DRIVER_OS_HANDOFF;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c
new file mode 100644 (file)
index 0000000..e9c3e6c
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnicodeCollation.c\r
+\r
+Abstract:\r
+\r
+  Unicode Collation protocol that follows the EFI 1.0 specification.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation)\r
+\r
+EFI_GUID  gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUnicodeCollationProtocolGuid, "Unicode Collation Protocol", "EFI 1.0 Unicode Collation Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h
new file mode 100644 (file)
index 0000000..0c84796
--- /dev/null
@@ -0,0 +1,211 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnicodeCollation.h\r
+\r
+Abstract:\r
+\r
+  Unicode Collation protocol that follows the EFI 1.0 specification.\r
+\r
+--*/\r
+\r
+#ifndef _UNICODE_COLLATION_H_\r
+#define _UNICODE_COLLATION_H_\r
+\r
+#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \\r
+  { \\r
+    0x1d85cd7f, 0xf43d, 0x11d2, 0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_UNICODE_COLLATION_PROTOCOL);\r
+\r
+//\r
+// Protocol data structures and defines\r
+//\r
+#define EFI_UNICODE_BYTE_ORDER_MARK          ((CHAR16)(0xfeff))\r
+#define EFI_UNICODE_BYTE_ORDER_MARK_REVERSE  ((CHAR16)(0xfffe))\r
+\r
+//\r
+// Protocol member functions\r
+//\r
+typedef\r
+INTN\r
+(EFIAPI *EFI_UNICODE_COLLATION_STRICOLL) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN CHAR16                                 *Str1,\r
+  IN CHAR16                                 *Str2\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Performs a case-insensitive comparison of two Null-terminated Unicode \r
+    strings.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+    Str1 - A pointer to a Null-terminated Unicode string.\r
+    Str2 - A pointer to a Null-terminated Unicode string.\r
+\r
+  Returns:\r
+    0   - Str1 is equivalent to Str2\r
+    > 0 - Str1 is lexically greater than Str2\r
+    < 0 - Str1 is lexically less than Str2\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN CHAR16                                 *String,\r
+  IN CHAR16                                 *Pattern\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Performs a case-insensitive comparison of a Null-terminated Unicode \r
+    pattern string and a Null-terminated Unicode string.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+    String  - A pointer to a Null-terminated Unicode string.\r
+    Pattern - A pointer to a Null-terminated Unicode pattern string.\r
+\r
+  Returns:\r
+    TRUE -  Pattern was found in String.\r
+    FALSE - Pattern was not found in String.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_UNICODE_COLLATION_STRLWR) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN OUT CHAR16                             *Str\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts all the Unicode characters in a Null-terminated Unicode string to \r
+    lower case Unicode characters.\r
+\r
+  Arguments:\r
+    This - Protocol instance pointer.\r
+    String  - A pointer to a Null-terminated Unicode string.\r
+\r
+  Returns:\r
+    NONE\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_UNICODE_COLLATION_STRUPR) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN OUT CHAR16                             *Str\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+   Converts all the Unicode characters in a Null-terminated Unicode string to upper\r
+   case Unicode characters.\r
+  \r
+  Arguments:\r
+    This   - Protocol instance pointer.\r
+    String - A pointer to a Null-terminated Unicode string.\r
+\r
+  Returns:\r
+    NONE\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_UNICODE_COLLATION_FATTOSTR) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN UINTN                                  FatSize,\r
+  IN CHAR8                                  *Fat,\r
+  OUT CHAR16                                *String\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+   Converts an 8.3 FAT file name in an OEM character set to a Null-terminated \r
+   Unicode string.\r
+  \r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    FatSize - The size of the string Fat in bytes.\r
+    Fat     - A pointer to a Null-terminated string that contains an 8.3 file\r
+               name using an OEM character set.\r
+    String  - A pointer to a Null-terminated Unicode string. The string must\r
+               be preallocated to hold FatSize Unicode characters.\r
+  Returns:\r
+    NONE\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_UNICODE_COLLATION_STRTOFAT) (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL         * This,\r
+  IN CHAR16                                 *String,\r
+  IN UINTN                                  FatSize,\r
+  OUT CHAR8                                 *Fat\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts a Null-terminated Unicode string to legal characters in a FAT \r
+    filename using an OEM character set. \r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    String  - A pointer to a Null-terminated Unicode string. The string must\r
+               be preallocated to hold FatSize Unicode characters.\r
+    FatSize - The size of the string Fat in bytes.\r
+    Fat     - A pointer to a Null-terminated string that contains an 8.3 file\r
+               name using an OEM character set.\r
+  Returns:\r
+    TRUE  - Fat is a Long File Name\r
+    FALSE - Fat is an 8.3 file name\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_UNICODE_COLLATION_PROTOCOL {\r
+  //\r
+  // general\r
+  //\r
+  EFI_UNICODE_COLLATION_STRICOLL    StriColl;\r
+  EFI_UNICODE_COLLATION_METAIMATCH  MetaiMatch;\r
+  EFI_UNICODE_COLLATION_STRLWR      StrLwr;\r
+  EFI_UNICODE_COLLATION_STRUPR      StrUpr;\r
+\r
+  //\r
+  // for supporting fat volumes\r
+  //\r
+  EFI_UNICODE_COLLATION_FATTOSTR    FatToStr;\r
+  EFI_UNICODE_COLLATION_STRTOFAT    StrToFat;\r
+\r
+  CHAR8                             *SupportedLanguages;\r
+} EFI_UNICODE_COLLATION_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUnicodeCollationProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c
new file mode 100644 (file)
index 0000000..340a4ca
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UsbHostController.c\r
+\r
+Abstract:\r
+\r
+  USB Host Controller protocol.\r
+\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)\r
+\r
+EFI_GUID  gEfiUsbHcProtocolGuid = EFI_USB_HC_PROTOCOL_GUID;\r
+EFI_GUID  gEfiUsb2HcProtocolGuid = EFI_USB2_HC_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUsbHcProtocolGuid, "Usb Host Controller Protocol", "USB 1.1 Host Controller");\r
+EFI_GUID_STRING(&gEfiUsb2HcProtocolGuid, "Usb2 Host Controller Protocol", "USB 2.0 Host Controller");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h
new file mode 100644 (file)
index 0000000..0061fd9
--- /dev/null
@@ -0,0 +1,411 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UsbHostController.h\r
+\r
+Abstract:\r
+\r
+   \r
+--*/\r
+\r
+#ifndef _USB_HOSTCONTROLLER_H_\r
+#define _USB_HOSTCONTROLLER_H_\r
+\r
+#include "usb.h"\r
+#include EFI_PROTOCOL_DEFINITION (UsbIo)\r
+\r
+#define EFI_USB_HC_PROTOCOL_GUID \\r
+  { \\r
+    0xf5089266, 0x1aa0, 0x4953, 0x97, 0xd8, 0x56, 0x2f, 0x8a, 0x73, 0xb5, 0x19 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_USB_HC_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiUsbHcStateHalt,\r
+  EfiUsbHcStateOperational,\r
+  EfiUsbHcStateSuspend,\r
+  EfiUsbHcStateMaximum\r
+} EFI_USB_HC_STATE;\r
+\r
+#define EFI_USB_HC_RESET_GLOBAL           0x0001\r
+#define EFI_USB_HC_RESET_HOST_CONTROLLER  0x0002\r
+#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG  0x0004\r
+#define EFI_USB_HC_RESET_HOST_WITH_DEBUG  0x0008\r
+\r
+//\r
+// Protocol definitions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_RESET) (\r
+  IN EFI_USB_HC_PROTOCOL    * This,\r
+  IN UINT16                 Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_STATE) (\r
+  IN  EFI_USB_HC_PROTOCOL    * This,\r
+  OUT EFI_USB_HC_STATE       * State\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_STATE) (\r
+  IN EFI_USB_HC_PROTOCOL    * This,\r
+  IN EFI_USB_HC_STATE       State\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL       * This,\r
+  IN     UINT8                     DeviceAddress,\r
+  IN     BOOLEAN                   IsSlowDevice,\r
+  IN     UINT8                     MaximumPacketLength,\r
+  IN     EFI_USB_DEVICE_REQUEST    * Request,\r
+  IN     EFI_USB_DATA_DIRECTION    TransferDirection,\r
+  IN OUT VOID                      *Data OPTIONAL,\r
+  IN OUT UINTN                     *DataLength OPTIONAL,\r
+  IN     UINTN                     TimeOut,\r
+  OUT    UINT32                    *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_BULK_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL    * This,\r
+  IN     UINT8                  DeviceAddress,\r
+  IN     UINT8                  EndPointAddress,\r
+  IN     UINT8                  MaximumPacketLength,\r
+  IN OUT VOID                   *Data,\r
+  IN OUT UINTN                  *DataLength,\r
+  IN OUT UINT8                  *DataToggle,\r
+  IN     UINTN                  TimeOut,\r
+  OUT    UINT32                 *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL                                 * This,\r
+  IN     UINT8                                               DeviceAddress,\r
+  IN     UINT8                                               EndPointAddress,\r
+  IN     BOOLEAN                                             IsSlowDevice,\r
+  IN     UINT8                                               MaxiumPacketLength,\r
+  IN     BOOLEAN                                             IsNewTransfer,\r
+  IN OUT UINT8                                               *DataToggle,\r
+  IN     UINTN                                               PollingInterval  OPTIONAL,\r
+  IN     UINTN                                               DataLength       OPTIONAL,\r
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK                     CallBackFunction OPTIONAL,\r
+  IN     VOID                                                *Context OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL    * This,\r
+  IN     UINT8                  DeviceAddress,\r
+  IN     UINT8                  EndPointAddress,\r
+  IN     BOOLEAN                IsSlowDevice,\r
+  IN     UINT8                  MaximumPacketLength,\r
+  IN OUT VOID                   *Data,\r
+  IN OUT UINTN                  *DataLength,\r
+  IN OUT UINT8                  *DataToggle,\r
+  IN     UINTN                  TimeOut,\r
+  OUT    UINT32                 *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL    * This,\r
+  IN     UINT8                  DeviceAddress,\r
+  IN     UINT8                  EndPointAddress,\r
+  IN     UINT8                  MaximumPacketLength,\r
+  IN OUT VOID                   *Data,\r
+  IN     UINTN                  DataLength,\r
+  OUT    UINT32                 *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) (\r
+  IN     EFI_USB_HC_PROTOCOL                * This,\r
+  IN     UINT8                              DeviceAddress,\r
+  IN     UINT8                              EndPointAddress,\r
+  IN     UINT8                              MaximumPacketLength,\r
+  IN OUT VOID                               *Data,\r
+  IN     UINTN                              DataLength,\r
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK    IsochronousCallBack,\r
+  IN     VOID                               *Context OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER) (\r
+  IN EFI_USB_HC_PROTOCOL    * This,\r
+  OUT UINT8                 *PortNumber\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) (\r
+  IN EFI_USB_HC_PROTOCOL     * This,\r
+  IN  UINT8                  PortNumber,\r
+  OUT EFI_USB_PORT_STATUS    * PortStatus\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) (\r
+  IN EFI_USB_HC_PROTOCOL     * This,\r
+  IN UINT8                   PortNumber,\r
+  IN EFI_USB_PORT_FEATURE    PortFeature\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) (\r
+  IN EFI_USB_HC_PROTOCOL     * This,\r
+  IN UINT8                   PortNumber,\r
+  IN EFI_USB_PORT_FEATURE    PortFeature\r
+  );\r
+\r
+typedef struct _EFI_USB_HC_PROTOCOL {\r
+  EFI_USB_HC_PROTOCOL_RESET                       Reset;\r
+  EFI_USB_HC_PROTOCOL_GET_STATE                   GetState;\r
+  EFI_USB_HC_PROTOCOL_SET_STATE                   SetState;\r
+  EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER            ControlTransfer;\r
+  EFI_USB_HC_PROTOCOL_BULK_TRANSFER               BulkTransfer;\r
+  EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER    AsyncInterruptTransfer;\r
+  EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER     SyncInterruptTransfer;\r
+  EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER        IsochronousTransfer;\r
+  EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER  AsyncIsochronousTransfer;\r
+  EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER     GetRootHubPortNumber;\r
+  EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS     GetRootHubPortStatus;\r
+  EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE    SetRootHubPortFeature;\r
+  EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE  ClearRootHubPortFeature;\r
+  UINT16                                          MajorRevision;\r
+  UINT16                                          MinorRevision;\r
+} EFI_USB_HC_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUsbHcProtocolGuid;\r
+\r
+\r
+#define EFI_USB2_HC_PROTOCOL_GUID \\r
+  { \\r
+    0x3e745226, 0x9818, 0x45b6, 0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_USB2_HC_PROTOCOL);\r
+\r
+#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004\r
+#define EFI_USB_HC_RESET_HOST_WITH_DEBUG   0x0008\r
+\r
+typedef struct {\r
+  UINT8      TranslatorHubAddress;\r
+  UINT8      TranslatorPortNumber;\r
+} EFI_USB2_HC_TRANSACTION_TRANSLATOR;\r
+\r
+//\r
+// Protocol definitions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY) (\r
+  IN  EFI_USB2_HC_PROTOCOL  *This,\r
+  OUT UINT8                 *MaxSpeed,\r
+  OUT UINT8                 *PortNumber,\r
+  OUT UINT8                 *Is64BitCapable\r
+  );\r
+\r
+#define EFI_USB_SPEED_FULL 0x0000\r
+#define EFI_USB_SPEED_LOW  0x0001\r
+#define EFI_USB_SPEED_HIGH 0x0002\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_RESET) (\r
+  IN EFI_USB2_HC_PROTOCOL   *This,\r
+  IN UINT16                 Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE) (\r
+  IN  EFI_USB2_HC_PROTOCOL    *This,\r
+  OUT EFI_USB_HC_STATE        *State\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE) (\r
+  IN EFI_USB2_HC_PROTOCOL    *This,\r
+  IN EFI_USB_HC_STATE        State\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL               *This,\r
+  IN     UINT8                              DeviceAddress,\r
+  IN     UINT8                              DeviceSpeed,\r
+  IN     UINTN                              MaximumPacketLength,\r
+  IN     EFI_USB_DEVICE_REQUEST             *Request,\r
+  IN     EFI_USB_DATA_DIRECTION             TransferDirection,\r
+  IN OUT VOID                               *Data       OPTIONAL,\r
+  IN OUT UINTN                              *DataLength OPTIONAL,\r
+  IN     UINTN                              TimeOut,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  OUT    UINT32                             *TransferResult\r
+  );\r
+\r
+#define EFI_USB_MAX_BULK_BUFFER_NUM 10\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL               *This,\r
+  IN     UINT8                              DeviceAddress,\r
+  IN     UINT8                              EndPointAddress,\r
+  IN     UINT8                              DeviceSpeed,\r
+  IN     UINTN                              MaximumPacketLength,\r
+  IN     UINT8                              DataBuffersNumber,\r
+  IN OUT VOID                               *Data[EFI_USB_MAX_BULK_BUFFER_NUM],\r
+  IN OUT UINTN                              *DataLength,\r
+  IN OUT UINT8                              *DataToggle,\r
+  IN     UINTN                              TimeOut,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  OUT    UINT32                             *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL                                *This,\r
+  IN     UINT8                                               DeviceAddress,\r
+  IN     UINT8                                               EndPointAddress,\r
+  IN     UINT8                                               DeviceSpeed,\r
+  IN     UINTN                                               MaxiumPacketLength,\r
+  IN     BOOLEAN                                             IsNewTransfer,\r
+  IN OUT UINT8                                               *DataToggle,\r
+  IN     UINTN                                               PollingInterval  OPTIONAL,\r
+  IN     UINTN                                               DataLength       OPTIONAL,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK                     CallBackFunction OPTIONAL,\r
+  IN     VOID                                                *Context         OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL   *This,\r
+  IN     UINT8                  DeviceAddress,\r
+  IN     UINT8                  EndPointAddress,\r
+  IN     UINT8                  DeviceSpeed,\r
+  IN     UINTN                  MaximumPacketLength,\r
+  IN OUT VOID                   *Data,\r
+  IN OUT UINTN                  *DataLength,\r
+  IN OUT UINT8                  *DataToggle,\r
+  IN     UINTN                  TimeOut,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  OUT    UINT32                 *TransferResult\r
+  );\r
+\r
+#define EFI_USB_MAX_ISO_BUFFER_NUM  7\r
+#define EFI_USB_MAX_ISO_BUFFER_NUM1 2\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL               *This,\r
+  IN     UINT8                              DeviceAddress,\r
+  IN     UINT8                              EndPointAddress,\r
+  IN     UINT8                              DeviceSpeed,\r
+  IN     UINTN                              MaximumPacketLength,\r
+  IN     UINT8                              DataBuffersNumber,\r
+  IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
+  IN     UINTN                              DataLength,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  OUT    UINT32                             *TransferResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) (\r
+  IN     EFI_USB2_HC_PROTOCOL               *This,\r
+  IN     UINT8                              DeviceAddress,\r
+  IN     UINT8                              EndPointAddress,\r
+  IN     UINT8                              DeviceSpeed,\r
+  IN     UINTN                              MaximumPacketLength,\r
+  IN     UINT8                              DataBuffersNumber,\r
+  IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],\r
+  IN     UINTN                              DataLength,\r
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,\r
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK    IsochronousCallBack,\r
+  IN     VOID                               *Context OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) (\r
+  IN EFI_USB2_HC_PROTOCOL    *This,\r
+  IN  UINT8                  PortNumber,\r
+  OUT EFI_USB_PORT_STATUS    *PortStatus\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) (\r
+  IN EFI_USB2_HC_PROTOCOL    *This,\r
+  IN UINT8                   PortNumber,\r
+  IN EFI_USB_PORT_FEATURE    PortFeature\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) (\r
+  IN EFI_USB2_HC_PROTOCOL    *This,\r
+  IN UINT8                   PortNumber,\r
+  IN EFI_USB_PORT_FEATURE    PortFeature\r
+  );\r
+\r
+typedef struct _EFI_USB2_HC_PROTOCOL {\r
+  EFI_USB2_HC_PROTOCOL_GET_CAPABILITY              GetCapability;\r
+  EFI_USB2_HC_PROTOCOL_RESET                       Reset;\r
+  EFI_USB2_HC_PROTOCOL_GET_STATE                   GetState;\r
+  EFI_USB2_HC_PROTOCOL_SET_STATE                   SetState;\r
+  EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER            ControlTransfer;\r
+  EFI_USB2_HC_PROTOCOL_BULK_TRANSFER               BulkTransfer;\r
+  EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER    AsyncInterruptTransfer;\r
+  EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER     SyncInterruptTransfer;\r
+  EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER        IsochronousTransfer;\r
+  EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER  AsyncIsochronousTransfer;\r
+  EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS     GetRootHubPortStatus;\r
+  EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE    SetRootHubPortFeature;\r
+  EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE  ClearRootHubPortFeature;\r
+  UINT16                                           MajorRevision;\r
+  UINT16                                           MinorRevision;\r
+} EFI_USB2_HC_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUsb2HcProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c
new file mode 100644 (file)
index 0000000..d28e327
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    UsbIo.c\r
+    \r
+Abstract:\r
+\r
+    EFI Usb I/O Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (UsbIo)\r
+\r
+EFI_GUID  gEfiUsbIoProtocolGuid = EFI_USB_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUsbIoProtocolGuid, "Usb IO Protocol", "EFI 1.1 Usb IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h
new file mode 100644 (file)
index 0000000..41c0ccb
--- /dev/null
@@ -0,0 +1,205 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    UsbIo.h\r
+\r
+Abstract:\r
+\r
+    EFI Usb I/O Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_USB_IO_H\r
+#define _EFI_USB_IO_H\r
+\r
+#include "usb.h"\r
+\r
+//\r
+// Global ID for the USB I/O Protocol\r
+//\r
+#define EFI_USB_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x2B2F68D6, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_USB_IO_PROTOCOL);\r
+\r
+//\r
+//  Asynchronous USB transfer call back function\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ASYNC_USB_TRANSFER_CALLBACK) (\r
+  IN VOID         *Data,\r
+  IN UINTN        DataLength,\r
+  IN VOID         *Context,\r
+  IN UINT32       Status\r
+  );\r
+\r
+//\r
+// Prototype for EFI USB I/O protocol\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_CONTROL_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL                        * This,\r
+  IN EFI_USB_DEVICE_REQUEST                     * Request,\r
+  IN EFI_USB_DATA_DIRECTION                     Direction,\r
+  IN UINT32                                     Timeout,\r
+  IN OUT VOID                                   *Data OPTIONAL,\r
+  IN UINTN                                      DataLength  OPTIONAL,\r
+  OUT UINT32                                    *Status\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_BULK_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  IN UINT8                          DeviceEndpoint,\r
+  IN OUT VOID                       *Data,\r
+  IN OUT UINTN                      *DataLength,\r
+  IN UINTN                          Timeout,\r
+  OUT UINT32                        *Status\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL                                 * This,\r
+  IN UINT8                                               DeviceEndpoint,\r
+  IN BOOLEAN                                             IsNewTransfer,\r
+  IN UINTN                                               PollingInterval    OPTIONAL,\r
+  IN UINTN                                               DataLength         OPTIONAL,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK                     InterruptCallBack  OPTIONAL,\r
+  IN VOID                                                *Context OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_SYNC_INTERRUPT_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  IN     UINT8                      DeviceEndpoint,\r
+  IN OUT VOID                       *Data,\r
+  IN OUT UINTN                      *DataLength,\r
+  IN     UINTN                      Timeout,\r
+  OUT    UINT32                     *Status\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_ISOCHRONOUS_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  IN     UINT8                      DeviceEndpoint,\r
+  IN OUT VOID                       *Data,\r
+  IN     UINTN                      DataLength,\r
+  OUT    UINT32                     *Status\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER) (\r
+  IN EFI_USB_IO_PROTOCOL              * This,\r
+  IN UINT8                            DeviceEndpoint,\r
+  IN OUT VOID                         *Data,\r
+  IN     UINTN                        DataLength,\r
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK  IsochronousCallBack,\r
+  IN VOID                             *Context OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_PORT_RESET) (\r
+  IN EFI_USB_IO_PROTOCOL    * This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_DEVICE_DESCRIPTOR) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  OUT EFI_USB_DEVICE_DESCRIPTOR     * DeviceDescriptor\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_CONFIG_DESCRIPTOR) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  OUT EFI_USB_CONFIG_DESCRIPTOR     * ConfigurationDescriptor\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_INTERFACE_DESCRIPTOR) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  OUT EFI_USB_INTERFACE_DESCRIPTOR  * InterfaceDescriptor\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  IN  UINT8                         EndpointIndex,\r
+  OUT EFI_USB_ENDPOINT_DESCRIPTOR   * EndpointDescriptor\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_STRING_DESCRIPTOR) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  IN  UINT16                        LangID,\r
+  IN  UINT8                         StringID,\r
+  OUT CHAR16                        **String\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_IO_GET_SUPPORTED_LANGUAGE) (\r
+  IN EFI_USB_IO_PROTOCOL            * This,\r
+  OUT UINT16                        **LangIDTable,\r
+  OUT UINT16                        *TableSize\r
+  );\r
+\r
+//\r
+//  Protocol Interface Structure\r
+//\r
+typedef struct _EFI_USB_IO_PROTOCOL {\r
+  //\r
+  // IO transfer\r
+  //\r
+  EFI_USB_IO_CONTROL_TRANSFER           UsbControlTransfer;\r
+  EFI_USB_IO_BULK_TRANSFER              UsbBulkTransfer;\r
+  EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER   UsbAsyncInterruptTransfer;\r
+  EFI_USB_IO_SYNC_INTERRUPT_TRANSFER    UsbSyncInterruptTransfer;\r
+  EFI_USB_IO_ISOCHRONOUS_TRANSFER       UsbIsochronousTransfer;\r
+  EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER UsbAsyncIsochronousTransfer;\r
+\r
+  //\r
+  // Common device request\r
+  //\r
+  EFI_USB_IO_GET_DEVICE_DESCRIPTOR      UsbGetDeviceDescriptor;\r
+  EFI_USB_IO_GET_CONFIG_DESCRIPTOR      UsbGetConfigDescriptor;\r
+  EFI_USB_IO_GET_INTERFACE_DESCRIPTOR   UsbGetInterfaceDescriptor;\r
+  EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR    UsbGetEndpointDescriptor;\r
+  EFI_USB_IO_GET_STRING_DESCRIPTOR      UsbGetStringDescriptor;\r
+  EFI_USB_IO_GET_SUPPORTED_LANGUAGE     UsbGetSupportedLanguages;\r
+\r
+  //\r
+  // Reset controller's parent port\r
+  //\r
+  EFI_USB_IO_PORT_RESET                 UsbPortReset;\r
+} EFI_USB_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUsbIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c
new file mode 100644 (file)
index 0000000..5680f0a
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiTableStorage.c\r
+    \r
+Abstract:\r
+\r
+  The filename of the Acpi table storage file.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (AcpiTableStorage)\r
+\r
+EFI_GUID gEfiAcpiTableStorageGuid = EFI_ACPI_TABLE_STORAGE_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiAcpiTableStorageGuid, "ACPI Table Storage File Name", \r
+                "Tiano ACPI 2.0 Table Storage file name GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h
new file mode 100644 (file)
index 0000000..b424671
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiTableStorage.h\r
+    \r
+Abstract:\r
+\r
+  GUID for the ACPI Table Storage filename.\r
+\r
+  This GUID is defined in the Tiano ACPI Table Storage EPS.\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_TABLE_STORAGE_H_\r
+#define _ACPI_TABLE_STORAGE_H_\r
+\r
+#define EFI_ACPI_TABLE_STORAGE_GUID \\r
+  { 0x7e374e25, 0x8e01, 0x4fee, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd }\r
+\r
+extern EFI_GUID gEfiAcpiTableStorageGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c
new file mode 100644 (file)
index 0000000..b7b9feb
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Apriori.c\r
+    \r
+Abstract:\r
+\r
+  GUID used as an FV filename for A Priori file. The A Priori file contains a\r
+  list of FV filenames that the DXE dispatcher will schedule reguardless of\r
+  the dependency grammer.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (Apriori)\r
+\r
+EFI_GUID  gAprioriGuid = EFI_APRIORI_GUID;\r
+\r
+EFI_GUID_STRING(&gAprioriGuid, "Apriori File Name", "Apriori File containing FV GUIDs");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h
new file mode 100644 (file)
index 0000000..5cf5d51
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Apriori.h\r
+    \r
+Abstract:\r
+\r
+  GUID used as an FV filename for A Priori file. The A Priori file contains a\r
+  list of FV filenames that the DXE dispatcher will schedule reguardless of\r
+  the dependency grammer.\r
+\r
+--*/\r
+\r
+#ifndef _APRIORI_GUID_H_\r
+#define _APRIORI_GUID_H_\r
+\r
+#define EFI_APRIORI_GUID \\r
+  { \\r
+    0xfc510ee7, 0xffdc, 0x11d4, 0xbd, 0x41, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gAprioriGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c
new file mode 100644 (file)
index 0000000..2a97b1e
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DataHubRecords.c\r
+\r
+Abstract:\r
+\r
+    This file defines GUIDs and associated data structures for records \r
+    posted to the Data Hub. \r
+    The producers of these records use these definitions to construct \r
+    records.\r
+    The consumers of these records use these definitions to retrieve,\r
+    filter and parse records.\r
+\r
+    For more information please look at DataHub.doc\r
+\r
+--*/\r
+\r
+\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (DataHubRecords)\r
+\r
+EFI_GUID gProcessorProducerGuid = EFI_PROCESSOR_PRODUCER_GUID;\r
+\r
+EFI_GUID gProcessorSubClassName = EFI_PROCESSOR_SUBCLASS_GUID;\r
+\r
+EFI_GUID gCacheSubClassName     = EFI_CACHE_SUBCLASS_GUID;\r
+\r
+EFI_GUID gMiscProducerGuid      = EFI_MISC_PRODUCER_GUID;\r
+EFI_GUID gMiscSubClassName      = EFI_MISC_SUBCLASS_GUID;\r
+EFI_GUID gEfiMiscSubClassGuid   = EFI_MISC_SUBCLASS_GUID;\r
+\r
+\r
+EFI_GUID gMemoryProducerGuid    = EFI_MEMORY_PRODUCER_GUID;\r
+\r
+EFI_GUID  gEfiMemorySubClassGuid = EFI_MEMORY_SUBCLASS_GUID;\r
+\r
+\r
+\r
+/* eof - DataHubRecords.c */\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h
new file mode 100644 (file)
index 0000000..baaf181
--- /dev/null
@@ -0,0 +1,109 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DataHubRecords.h\r
+\r
+Abstract:\r
+\r
+    This file defines GUIDs and associated data structures for records \r
+    posted to the Data Hub. \r
+    The producers of these records use these definitions to construct \r
+    records.\r
+    The consumers of these records use these definitions to retrieve,\r
+    filter and parse records.\r
+\r
+    For more information please look at DataHub.doc\r
+\r
+--*/\r
+\r
+#ifndef _DATAHUB_RECORDS_H_\r
+#define _DATAHUB_RECORDS_H_\r
+\r
+\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "DataHubSubClass.h"\r
+#include "DataHubSubClassProcessor.h"\r
+#include "DataHubSubClassCache.h"\r
+#include "DataHubSubClassMemory.h"\r
+#include "DataHubSubClassMisc.h"\r
+\r
+/*++\r
+BEGIN: Processor records definitions\r
+--*/\r
+\r
+extern  EFI_GUID gProcessorProducerGuid;\r
+\r
+#define EFI_PROCESSOR_PRODUCER_GUID \\r
+  { 0x1bf06aea, 0x5bec, 0x4a8d, 0x95, 0x76, 0x74, 0x9b, 0x09, 0x56, 0x2d, 0x30 }\r
+\r
+\r
+extern  EFI_GUID gProcessorSubClassName;\r
+\r
+\r
+extern  EFI_GUID gCacheSubClassName;\r
+\r
+\r
+extern  EFI_GUID gMiscSubClassName;\r
+\r
+/*++\r
+END: Processor records definitions\r
+--*/\r
+\r
+\r
+\r
+/*++\r
+BEGIN: Memory records definitions\r
+--*/\r
+\r
+extern  EFI_GUID gMemoryProducerGuid;\r
+\r
+#define EFI_MEMORY_PRODUCER_GUID \\r
+  { 0x1d7add6e, 0xb2da, 0x4b0b, 0xb2, 0x9f, 0x49, 0xcb, 0x42, 0xf4, 0x63, 0x56 }\r
+\r
+//\r
+// ... need memory sub classes here...\r
+//\r
+extern EFI_GUID  gEfiMemorySubClassGuid;\r
+\r
+\r
+\r
+/*++\r
+END: Memory records definitions\r
+--*/\r
+\r
+\r
+/*++\r
+BEGIN: Misc records definitions\r
+--*/\r
+\r
+extern  EFI_GUID gMiscProducerGuid;\r
+\r
+#define EFI_MISC_PRODUCER_GUID \\r
+{ 0x62512c92, 0x63c4, 0x4d80, 0x82, 0xb1, 0xc1, 0xa4, 0xdc, 0x44, 0x80, 0xe5 } \r
+\r
+\r
+\r
+//\r
+// ... need misc sub classes here...\r
+//\r
+extern EFI_GUID  gEfiMiscSubClassGuid;\r
+\r
+\r
+\r
+\r
+/*++\r
+END: Misc records definitions\r
+--*/\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h
new file mode 100644 (file)
index 0000000..19b3c38
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHubSubClass.h\r
+    \r
+Abstract:\r
+\r
+  Definitions for data hub data records that contains a sub class header\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DATA_HUB_SUBCLASS_H_\r
+#define _DATA_HUB_SUBCLASS_H_\r
+\r
+//\r
+// Sub Class Header type1\r
+//\r
+\r
+#define EFI_SUBCLASS_INSTANCE_RESERVED       0\r
+#define EFI_SUBCLASS_INSTANCE_NON_APPLICABLE 0xFFFF  //16 bit\r
+\r
+typedef struct {\r
+  UINT32    Version;\r
+  UINT32    HeaderSize;\r
+  UINT16    Instance;\r
+  UINT16    SubInstance;\r
+  UINT32    RecordType;    \r
+} EFI_SUBCLASS_TYPE1_HEADER;\r
+\r
+//\r
+// EXP data\r
+//\r
+\r
+typedef struct {\r
+  INT16     Value;\r
+  INT16     Exponent;\r
+} EFI_EXP_BASE10_DATA;\r
+\r
+typedef struct {\r
+  UINT16    Value;\r
+  UINT16    Exponent;\r
+} EFI_EXP_BASE2_DATA;\r
+\r
+//\r
+// Inter link data that references another data record\r
+//\r
+\r
+typedef struct {\r
+  EFI_GUID    ProducerName;\r
+  UINT16      Instance;\r
+  UINT16      SubInstance;\r
+} EFI_INTER_LINK_DATA;\r
+\r
+\r
+//\r
+// String Token Definition\r
+//\r
+#define EFI_STRING_TOKEN    UINT16\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h
new file mode 100644 (file)
index 0000000..0e7ed32
--- /dev/null
@@ -0,0 +1,151 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHubSubClassCache.h\r
+    \r
+Abstract:\r
+\r
+  Definitions for Cache sub class data records\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DATAHUB_SUBCLASS_CACHE_H_\r
+#define _DATAHUB_SUBCLASS_CACHE_H_\r
+\r
+#define EFI_CACHE_SUBCLASS_VERSION    0x00010000\r
+\r
+#define EFI_CACHE_SUBCLASS_GUID \\r
+{ 0x7f0013a7, 0xdc79, 0x4b22, 0x80, 0x99, 0x11, 0xf7, 0x5f, 0xdc, 0x82, 0x9d }\r
+\r
+typedef EFI_EXP_BASE2_DATA  EFI_CACHE_SIZE_DATA;\r
+\r
+typedef EFI_EXP_BASE2_DATA  EFI_MAXIMUM_CACHE_SIZE_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA EFI_CACHE_SPEED_DATA;\r
+\r
+typedef STRING_REF  EFI_CACHE_SOCKET_DATA;\r
+\r
+typedef struct {\r
+  UINT32  Other     :1;\r
+  UINT32  Unknown   :1;\r
+  UINT32  NonBurst    :1;\r
+  UINT32  Burst     :1;\r
+  UINT32  PipelineBurst :1;\r
+  UINT32  Asynchronous  :1;\r
+  UINT32  Synchronous :1;\r
+  UINT32  Reserved    :25;\r
+} EFI_CACHE_SRAM_TYPE_DATA;\r
+\r
+typedef enum {  \r
+  EfiCacheErrorOther = 1,\r
+  EfiCacheErrorUnknown = 2,\r
+  EfiCacheErrorNone = 3,\r
+  EfiCacheErrorParity = 4,\r
+  EfiCacheErrorSingleBit = 5,\r
+  EfiCacheErrorMultiBit = 6\r
+} EFI_CACHE_ERROR_TYPE_DATA;\r
+\r
+typedef enum {  \r
+  EfiCacheTypeOther = 1,\r
+  EfiCacheTypeUnknown = 2,\r
+  EfiCacheTypeInstruction = 3,\r
+  EfiCacheTypeData = 4,\r
+  EfiCacheTypeUnified = 5\r
+} EFI_CACHE_TYPE_DATA;\r
+\r
+typedef enum {  \r
+  EfiCacheAssociativityOther = 1,\r
+  EfiCacheAssociativityUnknown = 2,\r
+  EfiCacheAssociativityDirectMapped = 3,\r
+  EfiCacheAssociativity2Way = 4,\r
+  EfiCacheAssociativity4Way = 5,\r
+  EfiCacheAssociativityFully = 6,\r
+  EfiCacheAssociativity8Way = 7,\r
+  EfiCacheAssociativity16Way = 8\r
+} EFI_CACHE_ASSOCIATIVITY_DATA;\r
+\r
+typedef struct {  \r
+  UINT32    Level       :3;\r
+  UINT32    Socketed    :1;\r
+  UINT32    Reserved2   :1;\r
+  UINT32    Location    :2;\r
+  UINT32    Enable      :1;\r
+  UINT32    OperationalMode :2;\r
+  UINT32    Reserved1   :22;\r
+} EFI_CACHE_CONFIGURATION_DATA;\r
+\r
+#define EFI_CACHE_L1      1\r
+#define EFI_CACHE_L2      2\r
+#define EFI_CACHE_L3      3\r
+#define EFI_CACHE_L4      4\r
+#define EFI_CACHE_LMAX    EFI_CACHE_L4\r
+\r
+#define EFI_CACHE_SOCKETED      1\r
+#define EFI_CACHE_NOT_SOCKETED  0\r
+\r
+typedef enum {\r
+  EfiCacheInternal = 0,\r
+  EfiCacheExternal = 1,\r
+  EfiCacheReserved = 2,\r
+  EfiCacheUnknown  = 3\r
+} EFI_CACHE_LOCATION;\r
+  \r
+#define EFI_CACHE_ENABLED    1\r
+#define EFI_CACHE_DISABLED   0\r
+\r
+typedef enum {\r
+  EfiCacheWriteThrough = 0,\r
+  EfiCacheWriteBack    = 1,\r
+  EfiCacheDynamicMode  = 2,\r
+  EfiCacheUnknownMode  = 3\r
+} EFI_CACHE_OPERATIONAL_MODE;\r
+\r
+\r
+\r
+typedef enum {\r
+  CacheSizeRecordType = 1,\r
+  MaximumSizeCacheRecordType = 2,\r
+  CacheSpeedRecordType = 3,\r
+  CacheSocketRecordType = 4,\r
+  CacheSramTypeRecordType = 5,\r
+  CacheInstalledSramTypeRecordType = 6,\r
+  CacheErrorTypeRecordType = 7,\r
+  CacheTypeRecordType = 8,\r
+  CacheAssociativityRecordType = 9,\r
+  CacheConfigRecordType = 10\r
+} EFI_CACHE_VARIABLE_RECORD_TYPE;\r
+\r
+\r
+typedef union {\r
+  EFI_CACHE_SIZE_DATA             CacheSize;\r
+  EFI_MAXIMUM_CACHE_SIZE_DATA     MaximumCacheSize;\r
+  EFI_CACHE_SPEED_DATA            CacheSpeed;\r
+  EFI_CACHE_SOCKET_DATA           CacheSocket;\r
+  EFI_CACHE_SRAM_TYPE_DATA        CacheSramType;\r
+  EFI_CACHE_SRAM_TYPE_DATA        CacheInstalledSramType;\r
+  EFI_CACHE_ERROR_TYPE_DATA       CacheErrorType;\r
+  EFI_CACHE_TYPE_DATA             CacheType;\r
+  EFI_CACHE_ASSOCIATIVITY_DATA    CacheAssociativity;\r
+  EFI_CACHE_CONFIGURATION_DATA    CacheConfig;\r
+  EFI_CACHE_ASSOCIATION_DATA      CacheAssociation;\r
+} EFI_CACHE_VARIABLE_RECORD;\r
+\r
+typedef struct {\r
+   EFI_SUBCLASS_TYPE1_HEADER      DataRecordHeader;\r
+   EFI_CACHE_VARIABLE_RECORD      VariableRecord;  \r
+} EFI_CACHE_DATA_RECORD;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
new file mode 100644 (file)
index 0000000..2ab6743
--- /dev/null
@@ -0,0 +1,408 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHubSubClassMemory.h\r
+    \r
+Abstract:\r
+\r
+  Definitions for memory sub class data records\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DATAHUB_SUBCLASS_MEMORY_H_\r
+#define _DATAHUB_SUBCLASS_MEMORY_H_\r
+\r
+#include EFI_GUID_DEFINITION (DataHubRecords)\r
+\r
+\r
+#define EFI_MEMORY_SUBCLASS_GUID \\r
+  {0x4E8F4EBB, 0x64B9, 0x4e05, 0x9B, 0x18, 0x4C, 0xFE, 0x49, 0x23, 0x50, 0x97}\r
+  \r
+#define EFI_MEMORY_SUBCLASS_VERSION     0x0100\r
+\r
+\r
+#define EFI_MEMORY_SIZE_RECORD_NUMBER                 0x00000001\r
+\r
+typedef enum _EFI_MEMORY_REGION_TYPE {\r
+  EfiMemoryRegionMemory                       = 0x01,\r
+  EfiMemoryRegionReserved                     = 0x02,\r
+  EfiMemoryRegionAcpi                         = 0x03,\r
+  EfiMemoryRegionNvs                          = 0x04\r
+} EFI_MEMORY_REGION_TYPE;\r
+\r
+typedef struct {\r
+  UINT32                      ProcessorNumber;\r
+  UINT16                      StartBusNumber;\r
+  UINT16                      EndBusNumber;\r
+  EFI_MEMORY_REGION_TYPE      MemoryRegionType;\r
+  EFI_EXP_BASE2_DATA          MemorySize;\r
+  EFI_PHYSICAL_ADDRESS        MemoryStartAddress;\r
+} EFI_MEMORY_SIZE_DATA;\r
+\r
+\r
+#define EFI_MEMORY_ARRAY_LOCATION_RECORD_NUMBER       0x00000002\r
+\r
+typedef enum _EFI_MEMORY_ARRAY_LOCATION {\r
+  EfiMemoryArrayLocationOther                 = 0x01,\r
+  EfiMemoryArrayLocationUnknown               = 0x02,\r
+  EfiMemoryArrayLocationSystemBoard           = 0x03,\r
+  EfiMemoryArrayLocationIsaAddonCard          = 0x04,\r
+  EfiMemoryArrayLocationEisaAddonCard         = 0x05,\r
+  EfiMemoryArrayLocationPciAddonCard          = 0x06,\r
+  EfiMemoryArrayLocationMcaAddonCard          = 0x07,\r
+  EfiMemoryArrayLocationPcmciaAddonCard       = 0x08,\r
+  EfiMemoryArrayLocationProprietaryAddonCard  = 0x09,\r
+  EfiMemoryArrayLocationNuBus                 = 0x0A,\r
+  EfiMemoryArrayLocationPc98C20AddonCard      = 0xA0,\r
+  EfiMemoryArrayLocationPc98C24AddonCard      = 0xA1,\r
+  EfiMemoryArrayLocationPc98EAddonCard        = 0xA2,\r
+  EfiMemoryArrayLocationPc98LocalBusAddonCard = 0xA3\r
+} EFI_MEMORY_ARRAY_LOCATION;\r
+\r
+typedef enum _EFI_MEMORY_ARRAY_USE {\r
+  EfiMemoryArrayUseOther                      = 0x01,\r
+  EfiMemoryArrayUseUnknown                    = 0x02,\r
+  EfiMemoryArrayUseSystemMemory               = 0x03,\r
+  EfiMemoryArrayUseVideoMemory                = 0x04,\r
+  EfiMemoryArrayUseFlashMemory                = 0x05,\r
+  EfiMemoryArrayUseNonVolatileRam             = 0x06,\r
+  EfiMemoryArrayUseCacheMemory                = 0x07,\r
+} EFI_MEMORY_ARRAY_USE;\r
+\r
+typedef enum _EFI_MEMORY_ERROR_CORRECTION {\r
+  EfiMemoryErrorCorrectionOther               = 0x01,\r
+  EfiMemoryErrorCorrectionUnknown             = 0x02,\r
+  EfiMemoryErrorCorrectionNone                = 0x03,\r
+  EfiMemoryErrorCorrectionParity              = 0x04,\r
+  EfiMemoryErrorCorrectionSingleBitEcc        = 0x05,\r
+  EfiMemoryErrorCorrectionMultiBitEcc         = 0x06,\r
+  EfiMemoryErrorCorrectionCrc                 = 0x07,\r
+} EFI_MEMORY_ERROR_CORRECTION;\r
+\r
+typedef struct {\r
+  EFI_MEMORY_ARRAY_LOCATION   MemoryArrayLocation;\r
+  EFI_MEMORY_ARRAY_USE        MemoryArrayUse;\r
+  EFI_MEMORY_ERROR_CORRECTION MemoryErrorCorrection;\r
+  UINT32                      MaximumMemoryCapacity;\r
+  UINT16                      NumberMemoryDevices;\r
+} EFI_MEMORY_ARRAY_LOCATION_DATA;\r
+\r
+\r
+#define EFI_MEMORY_ARRAY_LINK_RECORD_NUMBER           0x00000003\r
+\r
+typedef enum _EFI_MEMORY_FORM_FACTOR {\r
+  EfiMemoryFormFactorOther                    = 0x01,\r
+  EfiMemoryFormFactorUnknown                  = 0x02,\r
+  EfiMemoryFormFactorSimm                     = 0x03,\r
+  EfiMemoryFormFactorSip                      = 0x04,\r
+  EfiMemoryFormFactorChip                     = 0x05,\r
+  EfiMemoryFormFactorDip                      = 0x06,\r
+  EfiMemoryFormFactorZip                      = 0x07,\r
+  EfiMemoryFormFactorProprietaryCard          = 0x08,\r
+  EfiMemoryFormFactorDimm                     = 0x09,\r
+  EfiMemoryFormFactorTsop                     = 0x0A,\r
+  EfiMemoryFormFactorRowOfChips               = 0x0B,\r
+  EfiMemoryFormFactorRimm                     = 0x0C,\r
+  EfiMemoryFormFactorSodimm                   = 0x0D,\r
+  EfiMemoryFormFactorSrimm                    = 0x0E,\r
+  EfiMemoryFormFactorFbDimm                   = 0x0F\r
+} EFI_MEMORY_FORM_FACTOR;\r
+\r
+typedef enum _EFI_MEMORY_ARRAY_TYPE {\r
+  EfiMemoryTypeOther                          = 0x01,\r
+  EfiMemoryTypeUnknown                        = 0x02,\r
+  EfiMemoryTypeDram                           = 0x03,\r
+  EfiMemoryTypeEdram                          = 0x04,\r
+  EfiMemoryTypeVram                           = 0x05,\r
+  EfiMemoryTypeSram                           = 0x06,\r
+  EfiMemoryTypeRam                            = 0x07,\r
+  EfiMemoryTypeRom                            = 0x08,\r
+  EfiMemoryTypeFlash                          = 0x09,\r
+  EfiMemoryTypeEeprom                         = 0x0A,\r
+  EfiMemoryTypeFeprom                         = 0x0B,\r
+  EfiMemoryTypeEprom                          = 0x0C,\r
+  EfiMemoryTypeCdram                          = 0x0D,\r
+  EfiMemoryType3Dram                          = 0x0E,\r
+  EfiMemoryTypeSdram                          = 0x0F,\r
+  EfiMemoryTypeSgram                          = 0x10,\r
+  EfiMemoryTypeRdram                          = 0x11,\r
+  EfiMemoryTypeDdr                            = 0x12,\r
+  EfiMemoryTypeDdr2                           = 0x13,\r
+  EfiMemoryTypeDdr2FbDimm                     = 0x14\r
+} EFI_MEMORY_ARRAY_TYPE;\r
+\r
+typedef struct {\r
+  UINT32                      Reserved        :1;\r
+  UINT32                      Other           :1;\r
+  UINT32                      Unknown         :1;\r
+  UINT32                      FastPaged       :1;\r
+  UINT32                      StaticColumn    :1;\r
+  UINT32                      PseudoStatic    :1;\r
+  UINT32                      Rambus          :1;\r
+  UINT32                      Synchronous     :1;\r
+  UINT32                      Cmos            :1;\r
+  UINT32                      Edo             :1;\r
+  UINT32                      WindowDram      :1;\r
+  UINT32                      CacheDram       :1;\r
+  UINT32                      Nonvolatile     :1;\r
+  UINT32                      Reserved1       :19;\r
+} EFI_MEMORY_TYPE_DETAIL;\r
+\r
+typedef enum {\r
+  EfiMemoryStateEnabled =0,\r
+  EfiMemoryStateUnknown,\r
+  EfiMemoryStateUnsupported,\r
+  EfiMemoryStateError,\r
+  EfiMemoryStateAbsent,\r
+  EfiMemoryStateDisabled,\r
+  EfiMemoryStatePartial\r
+} EFI_MEMORY_STATE;\r
+\r
+typedef struct {\r
+  EFI_STRING_TOKEN            MemoryDeviceLocator;\r
+  EFI_STRING_TOKEN            MemoryBankLocator;\r
+  EFI_STRING_TOKEN            MemoryManufacturer;\r
+  EFI_STRING_TOKEN            MemorySerialNumber;\r
+  EFI_STRING_TOKEN            MemoryAssetTag;\r
+  EFI_STRING_TOKEN            MemoryPartNumber;\r
+  EFI_INTER_LINK_DATA         MemoryArrayLink;\r
+  EFI_INTER_LINK_DATA         MemorySubArrayLink;\r
+  UINT16                      MemoryTotalWidth;\r
+  UINT16                      MemoryDataWidth;\r
+  UINT64                      MemoryDeviceSize;\r
+  EFI_MEMORY_FORM_FACTOR      MemoryFormFactor;\r
+  UINT8                       MemoryDeviceSet;\r
+  EFI_MEMORY_ARRAY_TYPE       MemoryType;\r
+  EFI_MEMORY_TYPE_DETAIL      MemoryTypeDetail;\r
+  UINT16                      MemorySpeed;\r
+  EFI_MEMORY_STATE            MemoryState;\r
+} EFI_MEMORY_ARRAY_LINK;\r
+\r
+\r
+#define EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER  0x00000004\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS        MemoryArrayStartAddress;\r
+  EFI_PHYSICAL_ADDRESS        MemoryArrayEndAddress;\r
+  EFI_INTER_LINK_DATA         PhysicalMemoryArrayLink;\r
+  UINT16                      MemoryArrayPartitionWidth;\r
+} EFI_MEMORY_ARRAY_START_ADDRESS;\r
+\r
+\r
+#define EFI_MEMORY_DEVICE_START_ADDRESS_RECORD_NUMBER 0x00000005\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS        MemoryDeviceStartAddress;\r
+  EFI_PHYSICAL_ADDRESS        MemoryDeviceEndAddress;\r
+  EFI_INTER_LINK_DATA         PhysicalMemoryDeviceLink;\r
+  EFI_INTER_LINK_DATA         PhysicalMemoryArrayLink;\r
+  UINT8                       MemoryDevicePartitionRowPosition;\r
+  UINT8                       MemoryDeviceInterleavePosition;\r
+  UINT8                       MemoryDeviceInterleaveDataDepth;\r
+} EFI_MEMORY_DEVICE_START_ADDRESS;\r
+\r
+\r
+//\r
+//  Memory. Channel Device Type -  SMBIOS Type 37\r
+//\r
+\r
+#define EFI_MEMORY_CHANNEL_TYPE_RECORD_NUMBER         0x00000006\r
+\r
+typedef enum _EFI_MEMORY_CHANNEL_TYPE {\r
+  EfiMemoryChannelTypeOther                   = 1,\r
+  EfiMemoryChannelTypeUnknown                 = 2,\r
+  EfiMemoryChannelTypeRambus                  = 3,\r
+  EfiMemoryChannelTypeSyncLink                = 4\r
+} EFI_MEMORY_CHANNEL_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MEMORY_CHANNEL_TYPE     MemoryChannelType;\r
+  UINT8                       MemoryChannelMaximumLoad;\r
+  UINT8                       MemoryChannelDeviceCount;\r
+} EFI_MEMORY_CHANNEL_TYPE_DATA;\r
+\r
+#define EFI_MEMORY_CHANNEL_DEVICE_RECORD_NUMBER       0x00000007\r
+\r
+typedef struct {\r
+  UINT8                       DeviceId;\r
+  EFI_INTER_LINK_DATA         DeviceLink;\r
+  UINT8                       MemoryChannelDeviceLoad;\r
+} EFI_MEMORY_CHANNEL_DEVICE_DATA;\r
+\r
+//\r
+//  Memory. Controller Information - SMBIOS Type 5\r
+//\r
+#define EFI_MEMORY_CONTROLLER_INFORMATION_RECORD_NUMBER 0x00000008\r
+\r
+typedef enum {  \r
+  EfiErrorDetectingMethodOther   = 1,\r
+  EfiErrorDetectingMethodUnknown = 2,\r
+  EfiErrorDetectingMethodNone    = 3,\r
+  EfiErrorDetectingMethodParity  = 4,\r
+  EfiErrorDetectingMethod32Ecc   = 5,\r
+  EfiErrorDetectingMethod64Ecc   = 6,\r
+  EfiErrorDetectingMethod128Ecc  = 7,\r
+  EfiErrorDetectingMethodCrc     = 8\r
+} EFI_MEMORY_ERROR_DETECT_METHOD_TYPE;\r
+\r
+typedef struct {\r
+  UINT8  Other                 :1;\r
+  UINT8  Unknown               :1;\r
+  UINT8  None                  :1;\r
+  UINT8  SingleBitErrorCorrect :1;\r
+  UINT8  DoubleBitErrorCorrect :1;\r
+  UINT8  ErrorScrubbing        :1;\r
+  UINT8  Reserved              :2;\r
+} EFI_MEMORY_ERROR_CORRECT_CAPABILITY;\r
+\r
+typedef enum {  \r
+  EfiMemoryInterleaveOther      = 1,\r
+  EfiMemoryInterleaveUnknown    = 2,\r
+  EfiMemoryInterleaveOneWay     = 3,\r
+  EfiMemoryInterleaveTwoWay     = 4,\r
+  EfiMemoryInterleaveFourWay    = 5,\r
+  EfiMemoryInterleaveEightWay   = 6,\r
+  EfiMemoryInterleaveSixteenWay = 7\r
+} EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE;\r
+\r
+typedef struct {\r
+  UINT16  Other                 :1;\r
+  UINT16  Unknown               :1;\r
+  UINT16  SeventyNs             :1;\r
+  UINT16  SixtyNs               :1;\r
+  UINT16  FiftyNs               :1;\r
+  UINT16  Reserved              :11;\r
+} EFI_MEMORY_SPEED_TYPE;\r
+\r
+typedef struct {\r
+  UINT16  Other                 :1;\r
+  UINT16  Unknown               :1;\r
+  UINT16  Standard              :1;\r
+  UINT16  FastPageMode          :1;\r
+  UINT16  EDO                   :1;\r
+  UINT16  Parity                :1;\r
+  UINT16  ECC                   :1;\r
+  UINT16  SIMM                  :1;\r
+  UINT16  DIMM                  :1;\r
+  UINT16  BurstEdo              :1;\r
+  UINT16  SDRAM                 :1;\r
+  UINT16  Reserved              :5;\r
+} EFI_MEMORY_SUPPORTED_TYPE;\r
+\r
+typedef struct {\r
+  UINT8  Five                  :1;\r
+  UINT8  There                 :1;\r
+  UINT8  Two                   :1;\r
+  UINT8  Reserved              :5;\r
+} EFI_MEMORY_MODULE_VOLTAGE_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MEMORY_ERROR_DETECT_METHOD_TYPE   ErrorDetectingMethod;\r
+  EFI_MEMORY_ERROR_CORRECT_CAPABILITY   ErrorCorrectingCapability;\r
+  EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE    MemorySupportedInterleave;\r
+  EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE    MemoryCurrentInterleave;\r
+  UINT8                                 MaxMemoryModuleSize;\r
+  EFI_MEMORY_SPEED_TYPE                 MemorySpeedType;\r
+  EFI_MEMORY_SUPPORTED_TYPE             MemorySupportedType;\r
+  EFI_MEMORY_MODULE_VOLTAGE_TYPE        MemoryModuleVoltage;\r
+  UINT8                                 NumberofMemorySlot;\r
+  EFI_MEMORY_ERROR_CORRECT_CAPABILITY   EnabledCorrectingCapability;\r
+  UINT16                                *MemoryModuleConfigHandles;\r
+} EFI_MEMORY_CONTROLLER_INFORMATION;\r
+\r
+//\r
+//  Memory. Error Information - SMBIOS Type 18\r
+//\r
+#define EFI_MEMORY_32BIT_ERROR_INFORMATION_RECORD_NUMBER 0x00000009\r
+\r
+typedef enum {  \r
+  EfiMemoryErrorOther             = 1,\r
+  EfiMemoryErrorUnknown           = 2,\r
+  EfiMemoryErrorOk                = 3,\r
+  EfiMemoryErrorBadRead           = 4,\r
+  EfiMemoryErrorParity            = 5,\r
+  EfiMemoryErrorSigleBit          = 6,\r
+  EfiMemoryErrorDoubleBit         = 7,\r
+  EfiMemoryErrorMultiBit          = 8,\r
+  EfiMemoryErrorNibble            = 9,\r
+  EfiMemoryErrorChecksum          = 10,\r
+  EfiMemoryErrorCrc               = 11,\r
+  EfiMemoryErrorCorrectSingleBit  = 12,\r
+  EfiMemoryErrorCorrected         = 13,\r
+  EfiMemoryErrorUnCorrectable     = 14\r
+} EFI_MEMORY_ERROR_TYPE;\r
+\r
+typedef enum {  \r
+  EfiMemoryGranularityOther               = 1,\r
+  EfiMemoryGranularityOtherUnknown        = 2,\r
+  EfiMemoryGranularityDeviceLevel         = 3,\r
+  EfiMemoryGranularityMemPartitionLevel   = 4\r
+} EFI_MEMORY_ERROR_GRANULARITY_TYPE;\r
+\r
+typedef enum {  \r
+  EfiMemoryErrorOperationOther            = 1,\r
+  EfiMemoryErrorOperationUnknown          = 2,\r
+  EfiMemoryErrorOperationRead             = 3,\r
+  EfiMemoryErrorOperationWrite            = 4,\r
+  EfiMemoryErrorOperationPartialWrite     = 5\r
+} EFI_MEMORY_ERROR_OPERATION_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MEMORY_ERROR_TYPE               MemoryErrorType;\r
+  EFI_MEMORY_ERROR_GRANULARITY_TYPE   MemoryErrorGranularity;\r
+  EFI_MEMORY_ERROR_OPERATION_TYPE     MemoryErrorOperation;\r
+  UINT32                              VendorSyndrome;\r
+  UINT32                              MemoryArrayErrorAddress;\r
+  UINT32                              DeviceErrorAddress;\r
+  UINT32                              DeviceErrorResolution;\r
+} EFI_MEMORY_32BIT_ERROR_INFORMATION;\r
+\r
+//\r
+//  Memory. Error Information - SMBIOS Type 33\r
+//\r
+#define EFI_MEMORY_64BIT_ERROR_INFORMATION_RECORD_NUMBER 0x0000000A\r
+\r
+typedef struct {\r
+  EFI_MEMORY_ERROR_TYPE               MemoryErrorType;\r
+  EFI_MEMORY_ERROR_GRANULARITY_TYPE   MemoryErrorGranularity;\r
+  EFI_MEMORY_ERROR_OPERATION_TYPE     MemoryErrorOperation;\r
+  UINT32                              VendorSyndrome;\r
+  UINT64                              MemoryArrayErrorAddress;\r
+  UINT64                              DeviceErrorAddress;\r
+  UINT32                              DeviceErrorResolution;\r
+} EFI_MEMORY_64BIT_ERROR_INFORMATION;\r
+\r
+\r
+typedef union _EFI_MEMORY_SUBCLASS_RECORDS {\r
+  EFI_MEMORY_SIZE_DATA                  SizeData;\r
+  EFI_MEMORY_ARRAY_LOCATION_DATA        ArrayLocationData;\r
+  EFI_MEMORY_ARRAY_LINK                 ArrayLink;\r
+  EFI_MEMORY_ARRAY_START_ADDRESS        ArrayStartAddress;\r
+  EFI_MEMORY_DEVICE_START_ADDRESS       DeviceStartAddress;\r
+  EFI_MEMORY_CHANNEL_TYPE_DATA          ChannelTypeData;\r
+  EFI_MEMORY_CHANNEL_DEVICE_DATA        ChannelDeviceData;\r
+  EFI_MEMORY_CONTROLLER_INFORMATION     MemoryControllerInfo;\r
+  EFI_MEMORY_32BIT_ERROR_INFORMATION    Memory32bitErrorInfo;\r
+  EFI_MEMORY_64BIT_ERROR_INFORMATION    Memory64bitErrorInfo;\r
+} EFI_MEMORY_SUBCLASS_RECORDS;\r
+\r
+typedef struct {\r
+  EFI_SUBCLASS_TYPE1_HEADER             Header;\r
+  EFI_MEMORY_SUBCLASS_RECORDS           Record;\r
+} EFI_MEMORY_SUBCLASS_DRIVER_DATA;\r
+\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
new file mode 100644 (file)
index 0000000..901a464
--- /dev/null
@@ -0,0 +1,1130 @@
+/*++\r
\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHubSubClassMisc.h\r
+    \r
+Abstract:\r
+\r
+  Definitions for Misc sub class data records\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DATAHUB_SUBCLASS_MISC_H_\r
+#define _DATAHUB_SUBCLASS_MISC_H_\r
+\r
+#include EFI_GUID_DEFINITION(DataHubRecords)\r
+\r
+#define EFI_MISC_SUBCLASS_GUID \\r
+{ 0x772484B2, 0x7482, 0x4b91, 0x9F, 0x9A, 0xAD, 0x43, 0xF8, 0x1C, 0x58, 0x81 }\r
+\r
+#define EFI_MISC_SUBCLASS_VERSION     0x0100\r
+\r
+#pragma pack(1)\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Last PCI Bus Number\r
+//\r
+#define EFI_MISC_LAST_PCI_BUS_RECORD_NUMBER   0x00000001\r
+\r
+typedef struct {\r
+  UINT8   LastPciBus;\r
+} EFI_MISC_LAST_PCI_BUS;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. BIOS Vendor - SMBIOS Type 0\r
+//\r
+#define EFI_MISC_BIOS_VENDOR_RECORD_NUMBER  0x00000002\r
+\r
+typedef struct {\r
+  UINT32  Reserved1                         :2;\r
+  UINT32  Unknown                           :1;\r
+  UINT32  BiosCharacteristicsNotSupported   :1;\r
+  UINT32  IsaIsSupported                    :1;\r
+  UINT32  McaIsSupported                    :1;\r
+  UINT32  EisaIsSupported                   :1;\r
+  UINT32  PciIsSupported                    :1;\r
+  UINT32  PcmciaIsSupported                 :1;\r
+  UINT32  PlugAndPlayIsSupported            :1;\r
+  UINT32  ApmIsSupported                    :1;\r
+  UINT32  BiosIsUpgradable                  :1;\r
+  UINT32  BiosShadowingAllowed              :1;\r
+  UINT32  VlVesaIsSupported                 :1;\r
+  UINT32  EscdSupportIsAvailable            :1;\r
+  UINT32  BootFromCdIsSupported             :1;\r
+  UINT32  SelectableBootIsSupported         :1;\r
+  UINT32  RomBiosIsSocketed                 :1;\r
+  UINT32  BootFromPcmciaIsSupported         :1;\r
+  UINT32  EDDSpecificationIsSupported       :1;\r
+  UINT32  JapaneseNecFloppyIsSupported      :1;\r
+  UINT32  JapaneseToshibaFloppyIsSupported  :1;\r
+  UINT32  Floppy525_360IsSupported          :1;\r
+  UINT32  Floppy525_12IsSupported           :1;\r
+  UINT32  Floppy35_720IsSupported           :1;\r
+  UINT32  Floppy35_288IsSupported           :1;\r
+  UINT32  PrintScreenIsSupported            :1;\r
+  UINT32  Keyboard8042IsSupported           :1;\r
+  UINT32  SerialIsSupported                 :1;\r
+  UINT32  PrinterIsSupported                :1;\r
+  UINT32  CgaMonoIsSupported                :1;\r
+  UINT32  NecPc98                           :1;\r
+  UINT32  AcpiIsSupported                   :1;\r
+  UINT32  UsbLegacyIsSupported              :1;\r
+  UINT32  AgpIsSupported                    :1;\r
+  UINT32  I20BootIsSupported                :1;\r
+  UINT32  Ls120BootIsSupported              :1;\r
+  UINT32  AtapiZipDriveBootIsSupported      :1;\r
+  UINT32  Boot1394IsSupported               :1;\r
+  UINT32  SmartBatteryIsSupported           :1;\r
+  UINT32  BiosBootSpecIsSupported           :1;\r
+  UINT32  FunctionKeyNetworkBootIsSupported :1;\r
+  UINT32  TargetContentDistributionEnabled  :1; \r
+  UINT32  Reserved                          :21;\r
+} EFI_MISC_BIOS_CHARACTERISTICS;\r
+\r
+typedef struct {\r
+  UINT32  BiosReserved                      :16;\r
+  UINT32  SystemReserved                    :16;\r
+  UINT32  Reserved                          :32;\r
+} EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION;\r
+\r
+typedef struct {\r
+  STRING_REF                      BiosVendor;\r
+  STRING_REF                      BiosVersion;\r
+  STRING_REF                      BiosReleaseDate;\r
+  EFI_PHYSICAL_ADDRESS            BiosStartingAddress;\r
+  EFI_EXP_BASE2_DATA              BiosPhysicalDeviceSize;\r
+  EFI_MISC_BIOS_CHARACTERISTICS   BiosCharacteristics1;\r
+  EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION  BiosCharacteristics2;\r
+  UINT8                           BiosMajorRelease;\r
+  UINT8                           BiosMinorRelease;\r
+  UINT8                           BiosEmbeddedFirmwareMajorRelease;\r
+  UINT8                           BiosEmbeddedFirmwareMinorRelease;\r
+} EFI_MISC_BIOS_VENDOR;       \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System Manufacturer - SMBIOS Type 1\r
+//\r
+#define EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER 0x00000003\r
+\r
+typedef enum {  \r
+  EfiSystemWakeupTypeReserved = 0,\r
+  EfiSystemWakeupTypeOther = 1,\r
+  EfiSystemWakeupTypeUnknown = 2,\r
+  EfiSystemWakeupTypeApmTimer = 3,\r
+  EfiSystemWakeupTypeModemRing = 4,\r
+  EfiSystemWakeupTypeLanRemote = 5,\r
+  EfiSystemWakeupTypePowerSwitch = 6,\r
+  EfiSystemWakeupTypePciPme = 7,\r
+  EfiSystemWakeupTypeAcPowerRestored = 8,\r
+} EFI_MISC_SYSTEM_WAKEUP_TYPE;\r
+\r
+typedef struct {\r
+  STRING_REF                      SystemManufacturer;\r
+  STRING_REF                      SystemProductName;\r
+  STRING_REF                      SystemVersion;\r
+  STRING_REF                      SystemSerialNumber;\r
+  EFI_GUID                        SystemUuid;\r
+  EFI_MISC_SYSTEM_WAKEUP_TYPE     SystemWakeupType;\r
+  STRING_REF                      SystemSKUNumber;\r
+  STRING_REF                      SystemFamily;\r
+} EFI_MISC_SYSTEM_MANUFACTURER;        \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Base Board Manufacturer - SMBIOS Type 2\r
+//\r
+#define EFI_MISC_BASE_BOARD_MANUFACTURER_RECORD_NUMBER 0x00000004\r
+\r
+typedef struct {\r
+  UINT32  Motherboard           :1;\r
+  UINT32  RequiresDaughterCard  :1;\r
+  UINT32  Removable             :1;\r
+  UINT32  Replaceable           :1;\r
+  UINT32  HotSwappable          :1;\r
+  UINT32  Reserved              :27;\r
+} EFI_BASE_BOARD_FEATURE_FLAGS;\r
+\r
+typedef enum {  \r
+  EfiBaseBoardTypeUnknown = 1,\r
+  EfiBaseBoardTypeOther = 2,\r
+  EfiBaseBoardTypeServerBlade = 3,\r
+  EfiBaseBoardTypeConnectivitySwitch = 4,\r
+  EfiBaseBoardTypeSystemManagementModule = 5,\r
+  EfiBaseBoardTypeProcessorModule = 6,\r
+  EfiBaseBoardTypeIOModule = 7,\r
+  EfiBaseBoardTypeMemoryModule = 8,\r
+  EfiBaseBoardTypeDaughterBoard = 9,\r
+  EfiBaseBoardTypeMotherBoard = 0xA,\r
+  EfiBaseBoardTypeProcessorMemoryModule = 0xB,\r
+  EfiBaseBoardTypeProcessorIOModule = 0xC,\r
+  EfiBaseBoardTypeInterconnectBoard = 0xD,\r
+} EFI_BASE_BOARD_TYPE;\r
+\r
+typedef struct {\r
+  STRING_REF                      BaseBoardManufacturer;\r
+  STRING_REF                      BaseBoardProductName;\r
+  STRING_REF                      BaseBoardVersion;\r
+  STRING_REF                      BaseBoardSerialNumber;\r
+  STRING_REF                      BaseBoardAssetTag;\r
+  STRING_REF                      BaseBoardChassisLocation;\r
+  EFI_BASE_BOARD_FEATURE_FLAGS    BaseBoardFeatureFlags;\r
+  EFI_BASE_BOARD_TYPE             BaseBoardType;\r
+  EFI_INTER_LINK_DATA             BaseBoardChassisLink;\r
+  UINT32                          BaseBoardNumberLinks;\r
+  EFI_INTER_LINK_DATA             LinkN;\r
+} EFI_MISC_BASE_BOARD_MANUFACTURER;       \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System/Chassis Enclosure - SMBIOS Type 3\r
+//\r
+#define EFI_MISC_CHASSIS_MANUFACTURER_RECORD_NUMBER  0x00000005\r
+\r
+typedef enum {  \r
+  EfiMiscChassisTypeOther = 0x1,\r
+  EfiMiscChassisTypeUnknown = 0x2,\r
+  EfiMiscChassisTypeDeskTop = 0x3,\r
+  EfiMiscChassisTypeLowProfileDesktop = 0x4,\r
+  EfiMiscChassisTypePizzaBox = 0x5,\r
+  EfiMiscChassisTypeMiniTower = 0x6,\r
+  EfiMiscChassisTypeTower = 0x7,\r
+  EfiMiscChassisTypePortable = 0x8,\r
+  EfiMiscChassisTypeLapTop = 0x9,\r
+  EfiMiscChassisTypeNotebook = 0xA,\r
+  EfiMiscChassisTypeHandHeld = 0xB,\r
+  EfiMiscChassisTypeDockingStation = 0xC,\r
+  EfiMiscChassisTypeAllInOne = 0xD,\r
+  EfiMiscChassisTypeSubNotebook = 0xE,\r
+  EfiMiscChassisTypeSpaceSaving = 0xF,\r
+  EfiMiscChassisTypeLunchBox = 0x10,\r
+  EfiMiscChassisTypeMainServerChassis = 0x11,\r
+  EfiMiscChassisTypeExpansionChassis = 0x12,\r
+  EfiMiscChassisTypeSubChassis = 0x13,\r
+  EfiMiscChassisTypeBusExpansionChassis = 0x14,\r
+  EfiMiscChassisTypePeripheralChassis = 0x15,\r
+  EfiMiscChassisTypeRaidChassis = 0x16,\r
+  EfiMiscChassisTypeRackMountChassis = 0x17,\r
+  EfiMiscChassisTypeSealedCasePc = 0x18,\r
+  EfiMiscChassisMultiSystemChassis = 0x19,\r
+} EFI_MISC_CHASSIS_TYPE;\r
+\r
+typedef struct {\r
+  UINT32  ChassisType       :16;\r
+  UINT32  ChassisLockPresent:1;\r
+  UINT32  Reserved          :15;\r
+} EFI_MISC_CHASSIS_STATUS;\r
+\r
+typedef enum {  \r
+  EfiChassisStateOther = 1,\r
+  EfiChassisStateUnknown = 2,\r
+  EfiChassisStateSafe = 3,\r
+  EfiChassisStateWarning = 4,\r
+  EfiChassisStateCritical = 5,\r
+  EfiChassisStateNonRecoverable = 6,\r
+} EFI_MISC_CHASSIS_STATE;\r
+\r
+typedef enum {  \r
+  EfiChassisSecurityStatusOther = 1,\r
+  EfiChassisSecurityStatusUnknown = 2,\r
+  EfiChassisSecurityStatusNone = 3,\r
+  EfiChassisSecurityStatusExternalInterfaceLockedOut = 4,\r
+  EfiChassisSecurityStatusExternalInterfaceLockedEnabled = 5,\r
+} EFI_MISC_CHASSIS_SECURITY_STATE;\r
+\r
+typedef struct {\r
+  UINT32  RecordType  :1;\r
+  UINT32  Reserved    :24;\r
+} EFI_MISC_ELEMENT_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MISC_ELEMENT_TYPE   ChassisElementType;\r
+  EFI_INTER_LINK_DATA     ChassisElementStructure;\r
+  EFI_BASE_BOARD_TYPE     ChassisBaseBoard;\r
+  UINT32                  ChassisElementMinimum;\r
+  UINT32                  ChassisElementMaximum;\r
+} EFI_MISC_ELEMENTS; \r
+\r
+typedef struct {\r
+  STRING_REF                      ChassisManufacturer;\r
+  STRING_REF                      ChassisVersion;\r
+  STRING_REF                      ChassisSerialNumber;\r
+  STRING_REF                      ChassisAssetTag;\r
+  EFI_MISC_CHASSIS_STATUS         ChassisType;\r
+  EFI_MISC_CHASSIS_STATE          ChassisBootupState;\r
+  EFI_MISC_CHASSIS_STATE          ChassisPowerSupplyState;\r
+  EFI_MISC_CHASSIS_STATE          ChassisThermalState;\r
+  EFI_MISC_CHASSIS_SECURITY_STATE ChassisSecurityState;\r
+  UINT32                          ChassisOemDefined;\r
+  UINT32                          ChassisHeight;\r
+  UINT32                          ChassisNumberPowerCords;\r
+  UINT32                          ChassisElementCount;\r
+  UINT32                          ChassisElementRecordLength;//\r
+  EFI_MISC_ELEMENTS               ChassisElements;\r
+} EFI_MISC_CHASSIS_MANUFACTURER;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Port Connector Information - SMBIOS Type 8\r
+//\r
+#define EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER 0x00000006\r
+\r
+typedef enum {  \r
+  EfiPortConnectorTypeNone = 0x0,\r
+  EfiPortConnectorTypeCentronics = 0x1,\r
+  EfiPortConnectorTypeMiniCentronics = 0x2,\r
+  EfiPortConnectorTypeProprietary = 0x3,\r
+  EfiPortConnectorTypeDB25Male = 0x4,\r
+  EfiPortConnectorTypeDB25Female = 0x5,\r
+  EfiPortConnectorTypeDB15Male = 0x6,\r
+  EfiPortConnectorTypeDB15Female = 0x7,\r
+  EfiPortConnectorTypeDB9Male = 0x8,\r
+  EfiPortConnectorTypeDB9Female = 0x9,\r
+  EfiPortConnectorTypeRJ11 = 0xA,\r
+  EfiPortConnectorTypeRJ45 = 0xB,\r
+  EfiPortConnectorType50PinMiniScsi = 0xC,\r
+  EfiPortConnectorTypeMiniDin = 0xD,\r
+  EfiPortConnectorTypeMicriDin = 0xE,\r
+  EfiPortConnectorTypePS2 = 0xF,\r
+  EfiPortConnectorTypeInfrared = 0x10,\r
+  EfiPortConnectorTypeHpHil = 0x11,\r
+  EfiPortConnectorTypeUsb = 0x12,\r
+  EfiPortConnectorTypeSsaScsi = 0x13,\r
+  EfiPortConnectorTypeCircularDin8Male = 0x14,\r
+  EfiPortConnectorTypeCircularDin8Female = 0x15,\r
+  EfiPortConnectorTypeOnboardIde = 0x16,\r
+  EfiPortConnectorTypeOnboardFloppy = 0x17,\r
+  EfiPortConnectorType9PinDualInline = 0x18,\r
+  EfiPortConnectorType25PinDualInline = 0x19,\r
+  EfiPortConnectorType50PinDualInline = 0x1A,\r
+  EfiPortConnectorType68PinDualInline = 0x1B,\r
+  EfiPortConnectorTypeOnboardSoundInput = 0x1C,\r
+  EfiPortConnectorTypeMiniCentronicsType14 = 0x1D,\r
+  EfiPortConnectorTypeMiniCentronicsType26 = 0x1E,\r
+  EfiPortConnectorTypeHeadPhoneMiniJack = 0x1F,\r
+  EfiPortConnectorTypeBNC = 0x20,\r
+  EfiPortConnectorType1394 = 0x21,\r
+  EfiPortConnectorTypePC98 = 0xA0,\r
+  EfiPortConnectorTypePC98Hireso = 0xA1,\r
+  EfiPortConnectorTypePCH98 = 0xA2,\r
+  EfiPortConnectorTypePC98Note = 0xA3,\r
+  EfiPortConnectorTypePC98Full = 0xA4,\r
+  EfiPortConnectorTypeOther = 0xFF,\r
+} EFI_MISC_PORT_CONNECTOR_TYPE;\r
+\r
+typedef enum {  \r
+  EfiPortTypeNone = 0x0,\r
+  EfiPortTypeParallelXtAtCompatible = 0x1,\r
+  EfiPortTypeParallelPortPs2 = 0x2,\r
+  EfiPortTypeParallelPortEcp = 0x3,\r
+  EfiPortTypeParallelPortEpp = 0x4,\r
+  EfiPortTypeParallelPortEcpEpp = 0x5,\r
+  EfiPortTypeSerialXtAtCompatible = 0x6,\r
+  EfiPortTypeSerial16450Compatible = 0x7,\r
+  EfiPortTypeSerial16550Compatible = 0x8,\r
+  EfiPortTypeSerial16550ACompatible = 0x9,\r
+  EfiPortTypeScsi = 0xA,\r
+  EfiPortTypeMidi = 0xB,\r
+  EfiPortTypeJoyStick = 0xC,\r
+  EfiPortTypeKeyboard = 0xD,\r
+  EfiPortTypeMouse = 0xE,\r
+  EfiPortTypeSsaScsi = 0xF,\r
+  EfiPortTypeUsb = 0x10,\r
+  EfiPortTypeFireWire = 0x11,\r
+  EfiPortTypePcmciaTypeI = 0x12,\r
+  EfiPortTypePcmciaTypeII = 0x13,\r
+  EfiPortTypePcmciaTypeIII = 0x14,\r
+  EfiPortTypeCardBus = 0x15,\r
+  EfiPortTypeAccessBusPort = 0x16,\r
+  EfiPortTypeScsiII = 0x17,\r
+  EfiPortTypeScsiWide = 0x18,\r
+  EfiPortTypePC98 = 0x19,\r
+  EfiPortTypePC98Hireso = 0x1A,\r
+  EfiPortTypePCH98 = 0x1B,\r
+  EfiPortTypeVideoPort = 0x1C,\r
+  EfiPortTypeAudioPort = 0x1D,\r
+  EfiPortTypeModemPort = 0x1E,\r
+  EfiPortTypeNetworkPort = 0x1F,\r
+  EfiPortType8251Compatible = 0xA0,\r
+  EfiPortType8251FifoCompatible = 0xA1,\r
+  EfiPortTypeOther = 0xFF,\r
+} EFI_MISC_PORT_TYPE;\r
+\r
+\r
+typedef struct {\r
+  EFI_STRING_TOKEN              PortInternalConnectorDesignator;\r
+  EFI_STRING_TOKEN              PortExternalConnectorDesignator;\r
+  EFI_MISC_PORT_CONNECTOR_TYPE  PortInternalConnectorType;\r
+  EFI_MISC_PORT_CONNECTOR_TYPE  PortExternalConnectorType;\r
+  EFI_MISC_PORT_TYPE            PortType;\r
+  EFI_MISC_PORT_DEVICE_PATH      PortPath;\r
+} EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR;      \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System Slots - SMBIOS Type 9\r
+//\r
+#define EFI_MISC_SYSTEM_SLOT_DESIGNATION_RECORD_NUMBER 0x00000007\r
+\r
+typedef enum {  \r
+  EfiSlotTypeOther = 0x1,\r
+  EfiSlotTypeUnknown = 0x2,\r
+  EfiSlotTypeIsa = 0x3,\r
+  EfiSlotTypeMca = 0x4,\r
+  EfiSlotTypeEisa = 0x5,\r
+  EfiSlotTypePci = 0x6,\r
+  EfiSlotTypePcmcia = 0x7,\r
+  EfiSlotTypeVlVesa = 0x8,\r
+  EfiSlotTypeProprietary = 0x9,\r
+  EfiSlotTypeProcessorCardSlot = 0xA,\r
+  EfiSlotTypeProprietaryMemoryCardSlot = 0xB,\r
+  EfiSlotTypeIORiserCardSlot = 0xC,\r
+  EfiSlotTypeNuBus = 0xD,\r
+  EfiSlotTypePci66MhzCapable = 0xE,\r
+  EfiSlotTypeAgp = 0xF,\r
+  EfiSlotTypeApg2X = 0x10,\r
+  EfiSlotTypeAgp4X = 0x11,\r
+  EfiSlotTypePciX = 0x12,\r
+  EfiSlotTypeAgp4x = 0x13,\r
+  EfiSlotTypePC98C20 = 0xA0,\r
+  EfiSlotTypePC98C24 = 0xA1,\r
+  EfiSlotTypePC98E = 0xA2,\r
+  EfiSlotTypePC98LocalBus = 0xA3,\r
+  EfiSlotTypePC98Card = 0xA4,\r
+  EfiSlotTypePciExpress = 0xA5,\r
+} EFI_MISC_SLOT_TYPE;\r
+\r
+typedef enum {  \r
+  EfiSlotDataBusWidthOther = 1,\r
+  EfiSlotDataBusWidthUnknown = 2,\r
+  EfiSlotDataBusWidth8Bit = 3,\r
+  EfiSlotDataBusWidth16Bit = 4,\r
+  EfiSlotDataBusWidth32Bit = 5,\r
+  EfiSlotDataBusWidth64Bit = 6,\r
+  EfiSlotDataBusWidth128Bit = 7,\r
+  EfiSlotDataBusWidth1xOrx1 = 8,\r
+  EfiSlotDataBusWidth2xOrx2 = 9,\r
+  EfiSlotDataBusWidth4xOrx4 = 0xA,\r
+  EfiSlotDataBusWidth8xOrx8 = 0xB,\r
+  EfiSlotDataBusWidth12xOrx12 = 0xC,\r
+  EfiSlotDataBusWidth16xOrx16 = 0xD,\r
+  EfiSlotDataBusWidth32xOrx32 = 0xE,\r
+} EFI_MISC_SLOT_DATA_BUS_WIDTH;\r
+\r
+typedef enum {  \r
+  EfiSlotUsageOther = 1,\r
+  EfiSlotUsageUnknown = 2,\r
+  EfiSlotUsageAvailable = 3,\r
+  EfiSlotUsageInUse = 4,\r
+} EFI_MISC_SLOT_USAGE;\r
+  \r
+typedef enum {  \r
+  EfiSlotLengthOther = 1,\r
+  EfiSlotLengthUnknown = 2,\r
+  EfiSlotLengthShort = 3,\r
+  EfiSlotLengthLong = 4\r
+} EFI_MISC_SLOT_LENGTH;\r
+\r
+typedef struct {\r
+  UINT32  CharacteristicsUnknown  :1;\r
+  UINT32  Provides50Volts         :1;\r
+  UINT32  Provides33Volts         :1;\r
+  UINT32  SharedSlot              :1;\r
+  UINT32  PcCard16Supported       :1;\r
+  UINT32  CardBusSupported        :1;\r
+  UINT32  ZoomVideoSupported      :1;\r
+  UINT32  ModemRingResumeSupported:1;\r
+  UINT32  PmeSignalSupported      :1;\r
+  UINT32  HotPlugDevicesSupported :1;\r
+  UINT32  SmbusSignalSupported    :1;\r
+  UINT32  Reserved                :21;\r
+} EFI_MISC_SLOT_CHARACTERISTICS;\r
+\r
+typedef struct {\r
+  STRING_REF                    SlotDesignation;\r
+  EFI_MISC_SLOT_TYPE            SlotType;\r
+  EFI_MISC_SLOT_DATA_BUS_WIDTH  SlotDataBusWidth;\r
+  EFI_MISC_SLOT_USAGE           SlotUsage;\r
+  EFI_MISC_SLOT_LENGTH          SlotLength;\r
+  UINT16                        SlotId;\r
+  EFI_MISC_SLOT_CHARACTERISTICS SlotCharacteristics;\r
+  EFI_DEVICE_PATH_PROTOCOL      SlotDevicePath;\r
+} EFI_MISC_SYSTEM_SLOT_DESIGNATION;      \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Onboard Device - SMBIOS Type 10\r
+//\r
+#define EFI_MISC_ONBOARD_DEVICE_RECORD_NUMBER 0x00000008\r
+\r
+typedef enum {  \r
+  EfiOnBoardDeviceTypeOther = 1,\r
+  EfiOnBoardDeviceTypeUnknown = 2,\r
+  EfiOnBoardDeviceTypeVideo = 3,\r
+  EfiOnBoardDeviceTypeScsiController = 4,\r
+  EfiOnBoardDeviceTypeEthernet = 5,\r
+  EfiOnBoardDeviceTypeTokenRing = 6,\r
+  EfiOnBoardDeviceTypeSound = 7,\r
+} EFI_MISC_ONBOARD_DEVICE_TYPE;\r
+\r
+typedef struct {\r
+  UINT32  DeviceType    :16;\r
+  UINT32  DeviceEnabled :1;\r
+  UINT32  Reserved      :15;\r
+} EFI_MISC_ONBOARD_DEVICE_STATUS;\r
+\r
+typedef struct {\r
+  STRING_REF                      OnBoardDeviceDescription;\r
+  EFI_MISC_ONBOARD_DEVICE_STATUS  OnBoardDeviceStatus;\r
+  EFI_DEVICE_PATH_PROTOCOL        OnBoardDevicePath;\r
+} EFI_MISC_ONBOARD_DEVICE;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. BIOS Language Information - SMBIOS Type 11\r
+//\r
+#define EFI_MISC_OEM_STRING_RECORD_NUMBER 0x00000009\r
+\r
+typedef struct {\r
+  STRING_REF                          OemStringRef[1];\r
+} EFI_MISC_OEM_STRING;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System Options - SMBIOS Type 12\r
+//\r
+typedef struct {\r
+  STRING_REF                          SystemOptionStringRef[1];\r
+} EFI_MISC_SYSTEM_OPTION_STRING;      \r
+\r
+#define EFI_MISC_SYSTEM_OPTION_STRING_RECORD_NUMBER 0x0000000A\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Number of Installable Languages - SMBIOS Type 13\r
+//\r
+#define EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_RECORD_NUMBER 0x0000000B\r
+\r
+typedef struct {\r
+  UINT32                              AbbreviatedLanguageFormat :1;\r
+  UINT32                              Reserved                  :31;\r
+} EFI_MISC_LANGUAGE_FLAGS;\r
+\r
+typedef struct {\r
+  UINT16                              NumberOfInstallableLanguages;\r
+  EFI_MISC_LANGUAGE_FLAGS             LanguageFlags;\r
+  UINT16                              CurrentLanguageNumber;\r
+} EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES;       \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System Language String\r
+//\r
+#define EFI_MISC_SYSTEM_LANGUAGE_STRING_RECORD_NUMBER 0x0000000C\r
+\r
+typedef struct {\r
+  UINT16                              LanguageId;\r
+  STRING_REF                          SystemLanguageString;\r
+} EFI_MISC_SYSTEM_LANGUAGE_STRING;      \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  Misc. Group Associations  - SMBIOS Type 14\r
+//\r
+#define EFI_MISC_GROUP_NAME_RECORD_NUMBER 0x0000000D\r
+\r
+typedef struct {\r
+  STRING_REF                          GroupName;\r
+  UINT16                              NumberGroupItems;\r
+  UINT16                              GroupId;\r
+} EFI_MISC_GROUP_NAME_DATA;\r
+\r
+#define EFI_MISC_GROUP_ITEM_SET_RECORD_NUMBER 0x0000000E\r
+\r
+typedef struct {\r
+  EFI_GUID            SubClass;\r
+  EFI_INTER_LINK_DATA GroupLink;\r
+  UINT16              GroupId;\r
+  UINT16              GroupElementId;\r
+} EFI_MISC_GROUP_ITEM_SET_DATA;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  Misc. Pointing Device Type - SMBIOS Type 21\r
+//\r
+#define EFI_MISC_POINTING_DEVICE_TYPE_RECORD_NUMBER 0x0000000F\r
+\r
+typedef enum { \r
+  EfiPointingDeviceTypeOther = 1,\r
+  EfiPointingDeviceTypeUnknown = 2,\r
+  EfiPointingDeviceTypeMouse = 3,\r
+  EfiPointingDeviceTypeTrackBall = 4,\r
+  EfiPointingDeviceTypeTrackPoint = 5,\r
+  EfiPointingDeviceTypeGlidePoint = 6,\r
+  EfiPointingDeviceTouchPad = 7,\r
+  EfiPointingDeviceTouchScreen = 8,\r
+  EfiPointingDeviceOpticalSensor = 9,\r
+} EFI_MISC_POINTING_DEVICE_TYPE;\r
+\r
+typedef enum {  \r
+  EfiPointingDeviceInterfaceOther = 1,\r
+  EfiPointingDeviceInterfaceUnknown = 2,\r
+  EfiPointingDeviceInterfaceSerial = 3,\r
+  EfiPointingDeviceInterfacePs2 = 4,\r
+  EfiPointingDeviceInterfaceInfrared = 5,\r
+  EfiPointingDeviceInterfaceHpHil = 6,\r
+  EfiPointingDeviceInterfaceBusMouse = 7,\r
+  EfiPointingDeviceInterfaceADB = 8,\r
+  EfiPointingDeviceInterfaceBusMouseDB9 = 0xA0,\r
+  EfiPointingDeviceInterfaceBusMouseMicroDin = 0xA1,\r
+  EfiPointingDeviceInterfaceUsb = 0xA2,\r
+} EFI_MISC_POINTING_DEVICE_INTERFACE;\r
+\r
+typedef struct {\r
+  EFI_MISC_POINTING_DEVICE_TYPE       PointingDeviceType;\r
+  EFI_MISC_POINTING_DEVICE_INTERFACE  PointingDeviceInterface;\r
+  UINT16                              NumberPointingDeviceButtons;\r
+  EFI_DEVICE_PATH_PROTOCOL            PointingDevicePath;\r
+} EFI_MISC_ONBOARD_DEVICE_TYPE_DATA;      \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  Misc. Portable Battery - SMBIOS Type 22\r
+//\r
+#define EFI_MISC_PORTABLE_BATTERY_RECORD_NUMBER 0x00000010\r
+\r
+typedef enum {  \r
+  EfiPortableBatteryDeviceChemistryOther = 1,\r
+  EfiPortableBatteryDeviceChemistryUnknown = 2,\r
+  EfiPortableBatteryDeviceChemistryLeadAcid = 3,\r
+  EfiPortableBatteryDeviceChemistryNickelCadmium = 4,\r
+  EfiPortableBatteryDeviceChemistryNickelMetalHydride = 5,\r
+  EfiPortableBatteryDeviceChemistryLithiumIon = 6,\r
+  EfiPortableBatteryDeviceChemistryZincAir = 7,\r
+  EfiPortableBatteryDeviceChemistryLithiumPolymer = 8,\r
+} EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY;\r
+\r
+typedef struct {\r
+  STRING_REF                                  Location;\r
+  STRING_REF                                  Manufacturer;\r
+  STRING_REF                                  ManufactureDate;\r
+  STRING_REF                                  SerialNumber;\r
+  STRING_REF                                  DeviceName;\r
+  EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY  DeviceChemistry;\r
+  UINT16                                      DesignCapacity;\r
+  UINT16                                      DesignVoltage;\r
+  STRING_REF                                  SBDSVersionNumber;\r
+  UINT8                                       MaximumError;\r
+  UINT16                                      SBDSSerialNumber;\r
+  UINT16                                      SBDSManufactureDate;\r
+  STRING_REF                                  SBDSDeviceChemistry;\r
+  UINT8                                       DesignCapacityMultiplier;\r
+  UINT32                                      OEMSpecific;  \r
+  UINT8                                       BatteryNumber; // Temporary   \r
+  BOOLEAN                                     Valid; // Is entry valid - Temporary\r
+} EFI_MISC_PORTABLE_BATTERY;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Reset Capabilities - SMBIOS Type 23\r
+//\r
+#define EFI_MISC_RESET_CAPABILITIES_RECORD_NUMBER 0x00000011\r
+\r
+typedef struct {\r
+  UINT32  Status              :1;\r
+  UINT32  BootOption          :2;\r
+  UINT32  BootOptionOnLimit   :2;\r
+  UINT32  WatchdogTimerPresent:1;\r
+  UINT32  Reserved            :26;\r
+} EFI_MISC_RESET_CAPABILITIES_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MISC_RESET_CAPABILITIES_TYPE  ResetCapabilities;\r
+  UINT16                            ResetCount;\r
+  UINT16                            ResetLimit;\r
+  UINT16                            ResetTimerInterval;\r
+  UINT16                            ResetTimeout;\r
+} EFI_MISC_RESET_CAPABILITIES;\r
\r
+typedef struct {\r
+    EFI_MISC_RESET_CAPABILITIES   ResetCapabilities;\r
+    UINT16                        ResetCount;\r
+    UINT16                        ResetLimit;\r
+    UINT16                        ResetTimerInterval;\r
+    UINT16                        ResetTimeout;\r
+} EFI_MISC_RESET_CAPABILITIES_DATA;       \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Hardware Security - SMBIOS Type 24\r
+//\r
+#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER 0x00000012\r
+\r
+typedef enum {\r
+  EfiHardwareSecurityStatusDisabled = 0,\r
+  EfiHardwareSecurityStatusEnabled = 1,\r
+  EfiHardwareSecurityStatusNotImplemented = 2,\r
+  EfiHardwareSecurityStatusUnknown = 3\r
+} EFI_MISC_HARDWARE_SECURITY_STATUS; \r
+\r
+typedef struct {\r
+  EFI_MISC_HARDWARE_SECURITY_STATUS   FrontPanelResetStatus   :2;  \r
+  EFI_MISC_HARDWARE_SECURITY_STATUS   AdministratorPasswordStatus   :2;  \r
+  EFI_MISC_HARDWARE_SECURITY_STATUS   KeyboardPasswordStatus :2;  \r
+  EFI_MISC_HARDWARE_SECURITY_STATUS   PowerOnPasswordStatus :2;  \r
+  EFI_MISC_HARDWARE_SECURITY_STATUS   Reserved :24;  \r
+} EFI_MISC_HARDWARE_SECURITY_SETTINGS;\r
+\r
+typedef struct {\r
+  EFI_MISC_HARDWARE_SECURITY_SETTINGS HardwareSecuritySettings;\r
+} EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA;       \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. System Power Controls - SMBIOS Type 25\r
+//\r
+#define EFI_MISC_SCHEDULED_POWER_ON_MONTH_RECORD_NUMBER 0x00000013\r
+\r
+typedef struct {\r
+  UINT8     ScheduledPoweronMonth;\r
+  UINT8     ScheduledPoweronDayOfMonth;\r
+  UINT8     ScheduledPoweronHour;\r
+  UINT8     ScheduledPoweronMinute;\r
+  UINT8     ScheduledPoweronSecond;\r
+} EFI_MISC_SCHEDULED_POWER_ON_MONTH;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Voltage Probe - SMBIOS Type 26\r
+//\r
+#define EFI_MISC_VOLTAGE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000014\r
+\r
+typedef struct {\r
+  UINT32    VoltageProbeSite :5;\r
+  UINT32    VoltageProbeStatus :3;\r
+  UINT32    Reserved :24;\r
+} EFI_MISC_VOLTAGE_PROBE_LOCATION;\r
+\r
+typedef struct {\r
+  STRING_REF                        VoltageProbeDescription;\r
+  EFI_MISC_VOLTAGE_PROBE_LOCATION   VoltageProbeLocation;\r
+  UINT16                            VoltageProbeMaximumValue;\r
+  UINT16                            VoltageProbeMinimumValue;\r
+  UINT16                            VoltageProbeResolution;\r
+  UINT16                            VoltageProbeTolerance;\r
+  UINT16                            VoltageProbeAccuracy;\r
+  UINT16                            VoltageProbeNominalValue;\r
+  UINT16                            MDLowerNoncriticalThreshold;\r
+  UINT16                            MDUpperNoncriticalThreshold;\r
+  UINT16                            MDLowerCriticalThreshold;\r
+  UINT16                            MDUpperCriticalThreshold;\r
+  UINT16                            MDLowerNonrecoverableThreshold;\r
+  UINT16                            MDUpperNonrecoverableThreshold;\r
+  UINT32                            VoltageProbeOemDefined;\r
+} EFI_MISC_VOLTAGE_PROBE_DESCRIPTION;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Cooling Device - SMBIOS Type 27\r
+//\r
+#define EFI_MISC_COOLING_DEVICE_TEMP_LINK_RECORD_NUMBER 0x00000015\r
+\r
+typedef struct {\r
+  UINT32 CoolingDevice :5;\r
+  UINT32 CoolingDeviceStatus :3;\r
+  UINT32 Reserved :24;\r
+} EFI_MISC_COOLING_DEVICE_TYPE;\r
+\r
+typedef struct {\r
+  EFI_MISC_COOLING_DEVICE_TYPE  CoolingDeviceType;\r
+  EFI_INTER_LINK_DATA           CoolingDeviceTemperatureLink;\r
+  UINT8                         CoolingDeviceUnitGroup;\r
+  UINT16                        CoolingDeviceNominalSpeed;\r
+  UINT32                        CoolingDeviceOemDefined;\r
+} EFI_MISC_COOLING_DEVICE_TEMP_LINK;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Temperature Probe - SMBIOS Type 28\r
+//\r
+#define EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000016\r
+\r
+typedef struct {\r
+  UINT32 TemperatureProbeSite :5;\r
+  UINT32 TemperatureProbeStatus :3;\r
+  UINT32 Reserved :24;\r
+} EFI_MISC_TEMPERATURE_PROBE_LOCATION;\r
+\r
+typedef struct {\r
+  STRING_REF                            TemperatureProbeDescription;\r
+  EFI_MISC_TEMPERATURE_PROBE_LOCATION   TemperatureProbeLocation;\r
+  UINT16                                TemperatureProbeMaximumValue;\r
+  UINT16                                TemperatureProbeMinimumValue;\r
+  UINT16                                TemperatureProbeResolution;\r
+  UINT16                                TemperatureProbeTolerance;\r
+  UINT16                                TemperatureProbeAccuracy;\r
+  UINT16                                TemperatureProbeNominalValue;\r
+  UINT16                                MDLowerNoncriticalThreshold;\r
+  UINT16                                MDUpperNoncriticalThreshold;\r
+  UINT16                                MDLowerCriticalThreshold;\r
+  UINT16                                MDUpperCriticalThreshold;\r
+  UINT16                                MDLowerNonrecoverableThreshold;\r
+  UINT16                                MDUpperNonrecoverableThreshold;\r
+  UINT32                                TemperatureProbeOemDefined;\r
+} EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Electrical Current Probe - SMBIOS Type 29\r
+//\r
+#define EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000017\r
+\r
+typedef struct {\r
+  UINT32 ElectricalCurrentProbeSite :5;\r
+  UINT32 ElectricalCurrentProbeStatus :3;\r
+  UINT32 Reserved :24;\r
+} EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION;\r
+\r
+typedef struct {\r
+  STRING_REF                                  ElectricalCurrentProbeDescription;\r
+  EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION  ElectricalCurrentProbeLocation;\r
+  UINT16                                      ElectricalCurrentProbeMaximumValue;\r
+  UINT16                                      ElectricalCurrentProbeMinimumValue;\r
+  UINT16                                      ElectricalCurrentProbeResolution;\r
+  UINT16                                      ElectricalCurrentProbeTolerance;\r
+  UINT16                                      ElectricalCurrentProbeAccuracy;\r
+  UINT16                                      ElectricalCurrentProbeNominalValue;\r
+  UINT16                                      MDLowerNoncriticalThreshold;\r
+  UINT16                                      MDUpperNoncriticalThreshold;\r
+  UINT16                                      MDLowerCriticalThreshold;\r
+  UINT16                                      MDUpperCriticalThreshold;\r
+  UINT16                                      MDLowerNonrecoverableThreshold;\r
+  UINT16                                      MDUpperNonrecoverableThreshold;\r
+  UINT32                                      ElectricalCurrentProbeOemDefined;\r
+} EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Out-of-Band Remote Access - SMBIOS Type 30\r
+//\r
+#define EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION_RECORD_NUMBER 0x00000018\r
+\r
+typedef struct {\r
+  UINT32 InboundConnectionEnabled :1;\r
+  UINT32 OutboundConnectionEnabled :1;\r
+  UINT32 Reserved :30;\r
+} EFI_MISC_REMOTE_ACCESS_CONNECTIONS;\r
+\r
+typedef struct {\r
+  STRING_REF                          RemoteAccessManufacturerNameDescription;\r
+  EFI_MISC_REMOTE_ACCESS_CONNECTIONS  RemoteAccessConnections;\r
+} EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION;\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. BIS Entry Point - SMBIOS Type 31\r
+//\r
+#define EFI_MISC_BIS_ENTRY_POINT_RECORD_NUMBER          0x00000019\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS       BisEntryPoint;\r
+} EFI_MISC_BIS_ENTRY_POINT;    \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Boot Information - SMBIOS Type 32\r
+//\r
+#define EFI_MISC_BOOT_INFORMATION_STATUS_RECORD_NUMBER  0x0000001A\r
+\r
+typedef enum {  \r
+  EfiBootInformationStatusNoError = 0,\r
+  EfiBootInformationStatusNoBootableMedia = 1,\r
+  EfiBootInformationStatusNormalOSFailedLoading = 2,\r
+  EfiBootInformationStatusFirmwareDetectedFailure = 3,\r
+  EfiBootInformationStatusOSDetectedFailure = 4,\r
+  EfiBootInformationStatusUserRequestedBoot = 5,\r
+  EfiBootInformationStatusSystemSecurityViolation = 6,\r
+  EfiBootInformationStatusPreviousRequestedImage = 7,\r
+  EfiBootInformationStatusWatchdogTimerExpired = 8,\r
+  EfiBootInformationStatusStartReserved = 9,\r
+  EfiBootInformationStatusStartOemSpecific = 128,\r
+  EfiBootInformationStatusStartProductSpecific = 192,\r
+} EFI_MISC_BOOT_INFORMATION_STATUS_TYPE;\r
+\r
+typedef struct {\r
+    EFI_MISC_BOOT_INFORMATION_STATUS_TYPE BootInformationStatus;\r
+    UINT8                                 BootInformationData[9];\r
+} EFI_MISC_BOOT_INFORMATION_STATUS;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Management Device - SMBIOS Type 34\r
+//\r
+#define EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION_RECORD_NUMBER 0x0000001B\r
+\r
+typedef enum {\r
+  EfiManagementDeviceTypeOther     = 1,\r
+  EfiManagementDeviceTypeUnknown   = 2,\r
+  EfiManagementDeviceTypeLm75      = 3,\r
+  EfiManagementDeviceTypeLm78      = 4,\r
+  EfiManagementDeviceTypeLm79      = 5,\r
+  EfiManagementDeviceTypeLm80      = 6,\r
+  EfiManagementDeviceTypeLm81      = 7,\r
+  EfiManagementDeviceTypeAdm9240   = 8,\r
+  EfiManagementDeviceTypeDs1780    = 9,\r
+  EfiManagementDeviceTypeMaxim1617 = 0xA,\r
+  EfiManagementDeviceTypeGl518Sm   = 0xB,\r
+  EfiManagementDeviceTypeW83781D   = 0xC,\r
+  EfiManagementDeviceTypeHt82H791  = 0xD\r
+} EFI_MISC_MANAGEMENT_DEVICE_TYPE;\r
+\r
+typedef enum {\r
+  EfiManagementDeviceAddressTypeOther   = 1,\r
+  EfiManagementDeviceAddressTypeUnknown = 2,\r
+  EfiManagementDeviceAddressTypeIOPort  = 3,\r
+  EfiManagementDeviceAddressTypeMemory  = 4,\r
+  EfiManagementDeviceAddressTypeSmbus   = 5\r
+} EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE;\r
+\r
+typedef struct {\r
+  STRING_REF                              ManagementDeviceDescription;\r
+  EFI_MISC_MANAGEMENT_DEVICE_TYPE         ManagementDeviceType;\r
+  UINTN                                   ManagementDeviceAddress;\r
+  EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE ManagementDeviceAddressType;\r
+} EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Misc. Management Device Component - SMBIOS Type 35\r
+//\r
+#define EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION_RECORD_NUMBER 0x0000001C\r
+\r
+typedef struct {\r
+  STRING_REF            ManagementDeviceComponentDescription;\r
+  EFI_INTER_LINK_DATA   ManagementDeviceLink;\r
+  EFI_INTER_LINK_DATA   ManagementDeviceComponentLink;\r
+  EFI_INTER_LINK_DATA   ManagementDeviceThresholdLink;\r
+} EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IPMI Data Record - SMBIOS Type 38\r
+//\r
+typedef enum {  \r
+  EfiIpmiOther = 0,\r
+  EfiIpmiKcs = 1,\r
+  EfiIpmiSmic = 2,\r
+  EfiIpmiBt = 3,\r
+} EFI_MISC_IPMI_INTERFACE_TYPE;\r
+\r
+typedef struct {\r
+  UINT16  IpmiSpecLeastSignificantDigit:4;\r
+  UINT16  IpmiSpecMostSignificantDigit:4;\r
+  UINT16  Reserved:8;\r
+} EFI_MISC_IPMI_SPECIFICATION_REVISION;\r
+\r
+typedef struct {\r
+  EFI_MISC_IPMI_INTERFACE_TYPE          IpmiInterfaceType;\r
+  EFI_MISC_IPMI_SPECIFICATION_REVISION  IpmiSpecificationRevision;\r
+  UINT16                                IpmiI2CSlaveAddress;\r
+  UINT16                                IpmiNvDeviceAddress;\r
+  UINT64                                IpmiBaseAddress;\r
+  EFI_DEVICE_PATH_PROTOCOL              IpmiDevicePath;\r
+} EFI_MISC_IPMI_INTERFACE_TYPE_DATA;\r
+       \r
+#define EFI_MISC_IPMI_INTERFACE_TYPE_RECORD_NUMBER  0x0000001D\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//System Power supply Record - SMBIOS Type 39\r
+//\r
+typedef struct {\r
+  UINT16  PowerSupplyHotReplaceable  :1;\r
+  UINT16  PowerSupplyPresent         :1;\r
+  UINT16  PowerSupplyUnplugged       :1;\r
+  UINT16  InputVoltageRangeSwitch    :4;\r
+  UINT16  PowerSupplyStatus           :3;\r
+  UINT16  PowerSupplyType             :4;\r
+  UINT16  Reserved                   :2;\r
+} POWER_SUPPLY_CHARACTERISTICS;\r
+\r
+typedef struct {\r
+  UINT8                           PowerUnitGroup;\r
+  STRING_REF                      PowerSupplyLocation;\r
+  STRING_REF                      PowerSupplyDeviceName;\r
+  STRING_REF                      PowerSupplyManufacturer;\r
+  STRING_REF                      PowerSupplySerialNumber;\r
+  STRING_REF                      PowerSupplyAssetTagNumber;\r
+  STRING_REF                      PowerSupplyModelPartNumber;\r
+  STRING_REF                      PowerSupplyRevisionLevel;\r
+  UINT16                          PowerSupplyMaxPowerCapacity;\r
+  POWER_SUPPLY_CHARACTERISTICS    PowerSupplyCharacteristics;\r
+  EFI_INTER_LINK_DATA             PowerSupplyInputVoltageProbeLink;\r
+  EFI_INTER_LINK_DATA             PowerSupplyCoolingDeviceLink;\r
+  EFI_INTER_LINK_DATA             PowerSupplyInputCurrentProbeLink;\r
+} EFI_MISC_SYSTEM_POWER_SUPPLY;\r
+\r
+#define EFI_MISC_SYSTEM_POWER_SUPPLY_RECORD_NUMBER 0x0000001E\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generic Data Record - All SMBIOS Type\r
+// Put smbios raw data into one datahub record directly. Smbios driver would\r
+// copy smbios raw data into smbios table but not take any translation.\r
+//\r
+typedef struct {\r
+  UINT8       Type;\r
+  UINT8       Length;\r
+  UINT16      Handle;\r
+} SMBIOS_STRUCTURE_HDR;\r
+\r
+typedef struct {\r
+  SMBIOS_STRUCTURE_HDR          Header;\r
+  UINT8                         RawData[1];\r
+} EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION; \r
+\r
+#define EFI_MISC_SMBIOS_STRUCT_ENCAP_RECORD_NUMBER  0x0000001F \r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  Misc. System Event Log  - SMBIOS Type 15\r
+//\r
+#define EFI_MISC_SYSTEM_EVENT_LOG_RECORD_NUMBER 0x00000020\r
+typedef struct {\r
+  //SMBIOS_STRUCTURE_HDR  Header;\r
+  UINT16                LogAreaLength;\r
+  UINT16                LogHeaderStartOffset;\r
+  UINT16                LogDataStartOffset;\r
+  UINT8                 AccessMethod;\r
+  UINT8                 LogStatus;\r
+  UINT32                LogChangeToken;\r
+  UINT32                AccessMethodAddress;\r
+  UINT8                 LogHeaderFormat;\r
+  UINT8                 NumberOfSupportedLogType;\r
+  UINT8                 LengthOfLogDescriptor;\r
+} EFI_MISC_SYSTEM_EVENT_LOG;\r
+\r
+//\r
+// Access Method.\r
+//  0x00~0x04:  as following definition\r
+//  0x05~0x7f:  Available for future assignment.\r
+//  0x80~0xff:  BIOS Vendor/OEM-specific.\r
+// \r
+#define ACCESS_INDEXIO_1INDEX8BIT_DATA8BIT    0x00\r
+#define ACCESS_INDEXIO_2INDEX8BIT_DATA8BIT    0X01\r
+#define ACCESS_INDEXIO_1INDEX16BIT_DATA8BIT   0X02\r
+#define ACCESS_MEMORY_MAPPED                  0x03\r
+#define ACCESS_GPNV                           0x04\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//Management Device Threshold Data Record - SMBIOS Type 36\r
+//\r
+#define EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD_RECORD_NUMBER  0x00000021\r
+\r
+typedef struct {\r
+  UINT16                          LowerThresNonCritical;\r
+  UINT16                          UpperThresNonCritical;\r
+  UINT16                          LowerThresCritical;\r
+  UINT16                          UpperThresCritical;\r
+  UINT16                          LowerThresNonRecover;\r
+  UINT16                          UpperThresNonRecover;\r
+} EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD;\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+//\r
+typedef union {\r
+  EFI_MISC_LAST_PCI_BUS                                 LastPciBus;\r
+  EFI_MISC_BIOS_VENDOR                                  MiscBiosVendor;\r
+  EFI_MISC_SYSTEM_MANUFACTURER                          MiscSystemManufacturer;\r
+  EFI_MISC_BASE_BOARD_MANUFACTURER                      MiscBaseBoardManufacturer;\r
+  EFI_MISC_CHASSIS_MANUFACTURER                         MiscChassisManufacturer;  \r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR           MiscPortInternalConnectorDesignator;\r
+  EFI_MISC_SYSTEM_SLOT_DESIGNATION                      MiscSystemSlotDesignation;\r
+  EFI_MISC_ONBOARD_DEVICE                               MiscOnboardDevice;\r
+  EFI_MISC_OEM_STRING                                   MiscOemString;\r
+  EFI_MISC_SYSTEM_OPTION_STRING                         MiscOptionString;\r
+  EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES              NumberOfInstallableLanguages;\r
+  EFI_MISC_SYSTEM_LANGUAGE_STRING                       MiscSystemLanguageString;\r
+  EFI_MISC_GROUP_NAME_DATA                              MiscGroupNameData;\r
+  EFI_MISC_GROUP_ITEM_SET_DATA                          MiscGroupItemSetData;\r
+  EFI_MISC_SYSTEM_EVENT_LOG                             MiscSystemEventLog;\r
+  EFI_MISC_ONBOARD_DEVICE_TYPE_DATA                     MiscOnboardDeviceTypeData;\r
+  EFI_MISC_PORTABLE_BATTERY                             MiscPortableBattery;\r
+  EFI_MISC_RESET_CAPABILITIES_DATA                      MiscResetCapablilitiesData;\r
+  EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA              MiscHardwareSecuritySettingsData;\r
+  EFI_MISC_SCHEDULED_POWER_ON_MONTH                     MiscScheduledPowerOnMonth;\r
+  EFI_MISC_VOLTAGE_PROBE_DESCRIPTION                    MiscVoltageProbeDescription;\r
+  EFI_MISC_COOLING_DEVICE_TEMP_LINK                     MiscCoolingDeviceTempLink;\r
+  EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION                MiscTemperatureProbeDescription;\r
+  EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION         MiscElectricalCurrentProbeDescription;\r
+  EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION       MiscRemoteAccessManufacturerDescription;  \r
+  EFI_MISC_BIS_ENTRY_POINT                              MiscBisEntryPoint;\r
+  EFI_MISC_BOOT_INFORMATION_STATUS                      MiscBootInformationStatus;\r
+  EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION                MiscManagementDeviceDescription;\r
+  EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION      MiscManagementDeviceComponentDescription;\r
+  EFI_MISC_IPMI_INTERFACE_TYPE_DATA                     MiscIpmiInterfaceTypeData;\r
+  EFI_MISC_SYSTEM_POWER_SUPPLY                          MiscPowerSupplyInfo;\r
+  EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION                  MiscSmbiosStructEncapsulation; \r
+  EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD                  MiscManagementDeviceThreshold; \r
+} EFI_MISC_SUBCLASS_RECORDS;\r
+\r
+//\r
+//\r
+//\r
+typedef struct {\r
+  EFI_SUBCLASS_TYPE1_HEADER       Header;\r
+  EFI_MISC_SUBCLASS_RECORDS       Record;\r
+} EFI_MISC_SUBCLASS_DRIVER_DATA;\r
+\r
+#pragma pack()\r
+\r
+#endif /* _DATAHUB_SUBCLASS_MISC_H_ */\r
+/* eof - DataHubSubClassMisc.h */\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
new file mode 100644 (file)
index 0000000..ed0c885
--- /dev/null
@@ -0,0 +1,360 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHubSubClassProcessor.h\r
+\r
+Abstract:\r
+\r
+  Definitions for processor sub class data records\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DATAHUB_SUBCLASS_PROCESSOR_H_\r
+#define _DATAHUB_SUBCLASS_PROCESSOR_H_\r
+\r
+#define EFI_PROCESSOR_SUBCLASS_VERSION    0x00010000\r
+\r
+#define EFI_PROCESSOR_SUBCLASS_GUID \\r
+  { 0x26fdeb7e, 0xb8af, 0x4ccf, 0xaa, 0x97, 0x02, 0x63, 0x3c, 0xe4, 0x8c, 0xa7 }\r
+\r
+\r
+typedef EFI_EXP_BASE10_DATA   EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA   EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA   EFI_PROCESSOR_CORE_FREQUENCY_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA  *EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA  *EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA   EFI_PROCESSOR_FSB_FREQUENCY_DATA;\r
+\r
+typedef STRING_REF            EFI_PROCESSOR_VERSION_DATA;\r
+\r
+typedef STRING_REF            EFI_PROCESSOR_MANUFACTURER_DATA;\r
+\r
+typedef STRING_REF            EFI_PROCESSOR_SERIAL_NUMBER_DATA;\r
+\r
+typedef STRING_REF            EFI_PROCESSOR_ASSET_TAG_DATA;\r
+\r
+typedef struct {\r
+  UINT32  ProcessorSteppingId:4;\r
+  UINT32  ProcessorModel:     4;\r
+  UINT32  ProcessorFamily:    4;\r
+  UINT32  ProcessorType:      2;\r
+  UINT32  ProcessorReserved1: 2;\r
+  UINT32  ProcessorXModel:    4;\r
+  UINT32  ProcessorXFamily:   8;\r
+  UINT32  ProcessorReserved2: 4;\r
+} EFI_PROCESSOR_SIGNATURE;\r
+\r
+typedef struct {\r
+  UINT32  ProcessorBrandIndex :8;\r
+  UINT32  ProcessorClflush    :8;\r
+  UINT32  ProcessorReserved   :8;\r
+  UINT32  ProcessorDfltApicId :8;\r
+} EFI_PROCESSOR_MISC_INFO;\r
+\r
+typedef struct {\r
+  UINT32  ProcessorFpu:       1;\r
+  UINT32  ProcessorVme:       1;\r
+  UINT32  ProcessorDe:        1;\r
+  UINT32  ProcessorPse:       1;\r
+  UINT32  ProcessorTsc:       1;\r
+  UINT32  ProcessorMsr:       1;\r
+  UINT32  ProcessorPae:       1;\r
+  UINT32  ProcessorMce:       1;\r
+  UINT32  ProcessorCx8:       1;\r
+  UINT32  ProcessorApic:      1;\r
+  UINT32  ProcessorReserved1: 1;\r
+  UINT32  ProcessorSep:       1;\r
+  UINT32  ProcessorMtrr:      1;\r
+  UINT32  ProcessorPge:       1;\r
+  UINT32  ProcessorMca:       1;\r
+  UINT32  ProcessorCmov:      1;\r
+  UINT32  ProcessorPat:       1;\r
+  UINT32  ProcessorPse36:     1;\r
+  UINT32  ProcessorPsn:       1;\r
+  UINT32  ProcessorClfsh:     1;\r
+  UINT32  ProcessorReserved2: 1;\r
+  UINT32  ProcessorDs:        1;\r
+  UINT32  ProcessorAcpi:      1;\r
+  UINT32  ProcessorMmx:       1;\r
+  UINT32  ProcessorFxsr:      1;\r
+  UINT32  ProcessorSse:       1;\r
+  UINT32  ProcessorSse2:      1;\r
+  UINT32  ProcessorSs:        1;\r
+  UINT32  ProcessorReserved3: 1;\r
+  UINT32  ProcessorTm:        1;\r
+  UINT32  ProcessorReserved4: 2;\r
+} EFI_PROCESSOR_FEATURE_FLAGS;\r
+\r
+typedef struct {\r
+  EFI_PROCESSOR_SIGNATURE     Signature;\r
+  EFI_PROCESSOR_MISC_INFO     MiscInfo;\r
+  UINT32                      Reserved;\r
+  EFI_PROCESSOR_FEATURE_FLAGS FeatureFlags;\r
+} EFI_PROCESSOR_ID_DATA;\r
+\r
+typedef enum {\r
+  EfiProcessorOther = 1,\r
+  EfiProcessorUnknown = 2,\r
+  EfiCentralProcessor = 3,\r
+  EfiMathProcessor = 4,\r
+  EfiDspProcessor = 5,\r
+  EfiVideoProcessor = 6\r
+} EFI_PROCESSOR_TYPE_DATA;\r
+\r
+typedef enum {\r
+  EfiProcessorFamilyOther        = 1, \r
+  EfiProcessorFamilyUnknown      = 2,\r
+  EfiProcessorFamily8086         = 3, \r
+  EfiProcessorFamily80286        = 4,\r
+  EfiProcessorFamilyIntel386     = 5, \r
+  EfiProcessorFamilyIntel486     = 6,\r
+  EfiProcessorFamily8087         = 7,\r
+  EfiProcessorFamily80287        = 8,\r
+  EfiProcessorFamily80387        = 9, \r
+  EfiProcessorFamily80487        = 0x0A,\r
+  EfiProcessorFamilyPentium      = 0x0B, \r
+  EfiProcessorFamilyPentiumPro   = 0x0C,\r
+  EfiProcessorFamilyPentiumII    = 0x0D,\r
+  EfiProcessorFamilyPentiumMMX   = 0x0E,\r
+  EfiProcessorFamilyCeleron      = 0x0F,\r
+  EfiProcessorFamilyPentiumIIXeon = 0x10,\r
+  EfiProcessorFamilyPentiumIII   = 0x11, \r
+  EfiProcessorFamilyM1           = 0x12,\r
+  EfiProcessorFamilyM2           = 0x13,\r
+  EfiProcessorFamilyM1Reserved2 = 0x14,\r
+  EfiProcessorFamilyM1Reserved3  = 0x15,\r
+  EfiProcessorFamilyM1Reserved4  = 0x16,\r
+  EfiProcessorFamilyM1Reserved5  = 0x17,\r
+  EfiProcessorFamilyAmdDuron     = 0x18,\r
+  EfiProcessorFamilyK5           = 0x19, \r
+  EfiProcessorFamilyK6           = 0x1A,\r
+  EfiProcessorFamilyK6_2         = 0x1B,\r
+  EfiProcessorFamilyK6_3         = 0x1C,\r
+  EfiProcessorFamilyAmdAthlon    = 0x1D,\r
+  EfiProcessorFamilyK6_2Plus     = 0x1E,\r
+  EfiProcessorFamilyK5Reserved6  = 0x1F,\r
+  EfiProcessorFamilyPowerPC      = 0x20,\r
+  EfiProcessorFamilyPowerPC601   = 0x21,\r
+  EfiProcessorFamilyPowerPC603   = 0x22,\r
+  EfiProcessorFamilyPowerPC603Plus = 0x23,\r
+  EfiProcessorFamilyPowerPC604   = 0x24,\r
+  EfiProcessorFamilyPowerPC620   = 0x25,\r
+  EfiProcessorFamilyPowerPC704   = 0x26,\r
+  EfiProcessorFamilyPowerPC750   = 0x27,\r
+  EfiProcessorFamilyAlpha2       = 0x30,\r
+  EfiProcessorFamilyAlpha21064   = 0x31,\r
+  EfiProcessorFamilyAlpha21066   = 0x32,\r
+  EfiProcessorFamilyAlpha21164   = 0x33,\r
+  EfiProcessorFamilyAlpha21164PC = 0x34,\r
+  EfiProcessorFamilyAlpha21164a  = 0x35,\r
+  EfiProcessorFamilyAlpha21264   = 0x36,\r
+  EfiProcessorFamilyAlpha21364   = 0x37,\r
+  EfiProcessorFamilyMips         = 0x40,\r
+  EfiProcessorFamilyMIPSR4000    = 0x41,\r
+  EfiProcessorFamilyMIPSR4200    = 0x42,\r
+  EfiProcessorFamilyMIPSR4400    = 0x43,\r
+  EfiProcessorFamilyMIPSR4600    = 0x44,\r
+  EfiProcessorFamilyMIPSR10000   = 0x45,\r
+  EfiProcessorFamilySparc        = 0x50,\r
+  EfiProcessorFamilySuperSparc   = 0x51,\r
+  EfiProcessorFamilymicroSparcII = 0x52,\r
+  EfiProcessorFamilymicroSparcIIep = 0x53,\r
+  EfiProcessorFamilyUltraSparc   = 0x54,\r
+  EfiProcessorFamilyUltraSparcII = 0x55,\r
+  EfiProcessorFamilyUltraSparcIIi = 0x56,\r
+  EfiProcessorFamilyUltraSparcIII = 0x57,\r
+  EfiProcessorFamilyUltraSparcIIIi = 0x58,\r
+  EfiProcessorFamily68040        = 0x60,\r
+  EfiProcessorFamily68xxx        = 0x61,\r
+  EfiProcessorFamily68000        = 0x62,\r
+  EfiProcessorFamily68010        = 0x63,\r
+  EfiProcessorFamily68020        = 0x64,\r
+  EfiProcessorFamily68030        = 0x65,\r
+  EfiProcessorFamilyHobbit       = 0x70,\r
+  EfiProcessorFamilyCrusoeTM5000 = 0x78,\r
+  EfiProcessorFamilyCrusoeTM3000 = 0x79,\r
+  EfiProcessorFamilyWeitek       = 0x80,\r
+  EfiProcessorFamilyItanium      = 0x82,\r
+  EfiProcessorFamilyAmdAthlon64  = 0x83,\r
+  EfiProcessorFamilyAmdOpteron   = 0x84,\r
+  EfiProcessorFamilyPARISC       = 0x90,\r
+  EfiProcessorFamilyPaRisc8500   = 0x91,\r
+  EfiProcessorFamilyPaRisc8000   = 0x92,\r
+  EfiProcessorFamilyPaRisc7300LC = 0x93,\r
+  EfiProcessorFamilyPaRisc7200   = 0x94,\r
+  EfiProcessorFamilyPaRisc7100LC = 0x95,\r
+  EfiProcessorFamilyPaRisc7100   = 0x96,\r
+  EfiProcessorFamilyV30          = 0xA0,\r
+  EfiProcessorFamilyPentiumIIIXeon = 0xB0,\r
+  EfiProcessorFamilyPentiumIIISpeedStep = 0xB1,\r
+  EfiProcessorFamilyPentium4     = 0xB2,\r
+  EfiProcessorFamilyIntelXeon    = 0xB3,\r
+  EfiProcessorFamilyAS400        = 0xB4,\r
+  EfiProcessorFamilyIntelXeonMP  = 0xB5,\r
+  EfiProcessorFamilyAMDAthlonXP = 0xB6,\r
+  EfiProcessorFamilyAMDAthlonMP = 0xB7,\r
+  EfiProcessorFamilyIntelItanium2 = 0xB8,\r
+  EfiProcessorFamilyIntelPentiumM = 0xB9,\r
+  EfiProcessorFamilyIntelCeleronD = 0xBA,\r
+  EfiProcessorFamilyIntelPentiumD = 0xBB,\r
+  EfiProcessorFamilyIntelPentiumEx = 0xBC,\r
+  EfiProcessorFamilyIBM390       = 0xC8,\r
+  EfiProcessorFamilyG4           = 0xC9,\r
+  EfiProcessorFamilyG5           = 0xCA,\r
+  EfiProcessorFamilyi860         = 0xFA,\r
+  EfiProcessorFamilyi960         = 0xFB\r
+} EFI_PROCESSOR_FAMILY_DATA;\r
+\r
+\r
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_VOLTAGE_DATA;\r
+\r
+typedef EFI_PHYSICAL_ADDRESS EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA;\r
+\r
+typedef UINT32 EFI_PROCESSOR_APIC_ID_DATA;\r
+\r
+typedef UINT32 EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA;\r
+\r
+typedef enum {\r
+  EfiProcessorIa32Microcode = 1,\r
+  EfiProcessorIpfPalAMicrocode = 2,\r
+  EfiProcessorIpfPalBMicrocode = 3\r
+} EFI_PROCESSOR_MICROCODE_TYPE;\r
+\r
+typedef struct {\r
+  EFI_PROCESSOR_MICROCODE_TYPE  ProcessorMicrocodeType;\r
+  UINT32                        ProcessorMicrocodeRevisionNumber;\r
+} EFI_PROCESSOR_MICROCODE_REVISION_DATA;\r
+\r
+typedef struct {\r
+  UINT32      CpuStatus       :3;\r
+  UINT32      Reserved1        :3;\r
+  UINT32      SocketPopulated     :1;\r
+  UINT32      Reserved2        :1;\r
+  UINT32      ApicEnable        :1;\r
+  UINT32      BootApplicationProcessor  :1;\r
+  UINT32      Reserved3        :22;\r
+} EFI_PROCESSOR_STATUS_DATA;\r
+\r
+typedef enum {\r
+  EfiCpuStatusUnknown = 0,\r
+  EfiCpuStatusEnabled = 1,\r
+  EfiCpuStatusDisabledByUser = 2,\r
+  EfiCpuStatusDisabledbyBios = 3,\r
+  EfiCpuStatusIdle = 4,\r
+  EfiCpuStatusOther = 7\r
+} EFI_CPU_STATUS;\r
+\r
+typedef enum {\r
+  EfiProcessorSocketOther = 1,\r
+  EfiProcessorSocketUnknown = 2,\r
+  EfiProcessorSocketDaughterBoard = 3,\r
+  EfiProcessorSocketZIF = 4,\r
+  EfiProcessorSocketReplacePiggyBack = 5,\r
+  EfiProcessorSocketNone = 6,\r
+  EfiProcessorSocketLIF = 7,\r
+  EfiProcessorSocketSlot1 = 8,\r
+  EfiProcessorSocketSlot2 = 9,\r
+  EfiProcessorSocket370Pin = 0xA,\r
+  EfiProcessorSocketSlotA = 0xB,\r
+  EfiProcessorSocketSlotM = 0xC,\r
+  EfiProcessorSocket423 = 0xD,\r
+  EfiProcessorSocketA462 = 0xE,\r
+  EfiProcessorSocket478 = 0xF,\r
+  EfiProcessorSocket754 = 0x10,\r
+  EfiProcessorSocket940 = 0x11,\r
+  EfiProcessorSocket939 = 0x12,\r
+  EfiProcessorSocketmPGA604 = 0x13,\r
+  EfiProcessorSocketLGA771 = 0x14,\r
+  EfiProcessorSocketLGA775 = 0x15\r
+} EFI_PROCESSOR_SOCKET_TYPE_DATA;\r
+\r
+typedef STRING_REF EFI_PROCESSOR_SOCKET_NAME_DATA;\r
+\r
+typedef EFI_INTER_LINK_DATA EFI_CACHE_ASSOCIATION_DATA;\r
+\r
+typedef enum {\r
+  EfiProcessorHealthy = 1,\r
+  EfiProcessorPerfRestricted = 2,\r
+  EfiProcessorFuncRestricted = 3\r
+} EFI_PROCESSOR_HEALTH_STATUS;  \r
+\r
+typedef UINTN   EFI_PROCESSOR_PACKAGE_NUMBER_DATA;\r
+\r
+typedef EFI_EXP_BASE10_DATA   EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA;\r
+\r
+typedef enum {\r
+  ProcessorCoreFrequencyRecordType = 1,\r
+  ProcessorFsbFrequencyRecordType = 2,\r
+  ProcessorVersionRecordType = 3,\r
+  ProcessorManufacturerRecordType = 4,\r
+  ProcessorSerialNumberRecordType = 5,\r
+  ProcessorIdRecordType = 6,\r
+  ProcessorTypeRecordType = 7,\r
+  ProcessorFamilyRecordType = 8,\r
+  ProcessorVoltageRecordType = 9,\r
+  ProcessorApicBaseAddressRecordType = 10,\r
+  ProcessorApicIdRecordType = 11,\r
+  ProcessorApicVersionNumberRecordType = 12,\r
+  CpuUcodeRevisionDataRecordType = 13,\r
+  ProcessorStatusRecordType = 14,\r
+  ProcessorSocketTypeRecordType = 15,\r
+  ProcessorSocketNameRecordType = 16,\r
+  CacheAssociationRecordType = 17,\r
+  ProcessorMaxCoreFrequencyRecordType = 18,\r
+  ProcessorAssetTagRecordType = 19,\r
+  ProcessorMaxFsbFrequencyRecordType = 20,\r
+  ProcessorPackageNumberRecordType = 21,\r
+  ProcessorCoreFrequencyListRecordType = 22,\r
+  ProcessorFsbFrequencyListRecordType  = 23,\r
+  ProcessorHealthStatusRecordType  = 24\r
+} EFI_CPU_VARIABLE_RECORD_TYPE;\r
+\r
+typedef union {\r
+  EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA  ProcessorCoreFrequencyList;\r
+  EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA   ProcessorFsbFrequencyList;\r
+  EFI_PROCESSOR_SERIAL_NUMBER_DATA        ProcessorSerialNumber;\r
+  EFI_PROCESSOR_CORE_FREQUENCY_DATA       ProcessorCoreFrequency;\r
+  EFI_PROCESSOR_FSB_FREQUENCY_DATA        ProcessorFsbFrequency;\r
+  EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA   ProcessorMaxCoreFrequency;\r
+  EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA    ProcessorMaxFsbFrequency;\r
+  EFI_PROCESSOR_VERSION_DATA              ProcessorVersion;\r
+  EFI_PROCESSOR_MANUFACTURER_DATA         ProcessorManufacturer;\r
+  EFI_PROCESSOR_ID_DATA                   ProcessorId;\r
+  EFI_PROCESSOR_TYPE_DATA                 ProcessorType;\r
+  EFI_PROCESSOR_FAMILY_DATA               ProcessorFamily;\r
+  EFI_PROCESSOR_VOLTAGE_DATA              ProcessorVoltage;\r
+  EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA    ProcessorApicBase;\r
+  EFI_PROCESSOR_APIC_ID_DATA              ProcessorApicId;\r
+  EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA  ProcessorApicVersionNumber;\r
+  EFI_PROCESSOR_MICROCODE_REVISION_DATA   CpuUcodeRevisionData;\r
+  EFI_PROCESSOR_STATUS_DATA               ProcessorStatus;\r
+  EFI_PROCESSOR_SOCKET_TYPE_DATA          ProcessorSocketType;\r
+  EFI_PROCESSOR_SOCKET_NAME_DATA          ProcessorSocketName;\r
+  EFI_PROCESSOR_ASSET_TAG_DATA            ProcessorAssetTag;\r
+  EFI_PROCESSOR_HEALTH_STATUS             ProcessorHealthStatus;\r
+  EFI_PROCESSOR_PACKAGE_NUMBER_DATA       ProcessorPackageNumber;\r
+} EFI_CPU_VARIABLE_RECORD;\r
+\r
+typedef struct {\r
+  EFI_SUBCLASS_TYPE1_HEADER      DataRecordHeader;\r
+  EFI_CPU_VARIABLE_RECORD        VariableRecord;\r
+} EFI_CPU_DATA_RECORD;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c
new file mode 100644 (file)
index 0000000..4d991f9
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DxeServices.c\r
+    \r
+Abstract:\r
+\r
+  GUID used for the DXE Services Table\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (DxeServices)\r
+\r
+EFI_GUID  gEfiDxeServicesTableGuid = EFI_DXE_SERVICES_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDxeServicesTableGuid, "DXE Services Table", "DXE Services Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h
new file mode 100644 (file)
index 0000000..29a4050
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DxeServices.h\r
+    \r
+Abstract:\r
+\r
+  GUID used for the DXE Services Table\r
+\r
+--*/\r
+\r
+#ifndef _DXE_SERVICES_H_\r
+#define _DXE_SERVICES_H_\r
+\r
+#define EFI_DXE_SERVICES_TABLE_GUID \\r
+  { \\r
+    0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 \\r
+  }\r
+\r
+extern EFI_GUID gEfiDxeServicesTableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf
new file mode 100644 (file)
index 0000000..f3c2b74
--- /dev/null
@@ -0,0 +1,63 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkFrameworkGuidLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkFrameworkGuidLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  \r
+[nmake.common]\r
+\r
+[sources.common]\r
+  AcpiTableStorage\AcpiTableStorage.h\r
+  AcpiTableStorage\AcpiTableStorage.c\r
+  Apriori\Apriori.h\r
+  Apriori\Apriori.c\r
+  DataHubRecords\DataHubRecords.h\r
+  DataHubRecords\DataHubRecords.c  \r
+  DxeServices\DxeServices.h\r
+  DxeServices\DxeServices.c\r
+  FirmwareFileSystem\FirmwareFileSystem.h\r
+  FirmwareFileSystem\FirmwareFileSystem.c\r
+  Hob\Hob.h\r
+  Hob\Hob.c\r
+  MemoryAllocationHob\MemoryAllocationHob.c\r
+  MemoryAllocationHob\MemoryAllocationHob.h\r
+  SmramMemoryReserve\SmramMemoryReserve.h\r
+  SmramMemoryReserve\SmramMemoryReserve.c\r
+  StatusCodeDataTypeId\StatusCodeDataTypeId.h\r
+  StatusCodeDataTypeId\StatusCodeDataTypeId.c\r
+  FrameworkDevicePath\FrameworkDevicePath.h\r
+  FrameworkDevicePath\FrameworkDevicePath.c\r
+  FirmwareFileSystem2\FirmwareFileSystem2.h\r
+  FirmwareFileSystem2\FirmwareFileSystem2.c\r
+  PeiApriori\PeiApriori.h\r
+  PeiApriori\PeiApriori.c\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c
new file mode 100644 (file)
index 0000000..a704cf1
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareFileSystem.c\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used to define the Firmware File System.  See the EFI Firmware \r
+  File System Specification for more details.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
+\r
+EFI_GUID  gEfiFirmwareFileSystemGuid    = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
+EFI_GUID  gEfiFirmwareVolumeTopFileGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFirmwareFileSystemGuid, "Firmware File System GUID", "EFI Firmware File System GUID");\r
+EFI_GUID_STRING(&gEfiFirmwareVolumeTopFileGuid, "Firmware Volume Top File GUID", "EFI FFS Volume Top File GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h
new file mode 100644 (file)
index 0000000..6d04092
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareFileSystem.h\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used to define the Firmware File System.  See the EFI Firmware \r
+  File System Specification for more details.\r
+\r
+--*/\r
+\r
+#ifndef _FIRMWARE_FILE_SYSTEM_GUID_H\r
+#define _FIRMWARE_FILE_SYSTEM_GUID_H\r
+\r
+//\r
+// GUID definitions are in EfiFirmwareFileSystem.h\r
+//\r
+#include "EfiFirmwareFileSystem.h"\r
+\r
+extern EFI_GUID gEfiFirmwareFileSystemGuid;\r
+extern EFI_GUID gEfiFirmwareVolumeTopFileGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c
new file mode 100644 (file)
index 0000000..27a8b83
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareFileSystem2.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(FirmwareFileSystem2)\r
+\r
+EFI_GUID gEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
+EFI_GUID_STRING(&gEfiFirmwareFileSystem2Guid, "FirmwareFileSystem2", "Efi FirmwareFileSystem2")\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h
new file mode 100644 (file)
index 0000000..3aca502
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareFileSystem2.h\r
+\r
+Abstract:\r
+\r
+   PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __FIRMWARE_FILE_SYSTEM2_GUID_H__\r
+#define __FIRMWARE_FILE_SYSTEM2_GUID_H__\r
+\r
+//\r
+// GUIDs defined by the FFS specification.\r
+//\r
+#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \\r
+  { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }\r
+\r
+extern EFI_GUID gEfiFirmwareFileSystem2Guid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c
new file mode 100644 (file)
index 0000000..60562c9
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FrameworkDevicePath.c\r
+    \r
+Abstract:\r
+\r
+  GUID used for \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
+\r
+EFI_GUID  gEfiFrameworkDevicePathGuid = EFI_FRAMEWORK_DEVICE_PATH_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFrameworkDevicePathGuid, "Framework Devic Path", "Framework Device Path GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h
new file mode 100644 (file)
index 0000000..e8adbaf
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+       This GUID is used to define a vendor specific device path being owned by the \r
+       Framework specificaitons. \r
+\r
+       Copyright (c) 2006, Intel Corporation                                                         \r
+       All rights reserved. This program and the accompanying materials                          \r
+       are licensed and made available under the terms and conditions of the BSD License         \r
+       which accompanies this distribution.  The full text of the license may be found at        \r
+       http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+       Module Name:    FrameworkDevicePath.h\r
+\r
+       @par Revision Reference:\r
+       Spec Version 0.9\r
+\r
+--*/\r
+\r
+#ifndef __FRAMEWORK_DEVICE_PATH_GUID_H__\r
+#define __FRAMEWORK_DEVICE_PATH_GUID_H__\r
+\r
+#define EFI_FRAMEWORK_DEVICE_PATH_GUID  \\r
+  { 0xb7084e63, 0x46b7, 0x4d1a, { 0x86, 0x77, 0xe3, 0x0b, 0x53, 0xdb, 0xf0, 0x50 } }\r
+\r
+extern EFI_GUID gEfiFrameworkDevicePathGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c
new file mode 100644 (file)
index 0000000..b69d107
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Hob.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for HOB List in the EFI 1.0 system table\r
+\r
+  These GUIDs point the HOB List passed in from PEI to DXE.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (Hob)\r
+\r
+EFI_GUID  gEfiHobListGuid = EFI_HOB_LIST_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHobListGuid, "HOB List", "HOB List GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h
new file mode 100644 (file)
index 0000000..250359f
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Hob.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for HOB List entries in the in the EFI 1.0 system table\r
+\r
+  These GUIDs point the HOB List passed from PEI to DXE.\r
+\r
+--*/\r
+\r
+#ifndef _HOB_GUID_H_\r
+#define _HOB_GUID_H_\r
+\r
+#define EFI_HOB_LIST_GUID \\r
+  { \\r
+    0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \\r
+  }\r
+\r
+extern EFI_GUID gEfiHobListGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c
new file mode 100644 (file)
index 0000000..7a03712
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MemoryAllocationHob.c\r
+    \r
+Abstract:\r
+\r
+    GUIDs for HOBs used in memory allcation\r
+    \r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(MemoryAllocationHob)\r
+\r
+EFI_GUID gEfiHobMemeryAllocBspStoreGuid  = EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID;\r
+EFI_GUID gEfiHobMemeryAllocStackGuid     = EFI_HOB_MEMORY_ALLOC_STACK_GUID;\r
+EFI_GUID gEfiHobMemeryAllocModuleGuid    = EFI_HOB_MEMORY_ALLOC_MODULE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHobMemeryAllocBspStoreGuid, "BSP Store HOB", "HOB for BSP Store Memory Allocation");\r
+EFI_GUID_STRING(&gEfiHobMemeryAllocStackGuid, "Stack HOB", "HOB for Stack Memory Allocation");\r
+EFI_GUID_STRING(&gEfiHobMemeryAllocModuleGuid, "Memry Allocation Module HOB", "HOB for Memory Allocation Module");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h
new file mode 100644 (file)
index 0000000..9afc36d
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MemoryAllocationHob.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs for HOBs used in memory allcation\r
+\r
+--*/\r
+\r
+#ifndef _HOB__MEMORY_ALLOCATION_GUID_H_\r
+#define _HOB__MEMORY_ALLOCATION_GUID_H_\r
+\r
+#define EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID  \\r
+  {0x564b33cd, 0xc92a, 0x4593, 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22};\r
+\r
+#define EFI_HOB_MEMORY_ALLOC_STACK_GUID  \\r
+  {0x4ed4bf27, 0x4092, 0x42e9, 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x0, 0xc9, 0xbd}\r
+\r
+#define EFI_HOB_MEMORY_ALLOC_MODULE_GUID  \\r
+  {0xf8e21975, 0x899, 0x4f58, 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a}\r
+\r
+extern EFI_GUID gEfiHobMemeryAllocBspStoreGuid;\r
+extern EFI_GUID gEfiHobMemeryAllocStackGuid;\r
+extern EFI_GUID gEfiHobMemeryAllocModuleGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c
new file mode 100644 (file)
index 0000000..c8136ef
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiApriori.c\r
+\r
+Abstract:\r
+\r
+   PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PeiApriori)\r
+\r
+EFI_GUID gEfiPeiAprioriGuid = EFI_PEI_APRIORI_FILE_NAME_GUID;\r
+EFI_GUID_STRING(&gEfiPeiAprioriGuid, "PeiApriori", "Efi PeiApriori")\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h
new file mode 100644 (file)
index 0000000..9125e45
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiApriori.h\r
+\r
+Abstract:\r
+\r
+   PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __PEI_APRIORI_GUID_H__\r
+#define __PEI_APRIORI_GUID_H__\r
+\r
+#include "Tiano.h"\r
+\r
+//\r
+// GUIDs defined by the FFS specification.\r
+//\r
+#define EFI_PEI_APRIORI_FILE_NAME_GUID \\r
+  { 0x1b45cc0a, 0x156a, 0x428a, 0xaf, 0x62, 0x49, 0x86, 0x4d, 0xa0, 0xe6, 0xe6}\r
+\r
+\r
+extern EFI_GUID gEfiPeiAprioriGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c
new file mode 100644 (file)
index 0000000..ea03917
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmramMemoryReserve.c\r
+    \r
+Abstract:\r
+\r
+  GUID for use in reserving SMRAM regions.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(SmramMemoryReserve)\r
+\r
+EFI_GUID gEfiSmmPeiSmramMemoryReserve  = EFI_SMM_PEI_SMRAM_MEMORY_RESERVE;\r
+\r
+EFI_GUID_STRING(&gEfiSmmPeiSmramMemoryReserve, "SMRAM Memory Reserve", "SMRAM Memory Reserve");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h
new file mode 100644 (file)
index 0000000..d848e28
--- /dev/null
@@ -0,0 +1,70 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmramMemoryReserve.h\r
+    \r
+Abstract:\r
+\r
+  GUID for use in reserving SMRAM regions.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_\r
+#define _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_\r
+\r
+#define EFI_SMM_PEI_SMRAM_MEMORY_RESERVE \\r
+  { \\r
+    0x6dadf1d1, 0xd4cc, 0x4910, 0xbb, 0x6e, 0x82, 0xb1, 0xfd, 0x80, 0xff, 0x3d \\r
+  }\r
+\r
+//\r
+// *******************************************************\r
+//  EFI_SMRAM_DESCRIPTOR\r
+// *******************************************************\r
+//\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  PhysicalStart;  // Phsyical location in DRAM\r
+  EFI_PHYSICAL_ADDRESS  CpuStart;       // Address CPU uses to access the SMI handler\r
+  // May or may not match PhysicalStart\r
+  //\r
+  UINT64                PhysicalSize;\r
+  UINT64                RegionState;\r
+} EFI_SMRAM_DESCRIPTOR;\r
+\r
+//\r
+// *******************************************************\r
+//  EFI_SMRAM_STATE\r
+// *******************************************************\r
+//\r
+#define EFI_SMRAM_OPEN                0x00000001\r
+#define EFI_SMRAM_CLOSED              0x00000002\r
+#define EFI_SMRAM_LOCKED              0x00000004\r
+#define EFI_CACHEABLE                 0x00000008\r
+#define EFI_ALLOCATED                 0x00000010\r
+#define EFI_NEEDS_TESTING             0x00000020\r
+#define EFI_NEEDS_ECC_INITIALIZATION  0x00000040\r
+\r
+//\r
+// *******************************************************\r
+//  EFI_SMRAM_HOB_DESCRIPTOR_BLOCK\r
+// *******************************************************\r
+//\r
+typedef struct {\r
+  UINT32                NumberOfSmmReservedRegions;\r
+  EFI_SMRAM_DESCRIPTOR  Descriptor[1];\r
+} EFI_SMRAM_HOB_DESCRIPTOR_BLOCK;\r
+\r
+extern EFI_GUID gEfiSmmPeiSmramMemoryReserve;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c
new file mode 100644 (file)
index 0000000..1fa9c2e
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeDataTypeId.c\r
+    \r
+Abstract:\r
+\r
+  GUID used to identify id for the caller who is initiating the Status Code.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+//\r
+// Taken out from StatusCode.C created by PRC\r
+//\r
+EFI_GUID  gEfiStatusCodeDataTypeStringGuid            = EFI_STATUS_CODE_DATA_TYPE_STRING_GUID;\r
+EFI_GUID  gEfiStatusCodeDataTypeDebugGuid             = EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID;\r
+EFI_GUID  gEfiStatusCodeDataTypeAssertGuid            = EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID;\r
+EFI_GUID  gEfiStatusCodeDataTypeExceptionHandlerGuid  = EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID;\r
+EFI_GUID  gEfiStatusCodeDataTypeErrorGuid             = EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID;\r
+EFI_GUID  gEfiStatusCodeDataTypeProgressCodeGuid      = EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID;\r
+\r
+EFI_GUID  gEfiStatusCodeSpecificDataGuid              = EFI_STATUS_CODE_SPECIFIC_DATA_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeStringGuid, "Status Code", "Data Hub record Data type String");\r
+EFI_GUID_STRING(&gEfiStatusCodeSpecificDataGuid, "Status Code", "Data Hub record Data type specific ");\r
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeDebugGuid, "Status Code", "Data Hub record data type Debug");\r
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeAssertGuid, "Status Code", "Data Hub record data type Assert");\r
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeErrorGuid, "Status Code", "Data Hub record data type Error");\r
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeProgressCodeGuid, "Status Code", "Data Hub record data type Progress Code");\r
+EFI_GUID_STRING\r
+  (&gEfiStatusCodeDataTypeExceptionHandlerGuid, "Status Code", "Data Hub record Data type Exception handler");\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiStatusCodeSpecificDataGuid, "Status Code Specific Data", "Specific Data for Tiano ReportStatusCode API");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h
new file mode 100644 (file)
index 0000000..bc26539
--- /dev/null
@@ -0,0 +1,385 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeDataTypeId.h\r
+    \r
+Abstract:\r
+\r
+  GUID used to identify id for the caller who is initiating the Status Code.\r
+\r
+--*/\r
+\r
+#ifndef _STATUS_CODE_DATA_TYPE_ID_H__\r
+#define _STATUS_CODE_DATA_TYPE_ID_H__\r
+\r
+\r
+#include "EfiStatusCode.h"\r
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+//\r
+// The size of string\r
+//\r
+#define EFI_STATUS_CODE_DATA_MAX_STRING_SIZE  150\r
+\r
+//\r
+// This is the max data size including all the headers which can be passed\r
+// as Status Code data. This data should be multiple of 8 byte\r
+// to avoid any kind of boundary issue. Also, sum of this data size (inclusive\r
+// of size of EFI_STATUS_CODE_DATA should not exceed the max record size of\r
+// data hub\r
+//\r
+#define EFI_STATUS_CODE_DATA_MAX_SIZE 200\r
+\r
+//\r
+// String Data Type defintion. This is part of Status Code Specification\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_STRING_GUID \\r
+  { \\r
+    0x92D11080, 0x496F, 0x4D95, 0xBE, 0x7E, 0x03, 0x74, 0x88, 0x38, 0x2B, 0x0A \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeStringGuid;\r
+\r
+//\r
+// This GUID indicates that the format of the accompanying data depends\r
+// upon the Status Code Value, but follows this Specification\r
+//\r
+#define EFI_STATUS_CODE_SPECIFIC_DATA_GUID \\r
+  { \\r
+    0x335984bd, 0xe805, 0x409a, 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6 \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeSpecificDataGuid;\r
+\r
+#pragma pack(1)\r
+\r
+typedef enum {\r
+  EfiStringAscii,\r
+  EfiStringUnicode,\r
+  EfiStringToken\r
+} EFI_STRING_TYPE;\r
+\r
+//\r
+// HII string token\r
+//\r
+typedef struct {\r
+EFI_HII_HANDLE Handle;\r
+STRING_REF Token;\r
+} EFI_STATUS_CODE_STRING_TOKEN;\r
+\r
+typedef union {\r
+CHAR8   *Ascii;\r
+CHAR16  *Unicode;\r
+EFI_STATUS_CODE_STRING_TOKEN Hii;\r
+} EFI_STATUS_CODE_STRING;\r
+\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA   DataHeader;\r
+  EFI_STRING_TYPE        StringType;\r
+  EFI_STATUS_CODE_STRING String;\r
+} EFI_STATUS_CODE_STRING_DATA;\r
+\r
+#pragma pack()\r
+//\r
+// Debug Assert Data. This is part of Status Code Specification\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID \\r
+  { \\r
+    0xDA571595, 0x4D99, 0x487C, 0x82, 0x7C, 0x26, 0x22, 0x67, 0x7D, 0x33, 0x07 \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeAssertGuid;\r
+\r
+//\r
+// Exception Data type (CPU REGS)\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID \\r
+  { \\r
+    0x3BC2BD12, 0xAD2E, 0x11D5, 0x87, 0xDD, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9 \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeExceptionHandlerGuid;\r
+\r
+//\r
+// Debug DataType defintions. User Defined Data Types.\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID \\r
+  { \\r
+    0x9A4E9246, 0xD553, 0x11D5, 0x87, 0xE2, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xb9 \\r
+  }\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  ErrorLevel;\r
+  //\r
+  // 12 * sizeof (UINT64) Var Arg stack\r
+  //\r
+  // ascii DEBUG () Format string\r
+  //\r
+} EFI_DEBUG_INFO;\r
+\r
+#pragma pack()\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeDebugGuid;\r
+\r
+//\r
+// Progress Code. User Defined Data Type Guid.\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID \\r
+  { \\r
+    0xAB359CE3, 0x99B3, 0xAE18, 0xC8, 0x9D, 0x95, 0xD3, 0xB0, 0x72, 0xE1, 0x9B \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeErrorGuid;\r
+\r
+//\r
+// declaration for EFI_EXP_DATA. This may change\r
+//\r
+typedef UINTN   EFI_EXP_DATA;\r
+\r
+//\r
+// Voltage Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_EXP_DATA          Voltage;\r
+  EFI_EXP_DATA          Threshold;\r
+} EFI_COMPUTING_UNIT_VOLTAGE_ERROR_DATA;\r
+\r
+//\r
+// Microcode Update Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  UINT32                Version;\r
+} EFI_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA;\r
+\r
+//\r
+// Asynchronous Timer Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_EXP_DATA          TimerLimit;\r
+} EFI_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA;\r
+\r
+//\r
+// Host Processor Mismatch Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  UINT32                Instance;\r
+  UINT16                Attributes;\r
+} EFI_HOST_PROCESSOR_MISMATCH_ERROR_DATA;\r
+\r
+//\r
+// EFI_COMPUTING_UNIT_MISMATCH_ATTRIBUTES\r
+// All other attributes are reserved for future use and\r
+// must be initialized to 0.\r
+//\r
+#define EFI_COMPUTING_UNIT_MISMATCH_SPEED       0x0001\r
+#define EFI_COMPUTING_UNIT_MISMATCH_FSB_SPEED   0x0002\r
+#define EFI_COMPUTING_UNIT_MISMATCH_FAMILY      0x0004\r
+#define EFI_COMPUTING_UNIT_MISMATCH_MODEL       0x0008\r
+#define EFI_COMPUTING_UNIT_MISMATCH_STEPPING    0x0010\r
+#define EFI_COMPUTING_UNIT_MISMATCH_CACHE_SIZE  0x0020\r
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM1        0x1000\r
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM2        0x2000\r
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM3        0x4000\r
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM4        0x8000\r
+\r
+//\r
+// Thermal Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_EXP_DATA          Temperature;\r
+  EFI_EXP_DATA          Threshold;\r
+} EFI_COMPUTING_UNIT_THERMAL_ERROR_DATA;\r
+\r
+//\r
+// Processor Disabled Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  UINT32                Cause;\r
+  BOOLEAN               SoftwareDisabled;\r
+} EFI_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA;\r
+\r
+typedef enum {\r
+  EfiInitCacheDataOnly,\r
+  EfiInitCacheInstrOnly,\r
+  EfiInitCacheBoth,\r
+  EfiInitCacheUnspecified\r
+} EFI_INIT_CACHE_TYPE;\r
+\r
+//\r
+// Embedded cache init extended data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  UINT32                Level;\r
+  EFI_INIT_CACHE_TYPE   Type;\r
+} EFI_CACHE_INIT_DATA;\r
+\r
+//\r
+// Memory Extended Error Data\r
+//\r
+//\r
+// Memory Error Granularity Definition\r
+//\r
+typedef UINT8 EFI_MEMORY_ERROR_GRANULARITY;\r
+\r
+//\r
+// Memory Error Operation Definition\r
+//\r
+typedef UINT8 EFI_MEMORY_ERROR_OPERATION;\r
+\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA          DataHeader;\r
+  EFI_MEMORY_ERROR_GRANULARITY  Granularity;\r
+  EFI_MEMORY_ERROR_OPERATION    Operation;\r
+  UINTN                         Syndrome;\r
+  EFI_PHYSICAL_ADDRESS          Address;\r
+  UINTN                         Resolution;\r
+} EFI_MEMORY_EXTENDED_ERROR_DATA;\r
+\r
+//\r
+// Memory Error Granularities\r
+//\r
+#define EFI_MEMORY_ERROR_OTHER      0x01\r
+#define EFI_MEMORY_ERROR_UNKNOWN    0x02\r
+#define EFI_MEMORY_ERROR_DEVICE     0x03\r
+#define EFI_MEMORY_ERROR_PARTITION  0x04\r
+\r
+//\r
+// Memory Error Operations\r
+//\r
+#define EFI_MEMORY_OPERATION_OTHER          0x01\r
+#define EFI_MEMORY_OPERATION_UNKNOWN        0x02\r
+#define EFI_MEMORY_OPERATION_READ           0x03\r
+#define EFI_MEMORY_OPERATION_WRITE          0x04\r
+#define EFI_MEMORY_OPERATION_PARTIAL_WRITE  0x05\r
+\r
+//\r
+// Define shorthands to describe Group Operations\r
+// Many memory init operations are essentially group\r
+// operations.\r
+// A shorthand to describe that the operation is performed\r
+// on multiple devices within the array\r
+//\r
+#define EFI_MULTIPLE_MEMORY_DEVICE_OPERATION  0xfffe\r
+//\r
+// A shorthand to describe that the operation is performed // on all devices within the array\r
+//\r
+#define EFI_ALL_MEMORY_DEVICE_OPERATION 0xffff\r
+//\r
+// A shorthand to describe that the operation is performed // on multiple arrays\r
+//\r
+#define EFI_MULTIPLE_MEMORY_ARRAY_OPERATION 0xfffe\r
+//\r
+// A shorthand to describe that the operation is performed // on all the arrays\r
+//\r
+#define EFI_ALL_MEMORY_ARRAY_OPERATION  0xffff\r
+\r
+//\r
+// DIMM number\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  UINT16                Array;\r
+  UINT16                Device;\r
+} EFI_STATUS_CODE_DIMM_NUMBER;\r
+#pragma pack()\r
+//\r
+// Memory Module Mismatch Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA        DataHeader;\r
+  EFI_STATUS_CODE_DIMM_NUMBER Instance;\r
+} EFI_MEMORY_MODULE_MISMATCH_ERROR_DATA;\r
+\r
+//\r
+// Memory Range Extended Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_PHYSICAL_ADDRESS  Start;\r
+  EFI_PHYSICAL_ADDRESS  Length;\r
+} EFI_MEMORY_RANGE_EXTENDED_DATA;\r
+\r
+//\r
+// Device handle Extended Data. Used for many\r
+// errors and progress codes to point to the device.\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_HANDLE            Handle;\r
+} EFI_DEVICE_HANDLE_EXTENDED_DATA;\r
+\r
+//\r
+// Resource Allocation Failure Extended Error Data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA      DataHeader;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINT32                    Bar;\r
+  VOID                      *ReqRes;\r
+  VOID                      *AllocRes;\r
+} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA;\r
+\r
+//\r
+// Extended Error Data for Assert\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA        DataHeader;\r
+  UINT32                      LineNumber;\r
+  UINT32                      FileNameSize;\r
+  EFI_STATUS_CODE_STRING_DATA *FileName;\r
+} EFI_DEBUG_ASSERT_DATA;\r
+\r
+//\r
+// System Context Data EBC/IA32/IPF\r
+//\r
+typedef union {\r
+  EFI_SYSTEM_CONTEXT_EBC  SystemContextEbc;\r
+  EFI_SYSTEM_CONTEXT_IA32 SystemContextIa32;\r
+  EFI_SYSTEM_CONTEXT_IPF  SystemContextIpf;\r
+} EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT;\r
+\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA                  DataHeader;\r
+  EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT  Context;\r
+} EFI_STATUS_CODE_EXCEP_EXTENDED_DATA;\r
+\r
+//\r
+// Legacy Oprom extended data\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_DATA  DataHeader;\r
+  EFI_HANDLE            DeviceHandle;\r
+  EFI_PHYSICAL_ADDRESS  RomImageBase;\r
+} EFI_LEGACY_OPROM_EXTENDED_DATA;\r
+\r
+//\r
+// Progress Code. User Defined Data Type Guid.\r
+//\r
+#define EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID \\r
+  { \\r
+    0xA356AB39, 0x35C4, 0x35DA, 0xB3, 0x7A, 0xF8, 0xEA, 0x9E, 0x8B, 0x36, 0xA3 \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeDataTypeProgressCodeGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h b/EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h
new file mode 100644 (file)
index 0000000..c37f368
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMode.h\r
+    \r
+Abstract:\r
+\r
+  This includes for the Boot mode information.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BOOT_MODE_H\r
+#define _EFI_BOOT_MODE_H\r
+\r
+#define BOOT_WITH_FULL_CONFIGURATION                  0x00\r
+#define BOOT_WITH_MINIMAL_CONFIGURATION               0x01\r
+#define BOOT_ASSUMING_NO_CONFIGURATION_CHANGES        0x02\r
+#define BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03\r
+#define BOOT_WITH_DEFAULT_SETTINGS                    0x04\r
+#define BOOT_ON_S4_RESUME                             0x05\r
+#define BOOT_ON_S5_RESUME                             0x06\r
+#define BOOT_ON_S2_RESUME                             0x10\r
+#define BOOT_ON_S3_RESUME                             0x11\r
+#define BOOT_ON_FLASH_UPDATE                          0x12\r
+#define BOOT_IN_RECOVERY_MODE                         0x20\r
+#define BOOT_IN_RECOVERY_MODE_MASK                    0x40\r
+#define BOOT_SPECIAL_MASK                             0x80\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h
new file mode 100644 (file)
index 0000000..0daa738
--- /dev/null
@@ -0,0 +1,210 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiBootScript.h\r
+\r
+Abstract:\r
+\r
+  \r
+\r
+--*/\r
+\r
+#ifndef _EFI_SCRIPT_H_\r
+#define _EFI_SCRIPT_H_\r
+\r
+#include "EfiSmbus.h"\r
+\r
+#define EFI_ACPI_S3_RESUME_SCRIPT_TABLE         0x00\r
+\r
+//\r
+// Boot Script Opcode Definitions\r
+//\r
+typedef const UINT16  EFI_BOOT_SCRIPT_OPCODE;\r
+\r
+#define EFI_BOOT_SCRIPT_IO_WRITE_OPCODE               0x00\r
+#define EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE          0x01\r
+#define EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE              0x02\r
+#define EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE         0x03\r
+#define EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE       0x04\r
+#define EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE  0x05\r
+#define EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE          0x06\r
+#define EFI_BOOT_SCRIPT_STALL_OPCODE                  0x07\r
+#define EFI_BOOT_SCRIPT_DISPATCH_OPCODE               0x08\r
+#define EFI_BOOT_SCRIPT_INFORMATION_OPCODE            0x0A\r
+\r
+#define EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE       0x0B\r
+#define EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE  0x0C\r
+\r
+#define EFI_BOOT_SCRIPT_TABLE_OPCODE                  0xAA\r
+#define EFI_BOOT_SCRIPT_TERMINATE_OPCODE              0xFF\r
+\r
+#pragma pack(1)\r
+\r
+//\r
+// EFI Boot Script Width\r
+//\r
+typedef enum {\r
+  EfiBootScriptWidthUint8,\r
+  EfiBootScriptWidthUint16,\r
+  EfiBootScriptWidthUint32,\r
+  EfiBootScriptWidthUint64,\r
+  EfiBootScriptWidthFifoUint8,\r
+  EfiBootScriptWidthFifoUint16,\r
+  EfiBootScriptWidthFifoUint32,\r
+  EfiBootScriptWidthFifoUint64,\r
+  EfiBootScriptWidthFillUint8,\r
+  EfiBootScriptWidthFillUint16,\r
+  EfiBootScriptWidthFillUint32,\r
+  EfiBootScriptWidthFillUint64,\r
+  EfiBootScriptWidthMaximum\r
+} EFI_BOOT_SCRIPT_WIDTH;\r
+\r
+typedef struct {\r
+  UINT16  OpCode;\r
+  UINT8   Length;\r
+} EFI_BOOT_SCRIPT_GENERIC_HEADER;\r
+\r
+typedef struct {\r
+  UINT16  OpCode;\r
+  UINT8   Length;\r
+  UINT16  Version;\r
+  UINT32  TableLength;\r
+  UINT16  Reserved[2];\r
+} EFI_BOOT_SCRIPT_TABLE_HEADER;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+} EFI_BOOT_SCRIPT_COMMON_HEADER;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT32                Count;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_IO_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_IO_READ_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT32                Count;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_MEM_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_MEM_READ_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT32                Count;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT32                Count;\r
+  UINT64                Address;\r
+  UINT16                Segment;\r
+} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT64                Address;\r
+} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                Width;\r
+  UINT64                Address;\r
+  UINT16                Segment;\r
+} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE;\r
+\r
+\r
+typedef struct {\r
+  UINT16                    OpCode;\r
+  UINT8                     Length;\r
+  UINT64                    SlaveAddress;\r
+  UINT64                    Command;\r
+  UINT32                    Operation;\r
+  BOOLEAN                   PecCheck;\r
+  UINT32                    DataSize;\r
+} EFI_BOOT_SCRIPT_SMBUS_EXECUTE;\r
+\r
+typedef struct {\r
+  UINT16  OpCode;\r
+  UINT8   Length;\r
+  UINT64  Duration;\r
+} EFI_BOOT_SCRIPT_STALL;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  EFI_PHYSICAL_ADDRESS  EntryPoint;\r
+} EFI_BOOT_SCRIPT_DISPATCH;\r
+\r
+typedef struct {\r
+  UINT16                OpCode;\r
+  UINT8                 Length;\r
+  UINT32                InformationLength;  \r
+  EFI_PHYSICAL_ADDRESS  Information;\r
+} EFI_BOOT_SCRIPT_INFORMATION;\r
+\r
+typedef struct {\r
+  UINT16  OpCode;\r
+  UINT8   Length;\r
+} EFI_BOOT_SCRIPT_TERMINATE;\r
+\r
+typedef union {\r
+  EFI_BOOT_SCRIPT_GENERIC_HEADER        *Header;\r
+  EFI_BOOT_SCRIPT_TABLE_HEADER          *TableInfo;\r
+  EFI_BOOT_SCRIPT_IO_WRITE              *IoWrite;\r
+  EFI_BOOT_SCRIPT_IO_READ_WRITE         *IoReadWrite;\r
+  EFI_BOOT_SCRIPT_MEM_WRITE             *MemWrite;\r
+  EFI_BOOT_SCRIPT_MEM_READ_WRITE        *MemReadWrite;\r
+  EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE      *PciWrite;\r
+  EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE *PciReadWrite;\r
+  EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE      *PciWrite2;\r
+  EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE *PciReadWrite2;\r
+  EFI_BOOT_SCRIPT_SMBUS_EXECUTE         *SmbusExecute;\r
+  EFI_BOOT_SCRIPT_STALL                 *Stall;\r
+  EFI_BOOT_SCRIPT_DISPATCH              *Dispatch;\r
+  EFI_BOOT_SCRIPT_INFORMATION           *Information;  \r
+  EFI_BOOT_SCRIPT_TERMINATE             *Terminate;\r
+  EFI_BOOT_SCRIPT_COMMON_HEADER         *CommonHeader;\r
+  UINT8                                 *Raw;\r
+} BOOT_SCRIPT_POINTERS;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h
new file mode 100644 (file)
index 0000000..79ecfc5
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCapsule.h\r
+\r
+Abstract:\r
+\r
+  Defines for the EFI Capsule functionality\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_CAPSULE_H_\r
+#define _EFI_CAPSULE_H_\r
+\r
+\r
+#define CAPSULE_BLOCK_DESCRIPTOR_SIGNATURE  EFI_SIGNATURE_32 ('C', 'B', 'D', 'S')\r
+\r
+typedef struct {\r
+  EFI_GUID  OemGuid;\r
+  UINT32    HeaderSize;\r
+  //\r
+  // UINT8                       OemHdrData[];\r
+  //\r
+} EFI_CAPSULE_OEM_HEADER;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+#define MAX_SUPPORT_CAPSULE_NUM               50\r
+#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET    0x00010000\r
+#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE   0x00020000 \r
+\r
+typedef struct {\r
+  UINT64                   Length;                    \r
+  union { \r
+    EFI_PHYSICAL_ADDRESS   DataBlock;                 \r
+    EFI_PHYSICAL_ADDRESS   ContinuationPointer;  \r
+  } Union;\r
+} EFI_CAPSULE_BLOCK_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  EFI_GUID  CapsuleGuid;\r
+  UINT32    HeaderSize;\r
+  UINT32    Flags;\r
+  UINT32    CapsuleImageSize;\r
+} EFI_CAPSULE_HEADER;\r
+\r
+typedef struct {\r
+  UINT32   CapsuleArrayNumber;\r
+  VOID*    CapsulePtr[1];\r
+} EFI_CAPSULE_TABLE;\r
+\r
+typedef struct {\r
+  UINT32      CapsuleGuidNumber;\r
+  EFI_GUID    CapsuleGuidPtr[1];\r
+} EFI_CAPSULE_INFO_TABLE;\r
+\r
+//\r
+// This GUID is used for collecting all capsules' Guids who install in ConfigTable.\r
+//\r
+#define EFI_CAPSULE_INFO_GUID \\r
+  { \\r
+    0x8B34EAC7, 0x2690, 0x460B, 0x8B, 0xA5, 0xD5, 0xCF, 0x32, 0x83, 0x17, 0x35 \\r
+  }\r
+\r
+#else\r
+\r
+typedef struct {\r
+  EFI_GUID  CapsuleGuid;\r
+  UINT32    HeaderSize;\r
+  UINT32    Flags;\r
+  UINT32    CapsuleImageSize;\r
+  UINT32    SequenceNumber;\r
+  EFI_GUID  InstanceId;\r
+  UINT32    OffsetToSplitInformation;\r
+  UINT32    OffsetToCapsuleBody;\r
+  UINT32    OffsetToOemDefinedHeader;\r
+  UINT32    OffsetToAuthorInformation;\r
+  UINT32    OffsetToRevisionInformation;\r
+  UINT32    OffsetToShortDescription;\r
+  UINT32    OffsetToLongDescription;\r
+  UINT32    OffsetToApplicableDevices;\r
+} EFI_CAPSULE_HEADER;\r
+\r
+//\r
+// An array of these describe the blocks that make up a capsule for\r
+// a capsule update.\r
+//\r
+typedef struct {\r
+  UINT64                Length;     // length of the data block\r
+  EFI_PHYSICAL_ADDRESS  Data;       // physical address of the data block\r
+  UINT32                Signature;  // CBDS\r
+  UINT32                CheckSum;   // to sum this structure to 0\r
+} EFI_CAPSULE_BLOCK_DESCRIPTOR;\r
+\r
+#endif\r
+\r
+//\r
+// Bits in the flags field of the capsule header\r
+//\r
+#define EFI_CAPSULE_HEADER_FLAG_SETUP 0x00000001  // supports setup changes\r
+//\r
+// This is the GUID of the capsule header of the image on disk.\r
+//\r
+#define EFI_CAPSULE_GUID \\r
+  { \\r
+    0x3B6686BD, 0x0D76, 0x4030, 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 \\r
+  }\r
+\r
+//\r
+// This is the GUID of the file created by the capsule application that contains\r
+// the path to the device(s) to update.\r
+//\r
+#define EFI_PATH_FILE_NAME_GUID \\r
+  { \\r
+    0x7644C181, 0xFA6E, 0x46DA, 0x80, 0xCB, 0x04, 0xB9, 0x90, 0x40, 0x62, 0xE8 \\r
+  }\r
+//\r
+// This is the GUID of the configuration results file created by the capsule\r
+// application.\r
+//\r
+#define EFI_CONFIG_FILE_NAME_GUID \\r
+  { \\r
+    0x98B8D59B, 0xE8BA, 0x48EE, 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB \\r
+  }\r
+\r
+#endif // #ifndef _EFI_CAPSULE_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h
new file mode 100644 (file)
index 0000000..599698d
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDependency.h\r
+\r
+Abstract:\r
+   \r
+  This module contains data specific to dependency expressions\r
+  and local function prototypes.\r
+        \r
+--*/\r
+\r
+#ifndef _DEPENDENCY_H_\r
+#define _DEPENDENCY_H_\r
+\r
+//\r
+//\r
+// EFI_DEP_BEFORE       - If present, it must be the first and only opcode\r
+// EFI_DEP_AFTER        - If present, it must be the first and only opcode\r
+// EFI_DEP_SOR          - If present, it must be the first opcode\r
+// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression\r
+//                        to save time.  A EFI_DEP_PUSH is evauated one an\r
+//                        replaced with EFI_DEP_REPLACE_TRUE\r
+//\r
+#define EFI_DEP_BEFORE        0x00\r
+#define EFI_DEP_AFTER         0x01\r
+#define EFI_DEP_PUSH          0x02\r
+#define EFI_DEP_AND           0x03\r
+#define EFI_DEP_OR            0x04\r
+#define EFI_DEP_NOT           0x05\r
+#define EFI_DEP_TRUE          0x06\r
+#define EFI_DEP_FALSE         0x07\r
+#define EFI_DEP_END           0x08\r
+#define EFI_DEP_SOR           0x09\r
+#define EFI_DEP_REPLACE_TRUE  0xff\r
+\r
+//\r
+// Define the initial size of the dependency expression evaluation stack\r
+//\r
+#define DEPEX_STACK_SIZE_INCREMENT  0x1000\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h
new file mode 100644 (file)
index 0000000..e246eac
--- /dev/null
@@ -0,0 +1,128 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiFirmwareFileSystem.h\r
+\r
+Abstract:\r
+\r
+  This file defines the data structures that comprise the FFS file system.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_FFS_FILE_SYSTEM_H_\r
+#define _EFI_FFS_FILE_SYSTEM_H_\r
+\r
+#include "EfiImageFormat.h"\r
+\r
+//\r
+// GUIDs defined by the FFS specification.\r
+//\r
+#define EFI_FIRMWARE_FILE_SYSTEM_GUID \\r
+  { \\r
+    0x7A9354D9, 0x0468, 0x444a, 0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF \\r
+  }\r
+\r
+#define EFI_FFS_VOLUME_TOP_FILE_GUID \\r
+  { \\r
+    0x1BA0062E, 0xC779, 0x4582, 0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9 \\r
+  }\r
+\r
+//\r
+// FFS specific file types\r
+//\r
+#define EFI_FV_FILETYPE_FFS_PAD 0xF0\r
+\r
+//\r
+// FFS File Attributes\r
+//\r
+#define FFS_ATTRIB_TAIL_PRESENT     0x01\r
+#define FFS_ATTRIB_RECOVERY         0x02\r
+#define FFS_ATTRIB_DATA_ALIGNMENT   0x38\r
+#define FFS_ATTRIB_CHECKSUM         0x40\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+#define FFS_ATTRIB_HEADER_EXTENSION 0x04\r
+#else\r
+//\r
+// PI 1.0 definition.\r
+// \r
+#define FFS_ATTRIB_FIXED           0x04\r
+#endif\r
+\r
+\r
+//\r
+// FFS_FIXED_CHECKSUM is the default checksum value used when the\r
+// FFS_ATTRIB_CHECKSUM attribute bit is clear\r
+// note this is NOT an architecturally defined value, but is in this file for\r
+// implementation convenience\r
+//\r
+#define FFS_FIXED_CHECKSUM  0x5A\r
+\r
+\r
+//\r
+// File state definitions\r
+//\r
+#define EFI_FILE_HEADER_CONSTRUCTION  0x01\r
+#define EFI_FILE_HEADER_VALID         0x02\r
+#define EFI_FILE_DATA_VALID           0x04\r
+#define EFI_FILE_MARKED_FOR_UPDATE    0x08\r
+#define EFI_FILE_DELETED              0x10\r
+#define EFI_FILE_HEADER_INVALID       0x20\r
+\r
+#define EFI_FILE_ALL_STATE_BITS       (EFI_FILE_HEADER_CONSTRUCTION | \\r
+                                 EFI_FILE_HEADER_VALID | \\r
+                                 EFI_FILE_DATA_VALID | \\r
+                                 EFI_FILE_MARKED_FOR_UPDATE | \\r
+                                 EFI_FILE_DELETED | \\r
+                                 EFI_FILE_HEADER_INVALID \\r
+          )\r
+\r
+#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \\r
+    ( \\r
+      (BOOLEAN) ( \\r
+          (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \\r
+        ) \\r
+    )\r
+\r
+//\r
+// FFS file integrity check structure\r
+//\r
+typedef UINT16  EFI_FFS_FILE_TAIL;\r
+\r
+typedef union {\r
+  struct {\r
+    UINT8 Header;\r
+    UINT8 File;\r
+  } Checksum;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
+  UINT16  TailReference;\r
+#else\r
+  UINT16  Checksum16;\r
+#endif\r
+} EFI_FFS_INTEGRITY_CHECK;\r
+\r
+//\r
+// FFS file header definition\r
+//\r
+typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;\r
+typedef UINT8 EFI_FFS_FILE_STATE;\r
+\r
+typedef struct {\r
+  EFI_GUID                Name;\r
+  EFI_FFS_INTEGRITY_CHECK IntegrityCheck;\r
+  EFI_FV_FILETYPE         Type;\r
+  EFI_FFS_FILE_ATTRIBUTES Attributes;\r
+  UINT8                   Size[3];\r
+  EFI_FFS_FILE_STATE      State;\r
+} EFI_FFS_FILE_HEADER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h
new file mode 100644 (file)
index 0000000..3a99d51
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2007 , Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiFirmwareVolume.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _EFI_FIRMWARE_VOLUME_H_\r
+#define _EFI_FIRMWARE_VOLUME_H_\r
+\r
+\r
+#define FV_DEVICE_SIGNATURE           EFI_SIGNATURE_32 ('_', 'F', 'V', '_')\r
+#define EFI_FV_FILE_ATTRIB_ALIGNMENT  0x0000001F\r
+#define EFI_FV_UNRELIABLE_WRITE       0x00000000\r
+#define EFI_FV_RELIABLE_WRITE         0x00000001\r
+\r
+\r
+//\r
+// EFI_FV_ATTRIBUTES bit definitions\r
+//\r
+typedef UINT64  EFI_FV_ATTRIBUTES;\r
+typedef UINT32  EFI_FV_FILE_ATTRIBUTES;\r
+typedef UINT32  EFI_FV_WRITE_POLICY;\r
+\r
+\r
+typedef struct {\r
+  EFI_GUID                *NameGuid;\r
+  EFI_FV_FILETYPE         Type;\r
+  EFI_FV_FILE_ATTRIBUTES  FileAttributes;\r
+  VOID                    *Buffer;\r
+  UINT32                  BufferSize;\r
+} EFI_FV_WRITE_FILE_DATA;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h
new file mode 100644 (file)
index 0000000..6e0fe39
--- /dev/null
@@ -0,0 +1,213 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007 , Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiFirmwareVolumeHeader.h\r
+\r
+Abstract:\r
+\r
+  Defines data structure that is the volume header found at the beginning of\r
+  all firmware volumes that are either memory mapped, or have an\r
+  associated FirmwareVolumeBlock protocol.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_FIRMWARE_VOLUME_HEADER_H_\r
+#define _EFI_FIRMWARE_VOLUME_HEADER_H_\r
+\r
+\r
+//\r
+// Firmware Volume Block Attributes bit definitions\r
+// They are the shared between Framework and PI1.0.\r
+//\r
+typedef UINT32  EFI_FVB_ATTRIBUTES;\r
+\r
+#define EFI_FVB_READ_DISABLED_CAP   0x00000001\r
+#define EFI_FVB_READ_ENABLED_CAP    0x00000002\r
+#define EFI_FVB_READ_STATUS         0x00000004\r
+\r
+#define EFI_FVB_WRITE_DISABLED_CAP  0x00000008\r
+#define EFI_FVB_WRITE_ENABLED_CAP   0x00000010\r
+#define EFI_FVB_WRITE_STATUS        0x00000020\r
+\r
+#define EFI_FVB_LOCK_CAP            0x00000040\r
+#define EFI_FVB_LOCK_STATUS         0x00000080\r
+\r
+#define EFI_FVB_STICKY_WRITE        0x00000200\r
+#define EFI_FVB_MEMORY_MAPPED       0x00000400\r
+#define EFI_FVB_ERASE_POLARITY      0x00000800\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+#define EFI_FVB_ALIGNMENT_CAP       0x00008000\r
+#define EFI_FVB_ALIGNMENT_2         0x00010000\r
+#define EFI_FVB_ALIGNMENT_4         0x00020000\r
+#define EFI_FVB_ALIGNMENT_8         0x00040000\r
+#define EFI_FVB_ALIGNMENT_16        0x00080000\r
+#define EFI_FVB_ALIGNMENT_32        0x00100000\r
+#define EFI_FVB_ALIGNMENT_64        0x00200000\r
+#define EFI_FVB_ALIGNMENT_128       0x00400000\r
+#define EFI_FVB_ALIGNMENT_256       0x00800000\r
+#define EFI_FVB_ALIGNMENT_512       0x01000000\r
+#define EFI_FVB_ALIGNMENT_1K        0x02000000\r
+#define EFI_FVB_ALIGNMENT_2K        0x04000000\r
+#define EFI_FVB_ALIGNMENT_4K        0x08000000\r
+#define EFI_FVB_ALIGNMENT_8K        0x10000000\r
+#define EFI_FVB_ALIGNMENT_16K       0x20000000\r
+#define EFI_FVB_ALIGNMENT_32K       0x40000000\r
+#define EFI_FVB_ALIGNMENT_64K       0x80000000\r
+\r
+#define EFI_FVB_CAPABILITIES  (EFI_FVB_READ_DISABLED_CAP | \\r
+                              EFI_FVB_READ_ENABLED_CAP | \\r
+                              EFI_FVB_WRITE_DISABLED_CAP | \\r
+                              EFI_FVB_WRITE_ENABLED_CAP | \\r
+                              EFI_FVB_LOCK_CAP \\r
+                              )\r
+\r
+#define EFI_FVB_STATUS    (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | EFI_FVB_LOCK_STATUS)\r
+\r
+\r
+\r
+#else\r
+\r
+#define EFI_FVB2_READ_LOCK_CAP        0x00001000\r
+#define EFI_FVB2_READ_LOCK_STATUS     0x00002000\r
+\r
+#define EFI_FVB2_WRITE_LOCK_CAP       0x00004000\r
+#define EFI_FVB2_WRITE_LOCK_STATUS    0x00008000\r
+\r
+#define EFI_FVB2_ALIGNMENT            0x001F0000\r
+#define EFI_FVB2_ALIGNMENT_1          0x00000000\r
+#define EFI_FVB2_ALIGNMENT_2          0x00010000\r
+#define EFI_FVB2_ALIGNMENT_4          0x00020000\r
+#define EFI_FVB2_ALIGNMENT_8          0x00030000\r
+#define EFI_FVB2_ALIGNMENT_16         0x00040000\r
+#define EFI_FVB2_ALIGNMENT_32         0x00050000\r
+#define EFI_FVB2_ALIGNMENT_64         0x00060000\r
+#define EFI_FVB2_ALIGNMENT_128        0x00070000\r
+#define EFI_FVB2_ALIGNMENT_256        0x00080000\r
+#define EFI_FVB2_ALIGNMENT_512        0x00090000\r
+#define EFI_FVB2_ALIGNMENT_1K         0x000A0000\r
+#define EFI_FVB2_ALIGNMENT_2K         0x000B0000\r
+#define EFI_FVB2_ALIGNMENT_4K         0x000C0000\r
+#define EFI_FVB2_ALIGNMENT_8K         0x000D0000\r
+#define EFI_FVB2_ALIGNMENT_16K        0x000E0000\r
+#define EFI_FVB2_ALIGNMENT_32K        0x000F0000\r
+#define EFI_FVB2_ALIGNMENT_64K        0x00100000\r
+#define EFI_FVB2_ALIGNMENT_128K       0x00110000\r
+#define EFI_FVB2_ALIGNMENT_256K       0x00120000\r
+#define EFI_FVB2_ALIGNMNET_512K       0x00130000\r
+#define EFI_FVB2_ALIGNMENT_1M         0x00140000\r
+#define EFI_FVB2_ALIGNMENT_2M         0x00150000\r
+#define EFI_FVB2_ALIGNMENT_4M         0x00160000\r
+#define EFI_FVB2_ALIGNMENT_8M         0x00170000\r
+#define EFI_FVB2_ALIGNMENT_16M        0x00180000\r
+#define EFI_FVB2_ALIGNMENT_32M        0x00190000\r
+#define EFI_FVB2_ALIGNMENT_64M        0x001A0000\r
+#define EFI_FVB2_ALIGNMENT_128M       0x001B0000\r
+#define EFI_FVB2_ALIGNMENT_256M       0x001C0000\r
+#define EFI_FVB2_ALIGNMENT_512M       0x001D0000\r
+#define EFI_FVB2_ALIGNMENT_1G         0x001E0000\r
+#define EFI_FVB2_ALIGNMENT_2G         0x001F0000\r
+\r
+#define EFI_FVB_CAPABILITIES  (EFI_FVB_READ_DISABLED_CAP | \\r
+                              EFI_FVB_READ_ENABLED_CAP   | \\r
+                              EFI_FVB_WRITE_DISABLED_CAP | \\r
+                              EFI_FVB_WRITE_ENABLED_CAP  | \\r
+                              EFI_FVB_LOCK_CAP           | \\r
+                              EFI_FVB2_READ_LOCK_CAP     | \\r
+                              EFI_FVB2_WRITE_LOCK_CAP    )\r
+\r
+#define EFI_FVB_STATUS    (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS       | \\r
+                           EFI_FVB_LOCK_STATUS | EFI_FVB2_READ_LOCK_STATUS  | \\r
+                           EFI_FVB2_WRITE_LOCK_STATUS )\r
+\r
+\r
+\r
+//\r
+// Extended Header Header. Located via ExtHeaderOffset.\r
+// The extended headers follow each other in memory and are \r
+// terminated by ExtHeaderType EFI_FV_EXT_TYPE_END\r
+//\r
+#define EFI_FV_EXT_TYPE_END   0x00\r
+typedef struct {\r
+  UINT16  ExtEntrySize;\r
+  UINT16  ExtEntryType;\r
+} EFI_FIRMWARE_VOLUME_EXT_ENTRY;\r
+\r
+//\r
+// GUID that maps OEM file types to GUIDs\r
+//\r
+#define EFI_FV_EXT_TYPE_OEM_TYPE  0x01\r
+typedef struct {\r
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY   Hdr;\r
+  UINT32                          TypeMask;\r
+  EFI_GUID                        Types[1];\r
+} EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE;\r
+\r
+//\r
+// Unique name of the FV\r
+//\r
+typedef struct {\r
+  EFI_GUID          FvName;\r
+  UINT32            ExtHeaderSize;\r
+} EFI_FIRMWARE_VOLUME_EXT_HEADER;\r
+\r
+\r
+#endif\r
+\r
+\r
+//\r
+// Firmware Volume Header Revision definition\r
+//\r
+#define EFI_FVH_REVISION  0x01\r
+//\r
+// PI1.0 define Firmware Volume Header Revision to 2\r
+//\r
+#define EFI_FVH_PI_REVISION  0x02\r
+\r
+//\r
+// Firmware Volume Header Signature definition\r
+//\r
+#define EFI_FVH_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', 'H')\r
+\r
+//\r
+// Firmware Volume Header Block Map Entry definition\r
+//\r
+typedef struct {\r
+  UINT32  NumBlocks;\r
+  UINT32  BlockLength;\r
+} EFI_FV_BLOCK_MAP_ENTRY;\r
+\r
+//\r
+// Firmware Volume Header definition\r
+//\r
+typedef struct {\r
+  UINT8                   ZeroVector[16];\r
+  EFI_GUID                FileSystemGuid;\r
+  UINT64                  FvLength;\r
+  UINT32                  Signature;\r
+  EFI_FVB_ATTRIBUTES      Attributes;\r
+  UINT16                  HeaderLength;\r
+  UINT16                  Checksum;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  UINT8                   Reserved[3];\r
+#else\r
+  UINT16                  ExtHeaderOffset;\r
+  UINT8                   Reserved[1];\r
+#endif\r
+  UINT8                   Revision;\r
+  EFI_FV_BLOCK_MAP_ENTRY  FvBlockMap[1];\r
+} EFI_FIRMWARE_VOLUME_HEADER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h
new file mode 100644 (file)
index 0000000..c4ac828
--- /dev/null
@@ -0,0 +1,279 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiImageFormat.h\r
+\r
+Abstract:\r
+\r
+  This file defines the data structures that are architecturally defined for file\r
+  images loaded via the FirmwareVolume protocol.  The Firmware Volume specification\r
+  is the basis for these definitions.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_IMAGE_FORMAT_H_\r
+#define _EFI_IMAGE_FORMAT_H_\r
+\r
+//\r
+// pack all data structures since this is actually a binary format and we cannot\r
+// allow internal padding in the data structures because of some compilerism..\r
+//\r
+#pragma pack(1)\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Architectural file types\r
+//\r
+typedef UINT8 EFI_FV_FILETYPE;\r
+\r
+#define EFI_FV_FILETYPE_ALL                   0x00\r
+#define EFI_FV_FILETYPE_RAW                   0x01\r
+#define EFI_FV_FILETYPE_FREEFORM              0x02\r
+#define EFI_FV_FILETYPE_SECURITY_CORE         0x03\r
+#define EFI_FV_FILETYPE_PEI_CORE              0x04\r
+#define EFI_FV_FILETYPE_DXE_CORE              0x05\r
+#define EFI_FV_FILETYPE_PEIM                  0x06\r
+#define EFI_FV_FILETYPE_DRIVER                0x07\r
+#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER  0x08\r
+#define EFI_FV_FILETYPE_APPLICATION           0x09\r
+//\r
+// File type 0x0A is reserved and should not be used\r
+//\r
+#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Section types\r
+//\r
+typedef UINT8 EFI_SECTION_TYPE;\r
+\r
+//\r
+// ************************************************************\r
+// The section type EFI_SECTION_ALL is a psuedo type.  It is\r
+// used as a wildcard when retrieving sections.  The section\r
+// type EFI_SECTION_ALL matches all section types.\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_ALL 0x00\r
+\r
+//\r
+// ************************************************************\r
+// Encapsulation section Type values\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_COMPRESSION   0x01\r
+#define EFI_SECTION_GUID_DEFINED  0x02\r
+\r
+//\r
+// ************************************************************\r
+// Leaf section Type values\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10\r
+\r
+#define EFI_SECTION_PE32                    0x10\r
+#define EFI_SECTION_PIC                     0x11\r
+#define EFI_SECTION_TE                      0x12\r
+#define EFI_SECTION_DXE_DEPEX               0x13\r
+#define EFI_SECTION_VERSION                 0x14\r
+#define EFI_SECTION_USER_INTERFACE          0x15\r
+#define EFI_SECTION_COMPATIBILITY16         0x16\r
+#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE   0x17\r
+#define EFI_SECTION_FREEFORM_SUBTYPE_GUID   0x18\r
+#define EFI_SECTION_RAW                     0x19\r
+#define EFI_SECTION_PEI_DEPEX               0x1B\r
+\r
+#define EFI_SECTION_LAST_LEAF_SECTION_TYPE  0x1B\r
+#define EFI_SECTION_LAST_SECTION_TYPE       0x1B\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Common section header\r
+//\r
+typedef struct {\r
+  UINT8 Size[3];\r
+  UINT8 Type;\r
+} EFI_COMMON_SECTION_HEADER;\r
+\r
+#define SECTION_SIZE(SectionHeaderPtr) \\r
+    ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Compression section\r
+//\r
+//\r
+// CompressionType values\r
+//\r
+#define EFI_NOT_COMPRESSED          0x00\r
+#define EFI_STANDARD_COMPRESSION    0x01\r
+#define EFI_CUSTOMIZED_COMPRESSION  0x02\r
+\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  UINT32                    UncompressedLength;\r
+  UINT8                     CompressionType;\r
+} EFI_COMPRESSION_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// GUID defined section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  EFI_GUID                  SectionDefinitionGuid;\r
+  UINT16                    DataOffset;\r
+  UINT16                    Attributes;\r
+} EFI_GUID_DEFINED_SECTION;\r
+\r
+//\r
+// Bit values for Attributes\r
+//\r
+#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED  0x01\r
+#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID    0x02\r
+\r
+//\r
+// Bit values for AuthenticationStatus\r
+//\r
+#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001\r
+#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED      0x000002\r
+#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED        0x000004\r
+#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED       0x000008\r
+#define EFI_AGGREGATE_AUTH_STATUS_ALL               0x00000f\r
+\r
+#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE     0x010000\r
+#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED          0x020000\r
+#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED            0x040000\r
+#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED           0x080000\r
+#define EFI_LOCAL_AUTH_STATUS_ALL                   0x0f0000\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PE32+ section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PE32_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PIC section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PIC_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PEIM header section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PEIM_HEADER_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DEPEX section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_DEPEX_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Version section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  UINT16                    BuildNumber;\r
+  INT16                     VersionString[1];\r
+} EFI_VERSION_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// User interface section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  INT16                     FileNameString[1];\r
+} EFI_USER_INTERFACE_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Code16 section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_CODE16_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Firmware Volume Image section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_FIRMWARE_VOLUME_IMAGE_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Freeform subtype GUID section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  EFI_GUID                  SubTypeGuid;\r
+} EFI_FREEFORM_SUBTYPE_GUID_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Raw section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_RAW_SECTION;\r
+\r
+//\r
+// undo the pragma from the beginning...\r
+//\r
+#pragma pack()\r
+\r
+typedef union {\r
+  EFI_COMMON_SECTION_HEADER         *CommonHeader;\r
+  EFI_COMPRESSION_SECTION           *CompressionSection;\r
+  EFI_GUID_DEFINED_SECTION          *GuidDefinedSection;\r
+  EFI_PE32_SECTION                  *Pe32Section;\r
+  EFI_PIC_SECTION                   *PicSection;\r
+  EFI_PEIM_HEADER_SECTION           *PeimHeaderSection;\r
+  EFI_DEPEX_SECTION                 *DependencySection;\r
+  EFI_VERSION_SECTION               *VersionSection;\r
+  EFI_USER_INTERFACE_SECTION        *UISection;\r
+  EFI_CODE16_SECTION                *Code16Section;\r
+  EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;\r
+  EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;\r
+  EFI_RAW_SECTION                   *RawSection;\r
+} EFI_FILE_SECTION_POINTER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h
new file mode 100644 (file)
index 0000000..fb3e6b9
--- /dev/null
@@ -0,0 +1,431 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiInternalFormRepresentation.h\r
+\r
+Abstract:\r
+\r
+  This file defines the encoding for the VFR (Visual Form Representation) language.\r
+  IFR is primarily consumed by the EFI presentation engine, and produced by EFI\r
+  internal application and drivers as well as all add-in card option-ROM drivers\r
+\r
+--*/\r
+\r
+#ifndef _EFI_INTERNAL_FORM_REPRESENTATION_H_\r
+#define _EFI_INTERNAL_FORM_REPRESENTATION_H_\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef UINT32  RELOFST;\r
+typedef UINT16  STRING_REF;\r
+typedef CHAR16  *EFI_STRING;\r
+\r
+//\r
+// IFR Op codes\r
+//\r
+#define EFI_IFR_FORM_OP                 0x01\r
+#define EFI_IFR_SUBTITLE_OP             0x02\r
+#define EFI_IFR_TEXT_OP                 0x03\r
+#define EFI_IFR_GRAPHIC_OP              0x04\r
+#define EFI_IFR_ONE_OF_OP               0x05\r
+#define EFI_IFR_CHECKBOX_OP             0x06\r
+#define EFI_IFR_NUMERIC_OP              0x07\r
+#define EFI_IFR_PASSWORD_OP             0x08\r
+#define EFI_IFR_ONE_OF_OPTION_OP        0x09  // ONEOF OPTION field\r
+#define EFI_IFR_SUPPRESS_IF_OP          0x0A\r
+#define EFI_IFR_END_FORM_OP             0x0B\r
+#define EFI_IFR_HIDDEN_OP               0x0C\r
+#define EFI_IFR_END_FORM_SET_OP         0x0D\r
+#define EFI_IFR_FORM_SET_OP             0x0E\r
+#define EFI_IFR_REF_OP                  0x0F\r
+#define EFI_IFR_END_ONE_OF_OP           0x10\r
+#define EFI_IFR_END_OP                  EFI_IFR_END_ONE_OF_OP\r
+#define EFI_IFR_INCONSISTENT_IF_OP      0x11\r
+#define EFI_IFR_EQ_ID_VAL_OP            0x12\r
+#define EFI_IFR_EQ_ID_ID_OP             0x13\r
+#define EFI_IFR_EQ_ID_LIST_OP           0x14\r
+#define EFI_IFR_AND_OP                  0x15\r
+#define EFI_IFR_OR_OP                   0x16\r
+#define EFI_IFR_NOT_OP                  0x17\r
+#define EFI_IFR_END_IF_OP               0x18  // for endif of inconsistentif, suppressif, grayoutif\r
+#define EFI_IFR_GRAYOUT_IF_OP           0x19\r
+#define EFI_IFR_DATE_OP                 0x1A\r
+#define EFI_IFR_TIME_OP                 0x1B\r
+#define EFI_IFR_STRING_OP               0x1C\r
+#define EFI_IFR_LABEL_OP                0x1D\r
+#define EFI_IFR_SAVE_DEFAULTS_OP        0x1E\r
+#define EFI_IFR_RESTORE_DEFAULTS_OP     0x1F\r
+#define EFI_IFR_BANNER_OP               0x20\r
+#define EFI_IFR_INVENTORY_OP            0x21\r
+#define EFI_IFR_EQ_VAR_VAL_OP           0x22\r
+#define EFI_IFR_ORDERED_LIST_OP         0x23\r
+#define EFI_IFR_VARSTORE_OP             0x24\r
+#define EFI_IFR_VARSTORE_SELECT_OP      0x25\r
+#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26\r
+#define EFI_IFR_TRUE_OP                 0x27\r
+#define EFI_IFR_FALSE_OP                0x28\r
+#define EFI_IFR_GT_OP                   0x29\r
+#define EFI_IFR_GE_OP                   0x2A\r
+#define EFI_IFR_OEM_DEFINED_OP          0x2B\r
+#define EFI_IFR_LAST_OPCODE             EFI_IFR_OEM_DEFINED_OP\r
+#define EFI_IFR_OEM_OP                  0xFE\r
+#define EFI_IFR_NV_ACCESS_COMMAND       0xFF\r
+\r
+//\r
+// Define values for the flags fields in some VFR opcodes. These are\r
+// bitmasks.\r
+//\r
+#define EFI_IFR_FLAG_DEFAULT              0x01\r
+#define EFI_IFR_FLAG_MANUFACTURING        0x02\r
+#define EFI_IFR_FLAG_INTERACTIVE          0x04\r
+#define EFI_IFR_FLAG_NV_ACCESS            0x08\r
+#define EFI_IFR_FLAG_RESET_REQUIRED       0x10\r
+#define EFI_IFR_FLAG_LATE_CHECK           0x20\r
+\r
+#define EFI_NON_DEVICE_CLASS              0x00  // Useful when you do not want something in the Device Manager\r
+#define EFI_DISK_DEVICE_CLASS             0x01\r
+#define EFI_VIDEO_DEVICE_CLASS            0x02\r
+#define EFI_NETWORK_DEVICE_CLASS          0x04\r
+#define EFI_INPUT_DEVICE_CLASS            0x08\r
+#define EFI_ON_BOARD_DEVICE_CLASS         0x10\r
+#define EFI_OTHER_DEVICE_CLASS            0x20\r
+\r
+#define EFI_SETUP_APPLICATION_SUBCLASS    0x00\r
+#define EFI_GENERAL_APPLICATION_SUBCLASS  0x01\r
+#define EFI_FRONT_PAGE_SUBCLASS           0x02\r
+#define EFI_SINGLE_USE_SUBCLASS           0x03  // Used to display a single entity and then exit\r
+//\r
+// Used to flag dynamically created op-codes. This is meaningful to the IFR Library set\r
+// and the browser since we need to distinguish between compiled NV map data and created data.\r
+// We do not allow new entries to be created in the NV map dynamically however we still need\r
+// to display this information correctly.  To dynamically create op-codes and assume that their\r
+// data will be saved, ensure that the NV starting location they refer to is pre-defined in the\r
+// NV map.\r
+//\r
+#define EFI_IFR_FLAG_CREATED  128\r
+\r
+#pragma pack(1)\r
+//\r
+// IFR Structure definitions\r
+//\r
+typedef struct {\r
+  UINT8 OpCode;\r
+  UINT8 Length;\r
+} EFI_IFR_OP_HEADER;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER     Header;\r
+  EFI_GUID              Guid;\r
+  STRING_REF            FormSetTitle;\r
+  STRING_REF            Help;\r
+  EFI_PHYSICAL_ADDRESS  CallbackHandle;\r
+  UINT16                Class;\r
+  UINT16                SubClass;\r
+  UINT16                NvDataSize; // set once, size of the NV data as defined in the script\r
+} EFI_IFR_FORM_SET;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        FormTitle;\r
+} EFI_IFR_FORM;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            LabelId;\r
+} EFI_IFR_LABEL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        SubTitle;\r
+} EFI_IFR_SUBTITLE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Help;\r
+  STRING_REF        Text;\r
+  STRING_REF        TextTwo;\r
+  UINT8             Flags;          // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;            // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_TEXT;\r
+\r
+//\r
+// goto\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        Prompt;\r
+  STRING_REF        Help;   // The string Token for the context-help\r
+  UINT8             Flags;  // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;    // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_REF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_FORM;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_FORM_SET;\r
+\r
+//\r
+// Also notice that the IFR_ONE_OF and IFR_CHECK_BOX are identical in structure......code assumes this to be true, if this ever\r
+// changes we need to revisit the InitializeTagStructures code\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+} EFI_IFR_ONE_OF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The offset in NV for storage of the data\r
+  UINT8             MaxEntries; // The maximum number of options in the ordered list (=size of NVStore)\r
+  STRING_REF        Prompt;     // The string token for the prompt\r
+  STRING_REF        Help;       // The string token for the context-help\r
+} EFI_IFR_ORDERED_LIST;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_CHECK_BOX;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Option;     // The string token describing the option\r
+  UINT16            Value;      // The value associated with this option that is stored in the NVRAM if chosen\r
+  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely above\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_ONE_OF_OPTION;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+  UINT8             Flags;      // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+  UINT16            Minimum;\r
+  UINT16            Maximum;\r
+  UINT16            Step;       // If step is 0, then manual input is specified, otherwise, left/right arrow selection is called for\r
+  UINT16            Default;\r
+} EFI_IFR_NUMERIC;\r
+\r
+//\r
+// There is an interesting twist with regards to Time and Date.  This is one of the few items which can accept input from\r
+// a user, however may or may not need to use storage in the NVRAM space.  The decided method for determining if NVRAM space\r
+// will be used (only for a TimeOp or DateOp) is:  If .QuestionId == 0 && .Width == 0 (normally an impossibility) then use system\r
+// resources to store the data away and not NV resources.  In other words, the setup engine will call gRT->SetTime, and gRT->SetDate\r
+// for the saving of data, and the values displayed will be from the gRT->GetXXXX series of calls.\r
+//\r
+typedef struct {\r
+  EFI_IFR_NUMERIC Hour;\r
+  EFI_IFR_NUMERIC Minute;\r
+  EFI_IFR_NUMERIC Second;\r
+} EFI_IFR_TIME;\r
+\r
+typedef struct {\r
+  EFI_IFR_NUMERIC Year;\r
+  EFI_IFR_NUMERIC Month;\r
+  EFI_IFR_NUMERIC Day;\r
+} EFI_IFR_DATE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
+  STRING_REF        Prompt;       // The String Token for the Prompt\r
+  STRING_REF        Help;         // The string Token for the context-help\r
+  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
+  UINT8             MinSize;      // Minimum allowable sized password\r
+  UINT8             MaxSize;      // Maximum allowable sized password\r
+  UINT16            Encoding;\r
+} EFI_IFR_PASSWORD;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
+  STRING_REF        Prompt;       // The String Token for the Prompt\r
+  STRING_REF        Help;         // The string Token for the context-help\r
+  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
+  UINT8             MinSize;      // Minimum allowable sized password\r
+  UINT8             MaxSize;      // Maximum allowable sized password\r
+} EFI_IFR_STRING;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_ONE_OF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            Value;\r
+  UINT16            Key;\r
+} EFI_IFR_HIDDEN;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT8             Flags;\r
+} EFI_IFR_SUPPRESS;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT8             Flags;\r
+} EFI_IFR_GRAYOUT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Popup;\r
+  UINT8             Flags;\r
+} EFI_IFR_INCONSISTENT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // offset into variable storage\r
+  UINT8             Width;        // size of variable storage\r
+  UINT16            Value;        // value to compare against\r
+} EFI_IFR_EQ_ID_VAL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // offset into variable storage\r
+  UINT8             Width;        // size of variable storage\r
+  UINT16            ListLength;\r
+  UINT16            ValueList[1];\r
+} EFI_IFR_EQ_ID_LIST;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId1;  // offset into variable storage for first value to compare\r
+  UINT8             Width;        // size of variable storage (must be same for both)\r
+  UINT16            QuestionId2;  // offset into variable storage for second value to compare\r
+} EFI_IFR_EQ_ID_ID;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VariableId;   // offset into variable storage\r
+  UINT16            Value;        // value to compare against\r
+} EFI_IFR_EQ_VAR_VAL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_AND;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_OR;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_NOT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_IF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        Prompt;\r
+  STRING_REF        Help;\r
+  UINT8             Flags;\r
+  UINT16            Key;\r
+} EFI_IFR_SAVE_DEFAULTS;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Help;\r
+  STRING_REF        Text;\r
+  STRING_REF        TextTwo;      // optional text\r
+} EFI_IFR_INVENTORY;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  EFI_GUID          Guid;         // GUID for the variable\r
+  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
+  UINT16            Size;         // size of the variable storage\r
+} EFI_IFR_VARSTORE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
+} EFI_IFR_VARSTORE_SELECT;\r
+\r
+//\r
+// Used for the ideqid VFR statement where two variable stores may be referenced in the\r
+// same VFR statement.\r
+// A browser should treat this as an EFI_IFR_VARSTORE_SELECT statement and assume that all following\r
+// IFR opcodes use the VarId as defined here.\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VarId;          // variable store ID, as referenced elsewhere in the form\r
+  UINT16            SecondaryVarId; // variable store ID, as referenced elsewhere in the form\r
+} EFI_IFR_VARSTORE_SELECT_PAIR;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_TRUE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_FALSE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_GT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_GE;\r
+\r
+//\r
+// Save defaults and restore defaults have same structure\r
+//\r
+#define EFI_IFR_RESTORE_DEFAULTS  EFI_IFR_SAVE_DEFAULTS\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Title;        // The string token for the banner title\r
+  UINT16            LineNumber;   // 1-based line number\r
+  UINT8             Alignment;    // left, center, or right-aligned\r
+} EFI_IFR_BANNER;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // Offset into the map\r
+  UINT8             StorageWidth; // Width of the value\r
+  CHAR8             Data[1];      // The Data itself\r
+} EFI_IFR_NV_DATA;\r
+\r
+#define EFI_IFR_BANNER_ALIGN_LEFT   0\r
+#define EFI_IFR_BANNER_ALIGN_CENTER 1\r
+#define EFI_IFR_BANNER_ALIGN_RIGHT  2\r
+#define EFI_IFR_BANNER_TIMEOUT      0xFF\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h
new file mode 100644 (file)
index 0000000..957eb4f
--- /dev/null
@@ -0,0 +1,82 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ EfiPciCfg.h\r
+\r
+Abstract:\r
+\r
+  Abstract the common fields of PciCfg definition between Framework 0.9x\r
+  and PI 1.0.\r
\r
+--*/\r
+\r
+#ifndef _EFI_PCI_CFG_H_\r
+#define _EFI_PCI_CFG_H_\r
+\r
+//\r
+// Framework specification 0.9x definition.\r
+//\r
+typedef enum {\r
+  PeiPciCfgWidthUint8   = 0,\r
+  PeiPciCfgWidthUint16  = 1,\r
+  PeiPciCfgWidthUint32  = 2,\r
+  PeiPciCfgWidthUint64  = 3,\r
+  PeiPciCfgWidthMaximum\r
+} PEI_PCI_CFG_PPI_WIDTH;\r
+\r
+#define PEI_PCI_CFG_ADDRESS(bus, dev, func, reg)  ( \\r
+      (UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)) \\r
+    ) & 0x00000000ffffffff\r
+\r
+//\r
+// PI 1.0 definition.\r
+//\r
+typedef enum {\r
+  EfiPeiPciCfgWidthUint8   = 0,\r
+  EfiPeiPciCfgWidthUint16  = 1,\r
+  EfiPeiPciCfgWidthUint32  = 2,\r
+  EfiPeiPciCfgWidthUint64  = 3,\r
+  EfiPeiPciCfgWidthMaximum\r
+} EFI_PEI_PCI_CFG_PPI_WIDTH;\r
+\r
+#define EFI_PEI_PCI_CFG_ADDRESS(bus, dev, func, reg)   \\r
+            (   ((bus) << 24)  | \\r
+                ((dev) << 16)  | \\r
+                ((func) << 8)  | \\r
+                ((reg) < 256 ? (reg): ((UINT64)(reg) << 32))) \r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+typedef struct {\r
+  UINT8 Register;\r
+  UINT8 Function;\r
+  UINT8 Device;\r
+  UINT8 Bus;\r
+  UINT8 Reserved[4];\r
+} PEI_PCI_CFG_PPI_PCI_ADDRESS;\r
+\r
+typedef PEI_PCI_CFG_PPI_PCI_ADDRESS        EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;\r
+\r
+#else\r
+\r
+typedef struct {\r
+  UINT8 Register;\r
+  UINT8 Function;\r
+  UINT8 Device;\r
+  UINT8 Bus;\r
+  UINT32 ExtendedRegister;\r
+} EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h
new file mode 100644 (file)
index 0000000..ed5f10d
--- /dev/null
@@ -0,0 +1,69 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiSmbus.h\r
+\r
+Abstract:\r
+\r
+  \r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMBUS_DEFINITION_H_\r
+#define _EFI_SMBUS_DEFINITION_H_\r
+\r
+//\r
+// EFI Smbus Device Address, Smbus Device Command, Smbus Operation\r
+//\r
+typedef struct {\r
+  UINTN SmbusDeviceAddress : 7;\r
+} EFI_SMBUS_DEVICE_ADDRESS;\r
+\r
+typedef UINTN EFI_SMBUS_DEVICE_COMMAND;\r
+\r
+typedef enum _EFI_SMBUS_OPERATION\r
+{\r
+  EfiSmbusQuickRead,\r
+  EfiSmbusQuickWrite,\r
+  EfiSmbusReceiveByte,\r
+  EfiSmbusSendByte,\r
+  EfiSmbusReadByte,\r
+  EfiSmbusWriteByte,\r
+  EfiSmbusReadWord,\r
+  EfiSmbusWriteWord,\r
+  EfiSmbusReadBlock,\r
+  EfiSmbusWriteBlock,\r
+  EfiSmbusProcessCall,\r
+  EfiSmbusBWBRProcessCall\r
+} EFI_SMBUS_OPERATION;\r
+\r
+typedef struct {\r
+  UINT32  VendorSpecificId;\r
+  UINT16  SubsystemDeviceId;\r
+  UINT16  SubsystemVendorId;\r
+  UINT16  Interface;\r
+  UINT16  DeviceId;\r
+  UINT16  VendorId;\r
+  UINT8   VendorRevision;\r
+  UINT8   DeviceCapabilities;\r
+} EFI_SMBUS_UDID;\r
+\r
+\r
+typedef struct {\r
+  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
+  EFI_SMBUS_UDID            SmbusDeviceUdid;\r
+} EFI_SMBUS_DEVICE_MAP;\r
+\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h
new file mode 100644 (file)
index 0000000..cbad559
--- /dev/null
@@ -0,0 +1,954 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiStatusCode.h\r
+\r
+Abstract:\r
+\r
+  Status Code Definitions, according to Intel Platform Innovation Framework \r
+  for EFI Status Codes Specification\r
+  Revision 0.92\r
+\r
+  The file is divided into sections for ease of use.\r
+\r
+  Section:    Contents:\r
+    1           General Status Code Definitions\r
+    2           Class definitions\r
+    3           Computing Unit Subclasses, Progress and Error Codes\r
+    4           Peripheral Subclasses, Progress and Error Codes.\r
+    5           IO Bus Subclasses, Progress and Error Codes.\r
+    6           Software Subclasses, Progress and Error Codes.\r
+    7           Debug Codes\r
+\r
+--*/\r
+\r
+#ifndef _EFI_STATUS_CODE_H_\r
+#define _EFI_STATUS_CODE_H_\r
+\r
+//\r
+// /////////////////////////////////////////////////////////////////////////////\r
+// Section 1\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Status Code Type Definition\r
+//\r
+typedef UINT32  EFI_STATUS_CODE_TYPE;\r
+\r
+//\r
+// A Status Code Type is made up of the code type and severity\r
+// All values masked by EFI_STATUS_CODE_RESERVED_MASK are\r
+// reserved for use by this specification.\r
+//\r
+#define EFI_STATUS_CODE_TYPE_MASK     0x000000FF\r
+#define EFI_STATUS_CODE_SEVERITY_MASK 0xFF000000\r
+#define EFI_STATUS_CODE_RESERVED_MASK 0x00FFFF00\r
+\r
+//\r
+// Definition of code types, all other values masked by\r
+// EFI_STATUS_CODE_TYPE_MASK are reserved for use by\r
+// this specification.\r
+//\r
+#define EFI_PROGRESS_CODE 0x00000001\r
+#define EFI_ERROR_CODE    0x00000002\r
+#define EFI_DEBUG_CODE    0x00000003\r
+\r
+//\r
+// Definitions of severities, all other values masked by\r
+// EFI_STATUS_CODE_SEVERITY_MASK are reserved for use by\r
+// this specification.\r
+//\r
+#define EFI_ERROR_MINOR       0x40000000\r
+#define EFI_ERROR_MAJOR       0x80000000\r
+#define EFI_ERROR_UNRECOVERED 0x90000000\r
+#define EFI_ERROR_UNCONTAINED 0xA0000000\r
+\r
+//\r
+// Status Code Value Definition\r
+//\r
+typedef UINT32  EFI_STATUS_CODE_VALUE;\r
+\r
+//\r
+// A Status Code Value is made up of the class, subclass, and\r
+// an operation.  Classes, subclasses, and operations are defined\r
+// in the following sections.\r
+//\r
+#define EFI_STATUS_CODE_CLASS_MASK      0xFF000000\r
+#define EFI_STATUS_CODE_SUBCLASS_MASK   0x00FF0000\r
+#define EFI_STATUS_CODE_OPERATION_MASK  0x0000FFFF\r
+\r
+typedef struct {\r
+  UINT16    HeaderSize;\r
+  UINT16    Size;\r
+  EFI_GUID  Type;\r
+} EFI_STATUS_CODE_DATA;\r
+\r
+//\r
+// Data Hub Status Code class record definition\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_TYPE  CodeType;\r
+  EFI_STATUS_CODE_VALUE Value;\r
+  UINT32                Instance;\r
+  EFI_GUID              CallerId;\r
+  EFI_STATUS_CODE_DATA  Data;\r
+} DATA_HUB_STATUS_CODE_DATA_RECORD;\r
+\r
+//\r
+// /////////////////////////////////////////////////////////////////////////////\r
+// Section 2\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Class definitions\r
+// Values of 4-127 are reserved for future use by this\r
+// specification.\r
+// Values in the range 128-255 are reserved for OEM use.\r
+//\r
+#define EFI_COMPUTING_UNIT  0x00000000\r
+#define EFI_PERIPHERAL      0x01000000\r
+#define EFI_IO_BUS          0x02000000\r
+#define EFI_SOFTWARE        0x03000000\r
+\r
+//\r
+// General partitioning scheme for Progress and Error Codes are\r
+// 0x0000-0x0FFF  - Shared by all sub-classes in a given class\r
+// 0x1000-0x7FFF  - Subclass Specific\r
+// 0x8000-0xFFFF  - OEM specific\r
+//\r
+#define EFI_SUBCLASS_SPECIFIC 0x1000\r
+#define EFI_OEM_SPECIFIC      0x8000\r
+\r
+//\r
+// /////////////////////////////////////////////////////////////////////////////\r
+// Section 3\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Computing Unit Subclass definitions.\r
+// Values of 7-127 are reserved for future use by this\r
+// specification.\r
+// Values of 128-255 are reserved for OEM use.\r
+//\r
+#define EFI_COMPUTING_UNIT_UNSPECIFIED        (EFI_COMPUTING_UNIT | 0x00000000)\r
+#define EFI_COMPUTING_UNIT_HOST_PROCESSOR     (EFI_COMPUTING_UNIT | 0x00010000)\r
+#define EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR (EFI_COMPUTING_UNIT | 0x00020000)\r
+#define EFI_COMPUTING_UNIT_IO_PROCESSOR       (EFI_COMPUTING_UNIT | 0x00030000)\r
+#define EFI_COMPUTING_UNIT_CACHE              (EFI_COMPUTING_UNIT | 0x00040000)\r
+#define EFI_COMPUTING_UNIT_MEMORY             (EFI_COMPUTING_UNIT | 0x00050000)\r
+#define EFI_COMPUTING_UNIT_CHIPSET            (EFI_COMPUTING_UNIT | 0x00060000)\r
+\r
+//\r
+// Computing Unit Class Progress Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_CU_PC_INIT_BEGIN  0x00000000\r
+#define EFI_CU_PC_INIT_END    0x00000001\r
+\r
+//\r
+// Computing Unit Unspecified Subclass Progress Code definitions.\r
+//\r
+//\r
+// Computing Unit Host Processor Subclass Progress Code definitions.\r
+//\r
+#define EFI_CU_HP_PC_POWER_ON_INIT          (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_HP_PC_CACHE_INIT             (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_HP_PC_RAM_INIT               (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_CU_HP_PC_MEMORY_CONTROLLER_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_CU_HP_PC_IO_INIT                (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_CU_HP_PC_BSP_SELECT             (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_CU_HP_PC_BSP_RESELECT           (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_CU_HP_PC_AP_INIT                (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_CU_HP_PC_SMM_INIT               (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+\r
+//\r
+// Computing Unit Firmware Processor Subclass Progress Code definitions.\r
+//\r
+//\r
+// Computing Unit IO Processor Subclass Progress Code definitions.\r
+//\r
+//\r
+// Computing Unit Cache Subclass Progress Code definitions.\r
+//\r
+#define EFI_CU_CACHE_PC_PRESENCE_DETECT (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_CACHE_PC_CONFIGURATION   (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Computing Unit Memory Subclass Progress Code definitions.\r
+//\r
+#define EFI_CU_MEMORY_PC_SPD_READ         (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_MEMORY_PC_PRESENCE_DETECT  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_MEMORY_PC_TIMING           (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_CU_MEMORY_PC_CONFIGURING      (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_CU_MEMORY_PC_OPTIMIZING       (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_CU_MEMORY_PC_INIT             (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_CU_MEMORY_PC_TEST             (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+\r
+//\r
+// Computing Unit Chipset Subclass Progress Code definitions.\r
+//\r
+//\r
+// Computing Unit Class Error Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_CU_EC_NON_SPECIFIC    0x00000000\r
+#define EFI_CU_EC_DISABLED        0x00000001\r
+#define EFI_CU_EC_NOT_SUPPORTED   0x00000002\r
+#define EFI_CU_EC_NOT_DETECTED    0x00000003\r
+#define EFI_CU_EC_NOT_CONFIGURED  0x00000004\r
+\r
+//\r
+// Computing Unit Unspecified Subclass Error Code definitions.\r
+//\r
+//\r
+// Computing Unit Host Processor Subclass Error Code definitions.\r
+//\r
+#define EFI_CU_HP_EC_INVALID_TYPE         (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_HP_EC_INVALID_SPEED        (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_HP_EC_MISMATCH             (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_CU_HP_EC_TIMER_EXPIRED        (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_CU_HP_EC_SELF_TEST            (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_CU_HP_EC_INTERNAL             (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_CU_HP_EC_THERMAL              (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_CU_HP_EC_LOW_VOLTAGE          (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_CU_HP_EC_HIGH_VOLTAGE         (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_CU_HP_EC_CACHE                (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_CU_HP_EC_MICROCODE_UPDATE     (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+#define EFI_CU_HP_EC_CORRECTABLE          (EFI_SUBCLASS_SPECIFIC | 0x0000000B)\r
+#define EFI_CU_HP_EC_UNCORRECTABLE        (EFI_SUBCLASS_SPECIFIC | 0x0000000C)\r
+#define EFI_CU_HP_EC_NO_MICROCODE_UPDATE  (EFI_SUBCLASS_SPECIFIC | 0x0000000D)\r
+\r
+//\r
+// Computing Unit Firmware Processor Subclass Error Code definitions.\r
+//\r
+#define EFI_CU_FP_EC_HARD_FAIL  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_FP_EC_SOFT_FAIL  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_FP_EC_COMM_ERROR (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+\r
+//\r
+// Computing Unit IO Processor Subclass Error Code definitions.\r
+//\r
+//\r
+// Computing Unit Cache Subclass Error Code definitions.\r
+//\r
+#define EFI_CU_CACHE_EC_INVALID_TYPE  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_CACHE_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_CACHE_EC_INVALID_SIZE  (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_CU_CACHE_EC_MISMATCH      (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+\r
+//\r
+// Computing Unit Memory Subclass Error Code definitions.\r
+//\r
+#define EFI_CU_MEMORY_EC_INVALID_TYPE   (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_CU_MEMORY_EC_INVALID_SPEED  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_CU_MEMORY_EC_CORRECTABLE    (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_CU_MEMORY_EC_UNCORRECTABLE  (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_CU_MEMORY_EC_SPD_FAIL       (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_CU_MEMORY_EC_INVALID_SIZE   (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_CU_MEMORY_EC_MISMATCH       (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_CU_MEMORY_EC_S3_RESUME_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_CU_MEMORY_EC_UPDATE_FAIL    (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_CU_MEMORY_EC_NONE_DETECTED  (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_CU_MEMORY_EC_NONE_USEFUL    (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+\r
+//\r
+// Computing Unit Chipset Subclass Error Code definitions.\r
+//\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+// Section 4\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Peripheral Subclass definitions.\r
+// Values of 13-127 are reserved for future use by this\r
+// specification.\r
+// Values of 128-255 are reserved for OEM use.\r
+//\r
+#define EFI_PERIPHERAL_UNSPECIFIED      (EFI_PERIPHERAL | 0x00000000)\r
+#define EFI_PERIPHERAL_KEYBOARD         (EFI_PERIPHERAL | 0x00010000)\r
+#define EFI_PERIPHERAL_MOUSE            (EFI_PERIPHERAL | 0x00020000)\r
+#define EFI_PERIPHERAL_LOCAL_CONSOLE    (EFI_PERIPHERAL | 0x00030000)\r
+#define EFI_PERIPHERAL_REMOTE_CONSOLE   (EFI_PERIPHERAL | 0x00040000)\r
+#define EFI_PERIPHERAL_SERIAL_PORT      (EFI_PERIPHERAL | 0x00050000)\r
+#define EFI_PERIPHERAL_PARALLEL_PORT    (EFI_PERIPHERAL | 0x00060000)\r
+#define EFI_PERIPHERAL_FIXED_MEDIA      (EFI_PERIPHERAL | 0x00070000)\r
+#define EFI_PERIPHERAL_REMOVABLE_MEDIA  (EFI_PERIPHERAL | 0x00080000)\r
+#define EFI_PERIPHERAL_AUDIO_INPUT      (EFI_PERIPHERAL | 0x00090000)\r
+#define EFI_PERIPHERAL_AUDIO_OUTPUT     (EFI_PERIPHERAL | 0x000A0000)\r
+#define EFI_PERIPHERAL_LCD_DEVICE       (EFI_PERIPHERAL | 0x000B0000)\r
+#define EFI_PERIPHERAL_NETWORK          (EFI_PERIPHERAL | 0x000C0000)\r
+\r
+//\r
+// Peripheral Class Progress Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_P_PC_INIT             0x00000000\r
+#define EFI_P_PC_RESET            0x00000001\r
+#define EFI_P_PC_DISABLE          0x00000002\r
+#define EFI_P_PC_PRESENCE_DETECT  0x00000003\r
+#define EFI_P_PC_ENABLE           0x00000004\r
+#define EFI_P_PC_RECONFIG         0x00000005\r
+#define EFI_P_PC_DETECTED         0x00000006\r
+\r
+//\r
+// Peripheral Class Unspecified Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Keyboard Subclass Progress Code definitions.\r
+//\r
+#define EFI_P_KEYBOARD_PC_CLEAR_BUFFER  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_P_KEYBOARD_PC_SELF_TEST     (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Peripheral Class Mouse Subclass Progress Code definitions.\r
+//\r
+#define EFI_P_MOUSE_PC_SELF_TEST  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+\r
+//\r
+// Peripheral Class Local Console Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Remote Console Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Serial Port Subclass Progress Code definitions.\r
+//\r
+#define EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+\r
+//\r
+// Peripheral Class Parallel Port Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Fixed Media Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Removable Media Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Audio Input Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Audio Output Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class LCD Device Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Network Subclass Progress Code definitions.\r
+//\r
+//\r
+// Peripheral Class Error Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_P_EC_NON_SPECIFIC       0x00000000\r
+#define EFI_P_EC_DISABLED           0x00000001\r
+#define EFI_P_EC_NOT_SUPPORTED      0x00000002\r
+#define EFI_P_EC_NOT_DETECTED       0x00000003\r
+#define EFI_P_EC_NOT_CONFIGURED     0x00000004\r
+#define EFI_P_EC_INTERFACE_ERROR    0x00000005\r
+#define EFI_P_EC_CONTROLLER_ERROR   0x00000006\r
+#define EFI_P_EC_INPUT_ERROR        0x00000007\r
+#define EFI_P_EC_OUTPUT_ERROR       0x00000008\r
+#define EFI_P_EC_RESOURCE_CONFLICT  0x00000009\r
+\r
+//\r
+// Peripheral Class Unspecified Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Keyboard Subclass Error Code definitions.\r
+//\r
+#define EFI_P_KEYBOARD_EC_LOCKED    (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_P_KEYBOARD_EC_STUCK_KEY (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Peripheral Class Mouse Subclass Error Code definitions.\r
+//\r
+#define EFI_P_MOUSE_EC_LOCKED (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+\r
+//\r
+// Peripheral Class Local Console Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Remote Console Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Serial Port Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Parallel Port Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Fixed Media Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Removable Media Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Audio Input Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Audio Output Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class LCD Device Subclass Error Code definitions.\r
+//\r
+//\r
+// Peripheral Class Network Subclass Error Code definitions.\r
+//\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+// Section 5\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IO Bus Subclass definitions.\r
+// Values of 13-127 are reserved for future use by this\r
+// specification.\r
+// Values of 128-255 are reserved for OEM use.\r
+//\r
+#define EFI_IO_BUS_UNSPECIFIED  (EFI_IO_BUS | 0x00000000)\r
+#define EFI_IO_BUS_PCI          (EFI_IO_BUS | 0x00010000)\r
+#define EFI_IO_BUS_USB          (EFI_IO_BUS | 0x00020000)\r
+#define EFI_IO_BUS_IBA          (EFI_IO_BUS | 0x00030000)\r
+#define EFI_IO_BUS_AGP          (EFI_IO_BUS | 0x00040000)\r
+#define EFI_IO_BUS_PC_CARD      (EFI_IO_BUS | 0x00050000)\r
+#define EFI_IO_BUS_LPC          (EFI_IO_BUS | 0x00060000)\r
+#define EFI_IO_BUS_SCSI         (EFI_IO_BUS | 0x00070000)\r
+#define EFI_IO_BUS_ATA_ATAPI    (EFI_IO_BUS | 0x00080000)\r
+#define EFI_IO_BUS_FC           (EFI_IO_BUS | 0x00090000)\r
+#define EFI_IO_BUS_IP_NETWORK   (EFI_IO_BUS | 0x000A0000)\r
+#define EFI_IO_BUS_SMBUS        (EFI_IO_BUS | 0x000B0000)\r
+#define EFI_IO_BUS_I2C          (EFI_IO_BUS | 0x000C0000)\r
+\r
+//\r
+// IO Bus Class Progress Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_IOB_PC_INIT     0x00000000\r
+#define EFI_IOB_PC_RESET    0x00000001\r
+#define EFI_IOB_PC_DISABLE  0x00000002\r
+#define EFI_IOB_PC_DETECT   0x00000003\r
+#define EFI_IOB_PC_ENABLE   0x00000004\r
+#define EFI_IOB_PC_RECONFIG 0x00000005\r
+#define EFI_IOB_PC_HOTPLUG  0x00000006\r
+\r
+//\r
+// IO Bus Class Unspecified Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class PCI Subclass Progress Code definitions.\r
+//\r
+#define EFI_IOB_PCI_PC_BUS_ENUM   (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_IOB_PCI_PC_RES_ALLOC  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_IOB_PCI_PC_HPC_INIT   (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+\r
+//\r
+// IO Bus Class USB Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class IBA Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class AGP Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class PC Card Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class LPC Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class SCSI Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class ATA/ATAPI Subclass Progress Code definitions.\r
+//\r
+#define EFI_IOB_ATA_BUS_SMART_ENABLE          (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_IOB_ATA_BUS_SMART_DISABLE         (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD   (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD  (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+\r
+//\r
+// IO Bus Class FC Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class IP Network Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class SMBUS Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class I2C Subclass Progress Code definitions.\r
+//\r
+//\r
+// IO Bus Class Error Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_IOB_EC_NON_SPECIFIC       0x00000000\r
+#define EFI_IOB_EC_DISABLED           0x00000001\r
+#define EFI_IOB_EC_NOT_SUPPORTED      0x00000002\r
+#define EFI_IOB_EC_NOT_DETECTED       0x00000003\r
+#define EFI_IOB_EC_NOT_CONFIGURED     0x00000004\r
+#define EFI_IOB_EC_INTERFACE_ERROR    0x00000005\r
+#define EFI_IOB_EC_CONTROLLER_ERROR   0x00000006\r
+#define EFI_IOB_EC_READ_ERROR         0x00000007\r
+#define EFI_IOB_EC_WRITE_ERROR        0x00000008\r
+#define EFI_IOB_EC_RESOURCE_CONFLICT  0x00000009\r
+\r
+//\r
+// IO Bus Class Unspecified Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class PCI Subclass Error Code definitions.\r
+//\r
+#define EFI_IOB_PCI_EC_PERR (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_IOB_PCI_EC_SERR (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// IO Bus Class USB Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class IBA Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class AGP Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class PC Card Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class LPC Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class SCSI Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class ATA/ATAPI Subclass Error Code definitions.\r
+//\r
+#define EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_IOB_ATA_BUS_SMART_DISABLED      (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// IO Bus Class FC Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class IP Network Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class SMBUS Subclass Error Code definitions.\r
+//\r
+//\r
+// IO Bus Class I2C Subclass Error Code definitions.\r
+//\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+// Section 6\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Software Subclass definitions.\r
+// Values of 20-127 are reserved for future use by this\r
+// specification.\r
+// Values of 128-255 are reserved for OEM use.\r
+//\r
+#define EFI_SOFTWARE_UNSPECIFIED          (EFI_SOFTWARE | 0x00000000)\r
+#define EFI_SOFTWARE_SEC                  (EFI_SOFTWARE | 0x00010000)\r
+#define EFI_SOFTWARE_PEI_CORE             (EFI_SOFTWARE | 0x00020000)\r
+#define EFI_SOFTWARE_PEI_MODULE           (EFI_SOFTWARE | 0x00030000)\r
+#define EFI_SOFTWARE_DXE_CORE             (EFI_SOFTWARE | 0x00040000)\r
+#define EFI_SOFTWARE_DXE_BS_DRIVER        (EFI_SOFTWARE | 0x00050000)\r
+#define EFI_SOFTWARE_DXE_RT_DRIVER        (EFI_SOFTWARE | 0x00060000)\r
+#define EFI_SOFTWARE_SMM_DRIVER           (EFI_SOFTWARE | 0x00070000)\r
+#define EFI_SOFTWARE_EFI_APPLICATION      (EFI_SOFTWARE | 0x00080000)\r
+#define EFI_SOFTWARE_EFI_OS_LOADER        (EFI_SOFTWARE | 0x00090000)\r
+#define EFI_SOFTWARE_RT                   (EFI_SOFTWARE | 0x000A0000)\r
+#define EFI_SOFTWARE_AL                   (EFI_SOFTWARE | 0x000B0000)\r
+#define EFI_SOFTWARE_EBC_EXCEPTION        (EFI_SOFTWARE | 0x000C0000)\r
+#define EFI_SOFTWARE_IA32_EXCEPTION       (EFI_SOFTWARE | 0x000D0000)\r
+#define EFI_SOFTWARE_IPF_EXCEPTION        (EFI_SOFTWARE | 0x000E0000)\r
+#define EFI_SOFTWARE_PEI_SERVICE          (EFI_SOFTWARE | 0x000F0000)\r
+#define EFI_SOFTWARE_EFI_BOOT_SERVICE     (EFI_SOFTWARE | 0x00100000)\r
+#define EFI_SOFTWARE_EFI_RUNTIME_SERVICE  (EFI_SOFTWARE | 0x00110000)\r
+#define EFI_SOFTWARE_EFI_DXE_SERVICE      (EFI_SOFTWARE | 0x00120000)\r
+#define EFI_SOFTWARE_X64_EXCEPTION        (EFI_SOFTWARE | 0x00130000)\r
+\r
+//\r
+// Software Class Progress Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_SW_PC_INIT                0x00000000\r
+#define EFI_SW_PC_LOAD                0x00000001\r
+#define EFI_SW_PC_INIT_BEGIN          0x00000002\r
+#define EFI_SW_PC_INIT_END            0x00000003\r
+#define EFI_SW_PC_AUTHENTICATE_BEGIN  0x00000004\r
+#define EFI_SW_PC_AUTHENTICATE_END    0x00000005\r
+#define EFI_SW_PC_INPUT_WAIT          0x00000006\r
+#define EFI_SW_PC_USER_SETUP          0x00000007\r
+\r
+//\r
+// Software Class Unspecified Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class SEC Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_SEC_PC_ENTRY_POINT     (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_SEC_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Software Class PEI Core Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_PEI_CORE_PC_ENTRY_POINT      (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_PEI_CORE_PC_RETURN_TO_LAST   (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+\r
+//\r
+// Software Class PEI Module Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_PEIM_PC_RECOVERY_BEGIN (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_PEIM_PC_CAPSULE_LOAD   (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_PEIM_PC_CAPSULE_START  (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_PEIM_PC_RECOVERY_USER  (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_PEIM_PC_RECOVERY_AUTO  (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+\r
+//\r
+// Software Class DXE Core Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_DXE_CORE_PC_ENTRY_POINT      (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_DXE_CORE_PC_RETURN_TO_LAST   (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_DXE_CORE_PC_START_DRIVER     (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+\r
+//\r
+// Software Class DXE BS Driver Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_DXE_BS_PC_LEGACY_OPROM_INIT            (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT          (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT            (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_DXE_BS_PC_EXIT_BOOT_SERVICES_EVENT     (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS     (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD           (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+\r
+//\r
+// Software Class DXE RT Driver Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_DXE_RT_PC_S0 (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_DXE_RT_PC_S1 (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_DXE_RT_PC_S2 (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_DXE_RT_PC_S3 (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_DXE_RT_PC_S4 (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_DXE_RT_PC_S5 (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+\r
+//\r
+// Software Class SMM Driver Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class EFI Application Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class EFI OS Loader Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class EFI RT Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_RT_PC_ENTRY_POINT      (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_RT_PC_HANDOFF_TO_NEXT  (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_RT_PC_RETURN_TO_LAST   (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+\r
+//\r
+// Software Class EFI AL Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_AL_PC_ENTRY_POINT    (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_AL_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Software Class EBC Exception Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class IA32 Exception Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class X64 Exception Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class IPF Exception Subclass Progress Code definitions.\r
+//\r
+//\r
+// Software Class PEI Services Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_PS_PC_INSTALL_PPI            (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_PS_PC_REINSTALL_PPI          (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_PS_PC_LOCATE_PPI             (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_PS_PC_NOTIFY_PPI             (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_PS_PC_GET_BOOT_MODE          (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_PS_PC_SET_BOOT_MODE          (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_SW_PS_PC_GET_HOB_LIST           (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_SW_PS_PC_CREATE_HOB             (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_SW_PS_PC_FFS_FIND_NEXT_VOLUME   (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_SW_PS_PC_FFS_FIND_NEXT_FILE     (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_SW_PS_PC_FFS_FIND_SECTION_DATA  (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+#define EFI_SW_PS_PC_INSTALL_PEI_MEMORY     (EFI_SUBCLASS_SPECIFIC | 0x0000000B)\r
+#define EFI_SW_PS_PC_ALLOCATE_PAGES         (EFI_SUBCLASS_SPECIFIC | 0x0000000C)\r
+#define EFI_SW_PS_PC_ALLOCATE_POOL          (EFI_SUBCLASS_SPECIFIC | 0x0000000D)\r
+#define EFI_SW_PS_PC_COPY_MEM               (EFI_SUBCLASS_SPECIFIC | 0x0000000E)\r
+#define EFI_SW_PS_PC_SET_MEM                (EFI_SUBCLASS_SPECIFIC | 0x0000000F)\r
+\r
+//\r
+// Software Class EFI Boot Services Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_BS_PC_RAISE_TPL                      (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_BS_PC_RESTORE_TPL                    (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_BS_PC_ALLOCATE_PAGES                 (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_BS_PC_FREE_PAGES                     (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_BS_PC_GET_MEMORY_MAP                 (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_BS_PC_ALLOCATE_POOL                  (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_SW_BS_PC_FREE_POOL                      (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_SW_BS_PC_CREATE_EVENT                   (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_SW_BS_PC_SET_TIMER                      (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_SW_BS_PC_WAIT_FOR_EVENT                 (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_SW_BS_PC_SIGNAL_EVENT                   (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+#define EFI_SW_BS_PC_CLOSE_EVENT                    (EFI_SUBCLASS_SPECIFIC | 0x0000000B)\r
+#define EFI_SW_BS_PC_CHECK_EVENT                    (EFI_SUBCLASS_SPECIFIC | 0x0000000C)\r
+#define EFI_SW_BS_PC_INSTALL_PROTOCOL_INTERFACE     (EFI_SUBCLASS_SPECIFIC | 0x0000000D)\r
+#define EFI_SW_BS_PC_REINSTALL_PROTOCOL_INTERFACE   (EFI_SUBCLASS_SPECIFIC | 0x0000000E)\r
+#define EFI_SW_BS_PC_UNINSTALL_PROTOCOL_INTERFACE   (EFI_SUBCLASS_SPECIFIC | 0x0000000F)\r
+#define EFI_SW_BS_PC_HANDLE_PROTOCOL                (EFI_SUBCLASS_SPECIFIC | 0x00000010)\r
+#define EFI_SW_BS_PC_PC_HANDLE_PROTOCOL             (EFI_SUBCLASS_SPECIFIC | 0x00000011)\r
+#define EFI_SW_BS_PC_REGISTER_PROTOCOL_NOTIFY       (EFI_SUBCLASS_SPECIFIC | 0x00000012)\r
+#define EFI_SW_BS_PC_LOCATE_HANDLE                  (EFI_SUBCLASS_SPECIFIC | 0x00000013)\r
+#define EFI_SW_BS_PC_INSTALL_CONFIGURATION_TABLE    (EFI_SUBCLASS_SPECIFIC | 0x00000014)\r
+#define EFI_SW_BS_PC_LOAD_IMAGE                     (EFI_SUBCLASS_SPECIFIC | 0x00000015)\r
+#define EFI_SW_BS_PC_START_IMAGE                    (EFI_SUBCLASS_SPECIFIC | 0x00000016)\r
+#define EFI_SW_BS_PC_EXIT                           (EFI_SUBCLASS_SPECIFIC | 0x00000017)\r
+#define EFI_SW_BS_PC_UNLOAD_IMAGE                   (EFI_SUBCLASS_SPECIFIC | 0x00000018)\r
+#define EFI_SW_BS_PC_EXIT_BOOT_SERVICES             (EFI_SUBCLASS_SPECIFIC | 0x00000019)\r
+#define EFI_SW_BS_PC_GET_NEXT_MONOTONIC_COUNT       (EFI_SUBCLASS_SPECIFIC | 0x0000001A)\r
+#define EFI_SW_BS_PC_STALL                          (EFI_SUBCLASS_SPECIFIC | 0x0000001B)\r
+#define EFI_SW_BS_PC_SET_WATCHDOG_TIMER             (EFI_SUBCLASS_SPECIFIC | 0x0000001C)\r
+#define EFI_SW_BS_PC_CONNECT_CONTROLLER             (EFI_SUBCLASS_SPECIFIC | 0x0000001D)\r
+#define EFI_SW_BS_PC_DISCONNECT_CONTROLLER          (EFI_SUBCLASS_SPECIFIC | 0x0000001E)\r
+#define EFI_SW_BS_PC_OPEN_PROTOCOL                  (EFI_SUBCLASS_SPECIFIC | 0x0000001F)\r
+#define EFI_SW_BS_PC_CLOSE_PROTOCOL                 (EFI_SUBCLASS_SPECIFIC | 0x00000020)\r
+#define EFI_SW_BS_PC_OPEN_PROTOCOL_INFORMATION      (EFI_SUBCLASS_SPECIFIC | 0x00000021)\r
+#define EFI_SW_BS_PC_PROTOCOLS_PER_HANDLE           (EFI_SUBCLASS_SPECIFIC | 0x00000022)\r
+#define EFI_SW_BS_PC_LOCATE_HANDLE_BUFFER           (EFI_SUBCLASS_SPECIFIC | 0x00000023)\r
+#define EFI_SW_BS_PC_LOCATE_PROTOCOL                (EFI_SUBCLASS_SPECIFIC | 0x00000024)\r
+#define EFI_SW_BS_PC_INSTALL_MULTIPLE_INTERFACES    (EFI_SUBCLASS_SPECIFIC | 0x00000025)\r
+#define EFI_SW_BS_PC_UNINSTALL_MULTIPLE_INTERFACES  (EFI_SUBCLASS_SPECIFIC | 0x00000026)\r
+#define EFI_SW_BS_PC_CALCULATE_CRC_32               (EFI_SUBCLASS_SPECIFIC | 0x00000027)\r
+#define EFI_SW_BS_PC_COPY_MEM                       (EFI_SUBCLASS_SPECIFIC | 0x00000028)\r
+#define EFI_SW_BS_PC_SET_MEM                        (EFI_SUBCLASS_SPECIFIC | 0x00000029)\r
+\r
+//\r
+// Software Class EFI Runtime Services Subclass Progress Code definitions.\r
+//\r
+#define EFI_SW_RS_PC_GET_TIME                       (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_RS_PC_SET_TIME                       (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_RS_PC_GET_WAKEUP_TIME                (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_RS_PC_SET_WAKEUP_TIME                (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP        (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_RS_PC_CONVERT_POINTER                (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_SW_RS_PC_GET_VARIABLE                   (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_SW_RS_PC_GET_NEXT_VARIABLE_NAME         (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_SW_RS_PC_SET_VARIABLE                   (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_SW_RS_PC_GET_NEXT_HIGH_MONOTONIC_COUNT  (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_SW_RS_PC_RESET_SYSTEM                   (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+\r
+//\r
+// Software Class EFI DXE Services Subclass Progress Code definitions\r
+//\r
+#define EFI_SW_DS_PC_ADD_MEMORY_SPACE             (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_DS_PC_ALLOCATE_MEMORY_SPACE        (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+#define EFI_SW_DS_PC_FREE_MEMORY_SPACE            (EFI_SUBCLASS_SPECIFIC | 0x00000002)\r
+#define EFI_SW_DS_PC_REMOVE_MEMORY_SPACE          (EFI_SUBCLASS_SPECIFIC | 0x00000003)\r
+#define EFI_SW_DS_PC_GET_MEMORY_SPACE_DESCRIPTOR  (EFI_SUBCLASS_SPECIFIC | 0x00000004)\r
+#define EFI_SW_DS_PC_SET_MEMORY_SPACE_ATTRIBUTES  (EFI_SUBCLASS_SPECIFIC | 0x00000005)\r
+#define EFI_SW_DS_PC_GET_MEMORY_SPACE_MAP         (EFI_SUBCLASS_SPECIFIC | 0x00000006)\r
+#define EFI_SW_DS_PC_ADD_IO_SPACE                 (EFI_SUBCLASS_SPECIFIC | 0x00000007)\r
+#define EFI_SW_DS_PC_ALLOCATE_IO_SPACE            (EFI_SUBCLASS_SPECIFIC | 0x00000008)\r
+#define EFI_SW_DS_PC_FREE_IO_SPACE                (EFI_SUBCLASS_SPECIFIC | 0x00000009)\r
+#define EFI_SW_DS_PC_REMOVE_IO_SPACE              (EFI_SUBCLASS_SPECIFIC | 0x0000000A)\r
+#define EFI_SW_DS_PC_GET_IO_SPACE_DESCRIPTOR      (EFI_SUBCLASS_SPECIFIC | 0x0000000B)\r
+#define EFI_SW_DS_PC_GET_IO_SPACE_MAP             (EFI_SUBCLASS_SPECIFIC | 0x0000000C)\r
+#define EFI_SW_DS_PC_DISPATCH                     (EFI_SUBCLASS_SPECIFIC | 0x0000000D)\r
+#define EFI_SW_DS_PC_SCHEDULE                     (EFI_SUBCLASS_SPECIFIC | 0x0000000E)\r
+#define EFI_SW_DS_PC_TRUST                        (EFI_SUBCLASS_SPECIFIC | 0x0000000F)\r
+#define EFI_SW_DS_PC_PROCESS_FIRMWARE_VOLUME      (EFI_SUBCLASS_SPECIFIC | 0x00000010)\r
+\r
+//\r
+// Software Class Error Code definitions.\r
+// These are shared by all subclasses.\r
+//\r
+#define EFI_SW_EC_NON_SPECIFIC            0x00000000\r
+#define EFI_SW_EC_LOAD_ERROR              0x00000001\r
+#define EFI_SW_EC_INVALID_PARAMETER       0x00000002\r
+#define EFI_SW_EC_UNSUPPORTED             0x00000003\r
+#define EFI_SW_EC_INVALID_BUFFER          0x00000004\r
+#define EFI_SW_EC_OUT_OF_RESOURCES        0x00000005\r
+#define EFI_SW_EC_ABORTED                 0x00000006\r
+#define EFI_SW_EC_ILLEGAL_SOFTWARE_STATE  0x00000007\r
+#define EFI_SW_EC_ILLEGAL_HARDWARE_STATE  0x00000008\r
+#define EFI_SW_EC_START_ERROR             0x00000009\r
+#define EFI_SW_EC_BAD_DATE_TIME           0x0000000A\r
+#define EFI_SW_EC_CFG_INVALID             0x0000000B\r
+#define EFI_SW_EC_CFG_CLR_REQUEST         0x0000000C\r
+#define EFI_SW_EC_CFG_DEFAULT             0x0000000D\r
+#define EFI_SW_EC_PWD_INVALID             0x0000000E\r
+#define EFI_SW_EC_PWD_CLR_REQUEST         0x0000000F\r
+#define EFI_SW_EC_PWD_CLEARED             0x00000010\r
+#define EFI_SW_EC_EVENT_LOG_FULL          0x00000011\r
+\r
+//\r
+// Software Class Unspecified Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class SEC Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class PEI Core Subclass Error Code definitions.\r
+//\r
+#define EFI_SW_PEI_CORE_EC_DXE_CORRUPT  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+\r
+//\r
+// Software Class PEI Module Subclass Error Code definitions.\r
+//\r
+#define EFI_SW_PEIM_EC_NO_RECOVERY_CAPSULE        (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+#define EFI_SW_PEIM_EC_INVALID_CAPSULE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x00000001)\r
+\r
+//\r
+// Software Class DXE Core Subclass Error Code definitions.\r
+//\r
+#define EFI_SW_CSM_LEGACY_ROM_INIT  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+//\r
+// Software Class DXE Boot Service Driver Subclass Error Code definitions.\r
+//\r
+#define EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE  (EFI_SUBCLASS_SPECIFIC | 0x00000000)\r
+\r
+//\r
+// Software Class DXE Runtime Service Driver Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class SMM Driver Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI Application Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI OS Loader Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI RT Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI AL Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EBC Exception Subclass Error Code definitions.\r
+// These exceptions are derived from the debug protocol definitions in the EFI\r
+// specification.\r
+//\r
+#define EFI_SW_EC_EBC_UNDEFINED             (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_UNDEFINED)\r
+#define EFI_SW_EC_EBC_DIVIDE_ERROR          (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DIVIDE_ERROR)\r
+#define EFI_SW_EC_EBC_DEBUG                 (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DEBUG)\r
+#define EFI_SW_EC_EBC_BREAKPOINT            (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BREAKPOINT)\r
+#define EFI_SW_EC_EBC_OVERFLOW              (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_OVERFLOW)\r
+#define EFI_SW_EC_EBC_INVALID_OPCODE        (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INVALID_OPCODE)\r
+#define EFI_SW_EC_EBC_STACK_FAULT           (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STACK_FAULT)\r
+#define EFI_SW_EC_EBC_ALIGNMENT_CHECK       (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_ALIGNMENT_CHECK)\r
+#define EFI_SW_EC_EBC_INSTRUCTION_ENCODING  (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INSTRUCTION_ENCODING)\r
+#define EFI_SW_EC_EBC_BAD_BREAK             (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BAD_BREAK)\r
+#define EFI_SW_EC_EBC_STEP                  (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STEP)\r
+\r
+//\r
+// Software Class IA32 Exception Subclass Error Code definitions.\r
+// These exceptions are derived from the debug protocol definitions in the EFI\r
+// specification.\r
+//\r
+#define EFI_SW_EC_IA32_DIVIDE_ERROR     (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DIVIDE_ERROR)\r
+#define EFI_SW_EC_IA32_DEBUG            (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DEBUG)\r
+#define EFI_SW_EC_IA32_NMI              (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_NMI)\r
+#define EFI_SW_EC_IA32_BREAKPOINT       (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BREAKPOINT)\r
+#define EFI_SW_EC_IA32_OVERFLOW         (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_OVERFLOW)\r
+#define EFI_SW_EC_IA32_BOUND            (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BOUND)\r
+#define EFI_SW_EC_IA32_INVALID_OPCODE   (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_OPCODE)\r
+#define EFI_SW_EC_IA32_DOUBLE_FAULT     (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DOUBLE_FAULT)\r
+#define EFI_SW_EC_IA32_INVALID_TSS      (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_TSS)\r
+#define EFI_SW_EC_IA32_SEG_NOT_PRESENT  (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SEG_NOT_PRESENT)\r
+#define EFI_SW_EC_IA32_STACK_FAULT      (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_STACK_FAULT)\r
+#define EFI_SW_EC_IA32_GP_FAULT         (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_GP_FAULT)\r
+#define EFI_SW_EC_IA32_PAGE_FAULT       (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_PAGE_FAULT)\r
+#define EFI_SW_EC_IA32_FP_ERROR         (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_FP_ERROR)\r
+#define EFI_SW_EC_IA32_ALIGNMENT_CHECK  (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_ALIGNMENT_CHECK)\r
+#define EFI_SW_EC_IA32_MACHINE_CHECK    (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_MACHINE_CHECK)\r
+#define EFI_SW_EC_IA32_SIMD             (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SIMD)\r
+\r
+//\r
+// Software Class X64 Exception Subclass Error Code definitions.\r
+// These exceptions are derived from the debug protocol definitions in the EFI\r
+// specification.\r
+//\r
+#define EFI_SW_EC_X64_DIVIDE_ERROR      (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DIVIDE_ERROR)\r
+#define EFI_SW_EC_X64_DEBUG             (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DEBUG)\r
+#define EFI_SW_EC_X64_NMI               (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_NMI)\r
+#define EFI_SW_EC_X64_BREAKPOINT        (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BREAKPOINT)\r
+#define EFI_SW_EC_X64_OVERFLOW          (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_OVERFLOW)\r
+#define EFI_SW_EC_X64_BOUND             (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BOUND)\r
+#define EFI_SW_EC_X64_INVALID_OPCODE    (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_OPCODE)\r
+#define EFI_SW_EC_X64_DOUBLE_FAULT      (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DOUBLE_FAULT)\r
+#define EFI_SW_EC_X64_INVALID_TSS       (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_TSS)\r
+#define EFI_SW_EC_X64_SEG_NOT_PRESENT   (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SEG_NOT_PRESENT)\r
+#define EFI_SW_EC_X64_STACK_FAULT       (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_STACK_FAULT)\r
+#define EFI_SW_EC_X64_GP_FAULT          (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_GP_FAULT)\r
+#define EFI_SW_EC_X64_PAGE_FAULT        (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_PAGE_FAULT)\r
+#define EFI_SW_EC_X64_FP_ERROR          (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_FP_ERROR)\r
+#define EFI_SW_EC_X64_ALIGNMENT_CHECK   (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_ALIGNMENT_CHECK)\r
+#define EFI_SW_EC_X64_MACHINE_CHECK     (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_MACHINE_CHECK)\r
+#define EFI_SW_EC_X64_SIMD              (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SIMD)\r
+\r
+//\r
+// Software Class IPF Exception Subclass Error Code definitions.\r
+// These exceptions are derived from the debug protocol definitions in the EFI\r
+// specification.\r
+//\r
+#define EFI_SW_EC_IPF_ALT_DTLB            (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_ALT_DTLB)\r
+#define EFI_SW_EC_IPF_DNESTED_TLB         (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DNESTED_TLB)\r
+#define EFI_SW_EC_IPF_BREAKPOINT          (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_BREAKPOINT)\r
+#define EFI_SW_EC_IPF_EXTERNAL_INTERRUPT  (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_EXTERNAL_INTERRUPT)\r
+#define EFI_SW_EC_IPF_GEN_EXCEPT          (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_GEN_EXCEPT)\r
+#define EFI_SW_EC_IPF_NAT_CONSUMPTION     (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_NAT_CONSUMPTION)\r
+#define EFI_SW_EC_IPF_DEBUG_EXCEPT        (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DEBUG_EXCEPT)\r
+#define EFI_SW_EC_IPF_UNALIGNED_ACCESS    (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_UNALIGNED_ACCESS)\r
+#define EFI_SW_EC_IPF_FP_FAULT            (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_FAULT)\r
+#define EFI_SW_EC_IPF_FP_TRAP             (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_TRAP)\r
+#define EFI_SW_EC_IPF_TAKEN_BRANCH        (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_TAKEN_BRANCH)\r
+#define EFI_SW_EC_IPF_SINGLE_STEP         (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_SINGLE_STEP)\r
+\r
+//\r
+// Software Class PEI Service Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI Boot Service Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI Runtime Service Subclass Error Code definitions.\r
+//\r
+//\r
+// Software Class EFI DXE Service Subclass Error Code definitions.\r
+//\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+// Section 7\r
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Debug Code definitions for all classes and subclass\r
+// Only one debug code is defined at this point and should\r
+// be used for anything that gets sent to debug stream.\r
+//\r
+#define EFI_DC_UNSPECIFIED  0x0\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h
new file mode 100644 (file)
index 0000000..fc6f532
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiVariable.h\r
+\r
+Abstract:\r
+\r
+  \r
+\r
+--*/\r
+\r
+#ifndef _EFI_VARIABLE_DEFINITION_H_\r
+#define _EFI_VARIABLE_DEFINITION_H_\r
+\r
+//\r
+// Variable attributes\r
+//\r
+#define EFI_VARIABLE_NON_VOLATILE       0x00000001\r
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002\r
+#define EFI_VARIABLE_RUNTIME_ACCESS     0x00000004\r
+#define EFI_VARIABLE_READ_ONLY          0x00000008\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h
new file mode 100644 (file)
index 0000000..e74e1f4
--- /dev/null
@@ -0,0 +1,615 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiApi.h\r
+\r
+Abstract:\r
+\r
+  Tiano PEI intrinsic definitions. This includes all Pei Services APIs.\r
+\r
+  Peims are passed in a pointer to a pointer to the PEI Services table.\r
+  The PEI Services table contains pointers to the PEI services exported\r
+  by the PEI Core.\r
+\r
+--*/\r
+\r
+#ifndef _PEI_API_H_\r
+#define _PEI_API_H_\r
+\r
+#include "PeiHob.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include EFI_PPI_DEFINITION (FirmwareVolumeInfo)\r
+#include EFI_PPI_DEFINITION (FirmwareVolume)\r
+#include EFI_PPI_DEFINITION (Decompress)\r
+\r
+\r
+//\r
+// Declare forward referenced data structures\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_PEI_NOTIFY_DESCRIPTOR);\r
+EFI_FORWARD_DECLARATION (EFI_PEI_SERVICES);\r
+\r
+#include EFI_PPI_DEFINITION (CpuIo)\r
+#include EFI_PPI_DEFINITION (PciCfg)\r
+#include EFI_PPI_DEFINITION (PciCfg2)\r
+\r
+//\r
+// PEI Specification Revision information\r
+//\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+#define PEI_SPECIFICATION_MAJOR_REVISION  0\r
+#define PEI_SPECIFICATION_MINOR_REVISION  91\r
+#else\r
+#define PEI_SPECIFICATION_MAJOR_REVISION  1\r
+#define PEI_SPECIFICATION_MINOR_REVISION  00\r
+\r
+#endif\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEIM_ENTRY_POINT)(\r
+  IN EFI_FFS_FILE_HEADER       * FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEIM_NOTIFY_ENTRY_POINT) (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  * NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_VERIFICATION) (\r
+  IN UINTN    SectionAddress\r
+  );\r
+\r
+//\r
+// PEI Ppi Services List Descriptors\r
+//\r
+#define EFI_PEI_PPI_DESCRIPTOR_PIC              0x00000001\r
+#define EFI_PEI_PPI_DESCRIPTOR_PPI              0x00000010\r
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK  0x00000020\r
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH  0x00000040\r
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES     0x00000060\r
+#define EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST   0x80000000\r
+\r
+typedef struct {\r
+  UINTN     Flags;\r
+  EFI_GUID  *Guid;\r
+  VOID      *Ppi;\r
+} EFI_PEI_PPI_DESCRIPTOR;\r
+\r
+typedef struct _EFI_PEI_NOTIFY_DESCRIPTOR {\r
+  UINTN                       Flags;\r
+  EFI_GUID                    *Guid;\r
+  EFI_PEIM_NOTIFY_ENTRY_POINT Notify;\r
+} EFI_PEI_NOTIFY_DESCRIPTOR;\r
+\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_REPORT_STATUS_CODE) (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  );\r
+\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+//\r
+// PEI PPI Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_INSTALL_PPI) (\r
+  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN  EFI_PEI_PPI_DESCRIPTOR      * PpiList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_REINSTALL_PPI) (\r
+  IN  EFI_PEI_SERVICES                **PeiServices,\r
+  IN  EFI_PEI_PPI_DESCRIPTOR          * OldPpi,\r
+  IN  EFI_PEI_PPI_DESCRIPTOR          * NewPpi\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_LOCATE_PPI) (\r
+  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN  EFI_GUID                    * Guid,\r
+  IN UINTN                        Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR   **PpiDescriptor,\r
+  IN OUT VOID                     **Ppi\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_NOTIFY_PPI) (\r
+  IN  EFI_PEI_SERVICES                **PeiServices,\r
+  IN  EFI_PEI_NOTIFY_DESCRIPTOR       * NotifyList\r
+  );\r
+\r
+//\r
+// PEI Boot Mode Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_BOOT_MODE) (\r
+  IN  EFI_PEI_SERVICES                 **PeiServices,\r
+  IN OUT EFI_BOOT_MODE                 * BootMode\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SET_BOOT_MODE) (\r
+  IN EFI_PEI_SERVICES                  **PeiServices,\r
+  IN EFI_BOOT_MODE                     BootMode\r
+  );\r
+\r
+//\r
+// PEI HOB Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_HOB_LIST) (\r
+  IN EFI_PEI_SERVICES                  **PeiServices,\r
+  IN OUT VOID                          **HobList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_CREATE_HOB) (\r
+  IN EFI_PEI_SERVICES                  **PeiServices,\r
+  IN UINT16                            Type,\r
+  IN UINT16                            Length,\r
+  IN OUT VOID                          **Hob\r
+  );\r
+\r
+ //\r
+ // PEI Firmware Volume Services\r
+ //\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME) (\r
+  IN EFI_PEI_SERVICES                **PeiServices,\r
+  IN UINTN                           Instance,\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER  **FwVolHeader\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE) (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_FV_FILETYPE             SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER  * FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA) (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_SECTION_TYPE            SectionType,\r
+  IN EFI_FFS_FILE_HEADER         * FfsFileHeader,\r
+  IN OUT VOID                    **SectionData\r
+  );\r
+\r
+//\r
+// PEI Memory Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_ALLOCATE_PAGES) (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   * Memory\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_ALLOCATE_POOL) (\r
+  IN EFI_PEI_SERVICES                **PeiServices,\r
+  IN UINTN                           Size,\r
+  OUT VOID                           **Buffer\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_PEI_COPY_MEM) (\r
+  IN VOID                       *Destination,\r
+  IN VOID                       *Source,\r
+  IN UINTN                      Length\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_PEI_SET_MEM) (\r
+  IN VOID                       *Buffer,\r
+  IN UINTN                      Size,\r
+  IN UINT8                      Value\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  );\r
+\r
+//\r
+// PEI Reset\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (\r
+  IN EFI_PEI_SERVICES   **PeiServices\r
+  );\r
+\r
+\r
+\r
+#else\r
+\r
+//\r
+// PEI PPI Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_INSTALL_PPI) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR      * PpiList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_REINSTALL_PPI) (\r
+  IN CONST EFI_PEI_SERVICES                **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR          * OldPpi,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR          * NewPpi\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_LOCATE_PPI) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN CONST EFI_GUID                    * Guid,\r
+  IN UINTN                             Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR        **PpiDescriptor OPTIONAL,\r
+  IN OUT VOID                          **Ppi\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_NOTIFY_PPI) (\r
+  IN CONST EFI_PEI_SERVICES                **PeiServices,\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR       * NotifyList\r
+  );\r
+\r
+//\r
+// PEI Boot Mode Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_BOOT_MODE) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN OUT EFI_BOOT_MODE                 * BootMode\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SET_BOOT_MODE) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_BOOT_MODE                     BootMode\r
+  );\r
+\r
+//\r
+// PEI HOB Services\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_HOB_LIST) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN OUT VOID                          **HobList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_CREATE_HOB) (\r
+  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN UINT16                            Type,\r
+  IN UINT16                            Length,\r
+  IN OUT VOID                          **Hob\r
+  );\r
+\r
+\r
+\r
+ //\r
+ // PEI Firmware Volume Services\r
+ //\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME2) (\r
+  IN CONST  EFI_PEI_SERVICES  **PeiServices,\r
+  IN UINTN                    Instance,\r
+  IN OUT EFI_PEI_FV_HANDLE    *VolumeHandle \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) (\r
+  IN CONST  EFI_PEI_SERVICES        **PeiServices,\r
+  IN EFI_FV_FILETYPE                SearchType,\r
+  IN CONST EFI_PEI_FV_HANDLE        *FwVolHeader,\r
+  IN OUT EFI_PEI_FILE_HANDLE        **FileHandle  \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) (\r
+  IN CONST  EFI_PEI_SERVICES    **PeiServices,\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_PEI_FILE_HANDLE        *FileHandle,\r
+  OUT VOID                      **SectionData\r
+  );\r
+\r
+  \r
+  //\r
+  // PEI Memory Services\r
+  //\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_ALLOCATE_PAGES) (\r
+\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   * Memory\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_ALLOCATE_POOL) (\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices,\r
+  IN UINTN                           Size,\r
+  OUT VOID                           **Buffer\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_PEI_COPY_MEM) (\r
+  IN VOID                       *Destination,\r
+  IN VOID                       *Source,\r
+  IN UINTN                      Length\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_PEI_SET_MEM) (\r
+  IN VOID                       *Buffer,\r
+  IN UINTN                      Size,\r
+  IN UINT8                      Value\r
+  );\r
+\r
+  //\r
+  // New interfaceas added by the PI 1.0\r
+  //\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_FIND_BY_NAME) (\r
+  IN  CONST EFI_GUID        *FileName,\r
+  IN  EFI_PEI_FV_HANDLE     VolumeHandle,\r
+  OUT EFI_PEI_FILE_HANDLE   *FileHandle\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_GET_FILE_INFO) (\r
+  IN  EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT EFI_FV_FILE_INFO      *FileInfo\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) (\r
+  IN  EFI_PEI_FV_HANDLE     *VolumeHandle,\r
+  OUT EFI_FV_INFO           *VolumeInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_REGISTER_FOR_SHADOW) (\r
+  IN EFI_PEI_FILE_HANDLE       FileHandle\r
+  );\r
+\r
+//\r
+// PEI Status Code Service\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (\r
+  IN EFI_PEI_SERVICES               **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE           Type,\r
+  IN EFI_STATUS_CODE_VALUE          Value,\r
+  IN UINT32                         Instance,\r
+  IN EFI_GUID                       *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA           *Data OPTIONAL\r
+  );\r
+\r
+//\r
+// PEI Reset Service\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (\r
+  IN EFI_PEI_SERVICES   **PeiServices\r
+  );\r
+\r
+#endif\r
+\r
+\r
+//\r
+// EFI PEI Services Table\r
+//\r
+#define PEI_SERVICES_SIGNATURE  0x5652455320494550\r
+#define PEI_SERVICES_REVISION   ((PEI_SPECIFICATION_MAJOR_REVISION << 16) | (PEI_SPECIFICATION_MINOR_REVISION))\r
+typedef PEI_CPU_IO_PPI          EFI_PEI_CPU_IO_PPI;\r
+\r
+\r
+typedef struct _EFI_PEI_SERVICES {\r
+  EFI_TABLE_HEADER              Hdr;\r
+\r
+  //\r
+  // PPI Functions\r
+  //\r
+  EFI_PEI_INSTALL_PPI           InstallPpi;\r
+  EFI_PEI_REINSTALL_PPI         ReInstallPpi;\r
+  EFI_PEI_LOCATE_PPI            LocatePpi;\r
+  EFI_PEI_NOTIFY_PPI            NotifyPpi;\r
+\r
+  //\r
+  // Boot Mode Functions\r
+  //\r
+  EFI_PEI_GET_BOOT_MODE         GetBootMode;\r
+  EFI_PEI_SET_BOOT_MODE         SetBootMode;\r
+\r
+  //\r
+  // HOB Functions\r
+  //\r
+  EFI_PEI_GET_HOB_LIST          GetHobList;\r
+  EFI_PEI_CREATE_HOB            CreateHob;\r
+\r
+  //\r
+  // Firmware Volume Functions\r
+  //\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  EFI_PEI_FFS_FIND_NEXT_VOLUME  FfsFindNextVolume;\r
+  EFI_PEI_FFS_FIND_NEXT_FILE    FfsFindNextFile;\r
+  EFI_PEI_FFS_FIND_SECTION_DATA FfsFindSectionData;\r
+#else\r
+  EFI_PEI_FFS_FIND_NEXT_VOLUME2  FfsFindNextVolume;\r
+  EFI_PEI_FFS_FIND_NEXT_FILE2    FfsFindNextFile;\r
+  EFI_PEI_FFS_FIND_SECTION_DATA2 FfsFindSectionData;\r
+#endif\r
+  //\r
+  // PEI Memory Functions\r
+  //\r
+  EFI_PEI_INSTALL_PEI_MEMORY    InstallPeiMemory;\r
+  EFI_PEI_ALLOCATE_PAGES        AllocatePages;\r
+  EFI_PEI_ALLOCATE_POOL         AllocatePool;\r
+  EFI_PEI_COPY_MEM              CopyMem;\r
+  EFI_PEI_SET_MEM               SetMem;\r
+\r
+  //\r
+  // Status Code\r
+  //\r
+  EFI_PEI_REPORT_STATUS_CODE    PeiReportStatusCode;\r
+\r
+  //\r
+  // Reset\r
+  //\r
+  EFI_PEI_RESET_SYSTEM          PeiResetSystem;\r
+\r
+  //\r
+  // Pointer to PPI interface\r
+  //\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+  PEI_CPU_IO_PPI                 *CpuIo;\r
+  PEI_PCI_CFG_PPI                *PciCfg;\r
+#else\r
+  EFI_PEI_CPU_IO_PPI             *CpuIo;\r
+  EFI_PEI_PCI_CFG2_PPI           *PciCfg;\r
+\r
+  //\r
+  // New interfaceas added by the PI 1.0\r
+  //\r
+  EFI_PEI_FFS_FIND_BY_NAME        FfsFindFileByName;\r
+  EFI_PEI_FFS_GET_FILE_INFO       FfsGetFileInfo;\r
+  EFI_PEI_FFS_GET_VOLUME_INFO     FfsGetVolumeInfo;\r
+  EFI_PEI_REGISTER_FOR_SHADOW     RegisterForShadow;\r
+#endif\r
+\r
+} EFI_PEI_SERVICES;\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+typedef struct {\r
+  UINTN                   BootFirmwareVolume;\r
+  UINTN                   SizeOfCacheAsRam;\r
+  EFI_PEI_PPI_DESCRIPTOR  *DispatchTable;\r
+} EFI_PEI_STARTUP_DESCRIPTOR;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_MAIN_ENTRY_POINT) (\r
+    IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor\r
+  );\r
+\r
+#else\r
+\r
+typedef struct _EFI_SEC_PEI_HAND_OFF{\r
+  UINT16  DataSize;\r
+  VOID    *BootFirmwareVolumeBase;\r
+  UINTN   BootFirmwareVolumeSize;\r
+  VOID    *TemporaryRamBase;\r
+  UINTN   TemporaryRamSize;\r
+  VOID    *PeiTemporaryRamBase;\r
+  UINTN   PeiTemporaryRamSize;\r
+  VOID    *StackBase;\r
+  UINTN   StackSize;\r
+}EFI_SEC_PEI_HAND_OFF;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_MAIN_ENTRY_POINT) (\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList\r
+  );\r
+\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h
new file mode 100644 (file)
index 0000000..abddea7
--- /dev/null
@@ -0,0 +1,251 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiHob.h\r
+\r
+Abstract:\r
+\r
+  PEI Hand Off Block (HOB) definition.\r
+\r
+  The HOB is a memory data structure used to hand-off system information from\r
+  PEI to DXE (the next phase).\r
+\r
+--*/\r
+\r
+#ifndef _PEI_HOB_H_\r
+#define _PEI_HOB_H_\r
+\r
+#include "BootMode.h"\r
+\r
+//\r
+// Every Hob must start with this data structure.\r
+//\r
+typedef struct {\r
+  UINT16  HobType;\r
+  UINT16  HobLength;\r
+  UINT32  Reserved;\r
+} EFI_HOB_GENERIC_HEADER;\r
+\r
+//\r
+// End of HOB List HOB\r
+//\r
+#define EFI_HOB_TYPE_END_OF_HOB_LIST  0xffff\r
+\r
+//\r
+// Handoff Information Table HOB\r
+//\r
+#define EFI_HOB_TYPE_HANDOFF          0x0001\r
+\r
+#define EFI_HOB_HANDOFF_TABLE_VERSION 0x0009\r
+\r
+typedef UINT32  EFI_BOOT_MODE;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  UINT32                  Version;\r
+  EFI_BOOT_MODE           BootMode;\r
+  EFI_PHYSICAL_ADDRESS    EfiMemoryTop;\r
+  EFI_PHYSICAL_ADDRESS    EfiMemoryBottom;\r
+  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryTop;\r
+  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryBottom;\r
+  EFI_PHYSICAL_ADDRESS    EfiEndOfHobList;\r
+} EFI_HOB_HANDOFF_INFO_TABLE;\r
+\r
+//\r
+// Memory Descriptor HOB\r
+//\r
+#define EFI_HOB_TYPE_MEMORY_ALLOCATION  0x0002\r
+\r
+typedef struct {\r
+  EFI_GUID              Name;\r
+  EFI_PHYSICAL_ADDRESS  MemoryBaseAddress;\r
+  UINT64                MemoryLength;\r
+  EFI_MEMORY_TYPE       MemoryType;\r
+  UINT8                 Reserved[4];\r
+} EFI_HOB_MEMORY_ALLOCATION_HEADER;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER            Header;\r
+  EFI_HOB_MEMORY_ALLOCATION_HEADER  AllocDescriptor;\r
+  //\r
+  // Additional data pertaining to the "Name" Guid memory\r
+  // may go here.\r
+  //\r
+} EFI_HOB_MEMORY_ALLOCATION;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER            Header;\r
+  EFI_HOB_MEMORY_ALLOCATION_HEADER  AllocDescriptor;\r
+} EFI_HOB_MEMORY_ALLOCATION_BSP_STORE;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER            Header;\r
+  EFI_HOB_MEMORY_ALLOCATION_HEADER  AllocDescriptor;\r
+} EFI_HOB_MEMORY_ALLOCATION_STACK;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER            Header;\r
+  EFI_HOB_MEMORY_ALLOCATION_HEADER  MemoryAllocationHeader;\r
+  EFI_GUID                          ModuleName;\r
+  EFI_PHYSICAL_ADDRESS              EntryPoint;\r
+} EFI_HOB_MEMORY_ALLOCATION_MODULE;\r
+\r
+#define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR  0x0003\r
+\r
+typedef UINT32  EFI_RESOURCE_TYPE;\r
+\r
+#define EFI_RESOURCE_SYSTEM_MEMORY          0\r
+#define EFI_RESOURCE_MEMORY_MAPPED_IO       1\r
+#define EFI_RESOURCE_IO                     2\r
+#define EFI_RESOURCE_FIRMWARE_DEVICE        3\r
+#define EFI_RESOURCE_MEMORY_MAPPED_IO_PORT  4\r
+#define EFI_RESOURCE_MEMORY_RESERVED        5\r
+#define EFI_RESOURCE_IO_RESERVED            6\r
+#define EFI_RESOURCE_MAX_MEMORY_TYPE        7\r
+\r
+typedef UINT32  EFI_RESOURCE_ATTRIBUTE_TYPE;\r
+\r
+#define EFI_RESOURCE_ATTRIBUTE_PRESENT                  0x00000001\r
+#define EFI_RESOURCE_ATTRIBUTE_INITIALIZED              0x00000002\r
+#define EFI_RESOURCE_ATTRIBUTE_TESTED                   0x00000004\r
+#define EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC           0x00000008\r
+#define EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC         0x00000010\r
+#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1           0x00000020\r
+#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2           0x00000040\r
+#define EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED           0x00000080\r
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED          0x00000100\r
+#define EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED      0x00000200\r
+#define EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE              0x00000400\r
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE        0x00000800\r
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE  0x00001000\r
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE     0x00002000\r
+#define EFI_RESOURCE_ATTRIBUTE_16_BIT_IO                0x00004000\r
+#define EFI_RESOURCE_ATTRIBUTE_32_BIT_IO                0x00008000\r
+#define EFI_RESOURCE_ATTRIBUTE_64_BIT_IO                0x00010000\r
+#define EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED        0x00020000\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER      Header;\r
+  EFI_GUID                    Owner;\r
+  EFI_RESOURCE_TYPE           ResourceType;\r
+  EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute;\r
+  EFI_PHYSICAL_ADDRESS        PhysicalStart;\r
+  UINT64                      ResourceLength;\r
+} EFI_HOB_RESOURCE_DESCRIPTOR;\r
+\r
+//\r
+// GUID Extension HOB\r
+// The HobLength is variable as it includes the GUID specific data.\r
+//\r
+#define EFI_HOB_TYPE_GUID_EXTENSION 0x0004\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  EFI_GUID                Name;\r
+\r
+  //\r
+  // Guid specific data goes here\r
+  //\r
+} EFI_HOB_GUID_TYPE;\r
+\r
+//\r
+// Firmware Volume HOB\r
+//\r
+#define EFI_HOB_TYPE_FV 0x0005\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+  UINT64                  Length;\r
+} EFI_HOB_FIRMWARE_VOLUME;\r
+\r
+//\r
+// CPU HOB\r
+//\r
+#define EFI_HOB_TYPE_CPU  0x0006\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  UINT8                   SizeOfMemorySpace;\r
+  UINT8                   SizeOfIoSpace;\r
+  UINT8                   Reserved[6];\r
+} EFI_HOB_CPU;\r
+\r
+//\r
+// PEI Core Memory Pool HOB\r
+// The HobLength is variable as the HOB contains pool allocations by\r
+// the PeiServices AllocatePool function\r
+//\r
+#define EFI_HOB_TYPE_PEI_MEMORY_POOL  0x0007\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+} EFI_HOB_MEMORY_POOL;\r
+\r
+//\r
+// Capsule volume HOB -- identical to a firmware volume\r
+//\r
+#define EFI_HOB_TYPE_CV 0x0008\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+  UINT64                  Length;\r
+} EFI_HOB_CAPSULE_VOLUME;\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+#define EFI_HOB_TYPE_FV2    0x0009\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+  UINT64                  Length;\r
+  EFI_GUID                FvName;\r
+  EFI_GUID                FileName;\r
+} EFI_HOB_FIRMWARE_VOLUME2;\r
+\r
+#define EFI_HOB_TYPE_LOAD_PEIM            0x000A\r
+\r
+#endif\r
+\r
+#define EFI_HOB_TYPE_UNUSED 0xFFFE\r
+\r
+//\r
+// Union of all the possible HOB Types\r
+//\r
+typedef union {\r
+  EFI_HOB_GENERIC_HEADER              *Header;\r
+  EFI_HOB_HANDOFF_INFO_TABLE          *HandoffInformationTable;\r
+  EFI_HOB_MEMORY_ALLOCATION           *MemoryAllocation;\r
+  EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *MemoryAllocationBspStore;\r
+  EFI_HOB_MEMORY_ALLOCATION_STACK     *MemoryAllocationStack;\r
+  EFI_HOB_MEMORY_ALLOCATION_MODULE    *MemoryAllocationModule;\r
+  EFI_HOB_RESOURCE_DESCRIPTOR         *ResourceDescriptor;\r
+  EFI_HOB_GUID_TYPE                   *Guid;\r
+  EFI_HOB_FIRMWARE_VOLUME             *FirmwareVolume;\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+  EFI_HOB_FIRMWARE_VOLUME2            *FirmwareVolume2;\r
+#endif\r
+  EFI_HOB_CPU                         *Cpu;\r
+  EFI_HOB_MEMORY_POOL                 *Pool;\r
+  EFI_HOB_CAPSULE_VOLUME              *CapsuleVolume;\r
+  UINT8                               *Raw;\r
+} EFI_PEI_HOB_POINTERS;\r
+\r
+#define GET_HOB_TYPE(Hob)     ((Hob).Header->HobType)\r
+#define GET_HOB_LENGTH(Hob)   ((Hob).Header->HobLength)\r
+#define GET_NEXT_HOB(Hob)     ((Hob).Raw + GET_HOB_LENGTH (Hob))\r
+#define END_OF_HOB_LIST(Hob)  (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h
new file mode 100644 (file)
index 0000000..5850075
--- /dev/null
@@ -0,0 +1,589 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoSpecApi.h\r
+\r
+Abstract:\r
+\r
+  Tiano intrinsic definitions in Tiano spec.\r
+\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_SPEC_API_H_\r
+#define _TIANO_SPEC_API_H_\r
+\r
+\r
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
+//\r
+// Prior to UEFI 2.0 Tiano extended these enums. This was replaced by\r
+// CreateEventEx() Event Groups in UEFI 2.0\r
+//\r
+#define EFI_EVENT_NOTIFY_SIGNAL_ALL     0x00000400\r
+\r
+#define EFI_EVENT_SIGNAL_READY_TO_BOOT  0x00000203\r
+#define EFI_EVENT_SIGNAL_LEGACY_BOOT    0x00000204\r
+#endif\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ADD_MEMORY_SPACE) (\r
+  IN EFI_GCD_MEMORY_TYPE   GcdMemoryType,\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length,\r
+  IN UINT64                Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Adds reserved memory, system memory, or memory-mapped I/O resources to the\r
+global coherency domain of the processor.\r
+\r
+Arguments:\r
+    \r
+  GcdMemoryType     - Memory type of the memory space.\r
+  \r
+  BaseAddress       - Base address of the memory space.\r
+  \r
+  Length            - Length of the memory space.\r
+  \r
+  Capabilities      - alterable attributes of the memory space.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - Merged this memory space into GCD map.  \r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ALLOCATE_MEMORY_SPACE) (\r
+  IN     EFI_GCD_ALLOCATE_TYPE               GcdAllocateType,\r
+  IN     EFI_GCD_MEMORY_TYPE                 GcdMemoryType,\r
+  IN     UINTN                               Alignment,\r
+  IN     UINT64                              Length,\r
+  IN OUT EFI_PHYSICAL_ADDRESS                * BaseAddress,\r
+  IN     EFI_HANDLE                          ImageHandle,\r
+  IN     EFI_HANDLE                          DeviceHandle OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocates nonexistent memory, reserved memory, system memory, or memorymapped\r
+I/O resources from the global coherency domain of the processor.\r
+\r
+Arguments:\r
+  \r
+  GcdAllocateType   - The type of allocate operation\r
+  \r
+  GcdMemoryType     - The desired memory type\r
+  \r
+  Alignment         - Align with 2^Alignment\r
+  \r
+  Length            - Length to allocate\r
+  \r
+  BaseAddress       - Base address to allocate\r
+  \r
+  Imagehandle       - The image handle consume the allocated space.\r
+  \r
+  DeviceHandle      - The device handle consume the allocated space.\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER       - Invalid parameter.\r
+  \r
+  EFI_NOT_FOUND               - No descriptor contains the desired space.\r
+  \r
+  EFI_SUCCESS                 - Memory space successfully allocated.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_FREE_MEMORY_SPACE) (\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length\r
+  )\r
+/*++\r
+\r
+Routine Description:Routine Description:\r
+\r
+  Frees nonexistent memory, reserved memory, system memory, or memory-mapped\r
+I/O resources from the global coherency domain of the processor.\r
+\r
+Arguments:\r
+    \r
+  BaseAddress       - Base address of the segment.\r
+  \r
+  Length            - Length of the segment.\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Space successfully freed.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_REMOVE_MEMORY_SPACE) (\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length\r
+  )\r
+/*++\r
+\r
+Routine Description:Routine Description:\r
+\r
+  Removes reserved memory, system memory, or memory-mapped I/O resources from\r
+the global coherency domain of the processor.\r
+\r
+Arguments:\r
+    \r
+  BaseAddress       - Base address of the memory space.\r
+  \r
+  Length            - Length of the memory space.\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Successfully remove a segment of memory space.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_MEMORY_SPACE_DESCRIPTOR) (\r
+  IN  EFI_PHYSICAL_ADDRESS             BaseAddress,\r
+  OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR  * Descriptor\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the descriptor for a memory region containing a specified address.\r
+\r
+Arguments:\r
+\r
+  BaseAddress       - Specified start address\r
+  \r
+  Descriptor        - Specified length\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER       - Invalid parameter\r
+  \r
+  EFI_SUCCESS                 - Successfully get memory space descriptor.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_MEMORY_SPACE_ATTRIBUTES) (\r
+  IN EFI_PHYSICAL_ADDRESS         BaseAddress,\r
+  IN UINT64                       Length,\r
+  IN UINT64                       Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Modifies the attributes for a memory region in the global coherency domain of the\r
+processor.\r
+\r
+Arguments:\r
+\r
+  BaseAddress       - Specified start address\r
+  \r
+  Length            - Specified length\r
+  \r
+  Attributes        - Specified attributes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - Successfully set attribute of a segment of memory space.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_MEMORY_SPACE_MAP) (\r
+  OUT UINTN                            *NumberOfDescriptors,\r
+  OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR  **MemorySpaceMap\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns a map of the memory resources in the global coherency domain of the\r
+processor.\r
+\r
+Arguments:\r
+\r
+  NumberOfDescriptors       - Number of descriptors.\r
+  \r
+  MemorySpaceMap            - Descriptor array\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER     - Invalid parameter\r
+  \r
+  EFI_OUT_OF_RESOURCES      - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS               - Successfully get memory space map.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ADD_IO_SPACE) (\r
+  IN EFI_GCD_IO_TYPE       GcdIoType,\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Adds reserved I/O or I/O resources to the global coherency domain of the processor.\r
+\r
+Arguments:\r
+    \r
+  GcdIoType         - IO type of the segment.\r
+  \r
+  BaseAddress       - Base address of the segment.\r
+  \r
+  Length            - Length of the segment.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - Merged this segment into GCD map.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_ALLOCATE_IO_SPACE) (\r
+  IN     EFI_GCD_ALLOCATE_TYPE               GcdAllocateType,\r
+  IN     EFI_GCD_IO_TYPE                     GcdIoType,\r
+  IN     UINTN                               Alignment,\r
+  IN     UINT64                              Length,\r
+  IN OUT EFI_PHYSICAL_ADDRESS                * BaseAddress,\r
+  IN     EFI_HANDLE                          ImageHandle,\r
+  IN     EFI_HANDLE                          DeviceHandle OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
+domain of the processor.\r
+\r
+Arguments:\r
+  \r
+  GcdAllocateType   - The type of allocate operation\r
+  \r
+  GcdIoType         - The desired IO type\r
+  \r
+  Alignment         - Align with 2^Alignment\r
+  \r
+  Length            - Length to allocate\r
+  \r
+  BaseAddress       - Base address to allocate\r
+  \r
+  Imagehandle       - The image handle consume the allocated space.\r
+  \r
+  DeviceHandle      - The device handle consume the allocated space.\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER       - Invalid parameter.\r
+  \r
+  EFI_NOT_FOUND               - No descriptor contains the desired space.\r
+  \r
+  EFI_SUCCESS                 - IO space successfully allocated.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_FREE_IO_SPACE) (\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length\r
+  )\r
+/*++\r
+\r
+Routine Description:Routine Description:\r
+\r
+  Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
+domain of the processor.\r
+\r
+Arguments:\r
+    \r
+  BaseAddress       - Base address of the segment.\r
+  \r
+  Length            - Length of the segment.\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Space successfully freed.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_REMOVE_IO_SPACE) (\r
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINT64                Length\r
+  )\r
+/*++\r
+\r
+Routine Description:Routine Description:\r
+\r
+  Removes reserved I/O or I/O resources from the global coherency domain of the\r
+processor.\r
+\r
+Arguments:\r
+    \r
+  BaseAddress       - Base address of the segment.\r
+  \r
+  Length            - Length of the segment.\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Successfully removed a segment of IO space.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_IO_SPACE_DESCRIPTOR) (\r
+  IN  EFI_PHYSICAL_ADDRESS         BaseAddress,\r
+  OUT EFI_GCD_IO_SPACE_DESCRIPTOR  * Descriptor\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the descriptor for an I/O region containing a specified address.\r
+\r
+Arguments:\r
+\r
+  BaseAddress       - Specified start address\r
+  \r
+  Descriptor        - Specified length\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER       - Descriptor is NULL.\r
+  \r
+  EFI_SUCCESS                 - Successfully get the IO space descriptor.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_IO_SPACE_MAP) (\r
+  OUT UINTN                        *NumberOfDescriptors,\r
+  OUT EFI_GCD_IO_SPACE_DESCRIPTOR  **IoSpaceMap\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns a map of the I/O resources in the global coherency domain of the processor.\r
+\r
+Arguments:\r
+\r
+  NumberOfDescriptors       - Number of descriptors.\r
+  \r
+  MemorySpaceMap            - Descriptor array\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER     - Invalid parameter\r
+  \r
+  EFI_OUT_OF_RESOURCES      - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS               - Successfully get IO space map.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISPATCH) (VOID)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Loads and executed DXE drivers from firmware volumes.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_SCHEDULE) (\r
+  IN EFI_HANDLE  FirmwareVolumeHandle,\r
+  IN EFI_GUID    * DriverName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Clears the Schedule on Request (SOR) flag for a component that is stored in a firmware volume.\r
+\r
+Arguments:\r
+\r
+  FirmwareVolumeHandle  - The handle of the firmware volume that contains the file specified by FileName.\r
+\r
+  DriverName            - A pointer to the name of the file in a firmware volume. \r
+  \r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_TRUST) (\r
+  IN EFI_HANDLE  FirmwareVolumeHandle,\r
+  IN EFI_GUID    * DriverName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Promotes a file stored in a firmware volume from the untrusted to the trusted state.\r
+\r
+Arguments:\r
+\r
+  FirmwareVolumeHandle  - The handle of the firmware volume that contains the file specified by FileName.\r
+\r
+  DriverName            - A pointer to the name of the file in a firmware volume. \r
+  \r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_BOOTSERVICE\r
+EFI_STATUS\r
+(EFIAPI *EFI_PROCESS_FIRMWARE_VOLUME) (\r
+  IN VOID                             *FvHeader,\r
+  IN UINTN                            Size,\r
+  OUT EFI_HANDLE                      * FirmwareVolumeHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Creates a firmware volume handle for a firmware volume that is present in system memory.\r
+\r
+Arguments:\r
+\r
+  FirmwareVolumeHeader    - A pointer to the header of the firmware volume.\r
+  Size                    - The size, in bytes, of the firmware volume.\r
+  FirmwareVolumeHandle    - On output, a pointer to the created handle.\r
+  \r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// DXE Services Table\r
+//\r
+#define EFI_DXE_SERVICES_SIGNATURE  0x565245535f455844\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+#define EFI_DXE_SERVICES_REVISION   ((0 << 16) | (90))\r
+#else\r
+#define EFI_DXE_SERVICES_REVISION   ((1 << 16) | (00))\r
+#endif\r
+\r
+typedef struct {\r
+  EFI_TABLE_HEADER                Hdr;\r
+\r
+  //\r
+  // Global Coherency Domain Services\r
+  //\r
+  EFI_ADD_MEMORY_SPACE            AddMemorySpace;\r
+  EFI_ALLOCATE_MEMORY_SPACE       AllocateMemorySpace;\r
+  EFI_FREE_MEMORY_SPACE           FreeMemorySpace;\r
+  EFI_REMOVE_MEMORY_SPACE         RemoveMemorySpace;\r
+  EFI_GET_MEMORY_SPACE_DESCRIPTOR GetMemorySpaceDescriptor;\r
+  EFI_SET_MEMORY_SPACE_ATTRIBUTES SetMemorySpaceAttributes;\r
+  EFI_GET_MEMORY_SPACE_MAP        GetMemorySpaceMap;\r
+  EFI_ADD_IO_SPACE                AddIoSpace;\r
+  EFI_ALLOCATE_IO_SPACE           AllocateIoSpace;\r
+  EFI_FREE_IO_SPACE               FreeIoSpace;\r
+  EFI_REMOVE_IO_SPACE             RemoveIoSpace;\r
+  EFI_GET_IO_SPACE_DESCRIPTOR     GetIoSpaceDescriptor;\r
+  EFI_GET_IO_SPACE_MAP            GetIoSpaceMap;\r
+\r
+  //\r
+  // Dispatcher Services\r
+  //\r
+  EFI_DISPATCH                    Dispatch;\r
+  EFI_SCHEDULE                    Schedule;\r
+  EFI_TRUST                       Trust;\r
+  //\r
+  // Service to process a single firmware volume found in a capsule\r
+  //\r
+  EFI_PROCESS_FIRMWARE_VOLUME     ProcessFirmwareVolume;\r
+} EFI_DXE_SERVICES;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h
new file mode 100644 (file)
index 0000000..a2f45a4
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoSpecDevicePath.h\r
+\r
+Abstract:\r
+\r
+  Tiano Device Path definitions in Tiano Spec.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_SPEC_DEVICE_PATH_H\r
+#define _TIANO_SPEC_DEVICE_PATH_H\r
+\r
+#pragma pack(1)\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+//\r
+// EFI Specification extension on Media Device Path\r
+//\r
+#define MEDIA_FV_FILEPATH_DP  0x06\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  NameGuid;\r
+} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;\r
+#endif\r
+\r
+\r
+#if (EFI_SPECIFICATION_VERSION == 0x00020000)\r
+//\r
+// For UEFI 2.0, use GUIDed PIWG device path to work-around EFI Specification extension on Media Device Path\r
+//\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  PiwgSpecificDevicePath;\r
+  UINT32                    Type;\r
+} PIWG_DEVICE_PATH;\r
+\r
+#define PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE         0x01\r
+typedef struct {\r
+  PIWG_DEVICE_PATH      Piwg;\r
+  EFI_GUID              NameGuid;\r
+} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;\r
+\r
+//\r
+// Place holder for a future extension\r
+//\r
+#define PIWG_MEDIA_FW_VOL_DEVICE_PATH_TYPE                  0x02\r
+typedef struct {\r
+  PIWG_DEVICE_PATH      Piwg;\r
+  EFI_GUID              VolumeGuid;\r
+} MEDIA_FW_VOL_DEVICE_PATH;\r
+#endif\r
+\r
+#if (EFI_SPECIFICATION_VERSION > 0x00020000)\r
+//\r
+// EFI Specification extension on Media Device Path was added to UEFI 2.1 specification,\r
+// so the definition is moved to EfiDevicePath.h\r
+//\r
+#endif\r
+\r
+#pragma pack()\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h
new file mode 100644 (file)
index 0000000..4836462
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoSpecError.h\r
+\r
+Abstract:\r
+\r
+  Tiano error codes defined in Tiano spec.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_SPEC_ERROR_H_\r
+#define _TIANO_SPEC_ERROR_H_\r
+\r
+#include "EfiBind.h"\r
+#define TIANO_ERROR(a)          (MAX_2_BITS | (a))\r
+\r
+//\r
+// Tiano added a couple of return types. These are owned by UEFI specification\r
+// and Tiano can not use them. Thus for UEFI 2.0/R8.6 support we moved the values\r
+// to a UEFI OEM extension range to conform to UEFI specification.\r
+//\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+  #define EFI_NOT_AVAILABLE_YET   EFIERR (28)\r
+  #define EFI_UNLOAD_IMAGE        EFIERR (29)\r
+#else\r
+  #define EFI_NOT_AVAILABLE_YET   TIANO_ERROR (0)\r
+  #define EFI_UNLOAD_IMAGE        TIANO_ERROR (1)\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h
new file mode 100644 (file)
index 0000000..5fdcf26
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoSpecTypes.h\r
+\r
+Abstract:\r
+\r
+  Tiano types defined in Tiano spec.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_SPEC_TYPES_H_\r
+#define _TIANO_SPEC_TYPES_H_\r
+\r
+//\r
+// Modifier for EFI DXE Services\r
+//\r
+#define EFI_DXESERVICE\r
+\r
+//\r
+// Global Coherencey Domain types\r
+//\r
+typedef enum {\r
+  EfiGcdMemoryTypeNonExistent,\r
+  EfiGcdMemoryTypeReserved,\r
+  EfiGcdMemoryTypeSystemMemory,\r
+  EfiGcdMemoryTypeMemoryMappedIo,\r
+  EfiGcdMemoryTypeMaximum\r
+} EFI_GCD_MEMORY_TYPE;\r
+\r
+typedef enum {\r
+  EfiGcdIoTypeNonExistent,\r
+  EfiGcdIoTypeReserved,\r
+  EfiGcdIoTypeIo,\r
+  EfiGcdIoTypeMaximum\r
+} EFI_GCD_IO_TYPE;\r
+\r
+typedef enum {\r
+  EfiGcdAllocateAnySearchBottomUp,\r
+  EfiGcdAllocateMaxAddressSearchBottomUp,\r
+  EfiGcdAllocateAddress,\r
+  EfiGcdAllocateAnySearchTopDown,\r
+  EfiGcdAllocateMaxAddressSearchTopDown,\r
+  EfiGcdMaxAllocateType\r
+} EFI_GCD_ALLOCATE_TYPE;\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  BaseAddress;\r
+  UINT64                Length;\r
+  UINT64                Capabilities;\r
+  UINT64                Attributes;\r
+  EFI_GCD_MEMORY_TYPE   GcdMemoryType;\r
+  EFI_HANDLE            ImageHandle;\r
+  EFI_HANDLE            DeviceHandle;\r
+} EFI_GCD_MEMORY_SPACE_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  BaseAddress;\r
+  UINT64                Length;\r
+  EFI_GCD_IO_TYPE       GcdIoType;\r
+  EFI_HANDLE            ImageHandle;\r
+  EFI_HANDLE            DeviceHandle;\r
+} EFI_GCD_IO_SPACE_DESCRIPTOR;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c
new file mode 100644 (file)
index 0000000..40b7654
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  BlockIo.c\r
+\r
+Abstract:\r
+\r
+  BlockIo PPI GUID as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (BlockIo)\r
+\r
+EFI_GUID  gPeiBlockIoPpiGuid = PEI_BLOCK_IO_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiBlockIoPpiGuid, "BlockIo", "PEI Block I/O PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h
new file mode 100644 (file)
index 0000000..5433edb
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  BlockIo.h\r
+\r
+Abstract:\r
+\r
+  BlockIo PPI as defined in EFI 2.0\r
+\r
+  Used to access block-oriented storage devices\r
+\r
+--*/\r
+\r
+#ifndef _PEI_BLOCK_IO_H_\r
+#define _PEI_BLOCK_IO_H_\r
+\r
+#define PEI_BLOCK_IO_PPI_GUID \\r
+  { \\r
+    0x695d8aa1, 0x42ee, 0x4c46, 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_RECOVERY_BLOCK_IO_INTERFACE);\r
+\r
+typedef UINT64  PEI_LBA;\r
+\r
+typedef enum {\r
+  LegacyFloppy  = 0,\r
+  IdeCDROM      = 1,\r
+  IdeLS120      = 2,\r
+  UsbMassStorage= 3,\r
+  MaxDeviceType\r
+} PEI_BLOCK_DEVICE_TYPE;\r
+\r
+typedef struct {\r
+  PEI_BLOCK_DEVICE_TYPE DeviceType;\r
+  BOOLEAN               MediaPresent;\r
+  UINTN                 LastBlock;\r
+  UINTN                 BlockSize;\r
+} PEI_BLOCK_IO_MEDIA;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_GET_NUMBER_BLOCK_DEVICES) (\r
+  IN  EFI_PEI_SERVICES                         **PeiServices,\r
+  IN PEI_RECOVERY_BLOCK_IO_INTERFACE           * This,\r
+  OUT UINTN                                    *NumberBlockDevices\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_GET_DEVICE_MEDIA_INFORMATION) (\r
+  IN  EFI_PEI_SERVICES                         **PeiServices,\r
+  IN PEI_RECOVERY_BLOCK_IO_INTERFACE           * This,\r
+  IN UINTN                                     DeviceIndex,\r
+  OUT PEI_BLOCK_IO_MEDIA                       * MediaInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_READ_BLOCKS) (\r
+  IN  EFI_PEI_SERVICES                         **PeiServices,\r
+  IN PEI_RECOVERY_BLOCK_IO_INTERFACE           * This,\r
+  IN UINTN                                     DeviceIndex,\r
+  IN PEI_LBA                                   StartLBA,\r
+  IN UINTN                                     BufferSize,\r
+  OUT VOID                                     *Buffer\r
+  );\r
+\r
+typedef struct _PEI_RECOVERY_BLOCK_IO_INTERFACE {\r
+  PEI_GET_NUMBER_BLOCK_DEVICES      GetNumberOfBlockDevices;\r
+  PEI_GET_DEVICE_MEDIA_INFORMATION  GetBlockDeviceMediaInfo;\r
+  PEI_READ_BLOCKS                   ReadBlocks;\r
+} PEI_RECOVERY_BLOCK_IO_INTERFACE;\r
+\r
+extern EFI_GUID gPeiBlockIoPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c
new file mode 100644 (file)
index 0000000..fad0db7
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootInRecoveryMode.c\r
+\r
+Abstract:\r
+\r
+  Boot Mode PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (BootInRecoveryMode)\r
+\r
+EFI_GUID  gPeiBootInRecoveryModePpiGuid = PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI;\r
+\r
+EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h
new file mode 100644 (file)
index 0000000..d601cb5
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootInRecoveryMode.h\r
+    \r
+Abstract:\r
+\r
+  Boot Mode PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_BOOT_IN_RECOVERY_MODE_PPI_H\r
+#define _PEI_BOOT_IN_RECOVERY_MODE_PPI_H\r
+\r
+#define PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI \\r
+  { \\r
+    0x17ee496a, 0xd8e4, 0x4b9a, 0x94, 0xd1, 0xce, 0x82, 0x72, 0x30, 0x8, 0x50 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_BOOT_IN_RECOVERY_MODE_PPI);\r
+\r
+extern EFI_GUID gPeiBootInRecoveryModePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c
new file mode 100644 (file)
index 0000000..8fa4345
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMode.c\r
+\r
+Abstract:\r
+\r
+  Boot Mode PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (BootMode)\r
+\r
+EFI_GUID  gPeiMasterBootModePpiGuid = PEI_MASTER_BOOT_MODE_PEIM_PPI;\r
+\r
+EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h
new file mode 100644 (file)
index 0000000..e0cf8de
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMode.h\r
+    \r
+Abstract:\r
+\r
+  Boot Mode PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_MASTER_BOOT_MODE_PPI_H\r
+#define _PEI_MASTER_BOOT_MODE_PPI_H\r
+\r
+#define PEI_MASTER_BOOT_MODE_PEIM_PPI \\r
+  { \\r
+    0x7408d748, 0xfc8c, 0x4ee6, 0x92, 0x88, 0xc4, 0xbe, 0xc0, 0x92, 0xa4, 0x10 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI);\r
+\r
+extern EFI_GUID gPeiMasterBootModePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c
new file mode 100644 (file)
index 0000000..690330a
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2001 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  BootScriptExecuter.c\r
+\r
+Abstract:\r
+\r
+  Boot Script Executer PPI GUID as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (BootScriptExecuter)\r
+\r
+EFI_GUID  gPeiBootScriptExecuterPpiGuid = PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiBootScriptExecuterPpiGuid, "BootScriptExecuter", "Boot Script Executer PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h
new file mode 100644 (file)
index 0000000..3dd29ce
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2001 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  BootScriptExecuter.h\r
+    \r
+Abstract:\r
+\r
+  Boot Script Executer PPI as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#ifndef _PEI_BOOT_SCRIPT_EXECUTER_PPI_H\r
+#define _PEI_BOOT_SCRIPT_EXECUTER_PPI_H\r
+\r
+#define PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID \\r
+  { \\r
+    0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0x0b, 0xfb, 0xff \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_BOOT_SCRIPT_EXECUTER_PPI);\r
+\r
+#define PEI_BOOT_SCRIPT_EXECUTER_PPI_REVISION 0x00000001\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_BOOT_SCRIPT_EXECUTE) (\r
+  IN     EFI_PEI_SERVICES                        **PeiServices,\r
+  IN PEI_BOOT_SCRIPT_EXECUTER_PPI                * This,\r
+  IN     EFI_PHYSICAL_ADDRESS                    Address,\r
+  IN     EFI_GUID                                * FvFile OPTIONAL\r
+  );\r
+\r
+typedef struct _PEI_BOOT_SCRIPT_EXECUTER_PPI {\r
+  UINT64                  Revision;\r
+  PEI_BOOT_SCRIPT_EXECUTE Execute;\r
+} PEI_BOOT_SCRIPT_EXECUTER_PPI;\r
+\r
+extern EFI_GUID gPeiBootScriptExecuterPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c
new file mode 100644 (file)
index 0000000..339cacc
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIO.c\r
+\r
+Abstract:\r
+\r
+  CPU IO PPI GUID as defined in Tiano\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (CpuIo)\r
+\r
+EFI_GUID  gPeiCpuIoPpiInServiceTableGuid = PEI_CPU_IO_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiCpuIoPpiInServiceTableGuid, "CPU IO", "CPU IO PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h
new file mode 100644 (file)
index 0000000..3d5aba7
--- /dev/null
@@ -0,0 +1,250 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIo.h\r
+\r
+Abstract:\r
+\r
+  CPU IO PPI defined in Tiano\r
+  CPU IO PPI abstracts CPU IO access\r
+  \r
+\r
+--*/\r
+\r
+#ifndef _PEI_CPUIO_PPI_H_\r
+#define _PEI_CPUIO_PPI_H_\r
+\r
+#define PEI_CPU_IO_PPI_GUID \\r
+  { \\r
+    0xe6af1f7b, 0xfc3f, 0x46da, 0xa8, 0x28, 0xa3, 0xb4, 0x57, 0xa4, 0x42, 0x82 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_CPU_IO_PPI);\r
+\r
+//\r
+// *******************************************************\r
+// PEI_CPU_IO_PPI_WIDTH\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  PeiCpuIoWidthUint8,\r
+  PeiCpuIoWidthUint16,\r
+  PeiCpuIoWidthUint32,\r
+  PeiCpuIoWidthUint64,\r
+  PeiCpuIoWidthFifoUint8,\r
+  PeiCpuIoWidthFifoUint16,\r
+  PeiCpuIoWidthFifoUint32,\r
+  PeiCpuIoWidthFifoUint64,\r
+  PeiCpuIoWidthFillUint8,\r
+  PeiCpuIoWidthFillUint16,\r
+  PeiCpuIoWidthFillUint32,\r
+  PeiCpuIoWidthFillUint64,\r
+  PeiCpuIoWidthMaximum\r
+} PEI_CPU_IO_PPI_WIDTH;\r
+\r
+//\r
+// *******************************************************\r
+// PEI_CPU_IO_PPI_IO_MEM\r
+// *******************************************************\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_MEM) (\r
+  IN  EFI_PEI_SERVICES                  **PeiServices,\r
+  IN PEI_CPU_IO_PPI                     * This,\r
+  IN  PEI_CPU_IO_PPI_WIDTH              Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+//\r
+// *******************************************************\r
+// PEI_CPU_IO_PPI_ACCESS\r
+// *******************************************************\r
+//\r
+typedef struct {\r
+  PEI_CPU_IO_PPI_IO_MEM Read;\r
+  PEI_CPU_IO_PPI_IO_MEM Write;\r
+} PEI_CPU_IO_PPI_ACCESS;\r
+\r
+//\r
+// *******************************************************\r
+// Base IO Class Functions\r
+// *******************************************************\r
+//\r
+typedef\r
+UINT8\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ8) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT16\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ16) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT32\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ32) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT64\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ64) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE8) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT8                   Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE16) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT16                  Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE32) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT32                  Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE64) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT64                  Data\r
+  );\r
+\r
+typedef\r
+UINT8\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ8) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT16\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ16) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT32\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ32) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+UINT64\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ64) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE8) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT8                   Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE16) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT16                  Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE32) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT32                  Data\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE64) (\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN PEI_CPU_IO_PPI           * This,\r
+  IN  UINT64                  Address,\r
+  IN  UINT64                  Data\r
+  );\r
+\r
+//\r
+// *******************************************************\r
+// PEI_CPU_IO_PPI\r
+// *******************************************************\r
+//\r
+typedef struct _PEI_CPU_IO_PPI {\r
+  PEI_CPU_IO_PPI_ACCESS       Mem;\r
+  PEI_CPU_IO_PPI_ACCESS       Io;\r
+  PEI_CPU_IO_PPI_IO_READ8     IoRead8;\r
+  PEI_CPU_IO_PPI_IO_READ16    IoRead16;\r
+  PEI_CPU_IO_PPI_IO_READ32    IoRead32;\r
+  PEI_CPU_IO_PPI_IO_READ64    IoRead64;\r
+  PEI_CPU_IO_PPI_IO_WRITE8    IoWrite8;\r
+  PEI_CPU_IO_PPI_IO_WRITE16   IoWrite16;\r
+  PEI_CPU_IO_PPI_IO_WRITE32   IoWrite32;\r
+  PEI_CPU_IO_PPI_IO_WRITE64   IoWrite64;\r
+  PEI_CPU_IO_PPI_MEM_READ8    MemRead8;\r
+  PEI_CPU_IO_PPI_MEM_READ16   MemRead16;\r
+  PEI_CPU_IO_PPI_MEM_READ32   MemRead32;\r
+  PEI_CPU_IO_PPI_MEM_READ64   MemRead64;\r
+  PEI_CPU_IO_PPI_MEM_WRITE8   MemWrite8;\r
+  PEI_CPU_IO_PPI_MEM_WRITE16  MemWrite16;\r
+  PEI_CPU_IO_PPI_MEM_WRITE32  MemWrite32;\r
+  PEI_CPU_IO_PPI_MEM_WRITE64  MemWrite64;\r
+} PEI_CPU_IO_PPI;\r
+\r
+extern EFI_GUID gPeiCpuIoPpiInServiceTableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c
new file mode 100644 (file)
index 0000000..0dddc67
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Decompress)\r
+\r
+\r
+EFI_GUID gEfiPeiDecompressPpiGuid = EFI_PEI_DECOMPRESS_PPI_GUID;\r
+EFI_GUID_STRING(&gEfiPeiDecompressPpiGuid, "PeiDecompress", "PeiDecompress PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h
new file mode 100644 (file)
index 0000000..4a01742
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __DECOMPRESS_PPI_H__\r
+#define __DECOMPRESS_PPI_H__\r
+\r
+\r
+#define EFI_PEI_DECOMPRESS_PPI_GUID \\r
+  { 0x1a36e4e7, 0xfab6, 0x476a, 0x8e, 0x75, 0x69, 0x5a, 0x5, 0x76, 0xfd, 0xd7}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_DECOMPRESS_PPI);\r
+\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_DECOMPRESS_DECOMPRESS)(\r
+  IN  CONST EFI_PEI_DECOMPRESS_PPI           *This,\r
+  IN  CONST EFI_COMPRESSION_SECTION          *InputSection,\r
+  OUT VOID                                   **OutputBuffer,\r
+  OUT UINTN                                  *OutputSize\r
+  );\r
+\r
+typedef struct _EFI_PEI_DECOMPRESS_PPI {\r
+  EFI_PEI_DECOMPRESS_DECOMPRESS   Decompress;\r
+} EFI_PEI_DECOMPRESS_PPI;\r
+\r
+\r
+\r
+extern EFI_GUID gEfiPeiDecompressPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c
new file mode 100644 (file)
index 0000000..b48b2a4
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  DeviceRecoveryModule.c\r
+\r
+Abstract:\r
+\r
+  Device Recovery Module PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (DeviceRecoveryModule)\r
+\r
+EFI_GUID  gPeiDeviceRecoveryModulePpiGuid = PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI;\r
+\r
+EFI_GUID_STRING(&gPeiDeviceRecoveryModulePpiGuid, "DeviceRecoveryModule", "Device Recovery Module PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h
new file mode 100644 (file)
index 0000000..fd7b4cb
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  DeviceRecoveryModule.h\r
+    \r
+Abstract:\r
+\r
+  Device Recovery Module PPI as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#ifndef _PEI_DEVICE_RECOVERY_MODULE_PPI_H\r
+#define _PEI_DEVICE_RECOVERY_MODULE_PPI_H\r
+\r
+#define PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI \\r
+  { \\r
+    0x0DE2CE25, 0x446A, 0x45a7, 0xBF, 0xC9, 0x37, 0xDA, 0x26, 0x34, 0x4B, 0x37 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_DEVICE_RECOVERY_MODULE_INTERFACE);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE) (\r
+  IN EFI_PEI_SERVICES                               **PeiServices,\r
+  IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE           * This,\r
+  OUT UINTN                                         *NumberRecoveryCapsules\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO) (\r
+  IN  EFI_PEI_SERVICES                              **PeiServices,\r
+  IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE           * This,\r
+  IN  UINTN                                         CapsuleInstance,\r
+  OUT UINTN                                         *Size,\r
+  OUT EFI_GUID                                      * CapsuleType\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_DEVICE_LOAD_RECOVERY_CAPSULE) (\r
+  IN OUT EFI_PEI_SERVICES                         **PeiServices,\r
+  IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE         * This,\r
+  IN UINTN                                        CapsuleInstance,\r
+  OUT VOID                                        *Buffer\r
+  );\r
+\r
+typedef struct _PEI_DEVICE_RECOVERY_MODULE_INTERFACE {\r
+  PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE  GetNumberRecoveryCapsules;\r
+  PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO    GetRecoveryCapsuleInfo;\r
+  PEI_DEVICE_LOAD_RECOVERY_CAPSULE        LoadRecoveryCapsule;\r
+} PEI_DEVICE_RECOVERY_MODULE_INTERFACE;\r
+\r
+extern EFI_GUID gPeiDeviceRecoveryModulePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c
new file mode 100644 (file)
index 0000000..a640309
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ DxeIpl.c\r
+\r
+Abstract:\r
+\r
+  DXE Initial Program Load PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (DxeIpl)\r
+\r
+EFI_GUID  gEfiDxeIplPpiGuid = EFI_DXE_IPL_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDxeIplPpiGuid, "DxeIpl", "DXE IPL PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h
new file mode 100644 (file)
index 0000000..d3cd1b1
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ DxeIpl.h\r
+\r
+Abstract:\r
+\r
+  DXE Initial Program Load PPI as defined in Tiano\r
+\r
+  When the PEI core is done it calls the DXE IPL via this PPI.\r
+\r
+--*/\r
+\r
+#ifndef _DXE_IPL_H_\r
+#define _DXE_IPL_H_\r
+\r
+#include "Tiano.h"\r
+#include "PeiHob.h"\r
+\r
+#define EFI_DXE_IPL_PPI_GUID \\r
+  { \\r
+    0xae8ce5d, 0xe448, 0x4437, 0xa8, 0xd7, 0xeb, 0xf5, 0xf1, 0x94, 0xf7, 0x31 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DXE_IPL_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DXE_IPL_ENTRY) (\r
+  IN EFI_DXE_IPL_PPI              * This,\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_HOB_POINTERS         HobList\r
+  );\r
+\r
+typedef struct _EFI_DXE_IPL_PPI {\r
+  EFI_DXE_IPL_ENTRY Entry;\r
+} EFI_DXE_IPL_PPI;\r
+\r
+extern EFI_GUID gEfiDxeIplPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
new file mode 100644 (file)
index 0000000..f39c93c
--- /dev/null
@@ -0,0 +1,102 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkFrameworkPpiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkFrameworkPpiLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+    BlockIo\BlockIo.h\r
+    BlockIo\BlockIo.c\r
+    BootInRecoveryMode\BootInRecoveryMode.h\r
+    BootInRecoveryMode\BootInRecoveryMode.c\r
+    BootMode\BootMode.h\r
+    BootMode\BootMode.c\r
+    BootScriptExecuter\BootScriptExecuter.h\r
+    BootScriptExecuter\BootScriptExecuter.c    \r
+    CpuIo\CpuIo.h\r
+    CpuIo\CpuIo.c\r
+    DeviceRecoveryModule\DeviceRecoveryModule.h\r
+    DeviceRecoveryModule\DeviceRecoveryModule.c    \r
+    DxeIpl\DxeIpl.h\r
+    DxeIpl\DxeIpl.c\r
+    EndOfPeiSignal\EndOfPeiSignal.h\r
+    EndOfPeiSignal\EndOfPeiSignal.c\r
+    FindFv\FindFv.h\r
+    FindFv\FindFv.c\r
+    LoadFile\LoadFile.h\r
+    LoadFile\LoadFile.c\r
+    MemoryDiscovered\MemoryDiscovered.h\r
+    MemoryDiscovered\MemoryDiscovered.c\r
+    PciCfg\PciCfg.h\r
+    PciCfg\PciCfg.c\r
+    PciCfg2\PciCfg2.h\r
+    PciCfg2\PciCfg2.c\r
+    RecoveryModule\RecoveryModule.h\r
+    RecoveryModule\RecoveryModule.c\r
+    Reset\Reset.h\r
+    Reset\Reset.c\r
+    S3Resume\S3Resume.h\r
+    S3Resume\S3Resume.c\r
+    SecPlatformInformation\SecPlatformInformation.h\r
+    SecPlatformInformation\SecPlatformInformation.c\r
+    SectionExtraction\SectionExtraction.h\r
+    SectionExtraction\SectionExtraction.c\r
+    Security\Security.h\r
+    Security\Security.c\r
+    Smbus\Smbus.h\r
+    Smbus\Smbus.c\r
+    Smbus2\Smbus2.h\r
+    Smbus2\Smbus2.c\r
+    Stall\Stall.h\r
+    Stall\Stall.c\r
+    StatusCode\StatusCode.h\r
+    StatusCode\StatusCode.c\r
+    Variable\Variable.h\r
+    Variable\Variable.c\r
+    Variable2\Variable2.h\r
+    Variable2\Variable2.c\r
+    Decompress\Decompress.h\r
+    Decompress\Decompress.c\r
+    FirmwareVolumeInfo\FirmwareVolumeInfo.h\r
+    FirmwareVolumeInfo\FirmwareVolumeInfo.c\r
+    LoadFile2\LoadFile2.h\r
+    LoadFile2\LoadFile2.c\r
+    Security2\Security2.h\r
+    Security2\Security2.c\r
+    FirmwareVolume\FirmwareVolume.h\r
+    FirmwareVolume\FirmwareVolume.c\r
+    GuidedSectionExtraction\GuidedSectionExtraction.h\r
+    GuidedSectionExtraction\GuidedSectionExtraction.c\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c
new file mode 100644 (file)
index 0000000..b4a2223
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EndOfPeiSignal.c\r
+\r
+Abstract:\r
+\r
+  This is installed prior to DXE taking over the memory map\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (EndOfPeiSignal)\r
+\r
+EFI_GUID  gEndOfPeiSignalPpiGuid = PEI_END_OF_PEI_PHASE_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEndOfPeiSignalPpiGuid, "EndOfPeiSignal", "End of PEI Phase Signalled PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h
new file mode 100644 (file)
index 0000000..250d052
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EndOfPeiSignal.h\r
+    \r
+Abstract:\r
+\r
+  PPI to be used to signal when the PEI ownership of the memory map\r
+  officially ends and DXE will take over\r
+\r
+--*/\r
+\r
+#ifndef _PEI_END_OF_PEI_SIGNAL_PPI_H\r
+#define _PEI_END_OF_PEI_SIGNAL_PPI_H\r
+\r
+#define PEI_END_OF_PEI_PHASE_PPI_GUID \\r
+  { \\r
+    0x605EA650, 0xC65C, 0x42e1, 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_END_OF_PEI_SIGNAL_PPI);\r
+\r
+extern EFI_GUID gEndOfPeiSignalPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c
new file mode 100644 (file)
index 0000000..48164c4
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ FindFv.c\r
+\r
+Abstract:\r
+\r
+  FindFv PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (FindFv)\r
+\r
+EFI_GUID  gEfiFindFvPpiGuid = EFI_FIND_FV_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFindFvPpiGuid, "FindFv", "FindFv PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h
new file mode 100644 (file)
index 0000000..72935f4
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ FindFv.h\r
+\r
+Abstract:\r
+\r
+  FindFv PPI as defined in Tiano\r
+\r
+  Used to locate FVs that contain PEIMs in PEI\r
+\r
+--*/\r
+\r
+#ifndef _FIND_FV_H_\r
+#define _FIND_FV_H_\r
+\r
+#include "EfiFirmwareVolumeHeader.h"\r
+\r
+#define EFI_FIND_FV_PPI_GUID \\r
+  { \\r
+    0x36164812, 0xa023, 0x44e5, 0xbd, 0x85, 0x5, 0xbf, 0x3c, 0x77, 0x0, 0xaa \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_FIND_FV_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FIND_FV_FINDFV) (\r
+  IN EFI_FIND_FV_PPI          * This,\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  UINT8                       *FvNumber,\r
+  EFI_FIRMWARE_VOLUME_HEADER  **FVAddress\r
+  );\r
+\r
+typedef struct _EFI_FIND_FV_PPI {\r
+  EFI_FIND_FV_FINDFV  FindFv;\r
+} EFI_FIND_FV_PPI;\r
+\r
+extern EFI_GUID gEfiFindFvPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c
new file mode 100644 (file)
index 0000000..73ff00c
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (FirmwareVolume)\r
+\r
+//\r
+// There is no PPI Guid definition here, since the guid of\r
+// this ppi is the same as the firmware volume format Guid.\r
+//
\ 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 (file)
index 0000000..ff75848
--- /dev/null
@@ -0,0 +1,112 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __FIRMWARE_VOLUME_H__\r
+#define __FIRMWARE_VOLUME_H__\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_PPI);\r
+\r
+typedef UINT32  EFI_FV_FILE_ATTRIBUTES;\r
+typedef VOID  * EFI_PEI_FILE_HANDLE;\r
+typedef VOID  * EFI_PEI_FV_HANDLE;\r
+\r
+\r
+typedef struct {\r
+  EFI_GUID                FileName;\r
+  EFI_FV_FILETYPE         FileType;\r
+  EFI_FV_FILE_ATTRIBUTES  FileAttributes;\r
+  VOID                    *Buffer;\r
+  UINT32                  BufferSize;\r
+} EFI_FV_FILE_INFO;\r
+\r
+typedef struct {\r
+  EFI_FVB_ATTRIBUTES  FvAttributes;\r
+  EFI_GUID            FvFormat;\r
+  EFI_GUID            FvName;\r
+  VOID                *FvStart;\r
+  UINT64              FvSize;\r
+} EFI_FV_INFO;\r
+\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_PROCESS_FV) (\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI        *This,\r
+  IN  VOID                                    *Buffer,\r
+  IN  UINTN                                   BufferSize,\r
+  OUT EFI_PEI_FV_HANDLE                       *FvHandle\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_FIND_FILE_TYPE) (\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI       *This,\r
+  IN EFI_FV_FILETYPE                         SearchType,\r
+  IN EFI_PEI_FV_HANDLE                       FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE                 *FileHandle\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_FIND_FILE_NAME) (\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI     *This,\r
+  IN CONST EFI_GUID                        *FileName,\r
+  IN EFI_PEI_FV_HANDLE                     FvHandle,\r
+  OUT EFI_PEI_FILE_HANDLE                  *FileHandle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_GET_FILE_INFO) (\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI     *This,\r
+  IN EFI_PEI_FILE_HANDLE                   FileHandle,\r
+  OUT EFI_FV_FILE_INFO                     *FileInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_GET_INFO)(\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI  *This,\r
+  IN EFI_PEI_FV_HANDLE                  FvHandle,\r
+  OUT EFI_FV_INFO                       *VolumeInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_FIND_SECTION) (\r
+  IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI   *This,\r
+  IN EFI_SECTION_TYPE                    SearchType,\r
+  IN EFI_PEI_FILE_HANDLE                 FileHandle,\r
+  OUT VOID                               **SectionData\r
+  );\r
+\r
+typedef struct _EFI_PEI_FIRMWARE_VOLUME_PPI {\r
+  EFI_PEI_FV_PROCESS_FV             ProcessVolume;\r
+  EFI_PEI_FV_FIND_FILE_TYPE         FindFileByType;   \r
+  EFI_PEI_FV_FIND_FILE_NAME         FindFileByName;     \r
+  EFI_PEI_FV_GET_FILE_INFO          GetFileInfo;      \r
+  EFI_PEI_FV_GET_INFO               GetVolumeInfo;\r
+  EFI_PEI_FV_FIND_SECTION           FindSectionByType;\r
+} EFI_PEI_FIRMWARE_VOLUME_PPI;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c
new file mode 100644 (file)
index 0000000..ae58480
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeInfo.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (FirmwareVolumeInfo)\r
+\r
+EFI_GUID gEfiFirmwareVolumeInfoPpiGuid = EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID;\r
+EFI_GUID_STRING(&gEfiFirmwareVolumeInfoPpiGuid, "FirmwareVolumeInfo", "FirmwareVolumeInfo PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h
new file mode 100644 (file)
index 0000000..f659be7
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeInfo.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __FIRMWARE_VOLUME_INFO_PPI__\r
+#define __FIRMWARE_VOLUME_INFO_PPI__\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI);\r
+\r
+\r
+//\r
+// The PPI GUID must match the EFI_GUID FvFormat value\r
+//\r
+#define EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID \\r
+  { 0x49edb1c1, 0xbf21, 0x4761, { 0xbb, 0x12, 0xeb, 0x0, 0x31, 0xaa, 0xbb, 0x39 } }\r
+\r
+\r
+typedef struct _EFI_PEI_FIRMWARE_VOLUME_INFO_PPI {\r
+  EFI_GUID            FvFormat;\r
+  VOID                *FvInfo;\r
+  UINT32              FvInfoSize;\r
+  EFI_GUID            *ParentFvName;\r
+  EFI_GUID            *ParentFileName;\r
+} EFI_PEI_FIRMWARE_VOLUME_INFO_PPI;\r
+\r
+\r
+extern EFI_GUID gEfiFirmwareVolumeInfoPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c
new file mode 100644 (file)
index 0000000..5cfb658
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidedSectionExtraction.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (GuidedSectionExtraction)\r
+\r
+//\r
+// There is no PPI Guid definition here since this PPI is for\r
+// extract EFI_SECTION_GUID_DEFINED type section.\r
+//
\ 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 (file)
index 0000000..8ad5e6a
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidedSectionExtraction.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#ifndef __GUIDED_SECTION_EXTRACTION_PPI_H__\r
+#define __GUIDED_SECTION_EXTRACTION_PPI_H__\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_EXTRACT_GUIDED_SECTION)(\r
+  IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI  *This,\r
+  IN CONST VOID                                   *InputSection,\r
+  OUT VOID                                        **OutputBuffer,\r
+  OUT UINTN                                       *OutputSize,\r
+  OUT UINT32                                      *AuthenticationStatus\r
+  );\r
+\r
+typedef struct _EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI {\r
+  EFI_PEI_EXTRACT_GUIDED_SECTION  ExtractSection;\r
+} EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c
new file mode 100644 (file)
index 0000000..03f9d27
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile.c\r
+\r
+Abstract:\r
+\r
+  Load File PPI GUID.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (LoadFile)\r
+\r
+EFI_GUID  gPeiFvFileLoaderPpiGuid = EFI_PEI_FV_FILE_LOADER_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiFvFileLoaderPpiGuid, "FvFileLoader", "Fv File Loader Support PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h
new file mode 100644 (file)
index 0000000..d6cf68a
--- /dev/null
@@ -0,0 +1,48 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile.h\r
+    \r
+Abstract:\r
+\r
+  Load image file from fv to memory. \r
+\r
+--*/\r
+\r
+#ifndef _PEI_FV_FILE_LOADER_PPI_H\r
+#define _PEI_FV_FILE_LOADER_PPI_H\r
+\r
+#define EFI_PEI_FV_FILE_LOADER_GUID \\r
+  { \\r
+    0x7e1f0d85, 0x4ff, 0x4bb2, 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_FV_FILE_LOADER_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FV_LOAD_FILE) (\r
+  IN EFI_PEI_FV_FILE_LOADER_PPI                 * This,\r
+  IN  EFI_FFS_FILE_HEADER                       * FfsHeader,\r
+  OUT EFI_PHYSICAL_ADDRESS                      * ImageAddress,\r
+  OUT UINT64                                    *ImageSize,\r
+  OUT EFI_PHYSICAL_ADDRESS                      * EntryPoint\r
+  );\r
+\r
+typedef struct _EFI_PEI_FV_FILE_LOADER_PPI {\r
+  EFI_PEI_FV_LOAD_FILE  FvLoadFile;\r
+} EFI_PEI_FV_FILE_LOADER_PPI;\r
+\r
+extern EFI_GUID gPeiFvFileLoaderPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c
new file mode 100644 (file)
index 0000000..f10821e
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile2.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (LoadFile2)\r
+\r
+\r
+EFI_GUID gEfiLoadFile2PpiGuid = EFI_PEI_LOAD_FILE_GUID;\r
+EFI_GUID_STRING(&gEfiLoadFile2PpiGuid, "PeiLoadFile2", "PeiLoadFile2 PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h
new file mode 100644 (file)
index 0000000..c43e1fd
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LoadFile2.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __LOAD_FILE_PPI_H__\r
+#define __LOAD_FILE_PPI_H__\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_LOAD_FILE_PPI);\r
+\r
+#define EFI_PEI_LOAD_FILE_GUID \\r
+  { 0xb9e0abfe, 0x5979, 0x4914, 0x97, 0x7f, 0x6d, 0xee, 0x78, 0xc2, 0x78, 0xa6}\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_LOAD_FILE) (\r
+  IN    CONST EFI_PEI_LOAD_FILE_PPI   *This,\r
+  IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
+  OUT    EFI_PHYSICAL_ADDRESS         *ImageAddress,\r
+  OUT    UINT64                       *ImageSize,\r
+  OUT    EFI_PHYSICAL_ADDRESS         *EntryPoint,\r
+  OUT    UINT32                       *AuthenticationState\r
+  );\r
+\r
+\r
+typedef struct _EFI_PEI_LOAD_FILE_PPI {\r
+  EFI_PEI_LOAD_FILE LoadFile;\r
+} EFI_PEI_LOAD_FILE_PPI;\r
+\r
+\r
+extern EFI_GUID gEfiLoadFile2PpiGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c
new file mode 100644 (file)
index 0000000..52aaf3d
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryDiscovered.c\r
+\r
+Abstract:\r
+\r
+  Memory Discovered PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (MemoryDiscovered)\r
+\r
+EFI_GUID  gPeiMemoryDiscoveredPpiGuid = PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiMemoryDiscoveredPpiGuid, "MemoryDiscovered", "Memory Discovered PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h
new file mode 100644 (file)
index 0000000..9fc5c3a
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryDiscovered.h\r
+    \r
+Abstract:\r
+\r
+  Memory Discovered PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_MEMORY_DISCOVERED_PPI_H\r
+#define _PEI_MEMORY_DISCOVERED_PPI_H\r
+\r
+#define PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID \\r
+  { \\r
+    0xf894643d, 0xc449, 0x42d1, 0x8e, 0xa8, 0x85, 0xbd, 0xd8, 0xc6, 0x5b, 0xde \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_PERMANENT_MEMORY_INSTALLED_PPI);\r
+\r
+extern EFI_GUID gPeiMemoryDiscoveredPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c
new file mode 100644 (file)
index 0000000..1175c60
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ PciCfg.c\r
+\r
+Abstract:\r
+\r
+  PciCfg PPI GUID as defined in PEI CIS specification.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (PciCfg)\r
+\r
+EFI_GUID  gPeiPciCfgPpiInServiceTableGuid = PEI_PCI_CFG_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiPciCfgPpiInServiceTableGuid, "PciCfg", "PciCfg PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h
new file mode 100644 (file)
index 0000000..520f0e6
--- /dev/null
@@ -0,0 +1,65 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ PciCfg.h\r
+\r
+Abstract:\r
+\r
+  PciCfg PPI as defined in PEI CIS specification\r
+\r
+  Used to access PCI configuration space in PEI\r
+\r
+--*/\r
+\r
+#ifndef _PEI_PCI_CFG_H_\r
+#define _PEI_PCI_CFG_H_\r
+#include "EfiPciCfg.h"\r
+\r
+#define PEI_PCI_CFG_PPI_GUID \\r
+  { \\r
+    0xe1f2eba0, 0xf7b9, 0x4a26, 0x86, 0x20, 0x13, 0x12, 0x21, 0x64, 0x2a, 0x90 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_PCI_CFG_PPI);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_PCI_CFG_PPI_IO) (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN PEI_PCI_CFG_PPI          * This,\r
+  IN PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                   Address,\r
+  IN OUT VOID                 *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_PCI_CFG_PPI_RW) (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN PEI_PCI_CFG_PPI          * This,\r
+  IN PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                   Address,\r
+  IN UINTN                    SetBits,\r
+  IN UINTN                    ClearBits\r
+  );\r
+\r
+typedef struct _PEI_PCI_CFG_PPI {\r
+  PEI_PCI_CFG_PPI_IO  Read;\r
+  PEI_PCI_CFG_PPI_IO  Write;\r
+  PEI_PCI_CFG_PPI_RW  Modify;\r
+} PEI_PCI_CFG_PPI;\r
+\r
+extern EFI_GUID gPeiPciCfgPpiInServiceTableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c
new file mode 100644 (file)
index 0000000..b508efe
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ PciCfg2.c\r
+\r
+Abstract:\r
+\r
+  PciCfg2 PPI GUID as defined in PI1.0 specification.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (PciCfg2)\r
+\r
+EFI_GUID  gPeiPciCfg2PpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiPciCfg2PpiGuid, "PciCfg2", "PciCfg2 PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h
new file mode 100644 (file)
index 0000000..766f165
--- /dev/null
@@ -0,0 +1,66 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ PciCfg2.h\r
+\r
+Abstract:\r
+\r
+  PciCfg2 PPI as defined in PI1.0 specification\r
+\r
+  Used to access PCI configuration space in PEI\r
+\r
+--*/\r
+\r
+#ifndef _PEI_PCI_CFG2_H_\r
+#define _PEI_PCI_CFG2_H_\r
+#include "EfiPciCfg.h"\r
+\r
+#define EFI_PEI_PCI_CFG2_PPI_GUID \\r
+  { \\r
+    0x57a449a, 0x1fdc, 0x4c06, 0xbf, 0xc9, 0xf5, 0x3f, 0x6a, 0x99, 0xbb, 0x92 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_PCI_CFG2_PPI);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PCI_CFG_PPI_IO) (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_PCI_CFG2_PPI     *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH      Width,\r
+  IN UINT64                         Address,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PCI_CFG_PPI_RW) (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_PCI_CFG2_PPI     *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH      Width,\r
+  IN UINT64                         Address,\r
+  IN VOID                           *SetBits,\r
+  IN VOID                           *ClearBits\r
+  );\r
+\r
+typedef struct _EFI_PEI_PCI_CFG2_PPI {\r
+  EFI_PEI_PCI_CFG_PPI_IO  Read;\r
+  EFI_PEI_PCI_CFG_PPI_IO  Write;\r
+  EFI_PEI_PCI_CFG_PPI_RW  Modify;\r
+  UINT16                  Segment;\r
+} EFI_PEI_PCI_CFG2_PPI;\r
+\r
+extern EFI_GUID gPeiPciCfg2PpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c
new file mode 100644 (file)
index 0000000..c1a7a52
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RecoveryModule.c\r
+\r
+Abstract:\r
+\r
+  Recovery Module PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (RecoveryModule)\r
+\r
+EFI_GUID  gPeiRecoveryModulePpiGuid = PEI_RECOVERY_MODULE_INTERFACE_PPI;\r
+\r
+EFI_GUID_STRING(&gPeiRecoveryModulePpiGuid, "RecoveryModule", "Recovery Module PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h
new file mode 100644 (file)
index 0000000..3a485e0
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  RecoveryModule.h\r
+    \r
+Abstract:\r
+\r
+  Recovery Module PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_RECOVERY_MODULE_PPI_H\r
+#define _PEI_RECOVERY_MODULE_PPI_H\r
+\r
+#define PEI_RECOVERY_MODULE_INTERFACE_PPI \\r
+  { \\r
+    0xFB6D9542, 0x612D, 0x4f45, 0x87, 0x2F, 0x5C, 0xFF, 0x52, 0xE9, 0x3D, 0xCF \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_RECOVERY_MODULE_INTERFACE);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_LOAD_RECOVERY_CAPSULE) (\r
+  IN EFI_PEI_SERVICES                       **PeiServices,\r
+  IN PEI_RECOVERY_MODULE_INTERFACE          * This\r
+  );\r
+\r
+typedef struct _PEI_RECOVERY_MODULE_INTERFACE {\r
+  PEI_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule;\r
+} PEI_RECOVERY_MODULE_INTERFACE;\r
+\r
+extern EFI_GUID gPeiRecoveryModulePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c
new file mode 100644 (file)
index 0000000..37a434d
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Reset.c\r
+\r
+Abstract:\r
+\r
+  Reset Service PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Reset)\r
+\r
+EFI_GUID  gPeiResetPpiGuid = PEI_RESET_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiResetPpiGuid, "Reset", "Reset PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h
new file mode 100644 (file)
index 0000000..f93fd37
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Reset.h\r
+\r
+Abstract:\r
+\r
+  Reset PPI as defined in Tiano\r
+\r
+  Used to reset the platform from PEI\r
+\r
+--*/\r
+\r
+#ifndef _PEI_RESET_H_\r
+#define _PEI_RESET_H_\r
+\r
+#define PEI_RESET_PPI_GUID \\r
+  { \\r
+    0xef398d58, 0x9dfd, 0x4103, 0xbf, 0x94, 0x78, 0xc6, 0xf4, 0xfe, 0x71, 0x2f \\r
+  }\r
+\r
+//\r
+// *******************************************************\r
+// PEI_RESET_TYPE\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  PeiResetCold,\r
+  PeiResetWarm,\r
+} PEI_RESET_TYPE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (\r
+  IN EFI_PEI_SERVICES   **PeiServices\r
+  );\r
+\r
+typedef struct {\r
+  EFI_PEI_RESET_SYSTEM  ResetSystem;\r
+} PEI_RESET_PPI;\r
+\r
+extern EFI_GUID gPeiResetPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c
new file mode 100644 (file)
index 0000000..3561bf1
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+  Copyright (c) 2004, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  \r
+Module Name:\r
+  \r
+  S3Resume.c\r
+\r
+Abstract:\r
+\r
+  Boot Script Executer PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (S3Resume)\r
+\r
+EFI_GUID  gPeiS3ResumePpiGuid = PEI_S3_RESUME_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiS3ResumePpiGuid, "S3Resume", "S3 Resume PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h
new file mode 100644 (file)
index 0000000..66f2c8a
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+  Copyright (c) 2004, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  \r
+Module Name:\r
+\r
+  S3Resume.h\r
+    \r
+Abstract:\r
+\r
+  S3 Resume PPI \r
+\r
+--*/\r
+\r
+#ifndef _PEI_S3_RESUME_PPI_H\r
+#define _PEI_S3_RESUME_PPI_H\r
+\r
+#define PEI_S3_RESUME_PPI_GUID \\r
+  { \\r
+    0x4426CCB2, 0xE684, 0x4a8a, 0xAE, 0x40, 0x20, 0xD4, 0xB0, 0x25, 0xB7, 0x10 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_S3_RESUME_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_S3_RESUME_PPI_RESTORE_CONFIG) (\r
+  IN EFI_PEI_SERVICES   **PeiServices\r
+  );\r
+\r
+typedef struct _PEI_S3_RESUME_PPI {\r
+  PEI_S3_RESUME_PPI_RESTORE_CONFIG  S3RestoreConfig;\r
+} PEI_S3_RESUME_PPI;\r
+\r
+extern EFI_GUID gPeiS3ResumePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c
new file mode 100644 (file)
index 0000000..f8e6977
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SecPlatformInformation.c\r
+\r
+Abstract:\r
+\r
+  Sec Platform Information as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (SecPlatformInformation)\r
+\r
+EFI_GUID  gEfiSecPlatformInformationPpiGuid = EFI_SEC_PLATFORM_INFORMATION_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSecPlatformInformationPpiGuid, "SecPlatformInformation", "Sec Platform Information");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h
new file mode 100644 (file)
index 0000000..3203967
--- /dev/null
@@ -0,0 +1,71 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SecPlatformInformation.h\r
+    \r
+Abstract:\r
+\r
+  Sec Platform Information PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_SEC_PLATFORM_INFORMATION_PPI_H\r
+#define _PEI_SEC_PLATFORM_INFORMATION_PPI_H\r
+\r
+#define EFI_SEC_PLATFORM_INFORMATION_GUID \\r
+  { \\r
+    0x6f8c2b35, 0xfef4, 0x448d, 0x82, 0x56, 0xe1, 0x1b, 0x19, 0xd6, 0x10, 0x77 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SEC_PLATFORM_INFORMATION_PPI);\r
+\r
+extern EFI_GUID gEfiSecPlatformInformationPpiGuid;\r
+\r
+typedef union {\r
+  struct {\r
+  UINT32 Status : 2;\r
+  UINT32 Tested : 1;\r
+  UINT32 Reserved1 :13;\r
+  UINT32 VirtualMemoryUnavailable : 1;\r
+  UINT32 Ia32ExecutionUnavailable : 1;\r
+  UINT32 FloatingPointUnavailable : 1;\r
+  UINT32 MiscFeaturesUnavailable : 1;\r
+  UINT32 Reserved2 :12;\r
+  } Bits;\r
+  UINT32 Uint32;\r
+} EFI_HEALTH_FLAGS;\r
+\r
+typedef struct {\r
+  EFI_HEALTH_FLAGS HealthFlags;\r
+} SEC_PLATFORM_INFORMATION_RECORD;\r
+\r
+typedef struct {\r
+  UINTN BootPhase;      // entry r20 value\r
+  UINTN UniqueId;       // PAL arbitration ID\r
+  UINTN HealthStat;     // Health Status\r
+  UINTN PALRetAddress;  // return address to PAL\r
+} IPF_HANDOFF_STATUS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SEC_PLATFORM_INFORMATION) (\r
+  IN EFI_PEI_SERVICES                    **PeiServices,\r
+  IN OUT UINT64                          *StructureSize,\r
+  IN OUT SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r
+  );\r
+\r
+typedef struct _EFI_SEC_PLATFORM_INFORMATION_PPI {\r
+  SEC_PLATFORM_INFORMATION  PlatformInformation;\r
+} EFI_SEC_PLATFORM_INFORMATION_PPI;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c
new file mode 100644 (file)
index 0000000..422a29d
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SectionExtraction.c\r
+\r
+Abstract:\r
+\r
+  Section Extraction Protocol PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (SectionExtraction)\r
+\r
+EFI_GUID  gPeiSectionExtractionPpiGuid = EFI_PEI_SECTION_EXTRACTION_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiSectionExtractionPpiGuid, "Section Extraction PPI", "Section Extraction PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h
new file mode 100644 (file)
index 0000000..47ae3d3
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SectionExtraction.h\r
+\r
+Abstract:\r
+\r
+  Section Extraction PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _SECTION_EXTRACTION_PPI_H_\r
+#define _SECTION_EXTRACTION_PPI_H_\r
+\r
+#define EFI_PEI_SECTION_EXTRACTION_PPI_GUID \\r
+  { \\r
+    0x4F89E208, 0xE144, 0x4804, 0x9E, 0xC8, 0x0F, 0x89, 0x4F, 0x7E, 0x36, 0xD7 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_SECTION_EXTRACTION_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_SECTION) (\r
+  IN EFI_PEI_SERVICES                         **PeiServices,\r
+  IN EFI_PEI_SECTION_EXTRACTION_PPI           * This,\r
+  IN EFI_SECTION_TYPE                         * SectionType,\r
+  IN EFI_GUID                                 * SectionDefinitionGuid, OPTIONAL\r
+  IN UINTN                                    SectionInstance,\r
+  IN VOID                                     **Buffer,\r
+  IN OUT UINT32                               *BufferSize,\r
+  OUT UINT32                                  *AuthenticationStatus\r
+  );\r
+\r
+//\r
+// Bit values for AuthenticationStatus\r
+//\r
+#define EFI_PEI_AUTH_STATUS_PLATFORM_OVERRIDE 0x01\r
+#define EFI_PEI_AUTH_STATUS_IMAGE_SIGNED      0x02\r
+#define EFI_PEI_AUTH_STATUS_NOT_TESTED        0x04\r
+#define EFI_PEI_AUTH_STATUS_TEST_FAILED       0x08\r
+\r
+typedef struct _EFI_PEI_SECTION_EXTRACTION_PPI {\r
+  EFI_PEI_GET_SECTION PeiGetSection;\r
+} EFI_PEI_SECTION_EXTRACTION_PPI;\r
+\r
+extern EFI_GUID gPeiSectionExtractionPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c
new file mode 100644 (file)
index 0000000..35e5f6b
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Security.c\r
+\r
+Abstract:\r
+\r
+  Security Architectural Protocol PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Security)\r
+\r
+EFI_GUID  gPeiSecurityPpiGuid = PEI_SECURITY_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiSecurityPpiGuid, "Security PPI", "Security Arch PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h
new file mode 100644 (file)
index 0000000..9a5aa15
--- /dev/null
@@ -0,0 +1,48 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ Security.h\r
+\r
+Abstract:\r
+\r
+  Security Architectural PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _SECURITY_PPI_H_\r
+#define _SECURITY_PPI_H_\r
+\r
+#define PEI_SECURITY_PPI_GUID \\r
+  { \\r
+    0x1388066e, 0x3a57, 0x4efa, 0x98, 0xf3, 0xc1, 0x2f, 0x3a, 0x95, 0x8a, 0x29 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_SECURITY_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SECURITY_AUTHENTICATION_STATE) (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN PEI_SECURITY_PPI             * This,\r
+  IN UINT32                       AuthenticationStatus,\r
+  IN EFI_FFS_FILE_HEADER          * FfsFileHeader,\r
+  IN OUT BOOLEAN                  *StartCrisisRecovery\r
+  );\r
+\r
+typedef struct _PEI_SECURITY_PPI {\r
+  PEI_SECURITY_AUTHENTICATION_STATE AuthenticationState;\r
+} PEI_SECURITY_PPI;\r
+\r
+extern EFI_GUID gPeiSecurityPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c
new file mode 100644 (file)
index 0000000..d267b29
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Security2.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Security2)\r
+\r
+EFI_GUID  gEfiPeiSecurity2PpiGuid = EFI_PEI_SECURITY2_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPeiSecurity2PpiGuid, "Security2 PPI", "Security2 Arch PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h
new file mode 100644 (file)
index 0000000..59dad70
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Security2.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#ifndef __SECURITY2_PPI_H__\r
+#define __SECURITY2_PPI_H__\r
+\r
+#define EFI_PEI_SECURITY2_PPI_GUID \\r
+  { 0xdcd0be23, 0x9586, 0x40f4, 0xb6, 0x43, 0x6, 0x52, 0x2c, 0xed, 0x4e, 0xde}\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_SECURITY2_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SECURITY_AUTHENTICATION_STATE) (\r
+  IN CONST EFI_PEI_SERVICES       **PeiServices,\r
+  IN CONST EFI_PEI_SECURITY2_PPI  *This,\r
+  IN UINT32                       AuthenticationStatus,\r
+  IN EFI_PEI_FV_HANDLE            FvHandle,\r
+  IN EFI_PEI_FILE_HANDLE          FileHandle,\r
+  IN OUT BOOLEAN                  *DeferExection\r
+  );\r
+\r
+typedef struct _EFI_PEI_SECURITY2_PPI {\r
+  EFI_PEI_SECURITY_AUTHENTICATION_STATE  AuthenticationState;\r
+} EFI_PEI_SECURITY2_PPI;\r
+\r
+\r
+extern EFI_GUID gEfiPeiSecurity2PpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c
new file mode 100644 (file)
index 0000000..c63c1f3
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+ Smbus.c\r
+\r
+Abstract:\r
+\r
+  Smbus PPI GUID as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Smbus)\r
+\r
+EFI_GUID  gPeiSmbusPpiGuid = PEI_SMBUS_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiSmbusPpiGuid, "Smbus", "Smbus PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h
new file mode 100644 (file)
index 0000000..cdd1834
--- /dev/null
@@ -0,0 +1,101 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Smbus.h\r
+    \r
+Abstract:\r
+\r
+  Smbus PPI as defined in EFI 2.0\r
+\r
+--*/\r
+\r
+#ifndef _PEI_SMBUS_PPI_H\r
+#define _PEI_SMBUS_PPI_H\r
+\r
+#include "EfiSmbus.h"\r
+\r
+#define PEI_SMBUS_PPI_GUID \\r
+  { \\r
+    0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0xb, 0xfb, 0xda \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_SMBUS_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SMBUS_PPI_EXECUTE_OPERATION) (\r
+  IN      EFI_PEI_SERVICES          **PeiServices,\r
+  IN PEI_SMBUS_PPI                  * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS  SlaveAddress,\r
+  IN      EFI_SMBUS_DEVICE_COMMAND  Command,\r
+  IN      EFI_SMBUS_OPERATION       Operation,\r
+  IN      BOOLEAN                   PecCheck,\r
+  IN OUT  UINTN                     *Length,\r
+  IN OUT  VOID                      *Buffer\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SMBUS_NOTIFY_FUNCTION) (\r
+  IN      EFI_PEI_SERVICES              **PeiServices,\r
+  IN PEI_SMBUS_PPI                      * SmbusPpi,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS      SlaveAddress,\r
+  IN      UINTN                         Data\r
+  );\r
+\r
+//\r
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.\r
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SMBUS_PPI_ARP_DEVICE) (\r
+  IN      EFI_PEI_SERVICES          **PeiServices,\r
+  IN PEI_SMBUS_PPI                  * This,\r
+  IN      BOOLEAN                   ArpAll,\r
+  IN      EFI_SMBUS_UDID            * SmbusUdid, OPTIONAL\r
+  IN OUT  EFI_SMBUS_DEVICE_ADDRESS  * SlaveAddress OPTIONAL\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SMBUS_PPI_GET_ARP_MAP) (\r
+  IN      EFI_PEI_SERVICES          **PeiServices,\r
+  IN PEI_SMBUS_PPI                  * This,\r
+  IN OUT  UINTN                     *Length,\r
+  IN OUT  EFI_SMBUS_DEVICE_MAP      **SmbusDeviceMap\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_SMBUS_PPI_NOTIFY) (\r
+  IN      EFI_PEI_SERVICES          **PeiServices,\r
+  IN PEI_SMBUS_PPI                  * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS  SlaveAddress,\r
+  IN      UINTN                     Data,\r
+  IN      PEI_SMBUS_NOTIFY_FUNCTION NotifyFunction\r
+  );\r
+\r
+typedef struct _PEI_SMBUS_PPI {\r
+  PEI_SMBUS_PPI_EXECUTE_OPERATION Execute;\r
+  PEI_SMBUS_PPI_ARP_DEVICE        ArpDevice;\r
+  PEI_SMBUS_PPI_GET_ARP_MAP       GetArpMap;\r
+  PEI_SMBUS_PPI_NOTIFY            Notify;\r
+} PEI_SMBUS_PPI;\r
+\r
+extern EFI_GUID gPeiSmbusPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c
new file mode 100644 (file)
index 0000000..f1207f2
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+ Smbus2.c\r
+\r
+Abstract:\r
+\r
+  Smbus2 PPI GUID as defined in PI1.0\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Smbus2)\r
+\r
+EFI_GUID  gPeiSmbus2PpiGuid = PEI_SMBUS2_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiSmbus2PpiGuid, "Smbus2", "Smbus2 PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h
new file mode 100644 (file)
index 0000000..e34d380
--- /dev/null
@@ -0,0 +1,96 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Smbus2.h\r
+    \r
+Abstract:\r
+\r
+  Smbus2 PPI as defined in PI 1.0\r
+\r
+--*/\r
+\r
+#ifndef _PEI_SMBUS2_PPI_H\r
+#define _PEI_SMBUS2_PPI_H\r
+\r
+#include "EfiSmbus.h"\r
+\r
+#define PEI_SMBUS2_PPI_GUID \\r
+  { \\r
+    0x9ca93627, 0xb65b, 0x4324, 0xa2, 0x2, 0xc0, 0xb4, 0x61, 0x76, 0x45, 0x43 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_SMBUS2_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION) (\r
+  IN CONST EFI_PEI_SMBUS2_PPI       * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS  SlaveAddress,\r
+  IN      EFI_SMBUS_DEVICE_COMMAND  Command,\r
+  IN      EFI_SMBUS_OPERATION       Operation,\r
+  IN      BOOLEAN                   PecCheck,\r
+  IN OUT  UINTN                     *Length,\r
+  IN OUT  VOID                      *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SMBUS_NOTIFY2_FUNCTION) (\r
+  IN  CONST EFI_PEI_SMBUS2_PPI          * SmbusPpi,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS      SlaveAddress,\r
+  IN      UINTN                         Data\r
+  );\r
+\r
+//\r
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.\r
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SMBUS2_PPI_ARP_DEVICE) (\r
+  IN CONST EFI_PEI_SMBUS2_PPI       * This,\r
+  IN      BOOLEAN                   ArpAll,\r
+  IN      EFI_SMBUS_UDID            * SmbusUdid, OPTIONAL\r
+  IN OUT  EFI_SMBUS_DEVICE_ADDRESS  * SlaveAddress OPTIONAL\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SMBUS2_PPI_GET_ARP_MAP) (\r
+  IN CONST EFI_PEI_SMBUS2_PPI       * This,\r
+  IN OUT  UINTN                     *Length,\r
+  IN OUT  EFI_SMBUS_DEVICE_MAP      **SmbusDeviceMap\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_SMBUS2_PPI_NOTIFY) (\r
+  IN CONST EFI_PEI_SMBUS2_PPI       * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS  SlaveAddress,\r
+  IN      UINTN                     Data,\r
+  IN      EFI_PEI_SMBUS_NOTIFY2_FUNCTION NotifyFunction\r
+  );\r
+\r
+typedef struct _EFI_PEI_SMBUS2_PPI {\r
+  EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION Execute;\r
+  EFI_PEI_SMBUS2_PPI_ARP_DEVICE        ArpDevice;\r
+  EFI_PEI_SMBUS2_PPI_GET_ARP_MAP       GetArpMap;\r
+  EFI_PEI_SMBUS2_PPI_NOTIFY            Notify;\r
+  EFI_GUID                             Identifier;\r
+} EFI_PEI_SMBUS2_PPI;\r
+\r
+extern EFI_GUID gPeiSmbus2PpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c
new file mode 100644 (file)
index 0000000..1e11f74
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+  Copyright (c) 1999 - 2002, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  \r
+Module Name:\r
+  \r
+  Stall.c\r
+\r
+Abstract:\r
+\r
+  Stall PPI\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (Stall)\r
+\r
+EFI_GUID  gPeiStallPpiGuid = PEI_STALL_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiStallPpiGuid, "Stall", "Stall PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h
new file mode 100644 (file)
index 0000000..f84a17e
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+  Copyright (c) 1999 - 2002, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  \r
+Module Name:\r
+\r
+  Stall.h\r
+    \r
+Abstract:\r
+\r
+  Stall PPI \r
+\r
+--*/\r
+\r
+#ifndef _PEI_STALL_PPI_H_\r
+#define _PEI_STALL_PPI_H_\r
+\r
+#define PEI_STALL_PPI_GUID \\r
+  { \\r
+    0x1f4c6f90, 0xb06b, 0x48d8, 0xa2, 0x01, 0xba, 0xe5, 0xf1, 0xcd, 0x7d, 0x56 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_STALL_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_STALL) (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN PEI_STALL_PPI              * This,\r
+  IN UINTN                      Microseconds\r
+  );\r
+\r
+typedef struct _PEI_STALL_PPI {\r
+  UINTN     Resolution;\r
+  PEI_STALL Stall;\r
+} PEI_STALL_PPI;\r
+\r
+extern EFI_GUID gPeiStallPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c
new file mode 100644 (file)
index 0000000..85d1131
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  StatusCode.c\r
+\r
+Abstract:\r
+\r
+  Status Code PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (StatusCode)\r
+\r
+EFI_GUID  gPeiStatusCodePpiGuid = PEI_STATUS_CODE_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiProgressCodePpiGuid, "StatusCode", "Status Code PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h
new file mode 100644 (file)
index 0000000..fd05b64
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCode.h\r
+    \r
+Abstract:\r
+\r
+  Status Code PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_STATUS_CODE_PPI_H\r
+#define _PEI_STATUS_CODE_PPI_H\r
+\r
+#define PEI_STATUS_CODE_PPI_GUID \\r
+  { \\r
+    0x229832d3, 0x7a30, 0x4b36, 0xb8, 0x27, 0xf4, 0xc, 0xb7, 0xd4, 0x54, 0x36 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_STATUS_CODE_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_REPORT_STATUS_CODE) (\r
+  IN EFI_PEI_SERVICES                **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE            CodeType,\r
+  IN EFI_STATUS_CODE_VALUE           Value,\r
+  IN UINT32                          Instance,\r
+  IN EFI_GUID                        * CallerId,\r
+  IN EFI_STATUS_CODE_DATA            * Data OPTIONAL\r
+  );\r
+\r
+typedef struct _PEI_STATUS_CODE_PPI {\r
+  PEI_REPORT_STATUS_CODE  ReportStatusCode;\r
+} PEI_STATUS_CODE_PPI;\r
+\r
+extern EFI_GUID gPeiStatusCodePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c
new file mode 100644 (file)
index 0000000..bc0a2a2
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  Boot Mode PPI GUID as defined in PEI EAS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (Variable)\r
+\r
+EFI_GUID  gPeiReadOnlyVariablePpiGuid = PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiReadOnlyVariablePpiGuid, "Variable", "Read Only Variable PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h
new file mode 100644 (file)
index 0000000..f07fe36
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable.h\r
+    \r
+Abstract:\r
+\r
+  Read-only Variable Service PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef _PEI_READ_ONLY_VARIABLE_PPI_H\r
+#define _PEI_READ_ONLY_VARIABLE_PPI_H\r
+\r
+#include "EfiVariable.h"\r
+\r
+#define PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID \\r
+  { \\r
+    0x3cdc90c6, 0x13fb, 0x4a75, 0x9e, 0x79, 0x59, 0xe9, 0xdd, 0x78, 0xb9, 0xfa \\r
+  }\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_GET_VARIABLE) (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_GET_NEXT_VARIABLE_NAME) (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 * VendorGuid\r
+  );\r
+\r
+typedef struct PEI_READ_ONLY_VARIABLE_PPI {\r
+  PEI_GET_VARIABLE            PeiGetVariable;\r
+  PEI_GET_NEXT_VARIABLE_NAME  PeiGetNextVariableName;\r
+} PEI_READ_ONLY_VARIABLE_PPI;\r
+\r
+EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI);\r
+\r
+extern EFI_GUID gPeiReadOnlyVariablePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c
new file mode 100644 (file)
index 0000000..684f7c4
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable2.c\r
+\r
+Abstract:\r
+\r
+  Read-only Variable2 Service PPI as defined in PI1.0\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (Variable2)\r
+\r
+EFI_GUID  gPeiReadOnlyVariable2PpiGuid = EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiReadOnlyVariable2PpiGuid, "Variable2", "Read Only Variable2 PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h
new file mode 100644 (file)
index 0000000..52e5980
--- /dev/null
@@ -0,0 +1,61 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable2.h\r
+    \r
+Abstract:\r
+\r
+  Read-only Variable2 Service PPI as defined in PI1.0\r
+\r
+--*/\r
+\r
+#ifndef _PEI_READ_ONLY_VARIABLE2_PPI_H\r
+#define _PEI_READ_ONLY_VARIABLE2_PPI_H\r
+\r
+#include "EfiVariable.h"\r
+\r
+#define EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID \\r
+  { \\r
+    0x2ab86ef5, 0xecb5, 0x4134, 0xb5, 0x56, 0x38, 0x54, 0xca, 0x1f, 0xe1, 0xb4 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_READ_ONLY_VARIABLE2_PPI);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_VARIABLE2) (\r
+  IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI    *This,\r
+  IN CONST CHAR16                             *VariableName,\r
+  IN CONST EFI_GUID                           *VariableGuid,\r
+  OUT UINT32                                  *Attributes,\r
+  IN OUT UINTN                                *DataSize,\r
+  OUT VOID                                    *Data\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_GET_NEXT_VARIABLE_NAME2) (\r
+  IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI    *This,\r
+  IN OUT UINTN                                *VariableNameSize,\r
+  IN OUT CHAR16                               *VariableName,\r
+  IN OUT EFI_GUID                             *VariableGuid\r
+  );\r
+\r
+typedef struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI {\r
+  EFI_PEI_GET_VARIABLE2            GetVariable;\r
+  EFI_PEI_GET_NEXT_VARIABLE_NAME2  GetNextVariableName;\r
+} EFI_PEI_READ_ONLY_VARIABLE2_PPI;\r
+\r
+extern EFI_GUID gPeiReadOnlyVariable2PpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c
new file mode 100644 (file)
index 0000000..1819c4e
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    AcpiS3Save.c\r
+\r
+Abstract:\r
+\r
+  Tiano Tiano S3 Save Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (AcpiS3Save)\r
+\r
+EFI_GUID  gEfiAcpiS3SaveGuid = EFI_ACPI_S3_SAVE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpiS3SaveGuid, "EFI Acpi S3 Save Protocol", "Tiano Acpi S3 Save Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h
new file mode 100644 (file)
index 0000000..b616a2e
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiS3Save.h\r
+\r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#ifndef _ACPI_S3_SAVE_PROTOCOL_H\r
+#define _ACPI_S3_SAVE_PROTOCOL_H\r
+\r
+//\r
+// Includes\r
+//\r
+#include "Tiano.h"\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_ACPI_S3_SAVE_PROTOCOL);\r
+\r
+//\r
+// S3 Save Protocol GUID\r
+//\r
+#define EFI_ACPI_S3_SAVE_GUID \\r
+  { \\r
+    0x125f2de1, 0xfb85, 0x440c, 0xa5, 0x4c, 0x4d, 0x99, 0x35, 0x8a, 0x8d, 0x38 \\r
+  }\r
+\r
+//\r
+// Protocol Data Structures\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_ACPI_S3_SAVE) (\r
+  IN EFI_ACPI_S3_SAVE_PROTOCOL      * This,\r
+  IN VOID                           * LegacyMemoryAddress \r
+  );\r
+\r
+typedef \r
+EFI_STATUS \r
+EFI_BOOTSERVICE \r
+(EFIAPI *EFI_ACPI_GET_LEGACY_MEMORY_SIZE) (\r
+  IN  EFI_ACPI_S3_SAVE_PROTOCOL     * This,\r
+  OUT UINTN                         * Size\r
+);\r
+\r
+typedef struct _EFI_ACPI_S3_SAVE_PROTOCOL {\r
+  EFI_ACPI_GET_LEGACY_MEMORY_SIZE   GetLegacyMemorySize;\r
+  EFI_ACPI_S3_SAVE                  S3Save;\r
+} EFI_ACPI_S3_SAVE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiAcpiS3SaveGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c
new file mode 100644 (file)
index 0000000..4d3fcc7
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2005, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  AcpiSupport.c\r
+\r
+Abstract:\r
+\r
+  Tiano EFI 2.0 ACPI Support Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (AcpiSupport)\r
+\r
+EFI_GUID  gEfiAcpiSupportGuid = EFI_ACPI_SUPPORT_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpiSupportGuid, "ACPI Support Protocol", "EFI 2.0 ACPI Support Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h
new file mode 100644 (file)
index 0000000..b99a15b
--- /dev/null
@@ -0,0 +1,128 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2005, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  AcpiSupport.h\r
+\r
+Abstract:\r
+\r
+  Definition of the ACPI Support protocol.  This is defined in the \r
+  Tiano ACPI External Product Specification, revision 0.5.1.\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_SUPPORT_PROTOCOL_H_\r
+#define _ACPI_SUPPORT_PROTOCOL_H_\r
+\r
+//\r
+// Includes\r
+//\r
+#include "Tiano.h"\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_ACPI_SUPPORT_PROTOCOL);\r
+\r
+//\r
+// ACPI Support Protocol GUID\r
+//\r
+#define EFI_ACPI_SUPPORT_GUID \\r
+  { \\r
+    0xdbff9d55, 0x89b7, 0x46da, 0xbd, 0xdf, 0x67, 0x7d, 0x3d, 0xc0, 0x24, 0x1d \\r
+  }\r
+\r
+//\r
+// Extern the GUID for protocol users.\r
+//\r
+extern EFI_GUID gEfiAcpiSupportGuid;\r
+\r
+//\r
+// Protocol Data Definitions\r
+//\r
+//\r
+// ACPI Version bitmap definition:\r
+//\r
+// EFI_ACPI_TABLE_VERSION_1_0B - ACPI Version 1.0b\r
+// EFI_ACPI_TABLE_VERSION_2_0 - ACPI Version 2.0\r
+// EFI_ACPI_TABLE_VERSION_3_0 - ACPI Version 3.0\r
+// EFI_ACPI_TABLE_VERSION_NONE - No ACPI Versions.  This might be used\r
+//  to create memory-based operation regions or other information\r
+//  that is not part of the ACPI "tree" but must still be found\r
+//  in ACPI memory space and/or managed by the core ACPI driver.\r
+//\r
+// Note that EFI provides discrete GUIDs for each version of ACPI\r
+// that is supported.  It is expected that each EFI GUIDed\r
+// version of ACPI will also have a corresponding bitmap\r
+// definition.  This allows maintenance of separate ACPI trees\r
+// for each distinctly different version of ACPI.\r
+//\r
+#define EFI_ACPI_TABLE_VERSION      UINT32\r
+\r
+#define EFI_ACPI_TABLE_VERSION_NONE (1 << 0)\r
+#define EFI_ACPI_TABLE_VERSION_1_0B (1 << 1)\r
+#define EFI_ACPI_TABLE_VERSION_2_0  (1 << 2)\r
+#define EFI_ACPI_TABLE_VERSION_3_0  (1 << 3)\r
+\r
+//\r
+// Protocol Member Functions\r
+//\r
+//\r
+// Retrieve a copy of an ACPI table and the handle of the table.\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_ACPI_GET_ACPI_TABLE) (\r
+  IN EFI_ACPI_SUPPORT_PROTOCOL            * This,\r
+  IN INTN                                 Index,\r
+  OUT VOID                                **Table,\r
+  OUT EFI_ACPI_TABLE_VERSION              * Version,\r
+  OUT UINTN                               *Handle\r
+  );\r
+\r
+//\r
+// Add, update, or remove a table.\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_ACPI_SET_ACPI_TABLE) (\r
+  IN EFI_ACPI_SUPPORT_PROTOCOL            * This,\r
+  IN VOID                                 *Table OPTIONAL,\r
+  IN BOOLEAN                              Checksum,\r
+  IN EFI_ACPI_TABLE_VERSION               Version,\r
+  IN OUT UINTN                            *Handle\r
+  );\r
+\r
+//\r
+// Publish tables to the outside world\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_ACPI_PUBLISH_TABLES) (\r
+  IN EFI_ACPI_SUPPORT_PROTOCOL            * This,\r
+  IN EFI_ACPI_TABLE_VERSION               Version\r
+  );\r
+\r
+//\r
+// ACPI Support Protocol\r
+//\r
+typedef struct _EFI_ACPI_SUPPORT_PROTOCOL {\r
+  EFI_ACPI_GET_ACPI_TABLE GetAcpiTable;\r
+  EFI_ACPI_SET_ACPI_TABLE SetAcpiTable;\r
+  EFI_ACPI_PUBLISH_TABLES PublishTables;\r
+} EFI_ACPI_SUPPORT_PROTOCOL;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c
new file mode 100644 (file)
index 0000000..3282996
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  BootScriptSave.c\r
+\r
+Abstract:\r
+\r
+  S3 Save Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)\r
+\r
+EFI_GUID  gEfiBootScriptSaveGuid = EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiBootScriptSaveGuid, "EFI Boot Script Save Protocol", "EFI Boot Script Save Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h
new file mode 100644 (file)
index 0000000..2d0348b
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootScriptSave.h\r
+\r
+Abstract:\r
+\r
+  S3 Save Protocol\r
+  \r
+--*/\r
+\r
+#ifndef _BOOT_SCRIPT_SAVE_PROTOCOL_H\r
+#define _BOOT_SCRIPT_SAVE_PROTOCOL_H\r
+\r
+//\r
+// Includes\r
+//\r
+#include "Tiano.h"\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_BOOT_SCRIPT_SAVE_PROTOCOL);\r
+\r
+//\r
+// S3 Save Protocol GUID\r
+//\r
+#define EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID \\r
+  { \\r
+    0x470e1529, 0xb79e, 0x4e32, 0xa0, 0xfe, 0x6a, 0x15, 0x6d, 0x29, 0xf9, 0xb2 \\r
+  }\r
+\r
+//\r
+// Protocol Data Structures\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_BOOT_SCRIPT_WRITE) (\r
+  IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL            * This,\r
+  IN UINT16                                   TableName,\r
+  IN UINT16                                   OpCode,\r
+  ...\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+EFI_BOOTSERVICE\r
+(EFIAPI *EFI_BOOT_SCRIPT_CLOSE_TABLE) (\r
+  IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL            * This,\r
+  IN UINT16                                   TableName,\r
+  OUT EFI_PHYSICAL_ADDRESS                    * Address\r
+  );\r
+\r
+//\r
+// S3 Save Protocol data structure\r
+//\r
+typedef struct _EFI_BOOT_SCRIPT_SAVE_PROTOCOL {\r
+  EFI_BOOT_SCRIPT_WRITE       Write;\r
+  EFI_BOOT_SCRIPT_CLOSE_TABLE CloseTable;\r
+} EFI_BOOT_SCRIPT_SAVE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiBootScriptSaveGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c
new file mode 100644 (file)
index 0000000..d767a66
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIO.c\r
+\r
+Abstract:\r
+\r
+  CPU IO Protocol GUID as defined in Tiano\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+\r
+EFI_GUID  gEfiCpuIoProtocolGuid = EFI_CPU_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCpuIoProtocolGuid, "CPU IO", "CPU IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h
new file mode 100644 (file)
index 0000000..c4944b4
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIO.h\r
+\r
+Abstract:\r
+\r
+  CPU IO Protocol as defined in Tiano\r
+\r
+  This code abstracts the CPU IO Protocol\r
+\r
+--*/\r
+\r
+#ifndef _CPUIO_H_\r
+#define _CPUIO_H_\r
+\r
+#define EFI_CPU_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xB0732526, 0x38C8, 0x4b40, 0x88, 0x77, 0x61, 0xC7, 0xB0, 0x6A, 0xAC, 0x45 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_CPU_IO_PROTOCOL);\r
+\r
+//\r
+// *******************************************************\r
+// EFI_CPU_IO_PROTOCOL_WIDTH\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  EfiCpuIoWidthUint8,\r
+  EfiCpuIoWidthUint16,\r
+  EfiCpuIoWidthUint32,\r
+  EfiCpuIoWidthUint64,\r
+  EfiCpuIoWidthFifoUint8,\r
+  EfiCpuIoWidthFifoUint16,\r
+  EfiCpuIoWidthFifoUint32,\r
+  EfiCpuIoWidthFifoUint64,\r
+  EfiCpuIoWidthFillUint8,\r
+  EfiCpuIoWidthFillUint16,\r
+  EfiCpuIoWidthFillUint32,\r
+  EfiCpuIoWidthFillUint64,\r
+  EfiCpuIoWidthMaximum\r
+} EFI_CPU_IO_PROTOCOL_WIDTH;\r
+\r
+//\r
+// *******************************************************\r
+// EFI_CPU_IO_PROTOCOL_IO_MEM\r
+// *******************************************************\r
+//\r
+typedef\r
+EFI_STATUS\r
+EFI_RUNTIMESERVICE\r
+(EFIAPI *EFI_CPU_IO_PROTOCOL_IO_MEM) (\r
+  IN EFI_CPU_IO_PROTOCOL                * This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+//\r
+// *******************************************************\r
+// EFI_CPU_IO_PROTOCOL_ACCESS\r
+// *******************************************************\r
+//\r
+typedef struct {\r
+  EFI_CPU_IO_PROTOCOL_IO_MEM  Read;\r
+  EFI_CPU_IO_PROTOCOL_IO_MEM  Write;\r
+} EFI_CPU_IO_PROTOCOL_ACCESS;\r
+\r
+//\r
+// *******************************************************\r
+// EFI_CPU_IO_PROTOCOL\r
+// *******************************************************\r
+//\r
+typedef struct _EFI_CPU_IO_PROTOCOL {\r
+  EFI_CPU_IO_PROTOCOL_ACCESS  Mem;\r
+  EFI_CPU_IO_PROTOCOL_ACCESS  Io;\r
+} EFI_CPU_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiCpuIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c
new file mode 100644 (file)
index 0000000..ad45047
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHub.c\r
+\r
+Abstract:\r
+\r
+  The logging hub protocol is used both by agents wishing to log\r
+  errors and those wishing to be made aware of all information that\r
+  has been logged.\r
+\r
+  For more information please look at Intel Platform Innovation \r
+  Framework for EFI Data Hub Specification.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (DataHub)\r
+\r
+EFI_GUID  gEfiDataHubProtocolGuid = EFI_DATA_HUB_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDataHubProtocolGuid, "DataHub Protocol", "EFI Data Hub Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h
new file mode 100644 (file)
index 0000000..2a2d86f
--- /dev/null
@@ -0,0 +1,125 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    DataHub.h\r
+\r
+Abstract:\r
+\r
+    The data hub protocol is used both by agents wishing to log\r
+    data and those wishing to be made aware of all information that\r
+    has been logged.\r
+\r
+    For more information please look at Intel Platform Innovation \r
+    Framework for EFI Data Hub Specification.\r
+\r
+--*/\r
+\r
+#ifndef __DATA_HUB_H__\r
+#define __DATA_HUB_H__\r
+\r
+#define EFI_DATA_HUB_PROTOCOL_GUID \\r
+  { \\r
+    0xae80d021, 0x618e, 0x11d4, 0xbc, 0xd7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+//\r
+// EFI generic Data Hub Header\r
+//\r
+// A Data Record is an EFI_DATA_RECORD_HEADER followed by RecordSize bytes of\r
+//  data. The format of the data is defined by the DataRecordGuid.\r
+//\r
+// If EFI_DATA_RECORD_HEADER is extended in the future the Version number must\r
+//  change and the HeaderSize will change if the definition of\r
+//  EFI_DATA_RECORD_HEADER is extended.\r
+//\r
+// The logger is responcible for initializing:\r
+//  Version, HeaderSize, RecordSize, DataRecordGuid, DataRecordClass\r
+//\r
+// The Data Hub driver is responcible for initializing:\r
+//   LogTime and LogMonotonicCount.\r
+//\r
+#define EFI_DATA_RECORD_HEADER_VERSION  0x0100\r
+typedef struct {\r
+  UINT16    Version;\r
+  UINT16    HeaderSize;\r
+  UINT32    RecordSize;\r
+  EFI_GUID  DataRecordGuid;\r
+  EFI_GUID  ProducerName;\r
+  UINT64    DataRecordClass;\r
+  EFI_TIME  LogTime;\r
+  UINT64    LogMonotonicCount;\r
+} EFI_DATA_RECORD_HEADER;\r
+\r
+//\r
+// Definition of DataRecordClass. These are used to filter out class types\r
+// at a very high level. The DataRecordGuid still defines the format of\r
+// the data. See DateHub.doc for rules on what can and can not be a\r
+// new DataRecordClass\r
+//\r
+#define EFI_DATA_RECORD_CLASS_DEBUG         0x0000000000000001\r
+#define EFI_DATA_RECORD_CLASS_ERROR         0x0000000000000002\r
+#define EFI_DATA_RECORD_CLASS_DATA          0x0000000000000004\r
+#define EFI_DATA_RECORD_CLASS_PROGRESS_CODE 0x0000000000000008\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_DATA_HUB_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DATA_HUB_LOG_DATA) (\r
+  IN  EFI_DATA_HUB_PROTOCOL   * This,\r
+  IN  EFI_GUID                * DataRecordGuid,\r
+  IN  EFI_GUID                * ProducerName,\r
+  IN  UINT64                  DataRecordClass,\r
+  IN  VOID                    *RawData,\r
+  IN  UINT32                  RawDataSize\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DATA_HUB_GET_NEXT_RECORD) (\r
+  IN EFI_DATA_HUB_PROTOCOL    * This,\r
+  IN OUT  UINT64              *MonotonicCount,\r
+  IN  EFI_EVENT               * FilterDriver OPTIONAL,\r
+  OUT EFI_DATA_RECORD_HEADER  **Record\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DATA_HUB_REGISTER_FILTER_DRIVER) (\r
+  IN EFI_DATA_HUB_PROTOCOL    * This,\r
+  IN EFI_EVENT                FilterEvent,\r
+  IN EFI_TPL                  FilterTpl,\r
+  IN UINT64                   FilterClass,\r
+  IN EFI_GUID                 * FilterDataRecordGuid OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER) (\r
+  IN EFI_DATA_HUB_PROTOCOL    * This,\r
+  IN EFI_EVENT                FilterEvent\r
+  );\r
+\r
+typedef struct _EFI_DATA_HUB_PROTOCOL {\r
+  EFI_DATA_HUB_LOG_DATA                 LogData;\r
+  EFI_DATA_HUB_GET_NEXT_RECORD          GetNextRecord;\r
+  EFI_DATA_HUB_REGISTER_FILTER_DRIVER   RegisterFilterDriver;\r
+  EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER UnregisterFilterDriver;\r
+} EFI_DATA_HUB_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDataHubProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf
new file mode 100644 (file)
index 0000000..8950b77
--- /dev/null
@@ -0,0 +1,116 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkFrameworkProtocolLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkFrameworkProtocolLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+  AcpiS3Save\AcpiS3Save.h\r
+  AcpiS3Save\AcpiS3Save.c\r
+  AcpiSupport\AcpiSupport.h\r
+  AcpiSupport\AcpiSupport.c\r
+  BootScriptSave\BootScriptSave.h\r
+  BootScriptSave\BootScriptSave.c\r
+  CpuIo\CpuIo.h\r
+  CpuIo\CpuIo.c\r
+  DataHub\DataHub.h\r
+  DataHub\DataHub.c\r
+  FirmwareVolume\FirmwareVolume.h\r
+  FirmwareVolume\FirmwareVolume.c\r
+  FirmwareVolume2\FirmwareVolume2.h\r
+  FirmwareVolume2\FirmwareVolume2.c\r
+  FirmwareVolumeBlock\FirmwareVolumeBlock.h\r
+  FirmwareVolumeBlock\FirmwareVolumeBlock.c\r
+  FormBrowser\FormBrowser.h\r
+  FormBrowser\FormBrowser.c\r
+  FormCallback\FormCallback.h\r
+  FormCallback\FormCallback.c\r
+  Hii\Hii.h\r
+  Hii\Hii.c\r
+  IdeControllerInit\IdeControllerInit.h\r
+  IdeControllerInit\IdeControllerInit.c\r
+  IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.h\r
+  IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.c\r
+  Legacy8259\Legacy8259.h\r
+  Legacy8259\Legacy8259.c\r
+  LegacyBios\LegacyBios.h\r
+  LegacyBios\LegacyBios.c\r
+  LegacyBiosPlatform\LegacyBiosPlatform.h\r
+  LegacyBiosPlatform\LegacyBiosPlatform.c\r
+  LegacyInterrupt\LegacyInterrupt.h\r
+  LegacyInterrupt\LegacyInterrupt.c\r
+  LegacyRegion\LegacyRegion.h\r
+  LegacyRegion\LegacyRegion.c\r
+  PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.h\r
+  PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.c\r
+  PciHotPlugInit\PciHotPlugInit.h\r
+  PciHotPlugInit\PciHotPlugInit.c\r
+  PciPlatform\PciPlatform.h\r
+  PciPlatform\PciPlatform.c\r
+  SectionExtraction\SectionExtraction.h\r
+  SectionExtraction\SectionExtraction.c\r
+  SecurityPolicy\SecurityPolicy.h\r
+  SecurityPolicy\SecurityPolicy.c\r
+  Smbus\Smbus.h\r
+  Smbus\Smbus.c\r
+\r
+[sources.ia32,sources.x64]\r
+  SmmAccess\SmmAccess.h\r
+  SmmAccess\SmmAccess.c\r
+  SmmBase\SmmBase.h\r
+  SmmBase\SmmBase.c\r
+  SmmControl\SmmControl.h\r
+  SmmControl\SmmControl.c\r
+  SmmCpuState\SmmCpuState.h\r
+  SmmCpuState\SmmCpuState.c\r
+  SmmGpiDispatch\SmmGpiDispatch.h\r
+  SmmGpiDispatch\SmmGpiDispatch.c\r
+  SmmIchnDispatch\SmmIchnDispatch.h\r
+  SmmIchnDispatch\SmmIchnDispatch.c\r
+  SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.h\r
+  SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.c\r
+  SmmPowerButtonDispatch\SmmPowerButtonDispatch.h\r
+  SmmPowerButtonDispatch\SmmPowerButtonDispatch.c\r
+  SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.h\r
+  SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.c\r
+  SmmStatusCode\SmmStatusCode.h\r
+  SmmStatusCode\SmmStatusCode.c\r
+  SmmSwDispatch\SmmSwDispatch.h\r
+  SmmSwDispatch\SmmSwDispatch.c\r
+  SmmSxDispatch\SmmSxDispatch.h\r
+  SmmSxDispatch\SmmSxDispatch.c\r
+  SmmUsbDispatch\SmmUsbDispatch.h\r
+  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 (file)
index 0000000..bba551e
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume.c\r
+\r
+Abstract:\r
+\r
+  Firmware Volume protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+  File level access layered on top of Firmware File System protocol.  This\r
+  protocol exists to provide a hook for a filter driver for a firmware volume.\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+\r
+EFI_GUID  gEfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFirmwareVolumeProtocolGuid, "FirmwareVolume Protocol", "Firmware Volume protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h
new file mode 100644 (file)
index 0000000..62bc492
--- /dev/null
@@ -0,0 +1,301 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume.h\r
+\r
+Abstract:\r
+\r
+  Firmware Volume protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+--*/\r
+\r
+#ifndef _FW_VOL_H_\r
+#define _FW_VOL_H_\r
+\r
+//\r
+// Statements that include other files\r
+//\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "EfiFirmwareVolume.h"\r
+//\r
+// Firmware Volume Protocol GUID definition\r
+//\r
+#define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \\r
+  { \\r
+    0x389F751F, 0x1838, 0x4388, 0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 \\r
+  }\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_PROTOCOL);\r
+\r
+//\r
+// ************************************************************\r
+// EFI_FV_ATTRIBUTES bit definitions\r
+// ************************************************************\r
+//\r
+#define EFI_FV_READ_DISABLE_CAP       0x0000000000000001\r
+#define EFI_FV_READ_ENABLE_CAP        0x0000000000000002\r
+#define EFI_FV_READ_STATUS            0x0000000000000004\r
+\r
+#define EFI_FV_WRITE_DISABLE_CAP      0x0000000000000008\r
+#define EFI_FV_WRITE_ENABLE_CAP       0x0000000000000010\r
+#define EFI_FV_WRITE_STATUS           0x0000000000000020\r
+\r
+#define EFI_FV_LOCK_CAP               0x0000000000000040\r
+#define EFI_FV_LOCK_STATUS            0x0000000000000080\r
+#define EFI_FV_WRITE_POLICY_RELIABLE  0x0000000000000100\r
+\r
+#define EFI_FV_ALIGNMENT_CAP          0x0000000000008000\r
+#define EFI_FV_ALIGNMENT_2            0x0000000000010000\r
+#define EFI_FV_ALIGNMENT_4            0x0000000000020000\r
+#define EFI_FV_ALIGNMENT_8            0x0000000000040000\r
+#define EFI_FV_ALIGNMENT_16           0x0000000000080000\r
+#define EFI_FV_ALIGNMENT_32           0x0000000000100000\r
+#define EFI_FV_ALIGNMENT_64           0x0000000000200000\r
+#define EFI_FV_ALIGNMENT_128          0x0000000000400000\r
+#define EFI_FV_ALIGNMENT_256          0x0000000000800000\r
+#define EFI_FV_ALIGNMENT_512          0x0000000001000000\r
+#define EFI_FV_ALIGNMENT_1K           0x0000000002000000\r
+#define EFI_FV_ALIGNMENT_2K           0x0000000004000000\r
+#define EFI_FV_ALIGNMENT_4K           0x0000000008000000\r
+#define EFI_FV_ALIGNMENT_8K           0x0000000010000000\r
+#define EFI_FV_ALIGNMENT_16K          0x0000000020000000\r
+#define EFI_FV_ALIGNMENT_32K          0x0000000040000000\r
+#define EFI_FV_ALIGNMENT_64K          0x0000000080000000\r
+\r
+//\r
+// Protocol API definitions\r
+//\r
+//\r
+// Forward declaration of protocol data structure\r
+//\r
+typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL  EFI_FIRMWARE_VOLUME_PROTOCOL;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_GET_ATTRIBUTES) (\r
+  IN  EFI_FIRMWARE_VOLUME_PROTOCOL  * This,\r
+  OUT EFI_FV_ATTRIBUTES             * Attributes\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  This - Calling context\r
+  Attributes - output buffer which contains attributes\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_SET_ATTRIBUTES) (\r
+  IN EFI_FIRMWARE_VOLUME_PROTOCOL   * This,\r
+  IN OUT EFI_FV_ATTRIBUTES          * Attributes\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Sets volume attributes\r
+\r
+Arguments:\r
+  This          Calling context\r
+  Attributes    Buffer which contains attributes\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_DEVICE_ERROR\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_READ_FILE) (\r
+  IN EFI_FIRMWARE_VOLUME_PROTOCOL   * This,\r
+  IN EFI_GUID                       * NameGuid,\r
+  IN OUT VOID                       **Buffer,\r
+  IN OUT UINTN                      *BufferSize,\r
+  OUT EFI_FV_FILETYPE               * FoundType,\r
+  OUT EFI_FV_FILE_ATTRIBUTES        * FileAttributes,\r
+  OUT UINT32                        *AuthenticationStatus\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+    Read the requested file (NameGuid) and returns data in Buffer.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  NameGuid - Filename identifying which file to read \r
+  Buffer - Pointer to pointer to buffer in which contents of file are returned.\r
+          \r
+          If Buffer is NULL, only type, attributes, and size are returned as\r
+          there is no output buffer.\r
+          \r
+          If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+          from BS pool by ReadFile\r
+          \r
+          If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+          allocated by the caller and is being passed in.\r
+          \r
+  BufferSize - Indicates the buffer size passed in, and on output the size\r
+          required to complete the read\r
+  FoundType - Indicates the type of the file who's data is returned\r
+  FileAttributes - Indicates the attributes of the file who's data is resturned\r
+  AuthenticationStatus - Indicates the authentication status of the data\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  EFI_WARN_BUFFER_TOO_SMALL\r
+  EFI_NOT_FOUND\r
+  EFI_DEVICE_ERROR\r
+  EFI_ACCESS_DENIED\r
+  \r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_READ_SECTION) (\r
+  IN EFI_FIRMWARE_VOLUME_PROTOCOL   * This,\r
+  IN EFI_GUID                       * NameGuid,\r
+  IN EFI_SECTION_TYPE               SectionType,\r
+  IN UINTN                          SectionInstance,\r
+  IN OUT VOID                       **Buffer,\r
+  IN OUT UINTN                      *BufferSize,\r
+  OUT UINT32                        *AuthenticationStatus\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+    Read the requested section from the specified file and returns data in Buffer.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  NameGuid - Filename identifying the file from which to read \r
+  SectionType - Indicates what section type to retrieve\r
+  SectionInstance - Indicates which instance of SectionType to retrieve\r
+  Buffer - Pointer to pointer to buffer in which contents of file are returned.\r
+          \r
+          If Buffer is NULL, only type, attributes, and size are returned as\r
+          there is no output buffer.\r
+          \r
+          If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+          from BS pool by ReadFile\r
+          \r
+          If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+          allocated by the caller and is being passed in.\r
+          \r
+  BufferSize - Indicates the buffer size passed in, and on output the size\r
+          required to complete the read\r
+  AuthenticationStatus - Indicates the authentication status of the data\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  EFI_WARN_BUFFER_TOO_SMALL\r
+  EFI_OUT_OF_RESOURCES\r
+  EFI_NOT_FOUND\r
+  EFI_DEVICE_ERROR\r
+  EFI_ACCESS_DENIED\r
+  \r
+--*/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_WRITE_FILE) (\r
+  IN EFI_FIRMWARE_VOLUME_PROTOCOL   * This,\r
+  IN UINT32                         NumberOfFiles,\r
+  IN EFI_FV_WRITE_POLICY            WritePolicy,\r
+  IN EFI_FV_WRITE_FILE_DATA         * FileData\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Write the supplied file (NameGuid) to the FV.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  NumberOfFiles - Indicates the number of file records pointed to by FileData\r
+  WritePolicy - Indicates the level of reliability of the write with respect to\r
+          things like power failure events.\r
+  FileData - A pointer to an array of EFI_FV_WRITE_FILE_DATA structures.  Each\r
+          element in the array indicates a file to write, and there are\r
+          NumberOfFiles elements in the input array.\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  EFI_OUT_OF_RESOURCES\r
+  EFI_DEVICE_ERROR\r
+  EFI_WRITE_PROTECTED\r
+  EFI_NOT_FOUND\r
+  EFI_INVALID_PARAMETER\r
+  \r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FV_GET_NEXT_FILE) (\r
+  IN EFI_FIRMWARE_VOLUME_PROTOCOL   * This,\r
+  IN OUT VOID                       *Key,\r
+  IN OUT EFI_FV_FILETYPE            * FileType,\r
+  OUT EFI_GUID                      * NameGuid,\r
+  OUT EFI_FV_FILE_ATTRIBUTES        * Attributes,\r
+  OUT UINTN                         *Size\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Given the input key, search for the next matching file in the volume.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  Key - Pointer to a caller allocated buffer that contains an implementation\r
+        specific key that is used to track where to begin searching on\r
+        successive calls.\r
+  FileType - Indicates the file type to filter for\r
+  NameGuid - Guid filename of the file found\r
+  Attributes - Attributes of the file found\r
+  Size - Size in bytes of the file found\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  EFI_NOT_FOUND\r
+  EFI_DEVICE_ERROR\r
+  EFI_ACCESS_DENIED\r
+\r
+--*/\r
+typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL {\r
+  FV_GET_ATTRIBUTES GetVolumeAttributes;\r
+  FV_SET_ATTRIBUTES SetVolumeAttributes;\r
+  FV_READ_FILE      ReadFile;\r
+  FV_READ_SECTION   ReadSection;\r
+  FV_WRITE_FILE     WriteFile;\r
+  FV_GET_NEXT_FILE  GetNextFile;\r
+  UINT32            KeySize;\r
+  EFI_HANDLE        ParentHandle;\r
+} EFI_FIRMWARE_VOLUME_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c
new file mode 100644 (file)
index 0000000..6f4efae
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume2.c\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
+\r
+EFI_GUID  gEfiFirmwareVolume2ProtocolGuid = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID;\r
+\r
+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 (file)
index 0000000..7a56aa2
--- /dev/null
@@ -0,0 +1,195 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolume2.h\r
+\r
+Abstract:\r
+\r
+  PI 1.0 spec definition.\r
+\r
+--*/\r
+\r
+#ifndef __FIRMWARE_VOLUME2_H__\r
+#define __FIRMWARE_VOLUME2_H__\r
+#include "EfiImageFormat.h"\r
+#include "EfiFirmwareVolume.h"\r
+\r
+//\r
+// Firmware Volume Protocol GUID definition\r
+//\r
+#define EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID \\r
+  { 0x220e73b6, 0x6bdb, 0x4413, 0x84, 0x5, 0xb9, 0x74, 0xb1, 0x8, 0x61, 0x9a }\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME2_PROTOCOL);\r
+\r
+\r
+//\r
+// ************************************************************\r
+// EFI_FV2_ATTRIBUTES bit definitions\r
+// ************************************************************\r
+//\r
+#define EFI_FV2_READ_DISABLE_CAP       0x0000000000000001\r
+#define EFI_FV2_READ_ENABLE_CAP        0x0000000000000002\r
+#define EFI_FV2_READ_STATUS            0x0000000000000004\r
+\r
+#define EFI_FV2_WRITE_DISABLE_CAP      0x0000000000000008\r
+#define EFI_FV2_WRITE_ENABLE_CAP       0x0000000000000010\r
+#define EFI_FV2_WRITE_STATUS           0x0000000000000020\r
+\r
+#define EFI_FV2_LOCK_CAP               0x0000000000000040\r
+#define EFI_FV2_LOCK_STATUS            0x0000000000000080\r
+#define EFI_FV2_WRITE_POLICY_RELIABLE  0x0000000000000100\r
+\r
+#define EFI_FV2_READ_LOCK_CAP          0x0000000000001000\r
+#define EFI_FV2_READ_LOCK_STATUS       0x0000000000002000\r
+#define EFI_FV2_WRITE_LOCK_CAP         0x0000000000004000\r
+#define EFI_FV2_WRITE_LOCK_STATUS      0x0000000000008000\r
+#define EFI_FV2_ALIGNMENT              0x00000000001F0000\r
+\r
+\r
+#define EFI_FV2_ALIGNMENT_1            0x0000000000000000\r
+#define EFI_FV2_ALIGNMENT_2            0x0000000000010000\r
+#define EFI_FV2_ALIGNMENT_4            0x0000000000020000\r
+#define EFI_FV2_ALIGNMENT_8            0x0000000000030000\r
+#define EFI_FV2_ALIGNMENT_16           0x0000000000040000\r
+#define EFI_FV2_ALIGNMENT_32           0x0000000000050000\r
+#define EFI_FV2_ALIGNMENT_64           0x0000000000060000\r
+#define EFI_FV2_ALIGNMENT_128          0x0000000000070000\r
+#define EFI_FV2_ALIGNMENT_256          0x0000000000080000\r
+#define EFI_FV2_ALIGNMENT_512          0x0000000000090000\r
+#define EFI_FV2_ALIGNMENT_1K           0x00000000000A0000\r
+#define EFI_FV2_ALIGNMENT_2K           0x00000000000B0000\r
+#define EFI_FV2_ALIGNMENT_4K           0x00000000000C0000\r
+#define EFI_FV2_ALIGNMENT_8K           0x00000000000D0000\r
+#define EFI_FV2_ALIGNMENT_16K          0x00000000000E0000\r
+#define EFI_FV2_ALIGNMENT_32K          0x00000000000F0000\r
+#define EFI_FV2_ALIGNMENT_64K          0x0000000000100000\r
+#define EFI_FV2_ALIGNMENT_128K         0x0000000000110000\r
+#define EFI_FV2_ALIGNMENT_256K         0x0000000000120000\r
+#define EFI_FV2_ALIGNMENT_512K         0x0000000000130000\r
+#define EFI_FV2_ALIGNMENT_1M           0x0000000000140000\r
+#define EFI_FV2_ALIGNMENT_2M           0x0000000000150000\r
+#define EFI_FV2_ALIGNMENT_4M           0x0000000000160000\r
+#define EFI_FV2_ALIGNMENT_8M           0x0000000000170000\r
+#define EFI_FV2_ALIGNMENT_16M          0x0000000000180000\r
+#define EFI_FV2_ALIGNMENT_32M          0x0000000000190000\r
+#define EFI_FV2_ALIGNMENT_64M          0x00000000001A0000\r
+#define EFI_FV2_ALIGNMENT_128M         0x00000000001B0000\r
+#define EFI_FV2_ALIGNMENT_256M         0x00000000001C0000\r
+#define EFI_FV2_ALIGNMENT_512M         0x00000000001D0000\r
+#define EFI_FV2_ALIGNMENT_1G           0x00000000001E0000\r
+#define EFI_FV2_ALIGNMENT_2G           0x00000000001F0000\r
+\r
+#define EFI_FV_FILE_ATTRIB_FIXED           0x00000100\r
+#define EFI_FV_FILE_ATTRIB_MEMORY_MAPPED   0x00000200\r
+\r
+\r
+//\r
+// Protocol API definitions\r
+//\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_GET_ATTRIBUTES) (\r
+  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  OUT EFI_FV_ATTRIBUTES                  *Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_SET_ATTRIBUTES) (\r
+  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL   *This,\r
+  IN OUT EFI_FV_ATTRIBUTES                *Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_READ_FILE) (\r
+  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN CONST EFI_GUID                       *NameGuid,\r
+  IN OUT VOID                             **Buffer,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT EFI_FV_FILETYPE                     *FoundType,\r
+  OUT EFI_FV_FILE_ATTRIBUTES              *FileAttributes,\r
+  OUT UINT32                              *AuthenticationStatus\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_READ_SECTION) (\r
+  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN CONST EFI_GUID                       *NameGuid,\r
+  IN EFI_SECTION_TYPE                     SectionType,\r
+  IN UINTN                                SectionInstance,\r
+  IN OUT VOID                             **Buffer,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT UINT32                              *AuthenticationStatus\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_WRITE_FILE) (\r
+  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN UINT32                               NumberOfFiles,\r
+  IN EFI_FV_WRITE_POLICY                  WritePolicy,\r
+  IN EFI_FV_WRITE_FILE_DATA               *FileData\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_GET_NEXT_FILE) (\r
+  IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN OUT VOID                             *Key,\r
+  IN OUT EFI_FV_FILETYPE                  *FileType,\r
+  OUT EFI_GUID                            *NameGuid,\r
+  OUT EFI_FV_FILE_ATTRIBUTES              *Attributes,\r
+  OUT UINTN                               *Size\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_GET_INFO) (\r
+  IN  CONST EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN  CONST EFI_GUID                       *InformationType,\r
+  IN  OUT UINTN                            *BufferSize,\r
+  OUT    VOID                              *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FV_SET_INFO) (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL  *This,\r
+  IN CONST  EFI_GUID                       *InformationType,\r
+  IN UINTN                                 BufferSize,\r
+  IN CONST VOID                           *Buffer\r
+  );\r
+\r
+\r
+typedef struct _EFI_FIRMWARE_VOLUME2_PROTOCOL {\r
+  EFI_FV_GET_ATTRIBUTES    GetVolumeAttributes;\r
+  EFI_FV_SET_ATTRIBUTES    SetVolumeAttributes;\r
+  EFI_FV_READ_FILE         ReadFile;\r
+  EFI_FV_READ_SECTION      ReadSection;\r
+  EFI_FV_WRITE_FILE        WriteFile;\r
+  EFI_FV_GET_NEXT_FILE     GetNextFile;\r
+  UINT32                   KeySize;\r
+  EFI_HANDLE               ParentHandle;\r
+  EFI_FV_GET_INFO          GetInfo;\r
+  EFI_FV_SET_INFO          SetInfo;\r
+} EFI_FIRMWARE_VOLUME2_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFirmwareVolume2ProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
new file mode 100644 (file)
index 0000000..aae1860
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeBlock.c\r
+\r
+Abstract:\r
+\r
+  Firmware Volume Block protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+  Low level firmware device access routines to abstract firmware device\r
+  hardware.\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+\r
+EFI_GUID  gEfiFirmwareVolumeBlockProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFirmwareVolumeBlockProtocolGuid, "FirmwareVolumeBlock Protocol", "Firmware Volume Block protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
new file mode 100644 (file)
index 0000000..8502810
--- /dev/null
@@ -0,0 +1,251 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeBlock.h\r
+\r
+Abstract:\r
+\r
+  Firmware Volume Block protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+  Low level firmware device access routines to abstract firmware device\r
+  hardware.\r
+\r
+--*/\r
+\r
+#ifndef _FW_VOL_BLOCK_H_\r
+#define _FW_VOL_BLOCK_H_\r
+\r
+#include "EfiFirmwareVolumeHeader.h"\r
+\r
+#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \\r
+  { \\r
+    0xDE28BC59, 0x6228, 0x41BD, 0xBD, 0xF6, 0xA3, 0xB9, 0xAD, 0xB5, 0x8D, 0xA1 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_GET_ATTRIBUTES) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  OUT EFI_FVB_ATTRIBUTES                          * Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves Volume attributes.  No polarity translations are done.\r
+\r
+Arguments:\r
+  This       - Calling context\r
+  Attributes - output buffer which contains attributes\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_SET_ATTRIBUTES) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  IN OUT EFI_FVB_ATTRIBUTES                       * Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Sets Volume attributes.  No polarity translations are done.\r
+\r
+Arguments:\r
+  This       - Calling context\r
+  Attributes - On input: contains new attributes\r
+               On output: contains current attributes of FV\r
+\r
+Returns:\r
+    EFI_INVALID_PARAMETER\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_GET_PHYSICAL_ADDRESS) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  OUT EFI_PHYSICAL_ADDRESS                        * Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV.\r
+\r
+Arguments:\r
+  This       - Calling context\r
+  Attributes - Address is a pointer to a caller allocated EFI_PHYSICAL_ADDRESS\r
+                 that on successful return from GetPhysicalAddress() contains the\r
+                 base address of the firmware volume. \r
+\r
+Returns:\r
+  EFI_UNSUPPORTED\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_GET_BLOCK_SIZE) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  IN EFI_LBA                                      Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumberOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the size in bytes of a specific block within an FV.\r
+    \r
+Arguments:\r
+  This            - Calling context.\r
+  Lba             - Indicates which block to return the size for.\r
+  BlockSize       - BlockSize is a pointer to a caller allocated \r
+                    UINTN in which the size of the block is returned.\r
+  NumberOfBlocks  - NumberOfBlocks is a pointer to a caller allocated\r
+                    UINTN in which the number of consecutive blocks\r
+                    starting with Lba is returned. All blocks in this\r
+                    range have a size of BlockSize.\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_READ) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  OUT UINT8                                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads data beginning at Lba:Offset from FV and places the data in Buffer.\r
+  The read terminates either when *NumBytes of data have been read, or when\r
+  a block boundary is reached.  *NumBytes is updated to reflect the actual\r
+  number of bytes read.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  Lba - Block in which to begin read\r
+  Offset - Offset in the block at which to begin read\r
+  NumBytes - At input, indicates the requested read size.  At output, indicates\r
+    the actual number of bytes read.\r
+  Buffer - Data buffer in which to place data read.\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_NOT_FOUND\r
+  EFI_DEVICE_ERROR\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_WRITE) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Writes data beginning at Lba:Offset from FV. The write terminates either\r
+  when *NumBytes of data have been written, or when a block boundary is\r
+  reached.  *NumBytes is updated to reflect the actual number of bytes\r
+  written.\r
+\r
+Arguments:\r
+  This - Calling context\r
+  Lba - Block in which to begin write\r
+  Offset - Offset in the block at which to begin write\r
+  NumBytes - At input, indicates the requested write size.  At output, indicates\r
+    the actual number of bytes written.\r
+  Buffer - Buffer containing source data for the write.\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER\r
+  EFI_NOT_FOUND\r
+  EFI_DEVICE_ERROR\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+#define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFF\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FVB_ERASE_BLOCKS) (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           * This,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  The EraseBlock() function erases one or more blocks as denoted by the \r
+variable argument list. The entire parameter list of blocks must be verified\r
+prior to erasing any blocks.  If a block is requested that does not exist \r
+within the associated firmware volume (it has a larger index than the last \r
+block of the firmware volume), the EraseBlock() function must return\r
+EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r
+\r
+Arguments:\r
+    This - Calling context\r
+    ...  - Starting LBA followed by Number of Lba to erase. a -1 to terminate\r
+           the list.\r
+    \r
+Returns:\r
+    EFI_INVALID_PARAMETER\r
+    EFI_DEVICE_ERROR\r
+    EFI_SUCCESS\r
+    EFI_ACCESS_DENIED\r
+    \r
+--*/\r
+;\r
+\r
+typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL {\r
+  EFI_FVB_GET_ATTRIBUTES        GetVolumeAttributes;\r
+  EFI_FVB_SET_ATTRIBUTES        SetVolumeAttributes;\r
+  EFI_FVB_GET_PHYSICAL_ADDRESS  GetPhysicalAddress;\r
+  EFI_FVB_GET_BLOCK_SIZE        GetBlockSize;\r
+  EFI_FVB_READ                  Read;\r
+  EFI_FVB_WRITE                 Write;\r
+  EFI_FVB_ERASE_BLOCKS          EraseBlocks;\r
+  EFI_HANDLE                    ParentHandle;\r
+} EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c
new file mode 100644 (file)
index 0000000..2f65746
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FormBrowser.c\r
+\r
+Abstract:\r
+\r
+  The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI \r
+  Configuration Driver.  This will allow the caller to direct the \r
+  configuration driver to use either the HII database or use the passed \r
+  in packet of data.  This will also allow the caller to post messages \r
+  into the configuration drivers internal mailbox.\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)\r
+\r
+EFI_GUID  gEfiFormBrowserProtocolGuid = EFI_FORM_BROWSER_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFormBrowserProtocolGuid, "Form Browser Protocol", "Form Browser 1.0 protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h
new file mode 100644 (file)
index 0000000..566f7cc
--- /dev/null
@@ -0,0 +1,97 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    FormBrowser.h\r
+\r
+Abstract:\r
+\r
+  The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI \r
+  Configuration Driver.  This will allow the caller to direct the \r
+  configuration driver to use either the HII database or use the passed \r
+  in packet of data.  This will also allow the caller to post messages \r
+  into the configuration drivers internal mailbox.\r
+\r
+--*/\r
+\r
+#ifndef _FORM_BROWSER_H_\r
+#define _FORM_BROWSER_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+#define EFI_FORM_BROWSER_PROTOCOL_GUID \\r
+  { \\r
+    0xe5a1333e, 0xe1b4, 0x4d55, 0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_FORM_BROWSER_PROTOCOL);\r
+\r
+typedef struct _EFI_FORM_BROWSER_PROTOCOL EFI_FORM_BROWSER_PROTOCOL;\r
+\r
+typedef struct {\r
+  UINT32  Length;\r
+  UINT16  Type;\r
+  UINT8   Data[1];\r
+} EFI_HII_PACKET;\r
+\r
+typedef struct {\r
+  EFI_HII_IFR_PACK    *IfrData;\r
+  EFI_HII_STRING_PACK *StringData;\r
+} EFI_IFR_PACKET;\r
+\r
+typedef struct {\r
+  UINTN LeftColumn;\r
+  UINTN RightColumn;\r
+  UINTN TopRow;\r
+  UINTN BottomRow;\r
+} SCREEN_DESCRIPTOR;\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SEND_FORM) (\r
+  IN  EFI_FORM_BROWSER_PROTOCOL       * This,\r
+  IN  BOOLEAN                         UseDatabase,\r
+  IN  EFI_HII_HANDLE                  * Handle,\r
+  IN  UINTN                           HandleCount,\r
+  IN  EFI_IFR_PACKET                  * Packet,\r
+  IN  EFI_HANDLE                      CallbackHandle,\r
+  IN  UINT8                           *NvMapOverride,\r
+  IN SCREEN_DESCRIPTOR                * ScreenDimensions,\r
+  OUT BOOLEAN                         *ResetRequired OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CREATE_POP_UP) (\r
+  IN  UINTN                           NumberOfLines,\r
+  IN  BOOLEAN                         HotKey,\r
+  IN  UINTN                           MaximumStringSize,\r
+  OUT CHAR16                          *StringBuffer,\r
+  OUT EFI_INPUT_KEY                   * KeyValue,\r
+  IN  CHAR16                          *String,\r
+  ...\r
+  );\r
+\r
+typedef struct _EFI_FORM_BROWSER_PROTOCOL {\r
+  EFI_SEND_FORM     SendForm;\r
+  EFI_CREATE_POP_UP CreatePopUp;\r
+} EFI_FORM_BROWSER_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFormBrowserProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c
new file mode 100644 (file)
index 0000000..69e2de0
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FormCallback.c\r
+\r
+Abstract:\r
+\r
+  The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom \r
+  NV storage devices as well as communication of user selections in a more \r
+  interactive environment.  This protocol should be published by hardware \r
+  specific drivers which want to export access to custom hardware storage or \r
+  publish IFR which has a requirement to call back the original driver.\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (FormCallback)\r
+\r
+EFI_GUID  gEfiFormCallbackProtocolGuid = EFI_FORM_CALLBACK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFormCallbackProtocolGuid, "Form Callback Protocol", "Form Callback 1.0 protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h
new file mode 100644 (file)
index 0000000..5091f3e
--- /dev/null
@@ -0,0 +1,120 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    FormCallback.h\r
+\r
+Abstract:\r
+\r
+  The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom \r
+  NV storage devices as well as communication of user selections in a more \r
+  interactive environment.  This protocol should be published by hardware \r
+  specific drivers which want to export access to custom hardware storage or \r
+  publish IFR which has a requirement to call back the original driver.\r
+\r
+--*/\r
+\r
+#ifndef _FORM_CALLBACK_H_\r
+#define _FORM_CALLBACK_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)\r
+\r
+#define EFI_FORM_CALLBACK_PROTOCOL_GUID \\r
+  { \\r
+    0xf3e4543d, 0xcf35, 0x6cef, 0x35, 0xc4, 0x4f, 0xe6, 0x34, 0x4d, 0xfc, 0x54 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_FORM_CALLBACK_PROTOCOL);\r
+\r
+typedef struct _EFI_FORM_CALLBACK_PROTOCOL  EFI_FORM_CALLBACK_PROTOCOL;\r
+\r
+#define RESET_REQUIRED  1 // Flags setting to signify that the callback operation resulted in an eventual\r
+// reset to be done upon exit of the browser\r
+//\r
+#define EXIT_REQUIRED   2   // Flags setting to signify that after the processing of the callback results - exit the browser\r
+#define SAVE_REQUIRED   4   // Flags setting to signify that after the processing of the callback results - save the NV data\r
+#define NV_CHANGED      8   // Flags setting to signify that after the processing of the callback results - turn the NV flag on\r
+#define NV_NOT_CHANGED  16  // Flags setting to signify that after the processing of the callback results - turn the NV flag off\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8   OpCode;           // Likely a string, numeric, or one-of\r
+  UINT8   Length;           // Length of the EFI_IFR_DATA_ENTRY packet\r
+  UINT16  Flags;            // Flags settings to determine what behavior is desired from the browser after the callback\r
+  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\r
+  // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value\r
+  // If the OpCode is a String type - Data is a CHAR16[x] type\r
+  // If the OpCode is a Checkbox type - Data is a UINT8 value\r
+  // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure\r
+  //\r
+} EFI_IFR_DATA_ENTRY;\r
+\r
+typedef struct {\r
+  VOID                *NvRamMap;  // If the flag of the op-code specified retrieval of a copy of the NVRAM map,\r
+  // this is a pointer to a buffer copy\r
+  //\r
+  UINT32              EntryCount; // How many EFI_IFR_DATA_ENTRY entries\r
+  EFI_IFR_DATA_ENTRY  Data[1];    // The in-line Data entries.\r
+} EFI_IFR_DATA_ARRAY;\r
+\r
+typedef union {\r
+  EFI_IFR_DATA_ARRAY  DataArray;  // Primarily used by those who call back to their drivers and use HII as a repository\r
+  EFI_IFR_PACKET      DataPacket; // Primarily used by those which do not use HII as a repository\r
+  CHAR16              String[1];  // If returning an error - fill the string with null-terminated contents\r
+} EFI_HII_CALLBACK_PACKET;\r
+#pragma pack()\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_NV_READ) (\r
+  IN     EFI_FORM_CALLBACK_PROTOCOL    * This,\r
+  IN     CHAR16                        *VariableName,\r
+  IN     EFI_GUID                      * VendorGuid,\r
+  OUT    UINT32                        *Attributes OPTIONAL,\r
+  IN OUT UINTN                         *DataSize,\r
+  OUT    VOID                          *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_NV_WRITE) (\r
+  IN     EFI_FORM_CALLBACK_PROTOCOL    * This,\r
+  IN     CHAR16                        *VariableName,\r
+  IN     EFI_GUID                      * VendorGuid,\r
+  IN     UINT32                        Attributes,\r
+  IN     UINTN                         DataSize,\r
+  IN     VOID                          *Buffer,\r
+  OUT    BOOLEAN                       *ResetRequired\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_FORM_CALLBACK) (\r
+  IN     EFI_FORM_CALLBACK_PROTOCOL    * This,\r
+  IN     UINT16                        KeyValue,\r
+  IN     EFI_IFR_DATA_ARRAY            * Data,\r
+  OUT    EFI_HII_CALLBACK_PACKET       **Packet\r
+  );\r
+\r
+typedef struct _EFI_FORM_CALLBACK_PROTOCOL {\r
+  EFI_NV_READ       NvRead;\r
+  EFI_NV_WRITE      NvWrite;\r
+  EFI_FORM_CALLBACK Callback;\r
+} EFI_FORM_CALLBACK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFormCallbackProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c
new file mode 100644 (file)
index 0000000..3ec3073
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Hii.c\r
+\r
+Abstract:\r
+\r
+  This file defines the Human Interface Infrastructure protocol which will \r
+  be used by resources which want to publish IFR/Font/String data and have it \r
+  collected by the Configuration engine.\r
+\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+EFI_GUID  gEfiHiiProtocolGuid = EFI_HII_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHiiProtocolGuid, "Human Interface Infrastructure Protocol", "HII 1.0 protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h
new file mode 100644 (file)
index 0000000..fd6c951
--- /dev/null
@@ -0,0 +1,613 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Hii.h\r
+\r
+Abstract:\r
+\r
+  This file defines the Human Interface Infrastructure protocol which will \r
+  be used by resources which want to publish IFR/Font/String data and have it \r
+  collected by the Configuration engine.\r
+\r
+--*/\r
+\r
+#ifndef _HII_H_\r
+#define _HII_H_\r
+\r
+#include "EfiInternalFormRepresentation.h"\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)\r
+\r
+#define EFI_HII_PROTOCOL_GUID \\r
+  { \\r
+    0xd7ad636e, 0xb997, 0x459b, 0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_HII_PROTOCOL);\r
+\r
+typedef struct _EFI_HII_PROTOCOL  EFI_HII_PROTOCOL;\r
+\r
+//\r
+// Global definition\r
+//\r
+#define NARROW_CHAR         0xFFF0\r
+#define WIDE_CHAR           0xFFF1\r
+#define NON_BREAKING_CHAR   0xFFF2\r
+#define GLYPH_WIDTH         8\r
+#define GLYPH_HEIGHT        19\r
+\r
+#define EFI_HII_FONT        1\r
+#define EFI_HII_STRING      2\r
+#define EFI_HII_IFR         3\r
+#define EFI_HII_KEYBOARD    4\r
+#define EFI_HII_HANDLES     5\r
+#define EFI_HII_VARIABLE    6\r
+#define EFI_HII_DEVICE_PATH 7\r
+\r
+#define HANG(foo) { \\r
+    volatile INT32  __iii; \\r
+    __iii = foo; \\r
+    while (__iii) \\r
+      ; \\r
+  }\r
+//\r
+// #define HANG(foo)\r
+//\r
+// References to string tokens must use this macro to enable scanning for\r
+// token usages.\r
+//\r
+#define STRING_TOKEN(t) t\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef UINT16  EFI_FORM_ID;\r
+typedef UINT16  EFI_FORM_LABEL;\r
+typedef UINT16  EFI_HII_HANDLE;\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  Length;\r
+  UINT16  Type;\r
+} EFI_HII_PACK_HEADER;\r
+\r
+//\r
+// A form list consists of a large variety of structure\r
+// possibilities so to represent the binary blob of data\r
+// associated with a package of forms, we will assume a\r
+// pointer to a self-describing data buffer.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK;\r
+\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;           // Must be filled in\r
+  EFI_HANDLE          ImageHandle;      // Must be filled in\r
+  EFI_HANDLE          DeviceHandle;     // Optional\r
+  EFI_HANDLE          ControllerHandle; // Optional\r
+  EFI_HANDLE          CallbackHandle;   // Optional\r
+  EFI_HANDLE          COBExportHandle;  // Optional\r
+} EFI_HII_HANDLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_VARIABLE_CONTENTS\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  EFI_GUID            VariableGuid;\r
+  UINT32              VariableNameLength;\r
+  UINT16              VariableId;\r
+  //\r
+  //  CHAR16                VariableName[]; //Null-terminated\r
+  //\r
+} EFI_HII_VARIABLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_DEVICE_PATH_PACK\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  //\r
+  //  EFI_DEVICE_PATH       DevicePath[];\r
+  //\r
+} EFI_HII_DEVICE_PATH_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_DATA_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_HANDLE  HiiHandle;\r
+  EFI_GUID        PackageGuid;\r
+  UINT32          DataTableSize;\r
+  UINT32          IfrDataOffset;\r
+  UINT32          StringDataOffset;\r
+  UINT32          VariableDataOffset;\r
+  UINT32          DevicePathOffset;\r
+  UINT32          NumberOfVariableData;\r
+  UINT32          NumberOfLanguages;\r
+  //\r
+  // EFI_HII_DEVICE_PATH_PACK DevicePath[];\r
+  // EFI_HII_VARIABLE_PACK VariableData[];\r
+  // EFI_HII_IFR_PACK IfrData;\r
+  // EFI_HII_STRING_PACK StringData[];\r
+  //\r
+} EFI_HII_DATA_TABLE;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_EXPORT_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  UINT16    NumberOfHiiDataTables;\r
+  EFI_GUID  Revision;\r
+  //\r
+  // EFI_HII_DATA_TABLE HiiDataTable[];\r
+  //\r
+} EFI_HII_EXPORT_TABLE;\r
+\r
+typedef struct {\r
+  BOOLEAN               FormSetUpdate;      // If TRUE, next variable is significant\r
+  EFI_PHYSICAL_ADDRESS  FormCallbackHandle; // If not 0, will update Formset with this info\r
+  BOOLEAN               FormUpdate;         // If TRUE, next variable is significant\r
+  STRING_REF            FormTitle;          // If not 0, will update Form with this info\r
+  UINT16                DataCount;          // The number of Data entries in this structure\r
+  UINT8                 *Data;              // An array of 1+ op-codes, specified by DataCount\r
+} EFI_HII_UPDATE_DATA;\r
+\r
+//\r
+// String attributes\r
+//\r
+#define LANG_RIGHT_TO_LEFT  0x00000001\r
+\r
+//\r
+// A string package is used to localize strings to a particular\r
+// language.  The package is associated with a particular driver\r
+// or set of drivers.  Tools are used to associate tokens with\r
+// string references in forms and in programs.  These tokens are\r
+// language agnostic.  When paired with a language pack (directly\r
+// or indirectly), the string token resolves into an actual\r
+// UNICODE string.  The NumStringPointers determines how many\r
+// StringPointers (offset values) there are as well as the total\r
+// number of Strings that are defined.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  RELOFST             LanguageNameString;\r
+  RELOFST             PrintableLanguageName;\r
+  UINT32              NumStringPointers;\r
+  UINT32              Attributes;\r
+  //\r
+  //  RELOFST               StringPointers[];\r
+  //  EFI_STRING            Strings[];\r
+  //\r
+} EFI_HII_STRING_PACK;\r
+\r
+//\r
+// We use this one to get the real size of the header\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  RELOFST             LanguageNameString;\r
+  RELOFST             PrintableLanguageName;\r
+  UINT32              NumStringPointers;\r
+  UINT32              Attributes;\r
+} EFI_HII_STRING_PACK_HEADER;\r
+\r
+//\r
+// Glyph Attributes\r
+//\r
+#define GLYPH_NON_SPACING   1\r
+#define GLYPH_NON_BREAKING  2\r
+\r
+typedef struct {\r
+  CHAR16  UnicodeWeight;\r
+  UINT8   Attributes;\r
+  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
+} EFI_NARROW_GLYPH;\r
+\r
+typedef struct {\r
+  CHAR16  UnicodeWeight;\r
+  UINT8   Attributes;\r
+  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
+  UINT8   GlyphCol2[GLYPH_HEIGHT];\r
+  UINT8   Pad[3];\r
+} EFI_WIDE_GLYPH;\r
+\r
+//\r
+// A font list consists of a font header followed by a series\r
+// of glyph structures.  Note that fonts are not language specific.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  UINT16              NumberOfNarrowGlyphs;\r
+  UINT16              NumberOfWideGlyphs;\r
+} EFI_HII_FONT_PACK;\r
+\r
+//\r
+// The IfrData in the EFI_HII_IFR_PACK structure definition\r
+// is variable length, and not really part of the header. To\r
+// simplify from code the size of the header, define an\r
+// identical structure that does not include the IfrData field.\r
+// Then use sizeof() this new structure to determine the\r
+// actual size of the header.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK_HEADER;\r
+\r
+//\r
+// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER;\r
+//\r
+typedef enum {\r
+  EfiKeyLCtrl,\r
+  EfiKeyA0,\r
+  EfiKeyLAlt,\r
+  EfiKeySpaceBar,\r
+  EfiKeyA2,\r
+  EfiKeyA3,\r
+  EfiKeyA4,\r
+  EfiKeyRCtrl,\r
+  EfiKeyLeftArrow,\r
+  EfiKeyDownArrow,\r
+  EfiKeyRightArrow,\r
+  EfiKeyZero,\r
+  EfiKeyPeriod,\r
+  EfiKeyEnter,\r
+  EfiKeyLShift,\r
+  EfiKeyB0,\r
+  EfiKeyB1,\r
+  EfiKeyB2,\r
+  EfiKeyB3,\r
+  EfiKeyB4,\r
+  EfiKeyB5,\r
+  EfiKeyB6,\r
+  EfiKeyB7,\r
+  EfiKeyB8,\r
+  EfiKeyB9,\r
+  EfiKeyB10,\r
+  EfiKeyRshift,\r
+  EfiKeyUpArrow,\r
+  EfiKeyOne,\r
+  EfiKeyTwo,\r
+  EfiKeyThree,\r
+  EfiKeyCapsLock,\r
+  EfiKeyC1,\r
+  EfiKeyC2,\r
+  EfiKeyC3,\r
+  EfiKeyC4,\r
+  EfiKeyC5,\r
+  EfiKeyC6,\r
+  EfiKeyC7,\r
+  EfiKeyC8,\r
+  EfiKeyC9,\r
+  EfiKeyC10,\r
+  EfiKeyC11,\r
+  EfiKeyC12,\r
+  EfiKeyFour,\r
+  EfiKeyFive,\r
+  EfiKeySix,\r
+  EfiKeyPlus,\r
+  EfiKeyTab,\r
+  EfiKeyD1,\r
+  EfiKeyD2,\r
+  EfiKeyD3,\r
+  EfiKeyD4,\r
+  EfiKeyD5,\r
+  EfiKeyD6,\r
+  EfiKeyD7,\r
+  EfiKeyD8,\r
+  EfiKeyD9,\r
+  EfiKeyD10,\r
+  EfiKeyD11,\r
+  EfiKeyD12,\r
+  EfiKeyD13,\r
+  EfiKeyDel,\r
+  EfiKeyEnd,\r
+  EfiKeyPgDn,\r
+  EfiKeySeven,\r
+  EfiKeyEight,\r
+  EfiKeyNine,\r
+  EfiKeyE0,\r
+  EfiKeyE1,\r
+  EfiKeyE2,\r
+  EfiKeyE3,\r
+  EfiKeyE4,\r
+  EfiKeyE5,\r
+  EfiKeyE6,\r
+  EfiKeyE7,\r
+  EfiKeyE8,\r
+  EfiKeyE9,\r
+  EfiKeyE10,\r
+  EfiKeyE11,\r
+  EfiKeyE12,\r
+  EfiKeyBackSpace,\r
+  EfiKeyIns,\r
+  EfiKeyHome,\r
+  EfiKeyPgUp,\r
+  EfiKeyNLck,\r
+  EfiKeySlash,\r
+  EfiKeyAsterisk,\r
+  EfiKeyMinus,\r
+  EfiKeyEsc,\r
+  EfiKeyF1,\r
+  EfiKeyF2,\r
+  EfiKeyF3,\r
+  EfiKeyF4,\r
+  EfiKeyF5,\r
+  EfiKeyF6,\r
+  EfiKeyF7,\r
+  EfiKeyF8,\r
+  EfiKeyF9,\r
+  EfiKeyF10,\r
+  EfiKeyF11,\r
+  EfiKeyF12,\r
+  EfiKeyPrint,\r
+  EfiKeySLck,\r
+  EfiKeyPause\r
+} EFI_KEY;\r
+\r
+typedef struct {\r
+  EFI_KEY Key;\r
+  CHAR16  Unicode;\r
+  CHAR16  ShiftedUnicode;\r
+  CHAR16  AltGrUnicode;\r
+  CHAR16  ShiftedAltGrUnicode;\r
+  UINT16  Modifier;\r
+} EFI_KEY_DESCRIPTOR;\r
+\r
+//\r
+// This structure allows a sparse set of keys to be redefined\r
+// or a complete redefinition of the keyboard layout.  Most\r
+// keyboards have a lot of commonality in their layouts, therefore\r
+// only defining those keys that need to change from the default\r
+// minimizes the passed in information.\r
+//\r
+// Additionally, when an update occurs, the active keyboard layout\r
+// will be switched to the newly updated keyboard layout.  This\r
+// allows for situations that when a keyboard layout driver is\r
+// loaded as part of system initialization, the system will default\r
+// the keyboard behavior to the new layout.\r
+//\r
+// Each call to update the keyboard mapping should contain the\r
+// complete set of key descriptors to be updated, since every\r
+// call to the HII which contains an EFI_HII_KEYBOARD_PACK will\r
+// wipe the previous set of overrides.  A call to\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  EFI_KEY_DESCRIPTOR  *Descriptor;\r
+  UINT8               DescriptorCount;\r
+} EFI_HII_KEYBOARD_PACK;\r
+\r
+//\r
+// The EFI_HII_PACKAGES can contain different types of packages just\r
+// after the structure as inline data.\r
+//\r
+typedef struct {\r
+  UINTN     NumberOfPackages;\r
+  EFI_GUID  *GuidId;\r
+  //\r
+  // EFI_HII_HANDLE_PACK    *HandlePack;        // Only one pack.\r
+  // EFI_HII_IFR_PACK       *IfrPack;           // Only one pack.\r
+  // EFI_HII_FONT_PACK      *FontPack[];        // Multiple packs ok\r
+  // EFI_HII_STRING_PACK    *StringPack[];      // Multiple packs ok\r
+  // EFI_HII_KEYBOARD_PACK  *KeyboardPack[];    // Multiple packs ok\r
+  //\r
+} EFI_HII_PACKAGES;\r
+\r
+typedef struct _EFI_HII_VARIABLE_PACK_LIST {\r
+  struct _EFI_HII_VARIABLE_PACK_LIST   *NextVariablePack;\r
+  EFI_HII_VARIABLE_PACK                *VariablePack;\r
+} EFI_HII_VARIABLE_PACK_LIST;\r
+\r
+#pragma pack()\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_PACK) (\r
+  IN  EFI_HII_PROTOCOL    * This,\r
+  IN  EFI_HII_PACKAGES    * Packages,\r
+  OUT EFI_HII_HANDLE      * Handle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_REMOVE_PACK) (\r
+  IN EFI_HII_PROTOCOL    *This,\r
+  IN EFI_HII_HANDLE      Handle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_FIND_HANDLES) (\r
+  IN     EFI_HII_PROTOCOL *This,\r
+  IN OUT UINT16           *HandleBufferLength,\r
+  OUT    EFI_HII_HANDLE   *Handle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_EXPORT) (\r
+  IN     EFI_HII_PROTOCOL *This,\r
+  IN     EFI_HII_HANDLE   Handle,\r
+  IN OUT UINTN            *BufferSize,\r
+  OUT    VOID             *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_RESET_STRINGS) (\r
+  IN     EFI_HII_PROTOCOL   *This,\r
+  IN     EFI_HII_HANDLE     Handle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_TEST_STRING) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     CHAR16            *StringToTest,\r
+  IN OUT UINT32            *FirstMissing,\r
+  OUT    UINT32            *GlyphBufferSize\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_GLYPH) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     CHAR16            *Source,\r
+  IN OUT UINT16            *Index,\r
+  OUT    UINT8             **GlyphBuffer,\r
+  OUT    UINT16            *BitWidth,\r
+  IN OUT UINT32            *InternalStatus\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GLYPH_TO_BLT) (\r
+  IN     EFI_HII_PROTOCOL               *This,\r
+  IN     UINT8                          *GlyphBuffer,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,\r
+  IN     UINTN                          Count,\r
+  IN     UINTN                          Width,\r
+  IN     UINTN                          Height,\r
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_STRING) (\r
+  IN     EFI_HII_PROTOCOL      *This,\r
+  IN     CHAR16                *Language,\r
+  IN     EFI_HII_HANDLE        Handle,\r
+  IN OUT STRING_REF            *Reference,\r
+  IN     CHAR16                *NewString\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) (\r
+  IN  EFI_HII_PROTOCOL    *This,\r
+  IN  EFI_HII_HANDLE      Handle,\r
+  OUT EFI_STRING          *LanguageString\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) (\r
+  IN  EFI_HII_PROTOCOL    *This,\r
+  IN  EFI_HII_HANDLE      Handle,\r
+  IN  CHAR16              *PrimaryLanguage,\r
+  OUT EFI_STRING          *LanguageString\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_STRING) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     STRING_REF        Token,\r
+  IN     BOOLEAN           Raw,\r
+  IN     CHAR16            *LanguageString,\r
+  IN OUT UINTN             *BufferLength,\r
+  OUT    EFI_STRING        StringBuffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_LINE) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     STRING_REF        Token,\r
+  IN OUT UINT16            *Index,\r
+  IN     UINT16            LineWidth,\r
+  IN     CHAR16            *LanguageString,\r
+  IN OUT UINT16            *BufferLength,\r
+  OUT    EFI_STRING        StringBuffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_FORMS) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     EFI_FORM_ID       FormId,\r
+  IN OUT UINTN             *BufferLength,\r
+  OUT    UINT8             *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) (\r
+  IN     EFI_HII_PROTOCOL           *This,\r
+  IN     EFI_HII_HANDLE             Handle,\r
+  IN     UINTN                      DefaultMask,\r
+  OUT    EFI_HII_VARIABLE_PACK_LIST **VariablePackList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_UPDATE_FORM) (\r
+  IN EFI_HII_PROTOCOL     *This,\r
+  IN EFI_HII_HANDLE       Handle,\r
+  IN EFI_FORM_LABEL       Label,\r
+  IN BOOLEAN              AddData,\r
+  IN EFI_HII_UPDATE_DATA  *Data\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (\r
+  IN     EFI_HII_PROTOCOL    * This,\r
+  OUT    UINT16              *DescriptorCount,\r
+  OUT    EFI_KEY_DESCRIPTOR  * Descriptor\r
+  );\r
+\r
+typedef struct _EFI_HII_PROTOCOL {\r
+  EFI_HII_NEW_PACK            NewPack;\r
+  EFI_HII_REMOVE_PACK         RemovePack;\r
+  EFI_HII_FIND_HANDLES        FindHandles;\r
+  EFI_HII_EXPORT              ExportDatabase;\r
+\r
+  EFI_HII_TEST_STRING         TestString;\r
+  EFI_HII_GET_GLYPH           GetGlyph;\r
+  EFI_HII_GLYPH_TO_BLT        GlyphToBlt;\r
+\r
+  EFI_HII_NEW_STRING          NewString;\r
+  EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;\r
+  EFI_HII_GET_SEC_LANGUAGES   GetSecondaryLanguages;\r
+  EFI_HII_GET_STRING          GetString;\r
+  EFI_HII_RESET_STRINGS       ResetStrings;\r
+  EFI_HII_GET_LINE            GetLine;\r
+  EFI_HII_GET_FORMS           GetForms;\r
+  EFI_HII_GET_DEFAULT_IMAGE   GetDefaultImage;\r
+  EFI_HII_UPDATE_FORM         UpdateForm;\r
+\r
+  EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;\r
+} EFI_HII_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiHiiProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c
new file mode 100644 (file)
index 0000000..b7c8ae9
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    IdeControllerInit.c\r
+    \r
+Abstract:\r
+\r
+    EFI IDE Controller Init Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (IdeControllerInit)\r
+\r
+EFI_GUID  gEfiIdeControllerInitProtocolGuid = EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiIdeControllerInitProtocolGuid, "IDE Controller Init Protocol", "Platform IDE Init Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
new file mode 100644 (file)
index 0000000..06df019
--- /dev/null
@@ -0,0 +1,348 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    IdeControllerInit.h\r
+    \r
+Abstract:\r
+\r
+    EFI Platform IDE Init Protocol\r
+\r
+Revision History\r
+        \r
+        0.01 - Draft, 5-01-2002\r
+        Add Atapi6 Identify structure definition, 8-14-2002\r
+\r
+--*/\r
+\r
+#ifndef _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H\r
+#define _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H\r
+\r
+//\r
+// Global ID for the EFI Platform IDE Protocol GUID\r
+//\r
+#define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \\r
+  { 0xa1e37052, 0x80d9, 0x4e65, 0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9 }\r
+\r
+////////////////////////////////////////////////////////////////////////////////////////\r
+// Forward reference, ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_IDE_CONTROLLER_INIT_PROTOCOL);\r
+\r
+//\r
+//////////////////////////////////////////////////////////////////////////////////////////\r
+// EFI_IDE_BUS_ENUMERATION_PHASE\r
+// EFI_IDE_CONTROLLER_ENUM_PHASE\r
+//\r
+typedef enum{\r
+  EfiIdeBeforeChannelEnumeration,\r
+  EfiIdeAfterChannelEnumeration,\r
+  EfiIdeBeforeChannelReset,\r
+  EfiIdeAfterChannelReset,\r
+  EfiIdeBusBeforeDevicePresenceDetection,\r
+  EfiIdeBusAfterDevicePresenceDetection,\r
+  EfiIdeResetMode,\r
+  EfiIdeBusPhaseMaximum\r
+} EFI_IDE_CONTROLLER_ENUM_PHASE;\r
+\r
+//\r
+//******************************************************\r
+// EFI_ATA_EXT_TRANSFER_PROTOCOL\r
+//******************************************************\r
+//\r
+// This extended mode describes the SATA physical protocol.\r
+// SATA physical layers can operate at different speeds. \r
+// These speeds are defined below. Various PATA protocols \r
+// and associated modes are not applicable to SATA devices.\r
+//\r
+\r
+typedef enum {\r
+  EfiAtaSataTransferProtocol  \r
+} EFI_ATA_EXT_TRANSFER_PROTOCOL;\r
+\r
+#define  EFI_SATA_AUTO_SPEED  0\r
+#define  EFI_SATA_GEN1_SPEED  1\r
+#define  EFI_SATA_GEN2_SPEED  2\r
+\r
+//\r
+//*******************************************************\r
+// EFI_IDE_CABLE_TYPE\r
+//*******************************************************\r
+//\r
+typedef enum {\r
+  EfiIdeCableTypeUnknown,\r
+  EfiIdeCableType40pin,\r
+  EfiIdeCableType80Pin,\r
+  EfiIdeCableTypeSerial,\r
+  EfiIdeCableTypeMaximum\r
+} EFI_IDE_CABLE_TYPE;\r
+\r
+//\r
+//******************************************************\r
+// EFI_ATA_MODE\r
+//******************************************************\r
+//\r
+typedef struct {\r
+  BOOLEAN  Valid;\r
+  UINT32       Mode; \r
+} EFI_ATA_MODE;\r
+\r
+//\r
+//******************************************************\r
+// EFI_ATA_EXTENDED_MODE\r
+//******************************************************\r
+//\r
+typedef struct {\r
+  EFI_ATA_EXT_TRANSFER_PROTOCOL  TransferProtocol;\r
+  UINT32                         Mode;\r
+} EFI_ATA_EXTENDED_MODE;\r
+\r
+//\r
+//******************************************************\r
+// EFI_ATA_COLLECTIVE_MODE\r
+//******************************************************\r
+//\r
+typedef struct {\r
+  EFI_ATA_MODE           PioMode; \r
+  EFI_ATA_MODE           SingleWordDmaMode;\r
+  EFI_ATA_MODE           MultiWordDmaMode;\r
+  EFI_ATA_MODE           UdmaMode;\r
+  UINT32                         ExtModeCount;\r
+  EFI_ATA_EXTENDED_MODE  ExtMode[1]; \r
+} EFI_ATA_COLLECTIVE_MODE;\r
+\r
+//\r
+//*******************************************************\r
+// EFI_ATA_IDENTIFY_DATA\r
+//*******************************************************\r
+//\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {   \r
+  UINT16  config;             // General Configuration\r
+  UINT16  cylinders;          // Number of Cylinders\r
+  UINT16  reserved_2;\r
+  UINT16  heads;              //Number of logical heads\r
+  UINT16  vendor_data1;\r
+  UINT16  vendor_data2;\r
+  UINT16  sectors_per_track;\r
+  UINT16  vendor_specific_7_9[3];\r
+  CHAR8   SerialNo[20];       // ASCII \r
+  UINT16  vendor_specific_20_21[2]; \r
+  UINT16  ecc_bytes_available;   \r
+  CHAR8   FirmwareVer[8];     // ASCII \r
+  CHAR8   ModelName[40];      // ASCII   \r
+  UINT16  multi_sector_cmd_max_sct_cnt;\r
+  UINT16  reserved_48;\r
+  UINT16  capabilities;\r
+  UINT16  reserved_50;    \r
+  UINT16  pio_cycle_timing;   \r
+  UINT16  reserved_52;            \r
+  UINT16  field_validity;    \r
+  UINT16  current_cylinders;\r
+  UINT16  current_heads;\r
+  UINT16  current_sectors;   \r
+  UINT16  CurrentCapacityLsb;\r
+  UINT16  CurrentCapacityMsb;    \r
+  UINT16  reserved_59;    \r
+  UINT16  user_addressable_sectors_lo;\r
+  UINT16  user_addressable_sectors_hi;\r
+  UINT16  reserved_62;    \r
+  UINT16  multi_word_dma_mode;   \r
+  UINT16  advanced_pio_modes;\r
+  UINT16  min_multi_word_dma_cycle_time;\r
+  UINT16  rec_multi_word_dma_cycle_time;\r
+  UINT16  min_pio_cycle_time_without_flow_control;\r
+  UINT16  min_pio_cycle_time_with_flow_control;\r
+  UINT16  reserved_69_79[11];    \r
+  UINT16  major_version_no;\r
+  UINT16  minor_version_no;\r
+  UINT16  command_set_supported_82; // word 82\r
+  UINT16  command_set_supported_83; // word 83\r
+  UINT16  command_set_feature_extn; // word 84\r
+  UINT16  command_set_feature_enb_85; // word 85\r
+  UINT16  command_set_feature_enb_86; // word 86\r
+  UINT16  command_set_feature_default; // word 87\r
+  UINT16  ultra_dma_mode; // word 88\r
+  UINT16  reserved_89_127[39];\r
+  UINT16  security_status;\r
+  UINT16  vendor_data_129_159[31];\r
+  UINT16  reserved_160_255[96];\r
+} EFI_ATA_IDENTIFY_DATA;\r
+\r
+#pragma pack()\r
+//\r
+//*******************************************************\r
+// EFI_ATAPI_IDENTIFY_DATA\r
+//*******************************************************\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+    UINT16  config;             // General Configuration\r
+    UINT16  obsolete_1;\r
+    UINT16  specific_config;\r
+    UINT16  obsolete_3;   \r
+    UINT16  retired_4_5[2];\r
+    UINT16  obsolete_6;   \r
+    UINT16  cfa_reserved_7_8[2];\r
+    UINT16  retired_9;\r
+    CHAR8   SerialNo[20];       // ASCII \r
+    UINT16  retired_20_21[2];\r
+    UINT16  obsolete_22;\r
+    CHAR8   FirmwareVer[8];     // ASCII \r
+    CHAR8   ModelName[40];      // ASCII \r
+    UINT16  multi_sector_cmd_max_sct_cnt;\r
+    UINT16  reserved_48;\r
+    UINT16  capabilities_49;\r
+    UINT16  capabilities_50;\r
+    UINT16  obsolete_51_52[2];   \r
+    UINT16  field_validity;\r
+    UINT16  obsolete_54_58[5];\r
+    UINT16  mutil_sector_setting;\r
+    UINT16  user_addressable_sectors_lo;\r
+    UINT16  user_addressable_sectors_hi;\r
+    UINT16  obsolete_62;\r
+    UINT16  multi_word_dma_mode;\r
+    UINT16  advanced_pio_modes;\r
+    UINT16  min_multi_word_dma_cycle_time;\r
+    UINT16  rec_multi_word_dma_cycle_time;\r
+    UINT16  min_pio_cycle_time_without_flow_control;\r
+    UINT16  min_pio_cycle_time_with_flow_control;\r
+    UINT16  reserved_69_74[6];\r
+    UINT16  queue_depth;\r
+    UINT16  reserved_76_79[4];\r
+    UINT16  major_version_no;\r
+    UINT16  minor_version_no;\r
+    UINT16  cmd_set_support_82;\r
+    UINT16  cmd_set_support_83;\r
+    UINT16  cmd_feature_support;\r
+    UINT16  cmd_feature_enable_85;\r
+    UINT16  cmd_feature_enable_86;\r
+    UINT16  cmd_feature_default;\r
+    UINT16  ultra_dma_select;\r
+    UINT16  time_required_for_sec_erase;\r
+    UINT16  time_required_for_enhanced_sec_erase;\r
+    UINT16  current_advanced_power_mgmt_value;\r
+    UINT16  master_pwd_revison_code;\r
+    UINT16  hardware_reset_result;\r
+    UINT16  current_auto_acoustic_mgmt_value;\r
+    UINT16  reserved_95_99[5];\r
+    UINT16  max_user_lba_for_48bit_addr[4];\r
+    UINT16  reserved_104_126[23];\r
+    UINT16  removable_media_status_notification_support;\r
+    UINT16  security_status;\r
+    UINT16  vendor_data_129_159[31];\r
+    UINT16  cfa_power_mode;\r
+    UINT16  cfa_reserved_161_175[15];\r
+    UINT16  current_media_serial_no[30];\r
+    UINT16  reserved_206_254[49];\r
+    UINT16  integrity_word;\r
+} EFI_ATAPI_IDENTIFY_DATA;\r
+\r
+#pragma pack()\r
+//\r
+//*******************************************************\r
+// EFI_IDENTIFY_DATA\r
+//*******************************************************\r
+//\r
+typedef union {\r
+  EFI_ATA_IDENTIFY_DATA       AtaData;\r
+  EFI_ATAPI_IDENTIFY_DATA    AtapiData;\r
+} EFI_IDENTIFY_DATA; \r
+\r
+#define   EFI_ATAPI_DEVICE_IDENTIFY_DATA  0x8000\r
+\r
+//\r
+/////////////////////////////////////////////////////////////////////////////////////////\r
+// Function prototype declaration, for ANSI compatability\r
+//\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_GET_CHANNEL_INFO) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+  IN  UINT8                           Channel, \r
+  OUT BOOLEAN                         *Enabled,\r
+  OUT UINT8                           *MaxDevices\r
+\r
+);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_NOTIFY_PHASE) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL  *This,\r
+  IN EFI_IDE_CONTROLLER_ENUM_PHASE     Phase,\r
+  IN UINT8                             Channel\r
+);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_SUBMIT_DATA) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+  IN  UINT8                           Channel,\r
+  IN  UINT8                           Device,\r
+  IN  EFI_IDENTIFY_DATA               *IdentifyData\r
+);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_DISQUALIFY_MODE) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+  IN  UINT8                           Channel,\r
+  IN  UINT8                           Device,\r
+  IN  EFI_ATA_COLLECTIVE_MODE         *BadModes\r
+);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_CALCULATE_MODE) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+  IN  UINT8                           Channel,\r
+  IN  UINT8                           Device,\r
+  OUT EFI_ATA_COLLECTIVE_MODE         **SupportedModes\r
+);\r
+\r
+//\r
+// ?? What happen to EFI_IDE_CONTROLLER_SET_TIMING ???\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IDE_CONTROLLER_SET_TIMING) (\r
+  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
+  IN  UINT8                           Channel,\r
+  IN  UINT8                           Device,\r
+  IN  EFI_ATA_COLLECTIVE_MODE         *Modes\r
+);\r
+\r
+//\r
+////////////////////////////////////////////////////////////////////////////////////////////////////\r
+// Interface structure \r
+// EFI_IDE_CONTROLLER_INIT_PROTOCOL protocol provides the chipset specific information to the IDE bus driver.\r
+// An IDE Bus driver wants to manage an IDE bus and possible IDE devices will have to retrieve the \r
+// EFI_IDE_CONTROLLER_INIT_PROTOCOL instances.\r
+//\r
+typedef struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL {\r
+  EFI_IDE_CONTROLLER_GET_CHANNEL_INFO    GetChannelInfo;\r
+  EFI_IDE_CONTROLLER_NOTIFY_PHASE        NotifyPhase;\r
+  EFI_IDE_CONTROLLER_SUBMIT_DATA         SubmitData;\r
+  EFI_IDE_CONTROLLER_DISQUALIFY_MODE     DisqualifyMode;\r
+  EFI_IDE_CONTROLLER_CALCULATE_MODE      CalculateMode;\r
+  EFI_IDE_CONTROLLER_SET_TIMING          SetTiming;\r
+  BOOLEAN                                                        EnumAll;\r
+  UINT8                                                               ChannelCount; \r
+} EFI_IDE_CONTROLLER_INIT_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiIdeControllerInitProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c
new file mode 100644 (file)
index 0000000..85ad37b
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IncompatiblePciDeviceSupport.c\r
+    \r
+Abstract:\r
+\r
+    EFI Incompatible PCI Device Support Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport)\r
+\r
+EFI_GUID  gEfiIncompatiblePciDeviceSupportProtocolGuid = EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiIncompatiblePciDeviceSupportProtocolGuid, "Incompatible PCI Device Support Protocol",\r
+      "Tiano Incompatible PCI Device Support Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h
new file mode 100644 (file)
index 0000000..01179e8
--- /dev/null
@@ -0,0 +1,55 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IncompatiblePciDeviceSupport.h\r
+    \r
+Abstract:\r
+\r
+    EFI Incompatible PCI Device Support Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_\r
+#define _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_\r
+\r
+#define EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID \\r
+        {0xeb23f55a, 0x7863, 0x4ac2, 0x8d, 0x3d, 0x95, 0x65, 0x35, 0xde, 0x03, 0x75}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT);\r
+\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE) (\r
+  IN EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT   *This,\r
+  IN  UINTN                                         VendorId,\r
+  IN  UINTN                                         DeviceId,\r
+  IN  UINTN                                         Revision,\r
+  IN  UINTN                                         SubVendorId,OPTIONAL\r
+  IN  UINTN                                         SubDeviceId,OPTIONAL\r
+  OUT VOID                                          *Configuration\r
+); \r
+\r
+\r
+//\r
+// Interface structure for the Incompatible PCI Device Support Protocol\r
+//\r
+typedef struct _EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT {\r
+  EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE      CheckDevice;  \r
+} EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiIncompatiblePciDeviceSupportProtocolGuid;\r
+  \r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c
new file mode 100644 (file)
index 0000000..bd67460
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+  \r
+    Legacy8259.c\r
+    \r
+Abstract:\r
+\r
+  EFI Legacy Region Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Legacy8259)\r
+\r
+EFI_GUID  gEfiLegacy8259ProtocolGuid = EFI_LEGACY_8259_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacy8259ProtocolGuid, "Legacy 8259 Protocol", "Legacy 8259 Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h
new file mode 100644 (file)
index 0000000..3b7c826
--- /dev/null
@@ -0,0 +1,317 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Legacy8259.h\r
+    \r
+Abstract:\r
+\r
+  This protocol abstracts the 8259 interrupt controller. This includes\r
+  PCI IRQ routing need to program the PCI Interrupt Line register.\r
+\r
+Revision History\r
+\r
+  The EFI Legacy 8259 Protocol is compliant with CSM spec 0.96.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_8259_H\r
+#define _EFI_LEGACY_8259_H\r
+\r
+#define EFI_LEGACY_8259_PROTOCOL_GUID \\r
+  { \\r
+    0x38321dba, 0x4fe0, 0x4e17, 0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_8259_PROTOCOL);\r
+\r
+typedef enum {\r
+  Efi8259Irq0,\r
+  Efi8259Irq1,\r
+  Efi8259Irq2,\r
+  Efi8259Irq3,\r
+  Efi8259Irq4,\r
+  Efi8259Irq5,\r
+  Efi8259Irq6,\r
+  Efi8259Irq7,\r
+  Efi8259Irq8,\r
+  Efi8259Irq9,\r
+  Efi8259Irq10,\r
+  Efi8259Irq11,\r
+  Efi8259Irq12,\r
+  Efi8259Irq13,\r
+  Efi8259Irq14,\r
+  Efi8259Irq15,\r
+  Efi8259IrqMax\r
+} EFI_8259_IRQ;\r
+\r
+typedef enum {\r
+  Efi8259LegacyMode,\r
+  Efi8259ProtectedMode,\r
+  Efi8259MaxMode\r
+} EFI_8259_MODE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_SET_VECTOR_BASE) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  UINT8                             MasterBase,\r
+  IN  UINT8                             SlaveBase\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for\r
+    the legacy mode mask and the protected mode mask. The base address for the 8259\r
+    is different for legacy and protected mode, so two masks are required.\r
+\r
+  Arguments:\r
+    This          - Protocol instance pointer.\r
+    MasterBase    - The base vector for the Master PIC in the 8259 controller\r
+    Slavebase     - The base vector for the Master PIC in the 8259 controller\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - The new bases were programmed\r
+    EFI_DEVICE_ERROR  - A device erro occured programming the vector bases\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_GET_MASK) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  OUT UINT16                            *LegacyMask, OPTIONAL\r
+  OUT UINT16                            *LegacyEdgeLevel, OPTIONAL\r
+  OUT UINT16                            *ProtectedMask, OPTIONAL\r
+  OUT UINT16                            *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for\r
+    the legacy mode mask and the protected mode mask. The base address for the 8259\r
+    is different for legacy and protected mode, so two masks are required.\r
+\r
+  Arguments:\r
+    This               - Protocol instance pointer.\r
+    LegacyMask         - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    LegacyEdgeLevel    - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    ProtectedMask      - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 status returned\r
+    EFI_DEVICE_ERROR  - Error reading 8259\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_SET_MASK) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  UINT16                            *LegacyMask, OPTIONAL\r
+  IN  UINT16                            *LegacyEdgeLevel, OPTIONAL\r
+  IN  UINT16                            *ProtectedMask, OPTIONAL\r
+  IN  UINT16                            *ProtectedEdgeLevel OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for\r
+    the legacy mode mask and the protected mode mask. The base address for the 8259\r
+    is different for legacy and protected mode, so two masks are required.\r
+    Also set the edge/level masks.\r
+\r
+  Arguments:\r
+    This               - Protocol instance pointer.\r
+    LegacyMask         - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    LegacyEdgeLevel    - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    ProtectedMask      - Bit 0 is Irq0 - Bit 15 is Irq15\r
+    ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 status returned\r
+    EFI_DEVICE_ERROR  - Error reading 8259\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_SET_MODE) (\r
+  IN EFI_LEGACY_8259_PROTOCOL         * This,\r
+  IN  EFI_8259_MODE                   Mode,\r
+  IN  UINT16                          *Mask, OPTIONAL\r
+  IN  UINT16                          *EdgeLevel OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set the 8259 mode of operation. The base address for the 8259 is different for\r
+    legacy and protected mode. The legacy mode requires the master 8259 to have a\r
+    master base of 0x08 and the slave base of 0x70. The protected mode base locations\r
+    are not defined. Interrupts must be masked by the caller before this function\r
+    is called. The interrupt mask from the current mode is saved. The interrupt \r
+    mask for the new mode is Mask, or if Mask does not exist the previously saved\r
+    mask is used.\r
+\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    Mode      - Mode of operation. i.e. real mode or protected mode\r
+    Mask      - Optional interupt mask for the new mode.\r
+    EdgeLevel - Optional trigger mask for the new mode.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - 8259 programmed\r
+    EFI_DEVICE_ERROR  - Error writting to 8259\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_GET_VECTOR) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  EFI_8259_IRQ                      Irq,\r
+  OUT UINT8                             *Vector\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Convert from IRQ to processor interrupt vector number.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+    Vector  - Processor vector number that matches Irq\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Vector matching Irq is returned\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_ENABLE_IRQ) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  EFI_8259_IRQ                      Irq,\r
+  IN  BOOLEAN                           LevelTriggered\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Enable Irq by unmasking interrupt in 8259\r
+\r
+  Arguments:\r
+    This           - Protocol instance pointer.\r
+    Irq            - 8259 IRQ0 - IRQ15\r
+    LevelTriggered - TRUE if level triggered.  FALSE if edge triggered.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Irq enabled on 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_DISABLE_IRQ) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  EFI_8259_IRQ                      Irq\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Disable Irq by masking interrupt in 8259\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Irq disabled on 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_GET_INTERRUPT_LINE) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  EFI_HANDLE                        PciHandle,\r
+  OUT UINT8                             *Vector\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    PciHandle represents a PCI config space of a PCI function. Vector \r
+    represents Interrupt Pin (from PCI config space) and it is the data\r
+    that is programmed into the Interrupt Line (from the PCI config space)\r
+    register.\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    PciHandle - PCI function to return vector for \r
+    Vector    - Vector for fucntion that matches \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - A valid Vector is returned\r
+    EFI_INVALID_PARAMETER - PciHandle not valid\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_8259_END_OF_INTERRUPT) (\r
+  IN EFI_LEGACY_8259_PROTOCOL           * This,\r
+  IN  EFI_8259_IRQ                      Irq\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Send an EOI to 8259\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    Irq     - 8259 IRQ0 - IRQ15\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - EOI successfully sent to 8259\r
+    EFI_INVALID_PARAMETER - Irq not valid\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_LEGACY_8259_PROTOCOL {\r
+  EFI_LEGACY_8259_SET_VECTOR_BASE     SetVectorBase;\r
+  EFI_LEGACY_8259_GET_MASK            GetMask;\r
+  EFI_LEGACY_8259_SET_MASK            SetMask;\r
+  EFI_LEGACY_8259_SET_MODE            SetMode;\r
+  EFI_LEGACY_8259_GET_VECTOR          GetVector;\r
+  EFI_LEGACY_8259_ENABLE_IRQ          EnableIrq;\r
+  EFI_LEGACY_8259_DISABLE_IRQ         DisableIrq;\r
+  EFI_LEGACY_8259_GET_INTERRUPT_LINE  GetInterruptLine;\r
+  EFI_LEGACY_8259_END_OF_INTERRUPT    EndOfInterrupt;\r
+} EFI_LEGACY_8259_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacy8259ProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c
new file mode 100644 (file)
index 0000000..b0bdb32
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LegacyBios.c\r
+    \r
+Abstract:\r
+\r
+  EFI Legacy BIOS Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)\r
+\r
+EFI_GUID  gEfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacyBiosProtocolGuid, "Legacy BIOS Protocol", "Legacy BIOS Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h
new file mode 100644 (file)
index 0000000..11b1c24
--- /dev/null
@@ -0,0 +1,701 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LegacyBios.h\r
+    \r
+Abstract:\r
+\r
+  The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage\r
+  under EFI and Legacy OS boot.\r
+\r
+  Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow \r
+  well known naming conventions.\r
+\r
+  Thunk - A thunk is a transition from one processor mode to another. A Thunk\r
+          is a transition from native EFI mode to 16-bit mode. A reverse thunk\r
+          would be a transition from 16-bit mode to native EFI mode.\r
+\r
+\r
+  Note: Note: Note: Note: Note: Note: Note:\r
+\r
+  You most likely should not use this protocol! Find the EFI way to solve the\r
+  problem to make your code portable\r
+\r
+  Note: Note: Note: Note: Note: Note: Note:\r
+\r
+Revision History\r
+\r
+  The EFI Legacy BIOS Protocol is compliant with CSM spec 0.96.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_BIOS_H\r
+#define _EFI_LEGACY_BIOS_H\r
+\r
+#define EFI_LEGACY_BIOS_PROTOCOL_GUID \\r
+  { \\r
+    0xdb9a1e3d, 0x45cb, 0x4abb, 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PROTOCOL);\r
+\r
+//\r
+// Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form\r
+//\r
+#define EFI_SEGMENT(_Adr)     (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
+#define EFI_OFFSET(_Adr)      (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
+#define BYTE_GRANULARITY      0x01\r
+#define WORD_GRANULARITY      0x02\r
+#define DWORD_GRANULARITY     0x04\r
+#define QWORD_GRANULARITY     0x08\r
+#define PARAGRAPH_GRANULARITY 0x10\r
+\r
+#define CARRY_FLAG            0x01\r
+\r
+typedef struct {\r
+  UINT32 CF:1;\r
+  UINT32 Reserved1:1;\r
+  UINT32 PF:1;\r
+  UINT32 Reserved2:1;\r
+  UINT32 AF:1;\r
+  UINT32 Reserved3:1;\r
+  UINT32 ZF:1;\r
+  UINT32 SF:1;\r
+  UINT32 TF:1;\r
+  UINT32 IF:1;\r
+  UINT32 DF:1;\r
+  UINT32 OF:1;\r
+  UINT32 IOPL:2;\r
+  UINT32 NT:1;\r
+  UINT32 Reserved4:2;\r
+  UINT32 VM:1;\r
+  UINT32 Reserved5:14;\r
+} EFI_EFLAGS_REG;\r
+\r
+typedef struct {\r
+  UINT16  CF : 1;\r
+  UINT16  Reserved1 : 1;\r
+  UINT16  PF : 1;\r
+  UINT16  Reserved2 : 1;\r
+  UINT16  AF : 1;\r
+  UINT16  Reserved3 : 1;\r
+  UINT16  ZF : 1;\r
+  UINT16  SF : 1;\r
+  UINT16  TF : 1;\r
+  UINT16  IF : 1;\r
+  UINT16  DF : 1;\r
+  UINT16  OF : 1;\r
+  UINT16  IOPL : 2;\r
+  UINT16  NT : 1;\r
+  UINT16  Reserved4 : 1;\r
+} EFI_FLAGS_REG;\r
+\r
+typedef struct {\r
+  UINT32         EAX;\r
+  UINT32         EBX;\r
+  UINT32         ECX;\r
+  UINT32         EDX;\r
+  UINT32         ESI;\r
+  UINT32         EDI;\r
+  EFI_EFLAGS_REG EFlags;\r
+  UINT16         ES;\r
+  UINT16         CS;\r
+  UINT16         SS;\r
+  UINT16         DS;\r
+  UINT16         FS;\r
+  UINT16         GS;\r
+  UINT32         EBP;\r
+  UINT32         ESP;\r
+} EFI_DWORD_REGS;\r
+\r
+typedef struct {\r
+  UINT16        AX;\r
+  UINT16        ReservedAX;\r
+  UINT16        BX;\r
+  UINT16        ReservedBX;\r
+  UINT16        CX;\r
+  UINT16        ReservedCX;\r
+  UINT16        DX;\r
+  UINT16        ReservedDX;\r
+  UINT16        SI;\r
+  UINT16        ReservedSI;\r
+  UINT16        DI;\r
+  UINT16        ReservedDI;\r
+  EFI_FLAGS_REG Flags;\r
+  UINT16        ReservedFlags;\r
+  UINT16        ES;\r
+  UINT16        CS;\r
+  UINT16        SS;\r
+  UINT16        DS;\r
+  UINT16        FS;\r
+  UINT16        GS;\r
+  UINT16        BP;\r
+  UINT16        ReservedBP;\r
+  UINT16        SP;\r
+  UINT16        ReservedSP;\r
+} EFI_WORD_REGS;\r
+\r
+typedef struct {\r
+  UINT8   AL;\r
+  UINT8   AH;\r
+  UINT16  ReservedAX;\r
+  UINT8   BL;\r
+  UINT8   BH;\r
+  UINT16  ReservedBX;\r
+  UINT8   CL;\r
+  UINT8   CH;\r
+  UINT16  ReservedCX;\r
+  UINT8   DL;\r
+  UINT8   DH;\r
+  UINT16  ReservedDX;\r
+} EFI_BYTE_REGS;\r
+\r
+typedef union {\r
+  EFI_DWORD_REGS E;\r
+  EFI_WORD_REGS  X;\r
+  EFI_BYTE_REGS  H;\r
+} EFI_IA32_REGISTER_SET;\r
+\r
+#pragma pack(1)\r
+//\r
+// $EFI table created by Legacy16 code and consumed by EFI Legacy driver\r
+//\r
+typedef struct {\r
+  UINT32  Signature;      // "$EFI"\r
+  UINT8   TableChecksum;\r
+  UINT8   TableLength;\r
+  UINT8   EfiMajorRevision;\r
+  UINT8   EfiMinorRevision;\r
+  UINT8   TableMajorRevision;\r
+  UINT8   TableMinorRevision;\r
+  UINT16  Reserved;\r
+  UINT16  Compatibility16CallSegment;\r
+  UINT16  Compatibility16CallOffset;\r
+\r
+  UINT16  PnPInstallationCheckSegment;\r
+  UINT16  PnPInstallationCheckOffset;\r
+\r
+  UINT32  EfiSystemTable; // IPF - CSM Integration\r
+  UINT32  OemIdStringPointer;\r
+  UINT32  AcpiRsdPtrPointer;\r
+  UINT16  OemRevision;\r
+  UINT32  E820Pointer;\r
+  UINT32  E820Length;\r
+  UINT32  IrqRoutingTablePointer;\r
+  UINT32  IrqRoutingTableLength;\r
+  UINT32  MpTablePtr;\r
+  UINT32  MpTableLength;\r
+  UINT16  OemIntSegment;\r
+  UINT16  OemIntOffset;\r
+  UINT16  Oem32Segment;\r
+  UINT16  Oem32Offset;\r
+  UINT16  Oem16Segment;\r
+  UINT16  Oem16Offset;\r
+  UINT16  TpmSegment;\r
+  UINT16  TpmOffset;\r
+  UINT32  IbvPointer;\r
+  UINT32  PciExpressBase;\r
+  UINT8   LastPciBus;\r
+\r
+} EFI_COMPATIBILITY16_TABLE;\r
+//\r
+// define maximum number of HDD system supports\r
+//\r
+#define MAX_HDD_ENTRIES 0x30\r
+\r
+typedef struct {\r
+  UINT16  Raw[256];\r
+} ATAPI_IDENTIFY;\r
+\r
+//\r
+// HDD_INFO status\r
+//\r
+#define HDD_PRIMARY               0x01\r
+#define HDD_SECONDARY             0x02\r
+#define HDD_MASTER_ATAPI_CDROM    0x04\r
+#define HDD_SLAVE_ATAPI_CDROM     0x08\r
+#define HDD_MASTER_IDE            0x20\r
+#define HDD_SLAVE_IDE             0x40\r
+#define HDD_MASTER_ATAPI_ZIPDISK  0x10\r
+#define HDD_SLAVE_ATAPI_ZIPDISK   0x80\r
+\r
+typedef struct {\r
+  UINT16          Status;\r
+  UINT32          Bus;\r
+  UINT32          Device;\r
+  UINT32          Function;\r
+  UINT16          CommandBaseAddress;\r
+  UINT16          ControlBaseAddress;\r
+  UINT16          BusMasterAddress;\r
+  UINT8           HddIrq;\r
+  ATAPI_IDENTIFY  IdentifyDrive[2];\r
+} HDD_INFO;\r
+\r
+//\r
+// Parties data structures\r
+//\r
+typedef struct {\r
+  UINT8 DirectoryServiceValidity : 1;\r
+  UINT8 RabcaUsedFlag : 1;\r
+  UINT8 ExecuteHddDiagnosticsFlag : 1;\r
+  UINT8 Reserved : 5;\r
+} UDC_ATTRIBUTES;\r
+\r
+typedef struct {\r
+  UDC_ATTRIBUTES  Attributes;\r
+  UINT8           DeviceNumber;\r
+  UINT8           BbsTableEntryNumberForParentDevice;\r
+  UINT8           BbsTableEntryNumberForBoot;\r
+  UINT8           BbsTableEntryNumberForHddDiag;\r
+  UINT8           BeerData[128];\r
+  UINT8           ServiceAreaData[64];\r
+} UD_TABLE;\r
+\r
+//\r
+// define BBS Device Types\r
+//\r
+#define BBS_FLOPPY        0x01\r
+#define BBS_HARDDISK      0x02\r
+#define BBS_CDROM         0x03\r
+#define BBS_PCMCIA        0x04\r
+#define BBS_USB           0x05\r
+#define BBS_EMBED_NETWORK 0x06\r
+#define BBS_BEV_DEVICE    0x80\r
+#define BBS_UNKNOWN       0xff\r
+\r
+typedef struct {\r
+  UINT16  OldPosition : 4;\r
+  UINT16  Reserved1 : 4;\r
+  UINT16  Enabled : 1;\r
+  UINT16  Failed : 1;\r
+  UINT16  MediaPresent : 2;\r
+  UINT16  Reserved2 : 4;\r
+} BBS_STATUS_FLAGS;\r
+\r
+#define MAX_BBS_ENTRIES 0x100\r
+//\r
+// BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to\r
+// be skipped.\r
+// BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before\r
+// priority has been assigned but indicates valid entry.\r
+// BBS_LOWEST_PRIORITY is normally used for removable media with no media\r
+//   inserted. This allows the 16-bit CSM to allocate a drive letter to\r
+//   the device.\r
+// BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign\r
+//   a drive letter to but never boot from.\r
+//\r
+// AdditionalIrq??Handler usage is IBV specific. The fields have been added\r
+// for:\r
+//   1. Saving non-BBS card info about IRQs taken by card.\r
+//   2. For BBS compliant cards that hook IRQs in order to have their SETUP\r
+//      executed.\r
+//\r
+#define BBS_DO_NOT_BOOT_FROM    0xFFFC\r
+#define BBS_LOWEST_PRIORITY     0xFFFD\r
+#define BBS_UNPRIORITIZED_ENTRY 0xFFFE\r
+#define BBS_IGNORE_ENTRY        0xFFFF\r
+\r
+typedef struct {\r
+  UINT16            BootPriority;\r
+  UINT32            Bus;\r
+  UINT32            Device;\r
+  UINT32            Function;\r
+  UINT8             Class;\r
+  UINT8             SubClass;\r
+  UINT16            MfgStringOffset;\r
+  UINT16            MfgStringSegment;\r
+  UINT16            DeviceType;\r
+  BBS_STATUS_FLAGS  StatusFlags;\r
+  UINT16            BootHandlerOffset;\r
+  UINT16            BootHandlerSegment;\r
+  UINT16            DescStringOffset;\r
+  UINT16            DescStringSegment;\r
+  UINT32            InitPerReserved;\r
+  UINT32            AdditionalIrq13Handler;\r
+  UINT32            AdditionalIrq18Handler;\r
+  UINT32            AdditionalIrq19Handler;\r
+  UINT32            AdditionalIrq40Handler;\r
+  UINT8             AssignedDriveNumber;\r
+  UINT32            AdditionalIrq41Handler;\r
+  UINT32            AdditionalIrq46Handler;\r
+  UINT32            IBV1;\r
+  UINT32            IBV2;\r
+} BBS_TABLE;\r
+\r
+#pragma pack()\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_INT86) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  UINT8                           BiosInt,\r
+  IN OUT  EFI_IA32_REGISTER_SET       * Regs\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Thunk to 16-bit real mode and execute a software interrupt with a vector \r
+    of BiosInt. Regs will contain the 16-bit register context on entry and \r
+    exit.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    BiosInt - Processor interrupt vector to invoke\r
+    Reg     - Register contexted passed into (and returned) from thunk to \r
+              16-bit mode\r
+\r
+  Returns:\r
+    FALSE   - Thunk completed, and there were no BIOS errors in the target code.\r
+              See Regs for status.\r
+    TRUE    - There was a BIOS erro in the target code.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_FARCALL86) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  UINT16                          Segment,\r
+  IN  UINT16                          Offset,\r
+  IN  EFI_IA32_REGISTER_SET           * Regs,\r
+  IN  VOID                            *Stack,\r
+  IN  UINTN                           StackSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the \r
+    16-bit register context on entry and exit. Arguments can be passed on \r
+    the Stack argument\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    Segment   - Segemnt of 16-bit mode call\r
+    Offset    - Offset of 16-bit mdoe call\r
+    Reg       - Register contexted passed into (and returned) from thunk to \r
+                16-bit mode\r
+    Stack     - Caller allocated stack used to pass arguments\r
+    StackSize - Size of Stack in bytes\r
+\r
+  Returns:\r
+    FALSE     - Thunk completed, and there were no BIOS errors in the target code.\r
+                See Regs for status.\r
+    TRUE      - There was a BIOS erro in the target code.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  EFI_HANDLE                      PciHandle,\r
+  OUT VOID                            **RomImage, OPTIONAL\r
+  OUT UINTN                           *RomSize, OPTIONAL\r
+  OUT UINTN                           *Flags\r
+\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Test to see if a legacy PCI ROM exists for this device. Optionally return\r
+    the Legacy ROM instance for this PCI device.\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
+    RomImage  - Return the legacy PCI ROM for this device\r
+    RomSize   - Size of ROM Image\r
+    Flags     - Indicates if ROM found and if PC-AT.\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Legacy Option ROM availible for this device\r
+    EFI_UNSUPPORTED  - Legacy Option ROM not supported.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  EFI_HANDLE                      PciHandle,\r
+  IN  VOID                            **RomImage,\r
+  OUT UINTN                           *Flags,\r
+  OUT UINT8                           *DiskStart, OPTIONAL\r
+  OUT UINT8                           *DiskEnd, OPTIONAL\r
+  OUT VOID                            **RomShadowAddress, OPTIONAL\r
+  OUT UINT32                          *ShadowedRomSize OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
+    about how many disks were added by the OPROM and the shadow address and\r
+    size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded.\r
+                This value is NULL if RomImage is non-NULL. This is the normal\r
+                case.\r
+    RomImage  - A PCI PC-AT ROM image. This argument is non-NULL if there is\r
+                no hardware associated with the ROM and thus no PciHandle,\r
+                otherwise is must be NULL.\r
+                Example is PXE base code.\r
+    Flags     - Return Status if ROM was found and if was Legacy OPROM.\r
+    DiskStart - Disk number of first device hooked by the ROM. If DiskStart\r
+                is the same as DiskEnd no disked were hooked.\r
+    DiskEnd   - Disk number of the last device hooked by the ROM.\r
+    RomShadowAddress  - Shadow address of PC-AT ROM\r
+    RomShadowSize     - Size of RomShadowAddress in bytes\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Thunk completed, see Regs for status.\r
+    EFI_INVALID_PARAMETER  - PciHandle not found\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_BOOT) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  BBS_BBS_DEVICE_PATH             * BootOption,\r
+  IN  UINT32                          LoadOptionsSize,\r
+  IN  VOID                            *LoadOptions\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Attempt to legacy boot the BootOption. If the EFI contexted has been \r
+    compromised this function will not return.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    BootOption - EFI Device Path from BootXXXX variable.\r
+    LoadOptionSize  - Size of LoadOption in size.\r
+    LoadOption      - LoadOption from BootXXXX variable\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Removable media not present\r
+\r
+--*/\r
+;\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN  UINT8                           Leds\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Update BDA with current Scroll, Num & Cap lock LEDS\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    Leds       - Status of current Scroll, Num & Cap lock LEDS\r
+                 Bit 0 is Scroll Lock  0 = Not locked\r
+                 Bit 1 is Num Lock\r
+                 Bit 2 is Caps Lock\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Removable media not present\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  OUT UINT16                          *HddCount,\r
+  OUT HDD_INFO                        **HddInfo,\r
+  OUT UINT16                          *BbsCount,\r
+  IN OUT BBS_TABLE                    **BbsTable\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieve legacy BBS info and assign boot priority.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    HddCount   - Number of HDD_INFO structures\r
+    HddInfo    - Onboard IDE controller information\r
+    BbsCount   - Number of BBS_TABLE structures\r
+    BbsTable   - List BBS entries\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Tables returned\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  OUT UINT16                          *BbsCount,\r
+  OUT BBS_TABLE                       **BbsTable\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Assign drive number to legacy HDD drives prior to booting an EFI\r
+    aware OS so the OS can access drives without an EFI driver.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    BbsCount   - Number of BBS_TABLE structures\r
+    BbsTable   - List BBS entries\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Drive numbers assigned\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL         * This,\r
+  IN UDC_ATTRIBUTES                   Attributes,\r
+  IN UINTN                            BbsEntry,\r
+  IN VOID                             *BeerData,\r
+  IN VOID                             *ServiceAreaData\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    To boot from an unconventional device like parties and/or execute\r
+    HDD diagnostics.\r
+\r
+  Arguments:\r
+    This            - Protocol instance pointer.\r
+    Attributes      - How to interpret the other input parameters\r
+    BbsEntry        - The 0-based index into the BbsTable for the parent \r
+                      device.\r
+    BeerData        - Pointer to the 128 bytes of ram BEER data.\r
+    ServiceAreaData - Pointer to the 64 bytes of raw Service Area data. The\r
+                      caller must provide a pointer to the specific Service\r
+                      Area and not the start all Service Areas. \r
+  Returns:\r
+    EFI_INVALID_PARAMETER if error. Does NOT return if no error.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL * This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Shadow all legacy16 OPROMs that haven't been shadowed.\r
+    Warning: Use this with caution. This routine disconnects all EFI\r
+             drivers. If used externally then caller must re-connect EFI\r
+             drivers.\r
+  Arguments:\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - OPROMs shadowed\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL * This,\r
+  IN    UINTN                 LegacyMemorySize,\r
+  IN    UINTN                 Region,\r
+  IN    UINTN                 Alignment,\r
+  OUT   VOID                  **LegacyMemoryAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get a region from the LegacyBios for S3 usage.\r
+\r
+Arguments:\r
+    This                   - Protocol instance pointer.\r
+    LegacyMemorySize     - Size of required region\r
+    Region                 - Region to use.\r
+                                 00 = Either 0xE0000 or 0xF0000 block\r
+                                 Bit0 = 1 0xF0000 block\r
+                                 Bit1 = 1 0xE0000 block\r
+    Alignment             - Address alignment. Bit mapped. First non-zero \r
+                            bit from right is alignment.\r
+    LegacyMemoryAddress  - Region Assigned\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Region assigned\r
+\r
+  Other       - Region not assigned\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION) (\r
+  IN EFI_LEGACY_BIOS_PROTOCOL * This,\r
+  IN    UINTN                 LegacyMemorySize,\r
+  IN    VOID                  *LegacyMemoryAddress,\r
+  IN    VOID                  *LegacyMemorySourceAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
+\r
+Arguments:\r
+    This                         - Protocol instance pointer.\r
+    LegacyMemorySize             - Size of data to copy\r
+    LegacyMemoryAddress          - Legacy Region destination address\r
+                                   Note: must be in region assigned by\r
+                                         LegacyBiosGetLegacyRegion\r
+    LegacyMemorySourceAddress    - Source of data\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS        - Region assigned\r
+  EFI_ACCESS_DENIED  - Destination outside assigned region\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_LEGACY_BIOS_PROTOCOL {\r
+  EFI_LEGACY_BIOS_INT86                       Int86;\r
+  EFI_LEGACY_BIOS_FARCALL86                   FarCall86;\r
+  EFI_LEGACY_BIOS_CHECK_ROM                   CheckPciRom;\r
+  EFI_LEGACY_BIOS_INSTALL_ROM                 InstallPciRom;\r
+  EFI_LEGACY_BIOS_BOOT                        LegacyBoot;\r
+  EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS  UpdateKeyboardLedStatus;\r
+  EFI_LEGACY_BIOS_GET_BBS_INFO                GetBbsInfo;\r
+  EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS    ShadowAllLegacyOproms;\r
+  EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI         PrepareToBootEfi;\r
+  EFI_LEGACY_BIOS_GET_LEGACY_REGION           GetLegacyRegion;\r
+  EFI_LEGACY_BIOS_COPY_LEGACY_REGION          CopyLegacyRegion;\r
+  EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE  BootUnconventionalDevice;\r
+} EFI_LEGACY_BIOS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacyBiosProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c
new file mode 100644 (file)
index 0000000..f9f2ac7
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyBiosPlatform.c\r
+    \r
+Abstract:\r
+\r
+  EFI Legacy BIOS Platform Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform)\r
+\r
+EFI_GUID  gEfiLegacyBiosPlatformProtocolGuid = EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacyBiosPlatformProtocolGuid, "Legacy BIOS Platform Protocol", "Legacy BIOS Platform Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h
new file mode 100644 (file)
index 0000000..1a1a0fa
--- /dev/null
@@ -0,0 +1,328 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyBiosPlatform.h\r
+    \r
+Abstract:\r
+\r
+  The EFI Legacy BIOS Patform Protocol is used to mate a Legacy16 \r
+  implementation with this EFI code. The EFI driver that produces \r
+  the Legacy BIOS protocol is generic and consumes this protocol.\r
+  A driver that matches the Legacy16 produces this protocol\r
+  \r
+Revision History\r
+\r
+  The EFI Legacy BIOS Platform Protocol is compliant with CSM spec 0.96.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_BIOS_PLATFORM_H\r
+#define _EFI_LEGACY_BIOS_PLATFORM_H\r
+\r
+#define EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID \\r
+  { \\r
+    0x783658a3, 0x4172, 0x4421, 0xa2, 0x99, 0xe0, 0x9, 0x7, 0x9c, 0xc, 0xb4 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PLATFORM_PROTOCOL);\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)\r
+\r
+#pragma pack(1)\r
+//\r
+// Define structures for GetOemIntData\r
+//  Note:\r
+//    OemIntDataElenent is an array of structures from 0 to Count-1.\r
+//    RawData is an array of bytes from 0 to RamDataLength-1.\r
+//\r
+typedef struct {\r
+  UINT16  Int;\r
+  UINT16  Ax;\r
+  UINT32  RawDataLength;\r
+  UINT8   RawData[1];\r
+} EFI_OEM_INT_DATA_ELEMENT;\r
+\r
+typedef struct {\r
+  UINT16                    Count;\r
+  EFI_OEM_INT_DATA_ELEMENT  OemIntDataElement[1];\r
+} EFI_OEM_INT_DATA;\r
+#pragma pack()\r
+\r
+typedef enum {\r
+  EfiGetPlatformBinaryMpTable        = 0,\r
+  EfiGetPlatformBinaryOemIntData     = 1,\r
+  EfiGetPlatformBinaryOem16Data      = 2,\r
+  EfiGetPlatformBinaryOem32Data      = 3,\r
+  EfiGetPlatformBinaryTpmBinary      = 4,\r
+  EfiGetPlatformBinarySystemRom      = 5,\r
+  EfiGetPlatformPciExpressBase       = 6,\r
+  EfiGetPlatformPmmSize              = 7,\r
+  EfiGetPlatformEndOfOpromShadowAddr = 8\r
+} EFI_GET_PLATFORM_INFO_MODE;\r
+\r
+typedef enum {\r
+  EfiGetPlatformVgaHandle       = 0,\r
+  EfiGetPlatformIdeHandle       = 1,\r
+  EfiGetPlatformIsaBusHandle    = 2,\r
+  EfiGetPlatformUsbHandle       = 3\r
+} EFI_GET_PLATFORM_HANDLE_MODE;\r
+\r
+typedef enum {\r
+  EfiPlatformHookPrepareToScanRom = 0,\r
+  EfiPlatformHookShadowServiceRoms= 1,\r
+  EfiPlatformHookAfterRomInit     = 2\r
+} EFI_GET_PLATFORM_HOOK_MODE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN EFI_GET_PLATFORM_INFO_MODE          Mode,\r
+  OUT VOID                               **Table,\r
+  OUT UINTN                              *TableSize,\r
+  OUT UINTN                              *Location,\r
+  OUT UINTN                              *Alignment,\r
+  IN  UINT16                             LegacySegment,\r
+  IN  UINT16                             LegacyOffset\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return a System ROM image for the platform\r
+\r
+  Arguments:\r
+    This                   - Protocol instance pointer.\r
+    Mode                   - Specifies what data to return\r
+    Table                  - Pointer to MP table.\r
+    TableSize              - Size in bytes of table.\r
+    Location               - Legacy region requested\r
+                               0x00 = Any location\r
+                               Bit 0 = 0xF0000 region\r
+                               Bit 1 = 0xE0000 region\r
+                               Multiple bits can be set\r
+    Alignment              - Address alignment for allocation.\r
+                             Bit mapped. First non-zero bit from right\r
+                             is alignment.\r
+                             \r
+    LegacySegment          - Segment in LegacyBios where Table is stored\r
+    LegacyOffset           - Offset in LegacyBios where Table is stored\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Data was returned successfully.\r
+    EFI_UNSUPPORTED - Mode is not supported on the platform.\r
+    EFI_NOT_FOUND   - Binary image or table not found.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN EFI_GET_PLATFORM_HANDLE_MODE        Mode,\r
+  IN UINT16                              Type,\r
+  OUT EFI_HANDLE                         **HandleBuffer,\r
+  OUT UINTN                              *HandleCount,\r
+  IN  VOID                               **AdditionalData OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the Legacy16 policy for which device should be the VGA controller\r
+    used during a Legacy16 boot.\r
+\r
+  Arguments:\r
+    This             - Protocol instance pointer.\r
+    Mode             - Specifies what handle to return.\r
+    Type             - Type from Device Path for Handle to represent.\r
+    HandleBuffer     - Handles of the device/controller in priority order \r
+                       with HandleBuffer[0] highest priority.\r
+    HandleCount      - Number of handles in the buffer.\r
+    AdditionalData   - Mode specific.\r
+\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Handle is valid\r
+    EFI_UNSUPPORTED - Mode is not supported on the platform.\r
+    EFI_NOT_FOUND   - Handle is not known\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_SMM_INIT) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN  VOID                               *EfiToLegacy16BootTable\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Load and initialize the Legacy BIOS SMM handler.\r
+\r
+  Arguments:\r
+    This                   - Protocol instance pointer.\r
+    EfiToLegacy16BootTable - Pointer to Legacy16 boot table.\r
+  Returns:\r
+    EFI_SUCCESS      - SMM code loaded.\r
+    EFI_DEVICE_ERROR - SMM code failed to load\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_HOOKS) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN EFI_GET_PLATFORM_HOOK_MODE          Mode,\r
+  IN UINT16                              Type,\r
+  IN  EFI_HANDLE                         DeviceHandle,\r
+  IN  OUT UINTN                          *ShadowAddress,\r
+  IN  EFI_COMPATIBILITY16_TABLE          * Compatibility16Table,\r
+  IN  VOID                               **AdditionalData OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Prepare to scan a ROM. \r
+\r
+  Arguments:\r
+    This                   - Protocol instance pointer.\r
+    Handle                 - Device handle\r
+    ShadowAddress          - Address that ROM is shadowed at prior to \r
+                             initialization or first free ROM address,\r
+                             depending upon mode.\r
+    Compatibility16Table   - Pointer to Compatibility16Table.\r
+    AdditionalData   - Mode specific.\r
+      \r
+\r
+  Returns:\r
+    EFI_SUCCESS     - RomImage is valid\r
+    EFI_UNSUPPORTED - Mode is not supported on the platform or platform \r
+                      policy is to not install this OPROM.\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  OUT VOID                               **RoutingTable,\r
+  OUT UINTN                              *RoutingTableEntries,\r
+  OUT VOID                               **LocalPirqTable, OPTIONAL\r
+  OUT UINTN                              *PirqTableSize, OPTIONAL\r
+  OUT VOID                               **LocalIrqPriorityTable, OPTIONAL\r
+  OUT UINTN                              *IrqPriorityTableEntries OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+      1. List of IRQ routing entries and number of entries.\r
+      2. Pointer to Entire $PIR table and length.\r
+      3. List of IRQs to assign to PCI in priority.\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    RoutingTable        - Pointer to PCI IRQ Routing table.\r
+    RoutingTableEntries - Number of entries in table.\r
+    LocalPirqTable         - $PIR table\r
+    PirqTableSize          - $PIR table size\r
+    LocalIrqPriorityTable  - List of interrupts in priority order to assign\r
+    IrqPriorityTableEntries- Number of entries in priority table\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - Table pointer returned\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN  UINTN                              PciBus,\r
+  IN  UINTN                              PciDevice,\r
+  IN  UINTN                              PciFunction,\r
+  IN  OUT UINT8                          *Pirq,\r
+  OUT UINT8                              *PciIrq\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Translate the PIRQ reported by the PCI device into the true PIRQ \r
+    from the internal IRQ routing information and IRQ assigned or to be\r
+    assigned to device.\r
+\r
+  Arguments:                           \r
+    This        - Protocol instance pointer.\r
+                  Base as defined below is the bus,device, function in\r
+                  IRQ routing table.\r
+    PciBus      - Base Bus for this device.\r
+    PciDevice   - Base Device for this device.\r
+    PciFunction - Base Function for this device.\r
+    Pirq        - Input is PIRQ reported by device, output is true PIRQ.\r
+    PciIrq      - The IRQ already assigned to the PIRQ or the IRQ to be\r
+                  assigned to the PIRQ.\r
+\r
+  Returns:\r
+    EFI_SUCCESS  - Irq translated\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT) (\r
+  IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL   * This,\r
+  IN  BBS_BBS_DEVICE_PATH                * BbsDevicePath,\r
+  IN  VOID                               *BbsTable,\r
+  IN  UINT32                             LoadOptionsSize,\r
+  IN  VOID                               *LoadOptions,\r
+  IN  VOID                               *EfiToLegacy16BootTable\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Attempt to legacy boot the BootOption. If the EFI contexted has been \r
+    compromised this function will not return.\r
+\r
+  Arguments:\r
+    This                      - Protocol instance pointer.\r
+    BbsDevicePath             - EFI Device Path from BootXXXX variable.\r
+    BbsTable                  - Internal BBS table.\r
+    LoadOptionSize            - Size of LoadOption in size.\r
+    LoadOption                - LoadOption from BootXXXX variable\r
+    EfiToLegacy16BootTable    - Pointer to BootTable structure\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Removable media not present\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL {\r
+  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO    GetPlatformInfo;\r
+  EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE  GetPlatformHandle;\r
+  EFI_LEGACY_BIOS_PLATFORM_SMM_INIT             SmmInit;\r
+  EFI_LEGACY_BIOS_PLATFORM_HOOKS                PlatformHooks;\r
+  EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE    GetRoutingTable;\r
+  EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ       TranslatePirq;\r
+  EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT      PrepareToBoot;\r
+} EFI_LEGACY_BIOS_PLATFORM_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacyBiosPlatformProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c
new file mode 100644 (file)
index 0000000..ef9091f
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyInterrupt.c\r
+    \r
+Abstract:\r
+\r
+  EFI Legacy InterruptProtocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt)\r
+\r
+EFI_GUID  gEfiLegacyInterruptProtocolGuid = EFI_LEGACY_INTERRUPT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacyInterruptProtocolGuid, "Legacy Interrupt Protocol", "Legacy Interrupt Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h
new file mode 100644 (file)
index 0000000..ecbe06a
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyInterrupt.h\r
+    \r
+Abstract:\r
+\r
+  This protocol manages the PIRQ for PCI devices\r
+\r
+Revision History\r
+\r
+  The EFI Legacy Interrupt Protocol is compliant with CSM spec 0.96.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_INTERRUPT_H_\r
+#define _EFI_LEGACY_INTERRUPT_H_\r
+\r
+#define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \\r
+  { \\r
+    0x31ce593d, 0x108a, 0x485d, 0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_INTERRUPT_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS) (\r
+  IN EFI_LEGACY_INTERRUPT_PROTOCOL            * This,\r
+  OUT UINT8                                   *NumberPirqs\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+      Return the number of PIRQs this hardware supports.\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    NumberPirsq         - Number of PIRQs.\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - Number of PIRQs returned.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_INTERRUPT_GET_LOCATION) (\r
+  IN EFI_LEGACY_INTERRUPT_PROTOCOL            * This,\r
+  OUT UINT8                                   *Bus,\r
+  OUT UINT8                                   *Device,\r
+  OUT UINT8                                   *Function\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+      Return PCI location of this device. $PIR table requires this info.\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    Bus                 - PCI Bus\r
+    Device              - PCI Device\r
+    Function            - PCI Function\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - Bus/Device/Function returned\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_INTERRUPT_READ_PIRQ) (\r
+  IN EFI_LEGACY_INTERRUPT_PROTOCOL           * This,\r
+  IN  UINT8                                  PirqNumber,\r
+  OUT UINT8                                  *PirqData\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+      Read the PIRQ register and return the data\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    PirqNumber          - PIRQ register to read\r
+    PirqData            - Data read\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - Data was read\r
+    EFI_INVALID_PARAMETER - Invalid PIRQ number\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_INTERRUPT_WRITE_PIRQ) (\r
+  IN EFI_LEGACY_INTERRUPT_PROTOCOL           * This,\r
+  IN  UINT8                                  PirqNumber,\r
+  IN UINT8                                   PirqData\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+      Write the specified PIRQ register with the given data.\r
+\r
+  Arguments:\r
+    This                - Protocol instance pointer.\r
+    PirqNumber          - PIRQ register to read.\r
+    PirqData            - Data written.\r
+\r
+  Returns:\r
+    EFI_SUCCESS   - Table pointer returned\r
+    EFI_INVALID_PARAMETER - Invalid PIRQ number\r
+\r
+--*/\r
+typedef struct _EFI_LEGACY_INTERRUPT_PROTOCOL {\r
+  EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS GetNumberPirqs;\r
+  EFI_LEGACY_INTERRUPT_GET_LOCATION     GetLocation;\r
+  EFI_LEGACY_INTERRUPT_READ_PIRQ        ReadPirq;\r
+  EFI_LEGACY_INTERRUPT_WRITE_PIRQ       WritePirq;\r
+} EFI_LEGACY_INTERRUPT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacyInterruptProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c
new file mode 100644 (file)
index 0000000..c4f697e
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyRegion.c\r
+    \r
+Abstract:\r
+\r
+  EFI Legacy Region Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyRegion)\r
+\r
+EFI_GUID  gEfiLegacyRegionProtocolGuid = EFI_LEGACY_REGION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacyRegionProtocolGuid, "Legacy Region Protocol", "Legacy Region Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h
new file mode 100644 (file)
index 0000000..d70e8ff
--- /dev/null
@@ -0,0 +1,82 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  LegacyRegion.h\r
+    \r
+Abstract:\r
+\r
+  This protocol manages the legacy memory regions between 0xc0000 - 0xfffff\r
+\r
+Revision History\r
+\r
+  The EFI Legacy Region Protocol is compliant with CSM spec 0.96.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_REGION_H_\r
+#define _EFI_LEGACY_REGION_H_\r
+\r
+#define EFI_LEGACY_REGION_PROTOCOL_GUID \\r
+  { \\r
+    0xfc9013a, 0x568, 0x4ba9, 0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_REGION_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION_DECODE) (\r
+  IN EFI_LEGACY_REGION_PROTOCOL           * This,\r
+  IN  UINT32                              Start,\r
+  IN  UINT32                              Length,\r
+  IN  BOOLEAN                             *On\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION_LOCK) (\r
+  IN EFI_LEGACY_REGION_PROTOCOL           * This,\r
+  IN  UINT32                              Start,\r
+  IN  UINT32                              Length,\r
+  OUT UINT32                              *Granularity OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION_BOOT_LOCK) (\r
+  IN EFI_LEGACY_REGION_PROTOCOL           * This,\r
+  IN  UINT32                              Start,\r
+  IN  UINT32                              Length,\r
+  OUT UINT32                              *Granularity OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LEGACY_REGION_UNLOCK) (\r
+  IN EFI_LEGACY_REGION_PROTOCOL           * This,\r
+  IN  UINT32                              Start,\r
+  IN  UINT32                              Length,\r
+  OUT UINT32                              *Granularity OPTIONAL\r
+  );\r
+\r
+typedef struct _EFI_LEGACY_REGION_PROTOCOL {\r
+  EFI_LEGACY_REGION_DECODE    Decode;\r
+  EFI_LEGACY_REGION_LOCK      Lock;\r
+  EFI_LEGACY_REGION_BOOT_LOCK BootLock;\r
+  EFI_LEGACY_REGION_UNLOCK    UnLock;\r
+} EFI_LEGACY_REGION_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacyRegionProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c
new file mode 100644 (file)
index 0000000..c62ed60
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciHostBridgeResourceAllocation.c\r
+\r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)\r
+\r
+EFI_GUID  gEfiPciHostBridgeResourceAllocationProtocolGuid = EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiPciHostBridgeResourceAllocationProtocolGuid, "PciHostBridgeRresourceAllocation Protocol",\r
+      "Pci Host Bridge Resource Allocation Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h
new file mode 100644 (file)
index 0000000..6e7e1f0
--- /dev/null
@@ -0,0 +1,364 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciHostBridgeResourceAllocation.h\r
+\r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_\r
+#define _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo)\r
+\r
+\r
+#define EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID \\r
+  { 0xCF8034BE,0x6768,0x4d8b,0xB7,0x39,0x7C,0xCE,0x68,0x3A,0x9F,0xBE }\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL);\r
+\r
+\r
+//\r
+// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES\r
+//\r
+\r
+// If this bit is set, then the PCI Root Bridge does not \r
+// support separate windows for Non-prefetchable and Prefetchable \r
+// memory. A PCI bus driver needs to include requests for Prefetchable \r
+// memory in the Non-prefetchable memory pool.\r
+//\r
+#define EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM  1\r
+\r
+//\r
+// If this bit is set, then the PCI Root Bridge supports \r
+// 64 bit memory windows.  If this bit is not set, \r
+// the PCI bus driver needs to include requests for 64 bit \r
+// memory address in the corresponding 32 bit memory pool. \r
+//\r
+#define EFI_PCI_HOST_BRIDGE_MEM64_DECODE   2\r
+\r
+\r
+//\r
+// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE\r
+//\r
+typedef enum {\r
+  EfiPciHostBridgeBeginEnumeration,\r
+  EfiPciHostBridgeBeginBusAllocation,\r
+  EfiPciHostBridgeEndBusAllocation,\r
+  EfiPciHostBridgeBeginResourceAllocation,\r
+  EfiPciHostBridgeAllocateResources,\r
+  EfiPciHostBridgeSetResources,\r
+  EfiPciHostBridgeFreeResources,\r
+  EfiPciHostBridgeEndResourceAllocation\r
+} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE;\r
+\r
+//\r
+// EfiPciHostBridgeBeginEnumeration\r
+// Reset the host bridge PCI apertures and internal data structures. \r
+// PCI enumerator should issue this notification before starting fresh \r
+// enumeration process. Enumeration cannot be restarted after sending \r
+// any other notification such as EfiPciHostBridgeBeginBusAllocation. \r
+//\r
+// EfiPciHostBridgeBeginBusAllocation  \r
+// The bus allocation phase is about to begin. No specific action \r
+// is required here. This notification can be used to perform any \r
+// chipset specific programming. \r
+//\r
+// EfiPciHostBridgeEndBusAllocation\r
+// The bus allocation and bus programming phase is complete. No specific\r
+// action is required here. This notification can be used to perform any \r
+// chipset specific programming. \r
+//\r
+// EfiPciHostBridgeBeginResourceAllocation\r
+// The resource allocation phase is about to begin.No specific action is \r
+// required here. This notification can be used to perform any chipset specific programming. \r
+//\r
+// EfiPciHostBridgeAllocateResources\r
+// Allocate resources per previously submitted requests for all the PCI Root \r
+// Bridges. These resource settings are returned on the next call to \r
+// GetProposedResources(). \r
+//\r
+// EfiPciHostBridgeSetResources\r
+// Program the Host Bridge hardware to decode previously allocated resources\r
+// (proposed resources) for all the PCI Root Bridges. \r
+//\r
+// EfiPciHostBridgeFreeResources\r
+// De-allocate previously allocated resources previously for all the PCI \r
+// Root Bridges and reset the I/O and memory apertures to initial state. \r
+//\r
+// EfiPciHostBridgeEndResourceAllocation\r
+// The resource allocation phase is completed.  No specific action is required \r
+// here. This notification can be used to perform any chipset specific programming. \r
+\r
+\r
+\r
+//\r
+// EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE\r
+//\r
+typedef enum {\r
+  EfiPciBeforeChildBusEnumeration,        \r
+  EfiPciBeforeResourceCollection\r
+} EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE;\r
+\r
+//\r
+// EfiPciBeforeChildBusEnumeration\r
+// This notification is only applicable to PCI-PCI bridges and \r
+// indicates that the PCI enumerator is about to begin enumerating \r
+// the bus behind the PCI-PCI Bridge. This notification is sent after \r
+// the primary bus number, the secondary bus number and the subordinate \r
+// bus number registers in the PCI-PCI Bridge are programmed to valid \r
+// (not necessary final) values\r
+//\r
+// EfiPciBeforeResourceCollection\r
+// This notification is sent before the PCI enumerator probes BAR registers \r
+// for every valid PCI function.\r
+//\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE            Phase\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  Enter a certain phase of the PCI enumeration process\r
+\r
+Arguments:\r
+  This  -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance\r
+  Phase -- The phase during enumeration\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_OUT_OF_RESOURCES - If SubmitResources ( ) could not allocate resources\r
+  EFI_NOT_READY        - This phase cannot be entered at this time\r
+  EFI_DEVICE_ERROR     - SetResources failed due to HW error.\r
+\r
+--*/  \r
+\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN OUT EFI_HANDLE                                       *RootBridgeHandle\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  Return the device handle of the next PCI root bridge that is associated with \r
+  this Host Bridge\r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- Returns the device handle of the next PCI Root Bridge. \r
+                      On input, it holds the RootBridgeHandle returned by the most \r
+                      recent call to GetNextRootBridge().The handle for the first \r
+                      PCI Root Bridge is returned if RootBridgeHandle is NULL on input\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+\r
+--*/  \r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                                                RootBridgeHandle,\r
+  OUT UINT64                                                    *Attributes\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  Returns the attributes of a PCI Root Bridge.\r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The device handle of the PCI Root Bridge \r
+                      that the caller is interested in\r
+  Attribute -- The pointer to attributes of the PCI Root Bridge                    \r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_INVALID_PARAMETER - Attributes is NULL\r
+\r
+--*/    \r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                                                RootBridgeHandle,\r
+  OUT VOID                                                      **Configuration\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  This is the request from the PCI enumerator to set up \r
+  the specified PCI Root Bridge for bus enumeration process. \r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The PCI Root Bridge to be set up\r
+  Configuration -- Pointer to the pointer to the PCI bus resource descriptor\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_DEVICE_ERROR      - Request failed due to hardware error\r
+  EFI_OUT_OF_RESOURCES  - Request failed due to lack of resources\r
+--*/\r
+\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN EFI_HANDLE                                                RootBridgeHandle,\r
+  IN VOID                                                      *Configuration\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  This function programs the PCI Root Bridge hardware so that \r
+  it decodes the specified PCI bus range\r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The PCI Root Bridge whose bus range is to be programmed\r
+  Configuration -- The pointer to the PCI bus resource descriptor\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_INVALID_PARAMETER - Configuration is NULL\r
+  EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor\r
+  EFI_INVALID_PARAMETER - Configuration contains one or more memory or IO ACPI resource descriptor\r
+  EFI_INVALID_PARAMETER - Address Range Minimum or Address Range Length fields in Configuration \r
+                          are invalid for this Root Bridge.\r
+  EFI_INVALID_PARAMETER - Configuration contains one or more invalid ACPI resource descriptor\r
+  EFI_DEVICE_ERROR      - Request failed due to hardware error\r
+  EFI_OUT_OF_RESOURCES  - Request failed due to lack of resources\r
+\r
+--*/    \r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN EFI_HANDLE                                                RootBridgeHandle,\r
+  IN VOID                                                      *Configuration\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  Submits the I/O and memory resource requirements for the specified PCI Root Bridge\r
+  \r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The PCI Root Bridge whose I/O and memory resource requirements \r
+                      are being submitted\r
+  Configuration -- The pointer to the PCI I/O and PCI memory resource descriptor                    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_INVALID_PARAMETER - Configuration is NULL\r
+  EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor\r
+  EFI_INVALID_PARAMETER - Configuration includes a resource descriptor of unsupported type\r
+\r
+--*/    \r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                                                RootBridgeHandle,\r
+  OUT VOID                                                      **Configuration\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  This function returns the proposed resource settings for the specified \r
+  PCI Root Bridge\r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The PCI Root Bridge handle\r
+  Configuration -- The pointer to the pointer to the PCI I/O \r
+                   and memory resource descriptor\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_DEVICE_ERROR      - Request failed due to hardware error\r
+  EFI_OUT_OF_RESOURCES  - Request failed due to lack of resources\r
+\r
+--*/    \r
+\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER) (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                                                RootBridgeHandle,\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS                PciAddress,\r
+  IN  EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE               Phase\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  This function is called for all the PCI controllers that the PCI \r
+  bus driver finds. Can be used to Preprogram the controller.\r
+\r
+Arguments:\r
+  This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  RootBridgeHandle -- The PCI Root Bridge handle\r
+  PciBusAddress -- Address of the controller on the PCI bus\r
+  Phase         -- The Phase during resource allocation\r
+    \r
+Returns:\r
+  EFI_SUCCESS - Success\r
+  EFI_INVALID_PARAMETER - RootBridgeHandle is invalid\r
+  EFI_DEVICE_ERROR      - Device pre-initialization failed due to hardware error.\r
+--*/    \r
+\r
+\r
+\r
+typedef struct _EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL {\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE           NotifyPhase;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE   GetNextRootBridge;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES         GetAllocAttributes;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION  StartBusEnumeration;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS        SetBusNumbers;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES       SubmitResources;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES GetProposedResources;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER  PreprocessController;\r
+} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPciHostBridgeResourceAllocationProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c
new file mode 100644 (file)
index 0000000..f96e0e3
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PciHotPlugInit.c\r
+    \r
+Abstract:\r
+\r
+    EFI PCI Hot Plug Init Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PciHotPlugInit)\r
+\r
+EFI_GUID  gEfiPciHotPlugInitProtocolGuid = EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciHotPlugInitProtocolGuid, "PCI Hot Plug Init Protocol", "PCI Hot Plug Init Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h
new file mode 100644 (file)
index 0000000..ff11e86
--- /dev/null
@@ -0,0 +1,97 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PciHotPlugInit.h\r
+    \r
+Abstract:\r
+\r
+    EFI PCI Hot Plug Init Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PCI_HOT_PLUG_INIT_H\r
+#define _EFI_PCI_HOT_PLUG_INIT_H\r
+\r
+//\r
+// Global ID for the PCI Hot Plug Protocol\r
+//\r
+#define EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID \\r
+  { 0xaa0e8bc1, 0xdabc, 0x46b0, 0xa8, 0x44, 0x37, 0xb8, 0x16, 0x9b, 0x2b, 0xea }\r
+\r
+  \r
+EFI_FORWARD_DECLARATION (EFI_PCI_HOT_PLUG_INIT_PROTOCOL);\r
+\r
+#define  EFI_HPC_STATE_INITIALIZED    0x01\r
+#define  EFI_HPC_STATE_ENABLED        0x02\r
+\r
+typedef UINT16 EFI_HPC_STATE;\r
+\r
+\r
+typedef struct{\r
+  EFI_DEVICE_PATH_PROTOCOL  *HpcDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *HpbDevicePath;\r
+} EFI_HPC_LOCATION;\r
+\r
+\r
+typedef enum{\r
+  EfiPaddingPciBus,\r
+  EfiPaddingPciRootBridge\r
+} EFI_HPC_PADDING_ATTRIBUTES;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_ROOT_HPC_LIST) (\r
+  IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL    *This,\r
+  OUT UINTN                            *HpcCount,\r
+  OUT EFI_HPC_LOCATION                **HpcList\r
+); \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_INITIALIZE_ROOT_HPC) (\r
+  IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL     *This,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL          *HpcDevicePath,\r
+  IN  UINT64                            HpcPciAddress,\r
+  IN  EFI_EVENT                         Event, OPTIONAL\r
+  OUT EFI_HPC_STATE                    *HpcState\r
+); \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_PCI_HOT_PLUG_PADDING) (\r
+  IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL       *This,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL          *HpcDevicePath,\r
+  IN  UINT64                            HpcPciAddress,\r
+  OUT EFI_HPC_STATE                    *HpcState,\r
+  OUT VOID                              **Padding,\r
+  OUT EFI_HPC_PADDING_ATTRIBUTES       *Attributes\r
+); \r
+\r
+\r
+//\r
+// Prototypes for the PCI Hot Plug Init Protocol\r
+//\r
+\r
+\r
+typedef struct _EFI_PCI_HOT_PLUG_INIT_PROTOCOL {\r
+  EFI_GET_ROOT_HPC_LIST                                  GetRootHpcList;\r
+  EFI_INITIALIZE_ROOT_HPC                                InitializeRootHpc;\r
+  EFI_GET_PCI_HOT_PLUG_PADDING                           GetResourcePadding;\r
+} EFI_PCI_HOT_PLUG_INIT_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiPciHotPlugInitProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c
new file mode 100644 (file)
index 0000000..4b3da5c
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PciPlatform.c\r
+\r
+Abstract:  \r
+  This file defines global GUID variables for PlatformOpRom protocols.\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_PRODUCER (PciPlatform)\r
\r
+\r
+EFI_GUID  gEfiPciPlatformProtocolGuid = EFI_PCI_PLATFORM_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiPciPlatformProtocolGuid, "Pci Platform Protocol", "Pci Platform Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h
new file mode 100644 (file)
index 0000000..38a9b2b
--- /dev/null
@@ -0,0 +1,211 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PciPlatform.h\r
+\r
+Abstract:\r
+  This file declares PlatfromOpRom protocols.\r
+\r
+--*/\r
+\r
+#ifndef _PCI_PLATFORM_H_\r
+#define _PCI_PLATFORM_H_\r
+\r
+\r
+#include "Tiano.h"\r
+#include "TianoTypes.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)\r
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)\r
+\r
+//\r
+// Protocol for GUID.\r
+//\r
+\r
+#define EFI_PCI_PLATFORM_PROTOCOL_GUID \\r
+{ 0x7d75280, 0x27d4, 0x4d69, 0x90, 0xd0, 0x56, 0x43, 0xe2, 0x38, 0xb3, 0x41}\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PCI_PLATFORM_PROTOCOL);\r
+\r
+typedef    UINT32   EFI_PCI_PLATFORM_POLICY;\r
+\r
\r
+#define     EFI_RESERVE_NONE_IO_ALIAS        0x0000\r
+#define     EFI_RESERVE_ISA_IO_ALIAS         0x0001\r
+#define     EFI_RESERVE_ISA_IO_NO_ALIAS      0x0002\r
+#define     EFI_RESERVE_VGA_IO_ALIAS         0x0004\r
+#define     EFI_RESERVE_VGA_IO_NO_ALIAS      0x0008\r
+\r
+\r
+typedef enum {\r
+  ChipsetEntry,\r
+  ChipsetExit,\r
+  MaximumChipsetPhase\r
+} EFI_PCI_CHIPSET_EXECUTION_PHASE;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_PLATFORM_PHASE_NOTIFY) (\r
+  IN EFI_PCI_PLATFORM_PROTOCOL                       *This,\r
+  IN  EFI_HANDLE                                     HostBridge,\r
+  IN  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE  Phase,\r
+  IN  EFI_PCI_CHIPSET_EXECUTION_PHASE                ChipsetPhase  \r
+)\r
+/*++\r
+\r
+  Routine Description:\r
+    The PlatformNotify() function can be used to notify the platform driver so that \r
+    it can perform platform-specific actions. No specific actions are required. \r
+    Eight notification points are defined at this time. More synchronization points \r
+    may be added as required in the future. The PCI bus driver calls the platform driver \r
+    twice for every Phase-once before the PCI Host Bridge Resource Allocation Protocol \r
+    driver is notified, and once after the PCI Host Bridge Resource Allocation Protocol \r
+    driver has been notified. \r
+    This member function may not perform any error checking on the input parameters. It \r
+    also does not return any error codes. If this member function detects any error condition, \r
+    it needs to handle those errors on its own because there is no way to surface any \r
+    errors to the caller.\r
+    \r
+  Arguments:\r
+    This         - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.  \r
+    HostBridge   - The handle of the host bridge controller. \r
+    Phase        - The phase of the PCI bus enumeration.\r
+    ChipsetPhase - Defines the execution phase of the PCI chipset driver. \r
+    \r
+  Returns:\r
+    EFI_SUCCESS  - The function completed successfully.\r
+    \r
+--*/\r
+;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER) (\r
+  IN  EFI_PCI_PLATFORM_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                     HostBridge,\r
+  IN  EFI_HANDLE                                     RootBridge,\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS    PciAddress,\r
+  IN  EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE   Phase,\r
+  IN  EFI_PCI_CHIPSET_EXECUTION_PHASE                ChipsetPhase\r
+)\r
+/*++\r
+\r
+  Routine Description:\r
+    The PlatformPrepController() function can be used to notify the platform driver so that \r
+    it can perform platform-specific actions. No specific actions are required. \r
+    Several notification points are defined at this time. More synchronization points may be \r
+    added as required in the future. The PCI bus driver calls the platform driver twice for \r
+    every PCI controller-once before the PCI Host Bridge Resource Allocation Protocol driver \r
+    is notified, and once after the PCI Host Bridge Resource Allocation Protocol driver has \r
+    been notified. \r
+    This member function may not perform any error checking on the input parameters. It also \r
+    does not return any error codes. If this member function detects any error condition, it \r
+    needs to handle those errors on its own because there is no way to surface any errors to \r
+    the caller.  \r
+    \r
+  Arguments:\r
+    This         - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.  \r
+    HostBridge   - The associated PCI host bridge handle. \r
+    RootBridge   - The associated PCI root bridge handle.\r
+    PciAddress   - The address of the PCI device on the PCI bus. \r
+    Phase        - The phase of the PCI controller enumeration. \r
+    ChipsetPhase - Defines the execution phase of the PCI chipset driver. \r
+    \r
+  Returns:\r
+    EFI_SUCCESS  - The function completed successfully.\r
+    \r
+--*/\r
+;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PCI_PLATFORM_GET_PLATFORM_POLICY) (\r
+  IN  EFI_PCI_PLATFORM_PROTOCOL           *This,\r
+  OUT EFI_PCI_PLATFORM_POLICY             *PciPolicy\r
+)\r
+/*++\r
+\r
+  Routine Description:\r
+    The GetPlatformPolicy() function retrieves the platform policy regarding PCI \r
+    enumeration. The PCI bus driver and the PCI Host Bridge Resource Allocation Protocol \r
+    driver can call this member function to retrieve the policy.\r
+    \r
+  Arguments:\r
+    This      - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.\r
+    PciPolicy - The platform policy with respect to VGA and ISA aliasing. \r
+    \r
+  Returns:\r
+    EFI_SUCCESS           - The function completed successfully.\r
+    EFI_INVALID_PARAMETER - PciPolicy is NULL.\r
+    \r
+--*/\r
+;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_PLATFORM_GET_PCI_ROM) (        \r
+  IN   EFI_PCI_PLATFORM_PROTOCOL    *This,\r
+  IN   EFI_HANDLE                   PciHandle,\r
+  OUT  VOID                         **RomImage,\r
+  OUT  UINTN                        *RomSize              \r
+)\r
+/*++\r
+\r
+  Routine Description:\r
+    The GetPciRom() function gets the PCI device's option ROM from a platform-specific location. \r
+    The option ROM will be loaded into memory. This member function is used to return an image \r
+    that is packaged as a PCI 2.2 option ROM. The image may contain both legacy and EFI option \r
+    ROMs. See the EFI 1.10 Specification for details. This member function can be used to return \r
+    option ROM images for embedded controllers. Option ROMs for embedded controllers are typically \r
+    stored in platform-specific storage, and this member function can retrieve it from that storage \r
+    and return it to the PCI bus driver. The PCI bus driver will call this member function before \r
+    scanning the ROM that is attached to any controller, which allows a platform to specify a ROM \r
+    image that is different from the ROM image on a PCI card.\r
+\r
+  Arguments:\r
+    This      - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.\r
+    PciHandle - The handle of the PCI device. \r
+    RomImage  - If the call succeeds, the pointer to the pointer to the option ROM image. \r
+                Otherwise, this field is undefined. The memory for RomImage is allocated \r
+                by EFI_PCI_PLATFORM_PROTOCOL.GetPciRom() using the EFI Boot Service AllocatePool(). \r
+                It is the caller's responsibility to free the memory using the EFI Boot Service \r
+                FreePool(), when the caller is done with the option ROM.\r
+    RomSize   - If the call succeeds, a pointer to the size of the option ROM size. Otherwise, \r
+                this field is undefined.\r
+                \r
+  Returns:\r
+    EFI_SUCCESS          - The option ROM was available for this device and loaded into memory.\r
+    EFI_NOT_FOUND        - No option ROM was available for this device.\r
+    EFI_OUT_OF_RESOURCES - No memory was available to load the option ROM.\r
+    EFI_DEVICE_ERROR     - An error occurred in getting the option ROM.\r
+        \r
+--*/\r
+;\r
+\r
+\r
+typedef struct _EFI_PCI_PLATFORM_PROTOCOL {\r
+  EFI_PCI_PLATFORM_PHASE_NOTIFY          PhaseNotify;\r
+  EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER PlatformPrepController;\r
+  EFI_PCI_PLATFORM_GET_PLATFORM_POLICY   GetPlatformPolicy;\r
+  EFI_PCI_PLATFORM_GET_PCI_ROM           GetPciRom;\r
+} EFI_PCI_PLATFORM_PROTOCOL;\r
+\r
+extern EFI_GUID   gEfiPciPlatformProtocolGuid;\r
+\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c
new file mode 100644 (file)
index 0000000..87ee975
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SectionExtraction.c\r
+\r
+Abstract:\r
+\r
+  Section Extraction protocol as defined in the Tiano File Image Format\r
+  specification.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)\r
+\r
+EFI_GUID  gEfiSectionExtractionProtocolGuid = EFI_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSectionExtractionProtocolGuid, "Section Extraction Protocol", "Tiano Section Extraction Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h
new file mode 100644 (file)
index 0000000..849a2c8
--- /dev/null
@@ -0,0 +1,83 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SectionExtraction.h\r
+\r
+Abstract:\r
+\r
+  Section extraction protocol as defined in the Tiano File Image Format specification.\r
+\r
+  This interface provides a means of decoding a set of sections into a linked list of\r
+  leaf sections.  This provides for an extensible and flexible file format.\r
+\r
+--*/\r
+\r
+#ifndef _SECTION_EXTRACTION_PROTOCOL_H\r
+#define _SECTION_EXTRACTION_PROTOCOL_H\r
+\r
+#include "EfiFirmwareFileSystem.h"\r
+\r
+//\r
+// Protocol GUID definition\r
+//\r
+#define EFI_SECTION_EXTRACTION_PROTOCOL_GUID \\r
+  { \\r
+    0x448F5DA4, 0x6DD7, 0x4FE1, 0x93, 0x07, 0x69, 0x22, 0x41, 0x92, 0x21, 0x5D \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SECTION_EXTRACTION_PROTOCOL);\r
+\r
+//\r
+// Protocol member functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_OPEN_SECTION_STREAM) (\r
+  IN  EFI_SECTION_EXTRACTION_PROTOCOL                   * This,\r
+  IN  UINTN                                             SectionStreamLength,\r
+  IN  VOID                                              *SectionStream,\r
+  OUT UINTN                                             *SectionStreamHandle\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_SECTION) (\r
+  IN EFI_SECTION_EXTRACTION_PROTOCOL                    * This,\r
+  IN UINTN                                              SectionStreamHandle,\r
+  IN EFI_SECTION_TYPE                                   * SectionType,\r
+  IN EFI_GUID                                           * SectionDefinitionGuid,\r
+  IN UINTN                                              SectionInstance,\r
+  IN VOID                                               **Buffer,\r
+  IN OUT UINTN                                          *BufferSize,\r
+  OUT UINT32                                            *AuthenticationStatus\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLOSE_SECTION_STREAM) (\r
+  IN EFI_SECTION_EXTRACTION_PROTOCOL                    * This,\r
+  IN UINTN                                              SectionStreamHandle\r
+  );\r
+\r
+//\r
+// Protocol definition\r
+//\r
+typedef struct _EFI_SECTION_EXTRACTION_PROTOCOL {\r
+  EFI_OPEN_SECTION_STREAM   OpenSectionStream;\r
+  EFI_GET_SECTION           GetSection;\r
+  EFI_CLOSE_SECTION_STREAM  CloseSectionStream;\r
+} EFI_SECTION_EXTRACTION_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSectionExtractionProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c
new file mode 100644 (file)
index 0000000..5b229b0
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SecurityPolicy.c\r
+\r
+Abstract:\r
+\r
+  Security Policy protocol as defined in the DXE CIS\r
+\r
+--*/\r
+\r
+#include "Tiano.h"                  \r
+#include EFI_PROTOCOL_DEFINITION (SecurityPolicy)\r
+\r
+EFI_GUID gEfiSecurityPolicyProtocolGuid = EFI_SECURITY_POLICY_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSecurityPolicyProtocolGuid, "Security Policy protocol", "Security Policy protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h
new file mode 100644 (file)
index 0000000..98a056e
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SecurityPolicy.h\r
+\r
+Abstract:\r
+\r
+  Security Policy protocol as defined in the DXE CIS\r
+\r
+--*/\r
+\r
+#ifndef _SECURITY_POLICY_H_\r
+#define _SECURITY_POLICY_H_\r
+\r
+//\r
+// Security policy protocol GUID definition\r
+//\r
+#define EFI_SECURITY_POLICY_PROTOCOL_GUID  \\r
+  {0x78E4D245, 0xCD4D, 0x4a05, 0xA2, 0xBA, 0x47, 0x43, 0xE8, 0x6C, 0xFC, 0xAB}\r
+\r
+extern EFI_GUID gEfiSecurityPolicyProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c
new file mode 100644 (file)
index 0000000..7518d0d
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmBus.c\r
+  \r
+Abstract:\r
+\r
+  EFI SMBUS Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Smbus)\r
+\r
+EFI_GUID  gEfiSmbusProtocolGuid = EFI_SMBUS_HC_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmbusProtocolGuid, "SMBUS Protocol", "EFI 2.0 SMBUS Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h
new file mode 100644 (file)
index 0000000..f6d2709
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Smbus.h\r
+    \r
+Abstract:\r
+\r
+  EFI SMBUS Protocol\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMBUS_H\r
+#define _EFI_SMBUS_H\r
+\r
+#include "EfiSmbus.h"\r
+\r
+#define EFI_SMBUS_HC_PROTOCOL_GUID \\r
+  { \\r
+    0xe49d33ed, 0x513d, 0x4634, 0xb6, 0x98, 0x6f, 0x55, 0xaa, 0x75, 0x1c, 0x1b \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMBUS_HC_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMBUS_HC_EXECUTE_OPERATION) (\r
+  IN EFI_SMBUS_HC_PROTOCOL              * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS      SlaveAddress,\r
+  IN      EFI_SMBUS_DEVICE_COMMAND      Command,\r
+  IN      EFI_SMBUS_OPERATION           Operation,\r
+  IN      BOOLEAN                       PecCheck,\r
+  IN OUT  UINTN                         *Length,\r
+  IN OUT  VOID                          *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMBUS_NOTIFY_FUNCTION) (\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS      SlaveAddress,\r
+  IN      UINTN                         Data\r
+  );\r
+\r
+//\r
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.\r
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE) (\r
+  IN EFI_SMBUS_HC_PROTOCOL              * This,\r
+  IN      BOOLEAN                       ArpAll,\r
+  IN      EFI_SMBUS_UDID                * SmbusUdid, OPTIONAL\r
+  IN OUT  EFI_SMBUS_DEVICE_ADDRESS      * SlaveAddress OPTIONAL\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP) (\r
+  IN EFI_SMBUS_HC_PROTOCOL              * This,\r
+  IN OUT  UINTN                         *Length,\r
+  IN OUT  EFI_SMBUS_DEVICE_MAP          **SmbusDeviceMap\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_NOTIFY) (\r
+  IN EFI_SMBUS_HC_PROTOCOL              * This,\r
+  IN      EFI_SMBUS_DEVICE_ADDRESS      SlaveAddress,\r
+  IN      UINTN                         Data,\r
+  IN      EFI_SMBUS_NOTIFY_FUNCTION     NotifyFunction\r
+  );\r
+\r
+typedef struct _EFI_SMBUS_HC_PROTOCOL {\r
+  EFI_SMBUS_HC_EXECUTE_OPERATION    Execute;\r
+  EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE  ArpDevice;\r
+  EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP GetArpMap;\r
+  EFI_SMBUS_HC_PROTOCOL_NOTIFY      Notify;\r
+} EFI_SMBUS_HC_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmbusProtocolGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c
new file mode 100644 (file)
index 0000000..9776e25
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmAccess.c\r
+\r
+Abstract:\r
+\r
+  This file defines SMM SMRAM abstraction protocol defined by the \r
+  SMM Component Interface Specification\r
+\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmAccess)\r
+\r
+EFI_GUID  gEfiSmmAccessProtocolGuid = EFI_SMM_ACCESS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmAccessProtocolGuid, "SMM Access Protocol", "SMM Access protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h
new file mode 100644 (file)
index 0000000..24e2cbc
--- /dev/null
@@ -0,0 +1,79 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmAccess.h\r
+\r
+Abstract:\r
+\r
+  This file defines SMM SMRAM Access abstraction protocol defined \r
+  by the SMM CIS.\r
+\r
+--*/\r
+\r
+#ifndef _SMM_ACCESS_H_\r
+#define _SMM_ACCESS_H_\r
+\r
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_ACCESS_PROTOCOL);\r
+\r
+#define EFI_SMM_ACCESS_PROTOCOL_GUID \\r
+  { \\r
+    0x3792095a, 0xe309, 0x4c1e, 0xaa, 0x01, 0x85, 0xf5, 0x65, 0x5a, 0x17, 0xf1 \\r
+  }\r
+\r
+//\r
+// SMM Access specification Data Structures\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_OPEN) (\r
+  IN EFI_SMM_ACCESS_PROTOCOL         * This,\r
+  UINTN                              DescriptorIndex\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_CLOSE) (\r
+  IN EFI_SMM_ACCESS_PROTOCOL          * This,\r
+  UINTN                               DescriptorIndex\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_LOCK) (\r
+  IN EFI_SMM_ACCESS_PROTOCOL         * This,\r
+  UINTN                              DescriptorIndex\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_CAPABILITIES) (\r
+  IN EFI_SMM_ACCESS_PROTOCOL             * This,\r
+  IN OUT UINTN                           *SmramMapSize,\r
+  IN OUT EFI_SMRAM_DESCRIPTOR            * SmramMap\r
+  );\r
+\r
+typedef struct _EFI_SMM_ACCESS_PROTOCOL {\r
+  EFI_SMM_OPEN          Open;\r
+  EFI_SMM_CLOSE         Close;\r
+  EFI_SMM_LOCK          Lock;\r
+  EFI_SMM_CAPABILITIES  GetCapabilities;\r
+  BOOLEAN               LockState;\r
+  BOOLEAN               OpenState;\r
+} EFI_SMM_ACCESS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmAccessProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c
new file mode 100644 (file)
index 0000000..4930f9b
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmBase.c\r
+\r
+Abstract:\r
+\r
+  This file defines SMM Base abstraction protocol defined by the \r
+  SMM Component Interface Specification\r
+\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmBase)\r
+\r
+EFI_GUID  gEfiSmmBaseProtocolGuid = EFI_SMM_BASE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmBaseProtocolGuid, "SMM Base Protocol", "SMM Base protocol");\r
+\r
+EFI_GUID  gEfiSmmCpuIoGuid = EFI_SMM_CPU_IO_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmCpuIoGuid, "SMM CPU IO", "SMM CPU IO");\r
+\r
+EFI_GUID  gEfiSmmCommunicateHeaderGuid = SMM_COMMUNICATE_HEADER_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmCommunicateHeaderGuid, "SMM Communicate Header Guid", "SMM Communicate Header Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h
new file mode 100644 (file)
index 0000000..9cda787
--- /dev/null
@@ -0,0 +1,797 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmBase.h\r
+\r
+Abstract:\r
+\r
+  This file defines SMM Base abstraction protocol defined by the SMM Architecture\r
+  Specification.  This is the base level of compatiblity for SMM drivers.\r
+\r
+--*/\r
+\r
+#ifndef _SMM_BASE_H_\r
+#define _SMM_BASE_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+\r
+#define EFI_SMM_BASE_PROTOCOL_GUID \\r
+  { \\r
+    0x1390954D, 0xda95, 0x4227, 0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8 \\r
+  }\r
+\r
+#define EFI_SMM_CPU_IO_GUID \\r
+  { \\r
+    0x5f439a0b, 0x45d8, 0x4682, 0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41 \\r
+  }\r
+\r
+#define SMM_COMMUNICATE_HEADER_GUID \\r
+  { \\r
+    0xF328E36C, 0x23B6, 0x4a95, 0x85, 0x4B, 0x32, 0xE1, 0x95, 0x34, 0xCD, 0x75 \\r
+  }\r
+\r
+//\r
+// SMM Base specification constant and types\r
+//\r
+#define SMM_SMST_SIGNATURE            EFI_SIGNATURE_32 ('S', 'M', 'S', 'T')\r
+#define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_BASE_PROTOCOL);\r
+EFI_FORWARD_DECLARATION (EFI_SMM_CPU_IO_INTERFACE);\r
+EFI_FORWARD_DECLARATION (EFI_SMM_CPU_SAVE_STATE);\r
+EFI_FORWARD_DECLARATION (EFI_SMM_OPTIONAL_FP_SAVE_STATE);\r
+EFI_FORWARD_DECLARATION (EFI_SMM_SYSTEM_TABLE);\r
+\r
+//\r
+// *******************************************************\r
+// EFI_SMM_IO_WIDTH\r
+// *******************************************************\r
+//\r
+typedef enum {\r
+  SMM_IO_UINT8  = 0,\r
+  SMM_IO_UINT16 = 1,\r
+  SMM_IO_UINT32 = 2,\r
+  SMM_IO_UINT64 = 3\r
+} EFI_SMM_IO_WIDTH;\r
+\r
+//\r
+// *******************************************************\r
+// EFI_SMM_IO_ACCESS\r
+// *******************************************************\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_CPU_IO) (\r
+  IN EFI_SMM_CPU_IO_INTERFACE         * This,\r
+  IN EFI_SMM_IO_WIDTH                 Width,\r
+  IN UINT64                           Address,\r
+  IN UINTN                            Count,\r
+  IN OUT VOID                         *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_SMM_CPU_IO  Read;\r
+  EFI_SMM_CPU_IO  Write;\r
+} EFI_SMM_IO_ACCESS;\r
+\r
+typedef struct _EFI_SMM_CPU_IO_INTERFACE {\r
+  EFI_SMM_IO_ACCESS Mem;\r
+  EFI_SMM_IO_ACCESS Io;\r
+} EFI_SMM_CPU_IO_INTERFACE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) (\r
+  IN EFI_MEMORY_TYPE                PoolType,\r
+  IN UINTN                          Size,\r
+  OUT VOID                          **Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMMCORE_FREE_POOL) (\r
+  IN VOID                   *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) (\r
+  IN EFI_ALLOCATE_TYPE      Type,\r
+  IN EFI_MEMORY_TYPE        MemoryType,\r
+  IN UINTN                  NumberOfPages,\r
+  OUT EFI_PHYSICAL_ADDRESS  * Memory\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMMCORE_FREE_PAGES) (\r
+  IN EFI_PHYSICAL_ADDRESS   Memory,\r
+  IN UINTN                  NumberOfPages\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_AP_PROCEDURE) (\r
+  IN  VOID                              *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_STARTUP_THIS_AP) (\r
+  IN  EFI_AP_PROCEDURE                    Procedure,\r
+  IN  UINTN                               CpuNumber,\r
+  IN  OUT VOID                            *ProcArguments OPTIONAL\r
+  );\r
+\r
+typedef struct _EFI_SMM_CPU_SAVE_STATE {\r
+  UINT8   Reserved1[248];\r
+  UINT32  SMBASE;\r
+  UINT32  SMMRevId;\r
+  UINT16  IORestart;\r
+  UINT16  AutoHALTRestart;\r
+  UINT8   Reserved2[164];\r
+  UINT32  ES;\r
+  UINT32  CS;\r
+  UINT32  SS;\r
+  UINT32  DS;\r
+  UINT32  FS;\r
+  UINT32  GS;\r
+  UINT32  LDTBase;\r
+  UINT32  TR;\r
+  UINT32  DR7;\r
+  UINT32  DR6;\r
+  UINT32  EAX;\r
+  UINT32  ECX;\r
+  UINT32  EDX;\r
+  UINT32  EBX;\r
+  UINT32  ESP;\r
+  UINT32  EBP;\r
+  UINT32  ESI;\r
+  UINT32  EDI;\r
+  UINT32  EIP;\r
+  UINT32  EFLAGS;\r
+  UINT32  CR3;\r
+  UINT32  CR0;\r
+} EFI_SMM_CPU_SAVE_STATE;\r
+\r
+typedef struct {\r
+  UINT8   Reserved19[760];    // FC00\r
+  UINT32  SMBASE;             // FEF8\r
+  UINT32  REVID;              // FEFC\r
+  UINT16  HALT_RESTART;       // FF00\r
+  UINT16  IO_RESTART;         // FF02\r
+  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\r
+  UINT32  EAX;                // FF5C\r
+  UINT32  Reserved16;         // FF60\r
+  UINT32  ECX;                // FF64\r
+  UINT32  Reserved15;         // FF68\r
+  UINT32  EDX;                // FF6C\r
+  UINT32  Reserved14;         // FF70\r
+  UINT32  EBX;                // FF74\r
+  UINT32  Reserved13;         // FF78\r
+  UINT32  ESP;                // FF7C\r
+  UINT32  Reserved12;         // FF80\r
+  UINT32  EBP;                // FF84\r
+  UINT32  Reserved11;         // FF88\r
+  UINT32  ESI;                // FF8C\r
+  UINT32  Reserved9;          // FF90\r
+  UINT32  EDI;                // FF94\r
+  UINT32  Reserved8;          // FF98\r
+  UINT32  IO_MEM_ADDR;        // FF9C\r
+  UINT32  Reserved7;          // FFA0\r
+  UINT32  IO_MISC;            // FFA4\r
+  UINT32  ES_SEL;             // FFA8\r
+  UINT32  CS_SEL;             // FFAC\r
+  UINT32  SS_SEL;             // FFB0\r
+  UINT32  DS_SEL;             // FFB4\r
+  UINT32  FS_SEL;             // FFB8\r
+  UINT32  GS_SEL;             // FFBC\r
+  UINT32  LDTR_SEL;           // FFC0\r
+  UINT32  TR_SEL;             // FFC4\r
+  UINT32  DR7;                // FFC8\r
+  UINT32  Reserved6;          // FFCC\r
+  UINT32  DR6;                // FFD0\r
+  UINT32  Reserved5;          // FFD4\r
+  UINT32  EIP;                // FFD8\r
+  UINT32  Reserved4;          // FFDC\r
+  UINT32  EFER;               // FFE0\r
+  UINT32  Reserved3;          // FFE4\r
+  UINT32  EFLAGS;             // FFE8\r
+  UINT32  Reserved2;          // FFEC\r
+  UINT32  CR3;                // FFF0\r
+  UINT32  Reserved1;          // FFF4\r
+  UINT32  CR0;                // FFF8\r
+  UINT32  Reserved0;          // FFFC\r
+} EFI_SMM_CPU_CT_SAVE_STATE;\r
+\r
+typedef struct {\r
+  UINT8   Reserved26[464];        // FC00 - FDCF\r
+  UINT32  GdtrUpperBase;          // FDD0\r
+  UINT32  LdtrUpperBase;          // FDD4\r
+  UINT32  IdtrUpperBase;          // FDD8\r
+  UINT32  Reserved25;             // FDDC - FDDF\r
+  UINT64  IoRdi;                  // FDE0\r
+  UINT64  IoRip;                  // FDE8\r
+  UINT64  IoRcx;                  // FDF0\r
+  UINT64  IoRsi;                  // FDF8\r
+  UINT8   Reserved24[64];         // FE00 - FE3F\r
+  UINT64  Cr4;                    // FE40\r
+  UINT8   Reserved23[68];         // FE48 - FE8B\r
+  UINT32  GdtrBase;               // FE8C\r
+  UINT32  Reserved22;             // FE90\r
+  UINT32  IdtrBase;               // FE94\r
+  UINT32  Reserved21;             // FE98\r
+  UINT32  LdtrBase;               // FE9C\r
+  UINT32  Reserved20;             // FEA0\r
+  UINT8   Reserved19[84];         // FEA4 - FEF7\r
+  UINT32  Smbase;                 // FEF8\r
+  UINT32  RevId;                  // FEFC\r
+  UINT16  IoRestart;              // FF00\r
+  UINT16  HaltRestart;            // FF02\r
+  UINT8   Reserved18[24];         // FF04 - FF1B\r
+  UINT32  R15;                    // FF1C\r
+  UINT32  Reserved17;             // FE20\r
+  UINT32  R14;                    // FF24\r
+  UINT32  Reserved16;             // FE28\r
+  UINT32  R13;                    // FF2C\r
+  UINT32  Reserved15;             // FE30\r
+  UINT32  R12;                    // FF34\r
+  UINT32  Reserved14;             // FE38\r
+  UINT32  R11;                    // FF3C\r
+  UINT32  Reserved13;             // FE40\r
+  UINT32  R10;                    // FF44\r
+  UINT32  Reserved12;             // FE48\r
+  UINT32  R9;                     // FF4C\r
+  UINT32  Reserved11;             // FE50\r
+  UINT32  R8;                     // FF54\r
+  UINT32  Reserved10;             // FE58\r
+  UINT32  Rax;                    // FF5C\r
+  UINT32  Reserved9;              // FE60\r
+  UINT32  Rcx;                    // FF64\r
+  UINT32  Reserved8;              // FE68\r
+  UINT32  Rdx;                    // FF6C\r
+  UINT32  Reserved7;              // FE70\r
+  UINT32  Rbx;                    // FF74\r
+  UINT32  Reserved6;              // FE78\r
+  UINT32  Rsp;                    // FF7C\r
+  UINT32  Reserved5;              // FE80\r
+  UINT32  Rbp;                    // FF84\r
+  UINT32  Reserved4;              // FE88\r
+  UINT32  Rsi;                    // FF8C\r
+  UINT32  Reserved3;              // FE90\r
+  UINT32  Rdi;                    // FF94\r
+  UINT32  Reserved2;              // FE98\r
+  UINT32  IoMemAddr;              // FF9C\r
+  UINT32  Reserved1;              // FEA0\r
+  UINT32  IoMiscInfo;             // FFA4\r
+  UINT32  EsSel;                  // FFA8\r
+  UINT32  CsSel;                  // FFAC\r
+  UINT32  SsSel;                  // FFB0\r
+  UINT32  DsSel;                  // FFB4\r
+  UINT32  FsSel;                  // FFB8\r
+  UINT32  GsSel;                  // FFBC\r
+  UINT32  LdtrSel;                // FFC0\r
+  UINT32  TrSel;                  // FFC4\r
+  UINT64  Dr7;                    // FFC8\r
+  UINT64  Dr6;                    // FFD0\r
+  UINT32  Rip;                    // FFD8\r
+  UINT32  Reserved0;              // FFDC\r
+  UINT64  Efr;                    // FFE0\r
+  UINT64  RFlags;                 // FFE8\r
+  UINT64  Cr3;                    // FFF0\r
+  UINT64  Cr0;                    // FFF8\r
+} EFI_SMM_CPU_MEROM_SAVE_STATE;\r
+\r
+\r
+typedef struct {\r
+  UINT8   Reserved14[0x228];  // FC00-FE28\r
+  UINT32  IO_EIP;             // FE28\r
+  UINT8   Reserved13[0x14];   // FE2C-FE40\r
+  UINT32  CR4;                // FE40\r
+  UINT8   Reserved12[0x48];   // FE44-FE8C\r
+  UINT32  GDT_BASE;           // FE8C\r
+  UINT8   Reserved11[0xC];    // FE90-FE9C\r
+  UINT32  LDT_BASE;           // FE9C\r
+  UINT8   Reserved10[0x58];   // FEA0-FEF8\r
+  UINT32  SMBASE;\r
+  UINT32  REVID;\r
+  UINT16  IO_RESTART;\r
+  UINT16  HALT_RESTART;\r
+  UINT8   Reserved9[0xA4];\r
+\r
+  UINT16  ES;\r
+  UINT16  Reserved8;\r
+  UINT16  CS;\r
+  UINT16  Reserved7;\r
+  UINT16  SS;\r
+  UINT16  Reserved6;\r
+  UINT16  DS;\r
+  UINT16  Reserved5;\r
+  UINT16  FS;\r
+  UINT16  Reserved4;\r
+  UINT16  GS;\r
+  UINT16  Reserved3;\r
+  UINT32  Reserved2;\r
+  UINT16  TR;\r
+  UINT16  Reserved1;\r
+  UINT32  DR7;\r
+  UINT32  DR6;\r
+  UINT32  EAX;\r
+  UINT32  ECX;\r
+  UINT32  EDX;\r
+  UINT32  EBX;\r
+  UINT32  ESP;\r
+  UINT32  EBP;\r
+  UINT32  ESI;\r
+  UINT32  EDI;\r
+  UINT32  EIP;\r
+  UINT32  EFLAGS;\r
+  UINT32  CR3;\r
+  UINT32  CR0;\r
+} EFI_SMM_CPU_CT_NOT_ENABLED_SAVE_STATE;\r
+\r
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE {\r
+  UINT16  Fcw;\r
+  UINT16  Fsw;\r
+  UINT16  Ftw;\r
+  UINT16  Opcode;\r
+  UINT32  Eip;\r
+  UINT16  Cs;\r
+  UINT16  Rsvd1;\r
+  UINT32  DataOffset;\r
+  UINT16  Ds;\r
+  UINT8   Rsvd2[10];\r
+  UINT8   St0Mm0[10], Rsvd3[6];\r
+  UINT8   St0Mm1[10], Rsvd4[6];\r
+  UINT8   St0Mm2[10], Rsvd5[6];\r
+  UINT8   St0Mm3[10], Rsvd6[6];\r
+  UINT8   St0Mm4[10], Rsvd7[6];\r
+  UINT8   St0Mm5[10], Rsvd8[6];\r
+  UINT8   St0Mm6[10], Rsvd9[6];\r
+  UINT8   St0Mm7[10], Rsvd10[6];\r
+  UINT8   Rsvd11[22 * 16];\r
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE;\r
+\r
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE32 {\r
+  UINT16  Fcw;\r
+  UINT16  Fsw;\r
+  UINT16  Ftw;\r
+  UINT16  Opcode;\r
+  UINT32  Eip;\r
+  UINT16  Cs;\r
+  UINT16  Rsvd1;\r
+  UINT32  DataOffset;\r
+  UINT16  Ds;\r
+  UINT8   Reserved2[10];\r
+  UINT8   St0Mm0[10], Rsvd3[6];\r
+  UINT8   St1Mm1[10], Rsvd4[6];\r
+  UINT8   St2Mm2[10], Rsvd5[6];\r
+  UINT8   St3Mm3[10], Rsvd6[6];\r
+  UINT8   St4Mm4[10], Rsvd7[6];\r
+  UINT8   St5Mm5[10], Rsvd8[6];\r
+  UINT8   St6Mm6[10], Rsvd9[6];\r
+  UINT8   St7Mm7[10], Rsvd10[6];\r
+  UINT8   Xmm0[16];\r
+  UINT8   Xmm1[16];\r
+  UINT8   Xmm2[16];\r
+  UINT8   Xmm3[16];\r
+  UINT8   Xmm4[16];\r
+  UINT8   Xmm5[16];\r
+  UINT8   Xmm6[16];\r
+  UINT8   Xmm7[16];\r
+  UINT8   Rsvd11[14 * 16];\r
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE32;\r
+\r
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE64 {\r
+  UINT16  Fcw;\r
+  UINT16  Fsw;\r
+  UINT16  Ftw;\r
+  UINT16  Opcode;\r
+  UINT64  Rip;\r
+  UINT64  DataOffset;\r
+  UINT8   Rsvd1[8];\r
+  UINT8   St0Mm0[10], Rsvd2[6];\r
+  UINT8   St1Mm1[10], Rsvd3[6];\r
+  UINT8   St2Mm2[10], Rsvd4[6];\r
+  UINT8   St3Mm3[10], Rsvd5[6];\r
+  UINT8   St4Mm4[10], Rsvd6[6];\r
+  UINT8   St5Mm5[10], Rsvd7[6];\r
+  UINT8   St6Mm6[10], Rsvd8[6];\r
+  UINT8   St7Mm7[10], Rsvd9[6];\r
+  UINT8   Xmm0[16];\r
+  UINT8   Xmm1[16];\r
+  UINT8   Xmm2[16];\r
+  UINT8   Xmm3[16];\r
+  UINT8   Xmm4[16];\r
+  UINT8   Xmm5[16];\r
+  UINT8   Xmm6[16];\r
+  UINT8   Xmm7[16];\r
+  UINT8   Xmm8[16];\r
+  UINT8   Xmm9[16];\r
+  UINT8   Xmm10[16];\r
+  UINT8   Xmm11[16];\r
+  UINT8   Xmm12[16];\r
+  UINT8   Xmm13[16];\r
+  UINT8   Xmm14[16];\r
+  UINT8   Xmm15[16];\r
+  UINT8   Rsvd10[6 * 16];\r
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE64;\r
+\r
+struct _EFI_SMM_SYSTEM_TABLE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (\r
+  IN EFI_SMM_SYSTEM_TABLE         * SystemTable,\r
+  IN EFI_GUID                     * Guid,\r
+  IN VOID                         *Table,\r
+  IN UINTN                        TableSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The SmmInstallConfigurationTable() function is used to maintain the list \r
+    of configuration tables that are stored in the System Management System \r
+    Table.  The list is stored as an array of (GUID, Pointer) pairs.  The list \r
+    must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r
+\r
+  Arguments:\r
+    SystemTable - A pointer to the SMM System Table.\r
+    Guid        - A pointer to the GUID for the entry to add, update, or remove.\r
+    Table       - A pointer to the buffer of the table to add.  \r
+    TableSize   - The size of the table to install.\r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The (Guid, Table) pair was added, updated, or removed.\r
+    EFI_INVALID_PARAMETER   - Guid is not valid.\r
+    EFI_NOT_FOUND           - An attempt was made to delete a non-existent entry.\r
+    EFI_OUT_OF_RESOURCES    - There is not enough memory available to complete the operation. \r
+\r
+--*/\r
+;\r
+\r
+//\r
+// System Management System Table (SMST)\r
+//\r
+typedef struct _EFI_SMM_SYSTEM_TABLE {\r
+  EFI_TABLE_HEADER                    Hdr;\r
+\r
+  CHAR16                              *SmmFirmwareVendor;\r
+  UINT32                              SmmFirmwareRevision;\r
+\r
+  EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;\r
+\r
+  //\r
+  // I/O Services\r
+  //\r
+  EFI_GUID                            EfiSmmCpuIoGuid;\r
+  EFI_SMM_CPU_IO_INTERFACE            SmmIo;\r
+\r
+  //\r
+  // Runtime memory service\r
+  //\r
+  EFI_SMMCORE_ALLOCATE_POOL           SmmAllocatePool;\r
+  EFI_SMMCORE_FREE_POOL               SmmFreePool;\r
+  EFI_SMMCORE_ALLOCATE_PAGES          SmmAllocatePages;\r
+  EFI_SMMCORE_FREE_PAGES              SmmFreePages;\r
+\r
+  //\r
+  // MP service\r
+  //\r
+  EFI_SMM_STARTUP_THIS_AP             SmmStartupThisAp;\r
+\r
+  //\r
+  // CPU information records\r
+  //\r
+  UINTN                               CurrentlyExecutingCpu;\r
+  UINTN                               NumberOfCpus;\r
+  EFI_SMM_CPU_SAVE_STATE              *CpuSaveState;\r
+  EFI_SMM_OPTIONAL_FP_SAVE_STATE      *CpuOptionalFloatingPointState;\r
+\r
+  //\r
+  // Extensibility table\r
+  //\r
+  UINTN                               NumberOfTableEntries;\r
+  EFI_CONFIGURATION_TABLE             *SmmConfigurationTable;\r
+\r
+} EFI_SMM_SYSTEM_TABLE;\r
+\r
+//\r
+// SMM Handler Definition\r
+//\r
+#define EFI_HANDLER_SUCCESS         0x0000\r
+#define EFI_HANDLER_CRITICAL_EXIT   0x0001\r
+#define EFI_HANDLER_SOURCE_QUIESCED 0x0002\r
+#define EFI_HANDLER_SOURCE_PENDING  0x0003\r
+\r
+//\r
+// Structure of Communicate Buffer\r
+//\r
+typedef struct {\r
+  EFI_GUID              HeaderGuid;\r
+  UINTN                 MessageLength;\r
+  UINT8                 Data[1];\r
+} EFI_SMM_COMMUNICATE_HEADER;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (\r
+  IN EFI_HANDLE             SmmImageHandle,\r
+  IN OUT VOID               *CommunicationBuffer OPTIONAL,\r
+  IN OUT UINTN              *SourceSize OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT) (\r
+  IN EFI_HANDLE             SmmImageHandle,\r
+  IN OUT VOID               *CommunicationBuffer OPTIONAL,\r
+  IN OUT UINTN              *SourceSize OPTIONAL\r
+  );\r
+\r
+typedef struct {\r
+  EFI_HANDLE                SmmHandler;\r
+  EFI_DEVICE_PATH_PROTOCOL  *HandlerDevicePath;\r
+} EFI_HANDLER_DESCRIPTOR;\r
+\r
+//\r
+// SMM Base Protocol Definition\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_REGISTER_HANDLER) (\r
+  IN EFI_SMM_BASE_PROTOCOL                           * This,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL                       * FilePath,\r
+  IN  VOID                                           *SourceBuffer OPTIONAL,\r
+  IN  UINTN                                          SourceSize,\r
+  OUT EFI_HANDLE                                     * ImageHandle,\r
+  IN  BOOLEAN                                        LegacyIA32Binary OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a given driver into SMRAM.  This is the equivalent of performing\r
+    the LoadImage/StartImage into System Management Mode.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    SourceBuffer          - Optional source buffer in case of the image file\r
+                            being in memory.\r
+    SourceSize            - Size of the source image file, if in memory.\r
+    ImageHandle           - Pointer to the handle that reflects the driver \r
+                            loaded into SMM.\r
+    LegacyIA32Binary      - The binary image to load is legacy 16 bit code.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The operation was successful.\r
+    EFI_OUT_OF_RESOURCES  - There were no additional SMRAM resources to load the handler\r
+    EFI_UNSUPPORTED       - This platform does not support 16-bit handlers.\r
+    EFI_UNSUPPORTED       - In runtime.\r
+    EFI_INVALID_PARAMETER - The handlers was not the correct image type\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_UNREGISTER_HANDLER) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  IN EFI_HANDLE                     ImageHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Remove a given driver SMRAM.  This is the equivalent of performing\r
+    the UnloadImage System Management Mode.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ImageHandle           - Pointer to the handle that reflects the driver \r
+                            loaded into SMM.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The operation was successful\r
+    EFI_INVALID_PARAMETER - The handler did not exist\r
+    EFI_UNSUPPORTED       - In runtime.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_COMMUNICATE) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  IN EFI_HANDLE                     ImageHandle,\r
+  IN OUT VOID                       *CommunicationBuffer,\r
+  IN OUT UINTN                      *SourceSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The SMM Inter-module Communicate Service Communicate() function \r
+    provides a services to send/received messages from a registered \r
+    EFI service.  The BASE protocol driver is responsible for doing \r
+    any of the copies such that the data lives in boot-service accessible RAM.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ImageHandle           - Pointer to the handle that reflects the driver \r
+                            loaded into SMM.\r
+    CommunicationBuffer   - Pointer to the buffer to convey into SMRAM.\r
+    SourceSize            - Size of the contents of buffer..\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The message was successfully posted\r
+    EFI_INVALID_PARAMETER - The buffer was NULL\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_CALLBACK_SERVICE) (\r
+  IN EFI_SMM_BASE_PROTOCOL                            * This,\r
+  IN EFI_HANDLE                                       SmmImageHandle,\r
+  IN EFI_SMM_CALLBACK_ENTRY_POINT                     CallbackAddress,\r
+  IN BOOLEAN                                          MakeLast OPTIONAL,\r
+  IN BOOLEAN                                          FloatingPointSave OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a callback to execute within SMM.   \r
+    This allows receipt of messages created with the Boot Service COMMUNICATE.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    CallbackAddress       - Address of the callback service\r
+    MakeFirst             - If present, will stipulate that the handler is posted \r
+                            to be the first module executed in the dispatch table.\r
+    MakeLast              - If present, will stipulate that the handler is posted \r
+                            to be last executed in the dispatch table.\r
+    FloatingPointSave     - This is an optional parameter which informs the \r
+                            EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save \r
+                            the floating point register state.  If any of the handlers \r
+                            require this, then the state will be saved for all of the handlers.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The operation was successful\r
+    EFI_OUT_OF_RESOURCES  - Not enough space in the dispatch queue\r
+    EFI_UNSUPPORTED       - In runtime.\r
+    EFI_UNSUPPORTED       - Not in SMM.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_ALLOCATE_POOL) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  IN EFI_MEMORY_TYPE                PoolType,\r
+  IN UINTN                          Size,\r
+  OUT VOID                          **Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The SmmAllocatePool() function allocates a memory region of Size bytes from memory of \r
+    type PoolType and returns the address of the allocated memory in the location referenced \r
+    by Buffer.  This function allocates pages from EFI SMRAM Memory as needed to grow the \r
+    requested pool type.  All allocations are eight-byte aligned.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    PoolType              - The type of pool to allocate.  \r
+                            The only supported type is EfiRuntimeServicesData; \r
+                            the interface will internally map this runtime request to SMRAM.\r
+    Size                  - The number of bytes to allocate from the pool.\r
+    Buffer                - A pointer to a pointer to the allocated buffer if the call \r
+                            succeeds; undefined otherwise.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The requested number of bytes was allocated.\r
+    EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.\r
+    EFI_INVALID_PARAMETER - PoolType was invalid.\r
+    EFI_UNSUPPORTED       - In runtime.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_FREE_POOL) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  IN VOID                           *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The SmmFreePool() function returns the memory specified by Buffer to the system.  \r
+    On return, the memory's type is EFI SMRAM Memory.  The Buffer that is freed must \r
+    have been allocated by SmmAllocatePool().\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Buffer                - Pointer to the buffer allocation.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The memory was returned to the system.\r
+    EFI_INVALID_PARAMETER - Buffer was invalid.\r
+    EFI_UNSUPPORTED       - In runtime.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_INSIDE_OUT) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  OUT BOOLEAN                       *InSmm\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    This routine tells caller if execution context is SMM or not.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The operation was successful\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_GET_SMST_LOCATION) (\r
+  IN EFI_SMM_BASE_PROTOCOL          * This,\r
+  IN OUT EFI_SMM_SYSTEM_TABLE       **Smst\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The GetSmstLocation() function returns the locatin of the System Management \r
+    Service Table.  The use of the API is such that a driver can discover the \r
+    location of the SMST in its entry point and then cache it in some driver \r
+    global variable so that the SMST can be invoked in subsequent callbacks.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Smst                  - Pointer to the SMST.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The operation was successful\r
+    EFI_INVALID_PARAMETER - Smst was invalid.  \r
+    EFI_UNSUPPORTED       - Not in SMM.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_SMM_BASE_PROTOCOL {\r
+  EFI_SMM_REGISTER_HANDLER    Register;\r
+  EFI_SMM_UNREGISTER_HANDLER  UnRegister;\r
+  EFI_SMM_COMMUNICATE         Communicate;\r
+  EFI_SMM_CALLBACK_SERVICE    RegisterCallback;\r
+  EFI_SMM_INSIDE_OUT          InSmm;\r
+  EFI_SMM_ALLOCATE_POOL       SmmAllocatePool;\r
+  EFI_SMM_FREE_POOL           SmmFreePool;\r
+  EFI_SMM_GET_SMST_LOCATION   GetSmstLocation;\r
+} EFI_SMM_BASE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmBaseProtocolGuid;\r
+extern EFI_GUID gEfiSmmCpuIoGuid;\r
+extern EFI_GUID gEfiSmmCommunicateHeaderGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c
new file mode 100644 (file)
index 0000000..d20283d
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmControl.c\r
+\r
+Abstract:\r
+\r
+  This file defines SMM Control abstraction protocol defined by the \r
+  SMM Component Interface Specification\r
+\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmControl)\r
+\r
+EFI_GUID  gEfiSmmControlProtocolGuid = EFI_SMM_CONTROL_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmControlProtocolGuid, "SMM Control Protocol", "SMM Control protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h
new file mode 100644 (file)
index 0000000..cf1bff0
--- /dev/null
@@ -0,0 +1,79 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmControl.h\r
+\r
+Abstract:\r
+\r
+  This file defines SMM Control abstraction protocol defined \r
+  by the SMM CIS.\r
+\r
+--*/\r
+\r
+#ifndef _SMM_CONTROL_H_\r
+#define _SMM_CONTROL_H_\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_CONTROL_PROTOCOL);\r
+\r
+#define EFI_SMM_CONTROL_PROTOCOL_GUID \\r
+  { \\r
+    0x8d12e231, 0xc667, 0x4fd1, 0x98, 0xf2, 0x24, 0x49, 0xa7, 0xe7, 0xb2, 0xe5 \\r
+  }\r
+\r
+//\r
+// SMM Control specification constant and types\r
+//\r
+// typedef EFI_SMM_PERIOD UINTN\r
+//\r
+// SMM Access specification Data Structures\r
+//\r
+typedef struct {\r
+  UINT8 SmiTriggerRegister;\r
+  UINT8 SmiDataRegister;\r
+} EFI_SMM_CONTROL_REGISTER;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_ACTIVATE) (\r
+  IN EFI_SMM_CONTROL_PROTOCOL                             * This,\r
+  IN OUT INT8                                             *ArgumentBuffer OPTIONAL,\r
+  IN OUT UINTN                                            *ArgumentBufferSize OPTIONAL,\r
+  IN BOOLEAN                                              Periodic OPTIONAL,\r
+  IN UINTN                                                ActivationInterval OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_DEACTIVATE) (\r
+  IN EFI_SMM_CONTROL_PROTOCOL                   * This,\r
+  IN BOOLEAN                                    Periodic OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_GET_REGISTER_INFO) (\r
+  IN EFI_SMM_CONTROL_PROTOCOL           * This,\r
+  IN OUT EFI_SMM_CONTROL_REGISTER       * SmiRegister\r
+  );\r
+\r
+typedef struct _EFI_SMM_CONTROL_PROTOCOL {\r
+  EFI_SMM_ACTIVATE          Trigger;\r
+  EFI_SMM_DEACTIVATE        Clear;\r
+  EFI_SMM_GET_REGISTER_INFO GetRegisterInfo;\r
+  UINTN                     MinimumTriggerPeriod;\r
+} EFI_SMM_CONTROL_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmControlProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h
new file mode 100644 (file)
index 0000000..05cc983
--- /dev/null
@@ -0,0 +1,150 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  CpuSaveState.h\r
+\r
+Abstract:\r
+\r
+  Define data structures used by EFI_SMM_CPU_SAVE_STATE protocol.\r
+\r
+Revision History\r
+\r
+++*/\r
+\r
+#ifndef _CPUSAVESTATE_H_\r
+#define _CPUSAVESTATE_H_\r
+\r
+typedef unsigned char               ASM_UINT8;\r
+typedef ASM_UINT8                   ASM_BOOL;\r
+typedef unsigned short              ASM_UINT16;\r
+typedef unsigned long               ASM_UINT32;\r
+\r
+#ifdef _H2INC\r
+typedef double                      ASM_UINT64;\r
+#else\r
+typedef unsigned __int64            ASM_UINT64;\r
+#endif\r
+\r
+#pragma pack (push)\r
+#pragma pack (1)\r
+\r
+typedef struct _EFI_SMM_CPU_STATE32 {\r
+  ASM_UINT8                         Reserved1[0xf8];        // fe00h\r
+  ASM_UINT32                        SMBASE;                 // fef8h\r
+  ASM_UINT32                        SMMRevId;               // fefch\r
+  ASM_UINT16                        IORestart;              // ff00h\r
+  ASM_UINT16                        AutoHALTRestart;        // ff02h\r
+  ASM_UINT32                        IEDBASE;                // ff04h\r
+  ASM_UINT8                         Reserved2[0x98];        // ff08h\r
+  ASM_UINT32                        IOMemAddr;              // ffa0h\r
+  ASM_UINT32                        IOMisc;                 // ffa4h\r
+  ASM_UINT32                        _ES;\r
+  ASM_UINT32                        _CS;\r
+  ASM_UINT32                        _SS;\r
+  ASM_UINT32                        _DS;\r
+  ASM_UINT32                        _FS;\r
+  ASM_UINT32                        _GS;\r
+  ASM_UINT32                        _LDTBase;\r
+  ASM_UINT32                        _TR;\r
+  ASM_UINT32                        _DR7;\r
+  ASM_UINT32                        _DR6;\r
+  ASM_UINT32                        _EAX;\r
+  ASM_UINT32                        _ECX;\r
+  ASM_UINT32                        _EDX;\r
+  ASM_UINT32                        _EBX;\r
+  ASM_UINT32                        _ESP;\r
+  ASM_UINT32                        _EBP;\r
+  ASM_UINT32                        _ESI;\r
+  ASM_UINT32                        _EDI;\r
+  ASM_UINT32                        _EIP;\r
+  ASM_UINT32                        _EFLAGS;\r
+  ASM_UINT32                        _CR3;\r
+  ASM_UINT32                        _CR0;\r
+} EFI_SMM_CPU_STATE32;\r
+\r
+typedef struct _EFI_SMM_CPU_STATE64 {\r
+  ASM_UINT8                         Reserved1[0x1d0];       // fc00h\r
+  ASM_UINT32                        GdtBaseHiDword;         // fdd0h\r
+  ASM_UINT32                        LdtBaseHiDword;         // fdd4h\r
+  ASM_UINT32                        IdtBaseHiDword;         // fdd8h\r
+  ASM_UINT8                         Reserved2[0xc];         // fddch\r
+  ASM_UINT64                        IO_EIP;                 // fde8h\r
+  ASM_UINT8                         Reserved3[0x50];        // fdf0h\r
+  ASM_UINT32                        _CR4;                   // fe40h\r
+  ASM_UINT8                         Reserved4[0x48];        // fe44h\r
+  ASM_UINT32                        GdtBaseLoDword;         // fe8ch\r
+  ASM_UINT32                        GdtLimit;               // fe90h\r
+  ASM_UINT32                        IdtBaseLoDword;         // fe94h\r
+  ASM_UINT32                        IdtLimit;               // fe98h\r
+  ASM_UINT32                        LdtBaseLoDword;         // fe9ch\r
+  ASM_UINT32                        LdtLimit;               // fea0h\r
+  ASM_UINT32                        LdtInfo;                // fea4h\r
+  ASM_UINT8                         Reserved5[0x50];        // fea8h\r
+  ASM_UINT32                        SMBASE;                 // fef8h\r
+  ASM_UINT32                        SMMRevId;               // fefch\r
+  ASM_UINT16                        IORestart;              // ff00h\r
+  ASM_UINT16                        AutoHALTRestart;        // ff02h\r
+  ASM_UINT32                        IEDBASE;                // ff04h\r
+  ASM_UINT8                         Reserved6[0x14];        // ff08h\r
+  ASM_UINT64                        _R15;                   // ff1ch\r
+  ASM_UINT64                        _R14;\r
+  ASM_UINT64                        _R13;\r
+  ASM_UINT64                        _R12;\r
+  ASM_UINT64                        _R11;\r
+  ASM_UINT64                        _R10;\r
+  ASM_UINT64                        _R9;\r
+  ASM_UINT64                        _R8;\r
+  ASM_UINT64                        _RAX;                   // ff5ch\r
+  ASM_UINT64                        _RCX;\r
+  ASM_UINT64                        _RDX;\r
+  ASM_UINT64                        _RBX;\r
+  ASM_UINT64                        _RSP;\r
+  ASM_UINT64                        _RBP;\r
+  ASM_UINT64                        _RSI;\r
+  ASM_UINT64                        _RDI;\r
+  ASM_UINT64                        IOMemAddr;              // ff9ch\r
+  ASM_UINT32                        IOMisc;                 // ffa4h\r
+  ASM_UINT32                        _ES;                    // ffa8h\r
+  ASM_UINT32                        _CS;\r
+  ASM_UINT32                        _SS;\r
+  ASM_UINT32                        _DS;\r
+  ASM_UINT32                        _FS;\r
+  ASM_UINT32                        _GS;\r
+  ASM_UINT32                        _LDTR;                  // ffc0h\r
+  ASM_UINT32                        _TR;\r
+  ASM_UINT64                        _DR7;                   // ffc8h\r
+  ASM_UINT64                        _DR6;\r
+  ASM_UINT64                        _RIP;                   // ffd8h\r
+  ASM_UINT64                        IA32_EFER;              // ffe0h\r
+  ASM_UINT64                        _RFLAGS;                // ffe8h\r
+  ASM_UINT64                        _CR3;                   // fff0h\r
+  ASM_UINT64                        _CR0;                   // fff8h\r
+} EFI_SMM_CPU_STATE64;\r
+\r
+#pragma warning (push)\r
+#pragma warning (disable: 4201)\r
+typedef union _EFI_SMM_CPU_STATE {\r
+  struct {\r
+    ASM_UINT8                       Reserved[0x200];\r
+    EFI_SMM_CPU_STATE32             x86;\r
+  };\r
+  EFI_SMM_CPU_STATE64               x64;\r
+} EFI_SMM_CPU_STATE;\r
+#pragma warning (pop)\r
+\r
+#pragma pack (pop)\r
+\r
+#define EFI_SMM_MIN_REV_ID_x64      0x30006\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c
new file mode 100644 (file)
index 0000000..703b355
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmCpuState.c\r
+\r
+Abstract:\r
+\r
+    Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmCpuState)\r
+\r
+EFI_GUID gEfiSmmCpuSaveStateProtocolGuid = EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiSmmCpuSaveStateProtocolGuid, "SMM CPU Save State Protocol", "SMM CPU Save State Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h
new file mode 100644 (file)
index 0000000..1a6c79d
--- /dev/null
@@ -0,0 +1,43 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmCpuState.h\r
+\r
+Abstract:\r
+\r
+    Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _SMMSAVESTATE_H_\r
+#define _SMMSAVESTATE_H_\r
+\r
+#include "CpuSaveState.h"\r
+\r
+//\r
+// Global ID for the Sx SMI Protocol\r
+//\r
+// {21F302AD-6E94-471b-84BC-B14800403A1D}\r
+#define EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID  \\r
+  { 0x21f302ad, 0x6e94, 0x471b, 0x84, 0xbc, 0xb1, 0x48, 0x0, 0x40, 0x3a, 0x1d }\r
+\r
+typedef struct _EFI_SMM_CPU_SAVE_STATE_PROTOCOL {\r
+  EFI_SMM_CPU_STATE                 **CpuSaveState;\r
+} EFI_SMM_CPU_SAVE_STATE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmCpuSaveStateProtocolGuid;\r
+\r
+#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 (file)
index 0000000..4bf9c73
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmGpiDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Gpi Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch)\r
+\r
+EFI_GUID  gEfiSmmGpiDispatchProtocolGuid = EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiSmmGpiDispatchProtocolGuid, "SMM GPI SMI Dispatch Protocol", "EFI 2.0 SMM GPI SMI Dispatch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h
new file mode 100644 (file)
index 0000000..861418e
--- /dev/null
@@ -0,0 +1,152 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmGpiDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Gpi Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_GPI_DISPATCH_H_\r
+#define _EFI_SMM_GPI_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the GPI SMI Protocol\r
+//\r
+#define EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0xe0744b81, 0x9513, 0x49cd, 0x8c, 0xea, 0xe9, 0x24, 0x5e, 0x70, 0x39, 0xda \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_GPI_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// GpiMask is a bit mask of 32 possible general purpose inputs that can generate a\r
+// a SMI.  Bit 0 corresponds to logical GPI[0], 1 corresponds to logical GPI[1], etc.\r
+//\r
+// The logical GPI index to physical pin on device is described by the GPI device name\r
+// found on the same handle as the GpiSmi child dispatch protocol.  The GPI device name\r
+// is defined as protocol with a GUID name and NULL protocol pointer.\r
+//\r
+typedef struct {\r
+  UINTN GpiNum;\r
+} EFI_SMM_GPI_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_GPI_DISPATCH) (\r
+  IN  EFI_HANDLE                    DispatchHandle,\r
+  IN  EFI_SMM_GPI_DISPATCH_CONTEXT  * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a GPI SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_GPI_REGISTER) (\r
+  IN EFI_SMM_GPI_DISPATCH_PROTOCOL            * This,\r
+  IN  EFI_SMM_GPI_DISPATCH                    DispatchFunction,\r
+  IN  EFI_SMM_GPI_DISPATCH_CONTEXT            * DispatchContext,\r
+  OUT EFI_HANDLE                              * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the GPI(s) for which the dispatch function\r
+                            should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The GPI input value\r
+                            is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_GPI_UNREGISTER) (\r
+  IN EFI_SMM_GPI_DISPATCH_PROTOCOL            * This,\r
+  IN  EFI_HANDLE                              DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM GPI SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_GPI_DISPATCH_PROTOCOL {\r
+  EFI_SMM_GPI_REGISTER    Register;\r
+  EFI_SMM_GPI_UNREGISTER  UnRegister;\r
+  UINTN                   NumSupportedGpis;\r
+} EFI_SMM_GPI_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmGpiDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c
new file mode 100644 (file)
index 0000000..a224873
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmIchnDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm ICH N Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch)\r
+\r
+EFI_GUID  gEfiSmmIchnDispatchProtocolGuid = EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiSmmIchnDispatchProtocolGuid, "SMM ICHn SMI Dispatch Protocol", "EFI 2.0 SMM ICHn SMI Dispatch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h
new file mode 100644 (file)
index 0000000..70d92f4
--- /dev/null
@@ -0,0 +1,204 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmIchnDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm ICH [N] Specific Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_ICHN_DISPATCH_H_\r
+#define _EFI_SMM_ICHN_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the ICH SMI Protocol\r
+//\r
+#define EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0xc50b323e, 0x9075, 0x4f2a, 0xac, 0x8e, 0xd2, 0x59, 0x6a, 0x10, 0x85, 0xcc \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_ICHN_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// ICHN Specific SMIs.  These are miscellaneous SMI sources that are supported by the\r
+// ICHN specific SMI implementation.  These may change over time.  TrapNumber is only\r
+// valid if the Type is Trap.\r
+//\r
+typedef enum {\r
+  //\r
+  // NOTE: NEVER delete items from this list/enumeration!  Doing so will prevent other versions\r
+  // of the code from compiling.  If the ICH version your driver is written for doesn't support\r
+  // some of these SMIs, then simply return EFI_UNSUPPORTED when a child/client tries to register\r
+  // for them.\r
+  //\r
+  IchnMch,\r
+  IchnPme,\r
+  IchnRtcAlarm,\r
+  IchnRingIndicate,\r
+  IchnAc97Wake,\r
+  IchnSerialIrq,\r
+  IchnY2KRollover,\r
+  IchnTcoTimeout,\r
+  IchnOsTco,\r
+  IchnNmi,\r
+  IchnIntruderDetect,\r
+  IchnBiosWp,\r
+  IchnMcSmi,\r
+  IchnPmeB0,\r
+  IchnThrmSts,\r
+  IchnSmBus,\r
+  IchnIntelUsb2,\r
+  IchnMonSmi7,\r
+  IchnMonSmi6,\r
+  IchnMonSmi5,\r
+  IchnMonSmi4,\r
+  IchnDevTrap13,\r
+  IchnDevTrap12,\r
+  IchnDevTrap11,\r
+  IchnDevTrap10,\r
+  IchnDevTrap9,\r
+  IchnDevTrap8,\r
+  IchnDevTrap7,\r
+  IchnDevTrap6,\r
+  IchnDevTrap5,\r
+  IchnDevTrap3,\r
+  IchnDevTrap2,\r
+  IchnDevTrap1,\r
+  IchnDevTrap0,\r
+  IchnIoTrap3,\r
+  IchnIoTrap2,\r
+  IchnIoTrap1,\r
+  IchnIoTrap0,\r
+  IchnPciExpress,\r
+  IchnMonitor,\r
+  IchnSpi,\r
+  IchnQRT,\r
+  IchnGpioUnlock,\r
+  //\r
+  // INSERT NEW ITEMS JUST BEFORE THIS LINE\r
+  //\r
+  NUM_ICHN_TYPES  // the number of items in this enumeration\r
+} EFI_SMM_ICHN_SMI_TYPE;\r
+\r
+typedef struct {\r
+  EFI_SMM_ICHN_SMI_TYPE Type;\r
+} EFI_SMM_ICHN_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_ICHN_DISPATCH) (\r
+  IN  EFI_HANDLE                      DispatchHandle,\r
+  IN  EFI_SMM_ICHN_DISPATCH_CONTEXT   * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a ICH n specific SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_ICHN_REGISTER) (\r
+  IN EFI_SMM_ICHN_DISPATCH_PROTOCOL             * This,\r
+  IN  EFI_SMM_ICHN_DISPATCH                     DispatchFunction,\r
+  IN  EFI_SMM_ICHN_DISPATCH_CONTEXT             * DispatchContext,\r
+  OUT EFI_HANDLE                                * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the ICHN SMI source for which the dispatch\r
+                            function should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The ICHN input value\r
+                            is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_ICHN_UNREGISTER) (\r
+  IN EFI_SMM_ICHN_DISPATCH_PROTOCOL             * This,\r
+  IN  EFI_HANDLE                                DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Ich n specific SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_ICHN_DISPATCH_PROTOCOL {\r
+  EFI_SMM_ICHN_REGISTER   Register;\r
+  EFI_SMM_ICHN_UNREGISTER UnRegister;\r
+} EFI_SMM_ICHN_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmIchnDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c
new file mode 100644 (file)
index 0000000..dc3c692
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmPeriodicTimerDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Periodic Timer Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch)\r
+\r
+EFI_GUID  gEfiSmmPeriodicTimerDispatchProtocolGuid = EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiSmmPeriodicTimerDispatchProtocolGuid, "SMM Periodic Timer SMI Dispatch Protocol",\r
+      "EFI 2.0 SMM Periodic Timer SMI Dispatch Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h
new file mode 100644 (file)
index 0000000..9aabb0c
--- /dev/null
@@ -0,0 +1,205 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmPeriodicTimerDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Periodic Timer Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_\r
+#define _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the Periodic Timer SMI Protocol\r
+//\r
+#define EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0x9cca03fc, 0x4c9e, 0x4a19, 0x9b, 0x6, 0xed, 0x7b, 0x47, 0x9b, 0xde, 0x55 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// Period is the minimum period of time in 100 nanosecond units that child gets called.\r
+// The child will be called back after a time greater than the time Period.\r
+//\r
+// SmiTickInterval is the period of time interval between SMIs.  Children of this interface\r
+// should use this field when registering for periodic timer intervals when a finer\r
+// granularity periodic SMI is desired.  Valid values for this field are those returned\r
+// by GetNextInterval.  A value of 0 indicates the parent is allowed to use any SMI\r
+// interval period to satisfy the requested period.\r
+//    Example: A chipset supports periodic SMIs on every 64ms or 2 seconds.\r
+//      A child wishes schedule a period SMI to fire on a period of 3 seconds, there\r
+//      are several ways to approach the problem:\r
+//      1. The child may accept a 4 second periodic rate, in which case it registers with\r
+//           Period = 40000\r
+//           SmiTickInterval = 20000\r
+//         The resulting SMI will occur every 2 seconds with the child called back on\r
+//         every 2nd SMI.\r
+//         NOTE: the same result would occur if the child set SmiTickInterval = 0.\r
+//      2. The child may choose the finer granularity SMI (64ms):\r
+//           Period = 30000\r
+//           SmiTickInterval = 640\r
+//         The resulting SMI will occur every 64ms with the child called back on\r
+//         every 47th SMI.\r
+//         NOTE: the child driver should be aware that this will result in more\r
+//           SMIs occuring during system runtime which can negatively impact system\r
+//           performance.\r
+//\r
+// ElapsedTime is the actual time in 100 nanosecond units elapsed since last called, a\r
+// value of 0 indicates an unknown amount of time.\r
+//\r
+typedef struct {\r
+  UINT64  Period;\r
+  UINT64  SmiTickInterval;\r
+  UINT64  ElapsedTime;\r
+} EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_DISPATCH) (\r
+  IN  EFI_HANDLE                                DispatchHandle,\r
+  IN  EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT   * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a Periodic Timer SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_INTERVAL) (\r
+  IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL           * This,\r
+  IN OUT UINT64                                         **SmiTickInterval\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Returns the next SMI tick period supported by the chipset.  The order\r
+    returned is from longest to shortest interval period.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    SmiTickInterval       - Pointer to pointer of next shorter SMI interval\r
+                            period supported by the child.  This parameter\r
+                            works as a get-first, get-next field.   The first\r
+                            time this function is called, *SmiTickInterval\r
+                            should be set to NULL to get the longest SMI\r
+                            interval.  The returned *SmiTickInterval should\r
+                            be passed in on subsequent calls to get\r
+                            the next shorter interval period until\r
+                            *SmiTickInterval = NULL.\r
+\r
+  Returns:\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_REGISTER) (\r
+  IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_SMM_PERIODIC_TIMER_DISPATCH                   DispatchFunction,\r
+  IN  EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT           * DispatchContext,\r
+  OUT EFI_HANDLE                                        * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the period at which the dispatch function\r
+                            should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The period input value\r
+                            is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_UNREGISTER) (\r
+  IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_HANDLE                                        DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Periodic Timer Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL {\r
+  EFI_SMM_PERIODIC_TIMER_REGISTER   Register;\r
+  EFI_SMM_PERIODIC_TIMER_UNREGISTER UnRegister;\r
+  EFI_SMM_PERIODIC_TIMER_INTERVAL   GetNextShorterInterval;\r
+} EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmPeriodicTimerDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c
new file mode 100644 (file)
index 0000000..5124fca
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmPowerButtonDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Power Button Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch)\r
+\r
+EFI_GUID  gEfiSmmPowerButtonDispatchProtocolGuid = EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiSmmPowerButtonDispatchProtocolGuid, "SMM Power Button SMI Dispatch Protocol",\r
+      "EFI 2.0 SMM Power Button SMI Dispatch Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h
new file mode 100644 (file)
index 0000000..2e53bf5
--- /dev/null
@@ -0,0 +1,153 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmPowerButtonDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Power Button Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_POWER_BUTTON_DISPATCH_H_\r
+#define _EFI_SMM_POWER_BUTTON_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the Power Button SMI Protocol\r
+//\r
+#define EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0xb709efa0, 0x47a6, 0x4b41, 0xb9, 0x31, 0x12, 0xec, 0xe7, 0xa8, 0xee, 0x56 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// Power Button. Example, Use for changing LEDs before ACPI OS is on.\r
+//    - DXE/BDS Phase\r
+//    - OS Install Phase\r
+//\r
+typedef enum {\r
+  PowerButtonEntry,\r
+  PowerButtonExit\r
+} EFI_POWER_BUTTON_PHASE;\r
+\r
+typedef struct {\r
+  EFI_POWER_BUTTON_PHASE  Phase;\r
+} EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_POWER_BUTTON_DISPATCH) (\r
+  IN  EFI_HANDLE                             DispatchHandle,\r
+  IN  EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT  * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a Power Button SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_POWER_BUTTON_REGISTER) (\r
+  IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL            * This,\r
+  IN  EFI_SMM_POWER_BUTTON_DISPATCH                    DispatchFunction,\r
+  IN  EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT            * DispatchContext,\r
+  OUT EFI_HANDLE                                       * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the Power Button SMI phase for which the dispatch\r
+                            function should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The Power Button  SMI\r
+                            phase is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_POWER_BUTTON_UNREGISTER) (\r
+  IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL             * This,\r
+  IN  EFI_HANDLE                                        DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Power Button SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL {\r
+  EFI_SMM_POWER_BUTTON_REGISTER   Register;\r
+  EFI_SMM_POWER_BUTTON_UNREGISTER UnRegister;\r
+} EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c
new file mode 100644 (file)
index 0000000..0967d38
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmStandbyButtonDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Standby Button Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch)\r
+\r
+EFI_GUID  gEfiSmmStandbyButtonDispatchProtocolGuid = EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiSmmStandbyButtonDispatchProtocolGuid, "SMM Standby Button SMI Dispatch Protocol",\r
+      "EFI 2.0 SMM Standby Button SMI Dispatch Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h
new file mode 100644 (file)
index 0000000..9426cd4
--- /dev/null
@@ -0,0 +1,153 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmStandbyButtonDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Standby Button Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_\r
+#define _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the Standby Button SMI Protocol\r
+//\r
+#define EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0x78965b98, 0xb0bf, 0x449e, 0x8b, 0x22, 0xd2, 0x91, 0x4e, 0x49, 0x8a, 0x98 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// Standby Button. Example, Use for changing LEDs before ACPI OS is on.\r
+//    - DXE/BDS Phase\r
+//    - OS Install Phase\r
+//\r
+typedef enum {\r
+  Entry,\r
+  Exit\r
+} EFI_STANDBY_BUTTON_PHASE;\r
+\r
+typedef struct {\r
+  EFI_STANDBY_BUTTON_PHASE  Phase;\r
+} EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_DISPATCH) (\r
+  IN  EFI_HANDLE                                DispatchHandle,\r
+  IN  EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT   * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a Standby Button SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_REGISTER) (\r
+  IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_SMM_STANDBY_BUTTON_DISPATCH                   DispatchFunction,\r
+  IN  EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT           * DispatchContext,\r
+  OUT EFI_HANDLE                                        * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the Standby Button SMI phase for which the dispatch\r
+                            function should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The Standby Button  SMI\r
+                            phase is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_UNREGISTER) (\r
+  IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_HANDLE                                        DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Standby Button SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL {\r
+  EFI_SMM_STANDBY_BUTTON_REGISTER   Register;\r
+  EFI_SMM_STANDBY_BUTTON_UNREGISTER UnRegister;\r
+} EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmStandbyButtonDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c
new file mode 100644 (file)
index 0000000..593b406
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmStatusCode.c\r
+\r
+Abstract:\r
+\r
+  SMM Status code Protocol as defined in EFI 2.0 (for Status Code Architectural Protocol)\r
+\r
+  This code abstracts Status Code reporting.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)\r
+\r
+EFI_GUID  gEfiSmmStatusCodeProtocolGuid = EFI_SMM_STATUS_CODE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmStatusCodeProtocolGuid, "SMM Status Code", "SMM Status Code Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h
new file mode 100644 (file)
index 0000000..ef9a089
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SmmStatusCode.h\r
+\r
+Abstract:\r
+\r
+  SMM Status code Protocol as defined in the DXE CIS (Status Code Architectural Protocol)\r
+\r
+  This code abstracts SMM Status Code reporting.\r
+\r
+--*/\r
+\r
+#ifndef _PROTOCOL_SMM_STATUS_CODE_H__\r
+#define _PROTOCOL_SMM_STATUS_CODE_H__\r
+\r
+//\r
+// Global ID for the Smm Status Code Protocol\r
+//\r
+#define EFI_SMM_STATUS_CODE_PROTOCOL_GUID \\r
+  { \\r
+    0x6afd2b77, 0x98c1, 0x4acd, 0xa6, 0xf9, 0x8a, 0x94, 0x39, 0xde, 0xf, 0xb1 \\r
+  }\r
+\r
+extern EFI_GUID gEfiSmmStatusCodeProtocolGuid;\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_SMM_STATUS_CODE_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_REPORT_STATUS_CODE) (\r
+  IN EFI_SMM_STATUS_CODE_PROTOCOL * This,\r
+  IN EFI_STATUS_CODE_TYPE         CodeType,\r
+  IN EFI_STATUS_CODE_VALUE        Value,\r
+  IN UINT32                       Instance,\r
+  IN EFI_GUID                     * CallerId,\r
+  IN EFI_STATUS_CODE_DATA         * Data OPTIONAL\r
+  );\r
+\r
+typedef struct _EFI_SMM_STATUS_CODE_PROTOCOL {\r
+  EFI_SMM_REPORT_STATUS_CODE  ReportStatusCode;\r
+} EFI_SMM_STATUS_CODE_PROTOCOL;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c
new file mode 100644 (file)
index 0000000..c6ff0aa
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmSwDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Software Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch)\r
+\r
+EFI_GUID  gEfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmSwDispatchProtocolGuid, "SMM Sw SMI Dispatch Protocol", "EFI 2.0 SMM Sw SMI Dispatch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h
new file mode 100644 (file)
index 0000000..765d1ba
--- /dev/null
@@ -0,0 +1,151 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmSwDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Software Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_SW_DISPATCH_H_\r
+#define _EFI_SMM_SW_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the SW SMI Protocol\r
+//\r
+#define EFI_SMM_SW_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0xe541b773, 0xdd11, 0x420c, 0xb0, 0x26, 0xdf, 0x99, 0x36, 0x53, 0xf8, 0xbf \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_SW_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+//\r
+// A particular chipset may not support all possible software SMI input values.\r
+// For example, the ICH supports only values 00h to 0FFh.  The parent only allows a single\r
+// child registration for each SwSmiInputValue.\r
+//\r
+typedef struct {\r
+  UINTN SwSmiInputValue;\r
+} EFI_SMM_SW_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_SW_DISPATCH) (\r
+  IN  EFI_HANDLE                    DispatchHandle,\r
+  IN  EFI_SMM_SW_DISPATCH_CONTEXT   * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a Software SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The SwSmiInputValue field is filled in\r
+                          by the software dispatch driver prior to\r
+                          invoking this dispatch function.\r
+                          The dispatch function will only be called\r
+                          for input values for which it is registered.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_SW_REGISTER) (\r
+  IN EFI_SMM_SW_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_SMM_SW_DISPATCH                   DispatchFunction,\r
+  IN  EFI_SMM_SW_DISPATCH_CONTEXT           * DispatchContext,\r
+  OUT EFI_HANDLE                            * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function which Software SMI input value the\r
+                            dispatch function should be invoked for.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The SW driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The SW SMI input value\r
+                            is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_SW_UNREGISTER) (\r
+  IN EFI_SMM_SW_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_HANDLE                            DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Software SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_SW_DISPATCH_PROTOCOL {\r
+  EFI_SMM_SW_REGISTER   Register;\r
+  EFI_SMM_SW_UNREGISTER UnRegister;\r
+  UINTN                 MaximumSwiValue;\r
+} EFI_SMM_SW_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmSwDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c
new file mode 100644 (file)
index 0000000..8ef15b5
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmSxDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm Sx Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch)\r
+\r
+EFI_GUID  gEfiSmmSxDispatchProtocolGuid = EFI_SMM_SX_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSmmSxDispatchProtocolGuid, "SMM Sx Dispatch Protocol", "EFI 2.0 SMM Sx Dispatch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h
new file mode 100644 (file)
index 0000000..e80272f
--- /dev/null
@@ -0,0 +1,170 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmSxDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm Sx Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_SX_DISPATCH_H_\r
+#define _EFI_SMM_SX_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the Sx SMI Protocol\r
+//\r
+#define EFI_SMM_SX_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0x14fc52be, 0x1dc, 0x426c, 0x91, 0xae, 0xa2, 0x3c, 0x3e, 0x22, 0xa, 0xe8 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_SX_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+typedef enum {\r
+  SxS0,\r
+  SxS1,\r
+  SxS2,\r
+  SxS3,\r
+  SxS4,\r
+  SxS5,\r
+  EfiMaximumSleepType\r
+} EFI_SLEEP_TYPE;\r
+\r
+typedef enum {\r
+  SxEntry,\r
+  SxExit,\r
+  EfiMaximumPhase\r
+} EFI_SLEEP_PHASE;\r
+\r
+typedef struct {\r
+  EFI_SLEEP_TYPE  Type;\r
+  EFI_SLEEP_PHASE Phase;\r
+} EFI_SMM_SX_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_SX_DISPATCH) (\r
+  IN  EFI_HANDLE                    DispatchHandle,\r
+  IN  EFI_SMM_SX_DISPATCH_CONTEXT   * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a Sx state SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The Type and Phase fields are filled in\r
+                          by the Sx dispatch driver prior to invoking\r
+                          this dispatch function.\r
+                          For this intertace, the Sx driver will call the\r
+                          dispatch function for all Sx type and phases,\r
+                          so the Sx state handler(s) must check the Type\r
+                          and Phase field of the Dispatch context and act\r
+                          accordingly.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_SX_REGISTER) (\r
+  IN EFI_SMM_SX_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_SMM_SX_DISPATCH                   DispatchFunction,\r
+  IN  EFI_SMM_SX_DISPATCH_CONTEXT           * DispatchContext,\r
+  OUT EFI_HANDLE                            * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function which Sx state type and phase the caller\r
+                            wishes to be called back on.  For this intertace,\r
+                            the Sx driver will call the registered handlers for\r
+                            all Sx type and phases, so the Sx state handler(s)\r
+                            must check the Type and Phase field of the Dispatch\r
+                            context and act accordingly.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_UNSUPPORTED       - The Sx driver or hardware does not support that\r
+                            Sx Type/Phase.\r
+    EFI_DEVICE_ERROR      - The Sx driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. Type & Phase are not\r
+                            within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_SX_UNREGISTER) (\r
+  IN EFI_SMM_SX_DISPATCH_PROTOCOL           * This,\r
+  IN  EFI_HANDLE                            DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully unregistered and the\r
+                            SMI source has been disabled if there are no other registered child\r
+                            dispatch functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM Child Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_SX_DISPATCH_PROTOCOL {\r
+  EFI_SMM_SX_REGISTER   Register;\r
+  EFI_SMM_SX_UNREGISTER UnRegister;\r
+} EFI_SMM_SX_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmSxDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c
new file mode 100644 (file)
index 0000000..32d1f70
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmUsbDispatch.c\r
+    \r
+Abstract:\r
+\r
+    EFI Smm USB Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch)\r
+\r
+EFI_GUID  gEfiSmmUsbDispatchProtocolGuid = EFI_SMM_USB_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiSmmUsbDispatchProtocolGuid, "SMM USB SMI Dispatch Protocol", "EFI 2.0 SMM USB SMI Dispatch Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h
new file mode 100644 (file)
index 0000000..386aad2
--- /dev/null
@@ -0,0 +1,149 @@
+/*++\r
+\r
+Copyright (c) 1999 - 2002, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SmmUsbDispatch.h\r
+\r
+Abstract:\r
+\r
+    EFI Smm USB Smi Child Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_USB_DISPATCH_H_\r
+#define _EFI_SMM_USB_DISPATCH_H_\r
+\r
+//\r
+// Global ID for the USB Protocol\r
+//\r
+#define EFI_SMM_USB_DISPATCH_PROTOCOL_GUID \\r
+  { \\r
+    0xa05b6ffd, 0x87af, 0x4e42, 0x95, 0xc9, 0x62, 0x28, 0xb6, 0x3c, 0xf3, 0xf3 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_SMM_USB_DISPATCH_PROTOCOL);\r
+\r
+//\r
+// Related Definitions\r
+//\r
+typedef enum {\r
+  UsbLegacy,\r
+  UsbWake\r
+} EFI_USB_SMI_TYPE;\r
+\r
+typedef struct {\r
+  EFI_USB_SMI_TYPE          Type;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Device;\r
+} EFI_SMM_USB_DISPATCH_CONTEXT;\r
+\r
+//\r
+// Member functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SMM_USB_DISPATCH) (\r
+  IN  EFI_HANDLE                    DispatchHandle,\r
+  IN  EFI_SMM_USB_DISPATCH_CONTEXT  * DispatchContext\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Dispatch function for a USB SMI handler.\r
+\r
+  Arguments:\r
+    DispatchHandle      - Handle of this dispatch function.\r
+    DispatchContext     - Pointer to the dispatch function's context.\r
+                          The DispatchContext fields are filled in\r
+                          by the dispatching driver prior to\r
+                          invoking this dispatch function.\r
+\r
+  Returns:\r
+    Nothing\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_USB_REGISTER) (\r
+  IN EFI_SMM_USB_DISPATCH_PROTOCOL            * This,\r
+  IN  EFI_SMM_USB_DISPATCH                    DispatchFunction,\r
+  IN  EFI_SMM_USB_DISPATCH_CONTEXT            * DispatchContext,\r
+  OUT EFI_HANDLE                              * DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchFunction      - Pointer to dispatch function to be invoked for\r
+                            this SMI source\r
+    DispatchContext       - Pointer to the dispatch function's context.\r
+                            The caller fills this context in before calling\r
+                            the register function to indicate to the register\r
+                            function the USB SMI types for which the dispatch\r
+                            function should be invoked.\r
+    DispatchHandle        - Handle of dispatch function, for when interfacing\r
+                            with the parent Sx state SMM driver.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully\r
+                            registered and the SMI source has been enabled.\r
+    EFI_DEVICE_ERROR      - The driver was unable to enable the SMI source.\r
+    EFI_OUT_OF_RESOURCES  - Not enough memory (system or SMM) to manage this\r
+                            child.\r
+    EFI_INVALID_PARAMETER - DispatchContext is invalid. The USB SMI type\r
+                            is not within valid range.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SMM_USB_UNREGISTER) (\r
+  IN EFI_SMM_USB_DISPATCH_PROTOCOL            * This,\r
+  IN  EFI_HANDLE                              DispatchHandle\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Unregister a child SMI source dispatch function with a parent SMM driver\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DispatchHandle        - Handle of dispatch function to deregister.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The dispatch function has been successfully \r
+                            unregistered and the SMI source has been disabled\r
+                            if there are no other registered child dispatch\r
+                            functions for this SMI source.\r
+    EFI_INVALID_PARAMETER - Handle is invalid.\r
+    other                 - TBD\r
+\r
+--*/\r
+\r
+//\r
+// Interface structure for the SMM USB SMI Dispatch Protocol\r
+//\r
+typedef struct _EFI_SMM_USB_DISPATCH_PROTOCOL {\r
+  EFI_SMM_USB_REGISTER    Register;\r
+  EFI_SMM_USB_UNREGISTER  UnRegister;\r
+} EFI_SMM_USB_DISPATCH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiSmmUsbDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c
new file mode 100644 (file)
index 0000000..f5b04ac
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    AcpiDescription.c\r
+    \r
+Abstract:\r
+\r
+\r
+   GUIDs used for ACPI Description\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (AcpiDescription)\r
+\r
+EFI_GUID  gEfiAcpiDescriptionGuid = EFI_ACPI_DESCRIPTION_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiAcpiDescriptionGuid, "ACPI Description", "ACPI Description GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h
new file mode 100644 (file)
index 0000000..43adf01
--- /dev/null
@@ -0,0 +1,127 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    AcpiDescription.h\r
+    \r
+Abstract:\r
+\r
+\r
+   GUIDs used for ACPI Description\r
+\r
+--*/\r
+\r
+#ifndef _EFI_ACPI_DESCRIPTION_H_\r
+#define _EFI_ACPI_DESCRIPTION_H_\r
+\r
+#define EFI_ACPI_DESCRIPTION_GUID \\r
+  { \\r
+    0x3c699197, 0x93c, 0x4c69, 0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9 \\r
+  }\r
+\r
+typedef struct {\r
+  UINT8   AddressSpaceId;\r
+  UINT8   RegisterBitWidth;\r
+  UINT8   RegisterBitOffset;\r
+  UINT8   AccessSize;\r
+  UINT64  Address;\r
+} EFI_ACPI_GENERIC_ADDRESS_STRUCTURE;\r
+\r
+#define ACPI_ADDRESS_ID_MEMORY    0\r
+#define ACPI_ADDRESS_ID_IO        1\r
+#define ACPI_ADDRESS_ID_PCI       2\r
+#define ACPI_ADDRESS_ID_EC        3\r
+#define ACPI_ADDRESS_ID_SMBUS     4\r
+\r
+#define ACPI_ADDRESS_ACCESS_ANY   0\r
+#define ACPI_ADDRESS_ACCESS_BYTE  1\r
+#define ACPI_ADDRESS_ACCESS_WORD  2\r
+#define ACPI_ADDRESS_ACCESS_DWORD 3\r
+#define ACPI_ADDRESS_ACCESS_QWORD 4\r
+\r
+//\r
+// Following structure defines ACPI Description information.\r
+// This information is platform specific, may be consumed by DXE generic driver.\r
+//\r
+#pragma pack(1)\r
+typedef struct _EFI_ACPI_DESCRIPTION {\r
+  //\r
+  // For Timer\r
+  //\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM_TMR_BLK;\r
+  UINT8                                    PM_TMR_LEN;\r
+  UINT8                                    TMR_VAL_EXT;\r
+\r
+  //\r
+  // For RTC\r
+  //\r
+  UINT8                                    DAY_ALRM;\r
+  UINT8                                    MON_ALRM;\r
+  UINT8                                    CENTURY;\r
+\r
+  //\r
+  // For Reset\r
+  //\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       RESET_REG;\r
+  UINT8                                    RESET_VALUE;\r
+\r
+  //\r
+  // For Shutdown\r
+  //\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM1a_EVT_BLK;\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM1b_EVT_BLK;\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM1a_CNT_BLK;\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM1b_CNT_BLK;\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       PM2_CNT_BLK;\r
+  UINT8                                    PM1_EVT_LEN;\r
+  UINT8                                    PM1_CNT_LEN;\r
+  UINT8                                    PM2_CNT_LEN;\r
+  UINT8                                    SLP_TYPa;\r
+  UINT8                                    SLP_TYPb;\r
+\r
+  //\r
+  // For sleep\r
+  //\r
+  UINT8                                    SLP1_TYPa;\r
+  UINT8                                    SLP1_TYPb;\r
+  UINT8                                    SLP2_TYPa;\r
+  UINT8                                    SLP2_TYPb;\r
+  UINT8                                    SLP3_TYPa;\r
+  UINT8                                    SLP3_TYPb;\r
+  UINT8                                    SLP4_TYPa;\r
+  UINT8                                    SLP4_TYPb;\r
+\r
+  //\r
+  // GPE\r
+  //\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       GPE0_BLK;\r
+  EFI_ACPI_GENERIC_ADDRESS_STRUCTURE       GPE1_BLK;\r
+  UINT8                                    GPE0_BLK_LEN;\r
+  UINT8                                    GPE1_BLK_LEN;\r
+  UINT8                                    GPE1_BASE;\r
+\r
+  //\r
+  // IAPC Boot Arch\r
+  //\r
+  UINT16                                   IAPC_BOOT_ARCH;\r
+\r
+  //\r
+  // Flags\r
+  //\r
+  UINT32                                   Flags;\r
+\r
+} EFI_ACPI_DESCRIPTION;\r
+#pragma pack()\r
+\r
+extern EFI_GUID gEfiAcpiDescriptionGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c
new file mode 100644 (file)
index 0000000..3017b31
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AlternateFvBlock.c\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used to define the Alternate Firmware Volume Block Guid.  \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (AlternateFvBlock)\r
+\r
+EFI_GUID  gEfiAlternateFvBlockGuid = EFI_ALTERNATE_FV_BLOCK_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiAlternateFvBlockGuid, "Alternate Firmware Volume Block GUID", "Alternate Firmware Volume Block GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h
new file mode 100644 (file)
index 0000000..53340ea
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AlternateFvBlock.h\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used to define the Alternate Firmware Volume Block Guid.  \r
+\r
+--*/\r
+\r
+#ifndef _ALT_FVB_GUID_H\r
+#define _ALT_FVB_GUID_H\r
+\r
+#define EFI_ALTERNATE_FV_BLOCK_GUID \\r
+  { \\r
+    0xf496922d, 0x172f, 0x4bbc, 0xa1, 0xeb, 0xe, 0xeb, 0x94, 0x9c, 0x34, 0x86 \\r
+  }\r
+\r
+extern EFI_GUID gEfiAlternateFvBlockGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c
new file mode 100644 (file)
index 0000000..d62e0fa
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Bmp.c\r
+ .c\r
+    \r
+Abstract:\r
+\r
+  GUID used as a filename for the BMP logo \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (Bmp)\r
+\r
+EFI_GUID gEfiDefaultBmpLogoGuid  = EFI_DEFAULT_BMP_LOGO_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiDefaultBmpLogoGuid, "Guid for BMP logo", "Guid for BMP logo");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h
new file mode 100644 (file)
index 0000000..e095d2a
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bmp.h\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _BMP_GUID_H_\r
+#define _BMP_GUID_H_\r
+\r
+\r
+//\r
+// Definitions for BMP files\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT8   Blue;\r
+  UINT8   Green;\r
+  UINT8   Red;\r
+  UINT8   Reserved;\r
+} BMP_COLOR_MAP;\r
+\r
+typedef struct {\r
+  CHAR8         CharB;\r
+  CHAR8         CharM;\r
+  UINT32        Size;\r
+  UINT16        Reserved[2];\r
+  UINT32        ImageOffset;\r
+  UINT32        HeaderSize;\r
+  UINT32        PixelWidth;\r
+  UINT32        PixelHeight;\r
+  UINT16        Planes;       // Must be 1\r
+  UINT16        BitPerPixel;  // 1, 4, 8, or 24\r
+  UINT32        CompressionType;\r
+  UINT32        ImageSize;    // Compressed image size in bytes\r
+  UINT32        XPixelsPerMeter;\r
+  UINT32        YPixelsPerMeter;\r
+  UINT32        NumberOfColors;\r
+  UINT32        ImportantColors;\r
+} BMP_IMAGE_HEADER;\r
+\r
+#pragma pack()\r
+\r
+#define EFI_DEFAULT_BMP_LOGO_GUID \\r
+  {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D}\r
+\r
+extern EFI_GUID gEfiDefaultBmpLogoGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c
new file mode 100644 (file)
index 0000000..6e32f78
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  BootState.c\r
+    \r
+Abstract:\r
+\r
+  GUID for use conveying the boot-state to PEI\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (BootState)\r
+\r
+EFI_GUID gEfiBootStateGuid = EFI_BOOT_STATE_VARIABLE_GUID;\r
+\r
+//\r
+// GUID for frequency selection HOB\r
+//\r
+EFI_GUID_STRING(&gEfiBootStateGuid, "Boot State", "Boot State");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h
new file mode 100644 (file)
index 0000000..e0aeba4
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootState.h\r
+\r
+Abstract:\r
+\r
+  Constants and declarations that are common accross PEI and DXE.\r
+--*/\r
+\r
+#ifndef _BOOT_STATE_H_\r
+#define _BOOT_STATE_H_\r
+\r
+#include "Tiano.h"\r
+\r
+//\r
+// BOOT STATE\r
+//\r
+\r
+typedef UINT32 EFI_BOOT_STATE;\r
+\r
+#define BOOT_STATE_VARIABLE_NAME  L"BootState"\r
+\r
+#define  EFI_BOOT_STATE_VARIABLE_GUID  \\r
+  {0x60b5e939, 0xfcf, 0x4227, 0xba, 0x83, 0x6b, 0xbe, 0xd4, 0x5b, 0xc0, 0xe3}\r
+\r
+extern EFI_GUID gEfiBootStateGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c
new file mode 100644 (file)
index 0000000..6e167d3
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Capsule.c\r
+    \r
+Abstract:\r
+\r
+  EFI Capsule update Guid data declarations.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_GUID_DEFINITION(Capsule)\r
+\r
+EFI_GUID gEfiCapsuleVendorGuid = EFI_CAPSULE_VENDOR_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCapsuleVendorGuid, "EFI", "Efi Capsule GUID")\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h
new file mode 100644 (file)
index 0000000..8c61f5e
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Capsule.h\r
+    \r
+Abstract:\r
+\r
+  Capsule update Guid definitions\r
+\r
+--*/\r
+\r
+#ifndef _EFI_CAPSULE_VENDOR_GUID_H_\r
+#define _EFI_CAPSULE_VENDOR_GUID_H_\r
+\r
+//\r
+// Note -- This guid is used as a vendor GUID (depending on implementation)\r
+// for the capsule variable if the capsule pointer is passes through reset\r
+// via a variable.\r
+//\r
+#define EFI_CAPSULE_VENDOR_GUID  \\r
+  { 0x711C703F, 0xC285, 0x4B10, 0xA3, 0xB0, 0x36, 0xEC, 0xBD, 0x3C, 0x8B, 0xE2 }\r
+  \r
+extern EFI_GUID gEfiCapsuleVendorGuid;\r
+\r
+#endif // #ifndef _EFI_CAPSULE_VENDOR_GUID_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c
new file mode 100644 (file)
index 0000000..e542d29
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CompatibleMemoryTested.c\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used for all Compatible Memory Range Tested GUID.  \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (CompatibleMemoryTested)\r
+\r
+EFI_GUID  gEfiCompatibleMemoryTestedGuid = EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiCompatibleMemoryTestedGuid, "CompatibleMemoryTested Protocol", "Tiano Generic Memory Test Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h
new file mode 100644 (file)
index 0000000..2223776
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CompatibleMemoryTested.h\r
+    \r
+Abstract:\r
+\r
+  Tiano Guid used for all Compatible Memory Range Tested GUID.  \r
+\r
+--*/\r
+\r
+#ifndef _COMPATIBLE_MEMORY_TESTED_GUID_H_\r
+#define _COMPATIBLE_MEMORY_TESTED_GUID_H_\r
+\r
+#define EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID \\r
+  { \\r
+    0x64c475ef, 0x344b, 0x492c, 0x93, 0xad, 0xab, 0x9e, 0xb4, 0x39, 0x50, 0x4 \\r
+  }\r
+\r
+extern EFI_GUID gEfiCompatibleMemoryTestedGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c
new file mode 100644 (file)
index 0000000..7fb5ab0
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleInDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(ConsoleInDevice)\r
+\r
+\r
+EFI_GUID  gEfiConsoleInDeviceGuid = EFI_CONSOLE_IN_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiConsoleInDeviceGuid, "Console In Device Guid", "EFI Conosle In Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h
new file mode 100644 (file)
index 0000000..7fc1b90
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleInDevice.h\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _CONSOLE_IN_DEVICE_H_\r
+#define _CONSOLE_IN_DEVICE_H_\r
+\r
+#define EFI_CONSOLE_IN_DEVICE_GUID    \\r
+    { 0xd3b36f2b, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+extern EFI_GUID gEfiConsoleInDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c
new file mode 100644 (file)
index 0000000..b546f6d
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleOutDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(ConsoleOutDevice)\r
+\r
+\r
+EFI_GUID  gEfiConsoleOutDeviceGuid = EFI_CONSOLE_OUT_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiConsoleOutDeviceGuid, "Console Out Device Guid", "EFI Console Out Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h
new file mode 100644 (file)
index 0000000..7eff36a
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleOutDevice.h\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _CONSOLE_OUT_DEVICE_H_\r
+#define _CONSOLE_OUT_DEVICE_H_\r
+\r
+#define EFI_CONSOLE_OUT_DEVICE_GUID    \\r
+    { 0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+extern EFI_GUID gEfiConsoleOutDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf b/EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf
new file mode 100644 (file)
index 0000000..c9465c5
--- /dev/null
@@ -0,0 +1,98 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkGuidLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the Edk Guid library.\r
+#\r
+#--*/\r
+[defines]\r
+BASE_NAME=   EdkGuidLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+    \r
+[nmake.common]\r
+\r
+[sources.common]\r
+  AcpiDescription\AcpiDescription.h\r
+  AcpiDescription\AcpiDescription.c\r
+  AlternateFvBlock\AlternateFvBlock.h\r
+  AlternateFvBlock\AlternateFvBlock.c\r
+  Bmp\Bmp.h\r
+  Bmp\Bmp.c\r
+  BootState\BootState.h\r
+  BootState\BootState.c\r
+  Capsule\Capsule.h\r
+  Capsule\Capsule.c\r
+  CompatibleMemoryTested\CompatibleMemoryTested.h\r
+  CompatibleMemoryTested\CompatibleMemoryTested.c\r
+  ConsoleInDevice\ConsoleInDevice.h\r
+  ConsoleInDevice\ConsoleInDevice.c\r
+  ConsoleOutDevice\ConsoleOutDevice.h\r
+  ConsoleOutDevice\ConsoleOutDevice.c\r
+  EfiShell\EfiShell.h\r
+  EfiShell\EfiShell.c\r
+  FlashMapHob\FlashMapHob.h\r
+  FlashMapHob\FlashMapHob.c\r
+  HotPlugDevice\HotPlugDevice.h\r
+  HotPlugDevice\HotPlugDevice.c\r
+  IoBaseHob\IoBaseHob.h\r
+  IoBaseHob\IoBaseHob.c\r
+  MemoryTypeInformation\MemoryTypeInformation.h\r
+  MemoryTypeInformation\MemoryTypeInformation.c\r
+  PciHotPlugDevice\PciHotPlugDevice.h\r
+  PciHotPlugDevice\PciHotPlugDevice.c\r
+  PciOptionRomTable\PciOptionRomTable.h\r
+  PciOptionRomTable\PciOptionRomTable.c\r
+  PciExpressBaseAddress\PciExpressBaseAddress.h\r
+  PciExpressBaseAddress\PciExpressBaseAddress.c\r
+  PeiFlushInstructionCache\PeiFlushInstructionCache.h\r
+  PeiFlushInstructionCache\PeiFlushInstructionCache.c\r
+  PeiPeCoffLoader\PeiPeCoffLoader.h\r
+  PeiPeCoffLoader\PeiPeCoffLoader.c\r
+  PeiPerformanceHob\PeiPerformanceHob.h\r
+  PeiPerformanceHob\PeiPerformanceHob.c\r
+  PeiTransferControl\PeiTransferControl.h\r
+  PeiTransferControl\PeiTransferControl.c\r
+  PrimaryConsoleInDevice\PrimaryConsoleInDevice.h\r
+  PrimaryConsoleInDevice\PrimaryConsoleInDevice.c\r
+  PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.h\r
+  PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.c\r
+  PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.h\r
+  PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.c\r
+  StandardErrorDevice\StandardErrorDevice.h\r
+  StandardErrorDevice\StandardErrorDevice.c\r
+  StatusCode\StatusCode.h\r
+  StatusCode\StatusCode.c\r
+  StatusCodeCallerId\StatusCodeCallerId.h\r
+  StatusCodeCallerId\StatusCodeCallerId.c\r
+  SystemNvDataGuid\SystemNvDataGuid.h\r
+  SystemNvDataGuid\SystemNvDataGuid.c\r
+  EventLegacyBios\EventLegacyBios.h\r
+  EventLegacyBios\EventLegacyBios.c\r
+  GenericVariable\GenericVariable.h\r
+  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 (file)
index 0000000..ee4ddb7
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiShell.c\r
+    \r
+Abstract:\r
+\r
+  FFS Filename for EFI Shell\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_GUID_DEFINITION (EfiShell)\r
+\r
+EFI_GUID gEfiShellFileGuid = EFI_SHELL_FILE_GUID;\r
+EFI_GUID gEfiMiniShellFileGuid = EFI_MINI_SHELL_FILE_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiShellFileGuid, "EfiShell", "Efi Shell FFS file name GUID")\r
+EFI_GUID_STRING (&gEfiMiniShellFileGuid, "EfiMiniShell", "Efi Mini-Shell FFS file name GUID")\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h b/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h
new file mode 100644 (file)
index 0000000..a3b76d3
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiShell.h\r
+    \r
+Abstract:\r
+\r
+  FFS Filename for EFI Shell\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SHELL_H_\r
+#define _EFI_SHELL_H_\r
+\r
+#define EFI_SHELL_FILE_GUID  \\r
+  { 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 }\r
+\r
+#define EFI_MINI_SHELL_FILE_GUID  \\r
+  { 0x86ad232b, 0xd33a, 0x465c, 0xbf, 0x5f, 0x41, 0x37, 0xb, 0xa9, 0x2f, 0xe2 }\r
+\r
+extern EFI_GUID gEfiShellFileGuid;\r
+extern EFI_GUID gEfiMiniShellFileGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c
new file mode 100644 (file)
index 0000000..75da46b
--- /dev/null
@@ -0,0 +1,23 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiLegacyBios.c\r
+    \r
+--*/\r
+#include "Tiano.h"\r
+\r
+#include EFI_GUID_DEFINITION (EventLegacyBios)\r
+\r
+EFI_GUID gEfiEventLegacyBootGuid = EFI_EVENT_LEGACY_BOOT_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiEventLegacyBootGuid, "EventLegacyBoot", "Event Legacy Boot GUID")\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h
new file mode 100644 (file)
index 0000000..648e254
--- /dev/null
@@ -0,0 +1,28 @@
+/** @file\r
+       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. \r
+\r
+       Copyright (c) 2006, Intel Corporation                                                         \r
+       All rights reserved. This program and the accompanying materials                          \r
+       are licensed and made available under the terms and conditions of the BSD License         \r
+       which accompanies this distribution.  The full text of the license may be found at        \r
+       http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+       Module Name:    EventLegacyBios.h\r
+\r
+       @par Revision Reference:\r
+       GUIDs defined in DXE CIS 0.91b.\r
+\r
+**/\r
+\r
+#ifndef __EVENT_LEGACY_BIOS_GUID_H__\r
+#define __EVENT_LEGACY_BIOS_GUID_H__\r
+\r
+#define EFI_EVENT_LEGACY_BOOT_GUID \\r
+   { 0x2a571201, 0x4966, 0x47f6, 0x8b, 0x86, 0xf3, 0x1e, 0x41, 0xf3, 0x2f, 0x10 }\r
+\r
+extern EFI_GUID gEfiEventLegacyBootGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c
new file mode 100644 (file)
index 0000000..2294280
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashMapHob.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for Flash Map HOB entries in the in the HOB list.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (FlashMapHob)\r
+\r
+\r
+EFI_GUID gEfiFlashMapHobGuid  = EFI_FLASH_MAP_HOB_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiFlashMapHobGuid, "Flash Map HOB", "Flash Map HOB GUID for HOB list");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h
new file mode 100644 (file)
index 0000000..1676df2
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashMapHob.h\r
+    \r
+Abstract:\r
+\r
+  GUID used for Flash Map HOB entries in the HOB list.\r
+\r
+--*/\r
+\r
+#ifndef _FLASH_MAP_HOB_GUID_H_\r
+#define _FLASH_MAP_HOB_GUID_H_\r
+\r
+//\r
+// Definitions for Flash Map\r
+//\r
+#define EFI_FLASH_MAP_HOB_GUID \\r
+  { 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 }\r
+\r
+extern EFI_GUID gEfiFlashMapHobGuid;\r
+\r
+#endif // _FLASH_MAP_HOB_GUID_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c
new file mode 100644 (file)
index 0000000..e1dc76c
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GenericVariable.c\r
+    \r
+Abstract:\r
+\r
+    The variable space Guid to pair with a Unicode string name to tag an EFI variable\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_GUID_DEFINITION (GenericVariable)\r
+\r
+EFI_GUID  gEfiGenericVariableGuid = EFI_GENERIC_VARIABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiGenericVariableGuid, "GenericVariable", "Generic Variable GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h
new file mode 100644 (file)
index 0000000..d6b4f3e
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GenericVariable.h\r
+    \r
+Abstract:\r
+\r
+    The variable space Guid to pair with a Unicode string name to tag an EFI variable\r
+\r
+--*/\r
+\r
+#ifndef _GENERIC_VARIABLE_H_\r
+#define _GENERIC_VARIABLE_H_\r
+\r
+#define EFI_GENERIC_VARIABLE_GUID \\r
+  { \\r
+    0x59d1c24f, 0x50f1, 0x401a, 0xb1, 0x01, 0xf3, 0x3e, 0x0d, 0xae, 0xd4, 0x43 \\r
+  }\r
+\r
+extern EFI_GUID gEfiGenericVariableGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c
new file mode 100644 (file)
index 0000000..fda226a
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  HotPlugDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(HotPlugDevice)\r
+\r
+\r
+EFI_GUID  gEfiHotPlugDeviceGuid = HOT_PLUG_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHotPlugDeviceGuid, "Hot Plug Device Guid", "Hot Plug Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h
new file mode 100644 (file)
index 0000000..0e7ebde
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  HotPlugDevice.h\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _HOT_PLUG_DEVICE_H_\r
+#define _HOT_PLUG_DEVICE_H_\r
+\r
+#define HOT_PLUG_DEVICE_GUID    \\r
+    { 0x220ac432, 0x1d43, 0x49e5, 0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b }\r
+\r
+extern EFI_GUID gEfiHotPlugDeviceGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c
new file mode 100644 (file)
index 0000000..f42089b
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  IoBaseHob.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for IoBase HOB entries in the in the HOB list.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(IoBaseHob)\r
+\r
+\r
+EFI_GUID gEfiIoBaseHobGuid  = EFI_IOBASE_HOB_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiIoBaseHobGuid, "IOBASE HOB", "IOBASE HOB GUID for HOB list.");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h
new file mode 100644 (file)
index 0000000..e55f2b1
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  IoBaseHob.h\r
+    \r
+Abstract:\r
+\r
+  GUID used for IoBase HOB entries in the HOB list.\r
+\r
+--*/\r
+\r
+#ifndef _IOBASE_GUID_H_\r
+#define _IOBASE_GUID_H_\r
+\r
+#define EFI_IOBASE_HOB_GUID \\r
+{ 0xd4a28a3e, 0xdcf2, 0x43cf, 0xa2, 0xb7, 0xf3, 0x57, 0x2a, 0x7c, 0xab, 0x9 }\r
+\r
+extern EFI_GUID gEfiIoBaseHobGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c
new file mode 100644 (file)
index 0000000..d39f635
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryTypeInformation.c\r
+    \r
+Abstract:\r
+\r
+  GUID used for Memory Type Information entries in the HOB list.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(MemoryTypeInformation)\r
+\r
+EFI_GUID gEfiMemoryTypeInformationGuid  = EFI_MEMORY_TYPE_INFORMATION_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiMemoryTypeInformationGuid, "Memory Type Information", \r
+                "Memory Type Information HOB GUID for HOB list.");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h
new file mode 100644 (file)
index 0000000..d85c843
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryTypeInformation.h\r
+    \r
+Abstract:\r
+\r
+  GUID used for Memory Type Information entries in the HOB list.\r
+\r
+--*/\r
+\r
+#ifndef _MEMORY_TYPE_INFORMATION_GUID_H_\r
+#define _MEMORY_TYPE_INFORMATION_GUID_H_\r
+\r
+#define EFI_MEMORY_TYPE_INFORMATION_GUID \\r
+  { 0x4c19049f,0x4137,0x4dd3,0x9c,0x10,0x8b,0x97,0xa8,0x3f,0xfd,0xfa }\r
+\r
+#define EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME L"MemoryTypeInformation"\r
+\r
+extern EFI_GUID gEfiMemoryTypeInformationGuid;\r
+\r
+typedef struct {\r
+  UINT32  Type;\r
+  UINT32  NumberOfPages;\r
+} EFI_MEMORY_TYPE_INFORMATION;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c
new file mode 100644 (file)
index 0000000..d2ae68b
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PciExpressBaseAddress.c\r
+    \r
+Abstract:\r
+\r
+\r
+   GUIDs used for PciExpress Base Address\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (PciExpressBaseAddress)\r
+\r
+EFI_GUID  gEfiPciExpressBaseAddressGuid = EFI_PCI_EXPRESS_BASE_ADDRESS_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciExpressBaseAddressGuid, "PCI Express Base Address", "PCI Express Base Address GUID");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h
new file mode 100644 (file)
index 0000000..0625b3e
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PciExpressBaseAddress.h\r
+    \r
+Abstract:\r
+\r
+\r
+   GUIDs used for PciExpress Base Address\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PCI_EXPRESS_BASE_ADDRESS_H_\r
+#define _EFI_PCI_EXPRESS_BASE_ADDRESS_H_\r
+\r
+#define EFI_PCI_EXPRESS_BASE_ADDRESS_GUID \\r
+  { \\r
+    0x3677d529, 0x326f, 0x4603, 0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 \\r
+  }\r
+\r
+//\r
+// Following structure defines PCI Express Base Address information.\r
+// This information is platform specific, and built into hob in PEI phase.\r
+// It can be consumed by PEI PCI driver and DXE PCI driver.\r
+//\r
+#pragma pack(1)\r
+typedef struct _EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION {\r
+  UINT32       HostBridgeNumber;\r
+  UINT32       RootBridgeNumber;\r
+  UINT64       PciExpressBaseAddress;\r
+} EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION;\r
+#pragma pack()\r
+\r
+extern EFI_GUID gEfiPciExpressBaseAddressGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c
new file mode 100644 (file)
index 0000000..a0b884c
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PciHotplugDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+  GUIDs used to indicate the device is Pccard hotplug device\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PciHotplugDevice)\r
+\r
+\r
+EFI_GUID  gEfiPciHotplugDeviceGuid = EFI_PCI_HOTPLUG_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciHotplugDeviceGuid, "PCI Hotplug Device", "PCI Hotplug Device GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h
new file mode 100644 (file)
index 0000000..dafcf1e
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PciHotplugDevice.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used to indicate the device is Pccard hotplug device\r
+  \r
+--*/\r
+\r
+#ifndef _PCI_HOTPLUG_DEVICE_GUID_H_\r
+#define _PCI_HOTPLUG_DEVICE_GUID_H_\r
+\r
+#define EFI_PCI_HOTPLUG_DEVICE_GUID \\r
+  { 0x0b280816, 0x52e7, 0x4e51, 0xaa, 0x57, 0x11, 0xbd, 0x41, 0xcb, 0xef, 0xc3 }\r
+\r
+extern EFI_GUID gEfiPciHotplugDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c
new file mode 100644 (file)
index 0000000..436c805
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciOptionRomTable.c\r
+    \r
+Abstract:\r
+\r
+  GUID and data structure used to describe the list of PCI Option ROMs present in a system.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PciOptionRomTable)\r
+\r
+EFI_GUID gEfiPciOptionRomTableGuid = EFI_PCI_OPTION_ROM_TABLE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciOptionRomTableGuid, "PCI Option ROM Table", "PCI Option ROM Table GUID in EFI System Table");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
new file mode 100644 (file)
index 0000000..5055ccc
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciOptionRomTable.h\r
+    \r
+Abstract:\r
+\r
+  GUID and data structure used to describe the list of PCI Option ROMs present in a system.\r
+\r
+--*/\r
+\r
+#ifndef _PCI_OPTION_ROM_TABLE_GUID_H_\r
+\r
+#define EFI_PCI_OPTION_ROM_TABLE_GUID \\r
+  { 0x7462660f, 0x1cbd, 0x48da, 0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c }\r
+\r
+extern EFI_GUID gEfiPciOptionRomTableGuid;\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS   RomAddress; \r
+  EFI_MEMORY_TYPE        MemoryType;\r
+  UINT32                 RomLength; \r
+  UINT32                 Seg; \r
+  UINT8                  Bus; \r
+  UINT8                  Dev; \r
+  UINT8                  Func; \r
+  BOOLEAN                ExecutedLegacyBiosImage; \r
+  BOOLEAN                DontLoadEfiRom;\r
+} EFI_PCI_OPTION_ROM_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  UINT64                         PciOptionRomCount;\r
+  EFI_PCI_OPTION_ROM_DESCRIPTOR   *PciOptionRomDescriptors;\r
+} EFI_PCI_OPTION_ROM_TABLE;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c
new file mode 100644 (file)
index 0000000..967f944
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeiFlushInstructionCache.c\r
+    \r
+Abstract:\r
+\r
+  GUID for the Instruction Cache Flushing APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PeiFlushInstructionCache)\r
+\r
+EFI_GUID gEfiPeiFlushInstructionCacheGuid  = EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPeiFlushInstructionCacheGuid, "PEI Flush Instruction Cache", \r
+                "Flush Instruction Cache APIs from PEI");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h
new file mode 100644 (file)
index 0000000..7bd6c89
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeiFlushInstructionCache.h\r
+    \r
+Abstract:\r
+\r
+  GUID for the Instruction Cache Flushing APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#ifndef _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_\r
+#define _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_\r
+\r
+#define EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID  \\r
+  { 0xd8117cfc, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH) (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS                              Start,\r
+  IN UINT64                                            Length\r
+  );\r
+\r
+typedef struct _EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL {\r
+  EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH  Flush;\r
+} EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPeiFlushInstructionCacheGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c
new file mode 100644 (file)
index 0000000..517ee4a
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeiPeCoffLoader.c\r
+    \r
+Abstract:\r
+\r
+  GUID for the PE/COFF Loader APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PeiPeCoffLoader)\r
+\r
+EFI_GUID gEfiPeiPeCoffLoaderGuid  = EFI_PEI_PE_COFF_LOADER_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPeiPeCoffLoaderGuid, "PE/COFF Loader", "PE/COFF Loader APIs from PEI");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
new file mode 100644 (file)
index 0000000..3589f31
--- /dev/null
@@ -0,0 +1,116 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeiPeCoffLoader.h\r
+    \r
+Abstract:\r
+\r
+  GUID for the PE/COFF Loader APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#ifndef _PEI_PE_COFF_LOADER_H_\r
+#define _PEI_PE_COFF_LOADER_H_\r
+\r
+#include "EfiImage.h"\r
+\r
+#define EFI_PEI_PE_COFF_LOADER_GUID  \\r
+  { 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_PE_COFF_LOADER_PROTOCOL);\r
+\r
+#define EFI_IMAGE_ERROR_SUCCESS                      0\r
+#define EFI_IMAGE_ERROR_IMAGE_READ                   1  \r
+#define EFI_IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE  2\r
+#define EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE         3\r
+#define EFI_IMAGE_ERROR_INVALID_SUBSYSTEM            4\r
+#define EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS        5\r
+#define EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE           6\r
+#define EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT    7\r
+#define EFI_IMAGE_ERROR_SECTION_NOT_LOADED           8\r
+#define EFI_IMAGE_ERROR_FAILED_RELOCATION            9\r
+#define EFI_IMAGE_ERROR_FAILED_ICACHE_FLUSH          10\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_READ_FILE) (\r
+  IN     VOID   *FileHandle,\r
+  IN     UINTN  FileOffset,\r
+  IN OUT UINTN  *ReadSize,\r
+  OUT    VOID   *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS              ImageAddress;\r
+  UINT64                            ImageSize;\r
+  EFI_PHYSICAL_ADDRESS              DestinationAddress;\r
+  EFI_PHYSICAL_ADDRESS              EntryPoint;\r
+  EFI_PEI_PE_COFF_LOADER_READ_FILE  ImageRead;\r
+  VOID                              *Handle;\r
+  VOID                              *FixupData;\r
+  UINT32                            SectionAlignment;\r
+  UINT32                            PeCoffHeaderOffset;\r
+  UINT32                            DebugDirectoryEntryRva;\r
+  VOID                              *CodeView;\r
+  CHAR8                             *PdbPointer;\r
+  UINTN                             SizeOfHeaders;\r
+  UINT32                            ImageCodeMemoryType;\r
+  UINT32                            ImageDataMemoryType;\r
+  UINT32                            ImageError;\r
+  UINTN                             FixupDataSize;\r
+  UINT16                            Machine;\r
+  UINT16                            ImageType;\r
+  BOOLEAN                           RelocationsStripped;\r
+  BOOLEAN                           IsTeImage;\r
+#ifdef EFI_NT_EMULATOR\r
+  VOID                              **ModHandle;\r
+#endif\r
+} EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT;\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL  *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL  *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL  *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) (\r
+  IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+  );\r
+\r
+typedef struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL {\r
+  EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO  GetImageInfo;\r
+  EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE      LoadImage;\r
+  EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE  RelocateImage;\r
+  EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE    UnloadImage;\r
+} EFI_PEI_PE_COFF_LOADER_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPeiPeCoffLoaderGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c
new file mode 100644 (file)
index 0000000..1906a97
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    OemFvHob.c\r
+    \r
+Abstract:\r
+\r
+  The GUID of the GUIDed HOB that represents the OEM FV block.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)\r
+\r
+EFI_GUID  gEfiPeiPerformanceHobGuid  = EFI_PEI_PERFORMANCE_HOB_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiPeiPerformanceHobGuid, "PEI Performance HOB",\r
+                 "Guid for PEI Performance Measurement HOB");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h
new file mode 100644 (file)
index 0000000..7f9104f
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeiPerformanceHob.h\r
+    \r
+Abstract:\r
+  The PEI performance HOB definition.\r
+\r
+--*/\r
+\r
+#ifndef _PEI_PERFORMANCE_HOB_GUID_H_\r
+#define _PEI_PERFORMANCE_HOB_GUID_H_\r
+\r
+\r
+#define EFI_PEI_PERFORMANCE_HOB_GUID  \\r
+{0x10f432de, 0xdeec, 0x4631, 0x80, 0xcd, 0x47, 0xf6, 0x5d, 0x8f, 0x80, 0xbb}\r
+\r
+#define PEI_PERF_MAX_DESC_STRING 8\r
+\r
+typedef struct {\r
+  UINT64          StartTimeCount;\r
+  UINT64          StopTimeCount;\r
+  EFI_GUID        Name;\r
+  UINT16          DescriptionString[PEI_PERF_MAX_DESC_STRING];\r
+} PEI_PERFORMANCE_MEASURE_LOG_ENTRY;\r
+\r
+typedef struct {\r
+  UINT32                             NumberOfEntries;\r
+  UINT32                             Reserved;\r
+  PEI_PERFORMANCE_MEASURE_LOG_ENTRY  Log[1];\r
+} EFI_HOB_GUID_DATA_PERFORMANCE_LOG;\r
+\r
+extern EFI_GUID gEfiPeiPerformanceHobGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c
new file mode 100644 (file)
index 0000000..ffd2b34
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiTransferControl.c\r
+    \r
+Abstract:\r
+\r
+  GUID for the SetJump()/LongJump() APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PeiTransferControl)\r
+\r
+EFI_GUID gEfiPeiTransferControlGuid = EFI_PEI_TRANSFER_CONTROL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPeiTransferControlGuid, "Transfer Control", "Transfer Control APIs from PEI");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h
new file mode 100644 (file)
index 0000000..0ed5a0d
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiTransferControl.h\r
+    \r
+Abstract:\r
+\r
+  GUID for the SetJump()/LongJump() APIs shared between PEI and DXE\r
+\r
+--*/\r
+\r
+#ifndef _PEI_TRANSFER_CONTROL_H_\r
+#define _PEI_TRANSFER_CONTROL_H_\r
+\r
+#define EFI_PEI_TRANSFER_CONTROL_GUID  \\r
+  { 0xd8117d02, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PEI_TRANSFER_CONTROL_PROTOCOL);\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  OUT VOID                                      *Context\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN VOID                                       *Context\r
+  );\r
+\r
+typedef struct _EFI_PEI_TRANSFER_CONTROL_PROTOCOL {\r
+  EFI_PEI_TRANSFER_CONTROL_LONG_JUMP   SetJump;\r
+  EFI_PEI_TRANSFER_CONTROL_LONG_JUMP   LongJump;\r
+  UINT32                               JumpContextSize;\r
+} EFI_PEI_TRANSFER_CONTROL_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPeiTransferControlGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c
new file mode 100644 (file)
index 0000000..a596247
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryConsoleInDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PrimaryConsoleInDevice)\r
+\r
+\r
+EFI_GUID  gEfiPrimaryConsoleInDeviceGuid = EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPrimaryConsoleInDeviceGuid, "Primary Console In Device Guid", \r
+                "EFI Primary Conosle In Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h
new file mode 100644 (file)
index 0000000..3681ef5
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryConsoleInDevice.h\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _PRIMARY_CONSOLE_IN_DEVICE_H_\r
+#define _PRIMARY_CONSOLE_IN_DEVICE_H_\r
+\r
+#define EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID    \\r
+  { 0xe451dcbe, 0x96a1, 0x4729, 0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd }\r
+\r
+extern EFI_GUID gEfiPrimaryConsoleInDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c
new file mode 100644 (file)
index 0000000..8dd11a1
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryConsoleOutDevice.c\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PrimaryConsoleOutDevice)\r
+\r
+EFI_GUID  gEfiPrimaryConsoleOutDeviceGuid = EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPrimaryConsoleOutDeviceGuid, "Primary Console Out Device Guid", \r
+                "EFI Primary Console Out Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h
new file mode 100644 (file)
index 0000000..d87cbbc
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryConsoleOutDevice.h\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _PRIMARY_CONSOLE_OUT_DEVICE_H_\r
+#define _PRIMARY_CONSOLE_OUT_DEVICE_H_\r
+\r
+#define EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID    \\r
+  { 0x62bdf38a, 0xe3d5, 0x492c, 0x95, 0xc, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e }\r
+\r
+extern EFI_GUID gEfiPrimaryConsoleOutDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c
new file mode 100644 (file)
index 0000000..23e0651
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryStandardErrorDevice.c\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(PrimaryStandardErrorDevice)\r
+\r
+EFI_GUID  gEfiPrimaryStandardErrorDeviceGuid = EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPrimaryStandardErrorDeviceGuid, "Primary Standard Error Device Guid", \r
+                "EFI Primary Standard Error Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h
new file mode 100644 (file)
index 0000000..15d53df
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrimaryStandardErrorDevice.h\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _PRIMARY_STANDARD_ERROR_DEVICE_H_\r
+#define _PRIMARY_STANDARD_ERROR_DEVICE_H_\r
+\r
+#define EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID    \\r
+  { 0x5a68191b, 0x9b97, 0x4752, 0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 }\r
+\r
+extern EFI_GUID gEfiPrimaryStandardErrorDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c
new file mode 100644 (file)
index 0000000..8badd8d
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StandardErrorDevice.c\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(StandardErrorDevice)\r
+\r
+\r
+EFI_GUID  gEfiStandardErrorDeviceGuid = EFI_STANDARD_ERROR_DEVICE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiStandardErrorDeviceGuid, "Standard Error Device Guid", "EFI Standard Error Device Guid");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h
new file mode 100644 (file)
index 0000000..b8cadfd
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StandardErrorDevice.h\r
+    \r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _STANDARD_ERROR_DEVICE_H_\r
+#define _STANDARD_ERROR_DEVICE_H_\r
+\r
+#define EFI_STANDARD_ERROR_DEVICE_GUID    \\r
+    { 0xd3b36f2d, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+extern EFI_GUID gEfiStandardErrorDeviceGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c
new file mode 100644 (file)
index 0000000..5c75cf0
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCode.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used to identify Data Hub records that originate from the Tiano \r
+  ReportStatusCode API.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (StatusCode)\r
+\r
+EFI_GUID  gEfiStatusCodeGuid = EFI_STATUS_CODE_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiStatusCodeGuid, "Status Code", "Data Hub record for Tiano ReportStatusCode API");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h
new file mode 100644 (file)
index 0000000..8953bb0
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCode.h\r
+    \r
+Abstract:\r
+\r
+  GUID used to identify Data Hub records that originate from the Tiano \r
+  ReportStatusCode API.\r
+\r
+--*/\r
+\r
+#ifndef _STATUS_CODE_H__\r
+#define _STATUS_CODE_H__\r
+\r
+#define EFI_STATUS_CODE_GUID \\r
+  { \\r
+    0xd083e94c, 0x6560, 0x42e4, 0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a \\r
+  }\r
+\r
+extern EFI_GUID gEfiStatusCodeGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c
new file mode 100644 (file)
index 0000000..87d979f
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeCallerId.c\r
+    \r
+Abstract:\r
+\r
+  GUID used to identify id for the caller who is initiating the Status Code.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+\r
+EFI_GUID  gEfiCallerIdGuid = EFI_STANDARD_CALLER_ID_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCallerIdGuid, "Status Code Caller Id", "Caller Id for Tiano ReportStatusCode API");\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h
new file mode 100644 (file)
index 0000000..964bb83
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeCallerId.h\r
+    \r
+Abstract:\r
+\r
+  GUID used to identify id for the caller who is initiating the Status Code.\r
+\r
+--*/\r
+\r
+#ifndef _STATUS_CODE_CALLER_ID_H__\r
+#define _STATUS_CODE_CALLER_ID_H__\r
+\r
+#include "EfiStatusCode.h"\r
+\r
+#ifndef EFI_STANDARD_CALLER_ID_GUID\r
+\r
+#define EFI_STANDARD_CALLER_ID_GUID \\r
+  {0xC9DCF469, 0xA7C4, 0x11D5, 0x87, 0xDA, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9}\r
+\r
+#endif\r
+\r
+extern EFI_GUID gEfiCallerIdGuid;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c
new file mode 100644 (file)
index 0000000..59f5633
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SystemNvDataGuid.c\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying\r
+  the System specific information.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_GUID_DEFINITION(SystemNvDataGuid)\r
+\r
+\r
+EFI_GUID gEfiSystemNvDataHobGuid  = EFI_SYSTEM_NV_DATA_HOB_GUID;\r
+EFI_GUID gEfiSystemNvDataFvGuid  = EFI_SYSTEM_NV_DATA_FV_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiSystemNvDataHobGuid, "SYSTEM NV DATA HOB", "SYSTEM NV DATA HOB GUID for HOB list.");\r
+EFI_GUID_STRING(&gEfiSystemNvDataFvGuid, "SYSTEM NV DATA FV", "SYSTEM NV DATA FV GUID");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h
new file mode 100644 (file)
index 0000000..ce3358d
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    SystemNvDataGuid.h\r
+    \r
+Abstract:\r
+\r
+  GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying\r
+  the System specific information.\r
+\r
+--*/\r
+\r
+#ifndef _SYSTEM_NV_DATA_GUID_H_\r
+#define _SYSTEM_NV_DATA_GUID_H_\r
+\r
+#define EFI_SYSTEM_NV_DATA_FV_GUID \\r
+  {0xfff12b8d, 0x7696, 0x4c8b, 0xa9, 0x85, 0x27, 0x47, 0x7, 0x5b, 0x4f, 0x50}\r
+\r
+#define EFI_SYSTEM_NV_DATA_HOB_GUID \\r
+  {0xd6e5092d, 0xc7b2, 0x4872, 0xaf, 0x66, 0xfd, 0xc0, 0xe6, 0xf9, 0x5e, 0x78}\r
+\r
+typedef struct {\r
+  EFI_GUID                  SystemNvDataHobGuid;\r
+  EFI_GUID                  SystemNvDataFvGuid;\r
+  EFI_LBA                   StartLba;    \r
+  UINTN                     StartLbaOffset;\r
+  EFI_LBA                   EndLba;    \r
+  UINTN                     EndLbaOffset;\r
+  UINT32                    DataTypeSignature;\r
+} NV_SYSTEM_DATA_GUID_TYPE;\r
+\r
+extern EFI_GUID gEfiSystemNvDataHobGuid;\r
+extern EFI_GUID gEfiSystemNvDataFvGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h
new file mode 100644 (file)
index 0000000..930d589
--- /dev/null
@@ -0,0 +1,129 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiBind.h\r
+\r
+Abstract:\r
+\r
+  Processor or compiler specific defines and types for EBC.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BIND_H_\r
+#define _EFI_BIND_H_\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)\r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+//\r
+// Disable warning that make it impossible to compile at /W3\r
+// This only works for Intel EBC Compiler tools\r
+//\r
+\r
+//\r
+// Disabling argument of type "TYPE **" is incompatible with parameter of type "void **"\r
+//\r
+#pragma warning ( disable : 167 )\r
+\r
+//\r
+// Disabling pointless comparison of unsigned integer with zero\r
+//\r
+#pragma warning ( disable : 186 )\r
+\r
+//\r
+// Disabling enumerated type mixed with another type\r
+//\r
+#pragma warning ( disable : 188 )\r
+\r
+//\r
+// Native integer types\r
+//\r
+typedef char                  int8_t;\r
+typedef unsigned char         uint8_t;\r
+\r
+typedef short                 int16_t;\r
+typedef unsigned short        uint16_t;\r
+\r
+typedef int                   int32_t;\r
+typedef unsigned int          uint32_t;\r
+\r
+typedef __int64               int64_t;\r
+typedef unsigned __int64      uint64_t;\r
+\r
+//\r
+// "long" type scales to the processor native size with EBC compiler\r
+//\r
+typedef long                  intn_t;\r
+typedef unsigned long         uintn_t;\r
+\r
+//\r
+// Scalable macro to set the most significant bit in a natural number\r
+//\r
+#define EFI_MAX_BIT           ((UINTN)0x01 << ((sizeof (char *) * 8) - 1))\r
+#define MAX_2_BITS            (EFI_MAX_BIT | (EFI_MAX_BIT >> 1))\r
+\r
+//\r
+// Maximum legal EBC address\r
+//\r
+#define EFI_MAX_ADDRESS   (UINTN)~0\r
+\r
+//\r
+//  Bad pointer value to use in check builds.\r
+//  if you see this value you are using uninitialized or free'ed data\r
+//\r
+#define EFI_BAD_POINTER          (UINTN)0xAFAFAFAFAFAFAFAF\r
+#define EFI_BAD_POINTER_AS_BYTE  (UINTN)0xAF\r
+\r
+//\r
+// _break() is an EBC compiler intrinsic function\r
+//\r
+extern \r
+uint64_t \r
+_break (\r
+  unsigned char BreakCode\r
+  );\r
+\r
+//\r
+// Macro to inject a break point in the code to assist debugging.\r
+//\r
+#define EFI_BREAKPOINT()  _break ( 3 )\r
+#define EFI_DEADLOOP()    while (TRUE)\r
+\r
+//\r
+// Memory Fence forces serialization, and is needed to support out of order\r
+//  memory transactions. The Memory Fence is mainly used to make sure IO\r
+//  transactions complete in a deterministic sequence, and to syncronize locks\r
+//  an other MP code. Currently no memory fencing is required.\r
+//\r
+#define MEMORY_FENCE()\r
+\r
+//\r
+// Some compilers don't support the forward reference construct:\r
+//  typedef struct XXXXX. The forward reference is required for \r
+//  ANSI compatibility.\r
+//\r
+// The following macro provide a workaround for such cases.\r
+//\r
+\r
+\r
+#ifdef EFI_NO_INTERFACE_DECL\r
+  #define EFI_FORWARD_DECLARATION(x)\r
+#else\r
+  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x\r
+#endif\r
+\r
+\r
+#define _EFIAPI       \r
+\r
+#endif // ifndef _EFI_BIND_H_\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h
new file mode 100644 (file)
index 0000000..0dd66c2
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiPeOptionalHeader.h\r
+\r
+Abstract:\r
+  Defines the optional header in the PE image per the PE specification.  This\r
+  file must be included only from within EfiImage.h since \r
+  EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined\r
+  there.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_\r
+#define _EFI_PE_OPTIONAL_HEADER_H_\r
+\r
+//\r
+// This is just to make sure you can cross compile with the EBC compiiler.\r
+// It does not make sense to have a PE loader coded in EBC. You need to \r
+// understand the basic \r
+//\r
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_EBC)\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
+\r
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
+\r
+//\r
+// BUGBUG: Is this the correct magic for EBC?\r
+//\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS32      EFI_IMAGE_NT_HEADERS;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h
new file mode 100644 (file)
index 0000000..027d247
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoBind.h\r
+\r
+Abstract:\r
+\r
+  Tiano's Processor or Compiler specific defines and types for EBC \r
+  besides EfiBind.h.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_BIND_H_\r
+#define _TIANO_BIND_H_\r
+\r
+#include "EfiBind.h"\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiCommon.h b/EdkCompatibilityPkg/Foundation/Include/EfiCommon.h
new file mode 100644 (file)
index 0000000..305bfea
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiCommon.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMMON_H_\r
+#define _EFI_COMMON_H_\r
+\r
+#include "EfiBind.h"\r
+#include "EfiTypes.h"\r
+#include "EfiStdArg.h"\r
+#include "EfiError.h"\r
+\r
+//\r
+// Define macros for including Protocols and Guids.\r
+//\r
+#define EFI_STRINGIZE(a)            #a\r
+#define EFI_PROTOCOL_DEFINITION(a)  EFI_STRINGIZE (Protocol/a/a.h)\r
+#define EFI_GUID_DEFINITION(a)      EFI_STRINGIZE (Guid/a/a.h)\r
+\r
+//\r
+// These should be used to include protocols.  If they are followed,\r
+// intelligent build tools can be created to check dependencies at build\r
+// time.\r
+//\r
+#define EFI_PROTOCOL_PRODUCER(a)    EFI_PROTOCOL_DEFINITION (a)\r
+#define EFI_PROTOCOL_CONSUMER(a)    EFI_PROTOCOL_DEFINITION (a)\r
+#define EFI_PROTOCOL_DEPENDENCY(a)  EFI_PROTOCOL_DEFINITION (a)\r
+\r
+//\r
+// Mechanism to associate a short and long ascii string with a GUID.\r
+// For normal builds the strings are not included. A build utility\r
+// can be constructed to extract the strings and build a table. It may\r
+// be possible to add a build opption to automatically generate a GUID\r
+// string table for a GUID to string utility build.\r
+//\r
+#define EFI_GUID_STRING(guidpointer, shortstring, longstring)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiDebug.h b/EdkCompatibilityPkg/Foundation/Include/EfiDebug.h
new file mode 100644 (file)
index 0000000..452fd02
--- /dev/null
@@ -0,0 +1,170 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDebug.h\r
+\r
+Abstract:\r
+\r
+  EFI Debug macros. The work needs tobe done in library. The Debug\r
+  macros them selves are standard for all files, including the core.\r
+  \r
+  There needs to be code linked in that produces the following macros:\r
+  \r
+  EfiDebugAssert(file, linenumber, assertion string) - worker function for \r
+      ASSERT. filename and line number of where this ASSERT() is located\r
+      is passed in along with the stringized version of the assertion.\r
+  \r
+  EfiDebugPrint - Worker function for debug print\r
+\r
+  _DEBUG_SET_MEM(address, length, value) - Set memory at address to value\r
+    for legnth bytes. This macro is used to initialzed uninitialized memory\r
+    or memory that is free'ed, so it will not be used by mistake. \r
+\r
+--*/\r
+\r
+#ifndef _EFI_DEBUG_H_\r
+#define _EFI_DEBUG_H_\r
+\r
+#ifdef EFI_DEBUG\r
+\r
+  VOID\r
+  EfiDebugAssert (\r
+    IN CHAR8    *FileName,\r
+    IN INTN     LineNumber,\r
+    IN CHAR8    *Description\r
+    );\r
+\r
+  VOID\r
+  EfiDebugPrint (\r
+    IN  UINTN ErrorLevel,\r
+    IN  CHAR8 *Format,\r
+    ...\r
+    );\r
+\r
+  VOID\r
+  EfiDebugVPrint (\r
+    IN  UINTN   ErrorLevel,\r
+    IN  CHAR8   *Format,\r
+    IN  VA_LIST Marker\r
+    );\r
+\r
+  //\r
+  // Define macros for the above functions so we can make them go away\r
+  // in non-debug builds.\r
+  //\r
+  #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \\r
+                      EfiDebugVPrint(ErrorLevel, Format, Marker) \r
+\r
+  #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description)  \\r
+                      EfiDebugAssert (FileName, LineNumber, Description)\r
+\r
+  #define _DEBUG_ASSERT(assertion)  \\r
+            EfiDebugAssert (__FILE__, __LINE__, #assertion)\r
+\r
+  #define _DEBUG(arg) DebugPrint arg\r
+\r
+  //\r
+  // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT\r
+  //\r
+  #define ASSERT(assertion)   if(!(assertion))  \\r
+                                _DEBUG_ASSERT(assertion)\r
+    \r
+  #define ASSERT_LOCKED(l)    if(!(l)->Lock) _DEBUG_ASSERT(l not locked)\r
+\r
+  //\r
+  // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do \r
+  //   the a debug print.\r
+  //\r
+  #define DEBUG(arg)        EfiDebugPrint arg\r
+\r
+  #define DEBUG_CODE(code)  code\r
+\r
+  #define CR(record, TYPE, field, signature)                    \\r
+            _CR(record, TYPE, field)->Signature != signature ?  \\r
+            (TYPE *) (_DEBUG_ASSERT("CR has Bad Signature"), record) :                        \\r
+            _CR(record, TYPE, field)\r
+\r
+  #define _DEBUG_SET_MEM(address, length, data) EfiCommonLibSetMem(address, length, data)\r
+\r
+  //\r
+  // Generate an ASSERT if the protocol specified by GUID is already installed on Handle.\r
+  // If Handle is NULL, then an ASSERT is generated if the protocol specified by GUID \r
+  // is present anywhere in the handle database\r
+  //\r
+  #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)               \\r
+    DEBUG_CODE ( {                                                      \\r
+    VOID  *Instance;                                                    \\r
+    if (Handle == NULL) {                                               \\r
+      ASSERT(EFI_ERROR(gBS->LocateProtocol (Guid, NULL, &Instance)));   \\r
+    } else {                                                            \\r
+      ASSERT(EFI_ERROR(gBS->HandleProtocol (Handle, Guid, &Instance))); \\r
+    } } ) \r
+\r
+#else\r
+  #define ASSERT(a)               \r
+  #define ASSERT_LOCKED(l)    \r
+  #define DEBUG(arg) \r
+  #define DEBUG_CODE(code)  \r
+  #define CR(Record, TYPE, Field, Signature)   \\r
+            _CR(Record, TYPE, Field)                           \r
+  #define _DEBUG_SET_MEM(address, length, data) \r
+  #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \r
+  #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description)  \r
+  #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)\r
+#endif\r
+\r
+//\r
+// Generate an ASSERT if Status is an error code\r
+//\r
+//#define ASSERT_EFI_ERROR(status)  ASSERT(!EFI_ERROR(status))\r
+#define ASSERT_EFI_ERROR(status)  if (EFI_ERROR(status))                \\r
+    DEBUG_CODE ( {                                                      \\r
+      DEBUG((EFI_D_ERROR, "\nASSERT!Status = 0x%x Info :",status));     \\r
+      ASSERT(!EFI_ERROR(status));                                \\r
+    } ) \r
+    \r
+#ifdef EFI_DEBUG_CLEAR_MEMORY\r
+  #define DEBUG_SET_MEMORY(address,length)  \\r
+            _DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)\r
+#else\r
+  #define DEBUG_SET_MEMORY(address,length)\r
+#endif\r
+\r
+#define EFI_D_INIT        0x00000001          // Initialization style messages\r
+#define EFI_D_WARN        0x00000002          // Warnings\r
+#define EFI_D_LOAD        0x00000004          // Load events\r
+#define EFI_D_FS          0x00000008          // EFI File system\r
+#define EFI_D_POOL        0x00000010          // Alloc & Free's\r
+#define EFI_D_PAGE        0x00000020          // Alloc & Free's\r
+#define EFI_D_INFO        0x00000040          // Verbose\r
+#define EFI_D_VARIABLE    0x00000100          // Variable\r
+#define EFI_D_BM          0x00000400          // Boot Manager (BDS)\r
+#define EFI_D_BLKIO       0x00001000          // BlkIo Driver\r
+#define EFI_D_NET         0x00004000          // SNI Driver\r
+#define EFI_D_UNDI        0x00010000          // UNDI Driver\r
+#define EFI_D_LOADFILE    0x00020000          // UNDI Driver\r
+#define EFI_D_EVENT       0x00080000          // Event messages\r
+\r
+#define EFI_D_ERROR       0x80000000          // Error\r
+\r
+#define EFI_D_GENERIC (EFI_D_ERROR | EFI_D_INIT | EFI_D_WARN | EFI_D_INFO | \\r
+                        EFI_D_BLKIO | EFI_D_NET | EFI_D_UNDI )       \r
+\r
+#define EFI_D_INTRINSIC ( EFI_D_EVENT | EFI_D_POOL | EFI_D_PAGE | \\r
+                          EFI_D_BM | EFI_D_LOAD | EFI_D_VARIABLE )        \r
+\r
+#define EFI_D_RESERVED  (EFI_D_GENERIC | EFI_D_INTRINSIC)       \r
+\r
+#define EFI_DBUG_MASK   (EFI_D_ERROR)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiDepex.h b/EdkCompatibilityPkg/Foundation/Include/EfiDepex.h
new file mode 100644 (file)
index 0000000..62a7784
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  EfiDepex.h\r
+\r
+Abstract:\r
+  This include file is only used in *.DXS files. Do not use this \r
+  include file in normal DXE code.\r
+\r
+  Depex - Dependency Expresion\r
+\r
+  The BNF grammar is thus:\r
+     <depex>   ::= before GUID       \r
+                 | after GUID\r
+                 | SOR <bool>\r
+                 | <bool>            \r
+     <bool>    ::= <bool> and <term> \r
+                 | <bool> or <term>  \r
+                 | <term>            \r
+     <term>    ::= not <factor>      \r
+                 | <factor>          \r
+     <factor>  ::= <bool>            \r
+                 | <boolval>         \r
+                 | <depinst>         \r
+                 | <termval>         \r
+     <boolval> ::= true              \r
+                 | false             \r
+     <depinst> ::= push GUID         \r
+     <termval> ::= end               \r
+\r
+--*/\r
+\r
+#ifndef _EFI_DEPEX_H_\r
+#define _EFI_DEPEX_H_\r
+\r
+#include "Tiano.h"\r
+\r
+//\r
+// The Depex grammer needs the string "TRUE" and "FALSE" we must\r
+// undo any pre-processor redefinitions\r
+//\r
+#undef TRUE\r
+#undef FALSE\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h b/EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h
new file mode 100644 (file)
index 0000000..9b0af35
--- /dev/null
@@ -0,0 +1,128 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiFlashMap.h\r
+\r
+Abstract:\r
+\r
+  Defines for the EFI Flash Map functionality\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_FLASHMAP_H_\r
+#define _EFI_FLASHMAP_H_\r
+\r
+#include "PeiHob.h"\r
+\r
+//\r
+// Definition for flash map GUIDed HOBs\r
+//\r
+typedef UINT32  EFI_FLASH_AREA_ATTRIBUTES;\r
+\r
+#define EFI_FLASH_AREA_FV           0x0001\r
+#define EFI_FLASH_AREA_SUBFV        0x0002\r
+#define EFI_FLASH_AREA_MEMMAPPED_FV 0x0004\r
+#define EFI_FLASH_AREA_REQUIRED     0x0008\r
+#define EFI_FLASH_AREA_CORRUPT      0x0010\r
+\r
+typedef UINT8   EFI_FLASH_AREA_TYPE;\r
+\r
+#define EFI_FLASH_AREA_RECOVERY_BIOS  0x0   // Recovery code\r
+#define EFI_FLASH_AREA_MAIN_BIOS      0x1   // Regular BIOS code\r
+#define EFI_FLASH_AREA_PAL_B          0x2   // PAL-B\r
+#define EFI_FLASH_AREA_RESERVED_03    0x3   // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_RESERVED_04    0x4   // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_DMI_FRU        0x5   // DMI FRU information\r
+#define EFI_FLASH_AREA_OEM_BINARY     0x6   // OEM Binary Code/data\r
+#define EFI_FLASH_AREA_RESERVED_07    0x7   // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_RESERVED_08    0x8   // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_RESERVED_09    0x9   // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_RESERVED_0A    0x0a  // Reserved for backwards compatibility\r
+#define EFI_FLASH_AREA_EFI_VARIABLES  0x0b  // EFI variables\r
+#define EFI_FLASH_AREA_MCA_LOG        0x0c  // MCA error log\r
+#define EFI_FLASH_AREA_SMBIOS_LOG     0x0d  // SMBIOS error log\r
+#define EFI_FLASH_AREA_FTW_BACKUP     0x0e  // A backup block during FTW operations\r
+#define EFI_FLASH_AREA_FTW_STATE      0x0f  // State information during FTW operations\r
+#define EFI_FLASH_AREA_UNUSED         0x0fd // Not used\r
+#define EFI_FLASH_AREA_GUID_DEFINED   0x0fe // Usage defined by a GUID\r
+#pragma pack(1)\r
+//\r
+// An individual sub-area Entry.\r
+// A single flash area may consist of  more than one sub-area.\r
+//\r
+typedef struct {\r
+  EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
+  UINT32                    Reserved;\r
+  EFI_PHYSICAL_ADDRESS      Base;\r
+  EFI_PHYSICAL_ADDRESS      Length;\r
+  EFI_GUID                  FileSystem;\r
+} EFI_FLASH_SUBAREA_ENTRY;\r
+\r
+typedef struct {\r
+  UINT8                   Reserved[3];\r
+  EFI_FLASH_AREA_TYPE     AreaType;\r
+  EFI_GUID                AreaTypeGuid;\r
+  UINT32                  NumEntries;\r
+  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
+} EFI_FLASH_MAP_ENTRY_DATA;\r
+\r
+typedef struct {\r
+  UINT8                   Reserved[3];\r
+  EFI_FLASH_AREA_TYPE     AreaType;\r
+  EFI_GUID                AreaTypeGuid;\r
+  UINT32                  NumberOfEntries;\r
+  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
+  //\r
+  // Extended Hob data.\r
+  //\r
+  // VolumeId and FilePath indicating a unique file.\r
+  //\r
+  UINT32                  VolumeId;\r
+  CHAR16                  FilePath[256];\r
+  UINT32                  ActuralSize;\r
+  UINT32                  Offset;\r
+} EFI_FLASH_MAP_FS_ENTRY_DATA;\r
+\r
+typedef struct {\r
+  EFI_HOB_GENERIC_HEADER  Header;\r
+  EFI_GUID                Name;\r
+  UINT8                   Reserved[3];\r
+  EFI_FLASH_AREA_TYPE     AreaType;\r
+  EFI_GUID                AreaTypeGuid;\r
+  UINT32                  NumEntries;\r
+  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
+} EFI_HOB_FLASH_MAP_ENTRY_TYPE;\r
+\r
+//\r
+// Internal definitions\r
+//\r
+typedef struct {\r
+  UINT8                   Reserved[3];\r
+  EFI_FLASH_AREA_TYPE     AreaType;\r
+  EFI_GUID                AreaTypeGuid;\r
+  UINT32                  NumberOfEntries;\r
+  EFI_FLASH_SUBAREA_ENTRY SubAreaData;\r
+} EFI_FLASH_AREA_HOB_DATA;\r
+\r
+typedef struct {\r
+  UINTN                     Base;\r
+  UINTN                     Length;\r
+  EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
+  EFI_FLASH_AREA_TYPE       AreaType;\r
+  UINT8                     Reserved[3];\r
+  EFI_GUID                  AreaTypeGuid;\r
+} EFI_FLASH_AREA_DATA;\r
+\r
+#pragma pack()\r
+\r
+#endif // #ifndef _EFI_FLASHMAP_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPci.h b/EdkCompatibilityPkg/Foundation/Include/EfiPci.h
new file mode 100644 (file)
index 0000000..3201409
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiPci.h\r
+\r
+Abstract:\r
+    Support for EFI PCI specification.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PCI_H_\r
+#define _EFI_PCI_H_\r
+\r
+//#include "pci22.h"\r
+//#include "pci23.h"\r
+//#include "pci30.h"\r
+\r
+#pragma pack(push, 1)\r
+\r
+typedef struct {\r
+  UINT8 Register;\r
+  UINT8 Function;\r
+  UINT8 Device;\r
+  UINT8 Bus;\r
+  UINT8 Reserved[4];\r
+} DEFIO_PCI_ADDR;\r
+\r
+#define EFI_ROOT_BRIDGE_LIST                            'eprb'\r
+#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE       0x0EF1\r
+\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT16  InitializationSize;\r
+  UINT32  EfiSignature; // 0x0EF1\r
+  UINT16  EfiSubsystem;\r
+  UINT16  EfiMachineType;\r
+  UINT16  CompressionType;\r
+  UINT8   Reserved[8];\r
+  UINT16  EfiImageHeaderOffset;\r
+  UINT16  PcirOffset;\r
+} EFI_PCI_EXPANSION_ROM_HEADER;\r
+\r
+typedef union {\r
+  UINT8                           *Raw;\r
+  PCI_EXPANSION_ROM_HEADER        *Generic;\r
+  EFI_PCI_EXPANSION_ROM_HEADER    *Efi;\r
+  EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt;\r
+} EFI_PCI_ROM_HEADER;\r
+\r
+#pragma pack(pop)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPerf.h b/EdkCompatibilityPkg/Foundation/Include/EfiPerf.h
new file mode 100644 (file)
index 0000000..55c743f
--- /dev/null
@@ -0,0 +1,158 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ EfiPerf.h\r
+\r
+Abstract:\r
+ EfiPerf.h provides performance primitive for the DXE and Shell phase\r
+\r
\r
+--*/\r
+\r
+#ifndef _EFI_PERF_H_\r
+#define _EFI_PERF_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Performance)\r
+\r
+EFI_STATUS\r
+InitializePerformanceInfrastructure (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable,\r
+  IN UINT64             Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+  Ticker      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EndMeasure (\r
+  IN EFI_HANDLE       Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle  - TODO: add argument description\r
+  Token   - TODO: add argument description\r
+  Host    - TODO: add argument description\r
+  Ticker  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+StartMeasure (\r
+  IN EFI_HANDLE       Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle  - TODO: add argument description\r
+  Token   - TODO: add argument description\r
+  Host    - TODO: add argument description\r
+  Ticker  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UpdateMeasure (\r
+  IN EFI_HANDLE      Handle,\r
+  IN UINT16          *Token,\r
+  IN UINT16          *Host,\r
+  IN EFI_HANDLE      HandleNew,\r
+  IN UINT16          *TokenNew,\r
+  IN UINT16          *HostNew\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle    - TODO: add argument description\r
+  Token     - TODO: add argument description\r
+  Host      - TODO: add argument description\r
+  HandleNew - TODO: add argument description\r
+  TokenNew  - TODO: add argument description\r
+  HostNew   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#ifdef EFI_DXE_PERFORMANCE\r
+#define PERF_ENABLE(handle, table, ticker)      InitializePerformanceInfrastructure (handle, table, ticker)\r
+#define PERF_START(handle, token, host, ticker) StartMeasure (handle, token, host, ticker)\r
+#define PERF_END(handle, token, host, ticker)   EndMeasure (handle, token, host, ticker)\r
+#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew) \\r
+  UpdateMeasure (handle, \\r
+                 token, \\r
+                 host, \\r
+                 handlenew, \\r
+                 tokennew, \\r
+                 hostnew \\r
+      )\r
+#define PERF_CODE(code) code\r
+#else\r
+#define PERF_ENABLE(handle, table, ticker)\r
+#define PERF_START(handle, token, host, ticker)\r
+#define PERF_END(handle, token, host, ticker)\r
+#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew)\r
+#define PERF_CODE(code)\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPxe.h b/EdkCompatibilityPkg/Foundation/Include/EfiPxe.h
new file mode 100644 (file)
index 0000000..0ff2252
--- /dev/null
@@ -0,0 +1,1816 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module name:\r
+\r
+    EfiPxe.h\r
+\r
+32/64-bit PXE specification:\r
+\r
+    alpha-4, 99-Dec-17\r
+\r
+Abstract:\r
+\r
+    This header file contains all of the PXE type definitions,\r
+    structure prototypes, global variables and constants that\r
+    are needed for porting PXE to EFI.\r
+--*/\r
+\r
+#ifndef _EFIPXE_H\r
+#define _EFIPXE_H\r
+\r
+#pragma pack(1)\r
+\r
+#define PXE_INTEL_ORDER 1 // Intel order\r
+// #define PXE_NETWORK_ORDER         1   // network order\r
+//\r
+#define PXE_UINT64_SUPPORT  1 // UINT64 supported\r
+// #define PXE_NO_UINT64_SUPPORT     1   // UINT64 not supported\r
+//\r
+#define PXE_BUSTYPE(a, b, c, d) \\r
+    ( \\r
+      (((UINT32) (d) & 0xFF) << 24) | (((UINT32) (c) & 0xFF) << 16) | (((UINT32) (b) & 0xFF) << 8) | \\r
+        ((UINT32) (a) & 0xFF) \\r
+    )\r
+\r
+//\r
+// UNDI ROM ID and devive ID signature\r
+//\r
+#define PXE_BUSTYPE_PXE PXE_BUSTYPE ('!', 'P', 'X', 'E')\r
+\r
+//\r
+// BUS ROM ID signatures\r
+//\r
+#define PXE_BUSTYPE_PCI     PXE_BUSTYPE ('P', 'C', 'I', 'R')\r
+#define PXE_BUSTYPE_PC_CARD PXE_BUSTYPE ('P', 'C', 'C', 'R')\r
+#define PXE_BUSTYPE_USB     PXE_BUSTYPE ('U', 'S', 'B', 'R')\r
+#define PXE_BUSTYPE_1394    PXE_BUSTYPE ('1', '3', '9', '4')\r
+\r
+#define PXE_SWAP_UINT16(n)  ((((UINT16) (n) & 0x00FF) << 8) | (((UINT16) (n) & 0xFF00) >> 8))\r
+\r
+#define PXE_SWAP_UINT32(n) \\r
+((((UINT32)(n) & 0x000000FF) << 24) |   \\r
+(((UINT32)(n) & 0x0000FF00) << 8) |     \\r
+(((UINT32)(n) & 0x00FF0000) >> 8) |     \\r
+(((UINT32)(n) & 0xFF000000) >> 24))\r
+\r
+#if PXE_UINT64_SUPPORT != 0\r
+#define PXE_SWAP_UINT64(n) \\r
+((((UINT64)(n) & 0x00000000000000FF) << 56) |   \\r
+(((UINT64)(n) & 0x000000000000FF00) << 40) |    \\r
+(((UINT64)(n) & 0x0000000000FF0000) << 24) |    \\r
+(((UINT64)(n) & 0x00000000FF000000) << 8) | \\r
+(((UINT64)(n) & 0x000000FF00000000) >> 8) | \\r
+(((UINT64)(n) & 0x0000FF0000000000) >> 24) |    \\r
+(((UINT64)(n) & 0x00FF000000000000) >> 40) |    \\r
+(((UINT64)(n) & 0xFF00000000000000) >> 56))\r
+#endif // PXE_UINT64_SUPPORT\r
+#if PXE_NO_UINT64_SUPPORT != 0\r
+#define PXE_SWAP_UINT64(n) { \\r
+    UINT32  tmp; \\r
+    tmp             = (PXE_UINT64) (n)[1]; \\r
+    (UINT64) (n)[1] = PXE_SWAP_UINT32 ((UINT64) (n)[0]); \\r
+    (UINT64) (n)[0] = tmp; \\r
+  }\r
+#endif // PXE_NO_UINT64_SUPPORT\r
+#define PXE_CPBSIZE_NOT_USED  0               // zero\r
+#define PXE_DBSIZE_NOT_USED   0               // zero\r
+#define PXE_CPBADDR_NOT_USED  (PXE_UINT64) 0  // zero\r
+#define PXE_DBADDR_NOT_USED   (PXE_UINT64) 0  // zero\r
+#define PXE_CONST             const\r
+\r
+#define PXE_VOLATILE          volatile\r
+\r
+#if PXE_UINT64_SUPPORT != 0\r
+//\r
+// typedef unsigned long PXE_UINT64;\r
+//\r
+typedef UINT64      PXE_UINT64;\r
+#endif // PXE_UINT64_SUPPORT\r
+#if PXE_NO_UINT64_SUPPORT != 0\r
+typedef PXE_UINT32  PXE_UINT64[2];\r
+#endif // PXE_NO_UINT64_SUPPORT\r
+#define PXE_FALSE 0 // zero\r
+#define PXE_TRUE  (!PXE_FALSE)\r
+\r
+typedef UINT16      PXE_OPCODE;\r
+\r
+//\r
+// Return UNDI operational state.\r
+//\r
+#define PXE_OPCODE_GET_STATE  0x0000\r
+\r
+//\r
+// Change UNDI operational state from Stopped to Started.\r
+//\r
+#define PXE_OPCODE_START  0x0001\r
+\r
+//\r
+// Change UNDI operational state from Started to Stopped.\r
+//\r
+#define PXE_OPCODE_STOP 0x0002\r
+\r
+//\r
+// Get UNDI initialization information.\r
+//\r
+#define PXE_OPCODE_GET_INIT_INFO  0x0003\r
+\r
+//\r
+// Get NIC configuration information.\r
+//\r
+#define PXE_OPCODE_GET_CONFIG_INFO  0x0004\r
+\r
+//\r
+// Changed UNDI operational state from Started to Initialized.\r
+//\r
+#define PXE_OPCODE_INITIALIZE 0x0005\r
+\r
+//\r
+// Re-initialize the NIC H/W.\r
+//\r
+#define PXE_OPCODE_RESET  0x0006\r
+\r
+//\r
+// Change the UNDI operational state from Initialized to Started.\r
+//\r
+#define PXE_OPCODE_SHUTDOWN 0x0007\r
+\r
+//\r
+// Read & change state of external interrupt enables.\r
+//\r
+#define PXE_OPCODE_INTERRUPT_ENABLES  0x0008\r
+\r
+//\r
+// Read & change state of packet receive filters.\r
+//\r
+#define PXE_OPCODE_RECEIVE_FILTERS  0x0009\r
+\r
+//\r
+// Read & change station MAC address.\r
+//\r
+#define PXE_OPCODE_STATION_ADDRESS  0x000A\r
+\r
+//\r
+// Read traffic statistics.\r
+//\r
+#define PXE_OPCODE_STATISTICS 0x000B\r
+\r
+//\r
+// Convert multicast IP address to multicast MAC address.\r
+//\r
+#define PXE_OPCODE_MCAST_IP_TO_MAC  0x000C\r
+\r
+//\r
+// Read or change non-volatile storage on the NIC.\r
+//\r
+#define PXE_OPCODE_NVDATA 0x000D\r
+\r
+//\r
+// Get & clear interrupt status.\r
+//\r
+#define PXE_OPCODE_GET_STATUS 0x000E\r
+\r
+//\r
+// Fill media header in packet for transmit.\r
+//\r
+#define PXE_OPCODE_FILL_HEADER  0x000F\r
+\r
+//\r
+// Transmit packet(s).\r
+//\r
+#define PXE_OPCODE_TRANSMIT 0x0010\r
+\r
+//\r
+// Receive packet.\r
+//\r
+#define PXE_OPCODE_RECEIVE  0x0011\r
+\r
+//\r
+// last valid opcode:\r
+//\r
+#define PXE_OPCODE_VALID_MAX  0x0011\r
+\r
+//\r
+// Last valid PXE UNDI OpCode number.\r
+//\r
+#define PXE_OPCODE_LAST_VALID 0x0011\r
+\r
+typedef UINT16  PXE_OPFLAGS;\r
+\r
+#define PXE_OPFLAGS_NOT_USED  0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Get State\r
+//\r
+// No OpFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Start\r
+//\r
+// No OpFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Stop\r
+//\r
+// No OpFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Get Init Info\r
+//\r
+// No Opflags\r
+\r
+////////////////////////////////////////\r
+// UNDI Get Config Info\r
+//\r
+// No Opflags\r
+\r
+////////////////////////////////////////\r
+// UNDI Initialize\r
+//\r
+#define PXE_OPFLAGS_INITIALIZE_CABLE_DETECT_MASK    0x0001\r
+#define PXE_OPFLAGS_INITIALIZE_DETECT_CABLE         0x0000\r
+#define PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Reset\r
+//\r
+#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS  0x0001\r
+#define PXE_OPFLAGS_RESET_DISABLE_FILTERS     0x0002\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Shutdown\r
+//\r
+// No OpFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Interrupt Enables\r
+//\r
+//\r
+// Select whether to enable or disable external interrupt signals.\r
+// Setting both enable and disable will return PXE_STATCODE_INVALID_OPFLAGS.\r
+//\r
+#define PXE_OPFLAGS_INTERRUPT_OPMASK  0xC000\r
+#define PXE_OPFLAGS_INTERRUPT_ENABLE  0x8000\r
+#define PXE_OPFLAGS_INTERRUPT_DISABLE 0x4000\r
+#define PXE_OPFLAGS_INTERRUPT_READ    0x0000\r
+\r
+//\r
+// Enable receive interrupts.  An external interrupt will be generated\r
+// after a complete non-error packet has been received.\r
+//\r
+#define PXE_OPFLAGS_INTERRUPT_RECEIVE 0x0001\r
+\r
+//\r
+// Enable transmit interrupts.  An external interrupt will be generated\r
+// after a complete non-error packet has been transmitted.\r
+//\r
+#define PXE_OPFLAGS_INTERRUPT_TRANSMIT  0x0002\r
+\r
+//\r
+// Enable command interrupts.  An external interrupt will be generated\r
+// when command execution stops.\r
+//\r
+#define PXE_OPFLAGS_INTERRUPT_COMMAND 0x0004\r
+\r
+//\r
+// Generate software interrupt.  Setting this bit generates an external\r
+// interrupt, if it is supported by the hardware.\r
+//\r
+#define PXE_OPFLAGS_INTERRUPT_SOFTWARE  0x0008\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Receive Filters\r
+//\r
+//\r
+// Select whether to enable or disable receive filters.\r
+// Setting both enable and disable will return PXE_STATCODE_INVALID_OPCODE.\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK   0xC000\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE   0x8000\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE  0x4000\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_READ     0x0000\r
+\r
+//\r
+// To reset the contents of the multicast MAC address filter list,\r
+// set this OpFlag:\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST 0x2000\r
+\r
+//\r
+// Enable unicast packet receiving.  Packets sent to the current station\r
+// MAC address will be received.\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST  0x0001\r
+\r
+//\r
+// Enable broadcast packet receiving.  Packets sent to the broadcast\r
+// MAC address will be received.\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST  0x0002\r
+\r
+//\r
+// Enable filtered multicast packet receiving.  Packets sent to any\r
+// of the multicast MAC addresses in the multicast MAC address filter\r
+// list will be received.  If the filter list is empty, no multicast\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004\r
+\r
+//\r
+// Enable promiscuous packet receiving.  All packets will be received.\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS  0x0008\r
+\r
+//\r
+// Enable promiscuous multicast packet receiving.  All multicast\r
+// packets will be received.\r
+//\r
+#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST  0x0010\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Station Address\r
+//\r
+#define PXE_OPFLAGS_STATION_ADDRESS_READ   0x0000\r
+#define PXE_OPFLAGS_STATION_ADDRESS_WRITE  0x0000\r
+#define PXE_OPFLAGS_STATION_ADDRESS_RESET  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Statistics\r
+//\r
+#define PXE_OPFLAGS_STATISTICS_READ   0x0000\r
+#define PXE_OPFLAGS_STATISTICS_RESET  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI MCast IP to MAC\r
+//\r
+//\r
+// Identify the type of IP address in the CPB.\r
+//\r
+#define PXE_OPFLAGS_MCAST_IP_TO_MAC_OPMASK  0x0003\r
+#define PXE_OPFLAGS_MCAST_IPV4_TO_MAC       0x0000\r
+#define PXE_OPFLAGS_MCAST_IPV6_TO_MAC       0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI NvData\r
+//\r
+//\r
+// Select the type of non-volatile data operation.\r
+//\r
+#define PXE_OPFLAGS_NVDATA_OPMASK 0x0001\r
+#define PXE_OPFLAGS_NVDATA_READ   0x0000\r
+#define PXE_OPFLAGS_NVDATA_WRITE  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Get Status\r
+//\r
+//\r
+// Return current interrupt status.  This will also clear any interrupts\r
+// that are currently set.  This can be used in a polling routine.  The\r
+// interrupt flags are still set and cleared even when the interrupts\r
+// are disabled.\r
+//\r
+#define PXE_OPFLAGS_GET_INTERRUPT_STATUS  0x0001\r
+\r
+//\r
+// Return list of transmitted buffers for recycling.  Transmit buffers\r
+// must not be changed or unallocated until they have recycled.  After\r
+// issuing a transmit command, wait for a transmit complete interrupt.\r
+// When a transmit complete interrupt is received, read the transmitted\r
+// buffers.  Do not plan on getting one buffer per interrupt.  Some\r
+// NICs and UNDIs may transmit multiple buffers per interrupt.\r
+//\r
+#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS 0x0002\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Fill Header\r
+//\r
+#define PXE_OPFLAGS_FILL_HEADER_OPMASK      0x0001\r
+#define PXE_OPFLAGS_FILL_HEADER_FRAGMENTED  0x0001\r
+#define PXE_OPFLAGS_FILL_HEADER_WHOLE       0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Transmit\r
+//\r
+//\r
+// S/W UNDI only.  Return after the packet has been transmitted.  A\r
+// transmit complete interrupt will still be generated and the transmit\r
+// buffer will have to be recycled.\r
+//\r
+#define PXE_OPFLAGS_SWUNDI_TRANSMIT_OPMASK  0x0001\r
+#define PXE_OPFLAGS_TRANSMIT_BLOCK          0x0001\r
+#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK     0x0000\r
+\r
+//\r
+//\r
+//\r
+#define PXE_OPFLAGS_TRANSMIT_OPMASK     0x0002\r
+#define PXE_OPFLAGS_TRANSMIT_FRAGMENTED 0x0002\r
+#define PXE_OPFLAGS_TRANSMIT_WHOLE      0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Receive\r
+//\r
+// No OpFlags\r
+//\r
+typedef UINT16  PXE_STATFLAGS;\r
+\r
+#define PXE_STATFLAGS_INITIALIZE  0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// Common StatFlags that can be returned by all commands.\r
+//\r
+//\r
+// The COMMAND_COMPLETE and COMMAND_FAILED status flags must be\r
+// implemented by all UNDIs.  COMMAND_QUEUED is only needed by UNDIs\r
+// that support command queuing.\r
+//\r
+#define PXE_STATFLAGS_STATUS_MASK       0xC000\r
+#define PXE_STATFLAGS_COMMAND_COMPLETE  0xC000\r
+#define PXE_STATFLAGS_COMMAND_FAILED    0x8000\r
+#define PXE_STATFLAGS_COMMAND_QUEUED    0x4000\r
+//\r
+// #define PXE_STATFLAGS_INITIALIZE              0x0000\r
+//\r
+#define PXE_STATFLAGS_DB_WRITE_TRUNCATED  0x2000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Get State\r
+//\r
+#define PXE_STATFLAGS_GET_STATE_MASK        0x0003\r
+#define PXE_STATFLAGS_GET_STATE_INITIALIZED 0x0002\r
+#define PXE_STATFLAGS_GET_STATE_STARTED     0x0001\r
+#define PXE_STATFLAGS_GET_STATE_STOPPED     0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Start\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Get Init Info\r
+//\r
+#define PXE_STATFLAGS_CABLE_DETECT_MASK           0x0001\r
+#define PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED  0x0000\r
+#define PXE_STATFLAGS_CABLE_DETECT_SUPPORTED      0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Initialize\r
+//\r
+#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Reset\r
+//\r
+#define PXE_STATFLAGS_RESET_NO_MEDIA  0x0001\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Shutdown\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Interrupt Enables\r
+//\r
+//\r
+// If set, receive interrupts are enabled.\r
+//\r
+#define PXE_STATFLAGS_INTERRUPT_RECEIVE 0x0001\r
+\r
+//\r
+// If set, transmit interrupts are enabled.\r
+//\r
+#define PXE_STATFLAGS_INTERRUPT_TRANSMIT  0x0002\r
+\r
+//\r
+// If set, command interrupts are enabled.\r
+//\r
+#define PXE_STATFLAGS_INTERRUPT_COMMAND 0x0004\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Receive Filters\r
+//\r
+//\r
+// If set, unicast packets will be received.\r
+//\r
+#define PXE_STATFLAGS_RECEIVE_FILTER_UNICAST  0x0001\r
+\r
+//\r
+// If set, broadcast packets will be received.\r
+//\r
+#define PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST  0x0002\r
+\r
+//\r
+// If set, multicast packets that match up with the multicast address\r
+// filter list will be received.\r
+//\r
+#define PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004\r
+\r
+//\r
+// If set, all packets will be received.\r
+//\r
+#define PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS  0x0008\r
+\r
+//\r
+// If set, all multicast packets will be received.\r
+//\r
+#define PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST  0x0010\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Station Address\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Statistics\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI MCast IP to MAC\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI NvData\r
+//\r
+// No additional StatFlags\r
+\r
+\r
+////////////////////////////////////////\r
+// UNDI Get Status\r
+//\r
+//\r
+// Use to determine if an interrupt has occurred.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK 0x000F\r
+#define PXE_STATFLAGS_GET_STATUS_NO_INTERRUPTS  0x0000\r
+\r
+//\r
+// If set, at least one receive interrupt occurred.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_RECEIVE  0x0001\r
+\r
+//\r
+// If set, at least one transmit interrupt occurred.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_TRANSMIT 0x0002\r
+\r
+//\r
+// If set, at least one command interrupt occurred.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_COMMAND  0x0004\r
+\r
+//\r
+// If set, at least one software interrupt occurred.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_SOFTWARE 0x0008\r
+\r
+//\r
+// This flag is set if the transmitted buffer queue is empty.  This flag\r
+// will be set if all transmitted buffer addresses get written into the DB.\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY  0x0010\r
+\r
+//\r
+// This flag is set if no transmitted buffer addresses were written\r
+// into the DB.  (This could be because DBsize was too small.)\r
+//\r
+#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN  0x0020\r
+\r
+//\r
+// //////////////////////////////////////\r
+// UNDI Fill Header\r
+//\r
+// No additional StatFlags\r
+\r
+////////////////////////////////////////\r
+// UNDI Transmit\r
+//\r
+// No additional StatFlags.\r
+\r
+////////////////////////////////////////\r
+// UNDI Receive\r
+//\r
+// No additional StatFlags.\r
+//\r
+typedef UINT16  PXE_STATCODE;\r
+\r
+#define PXE_STATCODE_INITIALIZE 0x0000\r
+\r
+//\r
+// //////////////////////////////////////\r
+// Common StatCodes returned by all UNDI commands, UNDI protocol functions\r
+// and BC protocol functions.\r
+//\r
+#define PXE_STATCODE_SUCCESS              0x0000\r
+\r
+#define PXE_STATCODE_INVALID_CDB          0x0001\r
+#define PXE_STATCODE_INVALID_CPB          0x0002\r
+#define PXE_STATCODE_BUSY                 0x0003\r
+#define PXE_STATCODE_QUEUE_FULL           0x0004\r
+#define PXE_STATCODE_ALREADY_STARTED      0x0005\r
+#define PXE_STATCODE_NOT_STARTED          0x0006\r
+#define PXE_STATCODE_NOT_SHUTDOWN         0x0007\r
+#define PXE_STATCODE_ALREADY_INITIALIZED  0x0008\r
+#define PXE_STATCODE_NOT_INITIALIZED      0x0009\r
+#define PXE_STATCODE_DEVICE_FAILURE       0x000A\r
+#define PXE_STATCODE_NVDATA_FAILURE       0x000B\r
+#define PXE_STATCODE_UNSUPPORTED          0x000C\r
+#define PXE_STATCODE_BUFFER_FULL          0x000D\r
+#define PXE_STATCODE_INVALID_PARAMETER    0x000E\r
+#define PXE_STATCODE_INVALID_UNDI         0x000F\r
+#define PXE_STATCODE_IPV4_NOT_SUPPORTED   0x0010\r
+#define PXE_STATCODE_IPV6_NOT_SUPPORTED   0x0011\r
+#define PXE_STATCODE_NOT_ENOUGH_MEMORY    0x0012\r
+#define PXE_STATCODE_NO_DATA              0x0013\r
+\r
+typedef UINT16  PXE_IFNUM;\r
+\r
+//\r
+// This interface number must be passed to the S/W UNDI Start command.\r
+//\r
+#define PXE_IFNUM_START 0x0000\r
+\r
+//\r
+// This interface number is returned by the S/W UNDI Get State and\r
+// Start commands if information in the CDB, CPB or DB is invalid.\r
+//\r
+#define PXE_IFNUM_INVALID 0x0000\r
+\r
+typedef UINT16  PXE_CONTROL;\r
+\r
+//\r
+// Setting this flag directs the UNDI to queue this command for later\r
+// execution if the UNDI is busy and it supports command queuing.\r
+// If queuing is not supported, a PXE_STATCODE_INVALID_CONTROL error\r
+// is returned.  If the queue is full, a PXE_STATCODE_CDB_QUEUE_FULL\r
+// error is returned.\r
+//\r
+#define PXE_CONTROL_QUEUE_IF_BUSY 0x0002\r
+\r
+//\r
+// These two bit values are used to determine if there are more UNDI\r
+// CDB structures following this one.  If the link bit is set, there\r
+// must be a CDB structure following this one.  Execution will start\r
+// on the next CDB structure as soon as this one completes successfully.\r
+// If an error is generated by this command, execution will stop.\r
+//\r
+#define PXE_CONTROL_LINK              0x0001\r
+#define PXE_CONTROL_LAST_CDB_IN_LIST  0x0000\r
+\r
+typedef UINT8   PXE_FRAME_TYPE;\r
+\r
+#define PXE_FRAME_TYPE_NONE         0x00\r
+#define PXE_FRAME_TYPE_UNICAST      0x01\r
+#define PXE_FRAME_TYPE_BROADCAST    0x02\r
+#define PXE_FRAME_TYPE_MULTICAST    0x03\r
+#define PXE_FRAME_TYPE_PROMISCUOUS  0x04\r
+\r
+typedef UINT32  PXE_IPV4;\r
+\r
+typedef UINT32  PXE_IPV6[4];\r
+#define PXE_MAC_LENGTH  32\r
+\r
+typedef UINT8   PXE_MAC_ADDR[PXE_MAC_LENGTH];\r
+\r
+typedef UINT8   PXE_IFTYPE;\r
+typedef UINT16  PXE_MEDIA_PROTOCOL;\r
+\r
+//\r
+// This information is from the ARP section of RFC 1700.\r
+//\r
+//     1 Ethernet (10Mb)                                    [JBP]\r
+//     2 Experimental Ethernet (3Mb)                        [JBP]\r
+//     3 Amateur Radio AX.25                                [PXK]\r
+//     4 Proteon ProNET Token Ring                          [JBP]\r
+//     5 Chaos                                              [GXP]\r
+//     6 IEEE 802 Networks                                  [JBP]\r
+//     7 ARCNET                                             [JBP]\r
+//     8 Hyperchannel                                       [JBP]\r
+//     9 Lanstar                                             [TU]\r
+//    10 Autonet Short Address                             [MXB1]\r
+//    11 LocalTalk                                         [JKR1]\r
+//    12 LocalNet (IBM* PCNet or SYTEK* LocalNET)           [JXM]\r
+//    13 Ultra link                                        [RXD2]\r
+//    14 SMDS                                              [GXC1]\r
+//    15 Frame Relay                                        [AGM]\r
+//    16 Asynchronous Transmission Mode (ATM)              [JXB2]\r
+//    17 HDLC                                               [JBP]\r
+//    18 Fibre Channel                            [Yakov Rekhter]\r
+//    19 Asynchronous Transmission Mode (ATM)      [Mark Laubach]\r
+//    20 Serial Line                                        [JBP]\r
+//    21 Asynchronous Transmission Mode (ATM)              [MXB1]\r
+//\r
+// * Other names and brands may be claimed as the property of others.\r
+//\r
+#define PXE_IFTYPE_ETHERNET       0x01\r
+#define PXE_IFTYPE_TOKENRING      0x04\r
+#define PXE_IFTYPE_FIBRE_CHANNEL  0x12\r
+\r
+typedef struct s_pxe_hw_undi {\r
+  UINT32  Signature;      // PXE_ROMID_SIGNATURE\r
+  UINT8   Len;            // sizeof(PXE_HW_UNDI)\r
+  UINT8   Fudge;          // makes 8-bit cksum equal zero\r
+  UINT8   Rev;            // PXE_ROMID_REV\r
+  UINT8   IFcnt;          // physical connector count\r
+  UINT8   MajorVer;       // PXE_ROMID_MAJORVER\r
+  UINT8   MinorVer;       // PXE_ROMID_MINORVER\r
+  UINT16  reserved;       // zero, not used\r
+  UINT32  Implementation; // implementation flags\r
+  // reserved             // vendor use\r
+  // UINT32 Status;       // status port\r
+  // UINT32 Command;      // command port\r
+  // UINT64 CDBaddr;      // CDB address port\r
+  //\r
+} PXE_HW_UNDI;\r
+\r
+//\r
+// Status port bit definitions\r
+//\r
+//\r
+// UNDI operation state\r
+//\r
+#define PXE_HWSTAT_STATE_MASK   0xC0000000\r
+#define PXE_HWSTAT_BUSY         0xC0000000\r
+#define PXE_HWSTAT_INITIALIZED  0x80000000\r
+#define PXE_HWSTAT_STARTED      0x40000000\r
+#define PXE_HWSTAT_STOPPED      0x00000000\r
+\r
+//\r
+// If set, last command failed\r
+//\r
+#define PXE_HWSTAT_COMMAND_FAILED 0x20000000\r
+\r
+//\r
+// If set, identifies enabled receive filters\r
+//\r
+#define PXE_HWSTAT_PROMISCUOUS_MULTICAST_RX_ENABLED 0x00001000\r
+#define PXE_HWSTAT_PROMISCUOUS_RX_ENABLED           0x00000800\r
+#define PXE_HWSTAT_BROADCAST_RX_ENABLED             0x00000400\r
+#define PXE_HWSTAT_MULTICAST_RX_ENABLED             0x00000200\r
+#define PXE_HWSTAT_UNICAST_RX_ENABLED               0x00000100\r
+\r
+//\r
+// If set, identifies enabled external interrupts\r
+//\r
+#define PXE_HWSTAT_SOFTWARE_INT_ENABLED     0x00000080\r
+#define PXE_HWSTAT_TX_COMPLETE_INT_ENABLED  0x00000040\r
+#define PXE_HWSTAT_PACKET_RX_INT_ENABLED    0x00000020\r
+#define PXE_HWSTAT_CMD_COMPLETE_INT_ENABLED 0x00000010\r
+\r
+//\r
+// If set, identifies pending interrupts\r
+//\r
+#define PXE_HWSTAT_SOFTWARE_INT_PENDING     0x00000008\r
+#define PXE_HWSTAT_TX_COMPLETE_INT_PENDING  0x00000004\r
+#define PXE_HWSTAT_PACKET_RX_INT_PENDING    0x00000002\r
+#define PXE_HWSTAT_CMD_COMPLETE_INT_PENDING 0x00000001\r
+\r
+//\r
+// Command port definitions\r
+//\r
+//\r
+// If set, CDB identified in CDBaddr port is given to UNDI.\r
+// If not set, other bits in this word will be processed.\r
+//\r
+#define PXE_HWCMD_ISSUE_COMMAND   0x80000000\r
+#define PXE_HWCMD_INTS_AND_FILTS  0x00000000\r
+\r
+//\r
+// Use these to enable/disable receive filters.\r
+//\r
+#define PXE_HWCMD_PROMISCUOUS_MULTICAST_RX_ENABLE 0x00001000\r
+#define PXE_HWCMD_PROMISCUOUS_RX_ENABLE           0x00000800\r
+#define PXE_HWCMD_BROADCAST_RX_ENABLE             0x00000400\r
+#define PXE_HWCMD_MULTICAST_RX_ENABLE             0x00000200\r
+#define PXE_HWCMD_UNICAST_RX_ENABLE               0x00000100\r
+\r
+//\r
+// Use these to enable/disable external interrupts\r
+//\r
+#define PXE_HWCMD_SOFTWARE_INT_ENABLE     0x00000080\r
+#define PXE_HWCMD_TX_COMPLETE_INT_ENABLE  0x00000040\r
+#define PXE_HWCMD_PACKET_RX_INT_ENABLE    0x00000020\r
+#define PXE_HWCMD_CMD_COMPLETE_INT_ENABLE 0x00000010\r
+\r
+//\r
+// Use these to clear pending external interrupts\r
+//\r
+#define PXE_HWCMD_CLEAR_SOFTWARE_INT      0x00000008\r
+#define PXE_HWCMD_CLEAR_TX_COMPLETE_INT   0x00000004\r
+#define PXE_HWCMD_CLEAR_PACKET_RX_INT     0x00000002\r
+#define PXE_HWCMD_CLEAR_CMD_COMPLETE_INT  0x00000001\r
+\r
+typedef struct s_pxe_sw_undi {\r
+  UINT32  Signature;      // PXE_ROMID_SIGNATURE\r
+  UINT8   Len;            // sizeof(PXE_SW_UNDI)\r
+  UINT8   Fudge;          // makes 8-bit cksum zero\r
+  UINT8   Rev;            // PXE_ROMID_REV\r
+  UINT8   IFcnt;          // physical connector count\r
+  UINT8   MajorVer;       // PXE_ROMID_MAJORVER\r
+  UINT8   MinorVer;       // PXE_ROMID_MINORVER\r
+  UINT16  reserved1;      // zero, not used\r
+  UINT32  Implementation; // Implementation flags\r
+  UINT64  EntryPoint;     // API entry point\r
+  UINT8   reserved2[3];   // zero, not used\r
+  UINT8   BusCnt;         // number of bustypes supported\r
+  UINT32  BusType[1];     // list of supported bustypes\r
+} PXE_SW_UNDI;\r
+\r
+typedef union u_pxe_undi {\r
+  PXE_HW_UNDI hw;\r
+  PXE_SW_UNDI sw;\r
+} PXE_UNDI;\r
+\r
+//\r
+// Signature of !PXE structure\r
+//\r
+#define PXE_ROMID_SIGNATURE PXE_BUSTYPE ('!', 'P', 'X', 'E')\r
+\r
+//\r
+// !PXE structure format revision\r
+//\r
+#define PXE_ROMID_REV 0x02\r
+\r
+//\r
+// UNDI command interface revision.  These are the values that get sent\r
+// in option 94 (Client Network Interface Identifier) in the DHCP Discover\r
+// and PXE Boot Server Request packets.\r
+//\r
+#define PXE_ROMID_MAJORVER    0x03\r
+#define PXE_ROMID_MINORVER    0x00\r
+#define PXE_ROMID_MINORVER_31 0x10\r
+\r
+//\r
+// Implementation flags\r
+//\r
+#define PXE_ROMID_IMP_HW_UNDI                             0x80000000\r
+#define PXE_ROMID_IMP_SW_VIRT_ADDR                        0x40000000\r
+#define PXE_ROMID_IMP_64BIT_DEVICE                        0x00010000\r
+#define PXE_ROMID_IMP_FRAG_SUPPORTED                      0x00008000\r
+#define PXE_ROMID_IMP_CMD_LINK_SUPPORTED                  0x00004000\r
+#define PXE_ROMID_IMP_CMD_QUEUE_SUPPORTED                 0x00002000\r
+#define PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED               0x00001000\r
+#define PXE_ROMID_IMP_NVDATA_SUPPORT_MASK                 0x00000C00\r
+#define PXE_ROMID_IMP_NVDATA_BULK_WRITABLE                0x00000C00\r
+#define PXE_ROMID_IMP_NVDATA_SPARSE_WRITABLE              0x00000800\r
+#define PXE_ROMID_IMP_NVDATA_READ_ONLY                    0x00000400\r
+#define PXE_ROMID_IMP_NVDATA_NOT_AVAILABLE                0x00000000\r
+#define PXE_ROMID_IMP_STATISTICS_SUPPORTED                0x00000200\r
+#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE               0x00000100\r
+#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED  0x00000080\r
+#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED            0x00000040\r
+#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED              0x00000020\r
+#define PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED     0x00000010\r
+#define PXE_ROMID_IMP_SOFTWARE_INT_SUPPORTED              0x00000008\r
+#define PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED           0x00000004\r
+#define PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED             0x00000002\r
+#define PXE_ROMID_IMP_CMD_COMPLETE_INT_SUPPORTED          0x00000001\r
+\r
+typedef struct s_pxe_cdb {\r
+  PXE_OPCODE    OpCode;\r
+  PXE_OPFLAGS   OpFlags;\r
+  UINT16        CPBsize;\r
+  UINT16        DBsize;\r
+  UINT64        CPBaddr;\r
+  UINT64        DBaddr;\r
+  PXE_STATCODE  StatCode;\r
+  PXE_STATFLAGS StatFlags;\r
+  UINT16        IFnum;\r
+  PXE_CONTROL   Control;\r
+} PXE_CDB;\r
+\r
+typedef union u_pxe_ip_addr {\r
+  PXE_IPV6  IPv6;\r
+  PXE_IPV4  IPv4;\r
+} PXE_IP_ADDR;\r
+\r
+typedef union pxe_device {\r
+  //\r
+  // PCI and PC Card NICs are both identified using bus, device\r
+  // and function numbers.  For PC Card, this may require PC\r
+  // Card services to be loaded in the BIOS or preboot\r
+  // environment.\r
+  //\r
+  struct {\r
+    //\r
+    // See S/W UNDI ROMID structure definition for PCI and\r
+    // PCC BusType definitions.\r
+    //\r
+    UINT32  BusType;\r
+\r
+    //\r
+    // Bus, device & function numbers that locate this device.\r
+    //\r
+    UINT16  Bus;\r
+    UINT8   Device;\r
+    UINT8   Function;\r
+  }\r
+  PCI, PCC;\r
+\r
+  //\r
+  // %%TBD - More information is needed about enumerating\r
+  // USB and 1394 devices.\r
+  //\r
+  struct {\r
+    UINT32  BusType;\r
+    UINT32  tdb;\r
+  }\r
+  USB, _1394;\r
+} PXE_DEVICE;\r
+\r
+//\r
+// cpb and db definitions\r
+//\r
+#define MAX_PCI_CONFIG_LEN    64  // # of dwords\r
+#define MAX_EEPROM_LEN        128 // #of dwords\r
+#define MAX_XMIT_BUFFERS      32  // recycling Q length for xmit_done\r
+#define MAX_MCAST_ADDRESS_CNT 8\r
+\r
+typedef struct s_pxe_cpb_start {\r
+  //\r
+  // PXE_VOID Delay(UINTN microseconds);\r
+  //\r
+  // UNDI will never request a delay smaller than 10 microseconds\r
+  // and will always request delays in increments of 10 microseconds.\r
+  // The Delay() CallBack routine must delay between n and n + 10\r
+  // microseconds before returning control to the UNDI.\r
+  //\r
+  // This field cannot be set to zero.\r
+  //\r
+  UINT64  Delay;\r
+\r
+  //\r
+  // PXE_VOID Block(UINT32 enable);\r
+  //\r
+  // UNDI may need to block multi-threaded/multi-processor access to\r
+  // critical code sections when programming or accessing the network\r
+  // device.  To this end, a blocking service is needed by the UNDI.\r
+  // When UNDI needs a block, it will call Block() passing a non-zero\r
+  // value.  When UNDI no longer needs a block, it will call Block()\r
+  // with a zero value.  When called, if the Block() is already enabled,\r
+  // do not return control to the UNDI until the previous Block() is\r
+  // disabled.\r
+  //\r
+  // This field cannot be set to zero.\r
+  //\r
+  UINT64  Block;\r
+\r
+  //\r
+  // PXE_VOID Virt2Phys(UINT64 virtual, UINT64 physical_ptr);\r
+  //\r
+  // UNDI will pass the virtual address of a buffer and the virtual\r
+  // address of a 64-bit physical buffer.  Convert the virtual address\r
+  // to a physical address and write the result to the physical address\r
+  // buffer.  If virtual and physical addresses are the same, just\r
+  // copy the virtual address to the physical address buffer.\r
+  //\r
+  // This field can be set to zero if virtual and physical addresses\r
+  // are equal.\r
+  //\r
+  UINT64  Virt2Phys;\r
+  //\r
+  // PXE_VOID Mem_IO(UINT8 read_write, UINT8 len, UINT64 port,\r
+  //              UINT64 buf_addr);\r
+  //\r
+  // UNDI will read or write the device io space using this call back\r
+  // function. It passes the number of bytes as the len parameter and it\r
+  // will be either 1,2,4 or 8.\r
+  //\r
+  // This field can not be set to zero.\r
+  //\r
+  UINT64  Mem_IO;\r
+} PXE_CPB_START;\r
+\r
+typedef struct s_pxe_cpb_start_31 {\r
+  //\r
+  // PXE_VOID Delay(UINT64 UnqId, UINTN microseconds);\r
+  //\r
+  // UNDI will never request a delay smaller than 10 microseconds\r
+  // and will always request delays in increments of 10 microseconds.\r
+  // The Delay() CallBack routine must delay between n and n + 10\r
+  // microseconds before returning control to the UNDI.\r
+  //\r
+  // This field cannot be set to zero.\r
+  //\r
+  UINT64  Delay;\r
+\r
+  //\r
+  // PXE_VOID Block(UINT64 unq_id, UINT32 enable);\r
+  //\r
+  // UNDI may need to block multi-threaded/multi-processor access to\r
+  // critical code sections when programming or accessing the network\r
+  // device.  To this end, a blocking service is needed by the UNDI.\r
+  // When UNDI needs a block, it will call Block() passing a non-zero\r
+  // value.  When UNDI no longer needs a block, it will call Block()\r
+  // with a zero value.  When called, if the Block() is already enabled,\r
+  // do not return control to the UNDI until the previous Block() is\r
+  // disabled.\r
+  //\r
+  // This field cannot be set to zero.\r
+  //\r
+  UINT64  Block;\r
+\r
+  //\r
+  // PXE_VOID Virt2Phys(UINT64 UnqId, UINT64 virtual, UINT64 physical_ptr);\r
+  //\r
+  // UNDI will pass the virtual address of a buffer and the virtual\r
+  // address of a 64-bit physical buffer.  Convert the virtual address\r
+  // to a physical address and write the result to the physical address\r
+  // buffer.  If virtual and physical addresses are the same, just\r
+  // copy the virtual address to the physical address buffer.\r
+  //\r
+  // This field can be set to zero if virtual and physical addresses\r
+  // are equal.\r
+  //\r
+  UINT64  Virt2Phys;\r
+  //\r
+  // PXE_VOID Mem_IO(UINT64 UnqId, UINT8 read_write, UINT8 len, UINT64 port,\r
+  //              UINT64 buf_addr);\r
+  //\r
+  // UNDI will read or write the device io space using this call back\r
+  // function. It passes the number of bytes as the len parameter and it\r
+  // will be either 1,2,4 or 8.\r
+  //\r
+  // This field can not be set to zero.\r
+  //\r
+  UINT64  Mem_IO;\r
+  //\r
+  // PXE_VOID Map_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size,\r
+  //                 UINT32 Direction, UINT64 mapped_addr);\r
+  //\r
+  // UNDI will pass the virtual address of a buffer, direction of the data\r
+  // flow from/to the mapped buffer (the constants are defined below)\r
+  // and a place holder (pointer) for the mapped address.\r
+  // This call will Map the given address to a physical DMA address and write\r
+  // the result to the mapped_addr pointer.  If there is no need to\r
+  // map the given address to a lower address (i.e. the given address is\r
+  // associated with a physical address that is already compatible to be\r
+  // used with the DMA, it converts the given virtual address to it's\r
+  // physical address and write that in the mapped address pointer.\r
+  //\r
+  // This field can be set to zero if there is no mapping service available\r
+  //\r
+  UINT64  Map_Mem;\r
+\r
+  //\r
+  // PXE_VOID UnMap_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size,\r
+  //            UINT32 Direction, UINT64 mapped_addr);\r
+  //\r
+  // UNDI will pass the virtual and mapped addresses of a buffer\r
+  // This call will un map the given address\r
+  //\r
+  // This field can be set to zero if there is no unmapping service available\r
+  //\r
+  UINT64  UnMap_Mem;\r
+\r
+  //\r
+  // PXE_VOID Sync_Mem(UINT64 unq_id, UINT64 virtual,\r
+  //            UINT32 size, UINT32 Direction, UINT64 mapped_addr);\r
+  //\r
+  // UNDI will pass the virtual and mapped addresses of a buffer\r
+  // This call will synchronize the contents of both the virtual and mapped\r
+  // buffers for the given Direction.\r
+  //\r
+  // This field can be set to zero if there is no service available\r
+  //\r
+  UINT64  Sync_Mem;\r
+\r
+  //\r
+  // protocol driver can provide anything for this Unique_ID, UNDI remembers\r
+  // that as just a 64bit value assocaited to the interface specified by\r
+  // the ifnum and gives it back as a parameter to all the call-back routines\r
+  // when calling for that interface!\r
+  //\r
+  UINT64  Unique_ID;\r
+  //\r
+} PXE_CPB_START_31;\r
+\r
+#define TO_AND_FROM_DEVICE    0\r
+#define FROM_DEVICE           1\r
+#define TO_DEVICE             2\r
+\r
+#define PXE_DELAY_MILLISECOND 1000\r
+#define PXE_DELAY_SECOND      1000000\r
+#define PXE_IO_READ           0\r
+#define PXE_IO_WRITE          1\r
+#define PXE_MEM_READ          2\r
+#define PXE_MEM_WRITE         4\r
+\r
+typedef struct s_pxe_db_get_init_info {\r
+  //\r
+  // Minimum length of locked memory buffer that must be given to\r
+  // the Initialize command. Giving UNDI more memory will generally\r
+  // give better performance.\r
+  //\r
+  // If MemoryRequired is zero, the UNDI does not need and will not\r
+  // use system memory to receive and transmit packets.\r
+  //\r
+  UINT32  MemoryRequired;\r
+\r
+  //\r
+  // Maximum frame data length for Tx/Rx excluding the media header.\r
+  //\r
+  UINT32  FrameDataLen;\r
+\r
+  //\r
+  // Supported link speeds are in units of mega bits.  Common ethernet\r
+  // values are 10, 100 and 1000.  Unused LinkSpeeds[] entries are zero\r
+  // filled.\r
+  //\r
+  UINT32  LinkSpeeds[4];\r
+\r
+  //\r
+  // Number of non-volatile storage items.\r
+  //\r
+  UINT32  NvCount;\r
+\r
+  //\r
+  // Width of non-volatile storage item in bytes.  0, 1, 2 or 4\r
+  //\r
+  UINT16  NvWidth;\r
+\r
+  //\r
+  // Media header length.  This is the typical media header length for\r
+  // this UNDI.  This information is needed when allocating receive\r
+  // and transmit buffers.\r
+  //\r
+  UINT16  MediaHeaderLen;\r
+\r
+  //\r
+  // Number of bytes in the NIC hardware (MAC) address.\r
+  //\r
+  UINT16  HWaddrLen;\r
+\r
+  //\r
+  // Maximum number of multicast MAC addresses in the multicast\r
+  // MAC address filter list.\r
+  //\r
+  UINT16  MCastFilterCnt;\r
+\r
+  //\r
+  // Default number and size of transmit and receive buffers that will\r
+  // be allocated by the UNDI.  If MemoryRequired is non-zero, this\r
+  // allocation will come out of the memory buffer given to the Initialize\r
+  // command.  If MemoryRequired is zero, this allocation will come out of\r
+  // memory on the NIC.\r
+  //\r
+  UINT16  TxBufCnt;\r
+  UINT16  TxBufSize;\r
+  UINT16  RxBufCnt;\r
+  UINT16  RxBufSize;\r
+\r
+  //\r
+  // Hardware interface types defined in the Assigned Numbers RFC\r
+  // and used in DHCP and ARP packets.\r
+  // See the PXE_IFTYPE typedef and PXE_IFTYPE_xxx macros.\r
+  //\r
+  UINT8   IFtype;\r
+\r
+  //\r
+  // Supported duplex.  See PXE_DUPLEX_xxxxx #defines below.\r
+  //\r
+  UINT8   Duplex;\r
+\r
+  //\r
+  // Supported loopback options.  See PXE_LOOPBACK_xxxxx #defines below.\r
+  //\r
+  UINT8   LoopBack;\r
+} PXE_DB_GET_INIT_INFO;\r
+\r
+#define PXE_MAX_TXRX_UNIT_ETHER           1500\r
+\r
+#define PXE_HWADDR_LEN_ETHER              0x0006\r
+#define PXE_MAC_HEADER_LEN_ETHER          0x000E\r
+\r
+#define PXE_DUPLEX_ENABLE_FULL_SUPPORTED  1\r
+#define PXE_DUPLEX_FORCE_FULL_SUPPORTED   2\r
+\r
+#define PXE_LOOPBACK_INTERNAL_SUPPORTED   1\r
+#define PXE_LOOPBACK_EXTERNAL_SUPPORTED   2\r
+\r
+typedef struct s_pxe_pci_config_info {\r
+  //\r
+  // This is the flag field for the PXE_DB_GET_CONFIG_INFO union.\r
+  // For PCI bus devices, this field is set to PXE_BUSTYPE_PCI.\r
+  //\r
+  UINT32  BusType;\r
+\r
+  //\r
+  // This identifies the PCI network device that this UNDI interface\r
+  // is bound to.\r
+  //\r
+  UINT16  Bus;\r
+  UINT8   Device;\r
+  UINT8   Function;\r
+\r
+  //\r
+  // This is a copy of the PCI configuration space for this\r
+  // network device.\r
+  //\r
+  union {\r
+    UINT8   Byte[256];\r
+    UINT16  Word[128];\r
+    UINT32  Dword[64];\r
+  } Config;\r
+} PXE_PCI_CONFIG_INFO;\r
+\r
+typedef struct s_pxe_pcc_config_info {\r
+  //\r
+  // This is the flag field for the PXE_DB_GET_CONFIG_INFO union.\r
+  // For PCC bus devices, this field is set to PXE_BUSTYPE_PCC.\r
+  //\r
+  UINT32  BusType;\r
+\r
+  //\r
+  // This identifies the PCC network device that this UNDI interface\r
+  // is bound to.\r
+  //\r
+  UINT16  Bus;\r
+  UINT8   Device;\r
+  UINT8   Function;\r
+\r
+  //\r
+  // This is a copy of the PCC configuration space for this\r
+  // network device.\r
+  //\r
+  union {\r
+    UINT8   Byte[256];\r
+    UINT16  Word[128];\r
+    UINT32  Dword[64];\r
+  } Config;\r
+} PXE_PCC_CONFIG_INFO;\r
+\r
+typedef struct s_pxe_usb_config_info {\r
+  UINT32  BusType;\r
+  //\r
+  // %%TBD What should we return here...\r
+  //\r
+} PXE_USB_CONFIG_INFO;\r
+\r
+typedef struct s_pxe_1394_config_info {\r
+  UINT32  BusType;\r
+  //\r
+  // %%TBD What should we return here...\r
+  //\r
+} PXE_1394_CONFIG_INFO;\r
+\r
+typedef union u_pxe_db_get_config_info {\r
+  PXE_PCI_CONFIG_INFO   pci;\r
+  PXE_PCC_CONFIG_INFO   pcc;\r
+  PXE_USB_CONFIG_INFO   usb;\r
+  PXE_1394_CONFIG_INFO  _1394;\r
+} PXE_DB_GET_CONFIG_INFO;\r
+\r
+typedef struct s_pxe_cpb_initialize {\r
+  //\r
+  // Address of first (lowest) byte of the memory buffer.  This buffer must\r
+  // be in contiguous physical memory and cannot be swapped out.  The UNDI\r
+  // will be using this for transmit and receive buffering.\r
+  //\r
+  UINT64  MemoryAddr;\r
+\r
+  //\r
+  // MemoryLength must be greater than or equal to MemoryRequired\r
+  // returned by the Get Init Info command.\r
+  //\r
+  UINT32  MemoryLength;\r
+\r
+  //\r
+  // Desired link speed in Mbit/sec.  Common ethernet values are 10, 100\r
+  // and 1000.  Setting a value of zero will auto-detect and/or use the\r
+  // default link speed (operation depends on UNDI/NIC functionality).\r
+  //\r
+  UINT32  LinkSpeed;\r
+\r
+  //\r
+  // Suggested number and size of receive and transmit buffers to\r
+  // allocate.  If MemoryAddr and MemoryLength are non-zero, this\r
+  // allocation comes out of the supplied memory buffer.  If MemoryAddr\r
+  // and MemoryLength are zero, this allocation comes out of memory\r
+  // on the NIC.\r
+  //\r
+  // If these fields are set to zero, the UNDI will allocate buffer\r
+  // counts and sizes as it sees fit.\r
+  //\r
+  UINT16  TxBufCnt;\r
+  UINT16  TxBufSize;\r
+  UINT16  RxBufCnt;\r
+  UINT16  RxBufSize;\r
+\r
+  //\r
+  // The following configuration parameters are optional and must be zero\r
+  // to use the default values.\r
+  //\r
+  UINT8   Duplex;\r
+\r
+  UINT8   LoopBack;\r
+} PXE_CPB_INITIALIZE;\r
+\r
+#define PXE_DUPLEX_DEFAULT      0x00\r
+#define PXE_FORCE_FULL_DUPLEX   0x01\r
+#define PXE_ENABLE_FULL_DUPLEX  0x02\r
+#define PXE_FORCE_HALF_DUPLEX   0x04\r
+#define PXE_DISABLE_FULL_DUPLEX 0x08\r
+\r
+#define LOOPBACK_NORMAL         0\r
+#define LOOPBACK_INTERNAL       1\r
+#define LOOPBACK_EXTERNAL       2\r
+\r
+typedef struct s_pxe_db_initialize {\r
+  //\r
+  // Actual amount of memory used from the supplied memory buffer.  This\r
+  // may be less that the amount of memory suppllied and may be zero if\r
+  // the UNDI and network device do not use external memory buffers.\r
+  //\r
+  // Memory used by the UNDI and network device is allocated from the\r
+  // lowest memory buffer address.\r
+  //\r
+  UINT32  MemoryUsed;\r
+\r
+  //\r
+  // Actual number and size of receive and transmit buffers that were\r
+  // allocated.\r
+  //\r
+  UINT16  TxBufCnt;\r
+  UINT16  TxBufSize;\r
+  UINT16  RxBufCnt;\r
+  UINT16  RxBufSize;\r
+} PXE_DB_INITIALIZE;\r
+\r
+typedef struct s_pxe_cpb_receive_filters {\r
+  //\r
+  // List of multicast MAC addresses.  This list, if present, will\r
+  // replace the existing multicast MAC address filter list.\r
+  //\r
+  PXE_MAC_ADDR  MCastList[MAX_MCAST_ADDRESS_CNT];\r
+} PXE_CPB_RECEIVE_FILTERS;\r
+\r
+typedef struct s_pxe_db_receive_filters {\r
+  //\r
+  // Filtered multicast MAC address list.\r
+  //\r
+  PXE_MAC_ADDR  MCastList[MAX_MCAST_ADDRESS_CNT];\r
+} PXE_DB_RECEIVE_FILTERS;\r
+\r
+typedef struct s_pxe_cpb_station_address {\r
+  //\r
+  // If supplied and supported, the current station MAC address\r
+  // will be changed.\r
+  //\r
+  PXE_MAC_ADDR  StationAddr;\r
+} PXE_CPB_STATION_ADDRESS;\r
+\r
+typedef struct s_pxe_dpb_station_address {\r
+  //\r
+  // Current station MAC address.\r
+  //\r
+  PXE_MAC_ADDR  StationAddr;\r
+\r
+  //\r
+  // Station broadcast MAC address.\r
+  //\r
+  PXE_MAC_ADDR  BroadcastAddr;\r
+\r
+  //\r
+  // Permanent station MAC address.\r
+  //\r
+  PXE_MAC_ADDR  PermanentAddr;\r
+} PXE_DB_STATION_ADDRESS;\r
+\r
+typedef struct s_pxe_db_statistics {\r
+  //\r
+  // Bit field identifying what statistic data is collected by the\r
+  // UNDI/NIC.\r
+  // If bit 0x00 is set, Data[0x00] is collected.\r
+  // If bit 0x01 is set, Data[0x01] is collected.\r
+  // If bit 0x20 is set, Data[0x20] is collected.\r
+  // If bit 0x21 is set, Data[0x21] is collected.\r
+  // Etc.\r
+  //\r
+  UINT64  Supported;\r
+\r
+  //\r
+  // Statistic data.\r
+  //\r
+  UINT64  Data[64];\r
+} PXE_DB_STATISTICS;\r
+\r
+//\r
+// Total number of frames received.  Includes frames with errors and\r
+// dropped frames.\r
+//\r
+#define PXE_STATISTICS_RX_TOTAL_FRAMES  0x00\r
+\r
+//\r
+// Number of valid frames received and copied into receive buffers.\r
+//\r
+#define PXE_STATISTICS_RX_GOOD_FRAMES 0x01\r
+\r
+//\r
+// Number of frames below the minimum length for the media.\r
+// This would be <64 for ethernet.\r
+//\r
+#define PXE_STATISTICS_RX_UNDERSIZE_FRAMES  0x02\r
+\r
+//\r
+// Number of frames longer than the maxminum length for the\r
+// media.  This would be >1500 for ethernet.\r
+//\r
+#define PXE_STATISTICS_RX_OVERSIZE_FRAMES 0x03\r
+\r
+//\r
+// Valid frames that were dropped because receive buffers were full.\r
+//\r
+#define PXE_STATISTICS_RX_DROPPED_FRAMES  0x04\r
+\r
+//\r
+// Number of valid unicast frames received and not dropped.\r
+//\r
+#define PXE_STATISTICS_RX_UNICAST_FRAMES  0x05\r
+\r
+//\r
+// Number of valid broadcast frames received and not dropped.\r
+//\r
+#define PXE_STATISTICS_RX_BROADCAST_FRAMES  0x06\r
+\r
+//\r
+// Number of valid mutlicast frames received and not dropped.\r
+//\r
+#define PXE_STATISTICS_RX_MULTICAST_FRAMES  0x07\r
+\r
+//\r
+// Number of frames w/ CRC or alignment errors.\r
+//\r
+#define PXE_STATISTICS_RX_CRC_ERROR_FRAMES  0x08\r
+\r
+//\r
+// Total number of bytes received.  Includes frames with errors\r
+// and dropped frames.\r
+//\r
+#define PXE_STATISTICS_RX_TOTAL_BYTES 0x09\r
+\r
+//\r
+// Transmit statistics.\r
+//\r
+#define PXE_STATISTICS_TX_TOTAL_FRAMES      0x0A\r
+#define PXE_STATISTICS_TX_GOOD_FRAMES       0x0B\r
+#define PXE_STATISTICS_TX_UNDERSIZE_FRAMES  0x0C\r
+#define PXE_STATISTICS_TX_OVERSIZE_FRAMES   0x0D\r
+#define PXE_STATISTICS_TX_DROPPED_FRAMES    0x0E\r
+#define PXE_STATISTICS_TX_UNICAST_FRAMES    0x0F\r
+#define PXE_STATISTICS_TX_BROADCAST_FRAMES  0x10\r
+#define PXE_STATISTICS_TX_MULTICAST_FRAMES  0x11\r
+#define PXE_STATISTICS_TX_CRC_ERROR_FRAMES  0x12\r
+#define PXE_STATISTICS_TX_TOTAL_BYTES       0x13\r
+\r
+//\r
+// Number of collisions detection on this subnet.\r
+//\r
+#define PXE_STATISTICS_COLLISIONS 0x14\r
+\r
+//\r
+// Number of frames destined for unsupported protocol.\r
+//\r
+#define PXE_STATISTICS_UNSUPPORTED_PROTOCOL 0x15\r
+\r
+typedef struct s_pxe_cpb_mcast_ip_to_mac {\r
+  //\r
+  // Multicast IP address to be converted to multicast MAC address.\r
+  //\r
+  PXE_IP_ADDR IP;\r
+} PXE_CPB_MCAST_IP_TO_MAC;\r
+\r
+typedef struct s_pxe_db_mcast_ip_to_mac {\r
+  //\r
+  // Multicast MAC address.\r
+  //\r
+  PXE_MAC_ADDR  MAC;\r
+} PXE_DB_MCAST_IP_TO_MAC;\r
+\r
+typedef struct s_pxe_cpb_nvdata_sparse {\r
+  //\r
+  // NvData item list.  Only items in this list will be updated.\r
+  //\r
+  struct {\r
+    //\r
+    //  Non-volatile storage address to be changed.\r
+    //\r
+    UINT32  Addr;\r
+\r
+    //\r
+    // Data item to write into above storage address.\r
+    //\r
+    union {\r
+      UINT8   Byte;\r
+      UINT16  Word;\r
+      UINT32  Dword;\r
+    } Data;\r
+  } Item[MAX_EEPROM_LEN];\r
+}\r
+PXE_CPB_NVDATA_SPARSE;\r
+\r
+//\r
+// When using bulk update, the size of the CPB structure must be\r
+// the same size as the non-volatile NIC storage.\r
+//\r
+typedef union u_pxe_cpb_nvdata_bulk {\r
+  //\r
+  // Array of byte-wide data items.\r
+  //\r
+  UINT8   Byte[MAX_EEPROM_LEN << 2];\r
+\r
+  //\r
+  // Array of word-wide data items.\r
+  //\r
+  UINT16  Word[MAX_EEPROM_LEN << 1];\r
+\r
+  //\r
+  // Array of dword-wide data items.\r
+  //\r
+  UINT32  Dword[MAX_EEPROM_LEN];\r
+} PXE_CPB_NVDATA_BULK;\r
+\r
+typedef struct s_pxe_db_nvdata {\r
+  //\r
+  // Arrays of data items from non-volatile storage.\r
+  //\r
+  union {\r
+    //\r
+    // Array of byte-wide data items.\r
+    //\r
+    UINT8   Byte[MAX_EEPROM_LEN << 2];\r
+\r
+    //\r
+    // Array of word-wide data items.\r
+    //\r
+    UINT16  Word[MAX_EEPROM_LEN << 1];\r
+\r
+    //\r
+    // Array of dword-wide data items.\r
+    //\r
+    UINT32  Dword[MAX_EEPROM_LEN];\r
+  } Data;\r
+} PXE_DB_NVDATA;\r
+\r
+typedef struct s_pxe_db_get_status {\r
+  //\r
+  // Length of next receive frame (header + data).  If this is zero,\r
+  // there is no next receive frame available.\r
+  //\r
+  UINT32  RxFrameLen;\r
+\r
+  //\r
+  // Reserved, set to zero.\r
+  //\r
+  UINT32  reserved;\r
+\r
+  //\r
+  //  Addresses of transmitted buffers that need to be recycled.\r
+  //\r
+  UINT64  TxBuffer[MAX_XMIT_BUFFERS];\r
+} PXE_DB_GET_STATUS;\r
+\r
+typedef struct s_pxe_cpb_fill_header {\r
+  //\r
+  // Source and destination MAC addresses.  These will be copied into\r
+  // the media header without doing byte swapping.\r
+  //\r
+  PXE_MAC_ADDR  SrcAddr;\r
+  PXE_MAC_ADDR  DestAddr;\r
+\r
+  //\r
+  // Address of first byte of media header.  The first byte of packet data\r
+  // follows the last byte of the media header.\r
+  //\r
+  UINT64        MediaHeader;\r
+\r
+  //\r
+  // Length of packet data in bytes (not including the media header).\r
+  //\r
+  UINT32        PacketLen;\r
+\r
+  //\r
+  // Protocol type.  This will be copied into the media header without\r
+  // doing byte swapping.  Protocol type numbers can be obtained from\r
+  // the Assigned Numbers RFC 1700.\r
+  //\r
+  UINT16        Protocol;\r
+\r
+  //\r
+  // Length of the media header in bytes.\r
+  //\r
+  UINT16        MediaHeaderLen;\r
+} PXE_CPB_FILL_HEADER;\r
+\r
+#define PXE_PROTOCOL_ETHERNET_IP  0x0800\r
+#define PXE_PROTOCOL_ETHERNET_ARP 0x0806\r
+#define MAX_XMIT_FRAGMENTS        16\r
+\r
+typedef struct s_pxe_cpb_fill_header_fragmented {\r
+  //\r
+  // Source and destination MAC addresses.  These will be copied into\r
+  // the media header without doing byte swapping.\r
+  //\r
+  PXE_MAC_ADDR        SrcAddr;\r
+  PXE_MAC_ADDR        DestAddr;\r
+\r
+  //\r
+  // Length of packet data in bytes (not including the media header).\r
+  //\r
+  UINT32              PacketLen;\r
+\r
+  //\r
+  // Protocol type.  This will be copied into the media header without\r
+  // doing byte swapping.  Protocol type numbers can be obtained from\r
+  // the Assigned Numbers RFC 1700.\r
+  //\r
+  PXE_MEDIA_PROTOCOL  Protocol;\r
+\r
+  //\r
+  // Length of the media header in bytes.\r
+  //\r
+  UINT16              MediaHeaderLen;\r
+\r
+  //\r
+  // Number of packet fragment descriptors.\r
+  //\r
+  UINT16              FragCnt;\r
+\r
+  //\r
+  // Reserved, must be set to zero.\r
+  //\r
+  UINT16              reserved;\r
+\r
+  //\r
+  // Array of packet fragment descriptors.  The first byte of the media\r
+  // header is the first byte of the first fragment.\r
+  //\r
+  struct {\r
+    //\r
+    // Address of this packet fragment.\r
+    //\r
+    UINT64  FragAddr;\r
+\r
+    //\r
+    // Length of this packet fragment.\r
+    //\r
+    UINT32  FragLen;\r
+\r
+    //\r
+    // Reserved, must be set to zero.\r
+    //\r
+    UINT32  reserved;\r
+  } FragDesc[MAX_XMIT_FRAGMENTS];\r
+}\r
+PXE_CPB_FILL_HEADER_FRAGMENTED;\r
+\r
+typedef struct s_pxe_cpb_transmit {\r
+  //\r
+  // Address of first byte of frame buffer.  This is also the first byte\r
+  // of the media header.\r
+  //\r
+  UINT64  FrameAddr;\r
+\r
+  //\r
+  // Length of the data portion of the frame buffer in bytes.  Do not\r
+  // include the length of the media header.\r
+  //\r
+  UINT32  DataLen;\r
+\r
+  //\r
+  // Length of the media header in bytes.\r
+  //\r
+  UINT16  MediaheaderLen;\r
+\r
+  //\r
+  // Reserved, must be zero.\r
+  //\r
+  UINT16  reserved;\r
+} PXE_CPB_TRANSMIT;\r
+\r
+typedef struct s_pxe_cpb_transmit_fragments {\r
+  //\r
+  // Length of packet data in bytes (not including the media header).\r
+  //\r
+  UINT32  FrameLen;\r
+\r
+  //\r
+  // Length of the media header in bytes.\r
+  //\r
+  UINT16  MediaheaderLen;\r
+\r
+  //\r
+  // Number of packet fragment descriptors.\r
+  //\r
+  UINT16  FragCnt;\r
+\r
+  //\r
+  // Array of frame fragment descriptors.  The first byte of the first\r
+  // fragment is also the first byte of the media header.\r
+  //\r
+  struct {\r
+    //\r
+    // Address of this frame fragment.\r
+    //\r
+    UINT64  FragAddr;\r
+\r
+    //\r
+    // Length of this frame fragment.\r
+    //\r
+    UINT32  FragLen;\r
+\r
+    //\r
+    // Reserved, must be set to zero.\r
+    //\r
+    UINT32  reserved;\r
+  } FragDesc[MAX_XMIT_FRAGMENTS];\r
+}\r
+PXE_CPB_TRANSMIT_FRAGMENTS;\r
+\r
+typedef struct s_pxe_cpb_receive {\r
+  //\r
+  // Address of first byte of receive buffer.  This is also the first byte\r
+  // of the frame header.\r
+  //\r
+  UINT64  BufferAddr;\r
+\r
+  //\r
+  // Length of receive buffer.  This must be large enough to hold the\r
+  // received frame (media header + data).  If the length of smaller than\r
+  // the received frame, data will be lost.\r
+  //\r
+  UINT32  BufferLen;\r
+\r
+  //\r
+  // Reserved, must be set to zero.\r
+  //\r
+  UINT32  reserved;\r
+} PXE_CPB_RECEIVE;\r
+\r
+typedef struct s_pxe_db_receive {\r
+  //\r
+  // Source and destination MAC addresses from media header.\r
+  //\r
+  PXE_MAC_ADDR        SrcAddr;\r
+  PXE_MAC_ADDR        DestAddr;\r
+\r
+  //\r
+  // Length of received frame.  May be larger than receive buffer size.\r
+  // The receive buffer will not be overwritten.  This is how to tell\r
+  // if data was lost because the receive buffer was too small.\r
+  //\r
+  UINT32              FrameLen;\r
+\r
+  //\r
+  // Protocol type from media header.\r
+  //\r
+  PXE_MEDIA_PROTOCOL  Protocol;\r
+\r
+  //\r
+  // Length of media header in received frame.\r
+  //\r
+  UINT16              MediaHeaderLen;\r
+\r
+  //\r
+  // Type of receive frame.\r
+  //\r
+  PXE_FRAME_TYPE      Type;\r
+\r
+  //\r
+  // Reserved, must be zero.\r
+  //\r
+  UINT8               reserved[7];\r
+\r
+} PXE_DB_RECEIVE;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h b/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h
new file mode 100644 (file)
index 0000000..633c595
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiSpec.h\r
+\r
+Abstract:\r
+\r
+  EFI master include file.\r
+\r
+  This is the main include file for EFI components. There should be\r
+  no defines or macros added to this file, other than the EFI version \r
+  information already in this file.\r
+\r
+  Don't add include files to the list for convenience, only add things\r
+  that are architectural. Don't add Protocols or GUID include files here\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SPEC_H_\r
+#define _EFI_SPEC_H_\r
+\r
+#include "EfiCommon.h"\r
+#include "EfiApi.h"\r
+#include "EfiDevicePath.h"\r
+\r
+//\r
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
+//\r
+#if !defined(EFI_SPECIFICATION_VERSION)\r
+  #error EFI_SPECIFICATION_VERSION not defined\r
+#elif !defined(TIANO_RELEASE_VERSION)\r
+  #error TIANO_RELEASE_VERSION not defined\r
+#elif (TIANO_RELEASE_VERSION == 0)\r
+//\r
+// UEFI mode with no Tiano extensions is legal\r
+//\r
+#elif ((TIANO_RELEASE_VERSION < 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000))\r
+  #error Illegal combination of EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION versions\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h b/EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h
new file mode 100644 (file)
index 0000000..d125ced
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiStdArg.h\r
+\r
+Abstract:\r
+\r
+  Support for variable length argument lists using the ANSI standard.\r
+  \r
+  Since we are using the ANSI standard we used the standard nameing and\r
+  did not folow the coding convention\r
+\r
+  VA_LIST  - typedef for argument list.\r
+  VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r
+  VA_END (VA_LIST Marker) - Clear Marker\r
+  VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r
+    the ... list. You must know the size and pass it in this macro.\r
+\r
+  example:\r
+\r
+  UINTN\r
+  ExampleVarArg (\r
+    IN UINTN  NumberOfArgs,\r
+    ...\r
+    )\r
+  {\r
+    VA_LIST Marker;\r
+    UINTN   Index;\r
+    UINTN   Result;\r
+\r
+    //\r
+    // Initialize the Marker\r
+    //\r
+    VA_START (Marker, NumberOfArgs);\r
+    for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r
+      //\r
+      // The ... list is a series of UINTN values, so average them up.\r
+      //\r
+      Result += VA_ARG (Marker, UINTN);\r
+    }\r
+\r
+    VA_END (Marker);\r
+    return Result\r
+  }\r
+\r
+--*/\r
+\r
+#ifndef _EFISTDARG_H_\r
+#define _EFISTDARG_H_\r
+\r
+#define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r
+\r
+//\r
+// Also support coding convention rules for var arg macros\r
+//\r
+#ifndef VA_START\r
+\r
+typedef CHAR8 *VA_LIST;\r
+#define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))\r
+#define VA_ARG(ap, t)   (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))\r
+#define VA_END(ap)      (ap = (VA_LIST) 0)\r
+\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h b/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h
new file mode 100644 (file)
index 0000000..67379aa
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiTpm.h\r
+\r
+Abstract:\r
+\r
+  EFI definition according to TCG_EFI_Platform_1_20_Final\r
+\r
+  See http://trustedcomputinggroup.org for latest specification updates\r
+\r
+--*/\r
+\r
+#ifndef _EFI_TPM_H_\r
+#define _EFI_TPM_H_\r
+\r
+#include <Tiano.h>\r
+\r
+//\r
+// The start of TPM return codes\r
+//\r
+#define TPM_BASE                    (EFI_MAX_BIT + (EFI_MAX_BIT >> 1))\r
+#include <IndustryStandard/Tpm12.h>\r
+\r
+//\r
+// Standard event types\r
+//\r
+#define EV_POST_CODE                ((TCG_EVENTTYPE) 0x00000001)\r
+#define EV_SEPARATOR                ((TCG_EVENTTYPE) 0x00000004)\r
+#define EV_S_CRTM_CONTENTS          ((TCG_EVENTTYPE) 0x00000007)\r
+#define EV_S_CRTM_VERSION           ((TCG_EVENTTYPE) 0x00000008)\r
+\r
+//\r
+// EFI specific event types\r
+//\r
+#define EV_EFI_EVENT_BASE                   ((TCG_EVENTTYPE) 0x80000000)\r
+#define EV_EFI_VARIABLE_DRIVER_CONFIG       (EV_EFI_EVENT_BASE + 1)\r
+#define EV_EFI_VARIABLE_BOOT                (EV_EFI_EVENT_BASE + 2)\r
+#define EV_EFI_BOOT_SERVICES_APPLICATION    (EV_EFI_EVENT_BASE + 3)\r
+#define EV_EFI_BOOT_SERVICES_DRIVER         (EV_EFI_EVENT_BASE + 4)\r
+#define EV_EFI_RUNTIME_SERVICES_DRIVER      (EV_EFI_EVENT_BASE + 5)\r
+#define EV_EFI_GPT_EVENT                    (EV_EFI_EVENT_BASE + 6)\r
+#define EV_EFI_ACTION                       (EV_EFI_EVENT_BASE + 7)\r
+#define EV_EFI_PLATFORM_FIRMWARE_BLOB       (EV_EFI_EVENT_BASE + 8)\r
+#define EV_EFI_HANDOFF_TABLES               (EV_EFI_EVENT_BASE + 9)\r
+\r
+//\r
+// Set structure alignment to 1-byte\r
+//\r
+#pragma pack (push, 1)\r
+\r
+typedef UINT32                     TCG_EVENTTYPE;\r
+\r
+#define TCG_DIGEST                 TPM_DIGEST\r
+#define TCG_PCRINDEX               TPM_PCRINDEX\r
+\r
+//\r
+// TCG_PCR_EVENT\r
+//\r
+typedef struct tdTCG_PCR_EVENT {\r
+  TCG_PCRINDEX                      PCRIndex;  // PCRIndex event extended to\r
+  TCG_EVENTTYPE                     EventType; // TCG EFI event type\r
+  TCG_DIGEST                        Digest;    // Value extended into PCRIndex\r
+  UINT32                            EventSize; // Size of the event data\r
+  UINT8                             Event[1];  // The event data\r
+} TCG_PCR_EVENT;\r
+\r
+//\r
+// TCG_PCR_EVENT_HDR\r
+//\r
+typedef struct tdTCG_PCR_EVENT_HDR {\r
+  TCG_PCRINDEX                      PCRIndex;\r
+  TCG_EVENTTYPE                     EventType;\r
+  TCG_DIGEST                        Digest;\r
+  UINT32                            EventSize;\r
+} TCG_PCR_EVENT_HDR;\r
+\r
+//\r
+// EFI_PLATFORM_FIRMWARE_BLOB\r
+//\r
+// BlobLength should be of type UINTN but we use UINT64 here\r
+// because PEI is 32-bit while DXE is 64-bit on x64 platforms\r
+//\r
+typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {\r
+  EFI_PHYSICAL_ADDRESS              BlobBase;\r
+  UINT64                            BlobLength;\r
+} EFI_PLATFORM_FIRMWARE_BLOB;\r
+\r
+//\r
+// EFI_IMAGE_LOAD_EVENT\r
+//\r
+// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,\r
+// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER\r
+//\r
+typedef struct tdEFI_IMAGE_LOAD_EVENT {\r
+  EFI_PHYSICAL_ADDRESS              ImageLocationInMemory;\r
+  UINTN                             ImageLengthInMemory;\r
+  UINTN                             ImageLinkTimeAddress;\r
+  UINTN                             LengthOfDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL          DevicePath[1];\r
+} EFI_IMAGE_LOAD_EVENT;\r
+\r
+//\r
+// EFI_HANDOFF_TABLE_POINTERS\r
+//\r
+// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate\r
+// the measurement of given configuration tables.\r
+//\r
+typedef struct tdEFI_HANDOFF_TABLE_POINTERS {\r
+  UINTN                            NumberOfTables;\r
+  EFI_CONFIGURATION_TABLE           TableEntry[1];\r
+} EFI_HANDOFF_TABLE_POINTERS;\r
+\r
+//\r
+// EFI_VARIABLE_DATA\r
+//\r
+// This structure serves as the header for measuring variables. The name of the\r
+// variable (in Unicode format) should immediately follow, then the variable\r
+// data.\r
+//\r
+typedef struct tdEFI_VARIABLE_DATA {\r
+  EFI_GUID                          VariableName;\r
+  UINTN                             UnicodeNameLength;\r
+  UINTN                             VariableDataLength;\r
+  CHAR16                            UnicodeName[1];\r
+  INT8                              VariableData[1];  // Driver or platform-specific data\r
+} EFI_VARIABLE_DATA;\r
+\r
+//\r
+// Restore original structure alignment\r
+//\r
+#pragma pack (pop)\r
+\r
+#endif  // _EFI_TPM_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiVariable.h b/EdkCompatibilityPkg/Foundation/Include/EfiVariable.h
new file mode 100644 (file)
index 0000000..b2a96f4
--- /dev/null
@@ -0,0 +1,85 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiVariable.h\r
+  \r
+Abstract:\r
+  \r
+  Header file for EFI Variable Services\r
+\r
+--*/\r
+\r
+#ifndef _EFI_VARIABLE_H_\r
+#define _EFI_VARIABLE_H_\r
+\r
+#define VARIABLE_STORE_SIGNATURE  EFI_SIGNATURE_32 ('$', 'V', 'S', 'S')\r
+\r
+#define MAX_VARIABLE_SIZE         1024\r
+\r
+//\r
+// Enlarges the hardware error record maximum variable size to 32K bytes\r
+//\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+#define MAX_HARDWARE_ERROR_VARIABLE_SIZE 0x8000\r
+#endif\r
+\r
+#define VARIABLE_DATA             0x55AA\r
+\r
+//\r
+// Variable Store Header flags\r
+//\r
+#define VARIABLE_STORE_FORMATTED  0x5a\r
+#define VARIABLE_STORE_HEALTHY    0xfe\r
+\r
+//\r
+// Variable Store Status\r
+//\r
+typedef enum {\r
+  EfiRaw,\r
+  EfiValid,\r
+  EfiInvalid,\r
+  EfiUnknown\r
+} VARIABLE_STORE_STATUS;\r
+\r
+//\r
+// Variable State flags\r
+//\r
+#define VAR_IN_DELETED_TRANSITION     0xfe  // Variable is in obsolete transistion\r
+#define VAR_DELETED                   0xfd  // Variable is obsolete\r
+#define VAR_ADDED                     0x7f  // Variable has been completely added\r
+#define IS_VARIABLE_STATE(_c, _Mask)  (BOOLEAN) (((~_c) & (~_Mask)) != 0)\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Size;\r
+  UINT8   Format;\r
+  UINT8   State;\r
+  UINT16  Reserved;\r
+  UINT32  Reserved1;\r
+} VARIABLE_STORE_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    StartId;\r
+  UINT8     State;\r
+  UINT8     Reserved;\r
+  UINT32    Attributes;\r
+  UINT32    NameSize;\r
+  UINT32    DataSize;\r
+  EFI_GUID  VendorGuid;\r
+} VARIABLE_HEADER;\r
+\r
+#pragma pack()\r
+\r
+#endif // _EFI_VARIABLE_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h b/EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h
new file mode 100644 (file)
index 0000000..a67d041
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiWorkingBlockHeader.h\r
+\r
+Abstract:\r
+\r
+  Defines data structure that is the headers found at the runtime \r
+  updatable firmware volumes, such as the FileSystemGuid of the \r
+  working block, the header structure of the variable block, FTW\r
+  working block, or event log block.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_WORKING_BLOCK_HEADER_H_\r
+#define _EFI_WORKING_BLOCK_HEADER_H_\r
+\r
+//\r
+// EFI Fault tolerant working block header\r
+// The header is immediately followed by the write queue.\r
+//\r
+typedef struct {\r
+  EFI_GUID  Signature;\r
+  UINT32    Crc;\r
+  UINT8     WorkingBlockValid : 1;\r
+  UINT8     WorkingBlockInvalid : 1;\r
+#define WORKING_BLOCK_VALID   0x1\r
+#define WORKING_BLOCK_INVALID 0x2\r
+  UINT8     Reserved : 6;\r
+  UINT8     Reserved3[3];\r
+  UINT64    WriteQueueSize;\r
+  //\r
+  // UINT8                WriteQueue[WriteQueueSize];\r
+  //\r
+} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h
new file mode 100644 (file)
index 0000000..ae60a28
--- /dev/null
@@ -0,0 +1,269 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiBind.h\r
+\r
+Abstract:\r
+\r
+  Processor or Compiler specific defines and types for IA-32.\r
+  We are using the ANSI C 2000 _t type definitions for basic types.\r
+  This it technically a violation of the coding standard, but they\r
+  are used to make EfiTypes.h portable. Code other than EfiTypes.h\r
+  should never use any ANSI C 2000 _t integer types.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BIND_H_\r
+#define _EFI_BIND_H_\r
+\r
+#ifdef EFI_DEBUG\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)                  \\r
+          EFI_STATUS                                          \\r
+          EFIAPI                                              \\r
+          InitFunction (                                      \\r
+            EFI_HANDLE        ImageHandle,                    \\r
+            EFI_SYSTEM_TABLE  *SystemTable                    \\r
+            );                                                \\r
+                                                              \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          EFI_STATUS                                                 \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+              VOID *ImageHandle,                              \\r
+              VOID *SystemTable                               \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(ImageHandle, SystemTable);  \\r
+          }\r
+\r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+#else\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)                  \r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+#endif\r
+\r
+#else\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)                  \r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+#endif\r
+\r
+\r
+\r
+\r
+\r
+//\r
+// Make sure we are useing the correct packing rules per EFI specification\r
+//\r
+#pragma pack()\r
+\r
+#if _MSC_EXTENSIONS\r
+\r
+//\r
+// Disable warning that make it impossible to compile at /W4\r
+// This only works for Microsoft* tools\r
+//\r
+\r
+//\r
+// Disabling bitfield type checking warnings.\r
+//\r
+#pragma warning ( disable : 4214 )\r
+\r
+//\r
+// Disabling the unreferenced formal parameter warnings.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// Disable slightly different base types warning as CHAR8 * can not be set\r
+// to a constant string.\r
+//\r
+#pragma warning ( disable : 4057 )\r
+\r
+//\r
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
+//\r
+#pragma warning ( disable : 4127 )\r
+\r
+//\r
+// Int64ShllMod32 unreferenced inline function\r
+//\r
+#pragma warning ( disable : 4514 )\r
+\r
+//\r
+// Unreferenced formal parameter - We are object oriented, so we pass This even\r
+//  if we  don't need them.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// This warning is caused by empty (after preprocessing) souce file.\r
+//\r
+#pragma warning ( disable : 4206 )\r
+\r
+\r
+#endif\r
+\r
+\r
+#if (__STDC_VERSION__ < 199901L)\r
+  //\r
+  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
+  //\r
\r
+  #if _MSC_EXTENSIONS \r
+    \r
+    //\r
+    // use Microsoft* C complier dependent interger width types \r
+    //\r
+    typedef unsigned __int64    uint64_t;\r
+    typedef __int64             int64_t;\r
+    typedef unsigned __int32    uint32_t;\r
+    typedef __int32             int32_t;\r
+    typedef unsigned short      uint16_t;\r
+    typedef short               int16_t;\r
+    typedef unsigned char       uint8_t;\r
+    typedef char                int8_t;\r
+  #else\r
+\r
+    //\r
+    // Assume standard IA-32 alignment. \r
+    // BugBug: Need to check portability of long long\r
+    //\r
+    typedef unsigned long long  uint64_t;\r
+    typedef long long           int64_t;\r
+    typedef unsigned int        uint32_t;\r
+    typedef int                 int32_t;\r
+    typedef unsigned short      uint16_t;\r
+    typedef short               int16_t;\r
+    typedef unsigned char       uint8_t;\r
+    typedef char                int8_t;\r
+  #endif\r
+#else\r
+  //\r
+  // Use ANSI C 2000 stdint.h integer width declarations\r
+  //\r
+  #include "stdint.h"\r
+#endif\r
+\r
+//\r
+// Native integer size in stdint.h\r
+//\r
+typedef uint32_t  uintn_t;\r
+typedef int32_t   intn_t;\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+#define EFI_MAX_BIT       0x80000000\r
+#define MAX_2_BITS        0xC0000000\r
+\r
+//\r
+// Maximum legal IA-32 address\r
+//\r
+#define EFI_MAX_ADDRESS   0xFFFFFFFF\r
+\r
+//\r
+//  Bad pointer value to use in check builds.\r
+//  if you see this value you are using uninitialized or free'ed data\r
+//\r
+#define EFI_BAD_POINTER          0xAFAFAFAF\r
+#define EFI_BAD_POINTER_AS_BYTE  0xAF\r
+\r
+//\r
+// Inject a break point in the code to assist debugging for NT Emulation Environment\r
+// For real hardware, just put in a halt loop. Don't do a while(1) because the\r
+// compiler will optimize away the rest of the function following, so that you run out in\r
+// the weeds if you skip over it with a debugger.\r
+//\r
+#define EFI_BREAKPOINT()  __asm { int 3 }\r
+#define EFI_DEADLOOP()    { volatile UINTN __iii; __iii = 1; while (__iii); }\r
+\r
+//\r
+// Memory Fence forces serialization, and is needed to support out of order\r
+//  memory transactions. The Memory Fence is mainly used to make sure IO\r
+//  transactions complete in a deterministic sequence, and to syncronize locks\r
+//  an other MP code. Currently no memory fencing is required.\r
+//\r
+#define MEMORY_FENCE()\r
+\r
+//\r
+// Some compilers don't support the forward reference construct:\r
+//  typedef struct XXXXX. The forward reference is required for \r
+//  ANSI compatibility.\r
+//\r
+// The following macro provide a workaround for such cases.\r
+//\r
+\r
+\r
+#ifdef EFI_NO_INTERFACE_DECL\r
+  #define EFI_FORWARD_DECLARATION(x)\r
+#else\r
+  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x\r
+#endif\r
+\r
+\r
+//\r
+// Some C compilers optimize the calling conventions to increase performance.\r
+// _EFIAPI is used to make all public APIs follow the standard C calling \r
+// convention.\r
+//\r
+#if _MSC_EXTENSIONS\r
+  //\r
+  // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.\r
+  // \r
+\r
+  #define _EFIAPI __cdecl  \r
+#else\r
+  #define _EFIAPI       \r
+#endif\r
+\r
+\r
+#ifdef _EFI_WINNT\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4142 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4142 )\r
+#else\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4068 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4068 )\r
+\r
+#endif\r
+\r
+\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h
new file mode 100644 (file)
index 0000000..549d9f4
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiPeOptionalHeader.h\r
+\r
+Abstract:\r
+  Defines the optional header in the PE image per the PE specification.  This\r
+  file must be included only from within EfiImage.h since \r
+  EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined\r
+  there.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_\r
+#define _EFI_PE_OPTIONAL_HEADER_H_\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA32)\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64) \r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS32      EFI_IMAGE_NT_HEADERS;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h
new file mode 100644 (file)
index 0000000..edf599a
--- /dev/null
@@ -0,0 +1,102 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoBind.h\r
+\r
+Abstract:\r
+\r
+  Tiano's Processor or Compiler specific defines and types for IA-32 \r
+  besides EfiBind.h.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_BIND_H_\r
+#define _TIANO_BIND_H_\r
+\r
+#include "EfiBind.h"\r
+\r
+#ifdef EFI_DEBUG\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)                     \\r
+                                       VOID                                                \\r
+                                       EFIAPI                                              \\r
+                                       InitFunction (                                      \\r
+                                       IN  VOID *HobStart                                                                                                                              \\r
+                               );                                                                                                                                                                                                      \\r
+                                                                                                                                                                                                                                                       \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          VOID                                                \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+              VOID *Hob                                       \\r
+              )                                               \\r
+          {                                                   \\r
+              InitFunction(Hob);                              \\r
+          }\r
+\r
+\r
+\r
+\r
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction)             \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          EFI_STATUS                                                 \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+              VOID  *ImageHandle,                             \\r
+              VOID  *Smst,                                    \\r
+              VOID  *CommunicationBuffer,                     \\r
+              UINTN *SourceSize                               \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(ImageHandle, Smst, CommunicationBuffer, SourceSize);  \\r
+          }\r
+\r
+#else\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)\r
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
+\r
+#else\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)\r
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h
new file mode 100644 (file)
index 0000000..6a7246f
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Acpi.h\r
+\r
+Abstract:\r
+\r
+  This file contains some basic ACPI definitions that are consumed by drivers\r
+  that do not care about ACPI versions.\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_H_\r
+#define _ACPI_H_\r
+\r
+#include "AcpiCommon.h"\r
+#include "Acpi1_0.h"\r
+#include "Acpi2_0.h"\r
+#include "Acpi3_0.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h
new file mode 100644 (file)
index 0000000..84c4147
--- /dev/null
@@ -0,0 +1,299 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Acpi1_0.h\r
+\r
+Abstract:\r
+\r
+  ACPI 1.0b definitions from the ACPI Specification, revision 1.0b\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_1_0_H_\r
+#define _ACPI_1_0_H_\r
+\r
+//\r
+// Statements that include other files\r
+//\r
+#include "AcpiCommon.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// ACPI 1.0b table structures\r
+//\r
+//\r
+// Root System Description Pointer Structure\r
+//\r
+typedef struct {\r
+  UINT64  Signature;\r
+  UINT8   Checksum;\r
+  UINT8   OemId[6];\r
+  UINT8   Reserved;\r
+  UINT32  RsdtAddress;\r
+} EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER;\r
+\r
+//\r
+// Root System Description Table\r
+// No definition needed as it is a common description table header followed by a\r
+// variable number of UINT32 table pointers.\r
+//\r
+//\r
+// RSDT Revision (as defined in ACPI 1.0b spec.)\r
+//\r
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Fixed ACPI Description Table Structure (FADT)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      FirmwareCtrl;\r
+  UINT32                      Dsdt;\r
+  UINT8                       IntModel;\r
+  UINT8                       Reserved1;\r
+  UINT16                      SciInt;\r
+  UINT32                      SmiCmd;\r
+  UINT8                       AcpiEnable;\r
+  UINT8                       AcpiDisable;\r
+  UINT8                       S4BiosReq;\r
+  UINT8                       Reserved2;\r
+  UINT32                      Pm1aEvtBlk;\r
+  UINT32                      Pm1bEvtBlk;\r
+  UINT32                      Pm1aCntBlk;\r
+  UINT32                      Pm1bCntBlk;\r
+  UINT32                      Pm2CntBlk;\r
+  UINT32                      PmTmrBlk;\r
+  UINT32                      Gpe0Blk;\r
+  UINT32                      Gpe1Blk;\r
+  UINT8                       Pm1EvtLen;\r
+  UINT8                       Pm1CntLen;\r
+  UINT8                       Pm2CntLen;\r
+  UINT8                       PmTmLen;\r
+  UINT8                       Gpe0BlkLen;\r
+  UINT8                       Gpe1BlkLen;\r
+  UINT8                       Gpe1Base;\r
+  UINT8                       Reserved3;\r
+  UINT16                      PLvl2Lat;\r
+  UINT16                      PLvl3Lat;\r
+  UINT16                      FlushSize;\r
+  UINT16                      FlushStride;\r
+  UINT8                       DutyOffset;\r
+  UINT8                       DutyWidth;\r
+  UINT8                       DayAlrm;\r
+  UINT8                       MonAlrm;\r
+  UINT8                       Century;\r
+  UINT8                       Reserved4;\r
+  UINT8                       Reserved5;\r
+  UINT8                       Reserved6;\r
+  UINT32                      Flags;\r
+} EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE;\r
+\r
+//\r
+// FADT Version (as defined in ACPI 1.0b spec.)\r
+//\r
+#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION  0x01\r
+\r
+//\r
+// Fixed ACPI Description Table Fixed Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_1_0_WBINVD       (1 << 0)\r
+#define EFI_ACPI_1_0_WBINVD_FLUSH (1 << 1)\r
+#define EFI_ACPI_1_0_PROC_C1      (1 << 2)\r
+#define EFI_ACPI_1_0_P_LVL2_UP    (1 << 3)\r
+#define EFI_ACPI_1_0_PWR_BUTTON   (1 << 4)\r
+#define EFI_ACPI_1_0_SLP_BUTTON   (1 << 5)\r
+#define EFI_ACPI_1_0_FIX_RTC      (1 << 6)\r
+#define EFI_ACPI_1_0_RTC_S4       (1 << 7)\r
+#define EFI_ACPI_1_0_TMR_VAL_EXT  (1 << 8)\r
+#define EFI_ACPI_1_0_DCK_CAP      (1 << 9)\r
+\r
+//\r
+// Firmware ACPI Control Structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+  UINT32  HardwareSignature;\r
+  UINT32  FirmwareWakingVector;\r
+  UINT32  GlobalLock;\r
+  UINT32  Flags;\r
+  UINT8   Reserved[40];\r
+} EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;\r
+\r
+//\r
+// Firmware Control Structure Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_1_0_S4BIOS_F (1 << 0)\r
+\r
+//\r
+// Multiple APIC Description Table header definition.  The rest of the table\r
+// must be defined in a platform specific manner.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      LocalApicAddress;\r
+  UINT32                      Flags;\r
+} EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;\r
+\r
+//\r
+// MADT Revision (as defined in ACPI 1.0b spec.)\r
+//\r
+#define EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Multiple APIC Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_1_0_PCAT_COMPAT  (1 << 0)\r
+\r
+//\r
+// Multiple APIC Description Table APIC structure types\r
+// All other values between 0x09 an 0xFF are reserved and\r
+// will be ignored by OSPM.\r
+//\r
+#define EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC           0x00\r
+#define EFI_ACPI_1_0_IO_APIC                        0x01\r
+#define EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE      0x02\r
+#define EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE  0x03\r
+#define EFI_ACPI_1_0_LOCAL_APIC_NMI                 0x04\r
+\r
+//\r
+// APIC Structure Definitions\r
+//\r
+//\r
+// Processor Local APIC Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT8   ApicId;\r
+  UINT32  Flags;\r
+} EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE;\r
+\r
+//\r
+// Local APIC Flags.  All other bits are reserved and must be 0.\r
+//\r
+#define EFI_ACPI_1_0_LOCAL_APIC_ENABLED (1 << 0)\r
+\r
+//\r
+// IO APIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   IoApicId;\r
+  UINT8   Reserved;\r
+  UINT32  IoApicAddress;\r
+  UINT32  SystemVectorBase;\r
+} EFI_ACPI_1_0_IO_APIC_STRUCTURE;\r
+\r
+//\r
+// Interrupt Source Override Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   Bus;\r
+  UINT8   Source;\r
+  UINT32  GlobalSystemInterruptVector;\r
+  UINT16  Flags;\r
+} EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;\r
+\r
+//\r
+// Non-Maskable Interrupt Source Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT32  GlobalSystemInterruptVector;\r
+} EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;\r
+\r
+//\r
+// Local APIC NMI Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT16  Flags;\r
+  UINT8   LocalApicInti;\r
+} EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE;\r
+\r
+//\r
+// Smart Battery Description Table (SBST)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      WarningEnergyLevel;\r
+  UINT32                      LowEnergyLevel;\r
+  UINT32                      CriticalEnergyLevel;\r
+} EFI_ACPI_1_0_SMART_BATTERY_DESCRIPTION_TABLE;\r
+\r
+//\r
+// Known table signatures\r
+//\r
+//\r
+// "RSD PTR " Root System Description Pointer\r
+//\r
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE  0x2052545020445352\r
+\r
+//\r
+// "APIC" Multiple APIC Description Table\r
+//\r
+#define EFI_ACPI_1_0_APIC_SIGNATURE 0x43495041\r
+\r
+//\r
+// "DSDT" Differentiated System Description Table\r
+//\r
+#define EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445344\r
+\r
+//\r
+// "FACS" Firmware ACPI Control Structure\r
+//\r
+#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE  0x53434146\r
+\r
+//\r
+// "FACP" Fixed ACPI Description Table\r
+//\r
+#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146\r
+\r
+//\r
+// "PSDT" Persistent System Description Table\r
+//\r
+#define EFI_ACPI_1_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445350\r
+\r
+//\r
+// "RSDT" Root System Description Table\r
+//\r
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445352\r
+\r
+//\r
+// "SBST" Smart Battery Specification Table\r
+//\r
+#define EFI_ACPI_1_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE  0x54534253\r
+\r
+//\r
+// "SSDT" Secondary System Description Table\r
+//\r
+#define EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h
new file mode 100644 (file)
index 0000000..60c2e40
--- /dev/null
@@ -0,0 +1,513 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Acpi2_0.h\r
+\r
+Abstract:\r
+\r
+  ACPI 2.0 definitions from the ACPI Specification, revision 2.0\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_2_0_H_\r
+#define _ACPI_2_0_H_\r
+\r
+//\r
+// Statements that include other files\r
+//\r
+#include "AcpiCommon.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// ACPI Specification Revision\r
+//\r
+#define EFI_ACPI_2_0_REVISION 0x02\r
+\r
+//\r
+// ACPI 2.0 Generic Address Space definition\r
+//\r
+typedef struct {\r
+  UINT8   AddressSpaceId;\r
+  UINT8   RegisterBitWidth;\r
+  UINT8   RegisterBitOffset;\r
+  UINT8   Reserved;\r
+  UINT64  Address;\r
+} EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE;\r
+\r
+//\r
+// Generic Address Space Address IDs\r
+//\r
+#define EFI_ACPI_2_0_SYSTEM_MEMORY              0\r
+#define EFI_ACPI_2_0_SYSTEM_IO                  1\r
+#define EFI_ACPI_2_0_PCI_CONFIGURATION_SPACE    2\r
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER        3\r
+#define EFI_ACPI_2_0_SMBUS                      4\r
+#define EFI_ACPI_2_0_FUNCTIONAL_FIXED_HARDWARE  0x7F\r
+\r
+//\r
+// ACPI 2.0 table structures\r
+//\r
+//\r
+// Root System Description Pointer Structure\r
+//\r
+typedef struct {\r
+  UINT64  Signature;\r
+  UINT8   Checksum;\r
+  UINT8   OemId[6];\r
+  UINT8   Revision;\r
+  UINT32  RsdtAddress;\r
+  UINT32  Length;\r
+  UINT64  XsdtAddress;\r
+  UINT8   ExtendedChecksum;\r
+  UINT8   Reserved[3];\r
+} EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER;\r
+\r
+//\r
+// RSD_PTR Revision (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02\r
+\r
+//\r
+// Common table header, this prefaces all ACPI tables, including FACS, but\r
+// excluding the RSD PTR structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+} EFI_ACPI_2_0_COMMON_HEADER;\r
+\r
+//\r
+// Root System Description Table\r
+// No definition needed as it is a common description table header followed by a\r
+// variable number of UINT32 table pointers.\r
+//\r
+//\r
+// RSDT Revision (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Extended System Description Table\r
+// No definition needed as it is a common description table header followed by a\r
+// variable number of UINT64 table pointers.\r
+//\r
+//\r
+// XSDT Revision (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Fixed ACPI Description Table Structure (FADT)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  UINT32                                  FirmwareCtrl;\r
+  UINT32                                  Dsdt;\r
+  UINT8                                   Reserved0;\r
+  UINT8                                   PreferredPmProfile;\r
+  UINT16                                  SciInt;\r
+  UINT32                                  SmiCmd;\r
+  UINT8                                   AcpiEnable;\r
+  UINT8                                   AcpiDisable;\r
+  UINT8                                   S4BiosReq;\r
+  UINT8                                   PstateCnt;\r
+  UINT32                                  Pm1aEvtBlk;\r
+  UINT32                                  Pm1bEvtBlk;\r
+  UINT32                                  Pm1aCntBlk;\r
+  UINT32                                  Pm1bCntBlk;\r
+  UINT32                                  Pm2CntBlk;\r
+  UINT32                                  PmTmrBlk;\r
+  UINT32                                  Gpe0Blk;\r
+  UINT32                                  Gpe1Blk;\r
+  UINT8                                   Pm1EvtLen;\r
+  UINT8                                   Pm1CntLen;\r
+  UINT8                                   Pm2CntLen;\r
+  UINT8                                   PmTmrLen;\r
+  UINT8                                   Gpe0BlkLen;\r
+  UINT8                                   Gpe1BlkLen;\r
+  UINT8                                   Gpe1Base;\r
+  UINT8                                   CstCnt;\r
+  UINT16                                  PLvl2Lat;\r
+  UINT16                                  PLvl3Lat;\r
+  UINT16                                  FlushSize;\r
+  UINT16                                  FlushStride;\r
+  UINT8                                   DutyOffset;\r
+  UINT8                                   DutyWidth;\r
+  UINT8                                   DayAlrm;\r
+  UINT8                                   MonAlrm;\r
+  UINT8                                   Century;\r
+  UINT16                                  IaPcBootArch;\r
+  UINT8                                   Reserved1;\r
+  UINT32                                  Flags;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  ResetReg;\r
+  UINT8                                   ResetValue;\r
+  UINT8                                   Reserved2[3];\r
+  UINT64                                  XFirmwareCtrl;\r
+  UINT64                                  XDsdt;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk;\r
+} EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE;\r
+\r
+//\r
+// FADT Version (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION  0x03\r
+\r
+//\r
+// Fixed ACPI Description Table Boot Architecture Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_2_0_LEGACY_DEVICES (1 << 0)\r
+#define EFI_ACPI_2_0_8042           (1 << 1)\r
+\r
+//\r
+// Fixed ACPI Description Table Fixed Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_2_0_WBINVD         (1 << 0)\r
+#define EFI_ACPI_2_0_WBINVD_FLUSH   (1 << 1)\r
+#define EFI_ACPI_2_0_PROC_C1        (1 << 2)\r
+#define EFI_ACPI_2_0_P_LVL2_UP      (1 << 3)\r
+#define EFI_ACPI_2_0_PWR_BUTTON     (1 << 4)\r
+#define EFI_ACPI_2_0_SLP_BUTTON     (1 << 5)\r
+#define EFI_ACPI_2_0_FIX_RTC        (1 << 6)\r
+#define EFI_ACPI_2_0_RTC_S4         (1 << 7)\r
+#define EFI_ACPI_2_0_TMR_VAL_EXT    (1 << 8)\r
+#define EFI_ACPI_2_0_DCK_CAP        (1 << 9)\r
+#define EFI_ACPI_2_0_RESET_REG_SUP  (1 << 10)\r
+#define EFI_ACPI_2_0_SEALED_CASE    (1 << 11)\r
+#define EFI_ACPI_2_0_HEADLESS       (1 << 12)\r
+#define EFI_ACPI_2_0_CPU_SW_SLP     (1 << 13)\r
+\r
+//\r
+// Firmware ACPI Control Structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+  UINT32  HardwareSignature;\r
+  UINT32  FirmwareWakingVector;\r
+  UINT32  GlobalLock;\r
+  UINT32  Flags;\r
+  UINT64  XFirmwareWakingVector;\r
+  UINT8   Version;\r
+  UINT8   Reserved[31];\r
+} EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;\r
+\r
+//\r
+// FACS Version (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION  0x01\r
+\r
+//\r
+// Firmware Control Structure Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_2_0_S4BIOS_F (1 << 0)\r
+\r
+//\r
+// Multiple APIC Description Table header definition.  The rest of the table\r
+// must be defined in a platform specific manner.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      LocalApicAddress;\r
+  UINT32                      Flags;\r
+} EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;\r
+\r
+//\r
+// MADT Revision (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Multiple APIC Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_2_0_PCAT_COMPAT  (1 << 0)\r
+\r
+//\r
+// Multiple APIC Description Table APIC structure types\r
+// All other values between 0x09 an 0xFF are reserved and\r
+// will be ignored by OSPM.\r
+//\r
+#define EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC           0x00\r
+#define EFI_ACPI_2_0_IO_APIC                        0x01\r
+#define EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE      0x02\r
+#define EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE  0x03\r
+#define EFI_ACPI_2_0_LOCAL_APIC_NMI                 0x04\r
+#define EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE    0x05\r
+#define EFI_ACPI_2_0_IO_SAPIC                       0x06\r
+#define EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC          0x07\r
+#define EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES     0x08\r
+\r
+//\r
+// APIC Structure Definitions\r
+//\r
+//\r
+// Processor Local APIC Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT8   ApicId;\r
+  UINT32  Flags;\r
+} EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE;\r
+\r
+//\r
+// Local APIC Flags.  All other bits are reserved and must be 0.\r
+//\r
+#define EFI_ACPI_2_0_LOCAL_APIC_ENABLED (1 << 0)\r
+\r
+//\r
+// IO APIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   IoApicId;\r
+  UINT8   Reserved;\r
+  UINT32  IoApicAddress;\r
+  UINT32  GlobalSystemInterruptBase;\r
+} EFI_ACPI_2_0_IO_APIC_STRUCTURE;\r
+\r
+//\r
+// Interrupt Source Override Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   Bus;\r
+  UINT8   Source;\r
+  UINT32  GlobalSystemInterrupt;\r
+  UINT16  Flags;\r
+} EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;\r
+\r
+//\r
+// Non-Maskable Interrupt Source Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT32  GlobalSystemInterrupt;\r
+} EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;\r
+\r
+//\r
+// Local APIC NMI Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT16  Flags;\r
+  UINT8   LocalApicLint;\r
+} EFI_ACPI_2_0_LOCAL_APIC_NMI_STRUCTURE;\r
+\r
+//\r
+// Local APIC Address Override Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Reserved;\r
+  UINT64  LocalApicAddress;\r
+} EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE;\r
+\r
+//\r
+// IO SAPIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   IoApicId;\r
+  UINT8   Reserved;\r
+  UINT32  GlobalSystemInterruptBase;\r
+  UINT64  IoSapicAddress;\r
+} EFI_ACPI_2_0_IO_SAPIC_STRUCTURE;\r
+\r
+//\r
+// Local SAPIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT8   LocalSapicId;\r
+  UINT8   LocalSapicEid;\r
+  UINT8   Reserved[3];\r
+  UINT32  Flags;\r
+} EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE;\r
+\r
+//\r
+// Platform Interrupt Sources Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT8   InterruptType;\r
+  UINT8   ProcessorId;\r
+  UINT8   ProcessorEid;\r
+  UINT8   IoSapicVector;\r
+  UINT32  GlobalSystemInterrupt;\r
+  UINT32  Reserved;\r
+} EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE;\r
+\r
+//\r
+// Smart Battery Description Table (SBST)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      WarningEnergyLevel;\r
+  UINT32                      LowEnergyLevel;\r
+  UINT32                      CriticalEnergyLevel;\r
+} EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE;\r
+\r
+//\r
+// SBST Version (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Embedded Controller Boot Resources Table (ECDT)\r
+// The table is followed by a null terminated ASCII string that contains\r
+// a fully qualified reference to the name space object.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  EcControl;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  EcData;\r
+  UINT32                                  Uid;\r
+  UINT8                                   GpeBit;\r
+} EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE;\r
+\r
+//\r
+// ECDT Version (as defined in ACPI 2.0 spec.)\r
+//\r
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION  0x01\r
+\r
+//\r
+// Known table signatures\r
+//\r
+//\r
+// "RSD PTR " Root System Description Pointer\r
+//\r
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE  0x2052545020445352\r
+\r
+//\r
+// "SPIC" Multiple SAPIC Description Table\r
+//\r
+// BUGBUG: Don't know where this came from except SR870BN4 uses it.\r
+// #define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495053\r
+//\r
+#define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041\r
+\r
+//\r
+// "BOOT" MS Simple Boot Spec\r
+//\r
+#define EFI_ACPI_2_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42\r
+\r
+//\r
+// "DBGP" MS Bebug Port Spec\r
+//\r
+#define EFI_ACPI_2_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244\r
+\r
+//\r
+// "DSDT" Differentiated System Description Table\r
+//\r
+#define EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445344\r
+\r
+//\r
+// "ECDT" Embedded Controller Boot Resources Table\r
+//\r
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345\r
+\r
+//\r
+// "ETDT" Event Timer Description Table\r
+//\r
+#define EFI_ACPI_2_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE  0x54445445\r
+\r
+//\r
+// "FACS" Firmware ACPI Control Structure\r
+//\r
+#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE  0x53434146\r
+\r
+//\r
+// "FACP" Fixed ACPI Description Table\r
+//\r
+#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146\r
+\r
+//\r
+// "APIC" Multiple APIC Description Table\r
+//\r
+#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE  0x43495041\r
+\r
+//\r
+// "PSDT" Persistent System Description Table\r
+//\r
+#define EFI_ACPI_2_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445350\r
+\r
+//\r
+// "RSDT" Root System Description Table\r
+//\r
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445352\r
+\r
+//\r
+// "SBST" Smart Battery Specification Table\r
+//\r
+#define EFI_ACPI_2_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE  0x54534253\r
+\r
+//\r
+// "SLIT" System Locality Information Table\r
+//\r
+#define EFI_ACPI_2_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE  0x54494C53\r
+\r
+//\r
+// "SPCR" Serial Port Concole Redirection Table\r
+//\r
+#define EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  0x52435053\r
+\r
+//\r
+// "SRAT" Static Resource Affinity Table\r
+//\r
+#define EFI_ACPI_2_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253\r
+\r
+//\r
+// "SSDT" Secondary System Description Table\r
+//\r
+#define EFI_ACPI_2_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353\r
+\r
+//\r
+// "SPMI" Server Platform Management Interface Table\r
+//\r
+#define EFI_ACPI_2_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_SIGNATURE 0x494D5053\r
+\r
+//\r
+// "XSDT" Extended System Description Table\r
+//\r
+#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445358\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h
new file mode 100644 (file)
index 0000000..be4483a
--- /dev/null
@@ -0,0 +1,681 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Acpi3_0.h\r
+\r
+Abstract:\r
+\r
+  ACPI 3.0 definitions from the ACPI Specification Revision 3.0\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_3_0_H_\r
+#define _ACPI_3_0_H_\r
+\r
+//\r
+// Statements that include other files\r
+//\r
+#include "AcpiCommon.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// ACPI Specification Revision\r
+//\r
+#define EFI_ACPI_3_0_REVISION 0x03\r
+\r
+//\r
+// ACPI 3.0 Generic Address Space definition\r
+//\r
+typedef struct {\r
+  UINT8   AddressSpaceId;\r
+  UINT8   RegisterBitWidth;\r
+  UINT8   RegisterBitOffset;\r
+  UINT8   AccessSize;\r
+  UINT64  Address;\r
+} EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE;\r
+\r
+//\r
+// Generic Address Space Address IDs\r
+//\r
+#define EFI_ACPI_3_0_SYSTEM_MEMORY              0\r
+#define EFI_ACPI_3_0_SYSTEM_IO                  1\r
+#define EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE    2\r
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER        3\r
+#define EFI_ACPI_3_0_SMBUS                      4\r
+#define EFI_ACPI_3_0_FUNCTIONAL_FIXED_HARDWARE  0x7F\r
+\r
+//\r
+// Generic Address Space Access Sizes\r
+//\r
+#define EFI_ACPI_3_0_UNDEFINED  0\r
+#define EFI_ACPI_3_0_BYTE       1\r
+#define EFI_ACPI_3_0_WORD       2\r
+#define EFI_ACPI_3_0_DWORD      3\r
+#define EFI_ACPI_3_0_QWORD      4\r
+\r
+//\r
+// ACPI 3.0 table structures\r
+//\r
+//\r
+// Root System Description Pointer Structure\r
+//\r
+typedef struct {\r
+  UINT64  Signature;\r
+  UINT8   Checksum;\r
+  UINT8   OemId[6];\r
+  UINT8   Revision;\r
+  UINT32  RsdtAddress;\r
+  UINT32  Length;\r
+  UINT64  XsdtAddress;\r
+  UINT8   ExtendedChecksum;\r
+  UINT8   Reserved[3];\r
+} EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER;\r
+\r
+//\r
+// RSD_PTR Revision (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02  // ACPISpec30 (Revision 3.0) says current value is 2\r
+//\r
+// Common table header, this prefaces all ACPI tables, including FACS, but\r
+// excluding the RSD PTR structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+} EFI_ACPI_3_0_COMMON_HEADER;\r
+\r
+//\r
+// Root System Description Table\r
+// No definition needed as it is a common description table header followed by a\r
+// variable number of UINT32 table pointers.\r
+//\r
+//\r
+// RSDT Revision (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Extended System Description Table\r
+// No definition needed as it is a common description table header followed by a\r
+// variable number of UINT64 table pointers.\r
+//\r
+//\r
+// XSDT Revision (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Fixed ACPI Description Table Structure (FADT)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  UINT32                                  FirmwareCtrl;\r
+  UINT32                                  Dsdt;\r
+  UINT8                                   Reserved0;\r
+  UINT8                                   PreferredPmProfile;\r
+  UINT16                                  SciInt;\r
+  UINT32                                  SmiCmd;\r
+  UINT8                                   AcpiEnable;\r
+  UINT8                                   AcpiDisable;\r
+  UINT8                                   S4BiosReq;\r
+  UINT8                                   PstateCnt;\r
+  UINT32                                  Pm1aEvtBlk;\r
+  UINT32                                  Pm1bEvtBlk;\r
+  UINT32                                  Pm1aCntBlk;\r
+  UINT32                                  Pm1bCntBlk;\r
+  UINT32                                  Pm2CntBlk;\r
+  UINT32                                  PmTmrBlk;\r
+  UINT32                                  Gpe0Blk;\r
+  UINT32                                  Gpe1Blk;\r
+  UINT8                                   Pm1EvtLen;\r
+  UINT8                                   Pm1CntLen;\r
+  UINT8                                   Pm2CntLen;\r
+  UINT8                                   PmTmrLen;\r
+  UINT8                                   Gpe0BlkLen;\r
+  UINT8                                   Gpe1BlkLen;\r
+  UINT8                                   Gpe1Base;\r
+  UINT8                                   CstCnt;\r
+  UINT16                                  PLvl2Lat;\r
+  UINT16                                  PLvl3Lat;\r
+  UINT16                                  FlushSize;\r
+  UINT16                                  FlushStride;\r
+  UINT8                                   DutyOffset;\r
+  UINT8                                   DutyWidth;\r
+  UINT8                                   DayAlrm;\r
+  UINT8                                   MonAlrm;\r
+  UINT8                                   Century;\r
+  UINT16                                  IaPcBootArch;\r
+  UINT8                                   Reserved1;\r
+  UINT32                                  Flags;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  ResetReg;\r
+  UINT8                                   ResetValue;\r
+  UINT8                                   Reserved2[3];\r
+  UINT64                                  XFirmwareCtrl;\r
+  UINT64                                  XDsdt;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk;\r
+} EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE;\r
+\r
+//\r
+// FADT Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION  0x04\r
+\r
+//\r
+// Fixed ACPI Description Table Preferred Power Management Profile\r
+//\r
+#define EFI_ACPI_3_0_PM_PROFILE_UNSPECIFIED         0\r
+#define EFI_ACPI_3_0_PM_PROFILE_DESKTOP             1\r
+#define EFI_ACPI_3_0_PM_PROFILE_MOBILE              2\r
+#define EFI_ACPI_3_0_PM_PROFILE_WORKSTATION         3\r
+#define EFI_ACPI_3_0_PM_PROFILE_ENTERPRISE_SERVER   4\r
+#define EFI_ACPI_3_0_PM_PROFILE_SOHO_SERVER         5\r
+#define EFI_ACPI_3_0_PM_PROFILE_APPLIANCE_PC        6\r
+#define EFI_ACPI_3_0_PM_PROFILE_PERFORMANCE_SERVER  7\r
+\r
+//\r
+// Fixed ACPI Description Table Boot Architecture Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_LEGACY_DEVICES    (1 << 0)\r
+#define EFI_ACPI_3_0_8042              (1 << 1)\r
+#define EFI_ACPI_3_0_VGA_NOT_PRESENT   (1 << 2)\r
+#define EFI_ACPI_3_0_MSI_NOT_SUPPORTED (1 << 3)\r
+#define EFI_ACPI_3_0_PCIE_ASPM_CONTROLS (1 << 4)\r
+//\r
+// Fixed ACPI Description Table Fixed Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_WBINVD                   (1 << 0)\r
+#define EFI_ACPI_3_0_WBINVD_FLUSH             (1 << 1)\r
+#define EFI_ACPI_3_0_PROC_C1                  (1 << 2)\r
+#define EFI_ACPI_3_0_P_LVL2_UP                (1 << 3)\r
+#define EFI_ACPI_3_0_PWR_BUTTON               (1 << 4)\r
+#define EFI_ACPI_3_0_SLP_BUTTON               (1 << 5)\r
+#define EFI_ACPI_3_0_FIX_RTC                  (1 << 6)\r
+#define EFI_ACPI_3_0_RTC_S4                   (1 << 7)\r
+#define EFI_ACPI_3_0_TMR_VAL_EXT              (1 << 8)\r
+#define EFI_ACPI_3_0_DCK_CAP                  (1 << 9)\r
+#define EFI_ACPI_3_0_RESET_REG_SUP            (1 << 10)\r
+#define EFI_ACPI_3_0_SEALED_CASE              (1 << 11)\r
+#define EFI_ACPI_3_0_HEADLESS                 (1 << 12)\r
+#define EFI_ACPI_3_0_CPU_SW_SLP               (1 << 13)\r
+#define EFI_ACPI_3_0_PCI_EXP_WAK              (1 << 14)\r
+#define EFI_ACPI_3_0_USE_PLATFORM_CLOCK       (1 << 15)\r
+#define EFI_ACPI_3_0_S4_RTC_STS_VALID         (1 << 16)\r
+#define EFI_ACPI_3_0_REMOTE_POWER_ON_CAPABLE  (1 << 17)\r
+#define EFI_ACPI_3_0_FORCE_APIC_CLUSTER_MODEL (1 << 18)\r
+#define EFI_ACPI_3_0_FORCE_APIC_PHYSICAL_DESTINATION_MODE (1 << 19)\r
+\r
+//\r
+// Firmware ACPI Control Structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+  UINT32  HardwareSignature;\r
+  UINT32  FirmwareWakingVector;\r
+  UINT32  GlobalLock;\r
+  UINT32  Flags;\r
+  UINT64  XFirmwareWakingVector;\r
+  UINT8   Version;\r
+  UINT8   Reserved[31];\r
+} EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;\r
+\r
+//\r
+// FACS Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION  0x01\r
+\r
+//\r
+// Firmware Control Structure Feature Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_S4BIOS_F (1 << 0)\r
+\r
+//\r
+// Differentiated System Description Table,\r
+// Secondary System Description Table\r
+// and Persistent System Description Table,\r
+// no definition needed as they are common description table header followed by a\r
+// definition block.\r
+//\r
+#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION   0x02\r
+#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_REVISION        0x02\r
+\r
+//\r
+// Multiple APIC Description Table header definition.  The rest of the table\r
+// must be defined in a platform specific manner.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      LocalApicAddress;\r
+  UINT32                      Flags;\r
+} EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;\r
+\r
+//\r
+// MADT Revision (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x02\r
+\r
+//\r
+// Multiple APIC Flags\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_PCAT_COMPAT  (1 << 0)\r
+\r
+//\r
+// Multiple APIC Description Table APIC structure types\r
+// All other values between 0x09 an 0xFF are reserved and\r
+// will be ignored by OSPM.\r
+//\r
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC           0x00\r
+#define EFI_ACPI_3_0_IO_APIC                        0x01\r
+#define EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE      0x02\r
+#define EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE  0x03\r
+#define EFI_ACPI_3_0_LOCAL_APIC_NMI                 0x04\r
+#define EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE    0x05\r
+#define EFI_ACPI_3_0_IO_SAPIC                       0x06\r
+#define EFI_ACPI_3_0_LOCAL_SAPIC                    0x07\r
+#define EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES     0x08\r
+\r
+//\r
+// APIC Structure Definitions\r
+//\r
+//\r
+// Processor Local APIC Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT8   ApicId;\r
+  UINT32  Flags;\r
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE;\r
+\r
+//\r
+// Local APIC Flags.  All other bits are reserved and must be 0.\r
+//\r
+#define EFI_ACPI_3_0_LOCAL_APIC_ENABLED (1 << 0)\r
+\r
+//\r
+// IO APIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   IoApicId;\r
+  UINT8   Reserved;\r
+  UINT32  IoApicAddress;\r
+  UINT32  GlobalSystemInterruptBase;\r
+} EFI_ACPI_3_0_IO_APIC_STRUCTURE;\r
+\r
+//\r
+// Interrupt Source Override Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   Bus;\r
+  UINT8   Source;\r
+  UINT32  GlobalSystemInterrupt;\r
+  UINT16  Flags;\r
+} EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;\r
+\r
+//\r
+// Platform Interrupt Sources Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT8   InterruptType;\r
+  UINT8   ProcessorId;\r
+  UINT8   ProcessorEid;\r
+  UINT8   IoSapicVector;\r
+  UINT32  GlobalSystemInterrupt;\r
+  UINT32  PlatformInterruptSourceFlags;\r
+  UINT8   CpeiProcessorOverride;\r
+  UINT8   Reserved[31];\r
+} EFI_ACPI_3_0_PLATFORM_INTERRUPT_APIC_STRUCTURE;\r
+\r
+//\r
+// MPS INTI flags.\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_POLARITY      (3 << 0)\r
+#define EFI_ACPI_3_0_TRIGGER_MODE  (3 << 2)\r
+\r
+//\r
+// Non-Maskable Interrupt Source Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT32  GlobalSystemInterrupt;\r
+} EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;\r
+\r
+//\r
+// Local APIC NMI Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT16  Flags;\r
+  UINT8   LocalApicLint;\r
+} EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE;\r
+\r
+//\r
+// Local APIC Address Override Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Reserved;\r
+  UINT64  LocalApicAddress;\r
+} EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE;\r
+\r
+//\r
+// IO SAPIC Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   IoApicId;\r
+  UINT8   Reserved;\r
+  UINT32  GlobalSystemInterruptBase;\r
+  UINT64  IoSapicAddress;\r
+} EFI_ACPI_3_0_IO_SAPIC_STRUCTURE;\r
+\r
+//\r
+// Local SAPIC Structure\r
+// This struct followed by a null-terminated ASCII string - ACPI Processor UID String\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   AcpiProcessorId;\r
+  UINT8   LocalSapicId;\r
+  UINT8   LocalSapicEid;\r
+  UINT8   Reserved[3];\r
+  UINT32  Flags;\r
+  UINT32  ACPIProcessorUIDValue;\r
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE;\r
+\r
+//\r
+// Platform Interrupt Sources Structure\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT16  Flags;\r
+  UINT8   InterruptType;\r
+  UINT8   ProcessorId;\r
+  UINT8   ProcessorEid;\r
+  UINT8   IoSapicVector;\r
+  UINT32  GlobalSystemInterrupt;\r
+  UINT32  PlatformInterruptSourceFlags;\r
+} EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE;\r
+\r
+//\r
+// Platform Interrupt Source Flags.\r
+// All other bits are reserved and must be set to 0.\r
+//\r
+#define EFI_ACPI_3_0_CPEI_PROCESSOR_OVERRIDE     (1 << 0)\r
+\r
+//\r
+// Smart Battery Description Table (SBST)\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      WarningEnergyLevel;\r
+  UINT32                      LowEnergyLevel;\r
+  UINT32                      CriticalEnergyLevel;\r
+} EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE;\r
+\r
+//\r
+// SBST Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01\r
+\r
+//\r
+// Embedded Controller Boot Resources Table (ECDT)\r
+// The table is followed by a null terminated ASCII string that contains\r
+// a fully qualified reference to the name space object.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  EcControl;\r
+  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE  EcData;\r
+  UINT32                                  Uid;\r
+  UINT8                                   GpeBit;\r
+} EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE;\r
+\r
+//\r
+// ECDT Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION  0x01\r
+\r
+//\r
+// System Resource Affinity Table (SRAT.  The rest of the table\r
+// must be defined in a platform specific manner.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT32                      Reserved1;  // Must be set to 1\r
+  UINT64                      Reserved2;\r
+} EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER;\r
+\r
+//\r
+// SRAT Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION  0x02\r
+\r
+//\r
+// SRAT structure types.\r
+// All other values between 0x02 an 0xFF are reserved and\r
+// will be ignored by OSPM.\r
+//\r
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY  0x00\r
+#define EFI_ACPI_3_0_MEMORY_AFFINITY                      0x01\r
+\r
+//\r
+// Processor Local APIC/SAPIC Affinity Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT8   ProximityDomain7To0;\r
+  UINT8   ApicId;\r
+  UINT32  Flags;\r
+  UINT8   LocalSapicEid;\r
+  UINT8   ProximityDomain31To8[3];\r
+  UINT8   Reserved[4];\r
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY_STRUCTURE;\r
+\r
+//\r
+// Local APIC/SAPIC Flags.  All other bits are reserved and must be 0.\r
+//\r
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_ENABLED (1 << 0)\r
+\r
+//\r
+// Memory Affinity Structure Definition\r
+//\r
+typedef struct {\r
+  UINT8   Type;\r
+  UINT8   Length;\r
+  UINT32  ProximityDomain;\r
+  UINT16  Reserved1;\r
+  UINT32  AddressBaseLow;\r
+  UINT32  AddressBaseHigh;\r
+  UINT32  LengthLow;\r
+  UINT32  LengthHigh;\r
+  UINT32  Reserved2;\r
+  UINT32  Flags;\r
+  UINT64  Reserved3;\r
+} EFI_ACPI_3_0_MEMORY_AFFINITY_STRUCTURE;\r
+\r
+//\r
+// Memory Flags.  All other bits are reserved and must be 0.\r
+//\r
+#define EFI_ACPI_3_0_MEMORY_ENABLED       (1 << 0)\r
+#define EFI_ACPI_3_0_MEMORY_HOT_PLUGGABLE (1 << 1)\r
+#define EFI_ACPI_3_0_MEMORY_NONVOLATILE   (1 << 2)\r
+\r
+//\r
+// System Locality Distance Information Table (SLIT).\r
+// The rest of the table is a matrix.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER Header;\r
+  UINT64                      NumberOfSystemLocalities;\r
+} EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER;\r
+\r
+//\r
+// SLIT Version (as defined in ACPI 3.0 spec.)\r
+//\r
+#define EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_REVISION  0x01\r
+\r
+//\r
+// Known table signatures\r
+//\r
+//\r
+// "RSD PTR " Root System Description Pointer\r
+//\r
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE  0x2052545020445352\r
+\r
+//\r
+// "APIC" Multiple APIC Description Table\r
+//\r
+#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE  0x43495041\r
+\r
+//\r
+// "DSDT" Differentiated System Description Table\r
+//\r
+#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445344\r
+\r
+//\r
+// "ECDT" Embedded Controller Boot Resources Table\r
+//\r
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345\r
+\r
+//\r
+// "FACP" Fixed ACPI Description Table\r
+//\r
+#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146\r
+\r
+//\r
+// "FACS" Firmware ACPI Control Structure\r
+//\r
+#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE  0x53434146\r
+\r
+//\r
+// "PSDT" Persistent System Description Table\r
+//\r
+#define EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445350\r
+\r
+//\r
+// "RSDT" Root System Description Table\r
+//\r
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445352\r
+\r
+//\r
+// "SBST" Smart Battery Specification Table\r
+//\r
+#define EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE  0x54534253\r
+\r
+//\r
+// "SLIT" System Locality Information Table\r
+//\r
+#define EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE  0x54494C53\r
+\r
+//\r
+// "SRAT" System Resource Affinity Table\r
+//\r
+#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253\r
+\r
+//\r
+// "SSDT" Secondary System Description Table\r
+//\r
+#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353\r
+\r
+//\r
+// "XSDT" Extended System Description Table\r
+//\r
+#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE  0x54445358\r
+\r
+//\r
+// "BOOT" MS Simple Boot Spec\r
+//\r
+#define EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42\r
+\r
+//\r
+// "CPEP" Corrected Platform Error Polling Table\r
+// See\r
+//\r
+#define EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE 0x50455043\r
+\r
+//\r
+// "DBGP" MS Debug Port Spec\r
+//\r
+#define EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244\r
+\r
+//\r
+// "ETDT" Event Timer Description Table\r
+//\r
+#define EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE  0x54445445\r
+\r
+//\r
+// "HPET" IA-PC High Precision Event Timer Table\r
+//\r
+#define EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE 0x54455048\r
+\r
+//\r
+// "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table\r
+//\r
+#define EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE  0x4746434D\r
+\r
+//\r
+// "SPCR" Serial Port Concole Redirection Table\r
+//\r
+#define EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  0x52435053\r
+\r
+//\r
+// "SPMI" Server Platform Management Interface Table\r
+//\r
+#define EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE 0x494D5053\r
+\r
+//\r
+// "TCPA" Trusted Computing Platform Alliance Capabilities Table\r
+//\r
+#define EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE 0x41504354\r
+\r
+//\r
+// "WDRT" Watchdog Resource Table\r
+//\r
+#define EFI_ACPI_3_0_WATCHDOG_RESOURCE_TABLE_SIGNATURE 0x54524457\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h
new file mode 100644 (file)
index 0000000..945e787
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AcpiCommon.h\r
+\r
+Abstract:\r
+\r
+  This file contains some basic ACPI definitions that are consumed by drivers\r
+  that do not care about ACPI versions.\r
+\r
+--*/\r
+\r
+#ifndef _ACPI_COMMON_H_\r
+#define _ACPI_COMMON_H_\r
+\r
+#include "Tiano.h"\r
+\r
+//\r
+// Common table header, this prefaces all ACPI tables, including FACS, but\r
+// excluding the RSD PTR structure\r
+//\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+} EFI_ACPI_COMMON_HEADER;\r
+\r
+//\r
+// Common ACPI description table header.  This structure prefaces most ACPI tables.\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+  UINT8   Revision;\r
+  UINT8   Checksum;\r
+  UINT8   OemId[6];\r
+  UINT64  OemTableId;\r
+  UINT32  OemRevision;\r
+  UINT32  CreatorId;\r
+  UINT32  CreatorRevision;\r
+} EFI_ACPI_DESCRIPTION_HEADER;\r
+\r
+#pragma pack()\r
+//\r
+// Define for Pci Host Bridge Resource Allocation\r
+//\r
+#define ACPI_ADDRESS_SPACE_DESCRIPTOR 0x8A\r
+#define ACPI_END_TAG_DESCRIPTOR       0x79\r
+\r
+#define ACPI_ADDRESS_SPACE_TYPE_MEM   0x00\r
+#define ACPI_ADDRESS_SPACE_TYPE_IO    0x01\r
+#define ACPI_ADDRESS_SPACE_TYPE_BUS   0x02\r
+\r
+//\r
+// Make sure structures match spec\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT8   Desc;\r
+  UINT16  Len;\r
+  UINT8   ResType;\r
+  UINT8   GenFlag;\r
+  UINT8   SpecificFlag;\r
+  UINT64  AddrSpaceGranularity;\r
+  UINT64  AddrRangeMin;\r
+  UINT64  AddrRangeMax;\r
+  UINT64  AddrTranslationOffset;\r
+  UINT64  AddrLen;\r
+} EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  UINT8 Desc;\r
+  UINT8 Checksum;\r
+} EFI_ACPI_END_TAG_DESCRIPTOR;\r
+\r
+//\r
+// General use definitions\r
+//\r
+#define EFI_ACPI_RESERVED_BYTE  0x00\r
+#define EFI_ACPI_RESERVED_WORD  0x0000\r
+#define EFI_ACPI_RESERVED_DWORD 0x00000000\r
+#define EFI_ACPI_RESERVED_QWORD 0x0000000000000000\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h
new file mode 100644 (file)
index 0000000..f750a63
--- /dev/null
@@ -0,0 +1,123 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  AlertStandardFormatTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI Alert Standard Format Description Table ASF! as described \r
+  in the ASF2.0 Specification\r
+\r
+--*/\r
+\r
+#ifndef _ALERT_STANDARD_FORMAT_TABLE_H\r
+#define _ALERT_STANDARD_FORMAT_TABLE_H\r
+\r
+#include "Acpi2_0.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack (1)\r
+\r
+//\r
+// Information Record header that appears at the beginning of each record\r
+//\r
+typedef struct {\r
+  UINT8                                Type;\r
+  UINT8                                Reserved;\r
+  UINT16                               RecordLength;\r
+} EFI_ACPI_ASF_RECORD_HEADER;\r
+\r
+//\r
+// This structure contains information that identifies the system type \r
+// and configuration\r
+//\r
+typedef struct {\r
+  EFI_ACPI_ASF_RECORD_HEADER           RecordHeader;\r
+  UINT8                                MinWatchDogResetValue;\r
+  UINT8                                MinPollingInterval;\r
+  UINT16                               SystemID;\r
+  UINT32                               IANAManufactureID;\r
+  UINT8                                FeatureFlags;\r
+  UINT8                                Reserved[3];\r
+} EFI_ACPI_ASF_INFO;\r
+\r
+//\r
+// Alert sensors definition\r
+//\r
+#define ASF_ALRT_SENSOR_ARRAY_LENGTH     36\r
+\r
+typedef struct {\r
+  EFI_ACPI_ASF_RECORD_HEADER           RecordHeader;\r
+  UINT8                                AssertionEventBitMask;\r
+  UINT8                                DeassertionEventBitMask;\r
+  UINT8                                NumberOfAlerts;\r
+  UINT8                                ArrayElementLength;\r
+  UINT8                                DeviceArray[ASF_ALRT_SENSOR_ARRAY_LENGTH];\r
+} EFI_ACPI_ASF_ALRT;\r
+\r
+//\r
+// Alert Remote Control System Actions\r
+//\r
+#define ASF_RCTL_DEVICES_ARRAY_LENGTH      16  \r
+typedef struct {\r
+  EFI_ACPI_ASF_RECORD_HEADER           RecordHeader;\r
+  UINT8                                NumberOfControls;\r
+  UINT8                                ArrayElementLength;\r
+  UINT16                               RctlReserved;\r
+  UINT8                                ControlArray[ASF_RCTL_DEVICES_ARRAY_LENGTH];\r
+} EFI_ACPI_ASF_RCTL;\r
+\r
+//\r
+// Remote Control Capabilities\r
+//\r
+typedef struct {\r
+  EFI_ACPI_ASF_RECORD_HEADER           RecordHeader;\r
+  UINT8                                RemoteControlCapabilities[7];\r
+  UINT8                                RMCPCompletionCode;\r
+  UINT32                               RMCPIANA;\r
+  UINT8                                RMCPSpecialCommand;\r
+  UINT8                                RMCPSpecialCommandParameter[2];\r
+  UINT8                                RMCPBootOptions[2];\r
+  UINT8                                RMCPOEMParameters[2];\r
+} EFI_ACPI_ASF_RMCP;\r
+\r
+//\r
+// SMBus Devices with fixed addresses\r
+//\r
+#define ASF_ADDR_DEVICE_ARRAY_LENGTH      16  \r
+typedef struct {\r
+  EFI_ACPI_ASF_RECORD_HEADER           RecordHeader;\r
+  UINT8                                SEEPROMAddress;\r
+  UINT8                                NumberOfDevices;\r
+  UINT8                                FixedSmbusAddresses[ASF_ADDR_DEVICE_ARRAY_LENGTH];\r
+} EFI_ACPI_ASF_ADDR;\r
+\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER          Header;\r
+  EFI_ACPI_ASF_INFO                    AsfInfo;\r
+  EFI_ACPI_ASF_ALRT                    AsfAlert;\r
+  EFI_ACPI_ASF_RCTL                    AsfRctl;\r
+  EFI_ACPI_ASF_RMCP                    AsfRmcp;\r
+  EFI_ACPI_ASF_ADDR                    AsfAddr;\r
+} EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE;\r
+\r
+//\r
+// "ASF!" ASF Description Table Signature\r
+//\r
+#define EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE_SIGNATURE  0x21465341\r
+\r
+#pragma pack ()\r
+\r
+#endif // _ALERT_STANDARD_FORMAT_TABLE_H\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h
new file mode 100644 (file)
index 0000000..78162c4
--- /dev/null
@@ -0,0 +1,202 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DMARemappingReportingTable.h\r
+\r
+Abstract:\r
+\r
+  The definition for ACPI DMA-Remapping Reporting (DMAR) Table.\r
+  It is defined in "Intel VT for Direct IO Architecture Specification".\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DMA_REMAPPING_REPORTING_TABLE_H_\r
+#define _EFI_DMA_REMAPPING_REPORTING_TABLE_H_\r
+\r
+#include "AcpiCommon.h"\r
+\r
+//\r
+// "DMAR" DMAR Description Table Signature\r
+//\r
+#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_SIGNATURE  0x52414d44\r
+\r
+//\r
+// DMAR Revision\r
+//\r
+#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_REVISION   0x01\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack (1)\r
+\r
+//\r
+// Definition for DMA Remapping Structure Types\r
+//\r
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_DRHD  0\r
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_RMRR  1\r
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_ATSR  2\r
+\r
+//\r
+// Definition for DMA Remapping Structure Header\r
+//\r
+typedef struct {\r
+  UINT16                                      Type;\r
+  UINT16                                      Length;\r
+} EFI_ACPI_DMAR_STRUCTURE_HEADER;\r
+\r
+//\r
+// Definition for DMA-Remapping PCI Path\r
+//\r
+typedef struct {\r
+  UINT8         Device;\r
+  UINT8         Function;\r
+} EFI_ACPI_DMAR_PCI_PATH;\r
+\r
+//\r
+// Definition for DMA-Remapping Device Scope Entry Structure\r
+//\r
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_ENDPOINT                 0x01\r
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_BRIDGE                   0x02\r
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_IOAPIC                   0x03\r
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_MSI_CAPABLE_HPET         0x04\r
+typedef struct {\r
+  UINT8                   DeviceScopeEntryType;\r
+  UINT8                   Length;\r
+  UINT16                  Reserved_2;\r
+  UINT8                   EnumerationID;\r
+  UINT8                   StartingBusNumber;\r
+} EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE;\r
+\r
+//\r
+// Definition for DMA-Remapping Hardware Definition (DRHD) Structure\r
+//\r
+#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_SET     0x1\r
+#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_CLEAR   0x0\r
+typedef struct {\r
+  UINT16                                      Type;\r
+  UINT16                                      Length;\r
+  UINT8                                       Flags;\r
+  UINT8                                       Reserved_5;\r
+  UINT16                                      SegmentNumber;\r
+  UINT64                                      RegisterBaseAddress;\r
+} EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE;\r
+\r
+//\r
+// Definition for Reserved Memory Region Reporting (RMRR) Structure\r
+//\r
+typedef struct {\r
+  UINT16                                      Type;\r
+  UINT16                                      Length;\r
+  UINT8                                       Reserved_4[2];\r
+  UINT16                                      SegmentNumber;\r
+  UINT64                                      ReservedMemoryRegionBaseAddress;\r
+  UINT64                                      ReservedMemoryRegionLimitAddress;\r
+} EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE;\r
+\r
+//\r
+// Definition for Root Port ATS Capability Reporting (ATSR) Structure\r
+//\r
+#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_SET     0x1\r
+#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_CLEAR   0x0\r
+typedef struct {\r
+  UINT16                                      Type;\r
+  UINT16                                      Length;\r
+  UINT8                                       Flags;\r
+  UINT8                                       Reserved_5;\r
+  UINT16                                      SegmentNumber;\r
+} EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE;\r
+\r
+//\r
+// Definition for DMA Remapping Structure\r
+//\r
+typedef union {\r
+  EFI_ACPI_DMAR_STRUCTURE_HEADER                               DMARStructureHeader;\r
+  EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE             DMARHardwareUnitDefinition;\r
+  EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE     DMARReservedMemoryRegionReporting;\r
+  EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE   DMARRootPortATSCapabilityReporting;\r
+} EFI_ACPI_DMA_REMAPPING_STRUCTURE;\r
+\r
+//\r
+// Definition for DMA-Remapping Reporting ACPI Table\r
+//\r
+#define EFI_ACPI_DMAR_TABLE_FLAGS_INTR_REMAP_SET            0x01\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER                               Header;\r
+  UINT8                                                     HostAddressWidth;\r
+  UINT8                                                     Flags;\r
+  UINT8                                                     Reserved_38[10];\r
+} EFI_ACPI_DMAR_DESCRIPTION_TABLE;\r
+\r
+//\r
+// The Platform specific definition can be as follows:\r
+//   NOTE: we use /**/ as comment for user convenience to copy it.\r
+//\r
+\r
+/*\r
+\r
+//\r
+// Dmar.h\r
+//\r
+\r
+#define EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES                  0x01  // user need to update\r
+typedef struct {\r
+  EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE               Header;\r
+  EFI_ACPI_DMAR_PCI_PATH                                   PciPath[EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES];    \r
+} EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE;\r
+\r
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY    0x01  // user need to update\r
+typedef struct {\r
+  EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE           Header;\r
+  EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE             DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY];\r
+} EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE;\r
+\r
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY    0x01  // user need to update\r
+typedef struct {\r
+  EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE   Header;\r
+  EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE             DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY];\r
+} EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE;\r
+\r
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY    0x01  // user need to update\r
+typedef struct {\r
+  EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE   Header;\r
+  EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE               DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY];\r
+} EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE;\r
+\r
+#define EFI_ACPI_DMAR_DHRD_ENTRY_COUNT                     0x1   // user need to update\r
+#define EFI_ACPI_DMAR_RMRR_ENTRY_COUNT                     0x1   // user need to update\r
+#define EFI_ACPI_DMAR_ATSR_ENTRY_COUNT                     0x1   // user need to update\r
+\r
+typedef struct {\r
+  EFI_ACPI_DMAR_DESCRIPTION_TABLE                                  Header;\r
+\r
+#if EFI_ACPI_3_0_DMAR_DHRD_ENTRY_COUNT > 0\r
+  EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE             Dhrd[EFI_ACPI_DMAR_DHRD_ENTRY_COUNT];\r
+#endif\r
+\r
+#if EFI_ACPI_3_0_DMAR_RMRR_ENTRY_COUNT > 0\r
+  EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE     Rmrr[EFI_ACPI_DMAR_RMRR_ENTRY_COUNT];\r
+#endif\r
+\r
+#if EFI_ACPI_3_0_DMAR_ATSR_ENTRY_COUNT > 0\r
+  EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE   Atsr[EFI_ACPI_DMAR_ATSR_ENTRY_COUNT];\r
+#endif\r
+\r
+} EFI_ACPI_3_0_DMA_REMAPPING_REPORTING_TABLE;\r
+\r
+*/\r
+\r
+#pragma pack()\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h
new file mode 100644 (file)
index 0000000..ee23907
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  HighPrecisionEventTimerTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI high precision event timer table definition, defined at \r
+  Intel IA-PC HPET (High Precision Event Timers) Specification.\r
+\r
+--*/\r
+\r
+#ifndef _HIGH_PRECISION_EVENT_TIMER_TABLE_H_\r
+#define _HIGH_PRECISION_EVENT_TIMER_TABLE_H_\r
+\r
+//\r
+// Include files\r
+//\r
+#include "Acpi2_0.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// High Precision Event Timer Table header definition.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  UINT32                                  EventTimerBlockId;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  BaseAddressLower32Bit;\r
+  UINT8                                   HpetNumber;\r
+  UINT16                                  MainCounterMinimumClockTickInPeriodicMode;\r
+  UINT8                                   PageProtectionAndOemAttribute;\r
+} EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER;\r
+\r
+//\r
+// HPET Revision (defined in spec)\r
+//\r
+#define EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION  0x01\r
+\r
+//\r
+// Page protection setting\r
+// Values 3 through 15 are reserved for use by the specification\r
+//\r
+#define EFI_ACPI_NO_PAGE_PROTECTION   0\r
+#define EFI_ACPI_4KB_PAGE_PROTECTION  1\r
+#define EFI_ACPI_64KB_PAGE_PROTECTION 2\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h
new file mode 100644 (file)
index 0000000..bf484a7
--- /dev/null
@@ -0,0 +1,283 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LegacyBiosMpTable.h\r
+\r
+Abstract:\r
+  Defives data structures per Multi Processor Specification Ver 1.4.\r
+\r
+--*/\r
+\r
+#ifndef LEGACY_BIOS_MPTABLE_H_\r
+#define LEGACY_BIOS_MPTABLE_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#define EFI_LEGACY_MP_TABLE_REV_1_4 0x04\r
+\r
+//\r
+// Define MP table structures. All are packed.\r
+//\r
+#pragma pack(push, 1)\r
+\r
+#define EFI_LEGACY_MP_TABLE_FLOATING_POINTER_SIGNATURE  EFI_SIGNATURE_32 ('_', 'M', 'P', '_')\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  PhysicalAddress;\r
+  UINT8   Length;\r
+  UINT8   SpecRev;\r
+  UINT8   Checksum;\r
+  UINT8   FeatureByte1;\r
+  struct {\r
+    UINT32  Reserved1 : 6;\r
+    UINT32  MutipleClk : 1;\r
+    UINT32  Imcr : 1;\r
+    UINT32  Reserved2 : 24;\r
+  } FeatureByte2_5;\r
+} EFI_LEGACY_MP_TABLE_FLOATING_POINTER;\r
+\r
+#define EFI_LEGACY_MP_TABLE_HEADER_SIGNATURE  EFI_SIGNATURE_32 ('P', 'C', 'M', 'P')\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT16  BaseTableLength;\r
+  UINT8   SpecRev;\r
+  UINT8   Checksum;\r
+  CHAR8   OemId[8];\r
+  CHAR8   OemProductId[12];\r
+  UINT32  OemTablePointer;\r
+  UINT16  OemTableSize;\r
+  UINT16  EntryCount;\r
+  UINT32  LocalApicAddress;\r
+  UINT16  ExtendedTableLength;\r
+  UINT8   ExtendedChecksum;\r
+  UINT8   Reserved;\r
+} EFI_LEGACY_MP_TABLE_HEADER;\r
+\r
+typedef struct {\r
+  UINT8 EntryType;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_TYPE;\r
+\r
+//\r
+// Entry Type 0: Processor.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_PROCESSOR  0x00\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 Id;\r
+  UINT8 Ver;\r
+  struct {\r
+    UINT8 Enabled : 1;\r
+    UINT8 Bsp : 1;\r
+    UINT8 Reserved : 6;\r
+  } Flags;\r
+  struct {\r
+    UINT32  Stepping : 4;\r
+    UINT32  Model : 4;\r
+    UINT32  Family : 4;\r
+    UINT32  Reserved : 20;\r
+  } Signature;\r
+  struct {\r
+    UINT32  Fpu : 1;\r
+    UINT32  Reserved1 : 6;\r
+    UINT32  Mce : 1;\r
+    UINT32  Cx8 : 1;\r
+    UINT32  Apic : 1;\r
+    UINT32  Reserved2 : 22;\r
+  } Features;\r
+  UINT32  Reserved1;\r
+  UINT32  Reserved2;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_PROCESSOR;\r
+\r
+//\r
+// Entry Type 1: Bus.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_BUS  0x01\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 Id;\r
+  CHAR8 TypeString[6];\r
+} EFI_LEGACY_MP_TABLE_ENTRY_BUS;\r
+\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUS   "CBUS  "  // Corollary CBus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUSII "CBUSII"  // Corollary CBUS II\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_EISA   "EISA  "  // Extended ISA\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_FUTURE "FUTURE"  // IEEE FutureBus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_INTERN "INTERN"  // Internal bus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_ISA    "ISA   "  // Industry Standard Architecture\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBI    "MBI   "  // Multibus I\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBII   "MBII  "  // Multibus II\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MCA    "MCA   "  // Micro Channel Architecture\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPI    "MPI   "  // MPI\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPSA   "MPSA  "  // MPSA\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_NUBUS  "NUBUS "  // Apple Macintosh NuBus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCI    "PCI   "  // Peripheral Component Interconnect\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCMCIA "PCMCIA"  // PC Memory Card International Assoc.\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_TC     "TC    "  // DEC TurboChannel\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VL     "VL    "  // VESA Local Bus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VME    "VME   "  // VMEbus\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_XPRESS "XPRESS"  // Express System Bus\r
+//\r
+// Entry Type 2: I/O APIC.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IOAPIC 0x02\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 Id;\r
+  UINT8 Ver;\r
+  struct {\r
+    UINT8 Enabled : 1;\r
+    UINT8 Reserved : 7;\r
+  } Flags;\r
+  UINT32  Address;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_IOAPIC;\r
+\r
+//\r
+// Entry Type 3: I/O Interrupt Assignment.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IO_INT 0x03\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 IntType;\r
+  struct {\r
+    UINT16  Polarity : 2;\r
+    UINT16  Trigger : 2;\r
+    UINT16  Reserved : 12;\r
+  } Flags;\r
+  UINT8 SourceBusId;\r
+  union {\r
+    struct {\r
+      UINT8 IntNo : 2;\r
+      UINT8 Dev : 5;\r
+      UINT8 Reserved : 1;\r
+    } fields;\r
+    UINT8 byte;\r
+  } SourceBusIrq;\r
+  UINT8 DestApicId;\r
+  UINT8 DestApicIntIn;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryIoIntTypeInt   = 0,\r
+  EfiLegacyMpTableEntryIoIntTypeNmi   = 1,\r
+  EfiLegacyMpTableEntryIoIntTypeSmi   = 2,\r
+  EfiLegacyMpTableEntryIoIntTypeExtInt= 3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_TYPE;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryIoIntFlagsPolaritySpec       = 0x0,\r
+  EfiLegacyMpTableEntryIoIntFlagsPolarityActiveHigh = 0x1,\r
+  EfiLegacyMpTableEntryIoIntFlagsPolarityReserved   = 0x2,\r
+  EfiLegacyMpTableEntryIoIntFlagsPolarityActiveLow  = 0x3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_POLARITY;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryIoIntFlagsTriggerSpec        = 0x0,\r
+  EfiLegacyMpTableEntryIoIntFlagsTriggerEdge        = 0x1,\r
+  EfiLegacyMpTableEntryIoIntFlagsTriggerReserved    = 0x2,\r
+  EfiLegacyMpTableEntryIoIntFlagsTriggerLevel       = 0x3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_TRIGGER;\r
+\r
+//\r
+// Entry Type 4: Local Interrupt Assignment.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_LOCAL_INT  0x04\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 IntType;\r
+  struct {\r
+    UINT16  Polarity : 2;\r
+    UINT16  Trigger : 2;\r
+    UINT16  Reserved : 12;\r
+  } Flags;\r
+  UINT8 SourceBusId;\r
+  UINT8 SourceBusIrq;\r
+  UINT8 DestApicId;\r
+  UINT8 DestApicIntIn;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryLocalIntTypeInt              = 0,\r
+  EfiLegacyMpTableEntryLocalIntTypeNmi              = 1,\r
+  EfiLegacyMpTableEntryLocalIntTypeSmi              = 2,\r
+  EfiLegacyMpTableEntryLocalIntTypeExtInt           = 3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_TYPE;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryLocalIntFlagsPolaritySpec      = 0x0,\r
+  EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveHigh= 0x1,\r
+  EfiLegacyMpTableEntryLocalIntFlagsPolarityReserved  = 0x2,\r
+  EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveLow = 0x3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_POLARITY;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryLocalIntFlagsTriggerSpec       = 0x0,\r
+  EfiLegacyMpTableEntryLocalIntFlagsTriggerEdge       = 0x1,\r
+  EfiLegacyMpTableEntryLocalIntFlagsTriggerReserved   = 0x2,\r
+  EfiLegacyMpTableEntryLocalIntFlagsTriggerLevel      = 0x3,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_TRIGGER;\r
+\r
+//\r
+// Entry Type 128: System Address Space Mapping.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_SYS_ADDR_SPACE_MAPPING 0x80\r
+typedef struct {\r
+  UINT8   EntryType;\r
+  UINT8   Length;\r
+  UINT8   BusId;\r
+  UINT8   AddressType;\r
+  UINT64  AddressBase;\r
+  UINT64  AddressLength;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING;\r
+\r
+typedef enum {\r
+  EfiLegacyMpTableEntryExtSysAddrSpaceMappingIo       = 0,\r
+  EfiLegacyMpTableEntryExtSysAddrSpaceMappingMemory   = 1,\r
+  EfiLegacyMpTableEntryExtSysAddrSpaceMappingPrefetch = 2,\r
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING_TYPE;\r
+\r
+//\r
+// Entry Type 129: Bus Hierarchy.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_BUS_HIERARCHY  0x81\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 Length;\r
+  UINT8 BusId;\r
+  struct {\r
+    UINT8 SubtractiveDecode : 1;\r
+    UINT8 Reserved : 7;\r
+  } BusInfo;\r
+  UINT8 ParentBus;\r
+  UINT8 Reserved1;\r
+  UINT8 Reserved2;\r
+  UINT8 Reserved3;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_BUS_HIERARCHY;\r
+\r
+//\r
+// Entry Type 130: Compatibility Bus Address Space Modifier.\r
+//\r
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_COMPAT_BUS_ADDR_SPACE_MODIFIER 0x82\r
+typedef struct {\r
+  UINT8 EntryType;\r
+  UINT8 Length;\r
+  UINT8 BusId;\r
+  struct {\r
+    UINT8 RangeMode : 1;\r
+    UINT8 Reserved : 7;\r
+  } AddrMode;\r
+  UINT32  PredefinedRangeList;\r
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_COMPAT_BUS_ADDR_SPACE_MODIFIER;\r
+\r
+#pragma pack(pop)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
new file mode 100644 (file)
index 0000000..5bbc059
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryMappedConfigurationSpaceAccessTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI memory mapped configuration space access table definition, defined at \r
+  in the PCI Firmware Specification, version 3.0.\r
+  Specification is available at http://www.pcisig.com.\r
+\r
+--*/\r
+\r
+#ifndef _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_\r
+#define _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_\r
+\r
+//\r
+// Include files\r
+//\r
+#include "AcpiCommon.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// Memory Mapped Configuration Space Access Table (MCFG)\r
+// This table is a basic description table header followed by\r
+// a number of base address allocation structures.\r
+//\r
+typedef struct {\r
+  UINT64  BaseAddress;\r
+  UINT16  PciSegmentGroupNumber;\r
+  UINT8   StartBusNumber;\r
+  UINT8   EndBusNumber;\r
+  UINT32  Reserved;\r
+} EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE;\r
+\r
+//\r
+// MCFG Revision (defined in spec)\r
+//\r
+#define EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION  0x01\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h
new file mode 100644 (file)
index 0000000..f8ca848
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  SdramSpd.h\r
+\r
+Abstract:\r
+\r
+  This file contains definitions for the SPD fields on an SDRAM.\r
\r
+--*/\r
+\r
+#ifndef _SDRAM_SPD_H\r
+#define _SDRAM_SPD_H\r
+\r
+//\r
+// SDRAM SPD field definitions\r
+//\r
+#define SPD_MEMORY_TYPE                 2\r
+#define SPD_SDRAM_ROW_ADDR              3\r
+#define SPD_SDRAM_COL_ADDR              4\r
+#define SPD_SDRAM_MODULE_ROWS           5\r
+#define SPD_SDRAM_MODULE_DATA_WIDTH_LSB 6\r
+#define SPD_SDRAM_MODULE_DATA_WIDTH_MSB 7\r
+#define SPD_SDRAM_ECC_SUPPORT           11\r
+#define SPD_SDRAM_REFRESH               12\r
+#define SPD_SDRAM_WIDTH                 13\r
+#define SPD_SDRAM_ERROR_WIDTH           14\r
+#define SPD_SDRAM_BURST_LENGTH          16\r
+#define SPD_SDRAM_NO_OF_BANKS           17\r
+#define SPD_SDRAM_CAS_LATENCY           18\r
+#define SPD_SDRAM_MODULE_ATTR           21\r
+\r
+#define SPD_SDRAM_TCLK1_PULSE           9   // cycle time for highest cas latency\r
+#define SPD_SDRAM_TAC1_PULSE            10  // access time for highest cas latency\r
+#define SPD_SDRAM_TCLK2_PULSE           23  // cycle time for 2nd highest cas latency\r
+#define SPD_SDRAM_TAC2_PULSE            24  // access time for 2nd highest cas latency\r
+#define SPD_SDRAM_TCLK3_PULSE           25  // cycle time for 3rd highest cas latency\r
+#define SPD_SDRAM_TAC3_PULSE            26  // access time for 3rd highest cas latency\r
+#define SPD_SDRAM_MIN_PRECHARGE         27\r
+#define SPD_SDRAM_ACTIVE_MIN            28\r
+#define SPD_SDRAM_RAS_CAS               29\r
+#define SPD_SDRAM_RAS_PULSE             30\r
+#define SPD_SDRAM_DENSITY               31\r
+\r
+//\r
+// Memory Type Definitions\r
+//\r
+#define SPD_VAL_SDR_TYPE  4 // SDR SDRAM memory\r
+#define SPD_VAL_DDR_TYPE  7 // DDR SDRAM memory\r
+#define SPD_VAL_DDR2_TYPE 8 // DDR2 SDRAM memory\r
+//\r
+// ECC Type Definitions\r
+//\r
+#define SPD_ECC_TYPE_NONE   0x00  // No error checking\r
+#define SPD_ECC_TYPE_PARITY 0x01  // No error checking\r
+#define SPD_ECC_TYPE_ECC    0x02  // Error checking only\r
+//\r
+// Module Attributes (Bit positions)\r
+//\r
+#define SPD_BUFFERED    0x01\r
+#define SPD_REGISTERED  0x02\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h
new file mode 100644 (file)
index 0000000..2c2a925
--- /dev/null
@@ -0,0 +1,80 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ServerProcessorManagementInterfaceTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI Server Processor Management Interface Table SPMI as described \r
+  in the IPMI2.0 Specification Revistion 1.5\r
+\r
+--*/\r
+\r
+#ifndef _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_\r
+#define _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_\r
+\r
+#include "Acpi2_0.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack (1)\r
+\r
+//\r
+// Server Processor Management Interface Table definition.\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER            Header;\r
+  UINT8                                  Reserved_36;\r
+  UINT8                                  InterfaceType;\r
+  UINT16                                 SpecificationRevision;\r
+  UINT8                                  InterruptType;\r
+  UINT8                                  GPE;\r
+  UINT8                                  Reserved_42;\r
+  UINT8                                  PCIDeviceFlag;\r
+  UINT32                                 GlobalSystemInterrupt;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddress;\r
+  UINT8                                  PCISegmentGroup_UID1;\r
+  UINT8                                  PCIBusNumber_UID2;\r
+  UINT8                                  PCIDeviceNumber_UID3;\r
+  UINT8                                  PCIFunctionNumber_UID4;\r
+} EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_DESCRIPTION_TABLE;\r
+\r
+#pragma pack ()\r
+\r
+//\r
+// SPMI Revision\r
+//\r
+#define EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_REVISION  0x05\r
+\r
+//\r
+// Interface Type\r
+//\r
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_RESERVED   0\r
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_KCS        1\r
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_SMIC       2\r
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_BT         3\r
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_SSIF       4\r
+\r
+//\r
+// SPMI Specfication Revision\r
+//\r
+#define EFI_ACPI_SPMI_SPECIFICATION_REVISION  0x0150\r
+\r
+//\r
+// SPMI Interrupt Type\r
+//\r
+#define EFI_ACPI_SPMI_INTERRUPT_TYPE_SCI     0x1\r
+#define EFI_ACPI_SPMI_INTERRUPT_TYPE_IOAPIC  0x2\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h
new file mode 100644 (file)
index 0000000..10ef37d
--- /dev/null
@@ -0,0 +1,576 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  Smbios.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _SMBIOS_TABLE_H_\r
+#define _SMBIOS_TABLE_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+typedef UINT8 SMBIOS_TABLE_STRING;\r
+\r
+typedef struct {\r
+  UINT8                 AnchorString[4];\r
+  UINT8                 EntryPointStructureChecksum;\r
+  UINT8                 EntryPointLength;\r
+  UINT8                 MajorVersion;\r
+  UINT8                 MinorVersion;\r
+  UINT16                MaxStructureSize;\r
+  UINT8                 EntryPointRevision;\r
+  UINT8                 FormattedArea[5];\r
+  UINT8                 IntermediateAnchorString[5];\r
+  UINT8                 IntermediateChecksum;\r
+  UINT16                TableLength;\r
+  UINT32                TableAddress;\r
+  UINT16                NumberOfSmbiosStructures;\r
+  UINT8                 SmbiosBcdRevision;\r
+} SMBIOS_TABLE_STRUCTURE;\r
+\r
+typedef struct {\r
+  UINT8                 Type;\r
+  UINT8                 Length;\r
+  UINT16                Handle;\r
+} SMBIOS_TABLE_HEADER;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Vendor;\r
+  SMBIOS_TABLE_STRING   BiosVersion;\r
+  UINT16                BiosSegment;\r
+  SMBIOS_TABLE_STRING   BiosReleaseDate;\r
+  UINT8                 BiosSize;\r
+  UINT64                BiosCharacteristics;\r
+  UINT8                 BIOSCharacteristicsExtensionBytes[2];\r
+  UINT8                 SystemBiosMajorRelease;\r
+  UINT8                 SystemBiosMinorRelease;\r
+  UINT8                 EmbeddedControllerFirmwareMajorRelease;\r
+  UINT8                 EmbeddedControllerFirmwareMinorRelease;\r
+} SMBIOS_TABLE_TYPE0;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  SMBIOS_TABLE_STRING   ProductName;\r
+  SMBIOS_TABLE_STRING   Version;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  EFI_GUID              Uuid;\r
+  UINT8                 WakeUpType;\r
+  SMBIOS_TABLE_STRING   SKUNumber;\r
+  SMBIOS_TABLE_STRING   Family;\r
+} SMBIOS_TABLE_TYPE1;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  SMBIOS_TABLE_STRING   ProductName;\r
+  SMBIOS_TABLE_STRING   Version;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   AssetTag;\r
+  UINT8                 FeatureFlag;\r
+  SMBIOS_TABLE_STRING   LocationInChassis;\r
+  UINT16                ChassisHandle;\r
+  UINT8                 BoardType;\r
+  UINT8                 NumberOfContainedObjectHandles;\r
+  UINT16                ContainedObjectHandles[1];\r
+} SMBIOS_TABLE_TYPE2;\r
+\r
+typedef struct {\r
+  UINT8                 ContainedElementType;\r
+  UINT8                 ContainedElementMinimum;\r
+  UINT8                 ContainedElementMaximum;\r
+} CONTAINED_ELEMENT;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  UINT8                 Type;\r
+  SMBIOS_TABLE_STRING   Version;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   AssetTag;\r
+  UINT8                 BootupState;\r
+  UINT8                 PowerSupplyState;\r
+  UINT8                 ThermalState;\r
+  UINT8                 SecurityStatus;\r
+  UINT8                 OemDefined[4];\r
+  UINT8                 Height;\r
+  UINT8                 NumberofPowerCords;\r
+  UINT8                 ContainedElementCount;\r
+  UINT8                 ContainedElementRecordLength;\r
+  CONTAINED_ELEMENT     ContainedElements[1];\r
+} SMBIOS_TABLE_TYPE3;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Socket;\r
+  UINT8                 ProcessorType;\r
+  UINT8                 ProcessorFamily;\r
+  SMBIOS_TABLE_STRING   ProcessorManufacture;\r
+  UINT8                 ProcessorId[8];\r
+  SMBIOS_TABLE_STRING   ProcessorVersion;\r
+  UINT8                 Voltage;\r
+  UINT16                ExternalClock;\r
+  UINT16                MaxSpeed;\r
+  UINT16                CurrentSpeed;\r
+  UINT8                 Status;\r
+  UINT8                 ProcessorUpgrade;\r
+  UINT16                L1CacheHandle;\r
+  UINT16                L2CacheHandle;\r
+  UINT16                L3CacheHandle;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   AssetTag;\r
+  SMBIOS_TABLE_STRING   PartNumber;\r
+} SMBIOS_TABLE_TYPE4;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 ErrDetectMethod;\r
+  UINT8                 ErrCorrectCapability;\r
+  UINT8                 SupportInterleave;\r
+  UINT8                 CurrentInterleave;\r
+  UINT8                 MaxMemoryModuleSize;\r
+  UINT16                SupportSpeed;\r
+  UINT16                SupportMemoryType;\r
+  UINT8                 MemoryModuleVoltage;\r
+  UINT8                 AssociatedMemorySlotNum;\r
+  UINT16                MemoryModuleConfigHandles[1];\r
+//  UINT8                 EnableErrCorrectCapabilities;\r
+} SMBIOS_TABLE_TYPE5;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   SocketDesignation;\r
+  UINT8                 BankConnections;\r
+  UINT8                 CurrentSpeed;\r
+  UINT16                CurrentMemoryType;\r
+  UINT8                 InstalledSize;\r
+  UINT8                 EnabledSize;\r
+  UINT8                 ErrorStatus;\r
+} SMBIOS_TABLE_TYPE6;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   SocketDesignation;\r
+  UINT16                CacheConfiguration;\r
+  UINT16                MaximumCacheSize;\r
+  UINT16                InstalledSize;\r
+  UINT16                SupportedSRAMType;\r
+  UINT16                CurrentSRAMType;\r
+  UINT8                 CacheSpeed;\r
+  UINT8                 ErrorCorrectionType;\r
+  UINT8                 SystemCacheType;\r
+  UINT8                 Associativity;\r
+} SMBIOS_TABLE_TYPE7;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   InternalReferenceDesignator;\r
+  UINT8                 InternalConnectorType;\r
+  SMBIOS_TABLE_STRING   ExternalReferenceDesignator;\r
+  UINT8                 ExternalConnectorType;\r
+  UINT8                 PortType;\r
+} SMBIOS_TABLE_TYPE8;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   SlotDesignation;\r
+  UINT8                 SlotType;\r
+  UINT8                 SlotDataBusWidth;\r
+  UINT8                 CurrentUsage;\r
+  UINT8                 SlotLength;\r
+  UINT16                SlotID;\r
+  UINT8                 SlotCharacteristics1;\r
+  UINT8                 SlotCharacteristics2;\r
+} SMBIOS_TABLE_TYPE9;\r
+\r
+typedef struct {\r
+  UINT8                 DeviceType;\r
+  SMBIOS_TABLE_STRING   DescriptionString;\r
+} DEVICE_STRUCT;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  DEVICE_STRUCT         Device[1];\r
+} SMBIOS_TABLE_TYPE10;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 StringCount;\r
+} SMBIOS_TABLE_TYPE11;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 StringCount;\r
+} SMBIOS_TABLE_TYPE12;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 InstallableLanguages;\r
+  UINT8                 Flags;\r
+  UINT8                 reserved[15];\r
+  SMBIOS_TABLE_STRING   CurrentLanguages;\r
+} SMBIOS_TABLE_TYPE13;\r
+\r
+typedef struct {\r
+  UINT8                 ItemType;\r
+  UINT16                ItemHandle;\r
+} GROUP_STRUCT;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   GroupName;\r
+  GROUP_STRUCT          Group[1];\r
+} SMBIOS_TABLE_TYPE14;\r
+\r
+typedef struct {\r
+  UINT8                 LogType;\r
+  UINT8                 DataFormatType;\r
+} EVENT_LOG_TYPE;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT16                LogAreaLength;\r
+  UINT16                LogHeaderStartOffset;\r
+  UINT16                LogDataStartOffset;\r
+  UINT8                 AccessMethod;\r
+  UINT8                 LogStatus;\r
+  UINT32                LogChangeToken;\r
+  UINT32                AccessMethodAddress;\r
+  UINT8                 LogHeaderFormat;\r
+  UINT8                 NumberOfSupportedLogTypeDescriptors;\r
+  UINT8                 LengthOfLogTypeDescriptor;\r
+  EVENT_LOG_TYPE        EventLogTypeDescriptors[1];\r
+} SMBIOS_TABLE_TYPE15;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Location;\r
+  UINT8                 Use;\r
+  UINT8                 MemoryErrorCorrection;\r
+  UINT32                MaximumCapacity;\r
+  UINT16                MemoryErrorInformationHandle;\r
+  UINT16                NumberOfMemoryDevices;\r
+} SMBIOS_TABLE_TYPE16;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT16                MemoryArrayHandle;\r
+  UINT16                MemoryErrorInformationHandle;\r
+  UINT16                TotalWidth;\r
+  UINT16                DataWidth;\r
+  UINT16                Size;\r
+  UINT8                 FormFactor;\r
+  UINT8                 DeviceSet;\r
+  SMBIOS_TABLE_STRING   DeviceLocator;\r
+  SMBIOS_TABLE_STRING   BankLocator;\r
+  UINT8                 MemoryType;\r
+  UINT16                TypeDetail;\r
+  UINT16                Speed;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   AssetTag;\r
+  SMBIOS_TABLE_STRING   PartNumber;\r
+} SMBIOS_TABLE_TYPE17;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 ErrorType;\r
+  UINT8                 ErrorGranularity;\r
+  UINT8                 ErrorOperation;\r
+  UINT32                VendorSyndrome;\r
+  UINT32                MemoryArrayErrorAddress;\r
+  UINT32                DeviceErrorAddress;\r
+  UINT32                ErrorResolution;\r
+} SMBIOS_TABLE_TYPE18;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT32                StartingAddress;\r
+  UINT32                EndingAddress;\r
+  UINT16                MemoryArrayHandle;\r
+  UINT8                 PartitionWidth;\r
+} SMBIOS_TABLE_TYPE19;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT32                StartingAddress;\r
+  UINT32                EndingAddress;\r
+  UINT16                MemoryDeviceHandle;\r
+  UINT16                MemoryArrayMappedAddressHandle;\r
+  UINT8                 PartitionRowPosition;\r
+  UINT8                 InterleavePosition;\r
+  UINT8                 InterleavedDataDepth;\r
+} SMBIOS_TABLE_TYPE20;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Type;\r
+  UINT8                 Interface;\r
+  UINT8                 NumberOfButtons;\r
+} SMBIOS_TABLE_TYPE21;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Location;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  SMBIOS_TABLE_STRING   ManufactureDate;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   DeviceName;\r
+  UINT8                 DeviceChemistry;\r
+  UINT16                DeviceCapacity;\r
+  UINT16                DesignVoltage;\r
+  SMBIOS_TABLE_STRING   SBDSVersionNumber;\r
+  UINT8                 MaximumErrorInBatteryData;\r
+  UINT16                SBDSSerialNumber;\r
+  UINT16                SBDSManufactureDate;\r
+  SMBIOS_TABLE_STRING   SBDSDeviceChemistry;\r
+  UINT8                 DesignCapacityMultiplier;\r
+  UINT32                OEMSpecific;\r
+} SMBIOS_TABLE_TYPE22;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Capabilities;\r
+  UINT16                ResetCount;\r
+  UINT16                ResetLimit;\r
+  UINT16                TimerInterval;\r
+  UINT16                Timeout;\r
+} SMBIOS_TABLE_TYPE23;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 HardwareSecuritySettings;\r
+} SMBIOS_TABLE_TYPE24;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 NextScheduledPowerOnMonth;\r
+  UINT8                 NextScheduledPowerOnDayOfMonth;\r
+  UINT8                 NextScheduledPowerOnHour;\r
+  UINT8                 NextScheduledPowerOnMinute;\r
+  UINT8                 NextScheduledPowerOnSecond;\r
+} SMBIOS_TABLE_TYPE25;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Description;\r
+  UINT8                 LocationAndStatus;\r
+  UINT16                MaximumValue;\r
+  UINT16                MinimumValue;\r
+  UINT16                Resolution;\r
+  UINT16                Tolerance;\r
+  UINT16                Accuracy;\r
+  UINT32                OEMDefined;\r
+  UINT16                NominalValue;\r
+} SMBIOS_TABLE_TYPE26;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT16                TemperatureProbeHandle;\r
+  UINT8                 DeviceTypeAndStatus;\r
+  UINT8                 CoolingUnitGroup;\r
+  UINT32                OEMDefined;\r
+  UINT16                NominalSpeed;\r
+} SMBIOS_TABLE_TYPE27;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Description;\r
+  UINT8                 LocationAndStatus;\r
+  UINT16                MaximumValue;\r
+  UINT16                MinimumValue;\r
+  UINT16                Resolution;\r
+  UINT16                Tolerance;\r
+  UINT16                Accuracy;\r
+  UINT32                OEMDefined;\r
+  UINT16                NominalValue;\r
+} SMBIOS_TABLE_TYPE28;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Description;\r
+  UINT8                 LocationAndStatus;\r
+  UINT16                MaximumValue;\r
+  UINT16                MinimumValue;\r
+  UINT16                Resolution;\r
+  UINT16                Tolerance;\r
+  UINT16                Accuracy;\r
+  UINT32                OEMDefined;\r
+  UINT16                NominalValue;\r
+} SMBIOS_TABLE_TYPE29;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   ManufacturerName;\r
+  UINT8                 Connections;\r
+} SMBIOS_TABLE_TYPE30;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Checksum;\r
+  UINT8                 Reserved1;\r
+  UINT16                Reserved2;\r
+  UINT32                BisEntry16;\r
+  UINT32                BisEntry32;\r
+  UINT64                Reserved3;\r
+  UINT32                Reserved4;\r
+} SMBIOS_TABLE_TYPE31;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 Reserved[6];\r
+  UINT8                 BootStatus[1];\r
+} SMBIOS_TABLE_TYPE32;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 ErrorType;\r
+  UINT8                 ErrorGranularity;\r
+  UINT8                 ErrorOperation;\r
+  UINT32                VendorSyndrome;\r
+  UINT64                MemoryArrayErrorAddress;\r
+  UINT64                DeviceErrorAddress;\r
+  UINT32                ErrorResolution;\r
+} SMBIOS_TABLE_TYPE33;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Description;\r
+  UINT8                 Type;\r
+  UINT32                Address;\r
+  UINT8                 AddressType;\r
+} SMBIOS_TABLE_TYPE34;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  SMBIOS_TABLE_STRING   Description;\r
+  UINT16                ManagementDeviceHandle;\r
+  UINT16                ComponentHandle;\r
+  UINT16                ThresholdHandle;\r
+} SMBIOS_TABLE_TYPE35;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT16                LowerThresholdNonCritical;\r
+  UINT16                UpperThresholdNonCritical;\r
+  UINT16                LowerThresholdCritical;\r
+  UINT16                UpperThresholdCritical;\r
+  UINT16                LowerThresholdNonRecoverable;\r
+  UINT16                UpperThresholdNonRecoverable;\r
+} SMBIOS_TABLE_TYPE36;\r
+\r
+typedef struct {\r
+  UINT8                 DeviceLoad;\r
+  UINT16                DeviceHandle;\r
+} MEMORY_DEVICE;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 ChannelType;\r
+  UINT8                 MaximumChannelLoad;\r
+  UINT8                 MemoryDeviceCount;\r
+  MEMORY_DEVICE         MemoryDevice[1];\r
+} SMBIOS_TABLE_TYPE37;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 InterfaceType;\r
+  UINT8                 IPMISpecificationRevision;\r
+  UINT8                 I2CSlaveAddress;\r
+  UINT8                 NVStorageDeviceAddress;\r
+  UINT64                BaseAddress;\r
+  UINT8                 BaseAddressModifier_InterruptInfo;\r
+  UINT8                 InterruptNumber;\r
+} SMBIOS_TABLE_TYPE38;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+  UINT8                 PowerUnitGroup;\r
+  SMBIOS_TABLE_STRING   Location;\r
+  SMBIOS_TABLE_STRING   DeviceName;\r
+  SMBIOS_TABLE_STRING   Manufacturer;\r
+  SMBIOS_TABLE_STRING   SerialNumber;\r
+  SMBIOS_TABLE_STRING   AssetTagNumber;\r
+  SMBIOS_TABLE_STRING   ModelPartNumber;\r
+  SMBIOS_TABLE_STRING   RevisionLevel;\r
+  UINT16                MaxPowerCapacity;\r
+  UINT16                PowerSupplyCharacteristics;\r
+  UINT16                InputVoltageProbeHandle;\r
+  UINT16                CoolingDeviceHandle;\r
+  UINT16                InputCurrentProbeHandle;\r
+} SMBIOS_TABLE_TYPE39;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+} SMBIOS_TABLE_TYPE126;\r
+\r
+typedef struct {\r
+  SMBIOS_TABLE_HEADER   Hdr;\r
+} SMBIOS_TABLE_TYPE127;\r
+\r
+typedef union {\r
+  SMBIOS_TABLE_HEADER   *Hdr;\r
+  SMBIOS_TABLE_TYPE0    *Type0;\r
+  SMBIOS_TABLE_TYPE1    *Type1;\r
+  SMBIOS_TABLE_TYPE2    *Type2;\r
+  SMBIOS_TABLE_TYPE3    *Type3;\r
+  SMBIOS_TABLE_TYPE4    *Type4;\r
+  SMBIOS_TABLE_TYPE5    *Type5;\r
+  SMBIOS_TABLE_TYPE6    *Type6;\r
+  SMBIOS_TABLE_TYPE7    *Type7;\r
+  SMBIOS_TABLE_TYPE8    *Type8;\r
+  SMBIOS_TABLE_TYPE9    *Type9;\r
+  SMBIOS_TABLE_TYPE10   *Type10;\r
+  SMBIOS_TABLE_TYPE11   *Type11;\r
+  SMBIOS_TABLE_TYPE12   *Type12;\r
+  SMBIOS_TABLE_TYPE13   *Type13;\r
+  SMBIOS_TABLE_TYPE14   *Type14;\r
+  SMBIOS_TABLE_TYPE15   *Type15;\r
+  SMBIOS_TABLE_TYPE16   *Type16;\r
+  SMBIOS_TABLE_TYPE17   *Type17;\r
+  SMBIOS_TABLE_TYPE18   *Type18;\r
+  SMBIOS_TABLE_TYPE19   *Type19;\r
+  SMBIOS_TABLE_TYPE20   *Type20;\r
+  SMBIOS_TABLE_TYPE21   *Type21;\r
+  SMBIOS_TABLE_TYPE22   *Type22;\r
+  SMBIOS_TABLE_TYPE23   *Type23;\r
+  SMBIOS_TABLE_TYPE24   *Type24;\r
+  SMBIOS_TABLE_TYPE25   *Type25;\r
+  SMBIOS_TABLE_TYPE26   *Type26;\r
+  SMBIOS_TABLE_TYPE27   *Type27;\r
+  SMBIOS_TABLE_TYPE28   *Type28;\r
+  SMBIOS_TABLE_TYPE29   *Type29;\r
+  SMBIOS_TABLE_TYPE30   *Type30;\r
+  SMBIOS_TABLE_TYPE31   *Type31;\r
+  SMBIOS_TABLE_TYPE32   *Type32;\r
+  SMBIOS_TABLE_TYPE33   *Type33;\r
+  SMBIOS_TABLE_TYPE34   *Type34;\r
+  SMBIOS_TABLE_TYPE35   *Type35;\r
+  SMBIOS_TABLE_TYPE36   *Type36;\r
+  SMBIOS_TABLE_TYPE37   *Type37;\r
+  SMBIOS_TABLE_TYPE38   *Type38;\r
+  SMBIOS_TABLE_TYPE39   *Type39;\r
+  SMBIOS_TABLE_TYPE126  *Type126;\r
+  SMBIOS_TABLE_TYPE127  *Type127;\r
+  UINT8                 *Raw;\r
+} SMBIOS_STRUCTURE_POINTER;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h
new file mode 100644 (file)
index 0000000..077498a
--- /dev/null
@@ -0,0 +1,1847 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Tpm12.h\r
+\r
+Abstract:\r
+\r
+  TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 94)\r
+\r
+  See http://trustedcomputinggroup.org for latest specification updates\r
+\r
+--*/\r
+\r
+#ifndef _TPM12_H_\r
+#define _TPM12_H_\r
+\r
+//\r
+// Structures are all packed on 1-byte alignment\r
+//\r
+\r
+#pragma pack (push)\r
+#pragma pack (1)\r
+\r
+//\r
+// Part 2, section 2.2: Basic types & Helper redefinitions\r
+//\r
+typedef UINT8                       TPM_AUTH_DATA_USAGE;\r
+typedef UINT8                       TPM_PAYLOAD_TYPE;\r
+typedef UINT8                       TPM_VERSION_BYTE;\r
+typedef UINT16                      TPM_TAG;\r
+typedef UINT16                      TPM_PROTOCOL_ID;\r
+typedef UINT16                      TPM_STARTUP_TYPE;\r
+typedef UINT16                      TPM_ENC_SCHEME;\r
+typedef UINT16                      TPM_SIG_SCHEME;\r
+typedef UINT16                      TPM_MIGRATE_SCHEME;\r
+typedef UINT16                      TPM_PHYSICAL_PRESENCE;\r
+typedef UINT16                      TPM_ENTITY_TYPE;\r
+typedef UINT16                      TPM_KEY_USAGE;\r
+typedef UINT16                      TPM_EK_TYPE;\r
+typedef UINT16                      TPM_STRUCTURE_TAG;\r
+typedef UINT16                      TPM_PLATFORM_SPECIFIC;\r
+typedef UINT32                      TPM_COMMAND_CODE;\r
+typedef UINT32                      TPM_CAPABILITY_AREA;\r
+typedef UINT32                      TPM_KEY_FLAGS;\r
+typedef UINT32                      TPM_ALGORITHM_ID;\r
+typedef UINT32                      TPM_MODIFIER_INDICATOR;\r
+typedef UINT32                      TPM_ACTUAL_COUNT;\r
+typedef UINT32                      TPM_TRANSPORT_ATTRIBUTES;\r
+typedef UINT32                      TPM_AUTHHANDLE;\r
+typedef UINT32                      TPM_DIRINDEX;\r
+typedef UINT32                      TPM_KEY_HANDLE;\r
+typedef UINT32                      TPM_PCRINDEX;\r
+typedef UINT32                      TPM_RESULT;\r
+typedef UINT32                      TPM_RESOURCE_TYPE;\r
+typedef UINT32                      TPM_KEY_CONTROL;\r
+typedef UINT32                      TPM_NV_INDEX;\r
+typedef UINT32                      TPM_FAMILY_ID;\r
+typedef UINT32                      TPM_FAMILY_VERIFICATION;\r
+typedef UINT32                      TPM_STARTUP_EFFECTS;\r
+typedef UINT32                      TPM_SYM_MODE;\r
+typedef UINT32                      TPM_FAMILY_FLAGS;\r
+typedef UINT32                      TPM_DELEGATE_INDEX;\r
+typedef UINT32                      TPM_CMK_DELEGATE;\r
+typedef UINT32                      TPM_COUNT_ID;\r
+typedef UINT32                      TPM_REDIT_COMMAND;\r
+typedef UINT32                      TPM_TRANSHANDLE;\r
+typedef UINT32                      TPM_HANDLE;\r
+typedef UINT32                      TPM_FAMILY_OPERATION;\r
+\r
+//\r
+// Part 2, section 2.2.4: Vendor specific\r
+// The following defines allow for the quick specification of a\r
+// vendor specific item.\r
+//\r
+#define TPM_Vendor_Specific32       ((UINT32) 0x00000400)\r
+#define TPM_Vendor_Specific8        ((UINT8) 0x80)\r
+\r
+//\r
+// Part 2, section 3.1: Structure TAGs\r
+//\r
+#define TPM_TAG_CONTEXTBLOB         ((TPM_STRUCTURE_TAG) 0x0001)\r
+#define TPM_TAG_CONTEXT_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0002)\r
+#define TPM_TAG_CONTEXTPOINTER      ((TPM_STRUCTURE_TAG) 0x0003)\r
+#define TPM_TAG_CONTEXTLIST         ((TPM_STRUCTURE_TAG) 0x0004)\r
+#define TPM_TAG_SIGNINFO            ((TPM_STRUCTURE_TAG) 0x0005)\r
+#define TPM_TAG_PCR_INFO_LONG       ((TPM_STRUCTURE_TAG) 0x0006)\r
+#define TPM_TAG_PERSISTENT_FLAGS    ((TPM_STRUCTURE_TAG) 0x0007)\r
+#define TPM_TAG_VOLATILE_FLAGS      ((TPM_STRUCTURE_TAG) 0x0008)\r
+#define TPM_TAG_PERSISTENT_DATA     ((TPM_STRUCTURE_TAG) 0x0009)\r
+#define TPM_TAG_VOLATILE_DATA       ((TPM_STRUCTURE_TAG) 0x000A)\r
+#define TPM_TAG_SV_DATA             ((TPM_STRUCTURE_TAG) 0x000B)\r
+#define TPM_TAG_EK_BLOB             ((TPM_STRUCTURE_TAG) 0x000C)\r
+#define TPM_TAG_EK_BLOB_AUTH        ((TPM_STRUCTURE_TAG) 0x000D)\r
+#define TPM_TAG_COUNTER_VALUE       ((TPM_STRUCTURE_TAG) 0x000E)\r
+#define TPM_TAG_TRANSPORT_INTERNAL  ((TPM_STRUCTURE_TAG) 0x000F)\r
+#define TPM_TAG_TRANSPORT_LOG_IN    ((TPM_STRUCTURE_TAG) 0x0010)\r
+#define TPM_TAG_TRANSPORT_LOG_OUT   ((TPM_STRUCTURE_TAG) 0x0011)\r
+#define TPM_TAG_AUDIT_EVENT_IN      ((TPM_STRUCTURE_TAG) 0x0012)\r
+#define TPM_TAG_AUDIT_EVENT_OUT     ((TPM_STRUCTURE_TAG) 0x0013)\r
+#define TPM_TAG_CURRENT_TICKS       ((TPM_STRUCTURE_TAG) 0x0014)\r
+#define TPM_TAG_KEY                 ((TPM_STRUCTURE_TAG) 0x0015)\r
+#define TPM_TAG_STORED_DATA12       ((TPM_STRUCTURE_TAG) 0x0016)\r
+#define TPM_TAG_NV_ATTRIBUTES       ((TPM_STRUCTURE_TAG) 0x0017)\r
+#define TPM_TAG_NV_DATA_PUBLIC      ((TPM_STRUCTURE_TAG) 0x0018)\r
+#define TPM_TAG_NV_DATA_SENSITIVE   ((TPM_STRUCTURE_TAG) 0x0019)\r
+#define TPM_TAG_DELEGATIONS         ((TPM_STRUCTURE_TAG) 0x001A)\r
+#define TPM_TAG_DELEGATE_PUBLIC     ((TPM_STRUCTURE_TAG) 0x001B)\r
+#define TPM_TAG_DELEGATE_TABLE_ROW  ((TPM_STRUCTURE_TAG) 0x001C)\r
+#define TPM_TAG_TRANSPORT_AUTH      ((TPM_STRUCTURE_TAG) 0x001D)\r
+#define TPM_TAG_TRANSPORT_PUBLIC    ((TPM_STRUCTURE_TAG) 0x001E)\r
+#define TPM_TAG_PERMANENT_FLAGS     ((TPM_STRUCTURE_TAG) 0x001F)\r
+#define TPM_TAG_STCLEAR_FLAGS       ((TPM_STRUCTURE_TAG) 0x0020)\r
+#define TPM_TAG_STANY_FLAGS         ((TPM_STRUCTURE_TAG) 0x0021)\r
+#define TPM_TAG_PERMANENT_DATA      ((TPM_STRUCTURE_TAG) 0x0022)\r
+#define TPM_TAG_STCLEAR_DATA        ((TPM_STRUCTURE_TAG) 0x0023)\r
+#define TPM_TAG_STANY_DATA          ((TPM_STRUCTURE_TAG) 0x0024)\r
+#define TPM_TAG_FAMILY_TABLE_ENTRY  ((TPM_STRUCTURE_TAG) 0x0025)\r
+#define TPM_TAG_DELEGATE_SENSITIVE  ((TPM_STRUCTURE_TAG) 0x0026)\r
+#define TPM_TAG_DELG_KEY_BLOB       ((TPM_STRUCTURE_TAG) 0x0027)\r
+#define TPM_TAG_KEY12               ((TPM_STRUCTURE_TAG) 0x0028)\r
+#define TPM_TAG_CERTIFY_INFO2       ((TPM_STRUCTURE_TAG) 0x0029)\r
+#define TPM_TAG_DELEGATE_OWNER_BLOB ((TPM_STRUCTURE_TAG) 0x002A)\r
+#define TPM_TAG_EK_BLOB_ACTIVATE    ((TPM_STRUCTURE_TAG) 0x002B)\r
+#define TPM_TAG_DAA_BLOB            ((TPM_STRUCTURE_TAG) 0x002C)\r
+#define TPM_TAG_DAA_CONTEXT         ((TPM_STRUCTURE_TAG) 0x002D)\r
+#define TPM_TAG_DAA_ENFORCE         ((TPM_STRUCTURE_TAG) 0x002E)\r
+#define TPM_TAG_DAA_ISSUER          ((TPM_STRUCTURE_TAG) 0x002F)\r
+#define TPM_TAG_CAP_VERSION_INFO    ((TPM_STRUCTURE_TAG) 0x0030)\r
+#define TPM_TAG_DAA_SENSITIVE       ((TPM_STRUCTURE_TAG) 0x0031)\r
+#define TPM_TAG_DAA_TPM             ((TPM_STRUCTURE_TAG) 0x0032)\r
+#define TPM_TAG_CMK_MIGAUTH         ((TPM_STRUCTURE_TAG) 0x0033)\r
+#define TPM_TAG_CMK_SIGTICKET       ((TPM_STRUCTURE_TAG) 0x0034)\r
+#define TPM_TAG_CMK_MA_APPROVAL     ((TPM_STRUCTURE_TAG) 0x0035)\r
+#define TPM_TAG_QUOTE_INFO2         ((TPM_STRUCTURE_TAG) 0x0036)\r
+\r
+//\r
+// Part 2, section 4: TPM Types\r
+//\r
+\r
+//\r
+// Part 2, section 4.1: TPM_RESOURCE_TYPE\r
+//\r
+#define TPM_RT_KEY                  ((TPM_RESOURCE_TYPE) 0x00000001) // The handle is a key handle and is the result of a LoadKey type operation\r
+#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\r
+#define TPM_RT_HASH                 ((TPM_RESOURCE_TYPE) 0x00000003) // Reserved for hashes\r
+#define TPM_RT_TRANS                ((TPM_RESOURCE_TYPE) 0x00000004) // The handle is for a transport session. Transport handles come from TPM_EstablishTransport\r
+#define TPM_RT_CONTEXT              ((TPM_RESOURCE_TYPE) 0x00000005) // Resource wrapped and held outside the TPM using the context save/restore commands\r
+#define TPM_RT_COUNTER              ((TPM_RESOURCE_TYPE) 0x00000006) // Reserved for counters\r
+#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\r
+#define TPM_RT_DAA_TPM              ((TPM_RESOURCE_TYPE) 0x00000008) // The value is a DAA TPM specific blob\r
+#define TPM_RT_DAA_V0               ((TPM_RESOURCE_TYPE) 0x00000009) // The value is a DAA V0 parameter\r
+#define TPM_RT_DAA_V1               ((TPM_RESOURCE_TYPE) 0x0000000A) // The value is a DAA V1 parameter\r
+\r
+//\r
+// Part 2, section 4.2: TPM_PAYLOAD_TYPE\r
+//\r
+#define TPM_PT_ASYM                 ((TPM_PAYLOAD_TYPE) 0x01) // The entity is an asymmetric key\r
+#define TPM_PT_BIND                 ((TPM_PAYLOAD_TYPE) 0x02) // The entity is bound data\r
+#define TPM_PT_MIGRATE              ((TPM_PAYLOAD_TYPE) 0x03) // The entity is a migration blob\r
+#define TPM_PT_MAINT                ((TPM_PAYLOAD_TYPE) 0x04) // The entity is a maintenance blob\r
+#define TPM_PT_SEAL                 ((TPM_PAYLOAD_TYPE) 0x05) // The entity is sealed data\r
+#define TPM_PT_MIGRATE_RESTRICTED   ((TPM_PAYLOAD_TYPE) 0x06) // The entity is a restricted-migration asymmetric key\r
+#define TPM_PT_MIGRATE_EXTERNAL     ((TPM_PAYLOAD_TYPE) 0x07) // The entity is a external migratable key\r
+#define TPM_PT_CMK_MIGRATE          ((TPM_PAYLOAD_TYPE) 0x08) // The entity is a CMK migratable blob\r
+#define TPM_PT_VENDOR_SPECIFIC      ((TPM_PAYLOAD_TYPE) 0x80) // 0x80 - 0xFF Vendor specific payloads\r
+\r
+//\r
+// Part 2, section 4.3: TPM_ENTIRY_TYPE\r
+//\r
+#define TPM_ET_KEYHANDLE            ((UINT16) 0x0001) // The entity is a keyHandle or key\r
+#define TPM_ET_OWNER                ((UINT16) 0x0002) // The entity is the TPM Owner\r
+#define TPM_ET_DATA                 ((UINT16) 0x0003) // The entity is some data\r
+#define TPM_ET_SRK                  ((UINT16) 0x0004) // The entity is the SRK\r
+#define TPM_ET_KEY                  ((UINT16) 0x0005) // The entity is a key or keyHandle\r
+#define TPM_ET_REVOKE               ((UINT16) 0x0006) // The entity is the RevokeTrust value\r
+#define TPM_ET_DEL_OWNER_BLOB       ((UINT16) 0x0007) // The entity is a delegate owner blob\r
+#define TPM_ET_DEL_ROW              ((UINT16) 0x0008) // The entity is a delegate row\r
+#define TPM_ET_DEL_KEY_BLOB         ((UINT16) 0x0009) // The entity is a delegate key blob\r
+#define TPM_ET_COUNTER              ((UINT16) 0x000A) // The entity is a counter\r
+#define TPM_ET_NV                   ((UINT16) 0x000B) // The entity is a NV index\r
+#define TPM_ET_RESERVED_HANDLE      ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting.\r
+//\r
+// TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable\r
+//\r
+#define TPM_ET_XOR                  ((UINT16) 0x0000) // ADIP encryption scheme: XOR\r
+#define TPM_ET_AES128               ((UINT16) 0x0006) // ADIP encryption scheme: AES 128 bits\r
+\r
+//\r
+// Part 2, section 4.4.1: Reserved Key Handles\r
+//\r
+#define TPM_KH_SRK                  ((TPM_KEY_HANDLE) 0x40000000) // The handle points to the SRK\r
+#define TPM_KH_OWNER                ((TPM_KEY_HANDLE) 0x40000001) // The handle points to the TPM Owner\r
+#define TPM_KH_REVOKE               ((TPM_KEY_HANDLE) 0x40000002) // The handle points to the RevokeTrust value\r
+#define TPM_KH_TRANSPORT            ((TPM_KEY_HANDLE) 0x40000003) // The handle points to the EstablishTransport static authorization\r
+#define TPM_KH_OPERATOR             ((TPM_KEY_HANDLE) 0x40000004) // The handle points to the Operator auth\r
+#define TPM_KH_ADMIN                ((TPM_KEY_HANDLE) 0x40000005) // The handle points to the delegation administration auth\r
+#define TPM_KH_EK                   ((TPM_KEY_HANDLE) 0x40000006) // The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub\r
+\r
+//\r
+// Part 2, section 4.5: TPM_STARTUP_TYPE\r
+//\r
+#define TPM_ST_CLEAR                ((TPM_STARTUP_TYPE) 0x0001) // The TPM is starting up from a clean state\r
+#define TPM_ST_STATE                ((TPM_STARTUP_TYPE) 0x0002) // The TPM is starting up from a saved state\r
+#define TPM_ST_DEACTIVATED          ((TPM_STARTUP_TYPE) 0x0003) // The TPM is to startup and set the deactivated flag to TRUE\r
+\r
+//\r
+// Part 2, section 4.6: TPM_STATUP_EFFECTS\r
+// The table makeup is still an open issue.\r
+//\r
+\r
+//\r
+// Part 2, section 4.7: TPM_PROTOCOL_ID\r
+//\r
+#define TPM_PID_OIAP                ((TPM_PROTOCOL_ID) 0x0001) // The OIAP protocol.\r
+#define TPM_PID_OSAP                ((TPM_PROTOCOL_ID) 0x0002) // The OSAP protocol.\r
+#define TPM_PID_ADIP                ((TPM_PROTOCOL_ID) 0x0003) // The ADIP protocol.\r
+#define TPM_PID_ADCP                ((TPM_PROTOCOL_ID) 0x0004) // The ADCP protocol.\r
+#define TPM_PID_OWNER               ((TPM_PROTOCOL_ID) 0x0005) // The protocol for taking ownership of a TPM.\r
+#define TPM_PID_DSAP                ((TPM_PROTOCOL_ID) 0x0006) // The DSAP protocol\r
+#define TPM_PID_TRANSPORT           ((TPM_PROTOCOL_ID) 0x0007) // The transport protocol\r
+\r
+//\r
+// Part 2, section 4.8: TPM_ALGORITHM_ID\r
+//   The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC,\r
+//   TPM_ALG_MGF1\r
+//\r
+#define TPM_ALG_RSA                 ((TPM_ALGORITHM_ID) 0x00000001) // The RSA algorithm.\r
+#define TPM_ALG_DES                 ((TPM_ALGORITHM_ID) 0x00000002) // The DES algorithm\r
+#define TPM_ALG_3DES                ((TPM_ALGORITHM_ID) 0x00000003) // The 3DES algorithm in EDE mode\r
+#define TPM_ALG_SHA                 ((TPM_ALGORITHM_ID) 0x00000004) // The SHA1 algorithm\r
+#define TPM_ALG_HMAC                ((TPM_ALGORITHM_ID) 0x00000005) // The RFC 2104 HMAC algorithm\r
+#define TPM_ALG_AES128              ((TPM_ALGORITHM_ID) 0x00000006) // The AES algorithm, key size 128\r
+#define TPM_ALG_MGF1                ((TPM_ALGORITHM_ID) 0x00000007) // The XOR algorithm using MGF1 to create a string the size of the encrypted block\r
+#define TPM_ALG_AES192              ((TPM_ALGORITHM_ID) 0x00000008) // AES, key size 192\r
+#define TPM_ALG_AES256              ((TPM_ALGORITHM_ID) 0x00000009) // AES, key size 256\r
+#define TPM_ALG_XOR                 ((TPM_ALGORITHM_ID) 0x0000000A) // XOR using the rolling nonces\r
+\r
+//\r
+// Part 2, section 4.9: TPM_PHYSICAL_PRESENCE\r
+//\r
+#define TPM_PHYSICAL_PRESENCE_HW_DISABLE    ((TPM_PHYSICAL_PRESENCE) 0x0200) // Sets the physicalPresenceHWEnable to FALSE\r
+#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE   ((TPM_PHYSICAL_PRESENCE) 0x0100) // Sets the physicalPresenceCMDEnable to FALSE\r
+#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) // Sets the physicalPresenceLifetimeLock to TRUE\r
+#define TPM_PHYSICAL_PRESENCE_HW_ENABLE     ((TPM_PHYSICAL_PRESENCE) 0x0040) // Sets the physicalPresenceHWEnable to TRUE\r
+#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE    ((TPM_PHYSICAL_PRESENCE) 0x0020) // Sets the physicalPresenceCMDEnable to TRUE\r
+#define TPM_PHYSICAL_PRESENCE_NOTPRESENT    ((TPM_PHYSICAL_PRESENCE) 0x0010) // Sets PhysicalPresence = FALSE\r
+#define TPM_PHYSICAL_PRESENCE_PRESENT       ((TPM_PHYSICAL_PRESENCE) 0x0008) // Sets PhysicalPresence = TRUE\r
+#define TPM_PHYSICAL_PRESENCE_LOCK          ((TPM_PHYSICAL_PRESENCE) 0x0004) // Sets PhysicalPresenceLock = TRUE\r
+\r
+//\r
+// Part 2, section 4.10: TPM_MIGRATE_SCHEME\r
+//\r
+#define TPM_MS_MIGRATE                      ((TPM_MIGRATE_SCHEME) 0x0001) // A public key that can be used with all TPM migration commands other than 'ReWrap' mode.\r
+#define TPM_MS_REWRAP                       ((TPM_MIGRATE_SCHEME) 0x0002) // A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob.\r
+#define TPM_MS_MAINT                        ((TPM_MIGRATE_SCHEME) 0x0003) // A public key that can be used for the Maintenance commands\r
+#define TPM_MS_RESTRICT_MIGRATE             ((TPM_MIGRATE_SCHEME) 0x0004) // The key is to be migrated to a Migration Authority.\r
+#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\r
+\r
+//\r
+// Part 2, section 4.11: TPM_EK_TYPE\r
+//\r
+#define TPM_EK_TYPE_ACTIVATE        ((TPM_EK_TYPE) 0x0001) // The blob MUST be TPM_EK_BLOB_ACTIVATE\r
+#define TPM_EK_TYPE_AUTH            ((TPM_EK_TYPE) 0x0002) // The blob MUST be TPM_EK_BLOB_AUTH\r
+\r
+//\r
+// Part 2, section 4.12: TPM_PLATFORM_SPECIFIC\r
+//\r
+#define TPM_PS_PC_11                ((TPM_PLATFORM_SPECIFIC) 0x0001) // PC Specific version 1.1\r
+#define TPM_PS_PC_12                ((TPM_PLATFORM_SPECIFIC) 0x0002) // PC Specific version 1.2\r
+#define TPM_PS_PDA_12               ((TPM_PLATFORM_SPECIFIC) 0x0003) // PDA Specific version 1.2\r
+#define TPM_PS_Server_12            ((TPM_PLATFORM_SPECIFIC) 0x0004) // Server Specific version 1.2\r
+#define TPM_PS_Mobile_12            ((TPM_PLATFORM_SPECIFIC) 0x0005) // Mobil Specific version 1.2\r
+\r
+//\r
+// Part 2, section 5: Basic Structures\r
+//\r
+\r
+//\r
+// Part 2, section 5.1: TPM_STRUCT_VER\r
+//\r
+typedef struct tdTPM_STRUCT_VER {\r
+  UINT8                             major;\r
+  UINT8                             minor;\r
+  UINT8                             revMajor;\r
+  UINT8                             revMinor;\r
+} TPM_STRUCT_VER;\r
+\r
+//\r
+// Part 2, section 5.3: TPM_VERSION\r
+//\r
+typedef struct tdTPM_VERSION {\r
+  TPM_VERSION_BYTE                  major;\r
+  TPM_VERSION_BYTE                  minor;\r
+  UINT8                             revMajor;\r
+  UINT8                             revMinor;\r
+} TPM_VERSION;\r
+\r
+//\r
+// Part 2, section 5.4: TPM_DIGEST\r
+//\r
+#define TPM_SHA1_160_HASH_LEN       0x14\r
+#define TPM_SHA1BASED_NONCE_LEN     TPM_SHA1_160_HASH_LEN\r
+\r
+typedef struct tdTPM_DIGEST{\r
+  UINT8                             digest[TPM_SHA1_160_HASH_LEN];\r
+} TPM_DIGEST;\r
+\r
+typedef TPM_DIGEST                  TPM_CHOSENID_HASH; // This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity.\r
+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.\r
+typedef TPM_DIGEST                  TPM_DIRVALUE; // This SHALL be the value of a DIR register\r
+typedef TPM_DIGEST                  TPM_HMAC;\r
+typedef TPM_DIGEST                  TPM_PCRVALUE; // The value inside of the PCR\r
+typedef TPM_DIGEST                  TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state\r
+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\r
+typedef TPM_DIGEST                  TPM_DAA_CONTEXT_SEED; // This SHALL be a random value\r
+\r
+//\r
+// Part 2, section 5.5: TPM_NONCE\r
+//\r
+typedef struct tdTPM_NONCE{\r
+  UINT8                             nonce[20];\r
+} TPM_NONCE;\r
+\r
+//\r
+// Part 2, section 5.6: TPM_AUTHDATA\r
+//\r
+typedef UINT8                       tdTPM_AUTHDATA[20];\r
+typedef tdTPM_AUTHDATA              TPM_AUTHDATA;\r
+typedef TPM_AUTHDATA                TPM_SECRET;\r
+typedef TPM_AUTHDATA                TPM_ENCAUTH;\r
+\r
+//\r
+// Part 2, section 5.7: TPM_KEY_HANDLE_LIST\r
+// Size of handle is loaded * sizeof(TPM_KEY_HANDLE)\r
+//\r
+typedef struct tdTPM_KEY_HANDLE_LIST {\r
+  UINT16                            loaded;\r
+  TPM_KEY_HANDLE                    handle[1];\r
+} TPM_KEY_HANDLE_LIST;\r
+\r
+//\r
+// Part 2, section 5.8: TPM_KEY_USAGE values\r
+//\r
+\r
+#define TPM_KEY_SIGNING             ((UINT16) 0x0010)\r
+// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be\r
+// used for signing operations, only. This means that it MUST be a leaf of the\r
+// Protected Storage key hierarchy.\r
+\r
+#define TPM_KEY_STORAGE             ((UINT16) 0x0011)\r
+// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap\r
+// and unwrap other keys in the Protected Storage hierarchy\r
+\r
+#define TPM_KEY_IDENTITY            ((UINT16) 0x0012)\r
+// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for\r
+// operations that require a TPM identity, only.\r
+\r
+#define TPM_KEY_AUTHCHANGE          ((UINT16) 0x0013)\r
+// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during\r
+// the ChangeAuthAsym process, only.\r
+\r
+#define TPM_KEY_BIND                ((UINT16) 0x0014)\r
+// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and\r
+// TPM_Unbind operations only.\r
+\r
+#define TPM_KEY_LEGACY              ((UINT16) 0x0015)\r
+// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding\r
+// operations. The key MAY be used for both signing and binding operations.\r
+// The TPM_KEY_LEGACY key type is to allow for use by applications where both\r
+// signing and encryption operations occur with the same key. The use of this\r
+// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a\r
+// key in use for TPM_MigrateKey\r
+\r
+#define TPM_KEY_MIGRATE             ((UINT16) 0x0016)\r
+// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey\r
+\r
+//\r
+// Part 2, section 5.8.1: Encryption/Signature schemes\r
+//\r
+\r
+#define TPM_ES_NONE                 ((TPM_ENC_SCHEME) 0x0001)\r
+#define TPM_ES_RSAESPKCSv15         ((TPM_ENC_SCHEME) 0x0002)\r
+#define TPM_ES_RSAESOAEP_SHA1_MGF1  ((TPM_ENC_SCHEME) 0x0003)\r
+#define TPM_ES_SYM_CNT              ((TPM_ENC_SCHEME) 0x0004)\r
+#define TPM_ES_SYM_OFB              ((TPM_ENC_SCHEME) 0x0005)\r
+\r
+#define TPM_SS_NONE                 ((TPM_SIG_SCHEME) 0x0001)\r
+#define TPM_SS_RSASSAPKCS1v15_SHA1  ((TPM_SIG_SCHEME) 0x0002)\r
+#define TPM_SS_RSASSAPKCS1v15_DER   ((TPM_SIG_SCHEME) 0x0003)\r
+#define TPM_SS_RSASSAPKCS1v15_INFO  ((TPM_SIG_SCHEME) 0x0004)\r
+\r
+//\r
+// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values\r
+//\r
+#define TPM_AUTH_NEVER              ((TPM_AUTH_DATA_USAGE) 0x00)\r
+#define TPM_AUTH_ALWAYS             ((TPM_AUTH_DATA_USAGE) 0x01)\r
+#define TPM_AUTH_PRIV_USE_ONLY      ((TPM_AUTH_DATA_USAGE) 0x03)\r
+\r
+//\r
+// Part 2, section 5.10: TPM_KEY_FLAGS\r
+//\r
+enum tdTPM_KEY_FLAGS {\r
+  redirection                       = 0x00000001,\r
+  migratable                        = 0x00000002,\r
+  isVolatile                        = 0x00000004,\r
+  pcrIgnoredOnRead                  = 0x00000008,\r
+  migrateAuthority                  = 0x00000010\r
+};\r
+\r
+//\r
+// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE\r
+//\r
+typedef struct tdTPM_CHANGEAUTH_VALIDATE {\r
+  TPM_SECRET                        newAuthSecret;\r
+  TPM_NONCE                         n1;\r
+} TPM_CHANGEAUTH_VALIDATE;\r
+\r
+//\r
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH\r
+//   decalared after section 10 to catch declaration of TPM_PUBKEY\r
+//\r
+// Part 2 section 10.1: TPM_KEY_PARMS\r
+//   [size_is(parmSize)] BYTE* parms;\r
+//\r
+typedef struct tdTPM_KEY_PARMS {\r
+  TPM_ALGORITHM_ID                  algorithmID;\r
+  TPM_ENC_SCHEME                    encScheme;\r
+  TPM_SIG_SCHEME                    sigScheme;\r
+  UINT32                            parmSize;\r
+  UINT8                             *parms;\r
+} TPM_KEY_PARMS;\r
+\r
+//\r
+// Part 2, section 10.4: TPM_STORE_PUBKEY\r
+//\r
+typedef struct tdTPM_STORE_PUBKEY {\r
+  UINT32                            keyLength;\r
+  UINT8                             key[1];\r
+} TPM_STORE_PUBKEY;\r
+\r
+//\r
+// Part 2, section 10.5: TPM_PUBKEY\r
+//\r
+typedef struct tdTPM_PUBKEY{\r
+  TPM_KEY_PARMS                     algorithmParms;\r
+  TPM_STORE_PUBKEY                  pubKey;\r
+} TPM_PUBKEY;\r
+\r
+//\r
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH\r
+//\r
+typedef struct tdTPM_MIGRATIONKEYAUTH{\r
+  TPM_PUBKEY                        migrationKey;\r
+  TPM_MIGRATE_SCHEME                migrationScheme;\r
+  TPM_DIGEST                        digest;\r
+} TPM_MIGRATIONKEYAUTH;\r
+\r
+//\r
+// Part 2, section 5.13: TPM_COUNTER_VALUE\r
+//\r
+typedef struct tdTPM_COUNTER_VALUE{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT8                             label[4];\r
+  TPM_ACTUAL_COUNT                  counter;\r
+} TPM_COUNTER_VALUE;\r
+\r
+//\r
+// Part 2, section 5.14: TPM_SIGN_INFO\r
+//   Size of data indicated by dataLen\r
+//\r
+typedef struct tdTPM_SIGN_INFO {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT8                             fixed[4];\r
+  TPM_NONCE                         replay;\r
+  UINT32                            dataLen;\r
+  UINT8                             *data;\r
+} TPM_SIGN_INFO;\r
+\r
+//\r
+// Part 2, section 5.15: TPM_MSA_COMPOSITE\r
+//   Number of migAuthDigest indicated by MSAlist\r
+//\r
+typedef struct tdTPM_MSA_COMPOSITE {\r
+  UINT32                            MSAlist;\r
+  TPM_DIGEST                        migAuthDigest[1];\r
+} TPM_MSA_COMPOSITE;\r
+\r
+//\r
+// Part 2, section 5.16: TPM_CMK_AUTH\r
+//\r
+typedef struct tdTPM_CMK_AUTH{\r
+  TPM_DIGEST                        migrationAuthorityDigest;\r
+  TPM_DIGEST                        destinationKeyDigest;\r
+  TPM_DIGEST                        sourceKeyDigest;\r
+} TPM_CMK_AUTH;\r
+\r
+//\r
+// Part 2, section 5.17: TPM_CMK_DELEGATE\r
+//\r
+#define TPM_CMK_DELEGATE_SIGNING    (((TPM_CMK_DELEGATE)1) << 31)\r
+#define TPM_CMK_DELEGATE_STORAGE    (((TPM_CMK_DELEGATE)1) << 30)\r
+#define TPM_CMK_DELEGATE_BIND       (((TPM_CMK_DELEGATE)1) << 29)\r
+#define TPM_CMK_DELEGATE_LEGACY     (((TPM_CMK_DELEGATE)1) << 28)\r
+#define TPM_CMK_DELEGATE_MIGRATE    (((TPM_CMK_DELEGATE)1) << 27)\r
+\r
+//\r
+// Part 2, section 5.18: TPM_SELECT_SIZE\r
+//\r
+typedef struct tdTPM_SELECT_SIZE {\r
+  UINT8                             major;\r
+  UINT8                             minor;\r
+  UINT16                            reqSize;\r
+} TPM_SELECT_SIZE;\r
+\r
+//\r
+// Part 2, section 5,19: TPM_CMK_MIGAUTH\r
+//\r
+typedef struct tdTPM_CMK_MIGAUTH{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_DIGEST                        msaDigest;\r
+  TPM_DIGEST                        pubKeyDigest;\r
+} TPM_CMK_MIGAUTH;\r
+\r
+//\r
+// Part 2, section 5.20: TPM_CMK_SIGTICKET\r
+//\r
+typedef struct tdTPM_CMK_SIGTICKET{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_DIGEST                        verKeyDigest;\r
+  TPM_DIGEST                        signedData;\r
+} TPM_CMK_SIGTICKET;\r
+\r
+//\r
+// Part 2, section 5.21: TPM_CMK_MA_APPROVAL\r
+//\r
+typedef struct tdTPM_CMK_MA_APPROVAL{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_DIGEST                        migrationAuthorityDigest;\r
+} TPM_CMK_MA_APPROVAL;\r
+\r
+//\r
+// Part 2, section 6: Command Tags\r
+//\r
+#define TPM_TAG_RQU_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C1)\r
+#define TPM_TAG_RQU_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C2)\r
+#define TPM_TAG_RQU_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C3)\r
+#define TPM_TAG_RSP_COMMAND         ((TPM_STRUCTURE_TAG) 0x00C4)\r
+#define TPM_TAG_RSP_AUTH1_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C5)\r
+#define TPM_TAG_RSP_AUTH2_COMMAND   ((TPM_STRUCTURE_TAG) 0x00C6)\r
+\r
+//\r
+// Part 2, section 7.1: TPM_PERMANENT_FLAGS\r
+//\r
+typedef struct tdTPM_PERMANENT_FLAGS{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  BOOLEAN                           disable;\r
+  BOOLEAN                           ownership;\r
+  BOOLEAN                           deactivated;\r
+  BOOLEAN                           readPubek;\r
+  BOOLEAN                           disableOwnerClear;\r
+  BOOLEAN                           allowMaintenance;\r
+  BOOLEAN                           physicalPresenceLifetimeLock;\r
+  BOOLEAN                           physicalPresenceHWEnable;\r
+  BOOLEAN                           physicalPresenceCMDEnable;\r
+  BOOLEAN                           CEKPUsed;\r
+  BOOLEAN                           TPMpost;\r
+  BOOLEAN                           TPMpostLock;\r
+  BOOLEAN                           FIPS;\r
+  BOOLEAN                           operator;\r
+  BOOLEAN                           enableRevokeEK;\r
+  BOOLEAN                           nvLocked;\r
+  BOOLEAN                           readSRKPub;\r
+  BOOLEAN                           tpmEstablished;\r
+  BOOLEAN                           maintenanceDone;\r
+} TPM_PERMANENT_FLAGS;\r
+\r
+//\r
+// Part 2, section 7.1.1: PERMANENT_FLAGS Subcap for SetCapability\r
+//\r
+#define TPM_PF_DISABLE                      ((TPM_CAPABILITY_AREA) 1)\r
+#define TPM_PF_OWNERSHIP                    ((TPM_CAPABILITY_AREA) 2)\r
+#define TPM_PF_DEACTIVATED                  ((TPM_CAPABILITY_AREA) 3)\r
+#define TPM_PF_READPUBEK                    ((TPM_CAPABILITY_AREA) 4)\r
+#define TPM_PF_DISABLEOWNERCLEAR            ((TPM_CAPABILITY_AREA) 5)\r
+#define TPM_PF_ALLOWMAINTENANCE             ((TPM_CAPABILITY_AREA) 6)\r
+#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((TPM_CAPABILITY_AREA) 7)\r
+#define TPM_PF_PHYSICALPRESENCEHWENABLE     ((TPM_CAPABILITY_AREA) 8)\r
+#define TPM_PF_PHYSICALPRESENCECMDENABLE    ((TPM_CAPABILITY_AREA) 9)\r
+#define TPM_PF_CEKPUSED                     ((TPM_CAPABILITY_AREA) 10)\r
+#define TPM_PF_TPMPOST                      ((TPM_CAPABILITY_AREA) 11)\r
+#define TPM_PF_TPMPOSTLOCK                  ((TPM_CAPABILITY_AREA) 12)\r
+#define TPM_PF_FIPS                         ((TPM_CAPABILITY_AREA) 13)\r
+#define TPM_PF_OPERATOR                     ((TPM_CAPABILITY_AREA) 14)\r
+#define TPM_PF_ENABLEREVOKEEK               ((TPM_CAPABILITY_AREA) 15)\r
+#define TPM_PF_NV_LOCKED                    ((TPM_CAPABILITY_AREA) 16)\r
+#define TPM_PF_READSRKPUB                   ((TPM_CAPABILITY_AREA) 17)\r
+#define TPM_PF_TPMESTABLISHED               ((TPM_CAPABILITY_AREA) 18)\r
+#define TPM_PF_MAINTENANCEDONE              ((TPM_CAPABILITY_AREA) 19)\r
+\r
+//\r
+// Part 2, section 7.2: TPM_STCLEAR_FLAGS\r
+//\r
+typedef struct tdTPM_STCLEAR_FLAGS{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  BOOLEAN                           deactivated;\r
+  BOOLEAN                           disableForceClear;\r
+  BOOLEAN                           physicalPresence;\r
+  BOOLEAN                           physicalPresenceLock;\r
+  BOOLEAN                           bGlobalLock;\r
+} TPM_STCLEAR_FLAGS;\r
+\r
+//\r
+// Part 2, section 7.2.1: STCLEAR_FLAGS Subcap for SetCapability\r
+//\r
+#define TPM_SF_DEACTIVATED          ((TPM_CAPABILITY_AREA) 1)\r
+#define TPM_SF_DISABLEFORCECLEAR    ((TPM_CAPABILITY_AREA) 2)\r
+#define TPM_SF_PHYSICALPRESENCE     ((TPM_CAPABILITY_AREA) 3)\r
+#define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4)\r
+#define TPM_SF_BGLOBALLOCK          ((TPM_CAPABILITY_AREA) 5)\r
+\r
+//\r
+// Part 2, section 7.3: TPM_STANY_FLAGS\r
+//\r
+typedef struct tdTPM_STANY_FLAGS{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  BOOLEAN                           postInitialise;\r
+  TPM_MODIFIER_INDICATOR            localityModifier;\r
+  BOOLEAN                           transportExclusive;\r
+  BOOLEAN                           TOSPresent;\r
+} TPM_STANY_FLAGS;\r
+\r
+//\r
+// Part 2, section 7.3.1: STANY_FLAGS Subcap for SetCapability\r
+//\r
+#define TPM_AF_POSTINITIALISE       ((TPM_CAPABILITY_AREA) 1)\r
+#define TPM_AF_LOCALITYMODIFIER     ((TPM_CAPABILITY_AREA) 2)\r
+#define TPM_AF_TRANSPORTEXCLUSIVE   ((TPM_CAPABILITY_AREA) 3)\r
+#define TPM_AF_TOSPRESENT           ((TPM_CAPABILITY_AREA) 4)\r
+\r
+//\r
+// All those structures (section 7.4, 7.5, 7.6) are not normative and \r
+// thus no definitions here\r
+//\r
+// Part 2, section 7.4: TPM_PERMANENT_DATA\r
+//\r
+//#define TPM_MIN_COUNTERS            4   // the minimum number of counters is 4\r
+//#define TPM_DELEGATE_KEY            TPM_KEY\r
+//#define TPM_NUM_PCR                 16\r
+//#define TPM_MAX_NV_WRITE_NOOWNER    64\r
+//typedef struct tdTPM_PERMANENT_DATA\r
+//{\r
+//    TPM_STRUCTURE_TAG               tag;\r
+//    UINT8                           revMajor;\r
+//    UINT8                           revMinor;\r
+//    TPM_NONCE                       tpmProof;\r
+//    TPM_NONCE                       ekReset;\r
+//    TPM_SECRET                      ownerAuth;\r
+//    TPM_SECRET                      operatorAuth;\r
+//    TPM_DIRVALUE                    authDIR[1];\r
+//    TPM_PUBKEY                      manuMaintPub;\r
+//    TPM_KEY                         endorsementKey;\r
+//    TPM_KEY                         srk;\r
+//    TPM_KEY                         contextKey;\r
+//    TPM_KEY                         delegateKey;\r
+//    TPM_COUNTER_VALUE               auditMonotonicCounter;\r
+//    TPM_COUNTER_VALUE               monitonicCounter[TPM_MIN_COUNTERS];\r
+//    TPM_PCR_ATTRIBUTES              pcrAttrib[TPM_NUM_PCR];\r
+//    UINT8                           ordinalAuditStatus[];\r
+//    UINT8                           *rngState;\r
+//    TPM_FAMILY_TABLE                familyTable;\r
+//    TPM_DELEGATE_TABLE              delegateTable;\r
+//    UINT32                          maxNVBufSize;\r
+//    UINT32                          lastFamilyID;\r
+//    UINT32                          noOwnerNVWrite;\r
+//    TPM_CMK_DELEGATE                restrictDelegate;\r
+//    TPM_DAA_TPM_SEED                tpmDAASeed;\r
+//} TPM_PERMANENT_DATA;\r
+\r
+//\r
+// Part 2, section 7.5: TPM_STCLEAR_DATA\r
+//   available inside TPM only\r
+//\r
+//typedef struct tdTPM_STCLEAR_DATA\r
+//{\r
+//    TPM_STRUCTURE_TAG               tag;\r
+//    TPM_NONCE                       contextNonceKey;\r
+//    TPM_COUNT_ID                    countID;\r
+//    UINT32                          ownerReference;\r
+//    BOOLEAN                         disableResetLock;\r
+//} TPM_STCLEAR_DATA;\r
+\r
+//\r
+// Part 2, section 7.6: TPM_STANY_DATA\r
+//   available inside TPM only\r
+//\r
+//typedef struct tdTPM_STANY_DATA\r
+//{\r
+//    TPM_STRUCTURE_TAG               tag;\r
+//    TPM_NONCE                       contextNonceSession;\r
+//    TPM_DIGEST                      auditDigest;\r
+//    TPM_CURRENT_TICKS               currentTicks;\r
+//    UINT32                          contextCount;\r
+//    UINT32                          contextList[TPM_MIN_SESSION_LIST];\r
+//    TPM_SESSION_DATA                sessions[TPM_MIN_SESSIONS];\r
+//} TPM_STANY_DATA;\r
+\r
+//\r
+// Part 2, section 8: PCR Structures\r
+// \r
+\r
+//\r
+// Part 2, section 8.1: TPM_PCR_SELECTION\r
+//   Size of pcrSelect[] indicated by sizeOfSelect\r
+//\r
+typedef struct tdTPM_PCR_SELECTION {\r
+  UINT16                            sizeOfSelect;\r
+  UINT8                             pcrSelect[1];\r
+} TPM_PCR_SELECTION;\r
+\r
+//\r
+// Part 2, section 8.2: TPM_PCR_COMPOSITE\r
+//   Size of pcrValue[] indicated by valueSize\r
+//\r
+typedef struct tdTPM_PCR_COMPOSITE {\r
+  TPM_PCR_SELECTION                 select;\r
+  UINT32                            valueSize;\r
+  TPM_PCRVALUE                      pcrValue[1];\r
+} TPM_PCR_COMPOSITE;\r
+\r
+//\r
+// Part 2, section 8.3: TPM_PCR_INFO\r
+//\r
+typedef struct tdTPM_PCR_INFO {\r
+  TPM_PCR_SELECTION                 pcrSelection;\r
+  TPM_COMPOSITE_HASH                digestAtRelease;\r
+  TPM_COMPOSITE_HASH                digestAtCreation;\r
+} TPM_PCR_INFO;\r
+\r
+//\r
+// Part 2, section 8.6: TPM_LOCALITY_SELECTION\r
+//\r
+typedef UINT8                       TPM_LOCALITY_SELECTION;\r
+\r
+#define TPM_LOC_FOUR                ((UINT8) 0x10)\r
+#define TPM_LOC_THREE               ((UINT8) 0x08)\r
+#define TPM_LOC_TWO                 ((UINT8) 0x04)\r
+#define TPM_LOC_ONE                 ((UINT8) 0x02)\r
+#define TPM_LOC_ZERO                ((UINT8) 0x01)\r
+\r
+//\r
+// Part 2, section 8.4: TPM_PCR_INFO_LONG\r
+//\r
+typedef struct tdTPM_PCR_INFO_LONG {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_LOCALITY_SELECTION            localityAtCreation;\r
+  TPM_LOCALITY_SELECTION            localityAtRelease;\r
+  TPM_PCR_SELECTION                 creationPCRSelection;\r
+  TPM_PCR_SELECTION                 releasePCRSelection;\r
+  TPM_COMPOSITE_HASH                digestAtCreation;\r
+  TPM_COMPOSITE_HASH                digestAtRelease;\r
+} TPM_PCR_INFO_LONG;\r
+\r
+//\r
+// Part 2, section 8.5: TPM_PCR_INFO_SHORT\r
+//\r
+typedef struct tdTPM_PCR_INFO_SHORT{\r
+  TPM_PCR_SELECTION                 pcrSelection;\r
+  TPM_LOCALITY_SELECTION            localityAtRelease;\r
+  TPM_COMPOSITE_HASH                digestAtRelease;\r
+} TPM_PCR_INFO_SHORT;\r
+\r
+//\r
+// Part 2, section 8.8: TPM_PCR_ATTRIBUTES\r
+//\r
+typedef struct tdTPM_PCR_ATTRIBUTES{\r
+  BOOLEAN                           pcrReset;\r
+  TPM_LOCALITY_SELECTION            pcrExtendLocal;\r
+  TPM_LOCALITY_SELECTION            pcrResetLocal;\r
+} TPM_PCR_ATTRIBUTES;\r
+\r
+//\r
+// Part 2, section 9: Storage Structures\r
+//\r
+\r
+//\r
+// Part 2, section 9.1: TPM_STORED_DATA\r
+//   [size_is(sealInfoSize)] BYTE* sealInfo;\r
+//   [size_is(encDataSize)] BYTE* encData;\r
+//\r
+typedef struct tdTPM_STORED_DATA {\r
+  TPM_STRUCT_VER                    ver;\r
+  UINT32                            sealInfoSize;\r
+  UINT8                             *sealInfo;\r
+  UINT32                            encDataSize;\r
+  UINT8                             *encData;\r
+} TPM_STORED_DATA;\r
+\r
+//\r
+// Part 2, section 9.2: TPM_STORED_DATA12\r
+//   [size_is(sealInfoSize)] BYTE* sealInfo;\r
+//   [size_is(encDataSize)] BYTE* encData;\r
+//\r
+typedef struct tdTPM_STORED_DATA12 {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_ENTITY_TYPE                   et;\r
+  UINT32                            sealInfoSize;\r
+  UINT8                             *sealInfo;\r
+  UINT32                            encDataSize;\r
+  UINT8                             *encData;\r
+} TPM_STORED_DATA12;\r
+\r
+//\r
+// Part 2, section 9.3: TPM_SEALED_DATA\r
+//   [size_is(dataSize)] BYTE* data;\r
+//\r
+typedef struct tdTPM_SEALED_DATA {\r
+  TPM_PAYLOAD_TYPE                  payload;\r
+  TPM_SECRET                        authData;\r
+  TPM_NONCE                         tpmProof;\r
+  TPM_DIGEST                        storedDigest;\r
+  UINT32                            dataSize;\r
+  UINT8                             *data;\r
+} TPM_SEALED_DATA;\r
+\r
+//\r
+// Part 2, section 9.4: TPM_SYMMETRIC_KEY\r
+//   [size_is(size)] BYTE* data;\r
+//\r
+typedef struct tdTPM_SYMMETRIC_KEY {\r
+  TPM_ALGORITHM_ID                  algId;\r
+  TPM_ENC_SCHEME                    encScheme;\r
+  UINT16                            dataSize;\r
+  UINT8                             *data;\r
+} TPM_SYMMETRIC_KEY;\r
+\r
+//\r
+// Part 2, section 9.5: TPM_BOUND_DATA\r
+//\r
+typedef struct tdTPM_BOUND_DATA {\r
+  TPM_STRUCT_VER                    ver;\r
+  TPM_PAYLOAD_TYPE                  payload;\r
+  UINT8                             payloadData[1];\r
+} TPM_BOUND_DATA;\r
+\r
+//\r
+// Part 2 section 10: TPM_KEY complex\r
+// \r
+\r
+//\r
+// Part 2, section 10.2: TPM_KEY\r
+//   [size_is(encDataSize)] BYTE* encData;\r
+//\r
+typedef struct tdTPM_KEY{\r
+  TPM_STRUCT_VER                    ver;\r
+  TPM_KEY_USAGE                     keyUsage;\r
+  TPM_KEY_FLAGS                     keyFlags;\r
+  TPM_AUTH_DATA_USAGE               authDataUsage;\r
+  TPM_KEY_PARMS                     algorithmParms;\r
+  UINT32                            PCRInfoSize;\r
+  UINT8                             *PCRInfo;\r
+  TPM_STORE_PUBKEY                  pubKey;\r
+  UINT32                            encDataSize;\r
+  UINT8                             *encData;\r
+} TPM_KEY;\r
+\r
+//\r
+// Part 2, section 10.3: TPM_KEY12\r
+//   [size_is(encDataSize)] BYTE* encData;\r
+//\r
+typedef struct tdTPM_KEY12{\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT16                            fill;\r
+  TPM_KEY_USAGE                     keyUsage;\r
+  TPM_KEY_FLAGS                     keyFlags;\r
+  TPM_AUTH_DATA_USAGE               authDataUsage;\r
+  TPM_KEY_PARMS                     algorithmParms;\r
+  UINT32                            PCRInfoSize;\r
+  UINT8                             *PCRInfo;\r
+  TPM_STORE_PUBKEY                  pubKey;\r
+  UINT32                            encDataSize;\r
+  UINT8                             *encData;\r
+} TPM_KEY12;\r
+\r
+//\r
+// Part 2, section 10.7: TPM_STORE_PRIVKEY\r
+//   [size_is(keyLength)] BYTE* key;\r
+//\r
+typedef struct tdTPM_STORE_PRIVKEY {\r
+  UINT32                            keyLength;\r
+  UINT8                             *key;\r
+} TPM_STORE_PRIVKEY;\r
+\r
+//\r
+// Part 2, section 10.6: TPM_STORE_ASYMKEY\r
+//\r
+typedef struct tdTPM_STORE_ASYMKEY {                // pos len total\r
+  TPM_PAYLOAD_TYPE                  payload;        // 0    1   1\r
+  TPM_SECRET                        usageAuth;      // 1    20  21\r
+  TPM_SECRET                        migrationAuth;  // 21   20  41\r
+  TPM_DIGEST                        pubDataDigest;  // 41   20  61\r
+  TPM_STORE_PRIVKEY                 privKey;        // 61 132-151 193-214\r
+} TPM_STORE_ASYMKEY;\r
+\r
+//\r
+// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY\r
+//   [size_is(partPrivKeyLen)] BYTE* partPrivKey;\r
+//\r
+typedef struct tdTPM_MIGRATE_ASYMKEY {              // pos  len  total\r
+  TPM_PAYLOAD_TYPE                  payload;        //   0    1       1\r
+  TPM_SECRET                        usageAuth;      //   1   20      21\r
+  TPM_DIGEST                        pubDataDigest;  //  21   20      41\r
+  UINT32                            partPrivKeyLen; //  41    4      45\r
+  UINT8                             *partPrivKey;   //  45 112-127 157-172\r
+} TPM_MIGRATE_ASYMKEY;\r
+\r
+//\r
+// Part 2, section 10.9: TPM_KEY_CONTROL\r
+//\r
+#define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001)\r
+\r
+//\r
+// Part 2, section 11: Signed Structures\r
+//\r
+\r
+typedef struct tdTPM_CERTIFY_INFO                           \r
+{\r
+    TPM_STRUCT_VER                  version;\r
+    TPM_KEY_USAGE                   keyUsage;\r
+    TPM_KEY_FLAGS                   keyFlags;\r
+    TPM_AUTH_DATA_USAGE             authDataUsage;\r
+    TPM_KEY_PARMS                   algorithmParms;\r
+    TPM_DIGEST                      pubkeyDigest;\r
+    TPM_NONCE                       data;\r
+    BOOLEAN                         parentPCRStatus;\r
+    UINT32                          PCRInfoSize;\r
+    UINT8                           *PCRInfo;\r
+} TPM_CERTIFY_INFO;\r
+\r
+typedef struct tdTPM_CERTIFY_INFO2\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    UINT8                           fill;\r
+    TPM_PAYLOAD_TYPE                payloadType;\r
+    TPM_KEY_USAGE                   keyUsage;\r
+    TPM_KEY_FLAGS                   keyFlags;\r
+    TPM_AUTH_DATA_USAGE             authDataUsage;\r
+    TPM_KEY_PARMS                   algorithmParms;\r
+    TPM_DIGEST                      pubkeyDigest;\r
+    TPM_NONCE                       data;\r
+    BOOLEAN                         parentPCRStatus;\r
+    UINT32                          PCRInfoSize;\r
+    UINT8                           *PCRInfo;\r
+    UINT32                          migrationAuthoritySize;\r
+    UINT8                           *migrationAuthority;\r
+} TPM_CERTIFY_INFO2;\r
+\r
+typedef struct tdTPM_QUOTE_INFO                            \r
+{\r
+    TPM_STRUCT_VER                  version;\r
+    UINT8                           fixed[4];\r
+    TPM_COMPOSITE_HASH              digestValue;\r
+    TPM_NONCE                       externalData;\r
+} TPM_QUOTE_INFO;\r
+\r
+typedef struct tdTPM_QUOTE_INFO2\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    UINT8                           fixed[4];\r
+    TPM_NONCE                       externalData;\r
+    TPM_PCR_INFO_SHORT              infoShort;\r
+} TPM_QUOTE_INFO2;\r
+\r
+//\r
+// Part 2, section 12: Identity Structures\r
+//\r
+\r
+typedef struct tdTPM_EK_BLOB\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_EK_TYPE                     ekType;\r
+    UINT32                          blobSize;\r
+    UINT8                           *blob;\r
+} TPM_EK_BLOB;\r
+\r
+typedef struct tdTPM_EK_BLOB_ACTIVATE\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_SYMMETRIC_KEY               sessionKey;\r
+    TPM_DIGEST                      idDigest;\r
+    TPM_PCR_INFO_SHORT              pcrInfo;\r
+} TPM_EK_BLOB_ACTIVATE;\r
+\r
+typedef struct tdTPM_EK_BLOB_AUTH\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_SECRET                      authValue;\r
+} TPM_EK_BLOB_AUTH;\r
+\r
+\r
+// TPM_CHOSENID_HASH = SHA(identityLabel || privacyCA)\r
+typedef TPM_DIGEST                  TPM_CHOSENID_HASH;\r
+\r
+typedef struct tdTPM_IDENTITY_CONTENTS\r
+{\r
+    TPM_STRUCT_VER                  ver;\r
+    UINT32                          ordinal;\r
+    TPM_CHOSENID_HASH               labelPrivCADigest;\r
+    TPM_PUBKEY                      identityPubKey;\r
+} TPM_IDENTITY_CONTENTS;\r
+\r
+typedef struct tdTPM_IDENTITY_REQ                          \r
+{\r
+    UINT32                          asymSize;\r
+    UINT32                          symSize;\r
+    TPM_KEY_PARMS                   asymAlgorithm;\r
+    TPM_KEY_PARMS                   symAlgorithm;\r
+    UINT8                           *asymBlob;\r
+    UINT8                           *symBlob;\r
+} TPM_IDENTITY_REQ;\r
+\r
+typedef struct tdTPM_IDENTITY_PROOF                        \r
+{\r
+    TPM_STRUCT_VER                  ver;\r
+    UINT32                          labelSize;\r
+    UINT32                          identityBindingSize;\r
+    UINT32                          endorsementSize;\r
+    UINT32                          platformSize;\r
+    UINT32                          conformanceSize;\r
+    TPM_PUBKEY                      identityKey;\r
+    UINT8                           *labelArea;\r
+    UINT8                           *identityBinding;\r
+    UINT8                           *endorsementCredential;\r
+    UINT8                           *platformCredential;\r
+    UINT8                           *conformanceCredential;\r
+} TPM_IDENTITY_PROOF;\r
+\r
+typedef struct tdTPM_ASYM_CA_CONTENTS                      \r
+{\r
+    TPM_SYMMETRIC_KEY               sessionKey;\r
+    TPM_DIGEST                      idDigest;\r
+} TPM_ASYM_CA_CONTENTS;\r
+\r
+typedef struct tdTPM_SYM_CA_ATTESTATION\r
+{\r
+    UINT32                          credSize;\r
+    TPM_KEY_PARMS                   algorithm;\r
+    UINT8                           *credential;\r
+} TPM_SYM_CA_ATTESTATION;\r
+\r
+//\r
+// Part 2, section 15: TPM_CURRENT_TICKS\r
+//   Placed here out of order because definitions are used in section 13.\r
+//\r
+typedef struct tdTPM_CURRENT_TICKS {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT64                            currentTicks;\r
+  UINT16                            tickRate;\r
+  TPM_NONCE                         tickNonce;\r
+} TPM_CURRENT_TICKS;\r
+\r
+//\r
+// Part 2, section 13: Transport structures\r
+//\r
+\r
+#define TPM_TRANSPORT_ENCRYPT       ((UINT32)0x00000001)\r
+#define TPM_TRANSPORT_LOG           ((UINT32)0x00000002)\r
+#define TPM_TRANSPORT_EXCLUSIVE     ((UINT32)0x00000004)\r
+\r
+typedef struct tdTPM_TRANSPORT_PUBLIC\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_TRANSPORT_ATTRIBUTES        transAttributes;\r
+    TPM_ALGORITHM_ID                algId;\r
+    TPM_ENC_SCHEME                  encScheme;\r
+} TPM_TRANSPORT_PUBLIC;\r
+\r
+typedef struct tdTPM_TRANSPORT_INTERNAL\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_AUTHDATA                    authData;\r
+    TPM_TRANSPORT_PUBLIC            transPublic;\r
+    TPM_TRANSHANDLE                 transHandle;\r
+    TPM_NONCE                       transNonceEven;\r
+    TPM_DIGEST                      transDigest;\r
+} TPM_TRANSPORT_INTERNAL;\r
+\r
+typedef struct tdTPM_TRANSPORT_LOG_IN\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DIGEST                      parameters;\r
+    TPM_DIGEST                      pubKeyHash;\r
+} TPM_TRANSPORT_LOG_IN;\r
+\r
+typedef struct tdTPM_TRANSPORT_LOG_OUT\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_CURRENT_TICKS               currentTicks;\r
+    TPM_DIGEST                      parameters;\r
+    TPM_MODIFIER_INDICATOR          locality;\r
+} TPM_TRANSPORT_LOG_OUT;\r
+\r
+typedef struct tdTPM_TRANSPORT_AUTH\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_AUTHDATA                    authData;\r
+} TPM_TRANSPORT_AUTH;\r
+\r
+//\r
+// Part 2, section 14: Audit Structures\r
+//\r
+\r
+typedef struct tdTPM_AUDIT_EVENT_IN\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DIGEST                      inputParms;\r
+    TPM_COUNTER_VALUE               auditCount;\r
+} TPM_AUDIT_EVENT_IN;\r
+\r
+typedef struct tdTPM_AUDIT_EVENT_OUT\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_COMMAND_CODE                ordinal;\r
+    TPM_DIGEST                      outputParms;\r
+    TPM_COUNTER_VALUE               auditCount;\r
+    TPM_RESULT                      returnCode;\r
+} TPM_AUDIT_EVENT_OUT;\r
+\r
+//\r
+// Part 2, section 16: Return Codes\r
+//\r
+#ifndef TPM_BASE\r
+#error "TPM Error Codes require definition of TPM_BASE"\r
+#endif\r
+\r
+#define TPM_VENDOR_ERROR            TPM_Vendor_Specific32\r
+#define TPM_NON_FATAL               0x00000800\r
+\r
+#define TPM_SUCCESS                 ((TPM_RESULT) TPM_BASE)\r
+#define TPM_AUTHFAIL                ((TPM_RESULT) (TPM_BASE + 1))\r
+#define TPM_BADINDEX                ((TPM_RESULT) (TPM_BASE + 2))\r
+#define TPM_BAD_PARAMETER           ((TPM_RESULT) (TPM_BASE + 3))\r
+#define TPM_AUDITFAILURE            ((TPM_RESULT) (TPM_BASE + 4))\r
+#define TPM_CLEAR_DISABLED          ((TPM_RESULT) (TPM_BASE + 5))\r
+#define TPM_DEACTIVATED             ((TPM_RESULT) (TPM_BASE + 6))\r
+#define TPM_DISABLED                ((TPM_RESULT) (TPM_BASE + 7))\r
+#define TPM_DISABLED_CMD            ((TPM_RESULT) (TPM_BASE + 8))\r
+#define TPM_FAIL                    ((TPM_RESULT) (TPM_BASE + 9))\r
+#define TPM_BAD_ORDINAL             ((TPM_RESULT) (TPM_BASE + 10))\r
+#define TPM_INSTALL_DISABLED        ((TPM_RESULT) (TPM_BASE + 11))\r
+#define TPM_INVALID_KEYHANDLE       ((TPM_RESULT) (TPM_BASE + 12))\r
+#define TPM_KEYNOTFOUND             ((TPM_RESULT) (TPM_BASE + 13))\r
+#define TPM_INAPPROPRIATE_ENC       ((TPM_RESULT) (TPM_BASE + 14))\r
+#define TPM_MIGRATEFAIL             ((TPM_RESULT) (TPM_BASE + 15))\r
+#define TPM_INVALID_PCR_INFO        ((TPM_RESULT) (TPM_BASE + 16))\r
+#define TPM_NOSPACE                 ((TPM_RESULT) (TPM_BASE + 17))\r
+#define TPM_NOSRK                   ((TPM_RESULT) (TPM_BASE + 18))\r
+#define TPM_NOTSEALED_BLOB          ((TPM_RESULT) (TPM_BASE + 19))\r
+#define TPM_OWNER_SET               ((TPM_RESULT) (TPM_BASE + 20))\r
+#define TPM_RESOURCES               ((TPM_RESULT) (TPM_BASE + 21))\r
+#define TPM_SHORTRANDOM             ((TPM_RESULT) (TPM_BASE + 22))\r
+#define TPM_SIZE                    ((TPM_RESULT) (TPM_BASE + 23))\r
+#define TPM_WRONGPCRVAL             ((TPM_RESULT) (TPM_BASE + 24))\r
+#define TPM_BAD_PARAM_SIZE          ((TPM_RESULT) (TPM_BASE + 25))\r
+#define TPM_SHA_THREAD              ((TPM_RESULT) (TPM_BASE + 26))\r
+#define TPM_SHA_ERROR               ((TPM_RESULT) (TPM_BASE + 27))\r
+#define TPM_FAILEDSELFTEST          ((TPM_RESULT) (TPM_BASE + 28))\r
+#define TPM_AUTH2FAIL               ((TPM_RESULT) (TPM_BASE + 29))\r
+#define TPM_BADTAG                  ((TPM_RESULT) (TPM_BASE + 30))\r
+#define TPM_IOERROR                 ((TPM_RESULT) (TPM_BASE + 31))\r
+#define TPM_ENCRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 32))\r
+#define TPM_DECRYPT_ERROR           ((TPM_RESULT) (TPM_BASE + 33))\r
+#define TPM_INVALID_AUTHHANDLE      ((TPM_RESULT) (TPM_BASE + 34))\r
+#define TPM_NO_ENDORSEMENT          ((TPM_RESULT) (TPM_BASE + 35))\r
+#define TPM_INVALID_KEYUSAGE        ((TPM_RESULT) (TPM_BASE + 36))\r
+#define TPM_WRONG_ENTITYTYPE        ((TPM_RESULT) (TPM_BASE + 37))\r
+#define TPM_INVALID_POSTINIT        ((TPM_RESULT) (TPM_BASE + 38))\r
+#define TPM_INAPPROPRIATE_SIG       ((TPM_RESULT) (TPM_BASE + 39))\r
+#define TPM_BAD_KEY_PROPERTY        ((TPM_RESULT) (TPM_BASE + 40))\r
+#define TPM_BAD_MIGRATION           ((TPM_RESULT) (TPM_BASE + 41))\r
+#define TPM_BAD_SCHEME              ((TPM_RESULT) (TPM_BASE + 42))\r
+#define TPM_BAD_DATASIZE            ((TPM_RESULT) (TPM_BASE + 43))\r
+#define TPM_BAD_MODE                ((TPM_RESULT) (TPM_BASE + 44))\r
+#define TPM_BAD_PRESENCE            ((TPM_RESULT) (TPM_BASE + 45))\r
+#define TPM_BAD_VERSION             ((TPM_RESULT) (TPM_BASE + 46))\r
+#define TPM_NO_WRAP_TRANSPORT       ((TPM_RESULT) (TPM_BASE + 47))\r
+#define TPM_AUDITFAIL_UNSUCCESSFUL  ((TPM_RESULT) (TPM_BASE + 48))\r
+#define TPM_AUDITFAIL_SUCCESSFUL    ((TPM_RESULT) (TPM_BASE + 49))\r
+#define TPM_NOTRESETABLE            ((TPM_RESULT) (TPM_BASE + 50))\r
+#define TPM_NOTLOCAL                ((TPM_RESULT) (TPM_BASE + 51))\r
+#define TPM_BAD_TYPE                ((TPM_RESULT) (TPM_BASE + 52))\r
+#define TPM_INVALID_RESOURCE        ((TPM_RESULT) (TPM_BASE + 53))\r
+#define TPM_NOTFIPS                 ((TPM_RESULT) (TPM_BASE + 54))\r
+#define TPM_INVALID_FAMILY          ((TPM_RESULT) (TPM_BASE + 55))\r
+#define TPM_NO_NV_PERMISSION        ((TPM_RESULT) (TPM_BASE + 56))\r
+#define TPM_REQUIRES_SIGN           ((TPM_RESULT) (TPM_BASE + 57))\r
+#define TPM_KEY_NOTSUPPORTED        ((TPM_RESULT) (TPM_BASE + 58))\r
+#define TPM_AUTH_CONFLICT           ((TPM_RESULT) (TPM_BASE + 59))\r
+#define TPM_AREA_LOCKED             ((TPM_RESULT) (TPM_BASE + 60))\r
+#define TPM_BAD_LOCALITY            ((TPM_RESULT) (TPM_BASE + 61))\r
+#define TPM_READ_ONLY               ((TPM_RESULT) (TPM_BASE + 62))\r
+#define TPM_PER_NOWRITE             ((TPM_RESULT) (TPM_BASE + 63))\r
+#define TPM_FAMILYCOUNT             ((TPM_RESULT) (TPM_BASE + 64))\r
+#define TPM_WRITE_LOCKED            ((TPM_RESULT) (TPM_BASE + 65))\r
+#define TPM_BAD_ATTRIBUTES          ((TPM_RESULT) (TPM_BASE + 66))\r
+#define TPM_INVALID_STRUCTURE       ((TPM_RESULT) (TPM_BASE + 67))\r
+#define TPM_KEY_OWNER_CONTROL       ((TPM_RESULT) (TPM_BASE + 68))\r
+#define TPM_BAD_COUNTER             ((TPM_RESULT) (TPM_BASE + 69))\r
+#define TPM_NOT_FULLWRITE           ((TPM_RESULT) (TPM_BASE + 70))\r
+#define TPM_CONTEXT_GAP             ((TPM_RESULT) (TPM_BASE + 71))\r
+#define TPM_MAXNVWRITES             ((TPM_RESULT) (TPM_BASE + 72))\r
+#define TPM_NOOPERATOR              ((TPM_RESULT) (TPM_BASE + 73))\r
+#define TPM_RESOURCEMISSING         ((TPM_RESULT) (TPM_BASE + 74))\r
+#define TPM_DELEGATE_LOCK           ((TPM_RESULT) (TPM_BASE + 75))\r
+#define TPM_DELEGATE_FAMILY         ((TPM_RESULT) (TPM_BASE + 76))\r
+#define TPM_DELEGATE_ADMIN          ((TPM_RESULT) (TPM_BASE + 77))\r
+#define TPM_TRANSPORT_NOTEXCLUSIVE  ((TPM_RESULT) (TPM_BASE + 78))\r
+#define TPM_OWNER_CONTROL           ((TPM_RESULT) (TPM_BASE + 79))\r
+#define TPM_DAA_RESOURCES           ((TPM_RESULT) (TPM_BASE + 80))\r
+#define TPM_DAA_INPUT_DATA0         ((TPM_RESULT) (TPM_BASE + 81))\r
+#define TPM_DAA_INPUT_DATA1         ((TPM_RESULT) (TPM_BASE + 82))\r
+#define TPM_DAA_ISSUER_SETTINGS     ((TPM_RESULT) (TPM_BASE + 83))\r
+#define TPM_DAA_TPM_SETTINGS        ((TPM_RESULT) (TPM_BASE + 84))\r
+#define TPM_DAA_STAGE               ((TPM_RESULT) (TPM_BASE + 85))\r
+#define TPM_DAA_ISSUER_VALIDITY     ((TPM_RESULT) (TPM_BASE + 86))\r
+#define TPM_DAA_WRONG_W             ((TPM_RESULT) (TPM_BASE + 87))\r
+#define TPM_BAD_HANDLE              ((TPM_RESULT) (TPM_BASE + 88))\r
+#define TPM_BAD_DELEGATE            ((TPM_RESULT) (TPM_BASE + 89))\r
+#define TPM_BADCONTEXT              ((TPM_RESULT) (TPM_BASE + 90))\r
+#define TPM_TOOMANYCONTEXTS         ((TPM_RESULT) (TPM_BASE + 91))\r
+#define TPM_MA_TICKET_SIGNATURE     ((TPM_RESULT) (TPM_BASE + 92))\r
+#define TPM_MA_DESTINATION          ((TPM_RESULT) (TPM_BASE + 93))\r
+#define TPM_MA_SOURCE               ((TPM_RESULT) (TPM_BASE + 94))\r
+#define TPM_MA_AUTHORITY            ((TPM_RESULT) (TPM_BASE + 95))\r
+#define TPM_PERMANENTEK             ((TPM_RESULT) (TPM_BASE + 97))\r
+#define TPM_BAD_SIGNATURE           ((TPM_RESULT) (TPM_BASE + 98))\r
+#define TPM_NOCONTEXTSPACE          ((TPM_RESULT) (TPM_BASE + 99))\r
+\r
+#define TPM_RETRY                   ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL))\r
+#define TPM_NEEDS_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 1))\r
+#define TPM_DOING_SELFTEST          ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 2))\r
+#define TPM_DEFEND_LOCK_RUNNING     ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 3))\r
+\r
+//\r
+// Part 2, section 17: Ordinals\r
+//\r
+// Ordinals are 32 bit values. The upper byte contains values that serve as\r
+// flag indicators, the next byte contains values indicating what committee\r
+// designated the ordinal, and the final two bytes contain the Command\r
+// Ordinal Index.\r
+//      3                   2                   1\r
+//    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\r
+//   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+//   |P|C|V| Reserved| Purview |     Command Ordinal Index           |\r
+//   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+//\r
+//  Where:\r
+//\r
+//    * P is Protected/Unprotected command. When 0 the command is a Protected\r
+//      command, when 1 the command is an Unprotected command.\r
+//\r
+//    * C is Non-Connection/Connection related command. When 0 this command\r
+//      passes through to either the protected (TPM) or unprotected (TSS)\r
+//      components.\r
+//\r
+//    * V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the\r
+//      command is vendor defined.\r
+//\r
+//    * All reserved area bits are set to 0.\r
+//\r
+\r
+#define TPM_ORD_ActivateIdentity                  ((TPM_COMMAND_CODE) 0x0000007A)\r
+#define TPM_ORD_AuthorizeMigrationKey             ((TPM_COMMAND_CODE) 0x0000002B)\r
+#define TPM_ORD_CertifyKey                        ((TPM_COMMAND_CODE) 0x00000032)\r
+#define TPM_ORD_CertifyKey2                       ((TPM_COMMAND_CODE) 0x00000033)\r
+#define TPM_ORD_CertifySelfTest                   ((TPM_COMMAND_CODE) 0x00000052)\r
+#define TPM_ORD_ChangeAuth                        ((TPM_COMMAND_CODE) 0x0000000C)\r
+#define TPM_ORD_ChangeAuthAsymFinish              ((TPM_COMMAND_CODE) 0x0000000F)\r
+#define TPM_ORD_ChangeAuthAsymStart               ((TPM_COMMAND_CODE) 0x0000000E)\r
+#define TPM_ORD_ChangeAuthOwner                   ((TPM_COMMAND_CODE) 0x00000010)\r
+#define TPM_ORD_CMK_ApproveMA                     ((TPM_COMMAND_CODE) 0x0000001D)\r
+#define TPM_ORD_CMK_ConvertMigration              ((TPM_COMMAND_CODE) 0x00000024)\r
+#define TPM_ORD_CMK_CreateBlob                    ((TPM_COMMAND_CODE) 0x0000001B)\r
+#define TPM_ORD_CMK_CreateKey                     ((TPM_COMMAND_CODE) 0x00000013)\r
+#define TPM_ORD_CMK_CreateTicket                  ((TPM_COMMAND_CODE) 0x00000012)\r
+#define TPM_ORD_CMK_SetRestrictions               ((TPM_COMMAND_CODE) 0x0000001C)\r
+#define TPM_ORD_ContinueSelfTest                  ((TPM_COMMAND_CODE) 0x00000053)\r
+#define TPM_ORD_ConvertMigrationBlob              ((TPM_COMMAND_CODE) 0x0000002A)\r
+#define TPM_ORD_CreateCounter                     ((TPM_COMMAND_CODE) 0x000000DC)\r
+#define TPM_ORD_CreateEndorsementKeyPair          ((TPM_COMMAND_CODE) 0x00000078)\r
+#define TPM_ORD_CreateMaintenanceArchive          ((TPM_COMMAND_CODE) 0x0000002C)\r
+#define TPM_ORD_CreateMigrationBlob               ((TPM_COMMAND_CODE) 0x00000028)\r
+#define TPM_ORD_CreateRevocableEK                 ((TPM_COMMAND_CODE) 0x0000007F)\r
+#define TPM_ORD_CreateWrapKey                     ((TPM_COMMAND_CODE) 0x0000001F)\r
+#define TPM_ORD_DAA_JOIN                          ((TPM_COMMAND_CODE) 0x00000029)\r
+#define TPM_ORD_DAA_SIGN                          ((TPM_COMMAND_CODE) 0x00000031)\r
+#define TPM_ORD_Delegate_CreateKeyDelegation      ((TPM_COMMAND_CODE) 0x000000D4)\r
+#define TPM_ORD_Delegate_CreateOwnerDelegation    ((TPM_COMMAND_CODE) 0x000000D5)\r
+#define TPM_ORD_Delegate_LoadOwnerDelegation      ((TPM_COMMAND_CODE) 0x000000D8)\r
+#define TPM_ORD_Delegate_Manage                   ((TPM_COMMAND_CODE) 0x000000D2)\r
+#define TPM_ORD_Delegate_ReadTable                ((TPM_COMMAND_CODE) 0x000000DB)\r
+#define TPM_ORD_Delegate_UpdateVerification       ((TPM_COMMAND_CODE) 0x000000D1)\r
+#define TPM_ORD_Delegate_VerifyDelegation         ((TPM_COMMAND_CODE) 0x000000D6)\r
+#define TPM_ORD_DirRead                           ((TPM_COMMAND_CODE) 0x0000001A)\r
+#define TPM_ORD_DirWriteAuth                      ((TPM_COMMAND_CODE) 0x00000019)\r
+#define TPM_ORD_DisableForceClear                 ((TPM_COMMAND_CODE) 0x0000005E)\r
+#define TPM_ORD_DisableOwnerClear                 ((TPM_COMMAND_CODE) 0x0000005C)\r
+#define TPM_ORD_DisablePubekRead                  ((TPM_COMMAND_CODE) 0x0000007E)\r
+#define TPM_ORD_DSAP                              ((TPM_COMMAND_CODE) 0x00000011)\r
+#define TPM_ORD_EstablishTransport                ((TPM_COMMAND_CODE) 0x000000E6)\r
+#define TPM_ORD_EvictKey                          ((TPM_COMMAND_CODE) 0x00000022)\r
+#define TPM_ORD_ExecuteTransport                  ((TPM_COMMAND_CODE) 0x000000E7)\r
+#define TPM_ORD_Extend                            ((TPM_COMMAND_CODE) 0x00000014)\r
+#define TPM_ORD_FieldUpgrade                      ((TPM_COMMAND_CODE) 0x000000AA)\r
+#define TPM_ORD_FlushSpecific                     ((TPM_COMMAND_CODE) 0x000000BA)\r
+#define TPM_ORD_ForceClear                        ((TPM_COMMAND_CODE) 0x0000005D)\r
+#define TPM_ORD_GetAuditDigest                    ((TPM_COMMAND_CODE) 0x00000085)\r
+#define TPM_ORD_GetAuditDigestSigned              ((TPM_COMMAND_CODE) 0x00000086)\r
+#define TPM_ORD_GetAuditEvent                     ((TPM_COMMAND_CODE) 0x00000082)\r
+#define TPM_ORD_GetAuditEventSigned               ((TPM_COMMAND_CODE) 0x00000083)\r
+#define TPM_ORD_GetCapability                     ((TPM_COMMAND_CODE) 0x00000065)\r
+#define TPM_ORD_GetCapabilityOwner                ((TPM_COMMAND_CODE) 0x00000066)\r
+#define TPM_ORD_GetCapabilitySigned               ((TPM_COMMAND_CODE) 0x00000064)\r
+#define TPM_ORD_GetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008C)\r
+#define TPM_ORD_GetPubKey                         ((TPM_COMMAND_CODE) 0x00000021)\r
+#define TPM_ORD_GetRandom                         ((TPM_COMMAND_CODE) 0x00000046)\r
+#define TPM_ORD_GetTestResult                     ((TPM_COMMAND_CODE) 0x00000054)\r
+#define TPM_ORD_GetTicks                          ((TPM_COMMAND_CODE) 0x000000F1)\r
+#define TPM_ORD_IncrementCounter                  ((TPM_COMMAND_CODE) 0x000000DD)\r
+#define TPM_ORD_Init                              ((TPM_COMMAND_CODE) 0x00000097)\r
+#define TPM_ORD_KeyControlOwner                   ((TPM_COMMAND_CODE) 0x00000023)\r
+#define TPM_ORD_KillMaintenanceFeature            ((TPM_COMMAND_CODE) 0x0000002E)\r
+#define TPM_ORD_LoadAuthContext                   ((TPM_COMMAND_CODE) 0x000000B7)\r
+#define TPM_ORD_LoadContext                       ((TPM_COMMAND_CODE) 0x000000B9)\r
+#define TPM_ORD_LoadKey                           ((TPM_COMMAND_CODE) 0x00000020)\r
+#define TPM_ORD_LoadKey2                          ((TPM_COMMAND_CODE) 0x00000041)\r
+#define TPM_ORD_LoadKeyContext                    ((TPM_COMMAND_CODE) 0x000000B5)\r
+#define TPM_ORD_LoadMaintenanceArchive            ((TPM_COMMAND_CODE) 0x0000002D)\r
+#define TPM_ORD_LoadManuMaintPub                  ((TPM_COMMAND_CODE) 0x0000002F)\r
+#define TPM_ORD_MakeIdentity                      ((TPM_COMMAND_CODE) 0x00000079)\r
+#define TPM_ORD_MigrateKey                        ((TPM_COMMAND_CODE) 0x00000025)\r
+#define TPM_ORD_NV_DefineSpace                    ((TPM_COMMAND_CODE) 0x000000CC)\r
+#define TPM_ORD_NV_ReadValue                      ((TPM_COMMAND_CODE) 0x000000CF)\r
+#define TPM_ORD_NV_ReadValueAuth                  ((TPM_COMMAND_CODE) 0x000000D0)\r
+#define TPM_ORD_NV_WriteValue                     ((TPM_COMMAND_CODE) 0x000000CD)\r
+#define TPM_ORD_NV_WriteValueAuth                 ((TPM_COMMAND_CODE) 0x000000CE)\r
+#define TPM_ORD_OIAP                              ((TPM_COMMAND_CODE) 0x0000000A)\r
+#define TPM_ORD_OSAP                              ((TPM_COMMAND_CODE) 0x0000000B)\r
+#define TPM_ORD_OwnerClear                        ((TPM_COMMAND_CODE) 0x0000005B)\r
+#define TPM_ORD_OwnerReadInternalPub              ((TPM_COMMAND_CODE) 0x00000081)\r
+#define TPM_ORD_OwnerReadPubek                    ((TPM_COMMAND_CODE) 0x0000007D)\r
+#define TPM_ORD_OwnerSetDisable                   ((TPM_COMMAND_CODE) 0x0000006E)\r
+#define TPM_ORD_PCR_Reset                         ((TPM_COMMAND_CODE) 0x000000C8)\r
+#define TPM_ORD_PcrRead                           ((TPM_COMMAND_CODE) 0x00000015)\r
+#define TPM_ORD_PhysicalDisable                   ((TPM_COMMAND_CODE) 0x00000070)\r
+#define TPM_ORD_PhysicalEnable                    ((TPM_COMMAND_CODE) 0x0000006F)\r
+#define TPM_ORD_PhysicalSetDeactivated            ((TPM_COMMAND_CODE) 0x00000072)\r
+#define TPM_ORD_Quote                             ((TPM_COMMAND_CODE) 0x00000016)\r
+#define TPM_ORD_Quote2                            ((TPM_COMMAND_CODE) 0x0000003E)\r
+#define TPM_ORD_ReadCounter                       ((TPM_COMMAND_CODE) 0x000000DE)\r
+#define TPM_ORD_ReadManuMaintPub                  ((TPM_COMMAND_CODE) 0x00000030)\r
+#define TPM_ORD_ReadPubek                         ((TPM_COMMAND_CODE) 0x0000007C)\r
+#define TPM_ORD_ReleaseCounter                    ((TPM_COMMAND_CODE) 0x000000DF)\r
+#define TPM_ORD_ReleaseCounterOwner               ((TPM_COMMAND_CODE) 0x000000E0)\r
+#define TPM_ORD_ReleaseTransportSigned            ((TPM_COMMAND_CODE) 0x000000E8)\r
+#define TPM_ORD_Reset                             ((TPM_COMMAND_CODE) 0x0000005A)\r
+#define TPM_ORD_ResetLockValue                    ((TPM_COMMAND_CODE) 0x00000040)\r
+#define TPM_ORD_RevokeTrust                       ((TPM_COMMAND_CODE) 0x00000080)\r
+#define TPM_ORD_SaveAuthContext                   ((TPM_COMMAND_CODE) 0x000000B6)\r
+#define TPM_ORD_SaveContext                       ((TPM_COMMAND_CODE) 0x000000B8)\r
+#define TPM_ORD_SaveKeyContext                    ((TPM_COMMAND_CODE) 0x000000B4)\r
+#define TPM_ORD_SaveState                         ((TPM_COMMAND_CODE) 0x00000098)\r
+#define TPM_ORD_Seal                              ((TPM_COMMAND_CODE) 0x00000017)\r
+#define TPM_ORD_Sealx                             ((TPM_COMMAND_CODE) 0x0000003D)\r
+#define TPM_ORD_SelfTestFull                      ((TPM_COMMAND_CODE) 0x00000050)\r
+#define TPM_ORD_SetCapability                     ((TPM_COMMAND_CODE) 0x0000003F)\r
+#define TPM_ORD_SetOperatorAuth                   ((TPM_COMMAND_CODE) 0x00000074)\r
+#define TPM_ORD_SetOrdinalAuditStatus             ((TPM_COMMAND_CODE) 0x0000008D)\r
+#define TPM_ORD_SetOwnerInstall                   ((TPM_COMMAND_CODE) 0x00000071)\r
+#define TPM_ORD_SetOwnerPointer                   ((TPM_COMMAND_CODE) 0x00000075)\r
+#define TPM_ORD_SetRedirection                    ((TPM_COMMAND_CODE) 0x0000009A)\r
+#define TPM_ORD_SetTempDeactivated                ((TPM_COMMAND_CODE) 0x00000073)\r
+#define TPM_ORD_SHA1Complete                      ((TPM_COMMAND_CODE) 0x000000A2)\r
+#define TPM_ORD_SHA1CompleteExtend                ((TPM_COMMAND_CODE) 0x000000A3)\r
+#define TPM_ORD_SHA1Start                         ((TPM_COMMAND_CODE) 0x000000A0)\r
+#define TPM_ORD_SHA1Update                        ((TPM_COMMAND_CODE) 0x000000A1)\r
+#define TPM_ORD_Sign                              ((TPM_COMMAND_CODE) 0x0000003C)\r
+#define TPM_ORD_Startup                           ((TPM_COMMAND_CODE) 0x00000099)\r
+#define TPM_ORD_StirRandom                        ((TPM_COMMAND_CODE) 0x00000047)\r
+#define TPM_ORD_TakeOwnership                     ((TPM_COMMAND_CODE) 0x0000000D)\r
+#define TPM_ORD_Terminate_Handle                  ((TPM_COMMAND_CODE) 0x00000096)\r
+#define TPM_ORD_TickStampBlob                     ((TPM_COMMAND_CODE) 0x000000F2)\r
+#define TPM_ORD_UnBind                            ((TPM_COMMAND_CODE) 0x0000001E)\r
+#define TPM_ORD_Unseal                            ((TPM_COMMAND_CODE) 0x00000018)\r
+#define TSC_ORD_PhysicalPresence                  ((TPM_COMMAND_CODE) 0x4000000A)\r
+#define TSC_ORD_ResetEstablishmentBit             ((TPM_COMMAND_CODE) 0x4000000B)\r
+\r
+//\r
+// Part 2, section 18: Context structures\r
+//\r
+\r
+typedef struct tdTPM_CONTEXT_BLOB\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_RESOURCE_TYPE               resourceType;\r
+    TPM_HANDLE                      handle;\r
+    UINT8                           label[16];\r
+    UINT32                          contextCount;\r
+    TPM_DIGEST                      integrityDigest;\r
+    UINT32                          additionalSize;\r
+    UINT8                           *additionalData;\r
+    UINT32                          sensitiveSize;\r
+    UINT8                           *sensitiveData;\r
+} TPM_CONTEXT_BLOB;\r
+\r
+typedef struct tdTPM_CONTEXT_SENSITIVE\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_NONCE                       contextNonce;\r
+    UINT32                          internalSize;\r
+    UINT8                           *internalData;\r
+} TPM_CONTEXT_SENSITIVE;\r
+\r
+//\r
+// Part 2, section 19: NV Structures\r
+//\r
+\r
+#define TPM_NV_INDEX_LOCK              ((UINT32)0xffffffff)\r
+#define TPM_NV_INDEX0                  ((UINT32)0x00000000)\r
+#define TPM_NV_INDEX_DIR               ((UINT32)0x10000001)\r
+#define TPM_NV_INDEX_EKCert            ((UINT32)0x0000f000)\r
+#define TPM_NV_INDEX_TPM_CC            ((UINT32)0x0000f001)\r
+#define TPM_NV_INDEX_PlatformCert      ((UINT32)0x0000f002)\r
+#define TPM_NV_INDEX_Platform_CC       ((UINT32)0x0000f003)\r
+// The following define ranges of reserved indices.\r
+#define TPM_NV_INDEX_TSS_BASE          ((UINT32)0x00011100)\r
+#define TPM_NV_INDEX_PC_BASE           ((UINT32)0x00011200)\r
+#define TPM_NV_INDEX_SERVER_BASE       ((UINT32)0x00011300)\r
+#define TPM_NV_INDEX_MOBILE_BASE       ((UINT32)0x00011400)\r
+#define TPM_NV_INDEX_PERIPHERAL_BASE   ((UINT32)0x00011500)\r
+#define TPM_NV_INDEX_GROUP_RESV_BASE   ((UINT32)0x00010000)\r
+\r
+typedef UINT32 TPM_NV_PER_ATTRIBUTES;\r
+// The typedefs TPM_NV_PER_ATTRIBUTES (not present in TPM 1.2 Spec. have been added \r
+// and structure fields that were to hold the following values\r
+#define TPM_NV_PER_READ_STCLEAR        (((UINT32)1)<<31)\r
+#define TPM_NV_PER_AUTHREAD            (((UINT32)1)<<18)\r
+#define TPM_NV_PER_OWNERREAD           (((UINT32)1)<<17)\r
+#define TPM_NV_PER_PPREAD              (((UINT32)1)<<16)\r
+#define TPM_NV_PER_GLOBALLOCK          (((UINT32)1)<<15)\r
+#define TPM_NV_PER_WRITE_STCLEAR       (((UINT32)1)<<14)\r
+#define TPM_NV_PER_WRITEDEFINE         (((UINT32)1)<<13)\r
+#define TPM_NV_PER_WRITEALL            (((UINT32)1)<<12)\r
+#define TPM_NV_PER_AUTHWRITE           (((UINT32)1)<<2)\r
+#define TPM_NV_PER_OWNERWRITE          (((UINT32)1)<<1)\r
+#define TPM_NV_PER_PPWRITE             (((UINT32)1)<<0)\r
+\r
+typedef struct tdTPM_NV_ATTRIBUTES\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_NV_PER_ATTRIBUTES           attributes;\r
+} TPM_NV_ATTRIBUTES;\r
+\r
+\r
+typedef struct tdTPM_NV_DATA_PUBLIC\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_NV_INDEX                    nvIndex;\r
+    TPM_PCR_INFO_SHORT              pcrInfoRead;\r
+    TPM_PCR_INFO_SHORT              pcrInfoWrite;\r
+    TPM_NV_ATTRIBUTES               permission;\r
+    BOOLEAN                         bReadSTClear;\r
+    BOOLEAN                         bWriteSTClear;\r
+    BOOLEAN                         bWriteDefine;\r
+    UINT32                          dataSize;\r
+} TPM_NV_DATA_PUBLIC;\r
+\r
+\r
+\r
+// Internal to TPM:\r
+//typedef struct tdTPM_NV_DATA_SENSITIVE\r
+//{\r
+//    TPM_STRUCTURE_TAG               tag;\r
+//    TPM_NV_DATA_PUBLIC              pubInfo;\r
+//   TPM_AUTHDATA                    authValue;\r
+//    UINT8                           *data;\r
+//} TPM_NV_DATA_SENSITIVE;\r
+\r
+\r
+//\r
+// Part 2, section 20: Delegation\r
+//\r
+\r
+//\r
+// Part 2, section 20.3: Owner Permissions Settings for per1 bits\r
+//\r
+#define TPM_DELEGATE_SetOrdinalAuditStatus          (((UINT32)1)<<30)\r
+#define TPM_DELEGATE_DirWriteAuth                   (((UINT32)1)<<29)\r
+#define TPM_DELEGATE_CMK_ApproveMA                  (((UINT32)1)<<28)\r
+#define TPM_DELEGATE_CMK_CreateTicket               (((UINT32)1)<<26)\r
+#define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (((UINT32)1)<<24)\r
+#define TPM_DELEGATE_DAA_Join                       (((UINT32)1)<<23)\r
+#define TPM_DELEGATE_AuthorizeMigrationKey          (((UINT32)1)<<22)\r
+#define TPM_DELEGATE_CreateMaintenanceArchive       (((UINT32)1)<<21)\r
+#define TPM_DELEGATE_LoadMaintenanceArchive         (((UINT32)1)<<20)\r
+#define TPM_DELEGATE_KillMaintenanceFeature         (((UINT32)1)<<19)\r
+#define TPM_DELEGATE_OwnerReadInteralPub            (((UINT32)1)<<18)\r
+#define TPM_DELEGATE_ResetLockValue                 (((UINT32)1)<<17)\r
+#define TPM_DELEGATE_OwnerClear                     (((UINT32)1)<<16)\r
+#define TPM_DELEGATE_DisableOwnerClear              (((UINT32)1)<<15)\r
+#define TPM_DELEGATE_OwnerSetDisable                (((UINT32)1)<<13)\r
+#define TPM_DELEGATE_SetCapability                  (((UINT32)1)<<12)\r
+#define TPM_DELEGATE_MakeIdentity                   (((UINT32)1)<<11)\r
+#define TPM_DELEGATE_ActivateIdentity               (((UINT32)1)<<10)\r
+#define TPM_DELEGATE_OwnerReadPubek                 (((UINT32)1)<<9)\r
+#define TPM_DELEGATE_DisablePubekRead               (((UINT32)1)<<8)\r
+#define TPM_DELEGATE_SetRedirection                 (((UINT32)1)<<7)\r
+#define TPM_DELEGATE_FieldUpgrade                   (((UINT32)1)<<6)\r
+#define TPM_DELEGATE_Delegate_UpdateVerification    (((UINT32)1)<<5)\r
+#define TPM_DELEGATE_CreateCounter                  (((UINT32)1)<<4)\r
+#define TPM_DELEGATE_ReleaseCounterOwner            (((UINT32)1)<<3)\r
+#define TPM_DELEGATE_DelegateManage                 (((UINT32)1)<<2)\r
+#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1)\r
+#define TPM_DELEGATE_DAA_Sign                       (((UINT32)1)<<0)\r
+\r
+//\r
+// Part 2, section 20.3: Key Permissions Settings for per1 bits\r
+//\r
+#define TPM_KEY_DELEGATE_CMK_ConvertMigration       (((UINT32)1)<<28)\r
+#define TPM_KEY_DELEGATE_TickStampBlob              (((UINT32)1)<<27)\r
+#define TPM_KEY_DELEGATE_ChangeAuthAsymStart        (((UINT32)1)<<26)\r
+#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish       (((UINT32)1)<<25)\r
+#define TPM_KEY_DELEGATE_CMK_CreateKey              (((UINT32)1)<<24)\r
+#define TPM_KEY_DELEGATE_MigrateKey                 (((UINT32)1)<<23)\r
+#define TPM_KEY_DELEGATE_LoadKey2                   (((UINT32)1)<<22)\r
+#define TPM_KEY_DELEGATE_EstablishTransport         (((UINT32)1)<<21)\r
+#define TPM_KEY_DELEGATE_ReleaseTransportSigned     (((UINT32)1)<<20)\r
+#define TPM_KEY_DELEGATE_Quote2                     (((UINT32)1)<<19)\r
+#define TPM_KEY_DELEGATE_Sealx                      (((UINT32)1)<<18)\r
+#define TPM_KEY_DELEGATE_MakeIdentity               (((UINT32)1)<<17)\r
+#define TPM_KEY_DELEGATE_ActivateIdentity           (((UINT32)1)<<16)\r
+#define TPM_KEY_DELEGATE_GetAuditDigestSigned       (((UINT32)1)<<15)\r
+#define TPM_KEY_DELEGATE_Sign                       (((UINT32)1)<<14)\r
+#define TPM_KEY_DELEGATE_CertifyKey2                (((UINT32)1)<<13)\r
+#define TPM_KEY_DELEGATE_CertifyKey                 (((UINT32)1)<<12)\r
+#define TPM_KEY_DELEGATE_CreateWrapKey              (((UINT32)1)<<11)\r
+#define TPM_KEY_DELEGATE_CMK_CreateBlob             (((UINT32)1)<<10)\r
+#define TPM_KEY_DELEGATE_CreateMigrationBlob        (((UINT32)1)<<9)\r
+#define TPM_KEY_DELEGATE_ConvertMigrationBlob       (((UINT32)1)<<8)\r
+#define TPM_KEY_DELEGATE_CreateKeyDelegation        (((UINT32)1)<<7)\r
+#define TPM_KEY_DELEGATE_ChangeAuth                 (((UINT32)1)<<6)\r
+#define TPM_KEY_DELEGATE_GetPubKey                  (((UINT32)1)<<5)\r
+#define TPM_KEY_DELEGATE_UnBind                     (((UINT32)1)<<4)\r
+#define TPM_KEY_DELEGATE_Quote                      (((UINT32)1)<<3)\r
+#define TPM_KEY_DELEGATE_Unseal                     (((UINT32)1)<<2)\r
+#define TPM_KEY_DELEGATE_Seal                       (((UINT32)1)<<1)\r
+#define TPM_KEY_DELEGATE_LoadKey                    (((UINT32)1)<<0)\r
+\r
+#define TPM_FAMILY_CREATE                 ((UINT32)0x00000001)\r
+#define TPM_FAMILY_ENABLE                 ((UINT32)0x00000002)\r
+#define TPM_FAMILY_ADMIN                  ((UINT32)0x00000003)\r
+#define TPM_FAMILY_INVALIDATE             ((UINT32)0x00000004)\r
+\r
+#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK   (((UINT32)1)<<1)\r
+#define TPM_FAMFLAG_ENABLE                (((UINT32)1)<<0)\r
+\r
+typedef struct tdTPM_FAMILY_LABEL\r
+{\r
+    UINT8                           label;\r
+} TPM_FAMILY_LABEL;\r
+\r
+typedef struct tdTPM_FAMILY_TABLE_ENTRY\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_FAMILY_LABEL                label;\r
+    TPM_FAMILY_ID                   familyID;\r
+    TPM_FAMILY_VERIFICATION         verificationCount;\r
+    TPM_FAMILY_FLAGS                flags;\r
+} TPM_FAMILY_TABLE_ENTRY;\r
+\r
+#define TPM_FAMILY_TABLE_ENTRY_MIN 8\r
+//typedef struct tdTPM_FAMILY_TABLE\r
+//{\r
+//    TPM_FAMILY_TABLE_ENTRY          FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];\r
+//} TPM_FAMILY_TABLE;\r
+\r
+\r
+typedef struct tdTPM_DELEGATE_LABEL\r
+{\r
+    UINT8                           label;\r
+} TPM_DELEGATE_LABEL;\r
+\r
+\r
+typedef UINT32 TPM_DELEGATE_TYPE;\r
+#define TPM_DEL_OWNER_BITS          ((UINT32)0x00000001)\r
+#define TPM_DEL_KEY_BITS            ((UINT32)0x00000002)\r
+\r
+typedef struct tdTPM_DELEGATIONS\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DELEGATE_TYPE               delegateType;\r
+    UINT32                          per1;\r
+    UINT32                          per2;\r
+} TPM_DELEGATIONS;\r
+\r
+typedef struct tdTPM_DELEGATE_PUBLIC\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DELEGATE_LABEL              label;\r
+    TPM_PCR_INFO_SHORT              pcrInfo;\r
+    TPM_DELEGATIONS                 permissions;\r
+    TPM_FAMILY_ID                   familyID;\r
+    TPM_FAMILY_VERIFICATION         verificationCount;\r
+} TPM_DELEGATE_PUBLIC;\r
+\r
+typedef struct tdTPM_DELEGATE_TABLE_ROW\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DELEGATE_PUBLIC             pub;\r
+    TPM_SECRET                      authValue;\r
+} TPM_DELEGATE_TABLE_ROW;\r
+\r
+\r
+#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2\r
+//typedef struct tdTPM_DELEGATE_TABLE\r
+//{\r
+//    TPM_DELEGATE_TABLE_ROW          delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];\r
+//} TPM_DELEGATE_TABLE;\r
+\r
+typedef struct tdTPM_DELEGATE_SENSITIVE\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_SECRET                      authValue;\r
+} TPM_DELEGATE_SENSITIVE;\r
+\r
+typedef struct tdTPM_DELEGATE_OWNER_BLOB\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DELEGATE_PUBLIC             pub;\r
+    TPM_DIGEST                      integrityDigest;\r
+    UINT32                          additionalSize;\r
+    UINT8                           *additionalArea;\r
+    UINT32                          sensitiveSize;\r
+    UINT8                           *sensitiveArea;\r
+} TPM_DELEGATE_OWNER_BLOB;\r
+\r
+typedef struct tdTPM_DELEGATE_KEY_BLOB\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DELEGATE_PUBLIC             pub;\r
+    TPM_DIGEST                      integrityDigest;\r
+    TPM_DIGEST                      pubKeyDigest;\r
+    UINT32                          additionalSize;\r
+    UINT8                           *additionalArea;\r
+    UINT32                          sensitiveSize;\r
+    UINT8                           *sensitiveArea;\r
+} TPM_DELEGATE_KEY_BLOB;\r
+\r
+//\r
+// Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability\r
+//\r
+#define TPM_CAP_ORD                     ((TPM_CAPABILITY_AREA) 0x00000001)\r
+#define TPM_CAP_ALG                     ((TPM_CAPABILITY_AREA) 0x00000002)\r
+#define TPM_CAP_PID                     ((TPM_CAPABILITY_AREA) 0x00000003)\r
+#define TPM_CAP_FLAG                    ((TPM_CAPABILITY_AREA) 0x00000004)\r
+#define TPM_CAP_PROPERTY                ((TPM_CAPABILITY_AREA) 0x00000005)\r
+#define TPM_CAP_VERSION                 ((TPM_CAPABILITY_AREA) 0x00000006)\r
+#define TPM_CAP_KEY_HANDLE              ((TPM_CAPABILITY_AREA) 0x00000007)\r
+#define TPM_CAP_CHECK_LOADED            ((TPM_CAPABILITY_AREA) 0x00000008)\r
+#define TPM_CAP_SYM_MODE                ((TPM_CAPABILITY_AREA) 0x00000009)\r
+#define TPM_CAP_KEY_STATUS              ((TPM_CAPABILITY_AREA) 0x0000000C)\r
+#define TPM_CAP_NV_LIST                 ((TPM_CAPABILITY_AREA) 0x0000000D)\r
+#define TPM_CAP_MFR                     ((TPM_CAPABILITY_AREA) 0x00000010)\r
+#define TPM_CAP_NV_INDEX                ((TPM_CAPABILITY_AREA) 0x00000011)\r
+#define TPM_CAP_TRANS_ALG               ((TPM_CAPABILITY_AREA) 0x00000012)\r
+#define TPM_CAP_HANDLE                  ((TPM_CAPABILITY_AREA) 0x00000014)\r
+#define TPM_CAP_TRANS_ES                ((TPM_CAPABILITY_AREA) 0x00000015)\r
+#define TPM_CAP_AUTH_ENCRYPT            ((TPM_CAPABILITY_AREA) 0x00000017)\r
+#define TPM_CAP_SELECT_SIZE             ((TPM_CAPABILITY_AREA) 0x00000018)\r
+#define TPM_CAP_VERSION_VAL             ((TPM_CAPABILITY_AREA) 0x0000001A)\r
+\r
+#define TPM_CAP_FLAG_PERMANENT          ((TPM_CAPABILITY_AREA) 0x00000108)\r
+#define TPM_CAP_FLAG_VOLATILE           ((TPM_CAPABILITY_AREA) 0x00000109)\r
+\r
+//\r
+// Part 2, section 21.2: CAP_PROPERTY Subcap values for GetCapability\r
+//\r
+#define TPM_CAP_PROP_PCR                ((TPM_CAPABILITY_AREA) 0x00000101)\r
+#define TPM_CAP_PROP_DIR                ((TPM_CAPABILITY_AREA) 0x00000102)\r
+#define TPM_CAP_PROP_MANUFACTURER       ((TPM_CAPABILITY_AREA) 0x00000103)\r
+#define TPM_CAP_PROP_KEYS               ((TPM_CAPABILITY_AREA) 0x00000104)\r
+#define TPM_CAP_PROP_MIN_COUNTER        ((TPM_CAPABILITY_AREA) 0x00000107)\r
+#define TPM_CAP_PROP_AUTHSESS           ((TPM_CAPABILITY_AREA) 0x0000010A)\r
+#define TPM_CAP_PROP_TRANSESS           ((TPM_CAPABILITY_AREA) 0x0000010B)\r
+#define TPM_CAP_PROP_COUNTERS           ((TPM_CAPABILITY_AREA) 0x0000010C)\r
+#define TPM_CAP_PROP_MAX_AUTHSESS       ((TPM_CAPABILITY_AREA) 0x0000010D)\r
+#define TPM_CAP_PROP_MAX_TRANSESS       ((TPM_CAPABILITY_AREA) 0x0000010E)\r
+#define TPM_CAP_PROP_MAX_COUNTERS       ((TPM_CAPABILITY_AREA) 0x0000010F)\r
+#define TPM_CAP_PROP_MAX_KEYS           ((TPM_CAPABILITY_AREA) 0x00000110)\r
+#define TPM_CAP_PROP_OWNER              ((TPM_CAPABILITY_AREA) 0x00000111)\r
+#define TPM_CAP_PROP_CONTEXT            ((TPM_CAPABILITY_AREA) 0x00000112)\r
+#define TPM_CAP_PROP_MAX_CONTEXT        ((TPM_CAPABILITY_AREA) 0x00000113)\r
+#define TPM_CAP_PROP_FAMILYROWS         ((TPM_CAPABILITY_AREA) 0x00000114)\r
+#define TPM_CAP_PROP_TIS_TIMEOUT        ((TPM_CAPABILITY_AREA) 0x00000115)\r
+#define TPM_CAP_PROP_STARTUP_EFFECT     ((TPM_CAPABILITY_AREA) 0x00000116)\r
+#define TPM_CAP_PROP_DELEGATE_ROW       ((TPM_CAPABILITY_AREA) 0x00000117)\r
+#define TPM_CAP_PROP_DAA_MAX            ((TPM_CAPABILITY_AREA) 0x00000119)\r
+#define CAP_PROP_SESSION_DAA            ((TPM_CAPABILITY_AREA) 0x0000011A)\r
+#define TPM_CAP_PROP_CONTEXT_DIST       ((TPM_CAPABILITY_AREA) 0x0000011B)\r
+#define TPM_CAP_PROP_DAA_INTERRUPT      ((TPM_CAPABILITY_AREA) 0x0000011C)\r
+#define TPM_CAP_PROP_SESSIONS           ((TPM_CAPABILITY_AREA) 0x0000011D)\r
+#define TPM_CAP_PROP_MAX_SESSIONS       ((TPM_CAPABILITY_AREA) 0x0000011E)\r
+#define TPM_CAP_PROP_CMK_RESTRICTION    ((TPM_CAPABILITY_AREA) 0x0000011F)\r
+#define TPM_CAP_PROP_DURATION           ((TPM_CAPABILITY_AREA) 0x00000120)\r
+#define TPM_CAP_PROP_ACTIVE_COUNTER     ((TPM_CAPABILITY_AREA) 0x00000122)\r
+#define TPM_CAP_PROP_MAX_NV_AVAILABLE   ((TPM_CAPABILITY_AREA) 0x00000123)\r
+#define TPM_CAP_PROP_INPUT_BUFFER       ((TPM_CAPABILITY_AREA) 0x00000124)\r
+\r
+//\r
+// Part 2, section 21.6: TPM_CAP_VERSION_INFO\r
+//   [size_is(vendorSpecificSize)] BYTE* vendorSpecific;\r
+//\r
+typedef struct tdTPM_CAP_VERSION_INFO {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_VERSION                       version;\r
+  UINT16                            specLevel;\r
+  UINT8                             errataRev;\r
+  UINT8                             tpmVendorID[4];\r
+  UINT16                            vendorSpecificSize;\r
+  UINT8                             *vendorSpecific;\r
+} TPM_CAP_VERSION_INFO;\r
+\r
+//\r
+// Part 2, section 22: DAA Structures\r
+//\r
+\r
+#define TPM_DAA_SIZE_r0                (43)\r
+#define TPM_DAA_SIZE_r1                (43)\r
+#define TPM_DAA_SIZE_r2                (128)\r
+#define TPM_DAA_SIZE_r3                (168)\r
+#define TPM_DAA_SIZE_r4                (219)\r
+#define TPM_DAA_SIZE_NT                (20)\r
+#define TPM_DAA_SIZE_v0                (128)\r
+#define TPM_DAA_SIZE_v1                (192)\r
+#define TPM_DAA_SIZE_NE                (256)\r
+#define TPM_DAA_SIZE_w                 (256)\r
+#define TPM_DAA_SIZE_issuerModulus     (256)\r
+#define TPM_DAA_power0                 (104)\r
+#define TPM_DAA_power1                 (1024)\r
+\r
+typedef struct tdTPM_DAA_ISSUER\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DIGEST                      DAA_digest_R0;\r
+    TPM_DIGEST                      DAA_digest_R1;\r
+    TPM_DIGEST                      DAA_digest_S0;\r
+    TPM_DIGEST                      DAA_digest_S1;\r
+    TPM_DIGEST                      DAA_digest_n;\r
+    TPM_DIGEST                      DAA_digest_gamma;\r
+    UINT8                           DAA_generic_q[26];\r
+} TPM_DAA_ISSUER;\r
+\r
+\r
+typedef struct tdTPM_DAA_TPM\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DIGEST                      DAA_digestIssuer;\r
+    TPM_DIGEST                      DAA_digest_v0;\r
+    TPM_DIGEST                      DAA_digest_v1;\r
+    TPM_DIGEST                      DAA_rekey;\r
+    UINT32                          DAA_count;\r
+} TPM_DAA_TPM;\r
+\r
+typedef struct tdTPM_DAA_CONTEXT\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_DIGEST                      DAA_digestContext;\r
+    TPM_DIGEST                      DAA_digest;\r
+    TPM_DAA_CONTEXT_SEED            DAA_contextSeed;\r
+    UINT8                           DAA_scratch[256];\r
+    UINT8                           DAA_stage;\r
+} TPM_DAA_CONTEXT;\r
+\r
+typedef struct tdTPM_DAA_JOINDATA\r
+{\r
+    UINT8                           DAA_join_u0[128];\r
+    UINT8                           DAA_join_u1[138];\r
+    TPM_DIGEST                      DAA_digest_n0;\r
+} TPM_DAA_JOINDATA;\r
+\r
+typedef struct tdTPM_DAA_BLOB\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    TPM_RESOURCE_TYPE               resourceType;\r
+    UINT8                           label[16];\r
+    TPM_DIGEST                      blobIntegrity;\r
+    UINT32                          additionalSize;\r
+    UINT8                           *additionalData;\r
+    UINT32                          sensitiveSize;\r
+    UINT8                           *sensitiveData;\r
+} TPM_DAA_BLOB;\r
+\r
+typedef struct tdTPM_DAA_SENSITIVE\r
+{\r
+    TPM_STRUCTURE_TAG               tag;\r
+    UINT32                          internalSize;\r
+    UINT8                           *internalData;\r
+} TPM_DAA_SENSITIVE;\r
+\r
+\r
+//\r
+// Part 2, section 23: Redirection\r
+//\r
+\r
+// This section of the TPM spec defines exactly one value but does not\r
+// give it a name. The definition of TPM_SetRedirection in Part3\r
+// refers to exactly one name but does not give its value. We join\r
+// them here.\r
+#define TPM_REDIR_GPIO              (0x00000001)\r
+\r
+//\r
+// TPM Command & Response Headers\r
+//\r
+typedef struct tdTPM_RQU_COMMAND_HDR {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT32                            paramSize;\r
+  TPM_COMMAND_CODE                  ordinal;\r
+} TPM_RQU_COMMAND_HDR;\r
+\r
+typedef struct tdTPM_RSP_COMMAND_HDR {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT32                            paramSize;\r
+  TPM_RESULT                        returnCode;\r
+} TPM_RSP_COMMAND_HDR;\r
+\r
+#pragma pack (pop)\r
+\r
+#endif  // _TPM12_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h
new file mode 100644 (file)
index 0000000..8a23e7e
--- /dev/null
@@ -0,0 +1,94 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WatchdogDescriptionTable.h\r
+\r
+Abstract:\r
+\r
+  ACPI Watchdog Description Table as defined in Intel\r
+  ICH Family Watchdog Timer (WDT) Application Note (AP-725)\r
+\r
+--*/\r
+\r
+#ifndef _WATCH_DOG_DESCRIPTION_TABLE_H_\r
+#define _WATCH_DOG_DESCRIPTION_TABLE_H_\r
+\r
+//\r
+// Include files\r
+//\r
+#include "Acpi2_0.h"\r
+\r
+//\r
+// Ensure proper structure formats\r
+//\r
+#pragma pack(1)\r
+//\r
+// WDDT structure\r
+//\r
+typedef struct {\r
+  EFI_ACPI_DESCRIPTION_HEADER             Header;\r
+  UINT16                                  SpecVersion;\r
+  UINT16                                  TableVersion;\r
+  UINT16                                  Vid;\r
+  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  BaseAddress;\r
+  UINT16                                  TimerMaxCount;\r
+  UINT16                                  TimerMinCount;\r
+  UINT16                                  TimerCountPeriod;\r
+  UINT16                                  Status;\r
+  UINT16                                  Capability;\r
+} EFI_ACPI_1_0_WATCH_DOG_DESCRIPTION_TABLE;\r
+\r
+//\r
+// "WDDT" Watchdog Description Table signatures\r
+//\r
+#define EFI_ACPI_1_0_WDDT_SIGNATURE 0x54444457\r
+\r
+#pragma pack()\r
+\r
+//\r
+// WDDT Revision\r
+//\r
+#define EFI_ACPI_WATCHDOG_DESCRIPTION_1_0_TABLE_REVISION  0x01\r
+\r
+//\r
+// WDDT Spec Version\r
+//\r
+#define EFI_ACPI_WDDT_SPEC_1_0_VERSION                0x01\r
+\r
+//\r
+// WDDT Description Table Version\r
+//\r
+#define EFI_ACPI_WDDT_TABLE_1_0_VERSION               0x01\r
+\r
+//\r
+// WDT Status\r
+//\r
+#define EFI_ACPI_WDDT_STATUS_AVAILABLE             0x0001\r
+#define EFI_ACPI_WDDT_STATUS_ACTIVE                0x0002\r
+#define EFI_ACPI_WDDT_STATUS_OWNED_BY_BIOS         0x0000\r
+#define EFI_ACPI_WDDT_STATUS_OWNED_BY_OS           0x0004\r
+#define EFI_ACPI_WDDT_STATUS_USER_RESET_EVENT      0x0800\r
+#define EFI_ACPI_WDDT_STATUS_WDT_EVENT             0x1000\r
+#define EFI_ACPI_WDDT_STATUS_POWER_FAIL_EVENT      0x2000\r
+#define EFI_ACPI_WDDT_STATUS_UNKNOWN_RESET_EVENT   0x4000\r
+\r
+//\r
+// WDT Capability\r
+//\r
+#define EFI_ACPI_WDDT_CAPABILITY_AUTO_RESET            0x0001\r
+#define EFI_ACPI_WDDT_CAPABILITY_ALERT_SUPPORT         0x0002\r
+#define EFI_ACPI_WDDT_CAPABILITY_PLATFORM_SHUTDOWN     0x0004\r
+#define EFI_ACPI_WDDT_CAPABILITY_IMMEDIATE_SHUTDOWN    0x0008\r
+#define EFI_ACPI_WDDT_CAPABILITY_BIOS_HANDOFF_SUPPORT  0x0010\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h
new file mode 100644 (file)
index 0000000..3fcc287
--- /dev/null
@@ -0,0 +1,331 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Atapi.h\r
+    \r
+Abstract: \r
+    \r
+\r
+Revision History\r
+--*/\r
+\r
+#ifndef _ATAPI_H\r
+#define _ATAPI_H\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT16  config;                     /* General Configuration */\r
+  UINT16  cylinders;                  /* Number of Cylinders */\r
+  UINT16  reserved_2;\r
+  UINT16  heads;                      /* Number of logical heads */\r
+  UINT16  vendor_data1;\r
+  UINT16  vendoe_data2;\r
+  UINT16  sectors_per_track;\r
+  UINT16  vendor_specific_7_9[3];\r
+  CHAR8   SerialNo[20];               /* ASCII */\r
+  UINT16  vendor_specific_20_21[2];\r
+  UINT16  ecc_bytes_available;\r
+  CHAR8   FirmwareVer[8];             /* ASCII */\r
+  CHAR8   ModelName[40];              /* ASCII */\r
+  UINT16  multi_sector_cmd_max_sct_cnt;\r
+  UINT16  reserved_48;\r
+  UINT16  capabilities;\r
+  UINT16  reserved_50;\r
+  UINT16  pio_cycle_timing;\r
+  UINT16  reserved_52;\r
+  UINT16  field_validity;\r
+  UINT16  current_cylinders;\r
+  UINT16  current_heads;\r
+  UINT16  current_sectors;\r
+  UINT16  CurrentCapacityLsb;\r
+  UINT16  CurrentCapacityMsb;\r
+  UINT16  reserved_59;\r
+  UINT16  user_addressable_sectors_lo;\r
+  UINT16  user_addressable_sectors_hi;\r
+  UINT16  reserved_62;\r
+  UINT16  multi_word_dma_mode;\r
+  UINT16  advanced_pio_modes;\r
+  UINT16  min_multi_word_dma_cycle_time;\r
+  UINT16  rec_multi_word_dma_cycle_time;\r
+  UINT16  min_pio_cycle_time_without_flow_control;\r
+  UINT16  min_pio_cycle_time_with_flow_control;\r
+  UINT16  reserved_69_79[11];\r
+  UINT16  major_version_no;\r
+  UINT16  minor_version_no;\r
+  UINT16  reserved_82_127[46];\r
+  UINT16  security_status;\r
+  UINT16  vendor_data_129_159[31];\r
+  UINT16  reserved_160_255[96];\r
+} IDENTIFY;\r
+\r
+typedef struct {\r
+  UINT8 peripheral_type;\r
+  UINT8 RMB;\r
+  UINT8 version;\r
+  UINT8 response_data_format;\r
+  UINT8 addnl_length;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 reserved_7;\r
+  UINT8 vendor_info[8];\r
+  UINT8 product_id[12];\r
+  UINT8 eeprom_product_code[4];\r
+  UINT8 firmware_rev_level[4];\r
+  UINT8 firmware_sub_rev_level[1];\r
+  UINT8 reserved_37;\r
+  UINT8 reserved_38;\r
+  UINT8 reserved_39;\r
+  UINT8 max_capacity_hi;\r
+  UINT8 max_capacity_mid;\r
+  UINT8 max_capacity_lo;\r
+  UINT8 reserved_43_95[95 - 43 + 1];\r
+  UINT8 vendor_id[20];\r
+  UINT8 eeprom_drive_sno[12];\r
+} INQUIRY_DATA;\r
+\r
+typedef struct {\r
+  UINT8 error_code : 7;\r
+  UINT8 valid : 1;\r
+  UINT8 reserved_1;\r
+  UINT8 sense_key : 4;\r
+  UINT8 reserved_21 : 1;\r
+  UINT8 ILI : 1;\r
+  UINT8 reserved_22 : 2;\r
+  UINT8 vendor_specific_3;\r
+  UINT8 vendor_specific_4;\r
+  UINT8 vendor_specific_5;\r
+  UINT8 vendor_specific_6;\r
+  UINT8 addnl_sense_length;           // n - 7\r
+  UINT8 vendor_specific_8;\r
+  UINT8 vendor_specific_9;\r
+  UINT8 vendor_specific_10;\r
+  UINT8 vendor_specific_11;\r
+  UINT8 addnl_sense_code;             // mandatory\r
+  UINT8 addnl_sense_code_qualifier;   // mandatory\r
+  UINT8 field_replaceable_unit_code;  // optional\r
+  UINT8 reserved_15;\r
+  UINT8 reserved_16;\r
+  UINT8 reserved_17;\r
+  //\r
+  // Followed by additional sense bytes     : FIXME\r
+  //\r
+} REQUEST_SENSE_DATA;\r
+\r
+typedef struct {\r
+  UINT8 LastLba3;\r
+  UINT8 LastLba2;\r
+  UINT8 LastLba1;\r
+  UINT8 LastLba0;\r
+  UINT8 BlockSize3;\r
+  UINT8 BlockSize2;\r
+  UINT8 BlockSize1;\r
+  UINT8 BlockSize0;\r
+} READ_CAPACITY_DATA;\r
+\r
+typedef struct {\r
+  UINT8 reserved_0;\r
+  UINT8 reserved_1;\r
+  UINT8 reserved_2;\r
+  UINT8 Capacity_Length;\r
+  UINT8 LastLba3;\r
+  UINT8 LastLba2;\r
+  UINT8 LastLba1;\r
+  UINT8 LastLba0;\r
+  UINT8 DesCode : 2;\r
+  UINT8 reserved_9 : 6;\r
+  UINT8 BlockSize2;\r
+  UINT8 BlockSize1;\r
+  UINT8 BlockSize0;\r
+} READ_FORMAT_CAPACITY_DATA;\r
+\r
+#pragma pack()\r
+//\r
+// ATAPI Command\r
+//\r
+#define ATAPI_SOFT_RESET_CMD      0x08\r
+#define PACKET_CMD                0xA0\r
+#define ATAPI_IDENTIFY_DEVICE_CMD 0xA1\r
+#define ATAPI_SERVICE_CMD         0xA2\r
+\r
+//\r
+// ATAPI Packet Command\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT8 opcode;\r
+  UINT8 reserved_1;\r
+  UINT8 reserved_2;\r
+  UINT8 reserved_3;\r
+  UINT8 reserved_4;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 reserved_7;\r
+  UINT8 reserved_8;\r
+  UINT8 reserved_9;\r
+  UINT8 reserved_10;\r
+  UINT8 reserved_11;\r
+} TEST_UNIT_READY_CMD;\r
+\r
+typedef struct {\r
+  UINT8 opcode;\r
+  UINT8 reserved_1 : 4;\r
+  UINT8 lun : 4;\r
+  UINT8 page_code;\r
+  UINT8 reserved_3;\r
+  UINT8 allocation_length;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 reserved_7;\r
+  UINT8 reserved_8;\r
+  UINT8 reserved_9;\r
+  UINT8 reserved_10;\r
+  UINT8 reserved_11;\r
+} INQUIRY_CMD;\r
+\r
+typedef struct {\r
+  UINT8 opcode;\r
+  UINT8 reserved_1 : 4;\r
+  UINT8 lun : 4;\r
+  UINT8 reserved_2;\r
+  UINT8 reserved_3;\r
+  UINT8 allocation_length;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 reserved_7;\r
+  UINT8 reserved_8;\r
+  UINT8 reserved_9;\r
+  UINT8 reserved_10;\r
+  UINT8 reserved_11;\r
+} REQUEST_SENSE_CMD;\r
+\r
+typedef struct {\r
+  UINT8 opcode;\r
+  UINT8 reserved_1 : 5;\r
+  UINT8 lun : 3;\r
+  UINT8 Lba0;\r
+  UINT8 Lba1;\r
+  UINT8 Lba2;\r
+  UINT8 Lba3;\r
+  UINT8 reserved_6;\r
+  UINT8 TranLen0;\r
+  UINT8 TranLen1;\r
+  UINT8 reserved_9;\r
+  UINT8 reserved_10;\r
+  UINT8 reserved_11;\r
+} READ10_CMD;\r
+\r
+typedef struct {\r
+  UINT8 opcode;\r
+  UINT8 reserved_1;\r
+  UINT8 reserved_2;\r
+  UINT8 reserved_3;\r
+  UINT8 reserved_4;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 allocation_length_hi;\r
+  UINT8 allocation_length_lo;\r
+  UINT8 reserved_9;\r
+  UINT8 reserved_10;\r
+  UINT8 reserved_11;\r
+} READ_FORMAT_CAP_CMD;\r
+\r
+typedef struct {\r
+  UINT8 peripheral_type;\r
+  UINT8 RMB;\r
+  UINT8 version;\r
+  UINT8 response_data_format;\r
+  UINT8 addnl_length;\r
+  UINT8 reserved_5;\r
+  UINT8 reserved_6;\r
+  UINT8 reserved_7;\r
+  UINT8 vendor_info[8];\r
+  UINT8 product_id[12];\r
+  UINT8 eeprom_product_code[4];\r
+  UINT8 firmware_rev_level[4];\r
+} USB_INQUIRY_DATA;\r
+\r
+typedef union {\r
+  UINT16              Data16[6];\r
+  TEST_UNIT_READY_CMD TestUnitReady;\r
+  READ10_CMD          Read10;\r
+  REQUEST_SENSE_CMD   RequestSence;\r
+  INQUIRY_CMD         Inquiry;\r
+  READ_FORMAT_CAP_CMD ReadFormatCapacity;\r
+} ATAPI_PACKET_COMMAND;\r
+\r
+#pragma pack()\r
+//\r
+// Packet Command Code\r
+//\r
+#define TEST_UNIT_READY       0x00\r
+#define REQUEST_SENSE         0x03\r
+#define INQUIRY               0x12\r
+#define READ_FORMAT_CAPACITY  0x23\r
+#define READ_CAPACITY         0x25\r
+#define READ_10               0x28\r
+\r
+#define DEFAULT_CTL           (0x0a)  // default content of device control register, disable INT\r
+#define DEFAULT_CMD           (0xa0)\r
+\r
+#define MAX_ATAPI_BYTE_COUNT  (0xfffe)\r
+\r
+//\r
+// Sense Key\r
+//\r
+#define REQUEST_SENSE_ERROR (0x70)\r
+#define SK_NO_SENSE         (0x0)\r
+#define SK_RECOVERY_ERROR   (0x1)\r
+#define SK_NOT_READY        (0x2)\r
+#define SK_MEDIUM_ERROR     (0x3)\r
+#define SK_HARDWARE_ERROR   (0x4)\r
+#define SK_ILLEGAL_REQUEST  (0x5)\r
+#define SK_UNIT_ATTENTION   (0x6)\r
+#define SK_DATA_PROTECT     (0x7)\r
+#define SK_BLANK_CHECK      (0x8)\r
+#define SK_VENDOR_SPECIFIC  (0x9)\r
+#define SK_RESERVED_A       (0xA)\r
+#define SK_ABORT            (0xB)\r
+#define SK_RESERVED_C       (0xC)\r
+#define SK_OVERFLOW         (0xD)\r
+#define SK_MISCOMPARE       (0xE)\r
+#define SK_RESERVED_F       (0xF)\r
+\r
+//\r
+// Additional Sense Codes\r
+//\r
+#define ASC_NOT_READY                   (0x04)\r
+#define ASC_MEDIA_ERR1                  (0x10)\r
+#define ASC_MEDIA_ERR2                  (0x11)\r
+#define ASC_MEDIA_ERR3                  (0x14)\r
+#define ASC_MEDIA_ERR4                  (0x30)\r
+#define ASC_MEDIA_UPSIDE_DOWN           (0x06)\r
+#define ASC_INVALID_CMD                 (0x20)\r
+#define ASC_LBA_OUT_OF_RANGE            (0x21)\r
+#define ASC_INVALID_FIELD               (0x24)\r
+#define ASC_WRITE_PROTECTED             (0x27)\r
+#define ASC_MEDIA_CHANGE                (0x28)\r
+#define ASC_RESET                       (0x29)  /* Power On Reset or Bus Reset occurred */\r
+#define ASC_ILLEGAL_FIELD               (0x26)\r
+#define ASC_NO_MEDIA                    (0x3A)\r
+#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)\r
+\r
+//\r
+// Additional Sense Code Qualifier\r
+//\r
+#define ASCQ_IN_PROGRESS  (0x01)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h
new file mode 100644 (file)
index 0000000..aa0668b
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    pci.h\r
+\r
+Abstract:\r
+    Support for PCI standard.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PCI_H\r
+#define _PCI_H\r
+\r
+#include "pci22.h"\r
+#include "pci23.h"\r
+#include "pci30.h"\r
+#include "EfiPci.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h
new file mode 100644 (file)
index 0000000..77aebb6
--- /dev/null
@@ -0,0 +1,555 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    pci22.h\r
+\r
+Abstract:\r
+    Support for PCI 2.2 standard.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PCI22_H\r
+#define _PCI22_H\r
+\r
+#define PCI_MAX_SEGMENT 0\r
+\r
+#define PCI_MAX_BUS     255\r
+\r
+#define PCI_MAX_DEVICE  31\r
+#define PCI_MAX_FUNC    7\r
+\r
+//\r
+// Command\r
+//\r
+#define PCI_VGA_PALETTE_SNOOP_DISABLED  0x20\r
+\r
+#pragma pack(push, 1)\r
+typedef struct {\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT16  Command;\r
+  UINT16  Status;\r
+  UINT8   RevisionID;\r
+  UINT8   ClassCode[3];\r
+  UINT8   CacheLineSize;\r
+  UINT8   LatencyTimer;\r
+  UINT8   HeaderType;\r
+  UINT8   BIST;\r
+} PCI_DEVICE_INDEPENDENT_REGION;\r
+\r
+typedef struct {\r
+  UINT32  Bar[6];\r
+  UINT32  CISPtr;\r
+  UINT16  SubsystemVendorID;\r
+  UINT16  SubsystemID;\r
+  UINT32  ExpansionRomBar;\r
+  UINT8   CapabilityPtr;\r
+  UINT8   Reserved1[3];\r
+  UINT32  Reserved2;\r
+  UINT8   InterruptLine;\r
+  UINT8   InterruptPin;\r
+  UINT8   MinGnt;\r
+  UINT8   MaxLat;\r
+} PCI_DEVICE_HEADER_TYPE_REGION;\r
+\r
+typedef struct {\r
+  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
+  PCI_DEVICE_HEADER_TYPE_REGION Device;\r
+} PCI_TYPE00;\r
+\r
+typedef struct {\r
+  UINT32  Bar[2];\r
+  UINT8   PrimaryBus;\r
+  UINT8   SecondaryBus;\r
+  UINT8   SubordinateBus;\r
+  UINT8   SecondaryLatencyTimer;\r
+  UINT8   IoBase;\r
+  UINT8   IoLimit;\r
+  UINT16  SecondaryStatus;\r
+  UINT16  MemoryBase;\r
+  UINT16  MemoryLimit;\r
+  UINT16  PrefetchableMemoryBase;\r
+  UINT16  PrefetchableMemoryLimit;\r
+  UINT32  PrefetchableBaseUpper32;\r
+  UINT32  PrefetchableLimitUpper32;\r
+  UINT16  IoBaseUpper16;\r
+  UINT16  IoLimitUpper16;\r
+  UINT8   CapabilityPtr;\r
+  UINT8   Reserved[3];\r
+  UINT32  ExpansionRomBAR;\r
+  UINT8   InterruptLine;\r
+  UINT8   InterruptPin;\r
+  UINT16  BridgeControl;\r
+} PCI_BRIDGE_CONTROL_REGISTER;\r
+\r
+typedef struct {\r
+  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
+  PCI_BRIDGE_CONTROL_REGISTER   Bridge;\r
+} PCI_TYPE01;\r
+\r
+typedef union {\r
+  PCI_TYPE00  Device;\r
+  PCI_TYPE01  Bridge;\r
+} PCI_TYPE_GENERIC;\r
+\r
+typedef struct {\r
+  UINT32  CardBusSocketReg; // Cardus Socket/ExCA Base\r
+  // Address Register\r
+  //\r
+  UINT16  Reserved;\r
+  UINT16  SecondaryStatus;      // Secondary Status\r
+  UINT8   PciBusNumber;         // PCI Bus Number\r
+  UINT8   CardBusBusNumber;     // CardBus Bus Number\r
+  UINT8   SubordinateBusNumber; // Subordinate Bus Number\r
+  UINT8   CardBusLatencyTimer;  // CardBus Latency Timer\r
+  UINT32  MemoryBase0;          // Memory Base Register 0\r
+  UINT32  MemoryLimit0;         // Memory Limit Register 0\r
+  UINT32  MemoryBase1;\r
+  UINT32  MemoryLimit1;\r
+  UINT32  IoBase0;\r
+  UINT32  IoLimit0;             // I/O Base Register 0\r
+  UINT32  IoBase1;              // I/O Limit Register 0\r
+  UINT32  IoLimit1;\r
+  UINT8   InterruptLine;        // Interrupt Line\r
+  UINT8   InterruptPin;         // Interrupt Pin\r
+  UINT16  BridgeControl;        // Bridge Control\r
+} PCI_CARDBUS_CONTROL_REGISTER;\r
+\r
+//\r
+// Definitions of PCI class bytes and manipulation macros.\r
+//\r
+#define PCI_CLASS_OLD                 0x00\r
+#define PCI_CLASS_OLD_OTHER           0x00\r
+#define PCI_CLASS_OLD_VGA             0x01\r
+\r
+#define PCI_CLASS_MASS_STORAGE        0x01\r
+#define PCI_CLASS_MASS_STORAGE_SCSI   0x00\r
+#define PCI_CLASS_MASS_STORAGE_IDE    0x01  // obsolete\r
+#define PCI_CLASS_IDE                 0x01\r
+#define PCI_CLASS_MASS_STORAGE_FLOPPY 0x02\r
+#define PCI_CLASS_MASS_STORAGE_IPI    0x03\r
+#define PCI_CLASS_MASS_STORAGE_RAID   0x04\r
+#define PCI_CLASS_MASS_STORAGE_OTHER  0x80\r
+\r
+#define PCI_CLASS_NETWORK             0x02\r
+#define PCI_CLASS_NETWORK_ETHERNET    0x00\r
+#define PCI_CLASS_ETHERNET            0x00  // obsolete\r
+#define PCI_CLASS_NETWORK_TOKENRING   0x01\r
+#define PCI_CLASS_NETWORK_FDDI        0x02\r
+#define PCI_CLASS_NETWORK_ATM         0x03\r
+#define PCI_CLASS_NETWORK_ISDN        0x04\r
+#define PCI_CLASS_NETWORK_OTHER       0x80\r
+\r
+#define PCI_CLASS_DISPLAY             0x03\r
+#define PCI_CLASS_DISPLAY_CTRL        0x03  // obsolete\r
+#define PCI_CLASS_DISPLAY_VGA         0x00\r
+#define PCI_CLASS_VGA                 0x00  // obsolete\r
+#define PCI_CLASS_DISPLAY_XGA         0x01\r
+#define PCI_CLASS_DISPLAY_3D          0x02\r
+#define PCI_CLASS_DISPLAY_OTHER       0x80\r
+#define PCI_CLASS_DISPLAY_GFX         0x80\r
+#define PCI_CLASS_GFX                 0x80  // obsolete\r
+\r
+#define PCI_CLASS_BRIDGE              0x06\r
+#define PCI_CLASS_BRIDGE_HOST         0x00\r
+#define PCI_CLASS_BRIDGE_ISA          0x01\r
+#define PCI_CLASS_ISA                 0x01  // obsolete\r
+#define PCI_CLASS_BRIDGE_EISA         0x02\r
+#define PCI_CLASS_BRIDGE_MCA          0x03\r
+#define PCI_CLASS_BRIDGE_P2P          0x04\r
+#define PCI_CLASS_BRIDGE_PCMCIA       0x05\r
+#define PCI_CLASS_BRIDGE_NUBUS        0x06\r
+#define PCI_CLASS_BRIDGE_CARDBUS      0x07\r
+#define PCI_CLASS_BRIDGE_RACEWAY      0x08\r
+#define PCI_CLASS_BRIDGE_ISA_PDECODE  0x80\r
+#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80  // obsolete\r
+\r
+#define PCI_CLASS_SCC                 0x07  // Simple communications controllers \r
+#define PCI_SUBCLASS_SERIAL           0x00\r
+#define PCI_IF_GENERIC_XT             0x00\r
+#define PCI_IF_16450                  0x01\r
+#define PCI_IF_16550                  0x02\r
+#define PCI_IF_16650                  0x03\r
+#define PCI_IF_16750                  0x04\r
+#define PCI_IF_16850                  0x05\r
+#define PCI_IF_16950                  0x06\r
+#define PCI_SUBCLASS_PARALLEL         0x01\r
+#define PCI_IF_PARALLEL_PORT          0x00\r
+#define PCI_IF_BI_DIR_PARALLEL_PORT   0x01\r
+#define PCI_IF_ECP_PARALLEL_PORT      0x02\r
+#define PCI_IF_1284_CONTROLLER        0x03\r
+#define PCI_IF_1284_DEVICE            0xFE\r
+#define PCI_SUBCLASS_MULTIPORT_SERIAL 0x02\r
+#define PCI_SUBCLASS_MODEM            0x03\r
+#define PCI_IF_GENERIC_MODEM          0x00\r
+#define PCI_IF_16450_MODEM            0x01\r
+#define PCI_IF_16550_MODEM            0x02\r
+#define PCI_IF_16650_MODEM            0x03\r
+#define PCI_IF_16750_MODEM            0x04\r
+#define PCI_SUBCLASS_OTHER            0x80\r
+\r
+#define PCI_CLASS_SYSTEM_PERIPHERAL   0x08\r
+#define PCI_SUBCLASS_PIC              0x00\r
+#define PCI_IF_8259_PIC               0x00\r
+#define PCI_IF_ISA_PIC                0x01\r
+#define PCI_IF_EISA_PIC               0x02\r
+#define PCI_IF_APIC_CONTROLLER        0x10 // I/O APIC interrupt controller , 32 bye none-prefectable memory.  \r
+#define PCI_IF_APIC_CONTROLLER2       0x20 \r
+#define PCI_SUBCLASS_TIMER            0x02\r
+#define PCI_IF_8254_TIMER             0x00\r
+#define PCI_IF_ISA_TIMER              0x01\r
+#define PCI_EISA_TIMER                0x02\r
+#define PCI_SUBCLASS_RTC              0x03\r
+#define PCI_IF_GENERIC_RTC            0x00\r
+#define PCI_IF_ISA_RTC                0x00\r
+#define PCI_SUBCLASS_PNP_CONTROLLER   0x04 // HotPlug Controller\r
+\r
+#define PCI_CLASS_INPUT_DEVICE        0x09\r
+#define PCI_SUBCLASS_KEYBOARD         0x00\r
+#define PCI_SUBCLASS_PEN              0x01\r
+#define PCI_SUBCLASS_MOUSE_CONTROLLER 0x02\r
+#define PCI_SUBCLASS_SCAN_CONTROLLER  0x03\r
+#define PCI_SUBCLASS_GAMEPORT         0x04\r
+\r
+#define PCI_CLASS_DOCKING_STATION     0x0A\r
+\r
+#define PCI_CLASS_PROCESSOR           0x0B\r
+#define PCI_SUBCLASS_PROC_386         0x00\r
+#define PCI_SUBCLASS_PROC_486         0x01\r
+#define PCI_SUBCLASS_PROC_PENTIUM     0x02\r
+#define PCI_SUBCLASS_PROC_ALPHA       0x10\r
+#define PCI_SUBCLASS_PROC_POWERPC     0x20\r
+#define PCI_SUBCLASS_PROC_MIPS        0x30\r
+#define PCI_SUBCLASS_PROC_CO_PORC     0x40 // Co-Processor\r
+\r
+#define PCI_CLASS_SERIAL              0x0C\r
+#define PCI_CLASS_SERIAL_FIREWIRE     0x00\r
+#define PCI_CLASS_SERIAL_ACCESS_BUS   0x01\r
+#define PCI_CLASS_SERIAL_SSA          0x02\r
+#define PCI_CLASS_SERIAL_USB          0x03\r
+#define PCI_IF_EHCI                   0x20\r
+#define PCI_CLASS_SERIAL_FIBRECHANNEL 0x04\r
+#define PCI_CLASS_SERIAL_SMB          0x05\r
+\r
+#define PCI_CLASS_WIRELESS            0x0D\r
+#define PCI_SUBCLASS_IRDA             0x00\r
+#define PCI_SUBCLASS_IR               0x01\r
+#define PCI_SUBCLASS_RF               0x02\r
+\r
+#define PCI_CLASS_INTELLIGENT_IO      0x0E\r
+\r
+#define PCI_CLASS_SATELLITE           0x0F\r
+#define PCI_SUBCLASS_TV               0x01\r
+#define PCI_SUBCLASS_AUDIO            0x02\r
+#define PCI_SUBCLASS_VOICE            0x03\r
+#define PCI_SUBCLASS_DATA             0x04\r
+\r
+#define PCI_SECURITY_CONTROLLER       0x10 // Encryption and decryption controller\r
+#define PCI_SUBCLASS_NET_COMPUT       0x00\r
+#define PCI_SUBCLASS_ENTERTAINMENT    0x10 \r
+\r
+#define PCI_CLASS_DPIO                0x11\r
+\r
+#define IS_CLASS1(_p, c)              ((_p)->Hdr.ClassCode[2] == (c))\r
+#define IS_CLASS2(_p, c, s)           (IS_CLASS1 (_p, c) && ((_p)->Hdr.ClassCode[1] == (s)))\r
+#define IS_CLASS3(_p, c, s, p)        (IS_CLASS2 (_p, c, s) && ((_p)->Hdr.ClassCode[0] == (p)))\r
+\r
+#define IS_PCI_DISPLAY(_p)            IS_CLASS1 (_p, PCI_CLASS_DISPLAY)\r
+#define IS_PCI_VGA(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 0)\r
+#define IS_PCI_8514(_p)               IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 1)\r
+#define IS_PCI_GFX(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_GFX, 0)\r
+#define IS_PCI_OLD(_p)                IS_CLASS1 (_p, PCI_CLASS_OLD)\r
+#define IS_PCI_OLD_VGA(_p)            IS_CLASS2 (_p, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA)\r
+#define IS_PCI_IDE(_p)                IS_CLASS2 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_IDE)\r
+#define IS_PCI_SCSI(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_SCSI, 0)\r
+#define IS_PCI_RAID(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_RAID, 0)\r
+#define IS_PCI_LPC(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA, 0)\r
+#define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
+#define IS_PCI_P2P(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 0)\r
+#define IS_PCI_P2P_SUB(_p)            IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 1)\r
+#define IS_PCI_16550_SERIAL(_p)       IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)\r
+#define IS_PCI_USB(_p)                IS_CLASS2 (_p, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB)\r
+\r
+#define HEADER_TYPE_DEVICE            0x00\r
+#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01\r
+#define HEADER_TYPE_CARDBUS_BRIDGE    0x02\r
+\r
+#define HEADER_TYPE_MULTI_FUNCTION    0x80\r
+#define HEADER_LAYOUT_CODE            0x7f\r
+\r
+#define IS_PCI_BRIDGE(_p)             (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_PCI_TO_PCI_BRIDGE))\r
+#define IS_CARDBUS_BRIDGE(_p)         (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_CARDBUS_BRIDGE))\r
+#define IS_PCI_MULTI_FUNC(_p)         ((_p)->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION)\r
+\r
+#define PCI_DEVICE_ROMBAR             0x30\r
+#define PCI_BRIDGE_ROMBAR             0x38\r
+\r
+#define PCI_MAX_BAR                   0x0006\r
+#define PCI_MAX_CONFIG_OFFSET         0x0100\r
+\r
+#define PCI_VENDOR_ID_OFFSET                        0x00\r
+#define PCI_DEVICE_ID_OFFSET                        0x02\r
+#define PCI_COMMAND_OFFSET                          0x04\r
+#define PCI_PRIMARY_STATUS_OFFSET                   0x06\r
+#define PCI_REVISION_ID_OFFSET                      0x08\r
+#define PCI_CLASSCODE_OFFSET                        0x09\r
+#define PCI_SUBCLASSCODE_OFFSET                     0x0A\r
+#define PCI_CACHELINE_SIZE_OFFSET                   0x0C\r
+#define PCI_LATENCY_TIMER_OFFSET                    0x0D\r
+#define PCI_HEADER_TYPE_OFFSET                      0x0E\r
+#define PCI_BIST_OFFSET                             0x0F\r
+#define PCI_BASE_ADDRESSREG_OFFSET                  0x10\r
+#define PCI_CARDBUS_CIS_OFFSET                      0x28\r
+#define PCI_SVID_OFFSET                             0x2C // SubSystem Vendor id\r
+#define PCI_SUBSYSTEM_VENDOR_ID_OFFSET              0x2C\r
+#define PCI_SID_OFFSET                              0x2E // SubSystem ID\r
+#define PCI_SUBSYSTEM_ID_OFFSET                     0x2E\r
+#define PCI_EXPANSION_ROM_BASE                      0x30\r
+#define PCI_CAPBILITY_POINTER_OFFSET                0x34\r
+#define PCI_INT_LINE_OFFSET                         0x3C // Interrupt Line Register\r
+#define PCI_INT_PIN_OFFSET                          0x3D // Interrupt Pin Register\r
+#define PCI_MAXGNT_OFFSET                           0x3E // Max Grant Register\r
+#define PCI_MAXLAT_OFFSET                           0x3F // Max Latency Register\r
+\r
+#define PCI_BRIDGE_CONTROL_REGISTER_OFFSET          0x3E\r
+#define PCI_BRIDGE_STATUS_REGISTER_OFFSET           0x1E\r
+\r
+#define PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET      0x18\r
+#define PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET    0x19\r
+#define PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET  0x1a\r
+\r
+//\r
+// Interrupt Line "Unknown" or "No connection" value defined for x86 based system\r
+//\r
+#define PCI_INT_LINE_UNKNOWN                    0xFF               \r
+\r
+\r
+typedef struct {\r
+  UINT32  Reg : 8;\r
+  UINT32  Func : 3;\r
+  UINT32  Dev : 5;\r
+  UINT32  Bus : 8;\r
+  UINT32  Reserved : 7;\r
+  UINT32  Enable : 1;\r
+} PCI_CONFIG_ACCESS_CF8;\r
+\r
+#pragma pack()\r
+\r
+#define PCI_EXPANSION_ROM_HEADER_SIGNATURE              0xaa55\r
+#define PCI_DATA_STRUCTURE_SIGNATURE                    EFI_SIGNATURE_32 ('P', 'C', 'I', 'R')\r
+#define PCI_CODE_TYPE_PCAT_IMAGE                        0x00\r
+#define PCI_CODE_TYPE_EFI_IMAGE                         0x03\r
+#define EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED         0x0001\r
+\r
+#define EFI_PCI_COMMAND_IO_SPACE                        0x0001\r
+#define EFI_PCI_COMMAND_MEMORY_SPACE                    0x0002\r
+#define EFI_PCI_COMMAND_BUS_MASTER                      0x0004\r
+#define EFI_PCI_COMMAND_SPECIAL_CYCLE                   0x0008\r
+#define EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE     0x0010\r
+#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP               0x0020\r
+#define EFI_PCI_COMMAND_PARITY_ERROR_RESPOND            0x0040\r
+#define EFI_PCI_COMMAND_STEPPING_CONTROL                0x0080\r
+#define EFI_PCI_COMMAND_SERR                            0x0100\r
+#define EFI_PCI_COMMAND_FAST_BACK_TO_BACK               0x0200\r
+\r
+#define EFI_PCI_BRIDGE_CONTROL_PARITY_ERROR_RESPONSE    0x0001\r
+#define EFI_PCI_BRIDGE_CONTROL_SERR                     0x0002\r
+#define EFI_PCI_BRIDGE_CONTROL_ISA                      0x0004\r
+#define EFI_PCI_BRIDGE_CONTROL_VGA                      0x0008\r
+#define EFI_PCI_BRIDGE_CONTROL_VGA_16                   0x0010\r
+#define EFI_PCI_BRIDGE_CONTROL_MASTER_ABORT             0x0020\r
+#define EFI_PCI_BRIDGE_CONTROL_RESET_SECONDARY_BUS      0x0040\r
+#define EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK        0x0080\r
+#define EFI_PCI_BRIDGE_CONTROL_PRIMARY_DISCARD_TIMER    0x0100\r
+#define EFI_PCI_BRIDGE_CONTROL_SECONDARY_DISCARD_TIMER  0x0200\r
+#define EFI_PCI_BRIDGE_CONTROL_TIMER_STATUS             0x0400\r
+#define EFI_PCI_BRIDGE_CONTROL_DISCARD_TIMER_SERR       0x0800\r
+\r
+//\r
+// Following are the PCI-CARDBUS bridge control bit\r
+//\r
+#define EFI_PCI_BRIDGE_CONTROL_IREQINT_ENABLE       0x0080\r
+#define EFI_PCI_BRIDGE_CONTROL_RANGE0_MEMORY_TYPE   0x0100\r
+#define EFI_PCI_BRIDGE_CONTROL_RANGE1_MEMORY_TYPE   0x0200\r
+#define EFI_PCI_BRIDGE_CONTROL_WRITE_POSTING_ENABLE 0x0400\r
+\r
+//\r
+// Following are the PCI status control bit\r
+//\r
+#define EFI_PCI_STATUS_CAPABILITY             0x0010\r
+#define EFI_PCI_STATUS_66MZ_CAPABLE           0x0020\r
+#define EFI_PCI_FAST_BACK_TO_BACK_CAPABLE     0x0080\r
+#define EFI_PCI_MASTER_DATA_PARITY_ERROR      0x0100\r
+\r
+#define EFI_PCI_CAPABILITY_PTR                0x34\r
+#define EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR 0x14\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT8   Reserved[0x16];\r
+  UINT16  PcirOffset;\r
+} PCI_EXPANSION_ROM_HEADER;\r
+\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT8   Size512;\r
+  UINT8   InitEntryPoint[3];\r
+  UINT8   Reserved[0x12];\r
+  UINT16  PcirOffset;\r
+} EFI_LEGACY_EXPANSION_ROM_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  Signature;    // "PCIR"\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT16  Reserved0;\r
+  UINT16  Length;\r
+  UINT8   Revision;\r
+  UINT8   ClassCode[3];\r
+  UINT16  ImageLength;\r
+  UINT16  CodeRevision;\r
+  UINT8   CodeType;\r
+  UINT8   Indicator;\r
+  UINT16  Reserved1;\r
+} PCI_DATA_STRUCTURE;\r
+\r
+//\r
+// PCI Capability List IDs and records\r
+//\r
+#define EFI_PCI_CAPABILITY_ID_PMI     0x01\r
+#define EFI_PCI_CAPABILITY_ID_AGP     0x02\r
+#define EFI_PCI_CAPABILITY_ID_VPD     0x03\r
+#define EFI_PCI_CAPABILITY_ID_SLOTID  0x04\r
+#define EFI_PCI_CAPABILITY_ID_MSI     0x05\r
+#define EFI_PCI_CAPABILITY_ID_HOTPLUG 0x06\r
+#define EFI_PCI_CAPABILITY_ID_PCIX    0x07\r
+\r
+typedef struct {\r
+  UINT8 CapabilityID;\r
+  UINT8 NextItemPtr;\r
+} EFI_PCI_CAPABILITY_HDR;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_PMI\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  PMC;\r
+  UINT16                  PMCSR;\r
+  UINT8                   BridgeExtention;\r
+  UINT8                   Data;\r
+} EFI_PCI_CAPABILITY_PMI;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_AGP\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT8                   Rev;\r
+  UINT8                   Reserved;\r
+  UINT32                  Status;\r
+  UINT32                  Command;\r
+} EFI_PCI_CAPABILITY_AGP;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_VPD\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  AddrReg;\r
+  UINT32                  DataReg;\r
+} EFI_PCI_CAPABILITY_VPD;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_SLOTID\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT8                   ExpnsSlotReg;\r
+  UINT8                   ChassisNo;\r
+} EFI_PCI_CAPABILITY_SLOTID;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_MSI\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  MsgCtrlReg;\r
+  UINT32                  MsgAddrReg;\r
+  UINT16                  MsgDataReg;\r
+} EFI_PCI_CAPABILITY_MSI32;\r
+\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  MsgCtrlReg;\r
+  UINT32                  MsgAddrRegLsdw;\r
+  UINT32                  MsgAddrRegMsdw;\r
+  UINT16                  MsgDataReg;\r
+} EFI_PCI_CAPABILITY_MSI64;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_HOTPLUG\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  //\r
+  // not finished - fields need to go here\r
+  //\r
+} EFI_PCI_CAPABILITY_HOTPLUG;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_PCIX\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  CommandReg;\r
+  UINT32                  StatusReg;\r
+} EFI_PCI_CAPABILITY_PCIX;\r
+\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  SecStatusReg;\r
+  UINT32                  StatusReg;\r
+  UINT32                  SplitTransCtrlRegUp;\r
+  UINT32                  SplitTransCtrlRegDn;\r
+} EFI_PCI_CAPABILITY_PCIX_BRDG;\r
+\r
+#define DEVICE_ID_NOCARE    0xFFFF\r
+\r
+#define PCI_ACPI_UNUSED     0\r
+#define PCI_BAR_NOCHANGE    0\r
+#define PCI_BAR_OLD_ALIGN   0xFFFFFFFFFFFFFFFF\r
+#define PCI_BAR_EVEN_ALIGN  0xFFFFFFFFFFFFFFFE\r
+#define PCI_BAR_SQUAD_ALIGN 0xFFFFFFFFFFFFFFFD\r
+#define PCI_BAR_DQUAD_ALIGN 0xFFFFFFFFFFFFFFFC\r
+\r
+#define PCI_BAR_IDX0        0x00\r
+#define PCI_BAR_IDX1        0x01\r
+#define PCI_BAR_IDX2        0x02\r
+#define PCI_BAR_IDX3        0x03\r
+#define PCI_BAR_IDX4        0x04\r
+#define PCI_BAR_IDX5        0x05\r
+#define PCI_BAR_ALL         0xFF\r
+\r
+#pragma pack(pop)\r
+\r
+//\r
+// NOTE: The following header files are included here for\r
+// compatibility consideration.\r
+//\r
+#include "EfiPci.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h
new file mode 100644 (file)
index 0000000..c42991f
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    pci23.h\r
+\r
+Abstract:\r
+    Support for PCI 2.3 standard.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PCI23_H\r
+#define _PCI23_H\r
+\r
+#include "pci22.h"\r
+\r
+#define PCI_EXP_MAX_CONFIG_OFFSET     0x1000\r
+#define EFI_PCI_CAPABILITY_ID_PCIEXP  0x10\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h
new file mode 100644 (file)
index 0000000..1a9219b
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    pci30.h\r
+\r
+Abstract:\r
+    Support for PCI 3.0 standard.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PCI30_H\r
+#define _PCI30_H\r
+\r
+#include "pci23.h"\r
+\r
+#define PCI_CLASS_MASS_STORAGE_SATADPA   0x06\r
+#define PCI_CLASS_MASS_STORAGE_AHCI      PCI_CLASS_MASS_STORAGE_SATADPA\r
+\r
+#pragma pack(push, 1)\r
+\r
+typedef struct {\r
+  UINT32  Signature;    // "PCIR"\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT16  DeviceListOffset;\r
+  UINT16  Length;\r
+  UINT8   Revision;\r
+  UINT8   ClassCode[3];\r
+  UINT16  ImageLength;\r
+  UINT16  CodeRevision;\r
+  UINT8   CodeType;\r
+  UINT8   Indicator;\r
+  UINT16  MaxRuntimeImageLength;\r
+  UINT16  ConfigUtilityCodeHeaderOffset;\r
+  UINT16  DMTFCLPEntryPointOffset;\r
+} PCI_3_0_DATA_STRUCTURE;\r
+\r
+#pragma pack(pop)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h
new file mode 100644 (file)
index 0000000..70a6b23
--- /dev/null
@@ -0,0 +1,292 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                  \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    scsi.h\r
+    \r
+Abstract: \r
+    support for SCSI standard\r
+\r
+Revision History\r
+--*/\r
+\r
+#ifndef _SCSI_H\r
+#define _SCSI_H\r
+\r
+//\r
+// SCSI command OP Code\r
+//\r
+//\r
+// Commands for all device types\r
+//\r
+#define EFI_SCSI_OP_CHANGE_DEFINITION 0x40\r
+#define EFI_SCSI_OP_COMPARE           0x39\r
+#define EFI_SCSI_OP_COPY              0x18\r
+#define EFI_SCSI_OP_COPY_VERIFY       0x3a\r
+#define EFI_SCSI_OP_INQUIRY           0x12\r
+#define EFI_SCSI_OP_LOG_SELECT        0x4c\r
+#define EFI_SCSI_OP_LOG_SENSE         0x4d\r
+#define EFI_SCSI_OP_MODE_SEL6         0x15\r
+#define EFI_SCSI_OP_MODE_SEL10        0x55\r
+#define EFI_SCSI_OP_MODE_SEN6         0x1a\r
+#define EFI_SCSI_OP_MODE_SEN10        0x5a\r
+#define EFI_SCSI_OP_READ_BUFFER       0x3c\r
+#define EFI_SCSI_OP_REQUEST_SENSE     0x03\r
+#define EFI_SCSI_OP_SEND_DIAG         0x1d\r
+#define EFI_SCSI_OP_TEST_UNIT_READY   0x00\r
+#define EFI_SCSI_OP_WRITE_BUFF        0x3b\r
+\r
+//\r
+// Commands unique to Direct Access Devices\r
+//\r
+#define EFI_SCSI_OP_COMPARE         0x39\r
+#define EFI_SCSI_OP_FORMAT          0x04\r
+#define EFI_SCSI_OP_LOCK_UN_CACHE   0x36\r
+#define EFI_SCSI_OP_PREFETCH        0x34\r
+#define EFI_SCSI_OP_MEDIA_REMOVAL   0x1e\r
+#define EFI_SCSI_OP_READ6           0x08\r
+#define EFI_SCSI_OP_READ10          0x28\r
+#define EFI_SCSI_OP_READ_CAPACITY   0x25\r
+#define EFI_SCSI_OP_READ_DEFECT     0x37\r
+#define EFI_SCSI_OP_READ_LONG       0x3e\r
+#define EFI_SCSI_OP_REASSIGN_BLK    0x07\r
+#define EFI_SCSI_OP_RECEIVE_DIAG    0x1c\r
+#define EFI_SCSI_OP_RELEASE         0x17\r
+#define EFI_SCSI_OP_REZERO          0x01\r
+#define EFI_SCSI_OP_SEARCH_DATA_E   0x31\r
+#define EFI_SCSI_OP_SEARCH_DATA_H   0x30\r
+#define EFI_SCSI_OP_SEARCH_DATA_L   0x32\r
+#define EFI_SCSI_OP_SEEK6           0x0b\r
+#define EFI_SCSI_OP_SEEK10          0x2b\r
+#define EFI_SCSI_OP_SEND_DIAG       0x1d\r
+#define EFI_SCSI_OP_SET_LIMIT       0x33\r
+#define EFI_SCSI_OP_START_STOP_UNIT 0x1b\r
+#define EFI_SCSI_OP_SYNC_CACHE      0x35\r
+#define EFI_SCSI_OP_VERIFY          0x2f\r
+#define EFI_SCSI_OP_WRITE6          0x0a\r
+#define EFI_SCSI_OP_WRITE10         0x2a\r
+#define EFI_SCSI_OP_WRITE_VERIFY    0x2e\r
+#define EFI_SCSI_OP_WRITE_LONG      0x3f\r
+#define EFI_SCSI_OP_WRITE_SAME      0x41\r
+\r
+//\r
+// Commands unique to Sequential Access Devices\r
+//\r
+#define EFI_SCSI_OP_ERASE             0x19\r
+#define EFI_SCSI_OP_LOAD_UNLOAD       0x1b\r
+#define EFI_SCSI_OP_LOCATE            0x2b\r
+#define EFI_SCSI_OP_READ_BLOCK_LIMIT  0x05\r
+#define EFI_SCSI_OP_READ_POS          0x34\r
+#define EFI_SCSI_OP_READ_REVERSE      0x0f\r
+#define EFI_SCSI_OP_RECOVER_BUF_DATA  0x14\r
+#define EFI_SCSI_OP_RESERVE_UNIT      0x16\r
+#define EFI_SCSI_OP_REWIND            0x01\r
+#define EFI_SCSI_OP_SPACE             0x11\r
+#define EFI_SCSI_OP_VERIFY_TAPE       0x13\r
+#define EFI_SCSI_OP_WRITE_FILEMARK    0x10\r
+\r
+//\r
+// Commands unique to Printer Devices\r
+//\r
+#define EFI_SCSI_OP_PRINT       0x0a\r
+#define EFI_SCSI_OP_SLEW_PRINT  0x0b\r
+#define EFI_SCSI_OP_STOP_PRINT  0x1b\r
+#define EFI_SCSI_OP_SYNC_BUFF   0x10\r
+\r
+//\r
+// Commands unique to Processor Devices\r
+//\r
+#define EFI_SCSI_OP_RECEIVE 0x08\r
+#define EFI_SCSI_OP_SEND    0x0a\r
+\r
+//\r
+// Commands unique to Write-Once Devices\r
+//\r
+#define EFI_SCSI_OP_MEDIUM_SCAN     0x38\r
+#define EFI_SCSI_OP_SEARCH_DAT_E10  0x31\r
+#define EFI_SCSI_OP_SEARCH_DAT_E12  0xb1\r
+#define EFI_SCSI_OP_SEARCH_DAT_H10  0x30\r
+#define EFI_SCSI_OP_SEARCH_DAT_H12  0xb0\r
+#define EFI_SCSI_OP_SEARCH_DAT_L10  0x32\r
+#define EFI_SCSI_OP_SEARCH_DAT_L12  0xb2\r
+#define EFI_SCSI_OP_SET_LIMIT10     0x33\r
+#define EFI_SCSI_OP_SET_LIMIT12     0xb3\r
+#define EFI_SCSI_OP_VERIFY10        0x2f\r
+#define EFI_SCSI_OP_VERIFY12        0xaf\r
+#define EFI_SCSI_OP_WRITE12         0xaa\r
+#define EFI_SCSI_OP_WRITE_VERIFY10  0x2e\r
+#define EFI_SCSI_OP_WRITE_VERIFY12  0xae\r
+\r
+//\r
+// Commands unique to CD-ROM Devices\r
+//\r
+#define EFI_SCSI_OP_PLAY_AUD_10       0x45\r
+#define EFI_SCSI_OP_PLAY_AUD_12       0xa5\r
+#define EFI_SCSI_OP_PLAY_AUD_MSF      0x47\r
+#define EFI_SCSI_OP_PLAY_AUD_TKIN     0x48\r
+#define EFI_SCSI_OP_PLAY_TK_REL10     0x49\r
+#define EFI_SCSI_OP_PLAY_TK_REL12     0xa9\r
+#define EFI_SCSI_OP_READ_CD_CAPACITY  0x25\r
+#define EFI_SCSI_OP_READ_HEADER       0x44\r
+#define EFI_SCSI_OP_READ_SUB_CHANNEL  0x42\r
+#define EFI_SCSI_OP_READ_TOC          0x43\r
+\r
+//\r
+// Commands unique to Scanner Devices\r
+//\r
+#define EFI_SCSI_OP_GET_DATABUFF_STAT 0x34\r
+#define EFI_SCSI_OP_GET_WINDOW        0x25\r
+#define EFI_SCSI_OP_OBJECT_POS        0x31\r
+#define EFI_SCSI_OP_SCAN              0x1b\r
+#define EFI_SCSI_OP_SET_WINDOW        0x24\r
+\r
+//\r
+// Commands unique to Optical Memory Devices\r
+//\r
+#define EFI_SCSI_OP_UPDATE_BLOCK  0x3d\r
+\r
+//\r
+// Commands unique to Medium Changer Devices\r
+//\r
+#define EFI_SCSI_OP_EXCHANGE_MEDIUM   0xa6\r
+#define EFI_SCSI_OP_INIT_ELEMENT_STAT 0x07\r
+#define EFI_SCSI_OP_POS_TO_ELEMENT    0x2b\r
+#define EFI_SCSI_OP_REQUEST_VE_ADDR   0xb5\r
+#define EFI_SCSI_OP_SEND_VOL_TAG      0xb6\r
+\r
+//\r
+// Commands unique to Communition Devices\r
+//\r
+#define EFI_SCSI_OP_GET_MESSAGE6    0x08\r
+#define EFI_SCSI_OP_GET_MESSAGE10   0x28\r
+#define EFI_SCSI_OP_GET_MESSAGE12   0xa8\r
+#define EFI_SCSI_OP_SEND_MESSAGE6   0x0a\r
+#define EFI_SCSI_OP_SEND_MESSAGE10  0x2a\r
+#define EFI_SCSI_OP_SEND_MESSAGE12  0xaa\r
+\r
+//\r
+// SCSI Data Transfer Direction\r
+//\r
+#define EFI_SCSI_DATA_IN  0\r
+#define EFI_SCSI_DATA_OUT 1\r
+\r
+//\r
+// Peripheral Device Type Definitions\r
+//\r
+#define EFI_SCSI_TYPE_DISK          0x00  // Disk device\r
+#define EFI_SCSI_TYPE_TAPE          0x01  // Tape device\r
+#define EFI_SCSI_TYPE_PRINTER       0x02  // Printer\r
+#define EFI_SCSI_TYPE_PROCESSOR     0x03  // Processor\r
+#define EFI_SCSI_TYPE_WORM          0x04  // Write-once read-multiple\r
+#define EFI_SCSI_TYPE_CDROM         0x05  // CD-ROM device\r
+#define EFI_SCSI_TYPE_SCANNER       0x06  // Scanner device\r
+#define EFI_SCSI_TYPE_OPTICAL       0x07  // Optical memory device\r
+#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08  // Medium Changer device\r
+#define EFI_SCSI_TYPE_COMMUNICATION 0x09  // Communications device\r
+#define EFI_SCSI_TYPE_RESERVED_LOW  0x0A  // Reserved (low)\r
+#define EFI_SCSI_TYPE_RESERVED_HIGH 0x1E  // Reserved (high)\r
+#define EFI_SCSI_TYPE_UNKNOWN       0x1F  // Unknown or no device type\r
+#pragma pack(1)\r
+//\r
+// Data structures for scsi command use\r
+//\r
+typedef struct {\r
+  UINT8 Peripheral_Type : 5;\r
+  UINT8 Peripheral_Qualifier : 3;\r
+  UINT8 DeviceType_Modifier : 7;\r
+  UINT8 RMB : 1;\r
+  UINT8 Version;\r
+  UINT8 Response_Data_Format;\r
+  UINT8 Addnl_Length;\r
+  UINT8 Reserved_5_95[95 - 5 + 1];\r
+} EFI_SCSI_INQUIRY_DATA;\r
+\r
+typedef struct {\r
+  UINT8 Error_Code : 7;\r
+  UINT8 Valid : 1;\r
+  UINT8 Segment_Number;\r
+  UINT8 Sense_Key : 4;\r
+  UINT8 Reserved_21 : 1;\r
+  UINT8 ILI : 1;\r
+  UINT8 Reserved_22 : 2;\r
+  UINT8 Information_3_6[4];\r
+  UINT8 Addnl_Sense_Length;           // n - 7\r
+  UINT8 Vendor_Specific_8_11[4];\r
+  UINT8 Addnl_Sense_Code;             // mandatory\r
+  UINT8 Addnl_Sense_Code_Qualifier;   // mandatory\r
+  UINT8 Field_Replaceable_Unit_Code;  // optional\r
+  UINT8 Reserved_15_17[3];\r
+} EFI_SCSI_SENSE_DATA;\r
+\r
+typedef struct {\r
+  UINT8 LastLba3;\r
+  UINT8 LastLba2;\r
+  UINT8 LastLba1;\r
+  UINT8 LastLba0;\r
+  UINT8 BlockSize3;\r
+  UINT8 BlockSize2;\r
+  UINT8 BlockSize1;\r
+  UINT8 BlockSize0;\r
+} EFI_SCSI_DISK_CAPACITY_DATA;\r
+\r
+#pragma pack()\r
+//\r
+// Sense Key\r
+//\r
+#define EFI_SCSI_REQUEST_SENSE_ERROR  (0x70)\r
+#define EFI_SCSI_SK_NO_SENSE          (0x0)\r
+#define EFI_SCSI_SK_RECOVERY_ERROR    (0x1)\r
+#define EFI_SCSI_SK_NOT_READY         (0x2)\r
+#define EFI_SCSI_SK_MEDIUM_ERROR      (0x3)\r
+#define EFI_SCSI_SK_HARDWARE_ERROR    (0x4)\r
+#define EFI_SCSI_SK_ILLEGAL_REQUEST   (0x5)\r
+#define EFI_SCSI_SK_UNIT_ATTENTION    (0x6)\r
+#define EFI_SCSI_SK_DATA_PROTECT      (0x7)\r
+#define EFI_SCSI_SK_BLANK_CHECK       (0x8)\r
+#define EFI_SCSI_SK_VENDOR_SPECIFIC   (0x9)\r
+#define EFI_SCSI_SK_RESERVED_A        (0xA)\r
+#define EFI_SCSI_SK_ABORT             (0xB)\r
+#define EFI_SCSI_SK_RESERVED_C        (0xC)\r
+#define EFI_SCSI_SK_OVERFLOW          (0xD)\r
+#define EFI_SCSI_SK_MISCOMPARE        (0xE)\r
+#define EFI_SCSI_SK_RESERVED_F        (0xF)\r
+\r
+//\r
+// Additional Sense Codes\r
+//\r
+#define EFI_SCSI_ASC_NOT_READY                    (0x04)\r
+#define EFI_SCSI_ASC_MEDIA_ERR1                   (0x10)\r
+#define EFI_SCSI_ASC_MEDIA_ERR2                   (0x11)\r
+#define EFI_SCSI_ASC_MEDIA_ERR3                   (0x14)\r
+#define EFI_SCSI_ASC_MEDIA_ERR4                   (0x30)\r
+#define EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN            (0x06)\r
+#define EFI_SCSI_ASC_INVALID_CMD                  (0x20)\r
+#define EFI_SCSI_ASC_LBA_OUT_OF_RANGE             (0x21)\r
+#define EFI_SCSI_ASC_INVALID_FIELD                (0x24)\r
+#define EFI_SCSI_ASC_WRITE_PROTECTED              (0x27)\r
+#define EFI_SCSI_ASC_MEDIA_CHANGE                 (0x28)\r
+#define EFI_SCSI_ASC_RESET                        (0x29)  /* Power On Reset or Bus Reset occurred */\r
+#define EFI_SCSI_ASC_ILLEGAL_FIELD                (0x26)\r
+#define EFI_SCSI_ASC_NO_MEDIA                     (0x3A)\r
+#define EFI_SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK  (0x64)\r
+\r
+//\r
+// Additional Sense Code Qualifier\r
+//\r
+#define EFI_SCSI_ASCQ_IN_PROGRESS (0x01)\r
+\r
+//\r
+// Max bytes needed to represent ID of a SCSI device\r
+//\r
+#define EFI_SCSI_TARGET_MAX_BYTES (0x10)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h
new file mode 100644 (file)
index 0000000..8ccfd11
--- /dev/null
@@ -0,0 +1,293 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    usb.h\r
+\r
+Abstract:\r
+    Support for USB 1.1 standard.\r
+\r
+\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _USB_H\r
+#define _USB_H\r
+//\r
+// USB Descriptor types\r
+//\r
+#define USB_DT_DEVICE     0x01\r
+#define USB_DT_CONFIG     0x02\r
+#define USB_DT_STRING     0x03\r
+#define USB_DT_INTERFACE  0x04\r
+#define USB_DT_ENDPOINT   0x05\r
+#define USB_DT_HUB        0x29\r
+#define USB_DT_HID        0x21\r
+\r
+//\r
+// USB request type\r
+//\r
+#define USB_TYPE_STANDARD (0x00 << 5)\r
+#define USB_TYPE_CLASS    (0x01 << 5)\r
+#define USB_TYPE_VENDOR   (0x02 << 5)\r
+#define USB_TYPE_RESERVED (0x03 << 5)\r
+\r
+//\r
+// USB request targer device\r
+//\r
+#define USB_RECIP_DEVICE    0x00\r
+#define USB_RECIP_INTERFACE 0x01\r
+#define USB_RECIP_ENDPOINT  0x02\r
+#define USB_RECIP_OTHER     0x03\r
+\r
+//\r
+// Request target types.\r
+//\r
+#define USB_RT_DEVICE     0x00\r
+#define USB_RT_INTERFACE  0x01\r
+#define USB_RT_ENDPOINT   0x02\r
+#define USB_RT_HUB        (USB_TYPE_CLASS | USB_RECIP_DEVICE)\r
+#define USB_RT_PORT       (USB_TYPE_CLASS | USB_RECIP_OTHER)\r
+\r
+//\r
+// USB Transfer Results\r
+//\r
+#define EFI_USB_NOERROR         0x00\r
+#define EFI_USB_ERR_NOTEXECUTE  0x01\r
+#define EFI_USB_ERR_STALL       0x02\r
+#define EFI_USB_ERR_BUFFER      0x04\r
+#define EFI_USB_ERR_BABBLE      0x08\r
+#define EFI_USB_ERR_NAK         0x10\r
+#define EFI_USB_ERR_CRC         0x20\r
+#define EFI_USB_ERR_TIMEOUT     0x40\r
+#define EFI_USB_ERR_BITSTUFF    0x80\r
+#define EFI_USB_ERR_SYSTEM      0x100\r
+\r
+//\r
+//Use 200 ms to increase the error handling response time\r
+//\r
+#define EFI_USB_INTERRUPT_DELAY 2000000\r
+\r
+//\r
+// USB transation direction\r
+//\r
+typedef enum {\r
+  EfiUsbDataIn,\r
+  EfiUsbDataOut,\r
+  EfiUsbNoData\r
+} EFI_USB_DATA_DIRECTION;\r
+\r
+//\r
+// Usb Data recipient type\r
+//\r
+typedef enum {\r
+  EfiUsbDevice,\r
+  EfiUsbInterface,\r
+  EfiUsbEndpoint\r
+} EFI_USB_RECIPIENT;\r
+\r
+typedef enum {\r
+  EfiUsbEndpointHalt,\r
+  EfiUsbDeviceRemoteWakeup\r
+} EFI_USB_STANDARD_FEATURE_SELECTOR;\r
+\r
+#pragma pack(1)\r
+//\r
+// Usb device request structure\r
+//\r
+typedef struct {\r
+  UINT8   RequestType;\r
+  UINT8   Request;\r
+  UINT16  Value;\r
+  UINT16  Index;\r
+  UINT16  Length;\r
+} EFI_USB_DEVICE_REQUEST;\r
+\r
+//\r
+// Standard USB request\r
+//\r
+#define USB_DEV_GET_STATUS                  0x00\r
+\r
+#define USB_DEV_CLEAR_FEATURE               0x01\r
+\r
+#define USB_DEV_SET_FEATURE                 0x03\r
+\r
+#define USB_DEV_SET_ADDRESS                 0x05\r
+#define USB_DEV_SET_ADDRESS_REQ_TYPE        0x00\r
+\r
+#define USB_DEV_GET_DESCRIPTOR              0x06\r
+#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE     0x80\r
+\r
+#define USB_DEV_SET_DESCRIPTOR              0x07\r
+#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE     0x00\r
+\r
+#define USB_DEV_GET_CONFIGURATION           0x08\r
+#define USB_DEV_GET_CONFIGURATION_REQ_TYPE  0x80\r
+\r
+#define USB_DEV_SET_CONFIGURATION           0x09\r
+#define USB_DEV_SET_CONFIGURATION_REQ_TYPE  0x00\r
+\r
+#define USB_DEV_GET_INTERFACE               0x0A\r
+#define USB_DEV_GET_INTERFACE_REQ_TYPE      0x81\r
+\r
+#define USB_DEV_SET_INTERFACE               0x0B\r
+#define USB_DEV_SET_INTERFACE_REQ_TYPE      0x01\r
+\r
+#define USB_DEV_SYNCH_FRAME                 0x0C\r
+#define USB_DEV_SYNCH_FRAME_REQ_TYPE        0x82\r
+\r
+//\r
+// Device descriptor. refer USB1.1\r
+//\r
+typedef struct usb_device_descriptor {\r
+  UINT8   Length;\r
+  UINT8   DescriptorType;\r
+  UINT16  BcdUSB;\r
+  UINT8   DeviceClass;\r
+  UINT8   DeviceSubClass;\r
+  UINT8   DeviceProtocol;\r
+  UINT8   MaxPacketSize0;\r
+  UINT16  IdVendor;\r
+  UINT16  IdProduct;\r
+  UINT16  BcdDevice;\r
+  UINT8   StrManufacturer;\r
+  UINT8   StrProduct;\r
+  UINT8   StrSerialNumber;\r
+  UINT8   NumConfigurations;\r
+} EFI_USB_DEVICE_DESCRIPTOR;\r
+\r
+//\r
+// Endpoint descriptor\r
+//\r
+typedef struct {\r
+  UINT8   Length;\r
+  UINT8   DescriptorType;\r
+  UINT8   EndpointAddress;\r
+  UINT8   Attributes;\r
+  UINT16  MaxPacketSize;\r
+  UINT8   Interval;\r
+} EFI_USB_ENDPOINT_DESCRIPTOR;\r
+\r
+//\r
+// Interface descriptor\r
+//\r
+typedef struct {\r
+  UINT8 Length;\r
+  UINT8 DescriptorType;\r
+  UINT8 InterfaceNumber;\r
+  UINT8 AlternateSetting;\r
+  UINT8 NumEndpoints;\r
+  UINT8 InterfaceClass;\r
+  UINT8 InterfaceSubClass;\r
+  UINT8 InterfaceProtocol;\r
+  UINT8 Interface;\r
+} EFI_USB_INTERFACE_DESCRIPTOR;\r
+\r
+//\r
+// USB alternate setting\r
+//\r
+typedef struct {\r
+  EFI_USB_INTERFACE_DESCRIPTOR  *Interface;\r
+} USB_ALT_SETTING;\r
+\r
+//\r
+// Configuration descriptor\r
+//\r
+typedef struct {\r
+  UINT8   Length;\r
+  UINT8   DescriptorType;\r
+  UINT16  TotalLength;\r
+  UINT8   NumInterfaces;\r
+  UINT8   ConfigurationValue;\r
+  UINT8   Configuration;\r
+  UINT8   Attributes;\r
+  UINT8   MaxPower;\r
+} EFI_USB_CONFIG_DESCRIPTOR;\r
+\r
+//\r
+// Supported String Languages\r
+//\r
+typedef struct {\r
+  UINT8   Length;\r
+  UINT8   DescriptorType;\r
+  UINT16  SupportedLanID[1];\r
+} EFI_USB_SUPPORTED_LANGUAGES;\r
+\r
+//\r
+// String descriptor\r
+//\r
+typedef struct {\r
+  UINT8   Length;\r
+  UINT8   DescriptorType;\r
+  CHAR16  String[1];\r
+} EFI_USB_STRING_DESCRIPTOR;\r
+\r
+//\r
+// Hub descriptor\r
+//\r
+#define MAXBYTES  8\r
+typedef struct {\r
+  UINT8 Length;\r
+  UINT8 DescriptorType;\r
+  UINT8 NbrPorts;\r
+  UINT8 HubCharacteristics[2];\r
+  UINT8 PwrOn2PwrGood;\r
+  UINT8 HubContrCurrent;\r
+  UINT8 Filler[MAXBYTES];\r
+} EFI_USB_HUB_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  UINT16  PortStatus;\r
+  UINT16  PortChangeStatus;\r
+} EFI_USB_PORT_STATUS;\r
+\r
+//\r
+// Constant value for Port Status & Port Change Status\r
+//\r
+#define USB_PORT_STAT_CONNECTION    0x0001\r
+#define USB_PORT_STAT_ENABLE        0x0002\r
+#define USB_PORT_STAT_SUSPEND       0x0004\r
+#define USB_PORT_STAT_OVERCURRENT   0x0008\r
+#define USB_PORT_STAT_RESET         0x0010\r
+#define USB_PORT_STAT_POWER         0x0100\r
+#define USB_PORT_STAT_LOW_SPEED     0x0200\r
+#define USB_PORT_STAT_HIGH_SPEED    0x0400\r
+#define USB_PORT_STAT_OWNER         0x0800\r
+\r
+#define USB_PORT_STAT_C_CONNECTION  0x0001\r
+#define USB_PORT_STAT_C_ENABLE      0x0002\r
+#define USB_PORT_STAT_C_SUSPEND     0x0004\r
+#define USB_PORT_STAT_C_OVERCURRENT 0x0008\r
+#define USB_PORT_STAT_C_RESET       0x0010\r
+\r
+//\r
+// Used for set/clear port feature request\r
+//\r
+typedef enum {\r
+  EfiUsbPortEnable            = 1,\r
+  EfiUsbPortSuspend           = 2,\r
+  EfiUsbPortReset             = 4,\r
+  EfiUsbPortPower             = 8,\r
+  EfiUsbPortOwner             = 13,\r
+  EfiUsbPortConnectChange     = 16,\r
+  EfiUsbPortEnableChange      = 17,\r
+  EfiUsbPortSuspendChange     = 18,\r
+  EfiUsbPortOverCurrentChange = 19,\r
+  EfiUsbPortResetChange       = 20\r
+} EFI_USB_PORT_FEATURE;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h
new file mode 100644 (file)
index 0000000..cad7ca1
--- /dev/null
@@ -0,0 +1,247 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiBind.h\r
+\r
+Abstract:\r
+\r
+  Processor or Compiler specific defines and types for Intel Itanium(TM).\r
+  We are using the ANSI C 2000 _t type definitions for basic types.\r
+  This it technically a violation of the coding standard, but they\r
+  are used to make EfiTypes.h portable. Code other than EfiTypes.h\r
+  should never use any ANSI C 2000 _t integer types.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BIND_H_\r
+#define _EFI_BIND_H_\r
+\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)                 \r
+\r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+\r
+\r
+\r
+//\r
+// Make sure we are useing the correct packing rules per EFI specification\r
+//\r
+#pragma pack()\r
+\r
+\r
+#if _MSC_EXTENSIONS \r
+    \r
+//\r
+// Disable warning that make it impossible to compile at /W4\r
+// This only works for Microsoft tools. Copied from the \r
+// IA-32 version of efibind.h\r
+//\r
+\r
+//\r
+// Disabling bitfield type checking warnings.\r
+//\r
+#pragma warning ( disable : 4214 )\r
+\r
+\r
+// Disabling the unreferenced formal parameter warnings.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// Disable slightly different base types warning as CHAR8 * can not be set\r
+// to a constant string.\r
+//\r
+#pragma warning ( disable : 4057 )\r
+\r
+//\r
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
+//\r
+#pragma warning ( disable : 4127 )\r
+\r
+//\r
+// Can not cast a function pointer to a data pointer. We need to do this on \r
+// IPF to get access to the PLABEL.\r
+//\r
+#pragma warning ( disable : 4514 )\r
+\r
+//\r
+// Int64ShllMod32 unreferenced inline function\r
+//\r
+#pragma warning ( disable : 4054 )\r
+\r
+//\r
+// Unreferenced formal parameter - We are object oriented, so we pass This even\r
+//  if we  don't need them.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// This warning is caused by empty (after preprocessing) souce file.\r
+//\r
+#pragma warning ( disable : 4206 )\r
+\r
+//\r
+// Warning: The result of the unary '&' operator may be unaligned. Ignore it.\r
+//\r
+#pragma warning ( disable : 4366 )\r
+\r
+#endif\r
+\r
+\r
+#if (__STDC_VERSION__ < 199901L)\r
+  //\r
+  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
+  //\r
\r
+  #if _MSC_EXTENSIONS \r
+    \r
+\r
+    //\r
+    // use Microsoft C complier dependent interger width types \r
+    //\r
+    typedef unsigned __int64    uint64_t;\r
+    typedef __int64             int64_t;\r
+    typedef unsigned __int32    uint32_t;\r
+    typedef __int32             int32_t;\r
+    typedef unsigned short      uint16_t;\r
+    typedef short               int16_t;\r
+    typedef unsigned char       uint8_t;\r
+    typedef char                int8_t;\r
+  #else\r
+    #ifdef _EFI_P64 \r
+      //\r
+      // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints \r
+      //  are 32-bits\r
+      //\r
+      typedef unsigned long long  uint64_t;\r
+      typedef long long           int64_t;\r
+      typedef unsigned int        uint32_t;\r
+      typedef int                 int32_t;\r
+      typedef unsigned short      uint16_t;\r
+      typedef short               int16_t;\r
+      typedef unsigned char       uint8_t;\r
+      typedef char                int8_t;\r
+    #else\r
+      //\r
+      // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.\r
+      //\r
+      typedef unsigned long   uint64_t;\r
+      typedef long            int64_t;\r
+      typedef unsigned int    uint32_t;\r
+      typedef int             int32_t;\r
+      typedef unsigned short  uint16_t;\r
+      typedef short           int16_t;\r
+      typedef unsigned char   uint8_t;\r
+      typedef char            int8_t;\r
+    #endif\r
+  #endif\r
+#else\r
+  //\r
+  // Use ANSI C 2000 stdint.h integer width declarations\r
+  //\r
+  #include "stdint.h"\r
+#endif\r
+\r
+//\r
+// Native integer size in stdint.h\r
+//\r
+typedef uint64_t  uintn_t;\r
+typedef int64_t   intn_t;\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+#define EFI_MAX_BIT  0x8000000000000000\r
+#define MAX_2_BITS   0xC000000000000000\r
+\r
+//\r
+// Maximum legal Itanium-based address\r
+//\r
+#define EFI_MAX_ADDRESS   0xFFFFFFFFFFFFFFFF\r
+\r
+//\r
+//  Bad pointer value to use in check builds.\r
+//  if you see this value you are using uninitialized or free'ed data\r
+//\r
+#define EFI_BAD_POINTER          0xAFAFAFAFAFAFAFAF\r
+#define EFI_BAD_POINTER_AS_BYTE  0xAF\r
+\r
+//\r
+// Inject a break point in the code to assist debugging.\r
+//\r
+#pragma intrinsic (__break)  \r
+#define EFI_BREAKPOINT()  __break(0)\r
+#define EFI_DEADLOOP()    while(TRUE)\r
+\r
+//\r
+// Memory Fence forces serialization, and is needed to support out of order\r
+//  memory transactions. The Memory Fence is mainly used to make sure IO\r
+//  transactions complete in a deterministic sequence, and to syncronize locks\r
+//  an other MP code. Intel Itanium(TM) processors require explicit memory fence instructions\r
+//  after every IO. Need to find a way of doing that in the function _mf.\r
+//\r
+void __mfa (void);                       \r
+#pragma intrinsic (__mfa)  \r
+#define MEMORY_FENCE()  __mfa()\r
+\r
+\r
+//\r
+// Some compilers don't support the forward reference construct:\r
+//  typedef struct XXXXX. The forward reference is required for \r
+//  ANSI compatibility.\r
+//\r
+// The following macro provide a workaround for such cases.\r
+//\r
+\r
+\r
+#ifdef EFI_NO_INTERFACE_DECL\r
+  #define EFI_FORWARD_DECLARATION(x)\r
+#else\r
+  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x\r
+#endif\r
+\r
+//\r
+// Some C compilers optimize the calling conventions to increase performance.\r
+// _EFIAPI is used to make all public APIs follow the standard C calling \r
+// convention.\r
+//\r
+\r
+#if _MSC_EXTENSIONS \r
+  #define _EFIAPI __cdecl  \r
+#else\r
+  #define _EFIAPI       \r
+#endif\r
+\r
+\r
+#ifdef _EFI_WINNT\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4142 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4142 )\r
+#else\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4068 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4068 )\r
+\r
+\r
+#endif\r
+\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h
new file mode 100644 (file)
index 0000000..53de8aa
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiPeOptionalHeader.h\r
+\r
+Abstract:\r
+  Defines the optional header in the PE image per the PE specification.  This\r
+  file must be included only from within EfiImage.h since \r
+  EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined\r
+  there.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_\r
+#define _EFI_PE_OPTIONAL_HEADER_H_\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA64)\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64      EFI_IMAGE_NT_HEADERS;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h
new file mode 100644 (file)
index 0000000..0fe1407
--- /dev/null
@@ -0,0 +1,556 @@
+// ++\r
+\r
+// TODO: fix comment to start with /*++\r
+//\r
+// Copyright (c) 2004, Intel Corporation\r
+// All rights reserved. This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution.  The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// Module Name:\r
+//\r
+//  IpfDefines.h\r
+//\r
+// Abstract:\r
+//\r
+//  IPF Processor Defines.\r
+//  NOTE: This file is included by assembly files as well.\r
+//\r
+// --\r
+//\r
+#ifndef _IPFDEFINES_H\r
+#define _IPFDEFINES_H\r
+\r
+//\r
+//  IPI DElivery Methods\r
+//\r
+#define IPI_INT_DELIVERY    0x0\r
+#define IPI_PMI_DELIVERY    0x2\r
+#define IPI_NMI_DELIVERY    0x4\r
+#define IPI_INIT_DELIVERY   0x5\r
+#define IPI_ExtINT_DELIVERY 0x7\r
+\r
+//\r
+// Define Itanium-based system registers.\r
+//\r
+// Define Itanium-based system register bit field offsets.\r
+//\r
+// Processor Status Register (PSR) Bit positions\r
+//\r
+// User / System mask\r
+//\r
+#define PSR_RV0 0\r
+#define PSR_BE  1\r
+#define PSR_UP  2\r
+#define PSR_AC  3\r
+#define PSR_MFL 4\r
+#define PSR_MFH 5\r
+\r
+//\r
+// PSR bits 6-12 reserved (must be zero)\r
+//\r
+#define PSR_MBZ0    6\r
+#define PSR_MBZ0_V  0x1ffUL L\r
+\r
+//\r
+// System only mask\r
+//\r
+#define PSR_IC      13\r
+#define PSR_IC_MASK (1 << 13)\r
+#define PSR_I       14\r
+#define PSR_PK      15\r
+#define PSR_MBZ1    16\r
+#define PSR_MBZ1_V  0x1UL L\r
+#define PSR_DT      17\r
+#define PSR_DFL     18\r
+#define PSR_DFH     19\r
+#define PSR_SP      20\r
+#define PSR_PP      21\r
+#define PSR_DI      22\r
+#define PSR_SI      23\r
+#define PSR_DB      24\r
+#define PSR_LP      25\r
+#define PSR_TB      26\r
+#define PSR_RT      27\r
+\r
+//\r
+// PSR bits 28-31 reserved (must be zero)\r
+//\r
+#define PSR_MBZ2    28\r
+#define PSR_MBZ2_V  0xfUL L\r
+\r
+//\r
+// Neither mask\r
+//\r
+#define PSR_CPL     32\r
+#define PSR_CPL_LEN 2\r
+#define PSR_IS      34\r
+#define PSR_MC      35\r
+#define PSR_IT      36\r
+#define PSR_IT_MASK 0x1000000000\r
+#define PSR_ID      37\r
+#define PSR_DA      38\r
+#define PSR_DD      39\r
+#define PSR_SS      40\r
+#define PSR_RI      41\r
+#define PSR_RI_LEN  2\r
+#define PSR_ED      43\r
+#define PSR_BN      44\r
+\r
+//\r
+// PSR bits 45-63 reserved (must be zero)\r
+//\r
+#define PSR_MBZ3    45\r
+#define PSR_MBZ3_V  0xfffffUL L\r
+\r
+//\r
+// Floating Point Status Register (FPSR) Bit positions\r
+//\r
+//\r
+// Traps\r
+//\r
+#define FPSR_VD 0\r
+#define FPSR_DD 1\r
+#define FPSR_ZD 2\r
+#define FPSR_OD 3\r
+#define FPSR_UD 4\r
+#define FPSR_ID 5\r
+\r
+//\r
+// Status Field 0 - Controls\r
+//\r
+#define FPSR0_FTZ0  6\r
+#define FPSR0_WRE0  7\r
+#define FPSR0_PC0   8\r
+#define FPSR0_RC0   10\r
+#define FPSR0_TD0   12\r
+\r
+//\r
+// Status Field 0 - Flags\r
+//\r
+#define FPSR0_V0  13\r
+#define FPSR0_D0  14\r
+#define FPSR0_Z0  15\r
+#define FPSR0_O0  16\r
+#define FPSR0_U0  17\r
+#define FPSR0_I0  18\r
+\r
+//\r
+// Status Field 1 - Controls\r
+//\r
+#define FPSR1_FTZ0  19\r
+#define FPSR1_WRE0  20\r
+#define FPSR1_PC0   21\r
+#define FPSR1_RC0   23\r
+#define FPSR1_TD0   25\r
+\r
+//\r
+// Status Field 1 - Flags\r
+//\r
+#define FPSR1_V0  26\r
+#define FPSR1_D0  27\r
+#define FPSR1_Z0  28\r
+#define FPSR1_O0  29\r
+#define FPSR1_U0  30\r
+#define FPSR1_I0  31\r
+\r
+//\r
+// Status Field 2 - Controls\r
+//\r
+#define FPSR2_FTZ0  32\r
+#define FPSR2_WRE0  33\r
+#define FPSR2_PC0   34\r
+#define FPSR2_RC0   36\r
+#define FPSR2_TD0   38\r
+\r
+//\r
+// Status Field 2 - Flags\r
+//\r
+#define FPSR2_V0  39\r
+#define FPSR2_D0  40\r
+#define FPSR2_Z0  41\r
+#define FPSR2_O0  42\r
+#define FPSR2_U0  43\r
+#define FPSR2_I0  44\r
+\r
+//\r
+// Status Field 3 - Controls\r
+//\r
+#define FPSR3_FTZ0  45\r
+#define FPSR3_WRE0  46\r
+#define FPSR3_PC0   47\r
+#define FPSR3_RC0   49\r
+#define FPSR3_TD0   51\r
+\r
+//\r
+// Status Field 0 - Flags\r
+//\r
+#define FPSR3_V0  52\r
+#define FPSR3_D0  53\r
+#define FPSR3_Z0  54\r
+#define FPSR3_O0  55\r
+#define FPSR3_U0  56\r
+#define FPSR3_I0  57\r
+\r
+//\r
+// FPSR bits 58-63 Reserved -- Must be zero\r
+//\r
+#define FPSR_MBZ0   58\r
+#define FPSR_MBZ0_V 0x3fUL L\r
+\r
+//\r
+// For setting up FPSR on kernel entry\r
+// All traps are disabled.\r
+//\r
+#define FPSR_FOR_KERNEL     0x3f\r
+\r
+#define FP_REG_SIZE         16  // 16 byte spill size\r
+#define HIGHFP_REGS_LENGTH  (96 * 16)\r
+\r
+//\r
+// Define hardware Task Priority Register (TPR)\r
+//\r
+//\r
+// TPR bit positions\r
+//\r
+#define TPR_MIC     4   // Bits 0 - 3 ignored\r
+#define TPR_MIC_LEN 4\r
+#define TPR_MMI     16  // Mask Maskable Interrupt\r
+//\r
+// Define hardware Interrupt Status Register (ISR)\r
+//\r
+//\r
+// ISR bit positions\r
+//\r
+#define ISR_CODE          0\r
+#define ISR_CODE_LEN      16\r
+#define ISR_CODE_MASK     0xFFFF\r
+#define ISR_IA_VECTOR     16\r
+#define ISR_IA_VECTOR_LEN 8\r
+#define ISR_MBZ0          24\r
+#define ISR_MBZ0_V        0xff\r
+#define ISR_X             32\r
+#define ISR_W             33\r
+#define ISR_R             34\r
+#define ISR_NA            35\r
+#define ISR_SP            36\r
+#define ISR_RS            37\r
+#define ISR_IR            38\r
+#define ISR_NI            39\r
+#define ISR_MBZ1          40\r
+#define ISR_EI            41\r
+#define ISR_ED            43\r
+#define ISR_MBZ2          44\r
+#define ISR_MBZ2_V        0xfffff\r
+\r
+//\r
+// ISR codes\r
+//\r
+// For General exceptions: ISR{3:0}\r
+//\r
+#define ISR_ILLEGAL_OP  0 //  Illegal operation fault\r
+#define ISR_PRIV_OP     1 //  Privileged operation fault\r
+#define ISR_PRIV_REG    2 //  Privileged register fauls\r
+#define ISR_RESVD_REG   3 //  Reserved register/field flt\r
+#define ISR_ILLEGAL_ISA 4 // Disabled instruction set transition fault\r
+//\r
+// Define hardware Default Control Register (DCR)\r
+//\r
+//\r
+// DCR bit positions\r
+//\r
+#define DCR_PP        0\r
+#define DCR_BE        1\r
+#define DCR_LC        2\r
+#define DCR_MBZ0      4\r
+#define DCR_MBZ0_V    0xf\r
+#define DCR_DM        8\r
+#define DCR_DP        9\r
+#define DCR_DK        10\r
+#define DCR_DX        11\r
+#define DCR_DR        12\r
+#define DCR_DA        13\r
+#define DCR_DD        14\r
+#define DCR_DEFER_ALL 0x7f00\r
+#define DCR_MBZ1      2\r
+#define DCR_MBZ1_V    0xffffffffffffUL L\r
+\r
+//\r
+// Define hardware RSE Configuration Register\r
+//\r
+// RS Configuration (RSC) bit field positions\r
+//\r
+#define RSC_MODE        0\r
+#define RSC_PL          2\r
+#define RSC_BE          4\r
+#define RSC_MBZ0        5\r
+#define RSC_MBZ0_V      0x3ff\r
+#define RSC_LOADRS      16\r
+#define RSC_LOADRS_LEN  14\r
+#define RSC_MBZ1        30\r
+#define RSC_MBZ1_V      0x3ffffffffUL L\r
+\r
+//\r
+// RSC modes\r
+//\r
+#define RSC_MODE_LY (0x0) // Lazy\r
+#define RSC_MODE_SI (0x1) // Store intensive\r
+#define RSC_MODE_LI (0x2) // Load intensive\r
+#define RSC_MODE_EA (0x3) // Eager\r
+//\r
+// RSC Endian bit values\r
+//\r
+#define RSC_BE_LITTLE 0\r
+#define RSC_BE_BIG    1\r
+\r
+//\r
+// Define Interruption Function State (IFS) Register\r
+//\r
+// IFS bit field positions\r
+//\r
+#define IFS_IFM     0\r
+#define IFS_IFM_LEN 38\r
+#define IFS_MBZ0    38\r
+#define IFS_MBZ0_V  0x1ffffff\r
+#define IFS_V       63\r
+#define IFS_V_LEN   1\r
+\r
+//\r
+// IFS is valid when IFS_V = IFS_VALID\r
+//\r
+#define IFS_VALID 1\r
+\r
+//\r
+// Define Page Table Address (PTA)\r
+//\r
+#define PTA_VE        0\r
+#define PTA_VF        8\r
+#define PTA_SIZE      2\r
+#define PTA_SIZE_LEN  6\r
+#define PTA_BASE      15\r
+\r
+//\r
+// Define Region Register (RR)\r
+//\r
+//\r
+// RR bit field positions\r
+//\r
+#define RR_VE       0\r
+#define RR_MBZ0     1\r
+#define RR_PS       2\r
+#define RR_PS_LEN   6\r
+#define RR_RID      8\r
+#define RR_RID_LEN  24\r
+#define RR_MBZ1     32\r
+\r
+//\r
+// SAL uses region register 0 and RID of 1000\r
+//\r
+#define SAL_RID     0x1000\r
+#define SAL_RR_REG  0x0\r
+#define SAL_TR      0x0\r
+\r
+//\r
+// Total number of region registers\r
+//\r
+#define RR_SIZE 8\r
+\r
+//\r
+// Define Protection Key Register (PKR)\r
+//\r
+// PKR bit field positions\r
+//\r
+#define PKR_V       0\r
+#define PKR_WD      1\r
+#define PKR_RD      2\r
+#define PKR_XD      3\r
+#define PKR_MBZ0    4\r
+#define PKR_KEY     8\r
+#define PKR_KEY_LEN 24\r
+#define PKR_MBZ1    32\r
+\r
+#define PKR_VALID   (1 << PKR_V)\r
+\r
+//\r
+// Number of protection key registers\r
+//\r
+#define PKRNUM  8\r
+\r
+//\r
+// Define Interruption TLB Insertion register (ITIR)\r
+//\r
+//\r
+// Define Translation Insertion Format (TR)\r
+//\r
+// PTE0 bit field positions\r
+//\r
+#define PTE0_P    0\r
+#define PTE0_MBZ0 1\r
+#define PTE0_MA   2\r
+#define PTE0_A    5\r
+#define PTE0_D    6\r
+#define PTE0_PL   7\r
+#define PTE0_AR   9\r
+#define PTE0_PPN  12\r
+#define PTE0_MBZ1 48\r
+#define PTE0_ED   52\r
+#define PTE0_IGN0 53\r
+\r
+//\r
+// ITIR bit field positions\r
+//\r
+#define ITIR_MBZ0     0\r
+#define ITIR_PS       2\r
+#define ITIR_PS_LEN   6\r
+#define ITIR_KEY      8\r
+#define ITIR_KEY_LEN  24\r
+#define ITIR_MBZ1     32\r
+#define ITIR_MBZ1_LEN 16\r
+#define ITIR_PPN      48\r
+#define ITIR_PPN_LEN  15\r
+#define ITIR_MBZ2     63\r
+\r
+#define ATTR_IPAGE    0x661 // Access Rights = RWX (bits 11-9=011), PL 0(8-7=0)\r
+#define ATTR_DEF_BITS 0x661 // Access Rights = RWX (bits 11-9=010), PL 0(8-7=0)\r
+// Dirty (bit 6=1), Accessed (bit 5=1),\r
+// MA WB (bits 4-2=000), Present (bit 0=1)\r
+//\r
+// Memory access rights\r
+//\r
+#define AR_UR_KR      0x0 // user/kernel read\r
+#define AR_URX_KRX    0x1 // user/kernel read and execute\r
+#define AR_URW_KRW    0x2 // user/kernel read & write\r
+#define AR_URWX_KRWX  0x3 // user/kernel read,write&execute\r
+#define AR_UR_KRW     0x4 // user read/kernel read,write\r
+#define AR_URX_KRWX   0x5 // user read/execute, kernel all\r
+#define AR_URWX_KRW   0x6 // user all, kernel read & write\r
+#define AR_UX_KRX     0x7 // user execute only, kernel read and execute\r
+//\r
+// Memory attribute values\r
+//\r
+//\r
+// The next 4 are all cached, non-sequential & speculative, coherent\r
+//\r
+#define MA_WBU  0x0 // Write back, unordered\r
+//\r
+// The next 3 are all non-cached, sequential & non-speculative\r
+//\r
+#define MA_UC   0x4 // Non-coalescing, sequential & non-speculative\r
+#define MA_UCE  0x5 // Non-coalescing, sequential, non-speculative\r
+// & fetchadd exported\r
+//\r
+#define MA_WC   0x6 // Non-cached, Coalescing,  non-seq., spec.\r
+#define MA_NAT  0xf // NaT page\r
+//\r
+// Definition of the offset of TRAP/INTERRUPT/FAULT handlers from the\r
+// base of IVA (Interruption Vector Address)\r
+//\r
+#define IVT_SIZE          0x8000\r
+#define EXTRA_ALIGNMENT   0x1000\r
+\r
+#define OFF_VHPTFLT       0x0000  // VHPT Translation fault\r
+#define OFF_ITLBFLT       0x0400  // Instruction TLB fault\r
+#define OFF_DTLBFLT       0x0800  // Data TLB fault\r
+#define OFF_ALTITLBFLT    0x0C00  // Alternate ITLB fault\r
+#define OFF_ALTDTLBFLT    0x1000  // Alternate DTLB fault\r
+#define OFF_NESTEDTLBFLT  0x1400  // Nested TLB fault\r
+#define OFF_IKEYMISSFLT   0x1800  // Inst Key Miss fault\r
+#define OFF_DKEYMISSFLT   0x1C00  // Data Key Miss fault\r
+#define OFF_DIRTYBITFLT   0x2000  // Dirty-Bit fault\r
+#define OFF_IACCESSBITFLT 0x2400  // Inst Access-Bit fault\r
+#define OFF_DACCESSBITFLT 0x2800  // Data Access-Bit fault\r
+#define OFF_BREAKFLT      0x2C00  // Break Inst fault\r
+#define OFF_EXTINT        0x3000  // External Interrupt\r
+//\r
+//  Offset 0x3400 to 0x0x4C00 are reserved\r
+//\r
+#define OFF_PAGENOTPFLT   0x5000  // Page Not Present fault\r
+#define OFF_KEYPERMFLT    0x5100  // Key Permission fault\r
+#define OFF_IACCESSRTFLT  0x5200  // Inst Access-Rights flt\r
+#define OFF_DACCESSRTFLT  0x5300  // Data Access-Rights fault\r
+#define OFF_GPFLT         0x5400  // General Exception fault\r
+#define OFF_FPDISFLT      0x5500  // Disable-FP fault\r
+#define OFF_NATFLT        0x5600  // NAT Consumption fault\r
+#define OFF_SPECLNFLT     0x5700  // Speculation fault\r
+#define OFF_DBGFLT        0x5900  // Debug fault\r
+#define OFF_ALIGNFLT      0x5A00  // Unaligned Reference fault\r
+#define OFF_LOCKDREFFLT   0x5B00  // Locked Data Reference fault\r
+#define OFF_FPFLT         0x5C00  // Floating Point fault\r
+#define OFF_FPTRAP        0x5D00  // Floating Point Trap\r
+#define OFF_LOPRIVTRAP    0x5E00  // Lower-Privilege Transfer Trap\r
+#define OFF_TAKENBRTRAP   0x5F00  // Taken Branch Trap\r
+#define OFF_SSTEPTRAP     0x6000  // Single Step Trap\r
+//\r
+// Offset 0x6100 to 0x6800 are reserved\r
+//\r
+#define OFF_IA32EXCEPTN   0x6900  // iA32 Exception\r
+#define OFF_IA32INTERCEPT 0x6A00  // iA32 Intercept\r
+#define OFF_IA32INT       0x6B00  // iA32 Interrupt\r
+#define NUMBER_OF_VECTORS 0x100\r
+//\r
+// Privilege levels\r
+//\r
+#define PL_KERNEL 0\r
+#define PL_USER   3\r
+\r
+//\r
+// Instruction set (IS) bits\r
+//\r
+#define IS_IA64 0\r
+#define IS_IA   1\r
+\r
+//\r
+// RSC while in kernel: enabled, little endian, PL = 0, eager mode\r
+//\r
+#define RSC_KERNEL  ((RSC_MODE_EA << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))\r
+\r
+//\r
+// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode\r
+//\r
+#define RSC_KERNEL_LAZ  ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))\r
+\r
+//\r
+// RSE disabled: disabled, PL = 0, little endian, eager mode\r
+//\r
+#define RSC_KERNEL_DISABLED   ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))\r
+\r
+#define NAT_BITS_PER_RNAT_REG 63\r
+\r
+//\r
+// Macros for generating PTE0 and PTE1 value\r
+//\r
+#define PTE0(ed, ppn12_47, ar, pl, d, a, ma, p) \\r
+                ( ( ed << PTE0_ED )               |  \\r
+                  ( ppn12_47 << PTE0_PPN )        |  \\r
+                  ( ar << PTE0_AR )               |  \\r
+                  ( pl << PTE0_PL )               |  \\r
+                  ( d << PTE0_D )                 |  \\r
+                  ( a << PTE0_A )                 |  \\r
+                  ( ma << PTE0_MA )               |  \\r
+                  ( p << PTE0_P )                    \\r
+                )\r
+\r
+#define ITIR(ppn48_63, key, ps)            \\r
+                ( ( ps << ITIR_PS )       |  \\r
+                  ( key << ITIR_KEY )     |  \\r
+                  ( ppn48_63 << ITIR_PPN )         \\r
+    )\r
+\r
+//\r
+// Macro to generate mask value from bit position. The result is a\r
+// 64-bit.\r
+//\r
+#define BITMASK(bp, value)      (value << bp)\r
+\r
+#define BUNDLE_SIZE             16\r
+#define SPURIOUS_INT            0xF\r
+\r
+#define FAST_DISABLE_INTERRUPTS rsm BITMASK (PSR_I, 1);;\r
+\r
+#define FAST_ENABLE_INTERRUPTS  ssm BITMASK (PSR_I, 1);;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i
new file mode 100644 (file)
index 0000000..68c5f8c
--- /dev/null
@@ -0,0 +1,66 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//  IpfMacro.i\r
+//\r
+// Abstract:\r
+//\r
+//  Contains the macros needed for calling procedures in Itanium-based assembly code.\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+#ifndef  _IA64PROC_I\r
+#define  _IA64PROC_I\r
+\r
+\r
+#define PROCEDURE_ENTRY(name)   .##text;            \\r
+                                .##type name, @function;    \\r
+                                .##proc name;           \\r
+name::\r
+\r
+#define PROCEDURE_EXIT(name)    .##endp name\r
+\r
+// Note: use of NESTED_SETUP requires number of locals (l) >= 3\r
+\r
+#define NESTED_SETUP(i,l,o,r) \\r
+         alloc loc1=ar##.##pfs,i,l,o,r ;\\r
+         mov loc0=b0\r
+\r
+#define NESTED_RETURN \\r
+         mov b0=loc0 ;\\r
+         mov ar##.##pfs=loc1 ;;\\r
+         br##.##ret##.##dpnt  b0;;\r
+\r
+\r
+#define INTERRUPT_HANDLER_BEGIN(name) \\r
+PROCEDURE_ENTRY(name##HandlerBegin) \\r
+;; \\r
+PROCEDURE_EXIT(name##HandlerBegin)\r
+\r
+#define INTERRUPT_HANDLER_END(name) \\r
+PROCEDURE_ENTRY(name##HandlerEnd) \\r
+;; \\r
+PROCEDURE_EXIT(name##HandlerEnd) \r
+\r
+\r
+#define INTERRUPT_HANDLER_BLOCK_BEGIN \\r
+INTERRUPT_HANDLER_BEGIN(First)\r
+\r
+#define INTERRUPT_HANDLER_BLOCK_END \\r
+INTERRUPT_HANDLER_END(Last)\r
+\r
+\r
+\r
+#endif  // _IA64PROC_I\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h
new file mode 100644 (file)
index 0000000..aaa6a64
--- /dev/null
@@ -0,0 +1,133 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PalApi.h\r
+\r
+Abstract:\r
+\r
+  Main PAL API's defined in PAL specification. \r
+\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _PALPROC_H\r
+#define _PALPROC_H\r
+\r
+#include "Tiano.h"\r
+\r
+#define PAL_CACHE_FLUSH       0x0001\r
+#define PAL_CACHE_INFO        0x0002\r
+#define PAL_CACHE_INIT        0x0003\r
+#define PAL_CACHE_SUMMARY     0x0004\r
+#define PAL_MEM_ATTRIB        0x0005\r
+#define PAL_PTCE_INFO         0x0006\r
+#define PAL_VM_INFO           0x0007\r
+#define PAL_VM_SUMMARY        0x0008\r
+#define PAL_BUS_GET_FEATURES  0x0009\r
+#define PAL_BUS_SET_FEATURES  0x000a\r
+#define PAL_DEBUG_INFO        0x000b\r
+#define PAL_FIXED_ADDR        0x000c\r
+#define PAL_FREQ_BASE         0x000d\r
+#define PAL_FREQ_RATIOS       0x000e\r
+#define PAL_PERF_MON_INFO     0x000f\r
+#define PAL_PLATFORM_ADDR     0x0010\r
+#define PAL_PROC_GET_FEATURES 0x0011\r
+#define PAL_PROC_SET_FEATURES 0x0012\r
+#define PAL_RSE_INFO          0x0013\r
+#define PAL_VERSION           0x0014\r
+\r
+#define PAL_MC_CLEAR_LOG      0x0015\r
+#define PAL_MC_DRAIN          0x0016\r
+#define PAL_MC_EXPECTED       0x0017\r
+#define PAL_MC_DYNAMIC_STATE  0x0018\r
+#define PAL_MC_ERROR_INFO     0x0019\r
+#define PAL_MC_RESUME         0x001a\r
+#define PAL_MC_REGISTER_MEM   0x001b\r
+#define PAL_HALT              0x001c\r
+#define PAL_HALT_LIGHT        0x001d\r
+#define PAL_COPY_INFO         0x001e\r
+#define PAL_SHUTDOWN          0x002c\r
+#define PAL_AUTH              0x0209\r
+#define PAL_SINGL_DISPERSAL   0x0226  // dec. 550\r
+#define PAL_HALT_INFO         0x0101\r
+#define PAL_CACHE_LINE_INIT   0x001f\r
+#define PAL_PMI_ENTRYPOINT    0x0020\r
+#define PAL_ENTER_IA_32_ENV   0x0021\r
+#define PAL_VM_PAGE_SIZE      0x0022\r
+#define PAL_MEM_FOR_TEST      0x0025\r
+#define PAL_CACHE_PROT_INFO   0x0026\r
+\r
+#define PAL_COPY_PAL          0x0100\r
+#define PAL_CACHE_READ        0x0103\r
+#define PAL_CACHE_WRITE       0x0104\r
+#define PAL_TEST_PROC         0x0102\r
+\r
+#define PAL_DEBUG_FEATURE     0x0063  // vp1\r
+typedef UINT64  EFI_PAL_STATUS;\r
+\r
+//\r
+//  Return values from PAL\r
+//\r
+typedef struct {\r
+  EFI_PAL_STATUS  Status; // register r8\r
+  UINT64          r9;\r
+  UINT64          r10;\r
+  UINT64          r11;\r
+} PAL_RETURN_REGS;\r
+\r
+//\r
+// PAL equates for other parameters.\r
+//\r
+#define PAL_SUCCESS             0x0\r
+#define PAL_CALL_ERROR          0xfffffffffffffffd\r
+#define PAL_CALL_UNIMPLEMENTED  0xffffffffffffffff\r
+#define PAL_CACHE_TYPE_I        0x1\r
+#define PAL_CACHE_TYPE_D        0x2\r
+#define PAL_CACHE_TYPE_I_AND_D  0x3\r
+#define PAL_CACHE_NO_INT        0x0\r
+#define PAL_CACHE_INT           0x2\r
+//\r
+// #define PAL_CACHE_PLAT_ACK                              0x4\r
+//\r
+#define PAL_CACHE_NO_PLAT_ACK               0x0\r
+#define PAL_CACHE_INVALIDATE                0x1\r
+#define PAL_CACHE_NO_INVALIDATE             0x0\r
+#define PAL_CACHE_ALL_LEVELS                - 0x1\r
+\r
+#define PAL_FEATURE_ENABLE                  0x1\r
+#define PAL_ENABLE_BERR_BIT                 63\r
+#define PAL_ENABLE_MCA_BINIT_BIT            61\r
+#define PAL_ENABLE_CMCI_MCA_BIT             60\r
+#define PAL_CACHE_DISABLE_BIT               59\r
+#define PAL_DISABLE_COHERENCY_BIT           58\r
+\r
+#define PAL_DIS_BUS_DATA_ERR_CHECK_BIT      63\r
+#define PAL_DIS_BUS_ADDR_ERR_CHECK_BIT      61\r
+#define PAL_DIS_BUS_INIT_EVENT_SIGNAL_BIT   60\r
+#define PAL_DIS_BUS_REQ_ERR_SIGNAL_BIT      58\r
+#define PAL_DIS_BUS_REQ_INT_ERR_SIGNAL_BIT  57\r
+#define PAL_DIS_BUS_REQ_ERR_CHECK_BIT       56\r
+#define PAL_DIS_BUS_RESP_ERR_CHECK_BIT      55\r
+\r
+#define PAL_COPY_BSP_TOKEN                  0x0\r
+#define PAL_COPY_AP_TOKEN                   0x1\r
+\r
+#define PAL_CODE_TOKEN                      0x0\r
+#define PAL_IA32EMU_CODE_TOKEN              0x1\r
+\r
+#define PAL_INTERRUPT_BLOCK_TOKEN           0x0\r
+#define PAL_IO_BLOCK_TOKEN                  0x1\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h
new file mode 100644 (file)
index 0000000..a6a7e4d
--- /dev/null
@@ -0,0 +1,724 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SalApi.h\r
+\r
+Abstract:\r
+\r
+  Main SAL API's defined in SAL 3.0 specification. \r
+\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _SAL_API_H_\r
+#define _SAL_API_H_\r
+\r
+typedef UINTN EFI_SAL_STATUS;\r
+\r
+//\r
+// EFI_SAL_STATUS defines\r
+//\r
+#define EFI_SAL_SUCCESS               ((EFI_SAL_STATUS) 0)\r
+#define EFI_SAL_MORE_RECORDS          ((EFI_SAL_STATUS) 3)\r
+#define EFI_SAL_NOT_IMPLEMENTED       ((EFI_SAL_STATUS) - 1)\r
+#define EFI_SAL_INVALID_ARGUMENT      ((EFI_SAL_STATUS) - 2)\r
+#define EFI_SAL_ERROR                 ((EFI_SAL_STATUS) - 3)\r
+#define EFI_SAL_VIRTUAL_ADDRESS_ERROR ((EFI_SAL_STATUS) - 4)\r
+#define EFI_SAL_NO_INFORMATION        ((EFI_SAL_STATUS) - 5)\r
+#define EFI_SAL_NOT_ENOUGH_SCRATCH    ((EFI_SAL_STATUS) - 9)\r
+\r
+//\r
+//  Delivery Mode of IPF CPU.\r
+//\r
+typedef enum {\r
+  INT,\r
+  MPreserved1,\r
+  PMI,\r
+  MPreserved2,\r
+  NMI,\r
+  INIT,\r
+  MPreserved3,\r
+  ExtINT\r
+} EFI_DELIVERY_MODE;\r
+\r
+//\r
+//  Return values from SAL\r
+//\r
+typedef struct {\r
+  EFI_SAL_STATUS  Status; // register r8\r
+  UINTN           r9;\r
+  UINTN           r10;\r
+  UINTN           r11;\r
+} SAL_RETURN_REGS;\r
+\r
+typedef SAL_RETURN_REGS (EFIAPI *SAL_PROC)\r
+  (\r
+    IN UINT64 FunctionId,\r
+    IN UINT64 Arg2,\r
+    IN UINT64 Arg3,\r
+    IN UINT64 Arg4,\r
+    IN UINT64 Arg5,\r
+    IN UINT64 Arg6,\r
+    IN UINT64 Arg7,\r
+    IN UINT64 Arg8\r
+  );\r
+\r
+//\r
+// SAL Procedure FunctionId definition\r
+//\r
+#define EFI_SAL_SET_VECTORS             0x01000000\r
+#define EFI_SAL_GET_STATE_INFO          0x01000001\r
+#define EFI_SAL_GET_STATE_INFO_SIZE     0x01000002\r
+#define EFI_SAL_CLEAR_STATE_INFO        0x01000003\r
+#define EFI_SAL_MC_RENDEZ               0x01000004\r
+#define EFI_SAL_MC_SET_PARAMS           0x01000005\r
+#define EFI_SAL_REGISTER_PHYSICAL_ADDR  0x01000006\r
+#define EFI_SAL_CACHE_FLUSH             0x01000008\r
+#define EFI_SAL_CACHE_INIT              0x01000009\r
+#define EFI_SAL_PCI_CONFIG_READ         0x01000010\r
+#define EFI_SAL_PCI_CONFIG_WRITE        0x01000011\r
+#define EFI_SAL_FREQ_BASE               0x01000012\r
+#define EFI_SAL_UPDATE_PAL              0x01000020\r
+\r
+#define EFI_SAL_FUNCTION_ID_MASK        0x0000ffff\r
+#define EFI_SAL_MAX_SAL_FUNCTION_ID     0x00000021\r
+\r
+//\r
+// SAL Procedure parameter definitions\r
+// Not much point in using typedefs or enums because all params\r
+// are UINT64 and the entry point is common\r
+//\r
+// EFI_SAL_SET_VECTORS\r
+//\r
+#define EFI_SAL_SET_MCA_VECTOR          0x0\r
+#define EFI_SAL_SET_INIT_VECTOR         0x1\r
+#define EFI_SAL_SET_BOOT_RENDEZ_VECTOR  0x2\r
+\r
+typedef struct {\r
+  UINT64  Length : 32;\r
+  UINT64  ChecksumValid : 1;\r
+  UINT64  Reserved1 : 7;\r
+  UINT64  ByteChecksum : 8;\r
+  UINT64  Reserved2 : 16;\r
+} SAL_SET_VECTORS_CS_N;\r
+\r
+//\r
+// EFI_SAL_GET_STATE_INFO, EFI_SAL_GET_STATE_INFO_SIZE,\r
+// EFI_SAL_CLEAR_STATE_INFO\r
+//\r
+#define EFI_SAL_MCA_STATE_INFO  0x0\r
+#define EFI_SAL_INIT_STATE_INFO 0x1\r
+#define EFI_SAL_CMC_STATE_INFO  0x2\r
+#define EFI_SAL_CP_STATE_INFO   0x3\r
+\r
+//\r
+// EFI_SAL_MC_SET_PARAMS\r
+//\r
+#define EFI_SAL_MC_SET_RENDEZ_PARAM 0x1\r
+#define EFI_SAL_MC_SET_WAKEUP_PARAM 0x2\r
+#define EFI_SAL_MC_SET_CPE_PARAM    0x3\r
+\r
+#define EFI_SAL_MC_SET_INTR_PARAM   0x1\r
+#define EFI_SAL_MC_SET_MEM_PARAM    0x2\r
+\r
+//\r
+// EFI_SAL_REGISTER_PAL_PHYSICAL_ADDR\r
+//\r
+#define EFI_SAL_REGISTER_PAL_ADDR 0x0\r
+\r
+//\r
+// EFI_SAL_CACHE_FLUSH\r
+//\r
+#define EFI_SAL_FLUSH_I_CACHE       0x01\r
+#define EFI_SAL_FLUSH_D_CACHE       0x02\r
+#define EFI_SAL_FLUSH_BOTH_CACHE    0x03\r
+#define EFI_SAL_FLUSH_MAKE_COHERENT 0x04\r
+\r
+//\r
+// EFI_SAL_PCI_CONFIG_READ, EFI_SAL_PCI_CONFIG_WRITE\r
+//\r
+#define EFI_SAL_PCI_CONFIG_ONE_BYTE   0x1\r
+#define EFI_SAL_PCI_CONFIG_TWO_BYTES  0x2\r
+#define EFI_SAL_PCI_CONFIG_FOUR_BYTES 0x4\r
+\r
+typedef struct {\r
+  UINT64  Register : 8;\r
+  UINT64  Function : 3;\r
+  UINT64  Device : 5;\r
+  UINT64  Bus : 8;\r
+  UINT64  Segment : 8;\r
+  UINT64  Reserved : 32;\r
+} SAL_PCI_ADDRESS;\r
+\r
+//\r
+// EFI_SAL_FREQ_BASE\r
+//\r
+#define EFI_SAL_CPU_INPUT_FREQ_BASE     0x0\r
+#define EFI_SAL_PLATFORM_IT_FREQ_BASE   0x1\r
+#define EFI_SAL_PLATFORM_RTC_FREQ_BASE  0x2\r
+\r
+//\r
+// EFI_SAL_UPDATE_PAL\r
+//\r
+#define EFI_SAL_UPDATE_BAD_PAL_VERSION  ((UINT64) -1)\r
+#define EFI_SAL_UPDATE_PAL_AUTH_FAIL    ((UINT64) -2)\r
+#define EFI_SAL_UPDATE_PAL_BAD_TYPE     ((UINT64) -3)\r
+#define EFI_SAL_UPDATE_PAL_READONLY     ((UINT64) -4)\r
+#define EFI_SAL_UPDATE_PAL_WRITE_FAIL   ((UINT64) -10)\r
+#define EFI_SAL_UPDATE_PAL_ERASE_FAIL   ((UINT64) -11)\r
+#define EFI_SAL_UPDATE_PAL_READ_FAIL    ((UINT64) -12)\r
+#define EFI_SAL_UPDATE_PAL_CANT_FIT     ((UINT64) -13)\r
+\r
+typedef struct {\r
+  UINT32  Size;\r
+  UINT32  MmddyyyyDate;\r
+  UINT16  Version;\r
+  UINT8   Type;\r
+  UINT8   Reserved[5];\r
+  UINT64  FwVendorId;\r
+} SAL_UPDATE_PAL_DATA_BLOCK;\r
+\r
+typedef struct _SAL_UPDATE_PAL_INFO_BLOCK {\r
+  struct _SAL_UPDATE_PAL_INFO_BLOCK *Next;\r
+  struct SAL_UPDATE_PAL_DATA_BLOCK  *DataBlock;\r
+  UINT8                             StoreChecksum;\r
+  UINT8                             Reserved[15];\r
+} SAL_UPDATE_PAL_INFO_BLOCK;\r
+\r
+//\r
+// SAL System Table Definitions\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Length;\r
+  UINT16  SalRevision;\r
+  UINT16  EntryCount;\r
+  UINT8   CheckSum;\r
+  UINT8   Reserved[7];\r
+  UINT16  SalAVersion;\r
+  UINT16  SalBVersion;\r
+  UINT8   OemId[32];\r
+  UINT8   ProductId[32];\r
+  UINT8   Reserved2[8];\r
+} SAL_SYSTEM_TABLE_HEADER;\r
+#pragma pack()\r
+\r
+#define EFI_SAL_ST_HEADER_SIGNATURE "SST_"\r
+#define EFI_SAL_REVISION            0x0300\r
+//\r
+// SAL System Types\r
+//\r
+#define EFI_SAL_ST_ENTRY_POINT        0\r
+#define EFI_SAL_ST_MEMORY_DESCRIPTOR  1\r
+#define EFI_SAL_ST_PLATFORM_FEATURES  2\r
+#define EFI_SAL_ST_TR_USAGE           3\r
+#define EFI_SAL_ST_PTC                4\r
+#define EFI_SAL_ST_AP_WAKEUP          5\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8   Type; //  Type == 0\r
+  UINT8   Reserved[7];\r
+  UINT64  PalProcEntry;\r
+  UINT64  SalProcEntry;\r
+  UINT64  SalGlobalDataPointer;\r
+  UINT64  Reserved2[2];\r
+} SAL_ST_ENTRY_POINT_DESCRIPTOR;\r
+\r
+//\r
+// Not needed for Itanium-based OS boot\r
+//\r
+typedef struct {\r
+  UINT8   Type; //  Type == 1\r
+  UINT8   NeedVirtualRegistration;\r
+  UINT8   MemoryAttributes;\r
+  UINT8   PageAccessRights;\r
+  UINT8   SupportedAttributes;\r
+  UINT8   Reserved;\r
+  UINT8   MemoryType;\r
+  UINT8   MemoryUsage;\r
+  UINT64  PhysicalMemoryAddress;\r
+  UINT32  Length;\r
+  UINT32  Reserved1;\r
+  UINT64  OemReserved;\r
+} SAL_ST_MEMORY_DESCRIPTOR_ENTRY;\r
+\r
+#pragma pack()\r
+//\r
+// Memory Attributes\r
+//\r
+#define SAL_MDT_ATTRIB_WB 0x00\r
+//\r
+// #define SAL_MDT_ATTRIB_UC   0x02\r
+//\r
+#define SAL_MDT_ATTRIB_UC   0x04\r
+#define SAL_MDT_ATTRIB_UCE  0x05\r
+#define SAL_MDT_ATTRIB_WC   0x06\r
+\r
+//\r
+// Supported memory Attributes\r
+//\r
+#define SAL_MDT_SUPPORT_WB  0x1\r
+#define SAL_MDT_SUPPORT_UC  0x2\r
+#define SAL_MDT_SUPPORT_UCE 0x4\r
+#define SAL_MDT_SUPPORT_WC  0x8\r
+\r
+//\r
+// Virtual address registration\r
+//\r
+#define SAL_MDT_NO_VA   0x00\r
+#define SAL_MDT_NEED_VA 0x01\r
+//\r
+// MemoryType info\r
+//\r
+#define SAL_REGULAR_MEMORY  0x0000\r
+#define SAL_MMIO_MAPPING    0x0001\r
+#define SAL_SAPIC_IPI_BLOCK 0x0002\r
+#define SAL_IO_PORT_MAPPING 0x0003\r
+#define SAL_FIRMWARE_MEMORY 0x0004\r
+#define SAL_BLACK_HOLE      0x000A\r
+//\r
+// Memory Usage info\r
+//\r
+#define SAL_MDT_USAGE_UNSPECIFIED 0x00\r
+#define SAL_PAL_CODE              0x01\r
+#define SAL_BOOTSERVICE_CODE      0x02\r
+#define SAL_BOOTSERVICE_DATA      0x03\r
+#define SAL_RUNTIMESERVICE_CODE   0x04\r
+#define SAL_RUNTIMESERVICE_DATA   0x05\r
+#define SAL_IA32_OPTIONROM        0x06\r
+#define SAL_IA32_SYSTEMROM        0x07\r
+#define SAL_PMI_CODE              0x0a\r
+#define SAL_PMI_DATA              0x0b\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8 Type;                     // Type == 2\r
+  UINT8 PlatformFeatures;\r
+  UINT8 Reserved[14];\r
+} SAL_ST_PLATFORM_FEATURES;\r
+#pragma pack()\r
+\r
+#define SAL_PLAT_FEAT_BUS_LOCK      0x01\r
+#define SAL_PLAT_FEAT_PLAT_IPI_HINT 0x02\r
+#define SAL_PLAT_FEAT_PROC_IPI_HINT 0x04\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8   Type;                   // Type == 3\r
+  UINT8   TRType;\r
+  UINT8   TRNumber;\r
+  UINT8   Reserved[5];\r
+  UINT64  VirtualAddress;\r
+  UINT64  EncodedPageSize;\r
+  UINT64  Reserved1;\r
+} SAL_ST_TR_DECRIPTOR;\r
+#pragma pack()\r
+\r
+#define EFI_SAL_ST_TR_USAGE_INSTRUCTION 00\r
+#define EFI_SAL_ST_TR_USAGE_DATA        01\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT64  NumberOfProcessors;\r
+  UINT64  LocalIDRegister;\r
+} SAL_COHERENCE_DOMAIN_INFO;\r
+#pragma pack()\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8                     Type; // Type == 4\r
+  UINT8                     Reserved[3];\r
+  UINT32                    NumberOfDomains;\r
+  SAL_COHERENCE_DOMAIN_INFO *DomainInformation;\r
+} SAL_ST_CACHE_COHERENCE_DECRIPTOR;\r
+#pragma pack()\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8   Type;                   // Type == 5\r
+  UINT8   WakeUpType;\r
+  UINT8   Reserved[6];\r
+  UINT64  ExternalInterruptVector;\r
+} SAL_ST_AP_WAKEUP_DECRIPTOR;\r
+#pragma pack()\r
+//\r
+// FIT Entry\r
+//\r
+#define EFI_SAL_FIT_ENTRY_PTR   (0x100000000 - 32)  // 4GB - 24\r
+#define EFI_SAL_FIT_PALA_ENTRY  (0x100000000 - 48)  // 4GB - 32\r
+#define EFI_SAL_FIT_PALB_TYPE   01\r
+\r
+typedef struct {\r
+  UINT64  Address;\r
+  UINT8   Size[3];\r
+  UINT8   Reserved;\r
+  UINT16  Revision;\r
+  UINT8   Type : 7;\r
+  UINT8   CheckSumValid : 1;\r
+  UINT8   CheckSum;\r
+} EFI_SAL_FIT_ENTRY;\r
+\r
+//\r
+//  SAL Common Record Header\r
+//\r
+typedef struct {\r
+  UINT16  Length;\r
+  UINT8   Data[1024];\r
+} SAL_OEM_DATA;\r
+\r
+typedef struct {\r
+  UINT8 Seconds;\r
+  UINT8 Minutes;\r
+  UINT8 Hours;\r
+  UINT8 Reserved;\r
+  UINT8 Day;\r
+  UINT8 Month;\r
+  UINT8 Year;\r
+  UINT8 Century;\r
+} SAL_TIME_STAMP;\r
+\r
+typedef struct {\r
+  UINT64          RecordId;\r
+  UINT16          Revision;\r
+  UINT8           ErrorSeverity;\r
+  UINT8           ValidationBits;\r
+  UINT32          RecordLength;\r
+  SAL_TIME_STAMP  TimeStamp;\r
+  UINT8           OemPlatformId[16];\r
+} SAL_RECORD_HEADER;\r
+\r
+typedef struct {\r
+  EFI_GUID  Guid;\r
+  UINT16    Revision;\r
+  UINT8     ErrorRecoveryInfo;\r
+  UINT8     Reserved;\r
+  UINT32    SectionLength;\r
+} SAL_SEC_HEADER;\r
+\r
+//\r
+// SAL Processor Record\r
+//\r
+#define SAL_PROCESSOR_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf1, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define CHECK_INFO_VALID_BIT_MASK   0x1\r
+#define REQUESTOR_ID_VALID_BIT_MASK 0x2\r
+#define RESPONDER_ID_VALID_BIT_MASK 0x4\r
+#define TARGER_ID_VALID_BIT_MASK    0x8\r
+#define PRECISE_IP_VALID_BIT_MASK   0x10\r
+\r
+typedef struct {\r
+  UINT64  InfoValid : 1;\r
+  UINT64  ReqValid : 1;\r
+  UINT64  RespValid : 1;\r
+  UINT64  TargetValid : 1;\r
+  UINT64  IpValid : 1;\r
+  UINT64  Reserved : 59;\r
+  UINT64  Info;\r
+  UINT64  Req;\r
+  UINT64  Resp;\r
+  UINT64  Target;\r
+  UINT64  Ip;\r
+} MOD_ERROR_INFO;\r
+\r
+typedef struct {\r
+  UINT8 CpuidInfo[40];\r
+  UINT8 Reserved;\r
+} CPUID_INFO;\r
+\r
+typedef struct {\r
+  UINT64  FrLow;\r
+  UINT64  FrHigh;\r
+} FR_STRUCT;\r
+\r
+#define MIN_STATE_VALID_BIT_MASK  0x1\r
+#define BR_VALID_BIT_MASK         0x2\r
+#define CR_VALID_BIT_MASK         0x4\r
+#define AR_VALID_BIT_MASK         0x8\r
+#define RR_VALID_BIT_MASK         0x10\r
+#define FR_VALID_BIT_MASK         0x20\r
+\r
+typedef struct {\r
+  UINT64    ValidFieldBits;\r
+  UINT8     MinStateInfo[1024];\r
+  UINT64    Br[8];\r
+  UINT64    Cr[128];\r
+  UINT64    Ar[128];\r
+  UINT64    Rr[8];\r
+  FR_STRUCT Fr[128];\r
+} PSI_STATIC_STRUCT;\r
+\r
+#define PROC_ERROR_MAP_VALID_BIT_MASK       0x1\r
+#define PROC_STATE_PARAMETER_VALID_BIT_MASK 0x2\r
+#define PROC_CR_LID_VALID_BIT_MASK          0x4\r
+#define PROC_STATIC_STRUCT_VALID_BIT_MASK   0x8\r
+#define CPU_INFO_VALID_BIT_MASK             0x1000000\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER    SectionHeader;\r
+  UINT64            ValidationBits;\r
+  UINT64            ProcErrorMap;\r
+  UINT64            ProcStateParameter;\r
+  UINT64            ProcCrLid;\r
+  MOD_ERROR_INFO    CacheError[15];\r
+  MOD_ERROR_INFO    TlbError[15];\r
+  MOD_ERROR_INFO    BusError[15];\r
+  MOD_ERROR_INFO    RegFileCheck[15];\r
+  MOD_ERROR_INFO    MsCheck[15];\r
+  CPUID_INFO        CpuInfo;\r
+  PSI_STATIC_STRUCT PsiValidData;\r
+} SAL_PROCESSOR_ERROR_RECORD;\r
+\r
+//\r
+//  Sal Platform memory Error Record\r
+//\r
+#define SAL_MEMORY_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf2, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define MEMORY_ERROR_STATUS_VALID_BIT_MASK                0x1\r
+#define MEMORY_PHYSICAL_ADDRESS_VALID_BIT_MASK            0x2\r
+#define MEMORY_ADDR_BIT_MASK                              0x4\r
+#define MEMORY_NODE_VALID_BIT_MASK                        0x8\r
+#define MEMORY_CARD_VALID_BIT_MASK                        0x10\r
+#define MEMORY_MODULE_VALID_BIT_MASK                      0x20\r
+#define MEMORY_BANK_VALID_BIT_MASK                        0x40\r
+#define MEMORY_DEVICE_VALID_BIT_MASK                      0x80\r
+#define MEMORY_ROW_VALID_BIT_MASK                         0x100\r
+#define MEMORY_COLUMN_VALID_BIT_MASK                      0x200\r
+#define MEMORY_BIT_POSITION_VALID_BIT_MASK                0x400\r
+#define MEMORY_PLATFORM_REQUESTOR_ID_VALID_BIT_MASK       0x800\r
+#define MEMORY_PLATFORM_RESPONDER_ID_VALID_BIT_MASK       0x1000\r
+#define MEMORY_PLATFORM_TARGET_VALID_BIT_MASK             0x2000\r
+#define MEMORY_PLATFORM_BUS_SPECIFIC_DATA_VALID_BIT_MASK  0x4000\r
+#define MEMORY_PLATFORM_OEM_ID_VALID_BIT_MASK             0x8000\r
+#define MEMORY_PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK    0x10000\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT64          MemErrorStatus;\r
+  UINT64          MemPhysicalAddress;\r
+  UINT64          MemPhysicalAddressMask;\r
+  UINT16          MemNode;\r
+  UINT16          MemCard;\r
+  UINT16          MemModule;\r
+  UINT16          MemBank;\r
+  UINT16          MemDevice;\r
+  UINT16          MemRow;\r
+  UINT16          MemColumn;\r
+  UINT16          MemBitPosition;\r
+  UINT64          ModRequestorId;\r
+  UINT64          ModResponderId;\r
+  UINT64          ModTargetId;\r
+  UINT64          BusSpecificData;\r
+  UINT8           MemPlatformOemId[16];\r
+} SAL_MEMORY_ERROR_RECORD;\r
+\r
+//\r
+//  PCI BUS Errors\r
+//\r
+#define SAL_PCI_BUS_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf4, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define PCI_BUS_ERROR_STATUS_VALID_BIT_MASK     0x1\r
+#define PCI_BUS_ERROR_TYPE_VALID_BIT_MASK       0x2\r
+#define PCI_BUS_ID_VALID_BIT_MASK               0x4\r
+#define PCI_BUS_ADDRESS_VALID_BIT_MASK          0x8\r
+#define PCI_BUS_DATA_VALID_BIT_MASK             0x10\r
+#define PCI_BUS_CMD_VALID_BIT_MASK              0x20\r
+#define PCI_BUS_REQUESTOR_ID_VALID_BIT_MASK     0x40\r
+#define PCI_BUS_RESPONDER_ID_VALID_BIT_MASK     0x80\r
+#define PCI_BUS_TARGET_VALID_BIT_MASK           0x100\r
+#define PCI_BUS_OEM_ID_VALID_BIT_MASK           0x200\r
+#define PCI_BUS_OEM_DATA_STRUCT_VALID_BIT_MASK  0x400\r
+\r
+typedef enum {\r
+  Unknown,\r
+  DataParityError,\r
+  SystemError,\r
+  MasterAbort,\r
+  BusTimeout,\r
+  MasterDataParityError,\r
+  AddressParityError,\r
+  CommandParityError\r
+} PCI_BUS_ERROR_TYPE;\r
+\r
+typedef struct {\r
+  UINT8 BusNumber;\r
+  UINT8 SegmentNumber;\r
+} PCI_BUS_ID;\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT64          PciBusErrorStatus;\r
+  UINT16          PciBusErrorType;\r
+  PCI_BUS_ID      PciBusId;\r
+  UINT32          Reserved;\r
+  UINT64          PciBusAddress;\r
+  UINT64          PciBusData;\r
+  UINT64          PciBusCommand;\r
+  UINT64          PciBusRequestorId;\r
+  UINT64          PciBusResponderId;\r
+  UINT64          PciBusTargetId;\r
+  UINT8           PciBusOemId[16];\r
+} SAL_PCI_BUS_ERROR_RECORD;\r
+\r
+//\r
+//  PCI Component Errors\r
+//\r
+#define SAL_PCI_COMP_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf6, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define PCI_COMP_ERROR_STATUS_VALID_BIT_MASK    0x1\r
+#define PCI_COMP_INFO_VALID_BIT_MASK            0x2\r
+#define PCI_COMP_MEM_NUM_VALID_BIT_MASK         0x4\r
+#define PCI_COMP_IO_NUM_VALID_BIT_MASK          0x8\r
+#define PCI_COMP_REG_DATA_PAIR_VALID_BIT_MASK   0x10\r
+#define PCI_COMP_OEM_DATA_STRUCT_VALID_BIT_MASK 0x20\r
+\r
+typedef struct {\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT8   ClassCode[3];\r
+  UINT8   FunctionNumber;\r
+  UINT8   DeviceNumber;\r
+  UINT8   BusNumber;\r
+  UINT8   SegmentNumber;\r
+  UINT8   Reserved[5];\r
+} PCI_COMP_INFO;\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT64          PciComponentErrorStatus;\r
+  PCI_COMP_INFO   PciComponentInfo;\r
+  UINT32          PciComponentMemNum;\r
+  UINT32          PciComponentIoNum;\r
+  UINT8           PciBusOemId[16];\r
+} SAL_PCI_COMPONENT_ERROR_RECORD;\r
+\r
+//\r
+//  Sal Device Errors Info.\r
+//\r
+#define SAL_DEVICE_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf3, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define SEL_RECORD_ID_VALID_BIT_MASK      0x1;\r
+#define SEL_RECORD_TYPE_VALID_BIT_MASK    0x2;\r
+#define SEL_GENERATOR_ID_VALID_BIT_MASK   0x4;\r
+#define SEL_EVM_REV_VALID_BIT_MASK        0x8;\r
+#define SEL_SENSOR_TYPE_VALID_BIT_MASK    0x10;\r
+#define SEL_SENSOR_NUM_VALID_BIT_MASK     0x20;\r
+#define SEL_EVENT_DIR_TYPE_VALID_BIT_MASK 0x40;\r
+#define SEL_EVENT_DATA1_VALID_BIT_MASK    0x80;\r
+#define SEL_EVENT_DATA2_VALID_BIT_MASK    0x100;\r
+#define SEL_EVENT_DATA3_VALID_BIT_MASK    0x200;\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT16          SelRecordId;\r
+  UINT8           SelRecordType;\r
+  UINT32          TimeStamp;\r
+  UINT16          GeneratorId;\r
+  UINT8           EvmRevision;\r
+  UINT8           SensorType;\r
+  UINT8           SensorNum;\r
+  UINT8           EventDirType;\r
+  UINT8           Data1;\r
+  UINT8           Data2;\r
+  UINT8           Data3;\r
+} SAL_DEVICE_ERROR_RECORD;\r
+\r
+//\r
+//  Sal SMBIOS Device Errors Info.\r
+//\r
+#define SAL_SMBIOS_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf5, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define SMBIOS_EVENT_TYPE_VALID_BIT_MASK  0x1\r
+#define SMBIOS_LENGTH_VALID_BIT_MASK      0x2\r
+#define SMBIOS_TIME_STAMP_VALID_BIT_MASK  0x4\r
+#define SMBIOS_DATA_VALID_BIT_MASK        0x8\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT8           SmbiosEventType;\r
+  UINT8           SmbiosLength;\r
+  UINT8           SmbiosBcdTimeStamp[6];\r
+} SAL_SMBIOS_DEVICE_ERROR_RECORD;\r
+\r
+//\r
+//  Sal Platform Specific Errors Info.\r
+//\r
+#define SAL_PLATFORM_ERROR_RECORD_INFO \\r
+  { \\r
+    0xe429faf7, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+#define PLATFORM_ERROR_STATUS_VALID_BIT_MASK    0x1\r
+#define PLATFORM_REQUESTOR_ID_VALID_BIT_MASK    0x2\r
+#define PLATFORM_RESPONDER_ID_VALID_BIT_MASK    0x4\r
+#define PLATFORM_TARGET_VALID_BIT_MASK          0x8\r
+#define PLATFORM_SPECIFIC_DATA_VALID_BIT_MASK   0x10\r
+#define PLATFORM_OEM_ID_VALID_BIT_MASK          0x20\r
+#define PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK 0x40\r
+#define PLATFORM_OEM_DEVICE_PATH_VALID_BIT_MASK 0x80\r
+\r
+typedef struct {\r
+  SAL_SEC_HEADER  SectionHeader;\r
+  UINT64          ValidationBits;\r
+  UINT64          PlatformErrorStatus;\r
+  UINT64          PlatformRequestorId;\r
+  UINT64          PlatformResponderId;\r
+  UINT64          PlatformTargetId;\r
+  UINT64          PlatformBusSpecificData;\r
+  UINT8           OemComponentId[16];\r
+} SAL_PLATFORM_SPECIFIC_ERROR_RECORD;\r
+\r
+//\r
+// Union of all the possible Sal Record Types\r
+//\r
+typedef union {\r
+  SAL_RECORD_HEADER                   *RecordHeader;\r
+  SAL_PROCESSOR_ERROR_RECORD          *SalProcessorRecord;\r
+  SAL_PCI_BUS_ERROR_RECORD            *SalPciBusRecord;\r
+  SAL_PCI_COMPONENT_ERROR_RECORD      *SalPciComponentRecord;\r
+  SAL_DEVICE_ERROR_RECORD             *ImpiRecord;\r
+  SAL_SMBIOS_DEVICE_ERROR_RECORD      *SmbiosRecord;\r
+  SAL_PLATFORM_SPECIFIC_ERROR_RECORD  *PlatformRecord;\r
+  SAL_MEMORY_ERROR_RECORD             *MemoryRecord;\r
+  UINT8                               *Raw;\r
+} SAL_ERROR_RECORDS_POINTERS;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h
new file mode 100644 (file)
index 0000000..dc51e1d
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoBind.h\r
+\r
+Abstract:\r
+\r
+  Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM) \r
+  besides EfiBind.h.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_BIND_H_\r
+#define _TIANO_BIND_H_\r
+\r
+#include "EfiBind.h"\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h b/EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h
new file mode 100644 (file)
index 0000000..cef364b
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Pei.h\r
+\r
+Abstract:\r
+\r
+  Framework PEI master include file.\r
+\r
+  This is the main include file for Framework PEI components. There should be\r
+  no defines or macros added to this file, other than the EFI version \r
+  information already in this file.\r
+\r
+  Don't add include files to the list for convenience, only add things\r
+  that are architectural. Don't add Protocols or GUID include files here\r
+\r
+--*/\r
+\r
+#ifndef _PEI_H_\r
+#define _PEI_H_\r
+\r
+//\r
+// PEI Specification Revision information\r
+//\r
+#include "TianoCommon.h"\r
+\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include "EfiDebug.h"\r
+#include "PeiDebug.h"\r
+\r
+//\r
+// Enable code sharing with DXE by removing ASSERT and DEBUG\r
+//\r
+// #define ASSERT(a)\r
+// #define DEBUG (a)\r
+//\r
+\r
+#ifdef EFI_PEI_REPORT_STATUS_CODE_ON\r
+#define PEI_REPORT_STATUS_CODE_CODE(Code) Code\r
+#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data) \\r
+          (*PeiServices)->PeiReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data)\r
+#else\r
+#define PEI_REPORT_STATUS_CODE_CODE(Code)\r
+#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data)\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h
new file mode 100644 (file)
index 0000000..a3cdb7b
--- /dev/null
@@ -0,0 +1,160 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiBind.h\r
+\r
+Abstract:\r
+\r
+  Tiano PEI core and PEIM binding macros\r
+\r
+--*/\r
+\r
+#ifndef _PEI_BIND_H_\r
+#define _PEI_BIND_H_\r
+\r
+#ifdef EFI_DEBUG\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+            IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup         \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(PeiStartup);                \\r
+          }\r
+\r
+#else\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+            IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData,    \\r
+            IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList         \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(SecCoreData, PpiList);      \\r
+          }\r
+\r
+#endif\r
+\r
+#define EFI_PEIM_ENTRY_POINT(InitFunction)                    \\r
+          UINTN                                               \\r
+          __stdcall                                           \\r
+          _DllMainCRTStartup (                                \\r
+              UINTN    Inst,                                  \\r
+              UINTN    reason_for_call,                       \\r
+              VOID    *rserved                                \\r
+              )                                               \\r
+          {                                                   \\r
+              return 1;                                       \\r
+          }                                                   \\r
+                                                              \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+              IN EFI_FFS_FILE_HEADER       *FfsHeader,        \\r
+              IN EFI_PEI_SERVICES          **PeiServices      \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(FfsHeader, PeiServices);    \\r
+          }\r
+\r
+#else\r
+\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \r
+#define EFI_PEIM_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
+\r
+#else\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+            IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup         \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(PeiStartup);                \\r
+          }\r
+\r
+#else\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+            IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData,    \\r
+            IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList         \\r
+            )                                               \\r
+          {                                                   \\r
+              return InitFunction(SecCoreData, PpiList);     \\r
+          }\r
+\r
+#endif\r
+\r
+          \r
+#define EFI_PEIM_ENTRY_POINT(InitFunction)                    \\r
+          EFI_STATUS                                          \\r
+          __declspec( dllexport  )                            \\r
+          __cdecl                                             \\r
+          InitializeDriver (                                  \\r
+              IN EFI_FFS_FILE_HEADER       *FfsHeader,        \\r
+              IN EFI_PEI_SERVICES          **PeiServices      \\r
+              )                                               \\r
+          {                                                   \\r
+              return InitFunction(FfsHeader, PeiServices);    \\r
+          }\r
+#else\r
+\r
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)                \r
+#define EFI_PEIM_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
+#endif\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h
new file mode 100644 (file)
index 0000000..a957c2b
--- /dev/null
@@ -0,0 +1,104 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiDebug.h\r
+\r
+Abstract:\r
+\r
+  PEI Debug macros. The work needs to be done in library. The Debug\r
+  macros them selves are standard for all files, including the core.\r
+  \r
+  There needs to be code linked in that produces the following macros:\r
+  \r
+  PeiDebugAssert(file, linenumber, assertion string) - worker function for \r
+      ASSERT. filename and line number of where this ASSERT() is located\r
+      is passed in along with the stringized version of the assertion.\r
+  \r
+  PeiDebugPrint - Worker function for debug print\r
+\r
+  _DEBUG_SET_MEM(address, length, value) - Set memory at address to value\r
+    for legnth bytes. This macro is used to initialzed uninitialized memory\r
+    or memory that is free'ed, so it will not be used by mistake. \r
+\r
+--*/\r
+\r
+#ifndef _PEIDEBUG_H_\r
+#define _PEIDEBUG_H_\r
+\r
+#ifdef EFI_DEBUG\r
+\r
+  VOID\r
+  PeiDebugAssert (\r
+    IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+    IN CHAR8              *FileName,\r
+    IN INTN               LineNumber,\r
+    IN CHAR8              *Description\r
+    );\r
+\r
+  VOID\r
+  PeiDebugPrint (\r
+    IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+    IN UINTN              ErrorLevel,\r
+    IN CHAR8              *Format,\r
+    ...\r
+    );\r
+\r
+  #define _PEI_DEBUG_ASSERT(PeiST, assertion)  \\r
+            PeiDebugAssert (PeiST, __FILE__, __LINE__, #assertion)\r
+\r
+  #define _PEI_DEBUG(PeiST, arg) PeiDebugPrint (PeiST, arg)\r
+\r
+  //\r
+  // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT\r
+  //\r
+  #define PEI_ASSERT(PeiST, assertion)   if(!(assertion))  \\r
+                                            _PEI_DEBUG_ASSERT(PeiST, assertion)\r
+    \r
+  #define PEI_ASSERT_LOCKED(PeiST, l)    if(!(l)->Lock) _PEI_DEBUG_ASSERT(PeiST, l not locked)\r
+\r
+  //\r
+  // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do \r
+  //   the a debug print.\r
+  //\r
+  \r
+  #define PEI_DEBUG(arg)        PeiDebugPrint arg\r
+\r
+  #define PEI_DEBUG_CODE(code)  code\r
+\r
+  #define PEI_CR(Record, TYPE, Field, Signature)   \\r
+            _CR(Record, TYPE, Field)                           \r
+\r
+\r
+  #define _PEI_DEBUG_SET_MEM(address, length, data) SetMem(address, length, data)\r
+\r
+#else\r
+  #define PEI_ASSERT(PeiST, a)               \r
+  #define PEI_ASSERT_LOCKED(PeiST, l)    \r
+  #define PEI_DEBUG(arg) \r
+  #define PEI_DEBUG_CODE(code)  \r
+  #define PEI_CR(Record, TYPE, Field, Signature)   \\r
+            _CR(Record, TYPE, Field)                           \r
+  #define _PEI_DEBUG_SET_MEM(address, length, data) \r
+#endif\r
+\r
+#define ASSERT_PEI_ERROR(PeiST, status)  PEI_ASSERT(PeiST, !EFI_ERROR(status))\r
+\r
+#ifdef EFI_DEBUG_CLEAR_MEMORY\r
+  #define PEI_DEBUG_SET_MEMORY(address,length)  \\r
+            _PEI_DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)\r
+#else\r
+  #define PEI_DEBUG_SET_MEMORY(address,length)\r
+#endif\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/Tiano.h b/EdkCompatibilityPkg/Foundation/Include/Tiano.h
new file mode 100644 (file)
index 0000000..55790c2
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Tiano.h\r
+\r
+Abstract:\r
+\r
+  Tiano master include file.\r
+\r
+  This is the main include file for Tiano components. \r
+\r
+  Don't add include files to the list for convenience, only add things\r
+  that are architectural. Don't add Protocols or GUID include files here\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_H_\r
+#define _TIANO_H_\r
+\r
+//\r
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
+//\r
+#if !defined(EFI_SPECIFICATION_VERSION)\r
+  #error EFI_SPECIFICATION_VERSION not defined\r
+#elif !defined(TIANO_RELEASE_VERSION)\r
+  #error TIANO_RELEASE_VERSION not defined\r
+#elif (TIANO_RELEASE_VERSION == 0)\r
+  #error TIANO_RELEASE_VERSION can not be zero\r
+#elif (EFI_SPECIFICATION_VERSION <= 0x00020000)\r
+  #define TIANO_EXTENSION_FLAG\r
+#endif\r
+\r
+#include "TianoCommon.h"\r
+#include "TianoApi.h"\r
+#include "EfiDebug.h"\r
+#include "TianoDevicePath.h"\r
+#include "EfiSpec.h"\r
+\r
+//\r
+// EFI Revision information\r
+//\r
+#define EFI_FIRMWARE_MAJOR_REVISION 0x1000\r
+#define EFI_FIRMWARE_MINOR_REVISION 1\r
+#define EFI_FIRMWARE_REVISION       ((EFI_FIRMWARE_MAJOR_REVISION << 16) | (EFI_FIRMWARE_MINOR_REVISION))\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoApi.h b/EdkCompatibilityPkg/Foundation/Include/TianoApi.h
new file mode 100644 (file)
index 0000000..da1ca7c
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoApi.h\r
+\r
+Abstract:\r
+\r
+  Tiano intrinsic definitions. \r
+\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_API_H_\r
+#define _TIANO_API_H_\r
+\r
+#include "EfiApi.h"\r
+#include "TianoSpecApi.h"\r
+\r
+//\r
+// Pointer to internal runtime function\r
+//\r
+#define EFI_INTERNAL_FUNCTION 0x00000002\r
+\r
+//\r
+// Pointer to internal runtime pointer\r
+//\r
+#define EFI_INTERNAL_POINTER  0x00000004\r
+\r
+//\r
+// Pointer to internal runtime pointer\r
+//\r
+#define EFI_IPF_GP_POINTER  0x00000008\r
+\r
+#define EFI_TPL_DRIVER      6\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoCommon.h b/EdkCompatibilityPkg/Foundation/Include/TianoCommon.h
new file mode 100644 (file)
index 0000000..c2a87c7
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  TianoCommon.h\r
+\r
+Abstract:\r
+\r
+  Tiano specific common definitions besides EfiCommon.h\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_COMMON_H_\r
+#define _TIANO_COMMON_H_\r
+\r
+#include "TianoBind.h"\r
+#include "TianoTypes.h"\r
+#include "EfiStdArg.h"\r
+#include "TianoError.h"\r
+#include "EfiStatusCode.h"\r
+#include "EfiCommon.h"\r
+\r
+//\r
+// Define macros for including Architectural Protocols and PPIs\r
+//\r
+#define EFI_ARCH_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (ArchProtocol/a/a.h)\r
+#define EFI_PPI_DEFINITION(a)           EFI_STRINGIZE (Ppi/a/a.h)\r
+\r
+//\r
+// These should be used to include protocols.  If they are followed,\r
+// intelligent build tools can be created to check dependencies at build\r
+// time.\r
+//\r
+#define EFI_ARCH_PROTOCOL_PRODUCER(a)   EFI_ARCH_PROTOCOL_DEFINITION (a)\r
+#define EFI_ARCH_PROTOCOL_CONSUMER(a)   EFI_ARCH_PROTOCOL_DEFINITION (a)\r
+#define EFI_ARCH_PROTOCOL_DEPENDENCY(a) EFI_ARCH_PROTOCOL_DEFINITION (a)\r
+\r
+#define EFI_PPI_PRODUCER(a)             EFI_PPI_DEFINITION (a)\r
+#define EFI_PPI_CONSUMER(a)             EFI_PPI_DEFINITION (a)\r
+#define EFI_PPI_DEPENDENCY(a)           EFI_PPI_DEFINITION (a)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h b/EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h
new file mode 100644 (file)
index 0000000..445a075
--- /dev/null
@@ -0,0 +1,130 @@
+/*++\r
\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoDevicePath.h\r
+\r
+Abstract:\r
+\r
+  Tiano Device Path definitions\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_DEVICE_PATH_H\r
+#define _TIANO_DEVICE_PATH_H\r
+\r
+#include "EfiDevicePath.h"\r
+#include "TianoSpecDevicePath.h"\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct _USB_PORT_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} USB_PORT_DEVICE_PATH;\r
+\r
+//\r
+// IDE\r
+//\r
+typedef struct _IDE_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} IDE_DEVICE_PATH;\r
+\r
+//\r
+// RMC Connector\r
+//\r
+typedef struct _RMC_CONN_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RMC_CONN_DEVICE_PATH;\r
+\r
+//\r
+// RIDE\r
+//\r
+typedef struct _RIDE_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RIDE_DEVICE_PATH;\r
+\r
+//\r
+// Gigabit NIC\r
+//\r
+typedef struct _GB_NIC_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciXBridgeDevicePath;\r
+  PCI_DEVICE_PATH           PciXBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} GB_NIC_DEVICE_PATH;\r
+\r
+//\r
+// P/S2 Connector\r
+//\r
+typedef struct _PS2_CONN_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH      LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PS2_CONN_DEVICE_PATH;\r
+\r
+//\r
+// Serial Port Connector\r
+//\r
+typedef struct _SERIAL_CONN_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH      LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} SERIAL_CONN_DEVICE_PATH;\r
+\r
+//\r
+// Parallel Port Connector\r
+//\r
+typedef struct _PARALLEL_CONN_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH      LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PARALLEL_CONN_DEVICE_PATH;\r
+\r
+//\r
+// Floopy Connector\r
+//\r
+typedef struct _FLOOPY_CONN_DEVICE_PATH {\r
+  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH           LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH      LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} FLOOPY_CONN_DEVICE_PATH;\r
+\r
+typedef union _EFI_MISC_PORT_DEVICE_PATH {\r
+  USB_PORT_DEVICE_PATH      UsbDevicePath;\r
+  IDE_DEVICE_PATH           IdeDevicePath;\r
+  RMC_CONN_DEVICE_PATH      RmcConnDevicePath;\r
+  RIDE_DEVICE_PATH          RideDevicePath;\r
+  GB_NIC_DEVICE_PATH        GbNicDevicePath;\r
+  PS2_CONN_DEVICE_PATH      Ps2ConnDevicePath;\r
+  SERIAL_CONN_DEVICE_PATH   SerialConnDevicePath;\r
+  PARALLEL_CONN_DEVICE_PATH ParallelConnDevicePath;\r
+  FLOOPY_CONN_DEVICE_PATH   FloppyConnDevicePath;\r
+} EFI_MISC_PORT_DEVICE_PATH;\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoError.h b/EdkCompatibilityPkg/Foundation/Include/TianoError.h
new file mode 100644 (file)
index 0000000..93cccf7
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoError.h\r
+\r
+Abstract:\r
+\r
+  Tiano error levels and their associated defines\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_ERROR_H_\r
+#define _TIANO_ERROR_H_\r
+\r
+#include "EfiError.h"\r
+#include "TianoSpecError.h"\r
+\r
+#define EFI_WARN_RETURN_FROM_LONG_JUMP  EFIWARN (5)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoTypes.h b/EdkCompatibilityPkg/Foundation/Include/TianoTypes.h
new file mode 100644 (file)
index 0000000..de52e4f
--- /dev/null
@@ -0,0 +1,48 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoTypes.h\r
+\r
+Abstract:\r
+\r
+  Tiano specific part besides EfiTypes.h\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_TYPES_H_\r
+#define _TIANO_TYPES_H_\r
+\r
+#include "EfiTypes.h"\r
+#include "TianoSpecTypes.h"\r
+\r
+//\r
+// attributes for reserved memory before it is promoted to system memory\r
+//\r
+#define EFI_MEMORY_PRESENT      0x0100000000000000\r
+#define EFI_MEMORY_INITIALIZED  0x0200000000000000\r
+#define EFI_MEMORY_TESTED       0x0400000000000000\r
+\r
+//\r
+// range for memory mapped port I/O on IPF\r
+//\r
+#define EFI_MEMORY_PORT_IO  0x4000000000000000\r
+\r
+//\r
+// A pointer to a function in IPF points to a plabel.\r
+//\r
+typedef struct {\r
+  UINT64  EntryPoint;\r
+  UINT64  GP;\r
+} EFI_PLABEL;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h
new file mode 100644 (file)
index 0000000..2b51b66
--- /dev/null
@@ -0,0 +1,222 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiBind.h\r
+\r
+Abstract:\r
+\r
+  Processor or Compiler specific defines and types for x64.\r
+  We are using the ANSI C 2000 _t type definitions for basic types.\r
+  This it technically a violation of the coding standard, but they\r
+  are used to make EfiTypes.h portable. Code other than EfiTypes.h\r
+  should never use any ANSI C 2000 _t integer types.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BIND_H_\r
+#define _EFI_BIND_H_\r
+\r
+\r
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)                  \r
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT\r
+\r
+\r
+\r
+//\r
+// Make sure we are useing the correct packing rules per EFI specification\r
+//\r
+#pragma pack()\r
+\r
+#if _MSC_EXTENSIONS\r
+\r
+//\r
+// Disable warning that make it impossible to compile at /W4\r
+// This only works for Microsoft* tools\r
+//\r
+\r
+//\r
+// Disabling bitfield type checking warnings.\r
+//\r
+#pragma warning ( disable : 4214 )\r
+\r
+//\r
+// Disabling the unreferenced formal parameter warnings.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// Disable slightly different base types warning as CHAR8 * can not be set\r
+// to a constant string.\r
+//\r
+#pragma warning ( disable : 4057 )\r
+\r
+//\r
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
+//\r
+#pragma warning ( disable : 4127 )\r
+\r
+//\r
+// Int64ShllMod32 unreferenced inline function\r
+//\r
+#pragma warning ( disable : 4514 )\r
+\r
+//\r
+// Unreferenced formal parameter - We are object oriented, so we pass This even\r
+//  if we  don't need them.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// This warning is caused by empty (after preprocessing) souce file.\r
+//\r
+#pragma warning ( disable : 4206 )\r
+\r
+//\r
+// Warning: The result of the unary '&' operator may be unaligned. Ignore it.\r
+//\r
+#pragma warning ( disable : 4366 )\r
+\r
+#endif\r
+\r
+\r
+#if (__STDC_VERSION__ < 199901L)\r
+  //\r
+  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
+  //\r
\r
+  #if _MSC_EXTENSIONS \r
+    \r
+    //\r
+    // use Microsoft* C complier dependent interger width types \r
+    //\r
+    typedef unsigned __int64    uint64_t;\r
+    typedef __int64             int64_t;\r
+    typedef unsigned __int32    uint32_t;\r
+    typedef __int32             int32_t;\r
+    typedef unsigned short      uint16_t;\r
+    typedef short               int16_t;\r
+    typedef unsigned char       uint8_t;\r
+    typedef char                int8_t;\r
+  #else\r
+\r
+    //\r
+    // Assume standard IA-32 alignment. \r
+    // BugBug: Need to check portability of long long\r
+    //\r
+    typedef unsigned long long  uint64_t;\r
+    typedef long long           int64_t;\r
+    typedef unsigned int        uint32_t;\r
+    typedef int                 int32_t;\r
+    typedef unsigned short      uint16_t;\r
+    typedef short               int16_t;\r
+    typedef unsigned char       uint8_t;\r
+    typedef char                int8_t;\r
+  #endif\r
+#else\r
+  //\r
+  // Use ANSI C 2000 stdint.h integer width declarations\r
+  //\r
+  #include "stdint.h"\r
+#endif\r
+\r
+//\r
+// Native integer size in stdint.h\r
+//\r
+typedef uint64_t  uintn_t;\r
+typedef int64_t   intn_t;\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+#define EFI_MAX_BIT       0x8000000000000000\r
+#define MAX_2_BITS        0xC000000000000000\r
+\r
+//\r
+// Maximum legal IA-32 address\r
+//\r
+#define EFI_MAX_ADDRESS   0xFFFFFFFFFFFFFFFF\r
+\r
+//\r
+//  Bad pointer value to use in check builds.\r
+//  if you see this value you are using uninitialized or free'ed data\r
+//\r
+#define EFI_BAD_POINTER          0xAFAFAFAFAFAFAFAF\r
+#define EFI_BAD_POINTER_AS_BYTE  0xAF\r
+\r
+//\r
+// Inject a break point in the code to assist debugging.\r
+//\r
+#define EFI_DEADLOOP()    { volatile int __iii; __iii = 1; while (__iii); }\r
+#define EFI_BREAKPOINT()  __debugbreak()\r
+\r
+//\r
+// Memory Fence forces serialization, and is needed to support out of order\r
+//  memory transactions. The Memory Fence is mainly used to make sure IO\r
+//  transactions complete in a deterministic sequence, and to syncronize locks\r
+//  an other MP code. Currently no memory fencing is required.\r
+//\r
+#define MEMORY_FENCE()\r
+\r
+//\r
+// Some compilers don't support the forward reference construct:\r
+//  typedef struct XXXXX. The forward reference is required for \r
+//  ANSI compatibility.\r
+//\r
+// The following macro provide a workaround for such cases.\r
+//\r
+\r
+\r
+#ifdef EFI_NO_INTERFACE_DECL\r
+  #define EFI_FORWARD_DECLARATION(x)\r
+#else\r
+  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x\r
+#endif\r
+\r
+\r
+//\r
+// Some C compilers optimize the calling conventions to increase performance.\r
+// _EFIAPI is used to make all public APIs follow the standard C calling \r
+// convention.\r
+//\r
+#if _MSC_EXTENSIONS\r
+  //\r
+  // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.\r
+  // \r
+\r
+  #define _EFIAPI __cdecl  \r
+#else\r
+  #define _EFIAPI       \r
+#endif\r
+\r
+\r
+#ifdef _EFI_WINNT\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4142 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4142 )\r
+#else\r
+\r
+  #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( disable : 4068 )\r
+\r
+  #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING()  \\r
+           warning ( default : 4068 )\r
+\r
+#endif\r
+\r
+\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h
new file mode 100644 (file)
index 0000000..03d1dc2
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiPeOptionalHeader.h\r
+\r
+Abstract:\r
+  Defines the optional header in the PE image per the PE specification.  This\r
+  file must be included only from within EfiImage.h since \r
+  EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined\r
+  there.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_\r
+#define _EFI_PE_OPTIONAL_HEADER_H_\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_X64)\r
+\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) \r
+\r
+//\r
+// Assume we can use IPF values\r
+//\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h
new file mode 100644 (file)
index 0000000..45fe211
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoBind.h\r
+\r
+Abstract:\r
+\r
+  Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM) \r
+  besides EfiBind.h.\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_BIND_H_\r
+#define _TIANO_BIND_H_\r
+\r
+#include "EfiBind.h"\r
+\r
+#define EFI_DXE_ENTRY_POINT(InitFunction)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
new file mode 100644 (file)
index 0000000..b80e6fa
--- /dev/null
@@ -0,0 +1,61 @@
+#/*++\r
+#\r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#   Module Name:\r
+#\r
+#     CompilerStubLib.inf\r
+#\r
+#   Abstract:\r
+#\r
+#     Component description file for the CompilerStub.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = CompilerStub\r
+COMPONENT_TYPE  = LIBRARY\r
+  \r
+[sources.common] \r
+\r
+[sources.ia32]\r
+  Ia32\memcpy.asm\r
+  Ia32\memset.asm\r
+  \r
+[sources.x64]  \r
+  x64\memcpy.asm\r
+  x64\memset.asm\r
+  \r
+[sources.Ipf]  \r
+  memcpy.c\r
+  memset.c\r
+  \r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+\r
+[libraries.common]\r
+\r
+[nmake.common]\r
+\r
+[nmake.ia32,nmake.x64]\r
+  C_FLAGS= $(C_FLAGS) /GL-\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm
new file mode 100644 (file)
index 0000000..37b5056
--- /dev/null
@@ -0,0 +1,81 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memcpy function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  memcpy (\r
+;    IN VOID   *Destination,\r
+;    IN VOID   *Source,\r
+;    IN UINTN  Count\r
+;    );\r
+;------------------------------------------------------------------------------\r
+memcpy  PROC    USES    esi edi\r
+    mov     esi, [esp + 16]             ; esi <- Source\r
+    mov     edi, [esp + 12]             ; edi <- Destination\r
+    mov     edx, [esp + 20]             ; edx <- Count\r
+    lea     eax, [esi + edx - 1]        ; eax <- End of Source\r
+    cmp     esi, edi\r
+    je      @CopyMemDone\r
+    cmp     edx, 0\r
+    je      @CopyMemDone\r
+    cmp     esi, edi\r
+    jae     @F\r
+    cmp     eax, edi                    ; Overlapped?\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    mov     ecx, edx\r
+    and     edx, 7\r
+    shr     ecx, 3                      ; ecx <- # of Qwords to copy\r
+    jz      @CopyBytes\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm0                  ; save mm0\r
+@@:\r
+    movq    mm0, [esi]\r
+    movq    [edi], mm0\r
+    add     esi, 8\r
+    add     edi, 8\r
+    loop    @B\r
+    movq    mm0, [esp]                  ; restore mm0\r
+    pop     ecx                         ; stack cleanup\r
+    pop     ecx                         ; stack cleanup\r
+    jmp     @CopyBytes\r
+@CopyBackward:\r
+    mov     esi, eax                    ; esi <- Last byte in Source\r
+    lea     edi, [edi + edx - 1]        ; edi <- Last byte in Destination\r
+    std\r
+@CopyBytes:\r
+    mov     ecx, edx\r
+    rep     movsb\r
+    cld\r
+@CopyMemDone:    \r
+    mov     eax, [esp + 12]\r
+    ret\r
+memcpy  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm
new file mode 100644 (file)
index 0000000..5ae5752
--- /dev/null
@@ -0,0 +1,86 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memcpy function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  memcpy (\r
+;    IN VOID   *Destination,\r
+;    IN VOID   *Source,\r
+;    IN UINTN  Count\r
+;    );\r
+;------------------------------------------------------------------------------\r
+memcpy  PROC    USES    esi edi\r
+    mov     esi, [esp + 16]             ; esi <- Source\r
+    mov     edi, [esp + 12]             ; edi <- Destination\r
+    mov     edx, [esp + 20]             ; edx <- Count\r
+    lea     eax, [esi + edx - 1]        ; eax <- End of Source\r
+    cmp     esi, edi\r
+    je      @CopyMemDone\r
+    cmp     edx, 0\r
+    je      @CopyMemDone\r
+    cmp     esi, edi\r
+    jae     @F\r
+    cmp     eax, edi                    ; Overlapped?\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    xor     ecx, ecx\r
+    sub     ecx, edi\r
+    and     ecx, 15                     ; ecx + edi aligns on 16-byte boundary\r
+    jz      @F\r
+    cmp     ecx, edx\r
+    cmova   ecx, edx\r
+    sub     edx, ecx                    ; edx <- remaining bytes to copy\r
+    rep     movsb\r
+@@:\r
+    mov     ecx, edx\r
+    and     edx, 15\r
+    shr     ecx, 4                      ; ecx <- # of DQwords to copy\r
+    jz      @CopyBytes\r
+    add     esp, -16\r
+@@:\r
+    movdqu  xmm0, [esi]                 ; esi may not be 16-bytes aligned\r
+    movdqa  [edi], xmm0                 ; edi should be 16-bytes aligned\r
+    add     esi, 16\r
+    add     edi, 16\r
+    loop    @B\r
+    add     esp, 16                     ; stack cleanup\r
+    jmp     @CopyBytes\r
+@CopyBackward:\r
+    mov     esi, eax                    ; esi <- Last byte in Source\r
+    lea     edi, [edi + edx - 1]        ; edi <- Last byte in Destination\r
+    std\r
+@CopyBytes:\r
+    mov     ecx, edx\r
+    rep     movsb\r
+    cld\r
+@CopyMemDone:    \r
+    mov     eax, [esp + 12]\r
+    ret\r
+memcpy  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm
new file mode 100644 (file)
index 0000000..3dbf920
--- /dev/null
@@ -0,0 +1,72 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memset function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  memset (\r
+;    OUT VOID   *Buffer,\r
+;    IN  UINT8  Value,\r
+;    IN  UINTN  Count\r
+;    )\r
+;------------------------------------------------------------------------------\r
+memset   PROC    USES    edi\r
+    mov     al, [esp + 12]\r
+    mov     ah, al\r
+    shrd    edx, eax, 16\r
+    shld    eax, edx, 16\r
+    mov     ecx, [esp + 16]             ; ecx <- Count\r
+    cmp     ecx, 0                      ; if Count == 0, do nothing\r
+    je      @SetDone\r
+    mov     edi, [esp + 8]              ; edi <- Buffer\r
+    mov     edx, ecx\r
+    and     edx, 7\r
+    shr     ecx, 3                      ; # of Qwords to set\r
+    jz      @SetBytes\r
+    add     esp, -10h\r
+    movq    [esp], mm0                  ; save mm0\r
+    movq    [esp + 8], mm1              ; save mm1\r
+    movd    mm0, eax\r
+    movd    mm1, eax\r
+    psllq   mm0, 32\r
+    por     mm0, mm1                    ; fill mm0 with 8 Value's\r
+@@:\r
+    movq    [edi], mm0\r
+    add     edi, 8\r
+    loop    @B\r
+    movq    mm0, [esp]                  ; restore mm0\r
+    movq    mm1, [esp + 8]              ; restore mm1\r
+    add     esp, 10h                    ; stack cleanup\r
+@SetBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+@SetDone:    \r
+    mov     eax, [esp + 8]              ; eax <- Buffer as return value\r
+    ret\r
+memset   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm
new file mode 100644 (file)
index 0000000..ce9ba64
--- /dev/null
@@ -0,0 +1,74 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memset function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  memset (\r
+;    OUT VOID   *Buffer,\r
+;    IN  UINT8  Value,\r
+;    IN  UINTN  Count\r
+;    )\r
+;------------------------------------------------------------------------------\r
+memset   PROC    USES    edi\r
+    mov     edx, [esp + 16]             ; edx <- Count\r
+    cmp     edx, 0                      ; if Count == 0, do nothing\r
+    je      @SetDone    \r
+    mov     edi, [esp + 8]              ; edi <- Buffer\r
+    mov     al, [esp + 12]              ; al <- Value\r
+    xor     ecx, ecx\r
+    sub     ecx, edi\r
+    and     ecx, 15                     ; ecx + edi aligns on 16-byte boundary\r
+    jz      @F\r
+    cmp     ecx, edx\r
+    cmova   ecx, edx\r
+    sub     edx, ecx\r
+    rep     stosb\r
+@@:\r
+    mov     ecx, edx\r
+    and     edx, 15\r
+    shr     ecx, 4                      ; ecx <- # of DQwords to set\r
+    jz      @SetBytes\r
+    mov     ah, al                      ; ax <- Value | (Value << 8)\r
+    add     esp, -16\r
+    movd    xmm0, eax\r
+    pshuflw xmm0, xmm0, 0               ; xmm0[0..63] <- Value repeats 8 times\r
+    movlhps xmm0, xmm0                  ; xmm0 <- Value repeats 16 times\r
+@@:\r
+    movdqa  [edi], xmm0                 ; edi should be 16-byte aligned\r
+    add     edi, 16\r
+    loop    @B\r
+    add     esp, 16                     ; stack cleanup\r
+@SetBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+@SetDone:    \r
+    mov     eax, [esp + 8]              ; eax <- Buffer as return value\r
+    ret\r
+memset   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c
new file mode 100644 (file)
index 0000000..300724a
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  memcpy.c\r
+\r
+Abstract:\r
+\r
+  The Microsoft compiler inlines memcpy and we can not stop it.\r
+  These routines allow the code to link!\r
+\r
+  There is no *.h definition of these modules as they are well known by the \r
+  compiler. See Microsoft documentation for more details!\r
+\r
+  volatile is used to prevent the compiler from trying to implement these\r
+  C functions as inline functions. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID *\r
+memcpy (\r
+  OUT VOID        *Dest,\r
+  IN  const VOID  *Src,\r
+  IN  UINTN       Count\r
+  )\r
+{\r
+  volatile UINT8  *Ptr;\r
+  const    UINT8  *Source;\r
+  \r
+  for (Ptr = Dest, Source = Src; Count > 0; Count--, Source++, Ptr++) {\r
+    *Ptr = *Source;\r
+  }\r
+\r
+  return Dest;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c
new file mode 100644 (file)
index 0000000..0f0f40d
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  memset.c\r
+\r
+Abstract:\r
+\r
+  The Microsoft compiler inlines memset and we can not stop it.\r
+  These routines allow the code to link!\r
+\r
+  There is no *.h definition of these modules as they are well known by the \r
+  compiler. See Microsoft documentation for more details!\r
+\r
+  volatile is used to prevent the compiler from trying to implement these\r
+  C functions as inline functions. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID *\r
+memset (\r
+  OUT VOID    *Dest,\r
+  IN  UINTN   Char,\r
+  IN  UINTN   Count\r
+  )\r
+{\r
+  volatile UINT8  *Ptr;\r
+  \r
+  for (Ptr = Dest; Count > 0; Count--, Ptr++) {\r
+    *Ptr = (UINT8) Char;\r
+  }\r
+\r
+  return Dest;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm
new file mode 100644 (file)
index 0000000..7e04431
--- /dev/null
@@ -0,0 +1,73 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memcpy function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; memcpy (\r
+;   OUT     VOID                      *DestinationBuffer,\r
+;   IN      CONST VOID                *SourceBuffer,\r
+;   IN      UINTN                     Length\r
+;   );\r
+;------------------------------------------------------------------------------\r
+memcpy  PROC    USES    rsi rdi\r
+    mov     rax, rcx                    ; rax <- Destination as return value\r
+    cmp     rdx, rcx                    ; if Source == Destination, do nothing\r
+    je      @CopyMemDone\r
+    cmp     r8, 0                       ; if Count == 0, do nothing\r
+    je      @CopyMemDone\r
+    mov     rsi, rdx                    ; rsi <- Source\r
+    mov     rdi, rcx                    ; rdi <- Destination\r
+    lea     r9, [rsi + r8 - 1]          ; r9 <- End of Source\r
+    cmp     rsi, rdi\r
+    jae     @F\r
+    cmp     r9, rdi\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    mov     rcx, r8\r
+    and     r8, 7\r
+    shr     rcx, 3                      ; rcx <- # of Qwords to copy\r
+    jz      @CopyBytes\r
+    DB      49h, 0fh, 7eh, 0c2h         ; movd r10, mm0 (Save mm0 in r10)\r
+@@:\r
+    DB      0fh, 6fh, 06h               ; movd mm0, [rsi]\r
+    DB      48h, 0fh, 7eh, 07h          ; movd [rdi], mm0\r
+    add     rsi, 8\r
+    add     rdi, 8\r
+    loop    @B\r
+    DB      49h, 0fh, 6eh, 0c2h         ; movd mm0, r10 (Restore mm0)\r
+    jmp     @CopyBytes\r
+@CopyBackward:\r
+    mov     rsi, r9                     ; rsi <- End of Source\r
+    lea     rdi, [rdi + r8 - 1]         ; rdi <- End of Destination\r
+    std                                 ; set direction flag\r
+@CopyBytes:\r
+    mov     rcx, r8\r
+    rep     movsb                       ; Copy bytes backward\r
+    cld\r
+@CopyMemDone:   \r
+    ret\r
+memcpy  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm
new file mode 100644 (file)
index 0000000..15bdf37
--- /dev/null
@@ -0,0 +1,80 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memcpy function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; memcpy (\r
+;   OUT     VOID                      *DestinationBuffer,\r
+;   IN      CONST VOID                *SourceBuffer,\r
+;   IN      UINTN                     Length\r
+;   );\r
+;------------------------------------------------------------------------------\r
+memcpy  PROC    USES    rsi rdi\r
+    mov     rax, rcx                    ; rax <- Destination as return value\r
+    cmp     rdx, rcx                    ; if Source == Destination, do nothing\r
+    je      @CopyMemDone\r
+    cmp     r8, 0                       ; if Count == 0, do nothing\r
+    je      @CopyMemDone\r
+    mov     rsi, rdx                    ; rsi <- Source\r
+    mov     rdi, rcx                    ; rdi <- Destination\r
+    lea     r9, [rsi + r8 - 1]          ; r9 <- Last byte of Source\r
+    cmp     rsi, rdi\r
+    jae     @F                          ; Copy forward if Source > Destination\r
+    cmp     r9, rdi                     ; Overlapped?\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    xor     rcx, rcx\r
+    sub     rcx, rdi                    ; rcx <- -rdi\r
+    and     rcx, 15                     ; rcx + rsi should be 16 bytes aligned\r
+    jz      @F                          ; skip if rcx == 0\r
+    cmp     rcx, r8\r
+    cmova   rcx, r8\r
+    sub     r8, rcx\r
+    rep     movsb\r
+@@:\r
+    mov     rcx, r8\r
+    and     r8, 15\r
+    shr     rcx, 4                      ; rcx <- # of DQwords to copy\r
+    jz      @CopyBytes\r
+@@:\r
+    movdqu  xmm0, [rsi]                 ; rsi may not be 16-byte aligned\r
+    movdqa  [rdi], xmm0                 ; rdi should be 16-byte aligned\r
+    add     rsi, 16\r
+    add     rdi, 16\r
+    loop    @B\r
+    jmp     @CopyBytes                  ; copy remaining bytes\r
+@CopyBackward:\r
+    mov     rsi, r9                     ; rsi <- Last byte of Source\r
+    lea     rdi, [rdi + r8 - 1]         ; rdi <- Last byte of Destination\r
+    std\r
+@CopyBytes:\r
+    mov     rcx, r8\r
+    rep     movsb\r
+    cld\r
+@CopyMemDone:   \r
+    ret\r
+memcpy  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm
new file mode 100644 (file)
index 0000000..134700d
--- /dev/null
@@ -0,0 +1,62 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memset function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; memset (\r
+;   OUT     VOID                      *Buffer,    --> rcx\r
+;   IN      UINT8                     Value,      --> rdx\r
+;   IN      UINTN                     Length      --> r8\r
+;   );\r
+;------------------------------------------------------------------------------\r
+memset   PROC    USES    rdi\r
+    mov     rax, rcx    \r
+    cmp     r8, 0                      ; if Size == 0, do nothing\r
+    je      @SetDone\r
+    mov     rax, rdx                   ; rdx <-> r8\r
+    mov     rdx, r8                    ; rdx <- Length\r
+    mov     r8, rax                    ; r8  <- Value\r
+    mov     ah, al\r
+    DB      48h, 0fh, 6eh, 0c0h         ; movd mm0, rax\r
+    mov     r8, rcx\r
+    mov     rdi, r8                     ; rdi <- Buffer\r
+    mov     rcx, rdx\r
+    and     edx, 7\r
+    shr     rcx, 3\r
+    jz      @SetBytes\r
+    DB      0fh, 70h, 0C0h, 00h         ; pshufw mm0, mm0, 0h\r
+@@:\r
+    DB      48h, 0fh, 7eh, 07h          ; movd [rdi], mm0\r
+    add     rdi, 8\r
+    loop    @B\r
+@SetBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+    mov     rax, r8\r
+@SetDone:\r
+    ret\r
+memset   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm
new file mode 100644 (file)
index 0000000..0370c9b
--- /dev/null
@@ -0,0 +1,74 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   memset function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; memset (\r
+;   OUT     VOID                      *Buffer,    --> rcx\r
+;   IN      UINT8                     Value,      --> rdx\r
+;   IN      UINTN                     Length      --> r8\r
+;   );\r
+;------------------------------------------------------------------------------\r
+memset   PROC    USES    rdi\r
+    mov     rax, rcx    \r
+    cmp     r8, 0                       ; if Size == 0, do nothing\r
+    je      @SetDone                    \r
+    mov     rax, rdx                    ; rdx <-> r8\r
+    mov     rdx, r8                     ; rdx <- Length\r
+    mov     r8, rax                     ; r8  <- Value\r
+    \r
+    mov     rdi, rcx                    ; rdi <- Buffer\r
+    mov     al, r8b                     ; al <- Value\r
+    mov     r9, rdi                     ; r9 <- Buffer as return value\r
+    xor     rcx, rcx\r
+    sub     rcx, rdi\r
+    and     rcx, 15                     ; rcx + rdi aligns on 16-byte boundary\r
+    jz      @F\r
+    cmp     rcx, rdx\r
+    cmova   rcx, rdx\r
+    sub     rdx, rcx\r
+    rep     stosb\r
+@@:\r
+    mov     rcx, rdx\r
+    and     rdx, 15\r
+    shr     rcx, 4\r
+    jz      @SetBytes\r
+    mov     ah, al                      ; ax <- Value repeats twice\r
+    movd    xmm0, eax                   ; xmm0[0..16] <- Value repeats twice\r
+    pshuflw xmm0, xmm0, 0               ; xmm0[0..63] <- Value repeats 8 times\r
+    movlhps xmm0, xmm0                  ; xmm0 <- Value repeats 16 times\r
+@@:\r
+    movdqa  [rdi], xmm0                 ; rdi should be 16-byte aligned\r
+    add     rdi, 16\r
+    loop    @B\r
+@SetBytes:\r
+    mov     ecx, edx                    ; high 32 bits of rcx are always zero\r
+    rep     stosb\r
+    mov     rax, r9                     ; rax <- Return value\r
+@SetDone:\r
+    ret\r
+memset   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c
new file mode 100644 (file)
index 0000000..20f7d6a
--- /dev/null
@@ -0,0 +1,122 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  CustomizedDecompress.c\r
+\r
+Abstract:\r
+\r
+  Implementation file for Customized decompression routine\r
+  \r
+--*/\r
+#include "TianoCommon.h"\r
+#include "CustomizedDecompress.h"\r
+\r
+EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL  mCustomizedDecompress = {\r
+  CustomizedGetInfo,\r
+  CustomizedDecompress\r
+};\r
+\r
+EFI_STATUS\r
+InstallCustomizedDecompress (\r
+  EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install customeized decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This                  - The protocol that needs to be installed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Always success\r
+\r
+--*/\r
+{\r
+  *This = &mCustomizedDecompress;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CustomizedGetInfo (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL     *This,\r
+  IN      VOID                              *Source,\r
+  IN      UINT32                            SrcSize,\r
+  OUT     UINT32                            *DstSize,\r
+  OUT     UINT32                            *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+  This        - The EFI customized decompress protocol\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - Not supported\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CustomizedDecompress (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL     *This,\r
+  IN      VOID                              *Source,\r
+  IN      UINT32                            SrcSize,\r
+  IN OUT  VOID                              *Destination,\r
+  IN      UINT32                            DstSize,\r
+  IN OUT  VOID                              *Scratch,\r
+  IN      UINT32                            ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - Not supported\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h
new file mode 100644 (file)
index 0000000..047c3d3
--- /dev/null
@@ -0,0 +1,113 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  CustomizedDecompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for Customized decompression routine\r
+  \r
+--*/\r
+#ifndef _CUSTOMIZED_DECOMPRESS_LIB_H_\r
+#define _CUSTOMIZED_DECOMPRESS_LIB_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (CustomizedDecompress)\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CustomizedGetInfo (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL     *This,\r
+  IN      VOID                              *Source,\r
+  IN      UINT32                            SrcSize,\r
+  OUT     UINT32                            *DstSize,\r
+  OUT     UINT32                            *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+  This        - The EFI customized decompress protocol\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - Not supported\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CustomizedDecompress (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL     *This,\r
+  IN      VOID                              *Source,\r
+  IN      UINT32                            SrcSize,\r
+  IN OUT  VOID                              *Destination,\r
+  IN      UINT32                            DstSize,\r
+  IN OUT  VOID                              *Scratch,\r
+  IN      UINT32                            ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - Not supported\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+InstallCustomizedDecompress (\r
+  EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install customeized decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This                  - The protocol that needs to be installed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Always success\r
+\r
+--*/\r
+;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf
new file mode 100644 (file)
index 0000000..151a473
--- /dev/null
@@ -0,0 +1,39 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    CustomizedDecompress.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the Customized Decompress library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME         = CustomizedDecompress\r
+COMPONENT_TYPE    = LIBRARY\r
+\r
+[sources.common]\r
+  CustomizedDecompress.c\r
+  CustomizedDecompress.h\r
+\r
+[includes.common]\r
+  .\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
new file mode 100644 (file)
index 0000000..a968f40
--- /dev/null
@@ -0,0 +1,172 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Debug.c\r
+\r
+Abstract:\r
+\r
+  Support for Debug primatives. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiPrintLib.h"\r
+#include "EfiStatusCode.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+#include EFI_PROTOCOL_DEFINITION (DEBUGMASK)\r
+\r
+//\r
+// You would think you should divid by sizeof (UINT64), but EBC does not like\r
+// that!\r
+//\r
+#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)\r
+\r
+VOID\r
+EfiDebugAssert (\r
+  IN CHAR8    *FileName,\r
+  IN INTN     LineNumber,\r
+  IN CHAR8    *Description\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded BREAKPOINT().\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  FileName    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT().\r
+\r
+  Description - Descritption, usally the assertion,\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+\r
+  EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);\r
+\r
+  EfiLibReportStatusCode (\r
+    (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
+    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
+    0,\r
+    &gEfiCallerIdGuid,\r
+    (EFI_STATUS_CODE_DATA *) Buffer\r
+    );\r
+\r
+  //\r
+  // Put break point in module that contained the error.\r
+  //\r
+  EFI_BREAKPOINT ();\r
+}\r
+\r
+VOID\r
+EfiDebugVPrint (\r
+  IN  UINTN   ErrorLevel,\r
+  IN  CHAR8   *Format,\r
+  IN  VA_LIST Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  Marker     - VarArgs\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINTN   ImageDebugMask;\r
+\r
+  //\r
+  // Check driver debug mask value and global mask\r
+  //\r
+  if (gDebugMaskInterface != NULL) {\r
+    gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);\r
+    if (!(ErrorLevel & ImageDebugMask)) {\r
+      return ;\r
+    }\r
+  } else if (!(gErrorLevel & ErrorLevel)) {\r
+    return ;\r
+  }\r
+\r
+  EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);\r
+\r
+  EfiLibReportStatusCode (\r
+    EFI_DEBUG_CODE,\r
+    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r
+    (UINT32) ErrorLevel,\r
+    &gEfiCallerIdGuid,\r
+    (EFI_STATUS_CODE_DATA *) Buffer\r
+    );\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+EfiDebugPrint (\r
+  IN  UINTN ErrorLevel,\r
+  IN  CHAR8 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Wrapper for EfiDebugVPrint ()\r
+  \r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  ...        - Print arguments.\r
+\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  EfiDebugVPrint (ErrorLevel, Format, Marker);\r
+  VA_END (Marker);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
new file mode 100644 (file)
index 0000000..1a827c1
--- /dev/null
@@ -0,0 +1,607 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePath.c\r
+\r
+Abstract:\r
+\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
+  OUT UINTN                         *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function retrieves the next device path instance from a device path data structure.\r
+\r
+Arguments:\r
+  DevicePath           - A pointer to a device path data structure.\r
+\r
+  Size                 - A pointer to the size of a device path instance in bytes.\r
+\r
+Returns:\r
+\r
+  This function returns a pointer to the current device path instance.\r
+  In addition, it returns the size in bytes of the current device path instance in Size,\r
+  and a pointer to the next device path instance in DevicePath.\r
+  If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ReturnValue;\r
+  UINT8                     Temp;\r
+\r
+  if (*DevicePath == NULL) {\r
+    if (Size != NULL) {\r
+      *Size = 0;\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Find the end of the device path instance\r
+  //\r
+  DevPath = *DevicePath;\r
+  while (!IsDevicePathEndType (DevPath)) {\r
+    DevPath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  //\r
+  // Compute the size of the device path instance\r
+  //\r
+  if (Size != NULL) {\r
+    *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+  }\r
+\r
+  //\r
+  // Make a copy and return the device path instance\r
+  //\r
+  Temp              = DevPath->SubType;\r
+  DevPath->SubType  = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
+  ReturnValue       = EfiDuplicateDevicePath (*DevicePath);\r
+  DevPath->SubType  = Temp;\r
+\r
+  //\r
+  // If DevPath is the end of an entire device path, then another instance\r
+  // does not follow, so *DevicePath is set to NULL.\r
+  //\r
+  if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {\r
+    *DevicePath = NULL;\r
+  } else {\r
+    *DevicePath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+BOOLEAN\r
+EfiIsDevicePathMultiInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE is this is a multi instance device path.\r
+\r
+Arguments:\r
+  DevicePath  - A pointer to a device path data structure.\r
+\r
+\r
+Returns:\r
+  TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi\r
+  instance.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
+\r
+  if (DevicePath == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  Node = DevicePath;\r
+  while (!EfiIsDevicePathEnd (Node)) {\r
+    if (EfiIsDevicePathEndInstance (Node)) {\r
+      return TRUE;\r
+    }\r
+\r
+    Node = EfiNextDevicePathNode (Node);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+UINTN\r
+EfiDevicePathSize (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculate the space size of a device path.\r
+\r
+Arguments:\r
+\r
+  DevicePath  - A specified device path\r
+\r
+Returns:\r
+\r
+  The size.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  if (DevicePath == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!EfiIsDevicePathEnd (DevicePath)) {\r
+    DevicePath = EfiNextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Compute the size and add back in the size of the end device path structure\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiDevicePathFromHandle (\r
+  IN EFI_HANDLE  Handle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get the device path protocol interface installed on a specified handle.\r
+\r
+Arguments:\r
+\r
+  Handle  - a specified handle\r
+\r
+Returns:\r
+\r
+  The device path protocol interface installed on that handle.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  DevicePath = NULL;\r
+  gBS->HandleProtocol (\r
+        Handle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        (VOID *) &DevicePath\r
+        );\r
+  return DevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiDuplicateDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Duplicate a device path structure.\r
+\r
+Arguments:\r
+\r
+  DevicePath  - The device path to duplicated.\r
+\r
+Returns:\r
+\r
+  The duplicated device path.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     Size;\r
+\r
+  if (DevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Compute the size\r
+  //\r
+  Size = EfiDevicePathSize (DevicePath);\r
+  if (Size == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Allocate space for duplicate device path\r
+  //\r
+  NewDevicePath = EfiLibAllocateCopyPool (Size, DevicePath);\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiAppendDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a Src1 and Src2 together.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  A pointer to the new device path is returned.\r
+  NULL is returned if space for the new device path could not be allocated from pool.\r
+  It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.\r
+\r
+--*/\r
+{\r
+  UINTN                     Size;\r
+  UINTN                     Size1;\r
+  UINTN                     Size2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath;\r
+\r
+  //\r
+  // If there's only 1 path, just duplicate it\r
+  //\r
+  if (!Src1) {\r
+    ASSERT (!IsDevicePathUnpacked (Src2));\r
+    return EfiDuplicateDevicePath (Src2);\r
+  }\r
+\r
+  if (!Src2) {\r
+    ASSERT (!IsDevicePathUnpacked (Src1));\r
+    return EfiDuplicateDevicePath (Src1);\r
+  }\r
+\r
+  //\r
+  // Allocate space for the combined device path. It only has one end node of\r
+  // length EFI_DEVICE_PATH_PROTOCOL\r
+  //\r
+  Size1         = EfiDevicePathSize (Src1);\r
+  Size2         = EfiDevicePathSize (Src2);\r
+  Size          = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+\r
+  NewDevicePath = EfiLibAllocateCopyPool (Size, Src1);\r
+\r
+  if (NewDevicePath != NULL) {\r
+\r
+    //\r
+    // Over write Src1 EndNode and do the copy\r
+    //\r
+    SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
+    EfiCopyMem (SecondDevicePath, Src2, Size2);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiAppendDevicePathNode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Node\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a device path node to the end of another device path.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Node - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  This function returns a pointer to the new device path.\r
+  If there is not enough temporary pool memory available to complete this function,\r
+  then NULL is returned.\r
+\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Temp;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     NodeLength;\r
+\r
+  //\r
+  // Build a Node that has a terminator on it\r
+  //\r
+  NodeLength  = DevicePathNodeLength (Node);\r
+\r
+  Temp        = EfiLibAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node);\r
+  if (Temp == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Add and end device path node to convert Node to device path\r
+  //\r
+  NextNode = NextDevicePathNode (Temp);\r
+  SetDevicePathEndNode (NextNode);\r
+\r
+  //\r
+  // Append device paths\r
+  //\r
+  NewDevicePath = EfiAppendDevicePath (Src1, Temp);\r
+  gBS->FreePool (Temp);\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiFileDevicePath (\r
+  IN EFI_HANDLE               Device  OPTIONAL,\r
+  IN CHAR16                   *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function allocates a device path for a file and appends it to an existiong\r
+  device path.\r
+\r
+Arguments:\r
+  Device     - A pointer to a device handle.\r
+\r
+  FileName   - A pointer to a Null-terminated Unicodestring.\r
+\r
+Returns:\r
+  A device path contain the file name.\r
+\r
+--*/\r
+{\r
+  UINTN                     Size;\r
+  FILEPATH_DEVICE_PATH      *FilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Eop;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  for (Size = 0; FileName[Size] != 0; Size++)\r
+    ;\r
+  Size        = (Size + 1) * 2;\r
+\r
+  FilePath    = EfiLibAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+\r
+  DevicePath  = NULL;\r
+\r
+  if (FilePath != NULL) {\r
+\r
+    //\r
+    // Build a file path\r
+    //\r
+    FilePath->Header.Type     = MEDIA_DEVICE_PATH;\r
+    FilePath->Header.SubType  = MEDIA_FILEPATH_DP;\r
+    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
+    EfiCopyMem (FilePath->PathName, FileName, Size);\r
+    Eop = NextDevicePathNode (&FilePath->Header);\r
+    SetDevicePathEndNode (Eop);\r
+\r
+    //\r
+    // Append file path to device's device path\r
+    //\r
+\r
+    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;\r
+    if (Device != NULL) {\r
+      DevicePath = EfiAppendDevicePath (\r
+                    EfiDevicePathFromHandle (Device),\r
+                    DevicePath\r
+                    );\r
+\r
+      gBS->FreePool (FilePath);\r
+    }\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EfiAppendDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Append a device path instance to another.\r
+\r
+Arguments:\r
+\r
+  Src       - The device path instance to be appended with.\r
+  Instance  - The device path instance appending the other.\r
+\r
+Returns:\r
+\r
+  The contaction of these two.\r
+\r
+--*/\r
+{\r
+  UINT8                     *Ptr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  UINTN                     SrcSize;\r
+  UINTN                     InstanceSize;\r
+\r
+  if (Src == NULL) {\r
+    return EfiDuplicateDevicePath (Instance);\r
+  }\r
+\r
+  SrcSize       = EfiDevicePathSize (Src);\r
+  InstanceSize  = EfiDevicePathSize (Instance);\r
+\r
+  Ptr           = EfiLibAllocateCopyPool (SrcSize + InstanceSize, Src);\r
+  if (Ptr != NULL) {\r
+\r
+    DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+\r
+    while (!IsDevicePathEnd (DevPath)) {\r
+      DevPath = NextDevicePathNode (DevPath);\r
+    }\r
+    //\r
+    // Convert the End to an End Instance, since we are\r
+    //  appending another instacne after this one its a good\r
+    //  idea.\r
+    //\r
+    DevPath->SubType  = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
+\r
+    DevPath           = NextDevicePathNode (DevPath);\r
+    EfiCopyMem (DevPath, Instance, InstanceSize);\r
+  }\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+EfiInitializeFwVolDevicepathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,\r
+  IN EFI_GUID                               *NameGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a Firmware Volume (FV) Media Device Path node.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability.\r
+\r
+Arguments:\r
+\r
+  FvDevicePathNode  - Pointer to a FV device path node to initialize\r
+  NameGuid          - FV file name to use in FvDevicePathNode\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000)\r
+  //\r
+  // Use old Device Path\r
+  //\r
+  FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+\r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  FvDevicePathNode->Piwg.Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Piwg.Header.SubType  = MEDIA_VENDOR_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+\r
+  //\r
+  // Add the GUID for generic PIWG device paths\r
+  //\r
+  EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID));\r
+\r
+  //\r
+  // Add in the FW Vol File Path PIWG defined inforation\r
+  //\r
+  FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
+\r
+#endif\r
+  EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID));\r
+}\r
+\r
+EFI_GUID *\r
+EFIAPI\r
+EfiGetNameGuidFromFwVolDevicePathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH   *FvDevicePathNode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability. The return value to this\r
+  function points to a location in FvDevicePathNode and it does not allocate\r
+  new memory for the GUID pointer that is returned.\r
+\r
+Arguments:\r
+\r
+  FvDevicePathNode  - Pointer to FV device path to check\r
+\r
+Returns:\r
+\r
+  NULL              - FvDevicePathNode is not valid.\r
+  Other             - FvDevicePathNode is valid and pointer to NameGuid was returned.\r
+\r
+--*/\r
+{\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000)\r
+  //\r
+  // Use old Device Path\r
+  //\r
+  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
+    return &FvDevicePathNode->NameGuid;\r
+  }\r
+\r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) {\r
+    if (EfiCompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
+      if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
+        return &FvDevicePathNode->NameGuid;\r
+      }\r
+    }\r
+  }\r
+#endif\r
+  return NULL;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c
new file mode 100644 (file)
index 0000000..ecce5f0
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DxeDriverLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_STATUS\r
+DxeInitializeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - Standard EFI Image entry parameter\r
+  \r
+  SystemTable     - Standard EFI Image entry parameter\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiInitializeDriverLib (ImageHandle, SystemTable);\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c
new file mode 100644 (file)
index 0000000..bfe0349
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PerformancePrimitives.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance library\r
+\r
+--*/\r
+\r
+#include "Tiano.h"  // for ASSERT macro\r
+#include "TianoCommon.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set TimerValue to 0, which is not expected to be run.\r
+\r
+Arguments:\r
+\r
+  TimerValue  - Timer value for output\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Should not be reached.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Should not be used for EBC, so assert.\r
+  //\r
+  *TimerValue = 0;\r
+  ASSERT (FALSE);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
new file mode 100644 (file)
index 0000000..f1af8cc
--- /dev/null
@@ -0,0 +1,429 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDriverLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+//\r
+// Global Interface for Debug Mask Protocol\r
+//\r
+EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL;\r
+\r
+EFI_STATUS\r
+EfiInitializeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - Standard EFI Image entry parameter\r
+  \r
+  SystemTable     - Standard EFI Image entry parameter\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  gST = SystemTable;\r
+\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = gST->BootServices;\r
+  gRT = gST->RuntimeServices;\r
+\r
+  ASSERT (gBS != NULL);\r
+  ASSERT (gRT != NULL);\r
+\r
+  //\r
+  // Get driver debug mask protocol interface\r
+  //\r
+#ifdef EFI_DEBUG\r
+  gBS->HandleProtocol (\r
+        ImageHandle,\r
+        &gEfiDebugMaskProtocolGuid,\r
+        (VOID *) &gDebugMaskInterface\r
+        );\r
+#endif\r
+  //\r
+  // Should be at EFI_D_INFO, but lets us know things are running\r
+  //\r
+  DEBUG ((EFI_D_INFO, "EfiInitializeDriverLib: Started\n"));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+EfiLibCompareLanguage (\r
+  IN  CHAR8  *Language1,\r
+  IN  CHAR8  *Language2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compare whether two names of languages are identical.\r
+\r
+Arguments:\r
+\r
+  Language1 - Name of language 1\r
+  Language2 - Name of language 2\r
+\r
+Returns:\r
+\r
+  TRUE      - same\r
+  FALSE     - not same\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {\r
+    if (Language1[Index] != Language2[Index]) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  if (((Language1[Index] == 0) && (Language2[Index] == 0))   || \r
+         ((Language1[Index] == 0) && (Language2[Index] != ';')) ||\r
+         ((Language1[Index] == ';') && (Language2[Index] != 0)) ||\r
+         ((Language1[Index] == ';') && (Language2[Index] != ';'))) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+#else\r
+  for (Index = 0; Index < 3; Index++) {\r
+    if (Language1[Index] != Language2[Index]) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return TRUE;\r
+#endif\r
+}\r
+\r
+STATIC\r
+CHAR8 *\r
+NextSupportedLanguage (\r
+  IN CHAR8                *Languages\r
+  )\r
+{\r
+#ifdef LANGUAGE_RFC_3066   // LANGUAGE_RFC_3066\r
+  for (; (*Languages != 0) && (*Languages != ';'); Languages++)\r
+    ;\r
+  return Languages;\r
+#else                      // LANGUAGE_ISO_639_2\r
+  return (Languages + 3);\r
+#endif\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibLookupUnicodeString (\r
+  IN  CHAR8                     *Language,\r
+  IN  CHAR8                     *SupportedLanguages,\r
+  IN  EFI_UNICODE_STRING_TABLE  *UnicodeStringTable,\r
+  OUT CHAR16                    **UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Translate a unicode string to a specified language if supported.\r
+  \r
+Arguments:\r
+\r
+  Language              - The name of language to translate to\r
+  SupportedLanguages    - Supported languages set\r
+  UnicodeStringTable    - Pointer of one item in translation dictionary\r
+  UnicodeString         - The translated string\r
+\r
+Returns: \r
+\r
+  EFI_INVALID_PARAMETER - Invalid parameter\r
+  EFI_UNSUPPORTED       - System not supported this language or this string translation\r
+  EFI_SUCCESS           - String successfully translated\r
+\r
+--*/\r
+{\r
+  //\r
+  // Make sure the parameters are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, or the Unicode String Table is empty, then the\r
+  // Unicode String specified by Language is not supported by this Unicode String Table\r
+  //\r
+  if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is in the set of Supported Languages\r
+  //\r
+  while (*SupportedLanguages != 0) {\r
+    if (EfiLibCompareLanguage (Language, SupportedLanguages)) {\r
+\r
+      //\r
+      // Search the Unicode String Table for the matching Language specifier\r
+      //\r
+      while (UnicodeStringTable->Language != NULL) {\r
+        if (EfiLibCompareLanguage (Language, UnicodeStringTable->Language)) {\r
+\r
+          //\r
+          // A matching string was found, so return it\r
+          //\r
+          *UnicodeString = UnicodeStringTable->UnicodeString;\r
+          return EFI_SUCCESS;\r
+        }\r
+\r
+        UnicodeStringTable++;\r
+      }\r
+\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    SupportedLanguages = NextSupportedLanguage(SupportedLanguages);\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibAddUnicodeString (\r
+  IN      CHAR8                     *Language,\r
+  IN      CHAR8                     *SupportedLanguages,\r
+  IN OUT  EFI_UNICODE_STRING_TABLE  **UnicodeStringTable,\r
+  IN      CHAR16                    *UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add an translation to the dictionary if this language if supported.\r
+  \r
+Arguments:\r
+\r
+  Language              - The name of language to translate to\r
+  SupportedLanguages    - Supported languages set\r
+  UnicodeStringTable    - Translation dictionary\r
+  UnicodeString         - The corresponding string for the language to be translated to\r
+\r
+Returns: \r
+\r
+  EFI_INVALID_PARAMETER - Invalid parameter\r
+  EFI_UNSUPPORTED       - System not supported this language\r
+  EFI_ALREADY_STARTED   - Already has a translation item of this language\r
+  EFI_OUT_OF_RESOURCES  - No enough buffer to be allocated\r
+  EFI_SUCCESS           - String successfully translated\r
+\r
+--*/\r
+{\r
+  UINTN                     NumberOfEntries;\r
+  EFI_UNICODE_STRING_TABLE  *OldUnicodeStringTable;\r
+  EFI_UNICODE_STRING_TABLE  *NewUnicodeStringTable;\r
+  UINTN                     UnicodeStringLength;\r
+\r
+  //\r
+  // Make sure the parameter are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, then a Unicode String can not be added\r
+  //\r
+  if (SupportedLanguages == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // If the Unicode String is empty, then a Unicode String can not be added\r
+  //\r
+  if (UnicodeString[0] == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is a member of SupportedLanguages\r
+  //\r
+  while (*SupportedLanguages != 0) {\r
+    if (EfiLibCompareLanguage (Language, SupportedLanguages)) {\r
+\r
+      //\r
+      // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
+      //\r
+      NumberOfEntries = 0;\r
+      if (*UnicodeStringTable != NULL) {\r
+        OldUnicodeStringTable = *UnicodeStringTable;\r
+        while (OldUnicodeStringTable->Language != NULL) {\r
+          if (EfiLibCompareLanguage (Language, OldUnicodeStringTable->Language)) {\r
+            return EFI_ALREADY_STARTED;\r
+          }\r
+\r
+          OldUnicodeStringTable++;\r
+          NumberOfEntries++;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Allocate space for a new Unicode String Table.  It must hold the current number of\r
+      // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
+      // marker\r
+      //\r
+      NewUnicodeStringTable = EfiLibAllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
+      if (NewUnicodeStringTable == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // If the current Unicode String Table contains any entries, then copy them to the\r
+      // newly allocated Unicode String Table.\r
+      //\r
+      if (*UnicodeStringTable != NULL) {\r
+        EfiCopyMem (\r
+          NewUnicodeStringTable,\r
+          *UnicodeStringTable,\r
+          NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
+          );\r
+      }\r
+\r
+      //\r
+      // Allocate space for a copy of the Language specifier\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrLen(Language) + 1, Language);\r
+      if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
+        gBS->FreePool (NewUnicodeStringTable);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // Compute the length of the Unicode String\r
+      //\r
+      for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)\r
+        ;\r
+\r
+      //\r
+      // Allocate space for a copy of the Unicode String\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries].UnicodeString = EfiLibAllocateCopyPool (\r
+                                                              (UnicodeStringLength + 1) * sizeof (CHAR16),\r
+                                                              UnicodeString\r
+                                                              );\r
+      if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
+        gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
+        gBS->FreePool (NewUnicodeStringTable);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // Mark the end of the Unicode String Table\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries + 1].Language       = NULL;\r
+      NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString  = NULL;\r
+\r
+      //\r
+      // Free the old Unicode String Table\r
+      //\r
+      if (*UnicodeStringTable != NULL) {\r
+        gBS->FreePool (*UnicodeStringTable);\r
+      }\r
+\r
+      //\r
+      // Point UnicodeStringTable at the newly allocated Unicode String Table\r
+      //\r
+      *UnicodeStringTable = NewUnicodeStringTable;\r
+\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    SupportedLanguages = NextSupportedLanguage(SupportedLanguages);\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibFreeUnicodeStringTable (\r
+  IN OUT  EFI_UNICODE_STRING_TABLE  *UnicodeStringTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free a string table.\r
+\r
+Arguments:\r
+\r
+  UnicodeStringTable      - The string table to be freed.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS       - The table successfully freed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  //\r
+  // If the Unicode String Table is NULL, then it is already freed\r
+  //\r
+  if (UnicodeStringTable == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Loop through the Unicode String Table until we reach the end of table marker\r
+  //\r
+  for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {\r
+\r
+    //\r
+    // Free the Language string from the Unicode String Table\r
+    //\r
+    gBS->FreePool (UnicodeStringTable[Index].Language);\r
+\r
+    //\r
+    // Free the Unicode String from the Unicode String Table\r
+    //\r
+    if (UnicodeStringTable[Index].UnicodeString != NULL) {\r
+      gBS->FreePool (UnicodeStringTable[Index].UnicodeString);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Free the Unicode String Table itself\r
+  //\r
+  gBS->FreePool (UnicodeStringTable);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf
new file mode 100644 (file)
index 0000000..3242574
--- /dev/null
@@ -0,0 +1,88 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#   EfiDriverLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the EFI driver library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EfiDriverLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  Debug.c\r
+  DevicePath.c\r
+  EfiDriverLib.c\r
+  DxeDriverLib.c\r
+  EfiGetConfigTable.c\r
+  EfiDriverModelLib.c\r
+  Event.c\r
+  Handle.c\r
+  LibGlobalSt.c\r
+  LibGlobalDs.c\r
+  LibGlobalErrorLevel.c\r
+  Lock.c\r
+  EfiLibAllocate.c\r
+  Perf.c\r
+  ReportStatusCode.c\r
+  GetImage.c\r
+\r
+  ..\hob\hob.c\r
+\r
+[sources.ia32]\r
+  ia32\PerformancePrimitives.c\r
+\r
+[sources.x64]\r
+  x64\PerformancePrimitives.c\r
+\r
+[sources.ipf]\r
+  ipf\PerformancePrimitives.s\r
+\r
+[sources.ebc]\r
+  Ebc\PerformancePrimitives.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkGuidLib\r
+  EdkProtocolLib\r
+  EdkFrameworkProtocolLib\r
+  EfiGuidLib\r
+  EfiProtocolLib\r
+  ArchProtocolLib\r
+  EfiCommonLib\r
+\r
+[libraries.ia32]\r
+  CpuIA32Lib\r
+\r
+[libraries.x64]\r
+  CpuIA32Lib\r
+\r
+[libraries.ipf]\r
+  CpuIA64Lib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c
new file mode 100644 (file)
index 0000000..5c2b47b
--- /dev/null
@@ -0,0 +1,289 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDriverModelLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_STATUS\r
+EfiLibInstallDriverBinding (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN EFI_SYSTEM_TABLE             *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,\r
+  IN EFI_HANDLE                   DriverBindingHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+{\r
+  EfiInitializeDriverLib (ImageHandle, SystemTable);\r
+\r
+  DriverBinding->ImageHandle          = ImageHandle;\r
+\r
+  DriverBinding->DriverBindingHandle  = DriverBindingHandle;\r
+\r
+  return gBS->InstallProtocolInterface (\r
+                &DriverBinding->DriverBindingHandle,\r
+                &gEfiDriverBindingProtocolGuid,\r
+                EFI_NATIVE_INTERFACE,\r
+                DriverBinding\r
+                );\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibInstallAllDriverProtocols (\r
+  IN EFI_HANDLE                         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                   * SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL        * DriverBinding,\r
+  IN EFI_HANDLE                         DriverBindingHandle,\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL       * ComponentName, OPTIONAL\r
+#else\r
+  IN EFI_COMPONENT_NAME_PROTOCOL        * ComponentName, OPTIONAL\r
+#endif\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL  * DriverConfiguration, OPTIONAL\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    * DriverDiagnostics OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+  ComponentName       - A Component Name Protocol instance that this driver is producing\r
+\r
+  DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
+  \r
+  DriverDiagnostics   - A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (ComponentName != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+                    &gEfiComponentName2ProtocolGuid,\r
+#else\r
+                    &gEfiComponentNameProtocolGuid,\r
+#endif\r
+                    EFI_NATIVE_INTERFACE,\r
+                    ComponentName\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (DriverConfiguration != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+                    &gEfiDriverConfigurationProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    DriverConfiguration\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (DriverDiagnostics != NULL) {\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &DriverBinding->DriverBindingHandle,\r
+                    &gEfiDriverDiagnosticsProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    DriverDiagnostics\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibTestManagedDevice (\r
+  IN EFI_HANDLE       ControllerHandle,\r
+  IN EFI_HANDLE       DriverBindingHandle,\r
+  IN EFI_GUID         *ManagedProtocolGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test to see if the controller is managed by a specific driver.\r
+\r
+Arguments:\r
+\r
+  ControllerHandle          - Handle for controller to test\r
+\r
+  DriverBindingHandle       - Driver binding handle for controller\r
+\r
+  ManagedProtocolGuid       - The protocol guid the driver opens on controller\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - The controller is managed by the driver\r
+\r
+  EFI_UNSUPPORTED - The controller is not managed by the driver\r
+\r
+--*/\r
+{\r
+  EFI_STATUS     Status;\r
+  VOID           *ManagedInterface;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  ManagedProtocolGuid,\r
+                  &ManagedInterface,\r
+                  DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+           ControllerHandle,\r
+           ManagedProtocolGuid,\r
+           DriverBindingHandle,\r
+           ControllerHandle\r
+           );\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibTestChildHandle (\r
+  IN EFI_HANDLE       ControllerHandle,\r
+  IN EFI_HANDLE       ChildHandle,\r
+  IN EFI_GUID         *ConsumedGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test to see if the child handle is the child of the controller\r
+\r
+Arguments:\r
+\r
+  ControllerHandle          - Handle for controller (parent)\r
+\r
+  ChildHandle               - Child handle to test\r
+\r
+  ConsumsedGuid             - Protocol guid consumed by child from controller\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - The child handle is the child of the controller\r
+\r
+  EFI_UNSUPPORTED - The child handle is not the child of the controller\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY   *OpenInfoBuffer;\r
+  UINTN                                 EntryCount;\r
+  UINTN                                 Index;\r
+\r
+  //\r
+  // Retrieve the list of agents that are consuming one of the protocols\r
+  // on ControllerHandle that the children consume\r
+  //\r
+  Status = gBS->OpenProtocolInformation (\r
+                  ControllerHandle,\r
+                  ConsumedGuid,\r
+                  &OpenInfoBuffer,\r
+                  &EntryCount\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // See if one of the agents is ChildHandle\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  for (Index = 0; Index < EntryCount; Index++) {\r
+    if (OpenInfoBuffer[Index].ControllerHandle == ChildHandle &&\r
+        OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {\r
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+  gBS->FreePool (OpenInfoBuffer);\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c
new file mode 100644 (file)
index 0000000..7fdbb8d
--- /dev/null
@@ -0,0 +1,61 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiGetConfigTable.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  OUT VOID **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get table from configuration table by name\r
+\r
+Arguments:\r
+\r
+  TableGuid       - Table name to search\r
+  \r
+  Table           - Pointer to the table caller wants\r
+\r
+Returns: \r
+\r
+  EFI_NOT_FOUND   - Not found the table\r
+  \r
+  EFI_SUCCESS     - Found the table\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  *Table = NULL;\r
+  for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
+    if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+      *Table = gST->ConfigurationTable[Index].VendorTable;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c
new file mode 100644 (file)
index 0000000..6558e3d
--- /dev/null
@@ -0,0 +1,233 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiLibAllocate.c\r
+\r
+Abstract:\r
+\r
+  Support routines for memory allocation routines for use with drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+VOID *\r
+EfiLibAllocatePool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
+  return Memory;\r
+}\r
+\r
+VOID *\r
+EfiLibAllocateRuntimePool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate RuntimeServicesData pool.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);\r
+  return Memory;\r
+}\r
+\r
+VOID *\r
+EfiLibAllocateZeroPool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool and zero it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = EfiLibAllocatePool (AllocationSize);\r
+  if (Memory != NULL) {\r
+    gBS->SetMem (Memory, AllocationSize, 0);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+VOID *\r
+EfiLibAllocateRuntimeZeroPool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate RuntimeServicesData pool and zero it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = EfiLibAllocateRuntimePool (AllocationSize);\r
+  if (Memory != NULL) {\r
+    gBS->SetMem (Memory, AllocationSize, 0);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+VOID *\r
+EfiLibAllocateCopyPool (\r
+  IN  UINTN   AllocationSize,\r
+  IN  VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool and use a buffer provided by \r
+  caller to fill it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+  \r
+  Buffer          - Buffer that will be filled into the buffer allocated\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
+  if (Memory != NULL) {\r
+    gBS->CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+VOID *\r
+EfiLibAllocateRuntimeCopyPool (\r
+  IN  UINTN            AllocationSize,\r
+  IN  VOID             *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate RuntimeServicesData pool and use a buffer provided by \r
+  caller to fill it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+  \r
+  Buffer          - Buffer that will be filled into the buffer allocated\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);\r
+  if (Memory != NULL) {\r
+    gBS->CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+\r
+VOID\r
+EfiLibSafeFreePool (\r
+  IN  VOID             *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free pool safely (without setting back Buffer to NULL).\r
+\r
+Arguments:\r
+  \r
+  Buffer          - The allocated pool entry to free\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  if (Buffer != NULL) {\r
+    gBS->FreePool (Buffer);\r
+  }\r
+}
\ 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 (file)
index 0000000..3cb668e
--- /dev/null
@@ -0,0 +1,371 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Event.c\r
+\r
+Abstract:\r
+\r
+  Support for Event lib fucntions.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_EVENT\r
+EfiLibCreateProtocolNotifyEvent (\r
+  IN EFI_GUID             *ProtocolGuid,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext,\r
+  OUT VOID                **Registration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a protocol notification event and return it.\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid    - Protocol to register notification event on.\r
+\r
+  NotifyTpl       - Maximum TPL to single the NotifyFunction.\r
+\r
+  NotifyFunction  - EFI notification routine.\r
+\r
+  NotifyContext   - Context passed into Event when it is created.\r
+\r
+  Registration    - Registration key returned from RegisterProtocolNotify().\r
+\r
+Returns:\r
+\r
+  The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
+  is added to the system.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;\r
+\r
+  //\r
+  // Create the event\r
+  //\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &Event\r
+                  );\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Register for protocol notifactions on this event\r
+  //\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  ProtocolGuid,\r
+                  Event,\r
+                  Registration\r
+                  );\r
+\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Kick the event so we will perform an initial pass of\r
+  // current installed drivers\r
+  //\r
+\r
+  gBS->SignalEvent (Event);\r
+  return Event;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibNamedEventListen (\r
+  IN EFI_GUID             * Name,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Listenes to signals on the name.\r
+  EfiLibNamedEventSignal() signals the event.\r
+\r
+  NOTE: For now, the named listening/signalling is implemented\r
+  on a protocol interface being installed and uninstalled.\r
+  In the future, this maybe implemented based on a dedicated mechanism.\r
+\r
+Arguments:\r
+  Name            - Name to register the listener on.\r
+  NotifyTpl       - Maximum TPL to singnal the NotifyFunction.\r
+  NotifyFunction  - The listener routine.\r
+  NotifyContext   - Context passed into the listener routine.\r
+\r
+Returns:\r
+  EFI_SUCCESS if successful.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;\r
+  VOID        *RegistrationLocal;\r
+\r
+  //\r
+  // Create event\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &Event\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  Status = gBS->RegisterProtocolNotify (\r
+                  Name,\r
+                  Event,\r
+                  &RegistrationLocal\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibNamedEventSignal (\r
+  IN EFI_GUID            *Name\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Signals a named event. All registered listeners will run.\r
+  The listeners should register using EfiLibNamedEventListen() function.\r
+\r
+  NOTE: For now, the named listening/signalling is implemented\r
+  on a protocol interface being installed and uninstalled.\r
+  In the future, this maybe implemented based on a dedicated mechanism.\r
+\r
+Arguments:\r
+  Name - Name to perform the signaling on. The name is a GUID.\r
+\r
+Returns:\r
+  EFI_SUCCESS if successfull.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  Name,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  Handle,\r
+                  Name,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+static\r
+VOID\r
+EFIAPI\r
+EventNotifySignalAllNullEvent (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  //\r
+  // This null event is a size efficent way to enusre that \r
+  // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.\r
+  // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into \r
+  // CreateEventEx() and this function is used to make the\r
+  // old error checking in CreateEvent() for Tiano extensions\r
+  // function.\r
+  //\r
+  return;\r
+}\r
+\r
+#endif\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventLegacyBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *LegacyBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Legacy Boot Event.  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Returns:\r
+  EFI_SUCCESS   Event was created.\r
+  Other         Event was not created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+\r
+  if (NotifyFunction == NULL) {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  LegacyBootEvent\r
+                  );\r
+#else\r
+\r
+  EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventLegacyBootGuid,\r
+                  LegacyBootEvent\r
+                  );\r
+#endif\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventReadyToBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *ReadyToBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  @param LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Return:\r
+  EFI_SUCCESS   - Event was created.\r
+  Other         - Event was not created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+\r
+  if (NotifyFunction == NULL) {\r
+    EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+    EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  ReadyToBootEvent\r
+                  );\r
+#else\r
+\r
+  EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventReadyToBootGuid,\r
+                  ReadyToBootEvent\r
+                  );\r
+#endif\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c
new file mode 100644 (file)
index 0000000..3d44562
--- /dev/null
@@ -0,0 +1,220 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  GetImage.c\r
+\r
+Abstract:\r
+\r
+  Image data extraction support for common use.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiImageFormat.h"\r
+\r
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)\r
+\r
+EFI_STATUS\r
+GetImageFromFv (\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  IN  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv,\r
+#else\r
+  IN  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
+#endif\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_FV_FILETYPE           FileType;\r
+  EFI_FV_FILE_ATTRIBUTES    Attributes;\r
+  UINT32                    AuthenticationStatus;\r
+\r
+  //\r
+  // Read desired section content in NameGuid file\r
+  //\r
+  *Buffer     = NULL;\r
+  *Size       = 0;\r
+  Status      = Fv->ReadSection (\r
+                      Fv,\r
+                      NameGuid,\r
+                      SectionType,\r
+                      0,\r
+                      Buffer,\r
+                      Size,\r
+                      &AuthenticationStatus\r
+                      );\r
+\r
+  if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {\r
+    //\r
+    // Try reading PE32 section, since the TE section does not exist\r
+    //\r
+    *Buffer = NULL;\r
+    *Size   = 0;\r
+    Status  = Fv->ReadSection (\r
+                    Fv,\r
+                    NameGuid,\r
+                    EFI_SECTION_PE32,\r
+                    0,\r
+                    Buffer,\r
+                    Size,\r
+                    &AuthenticationStatus\r
+                    );\r
+  }\r
+\r
+  if (EFI_ERROR (Status) && \r
+      ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) {\r
+    //\r
+    // Try reading raw file, since the desired section does not exist\r
+    //\r
+    *Buffer = NULL;\r
+    *Size   = 0;\r
+    Status  = Fv->ReadFile (\r
+                    Fv,\r
+                    NameGuid,\r
+                    Buffer,\r
+                    Size,\r
+                    &FileType,\r
+                    &Attributes,\r
+                    &AuthenticationStatus\r
+                    );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+GetImage (\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size\r
+  )\r
+{\r
+  return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE);\r
+}\r
+\r
+EFI_STATUS\r
+GetImageEx (\r
+  IN  EFI_HANDLE         ImageHandle,\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size,\r
+  BOOLEAN                WithinImageFv\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_HANDLE                    *HandleBuffer;\r
+  UINTN                         HandleCount;\r
+  UINTN                         Index;\r
+  EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *ImageFv;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv;\r
+#else\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
+#endif\r
+\r
+  if (ImageHandle == NULL && WithinImageFv) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status  = EFI_NOT_FOUND;\r
+  ImageFv = NULL;\r
+  if (ImageHandle != NULL) {\r
+    Status = gBS->HandleProtocol (\r
+               ImageHandle,\r
+               &gEfiLoadedImageProtocolGuid,\r
+               &LoadedImage\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    Status = gBS->HandleProtocol (\r
+                    LoadedImage->DeviceHandle,\r
+                  #if (PI_SPECIFICATION_VERSION < 0x00010000)    \r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                  #else\r
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                  #endif\r
+                    &ImageFv\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size);\r
+    }\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS || WithinImageFv) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+                  &gEfiFirmwareVolumeProtocolGuid,\r
+                #else\r
+                  &gEfiFirmwareVolume2ProtocolGuid,\r
+                #endif\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Find desired image in all Fvs\r
+  //\r
+  for (Index = 0; Index < HandleCount; ++Index) {\r
+    Status = gBS->HandleProtocol (\r
+                    HandleBuffer[Index],\r
+                  #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                  #else\r
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                  #endif\r
+                    (VOID**)&Fv\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool(HandleBuffer);\r
+      return Status;\r
+    }\r
+\r
+    if (ImageFv != NULL && Fv == ImageFv) {\r
+      continue;\r
+    }\r
+\r
+    Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size);\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+  gBS->FreePool(HandleBuffer);\r
+\r
+  //\r
+  // Not found image\r
+  //\r
+  if (Index == HandleCount) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c
new file mode 100644 (file)
index 0000000..179079d
--- /dev/null
@@ -0,0 +1,176 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Handle.c\r
+\r
+Abstract:\r
+\r
+  Support for Handle lib fucntions.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_STATUS\r
+EfiLibLocateHandleProtocolByProtocols (\r
+  IN OUT EFI_HANDLE        * Handle, OPTIONAL\r
+  OUT    VOID              **Interface, OPTIONAL\r
+  ...\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Function locates Protocol and/or Handle on which all Protocols specified\r
+  as a variable list are installed.\r
+  It supports continued search. The caller must assure that no handles are added\r
+  or removed while performing continued search, by e.g., rising the TPL and not\r
+  calling any handle routines. Otherwise the behavior is undefined.\r
+\r
+Arguments:\r
+\r
+  Handle        - The address of handle to receive the handle on which protocols\r
+                  indicated by the variable list are installed.\r
+                  If points to NULL, all handles are searched. If pointing to a\r
+                  handle returned from previous call, searches starting from next handle.\r
+                  If NULL, the parameter is ignored.\r
+\r
+  Interface     - The address of a pointer to a protocol interface that will receive\r
+                  the interface indicated by first variable argument.\r
+                  If NULL, the parameter is ignored.\r
+\r
+  ...           - A variable argument list containing protocol GUIDs. Must end with NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS  - All the protocols where found on same handle.\r
+  EFI_NOT_FOUND - A Handle with all the protocols installed was not found.\r
+  Other values as may be returned from LocateHandleBuffer() or HandleProtocol().\r
+\r
+--*/\r
+{\r
+  VA_LIST     args;\r
+  EFI_STATUS  Status;\r
+  EFI_GUID    *Protocol;\r
+  EFI_GUID    *ProtocolFirst;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       NumberOfHandles;\r
+  UINTN       Idx;\r
+  VOID        *AnInterface;\r
+\r
+  AnInterface = NULL;\r
+  VA_START (args, Interface);\r
+  ProtocolFirst = VA_ARG (args, EFI_GUID *);\r
+\r
+  //\r
+  // Get list of all handles that support the first protocol.\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  ProtocolFirst,\r
+                  NULL,\r
+                  &NumberOfHandles,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Check if this is a countinuation of handle searching.\r
+  //\r
+  Idx = 0;\r
+  if ((Handle != NULL) && (*Handle != NULL)) {\r
+    //\r
+    // Leave the Idx just beyond the matching handle.\r
+    //\r
+    for (; Idx < NumberOfHandles;) {\r
+      if (*Handle == HandleBuffer[Idx++]) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // Iterate handles testing for presence of remaining protocols.\r
+  //\r
+  for (; Idx < NumberOfHandles; Idx++) {\r
+\r
+    //\r
+    // Start with the second protocol, the first one is sure on this handle.\r
+    //\r
+    VA_START (args, Interface);\r
+    VA_ARG (args, EFI_GUID *);\r
+\r
+    //\r
+    // Iterate protocols from the variable list.\r
+    //\r
+    while (TRUE) {\r
+\r
+      Protocol = VA_ARG (args, EFI_GUID *);\r
+\r
+      if (Protocol == NULL) {\r
+\r
+        //\r
+        // If here, the list was iterated successfully\r
+        // finding each protocol on a single handle.\r
+        //\r
+\r
+        Status = EFI_SUCCESS;\r
+\r
+        //\r
+        // OPTIONAL parameter returning the Handle.\r
+        //\r
+        if (Handle != NULL) {\r
+          *Handle = HandleBuffer[Idx];\r
+        }\r
+\r
+        //\r
+        // OPTIONAL parameter returning the first rotocol's Interface.\r
+        //\r
+        if (Interface != NULL) {\r
+          Status = gBS->HandleProtocol (\r
+                          HandleBuffer[Idx],\r
+                          ProtocolFirst,\r
+                          Interface\r
+                          );\r
+        }\r
+\r
+        goto lbl_out;\r
+      }\r
+\r
+      Status = gBS->HandleProtocol (\r
+                      HandleBuffer[Idx],\r
+                      Protocol,\r
+                      &AnInterface\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+\r
+        //\r
+        // This handle does not have the iterated protocol.\r
+        //\r
+        break;\r
+      }\r
+    }\r
+\r
+  }\r
+\r
+  //\r
+  // If here, no handle that bears all the protocols was found.\r
+  //\r
+  Status = EFI_NOT_FOUND;\r
+\r
+lbl_out:\r
+  gBS->FreePool (HandleBuffer);\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s
new file mode 100644 (file)
index 0000000..5814bb7
--- /dev/null
@@ -0,0 +1,61 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    PerformancePrimitives.s\r
+//\r
+//  Abstract:\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+.file  "PerformancePrimitives.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// GetTimerValue\r
+//\r
+// Implementation of CPU-based time service\r
+//\r
+// On Entry :\r
+//    EFI_STATUS\r
+//    GetTimerValue (\r
+//      OUT UINT64    *TimerValue\r
+//    )\r
+//\r
+// Return Value: \r
+//        r8  = Status\r
+//        r9  = 0\r
+//        r10 = 0\r
+//        r11 = 0\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (GetTimerValue)\r
+\r
+      NESTED_SETUP (1,8,0,0)\r
+      mov               r8 = ar.itc;;\r
+      st8               [r32]= r8\r
+      mov               r8 = r0\r
+      mov               r9 = r0\r
+      mov               r10 = r0\r
+      mov               r11 = r0\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (GetTimerValue)\r
+//---------------------------------------------------------------------------\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c
new file mode 100644 (file)
index 0000000..328e465
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LibGlobalDs.c\r
+\r
+Abstract:\r
+\r
+  Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.\r
+  Each seperatly linked module has it's own copy of these globals.\r
+\r
+  gBS       - Boot Services table pointer\r
+  gRT       - Runt Time services table pointer\r
+  gST       - System Table pointer\r
+  \r
+  gErrorLevel     - Debug error level.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_DXE_SERVICES  *gDS = NULL;\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c
new file mode 100644 (file)
index 0000000..64ed94c
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LibGlobalErrorLevel.c\r
+\r
+Abstract:\r
+\r
+  Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.\r
+  Each seperatly linked module has it's own copy of these globals.\r
+\r
+  gBS       - Boot Services table pointer\r
+  gRT       - Runt Time services table pointer\r
+  gST       - System Table pointer\r
+  \r
+  gErrorLevel     - Debug error level.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+UINTN gErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD;\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c
new file mode 100644 (file)
index 0000000..5a65285
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LibGlobalSt.c\r
+\r
+Abstract:\r
+\r
+  Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.\r
+  Each seperatly linked module has it's own copy of these globals.\r
+\r
+  gBS       - Boot Services table pointer\r
+  gRT       - Runt Time services table pointer\r
+  gST       - System Table pointer\r
+  \r
+  gErrorLevel     - Debug error level.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+EFI_SYSTEM_TABLE      *gST  = NULL;\r
+EFI_BOOT_SERVICES     *gBS  = NULL;\r
+EFI_RUNTIME_SERVICES  *gRT  = NULL;\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c
new file mode 100644 (file)
index 0000000..5667a34
--- /dev/null
@@ -0,0 +1,159 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Lock.c\r
+\r
+Abstract:\r
+\r
+  Support for locking lib services.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  Note on a check build ASSERT()s are used to ensure proper\r
+  lock usage.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - The task priority level of the lock\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+{\r
+  Lock->Tpl       = Priority;\r
+  Lock->OwnerTpl  = 0;\r
+  Lock->Lock      = 0;\r
+}\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+{\r
+  if (Lock->Lock != 0) {\r
+    //\r
+    // Lock is already owned, so bail out\r
+    //\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+\r
+  Lock->Lock += 1;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  Lock owned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiAcquireLockOrFail (Lock);\r
+\r
+  //\r
+  // Lock was already locked.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock, and\r
+    restores the previous task priority level.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    Lock unowned\r
+\r
+--*/\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  Tpl = Lock->OwnerTpl;\r
+\r
+  ASSERT (Lock->Lock == 1);\r
+  Lock->Lock -= 1;\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
new file mode 100644 (file)
index 0000000..55d1a1d
--- /dev/null
@@ -0,0 +1,861 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Perf.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance primatives. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (Performance)\r
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)\r
+#include EFI_GUID_DEFINITION (Hob)\r
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)\r
+#include "linkedlist.h"\r
+#include "EfiHobLib.h"\r
+#include "EfiImage.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  );\r
+\r
+EFI_STATUS\r
+GetPeiPerformance (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN UINT64               Ticker\r
+  );\r
+\r
+#define EFI_PERFORMANCE_DATA_SIGNATURE  EFI_SIGNATURE_32 ('P', 'E', 'D', 'A')\r
+\r
+typedef struct {\r
+  UINT32          Signature;\r
+  EFI_LIST_ENTRY  Link;\r
+  EFI_GAUGE_DATA  GaugeData;\r
+} EFI_PERF_DATA_LIST;\r
+\r
+#define GAUGE_DATA_FROM_LINK(_link)  \\r
+            CR(_link, EFI_PERF_DATA_LIST, Link, EFI_PERFORMANCE_DATA_SIGNATURE)\r
+\r
+#define GAUGE_DATA_FROM_GAUGE(_GaugeData)  \\r
+            CR(_GaugeData, EFI_PERF_DATA_LIST, GaugeData, EFI_PERFORMANCE_DATA_SIGNATURE)\r
+\r
+#define EFI_PERFORMANCE_SIGNATURE         EFI_SIGNATURE_32 ('P', 'E', 'R', 'F')\r
+\r
+//\r
+// Performance protocol instance data structure\r
+//\r
+typedef struct {\r
+  UINTN                     Signature;\r
+  EFI_HANDLE                Handle;\r
+  EFI_PERFORMANCE_PROTOCOL  Perf;\r
+  UINT8                     Phase;\r
+} EFI_PERFORMANCE_INSTANCE;\r
+\r
+//\r
+// Performace protocol instance containing record macro\r
+//\r
+\r
+#define EFI_PERFORMANCE_FROM_THIS(a) \\r
+  CR(a, EFI_PERFORMANCE_INSTANCE, Perf, EFI_PERFORMANCE_SIGNATURE)\r
+\r
+EFI_LIST_ENTRY  mPerfDataHead = INITIALIZE_LIST_HEAD_VARIABLE(mPerfDataHead);\r
+\r
+STATIC\r
+VOID\r
+GetShortPdbFileName (\r
+  CHAR8  *PdbFileName,\r
+  CHAR8  *GaugeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index1;\r
+  UINTN StartIndex;\r
+  UINTN EndIndex;\r
+\r
+  if (PdbFileName == NULL) {\r
+    EfiAsciiStrCpy (GaugeString, " ");\r
+  } else {\r
+    StartIndex = 0;\r
+    for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
+      ;\r
+\r
+    for (Index = 0; PdbFileName[Index] != 0; Index++) {\r
+      if (PdbFileName[Index] == '\\') {\r
+        StartIndex = Index + 1;\r
+      }\r
+\r
+      if (PdbFileName[Index] == '.') {\r
+        EndIndex = Index;\r
+      }\r
+    }\r
+\r
+    Index1 = 0;\r
+    for (Index = StartIndex; Index < EndIndex; Index++) {\r
+      GaugeString[Index1] = PdbFileName[Index];\r
+      Index1++;\r
+      if (Index1 == EFI_PERF_PDBFILENAME_LENGTH - 1) {\r
+        break;\r
+      }\r
+    }\r
+\r
+    GaugeString[Index1] = 0;\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+CHAR8 *\r
+GetPdbPath (\r
+  VOID *ImageBase\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Located PDB path name in PE image\r
+\r
+Arguments:\r
+\r
+  ImageBase - base of PE to search\r
+\r
+Returns:\r
+\r
+  Pointer into image at offset of PDB file name if PDB file name is found,\r
+  Otherwise a pointer to an empty string.\r
+\r
+--*/\r
+{\r
+  CHAR8                           *PdbPath;\r
+  UINT32                          DirCount;\r
+  EFI_IMAGE_DOS_HEADER            *DosHdr;\r
+  EFI_IMAGE_NT_HEADERS            *NtHdr;\r
+  UINT16                          Magic;\r
+  EFI_IMAGE_OPTIONAL_HEADER32     *OptionalHdr32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64     *OptionalHdr64;\r
+  EFI_IMAGE_DATA_DIRECTORY        *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;\r
+  VOID                            *CodeViewEntryPointer;\r
+\r
+  CodeViewEntryPointer  = NULL;\r
+  PdbPath               = NULL;\r
+  DosHdr                = ImageBase;\r
+  if (DosHdr && DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    NtHdr           = (EFI_IMAGE_NT_HEADERS *) ((UINT8 *) DosHdr + DosHdr->e_lfanew);\r
+    //\r
+    // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.\r
+    //       It is for backward-compatibility consideration, because\r
+    //       some system will generate PE32+ image with PE32 Magic.\r
+    //\r
+    if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+    } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else {\r
+      Magic = NtHdr->OptionalHeader.Magic;\r
+    }\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      OptionalHdr32 = (VOID *) &NtHdr->OptionalHeader;\r
+      DirectoryEntry  = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    } else {\r
+      OptionalHdr64 = (VOID *) &NtHdr->OptionalHeader;\r
+      DirectoryEntry  = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    }\r
+    \r
+    if (DirectoryEntry->VirtualAddress != 0) {\r
+      for (DirCount = 0;\r
+           (DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && CodeViewEntryPointer == NULL;\r
+           DirCount++\r
+          ) {\r
+        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (DirectoryEntry->VirtualAddress + (UINTN) ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
+        if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+          CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageBase);\r
+          switch (*(UINT32 *) CodeViewEntryPointer) {\r
+          case CODEVIEW_SIGNATURE_NB10:\r
+            PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+            break;\r
+\r
+          case CODEVIEW_SIGNATURE_RSDS:\r
+            PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+            break;\r
+\r
+          default:\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return PdbPath;\r
+}\r
+\r
+STATIC\r
+VOID\r
+GetNameFromHandle (\r
+  IN  EFI_HANDLE     Handle,\r
+  OUT CHAR8          *GaugeString\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL   *Image;\r
+  CHAR8                       *PdbFileName;\r
+  EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;\r
+\r
+  EfiAsciiStrCpy (GaugeString, " ");\r
+\r
+  //\r
+  // Get handle name from image protocol\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID**)&Image\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Status = gBS->OpenProtocol (\r
+                    Handle,\r
+                    &gEfiDriverBindingProtocolGuid,\r
+                    (VOID **) &DriverBinding,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return ;\r
+    }\r
+    //\r
+    // Get handle name from image protocol\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    DriverBinding->ImageHandle,\r
+                    &gEfiLoadedImageProtocolGuid,\r
+                    (VOID**)&Image\r
+                    );\r
+  }\r
+\r
+  PdbFileName = GetPdbPath (Image->ImageBase);\r
+\r
+  if (PdbFileName != NULL) {\r
+    GetShortPdbFileName (PdbFileName, GaugeString);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+EFI_PERF_DATA_LIST *\r
+CreateDataNode (\r
+  IN EFI_HANDLE       Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a EFI_PERF_DATA_LIST data node.\r
+\r
+Arguments:\r
+\r
+  Handle  - Handle of gauge data\r
+  Token   - Token of gauge data\r
+  Host    - Host of gauge data\r
+\r
+Returns:\r
+\r
+  Pointer to a data node created.\r
+\r
+--*/\r
+{\r
+  EFI_PERF_DATA_LIST  *Node;\r
+\r
+  //\r
+  // Al\ a new image structure\r
+  //\r
+  Node = EfiLibAllocateZeroPool (sizeof (EFI_PERF_DATA_LIST));\r
+  if (Node != NULL) {\r
+\r
+    Node->Signature         = EFI_PERFORMANCE_DATA_SIGNATURE;\r
+\r
+    Node->GaugeData.Handle  = Handle;\r
+\r
+    if (Token != NULL) {\r
+      EfiStrCpy ((Node->GaugeData).Token, Token);\r
+    }\r
+\r
+    if (Host != NULL) {\r
+      EfiStrCpy ((Node->GaugeData).Host, Host);\r
+    }\r
+\r
+    if (Handle != NULL) {\r
+      GetNameFromHandle (Handle, Node->GaugeData.PdbFileName);\r
+    }\r
+  }\r
+\r
+  return Node;\r
+}\r
+\r
+\r
+EFI_PERF_DATA_LIST *\r
+GetDataNode (\r
+  IN EFI_HANDLE        Handle,\r
+  IN UINT16            *Token,\r
+  IN UINT16            *Host,\r
+  IN EFI_GUID          *GuidName,\r
+  IN EFI_GAUGE_DATA    *PrevGauge\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Search gauge node list to find one node with matched handle, token, host and Guid name.\r
+\r
+Arguments:\r
+\r
+  Handle    - Handle to match\r
+  Token     - Token to match\r
+  Host      - Host to match\r
+  GuidName  - Guid name to match\r
+  PrevGauge - Start node, start from list head if NULL\r
+\r
+Returns:\r
+\r
+  Return pointer to the node found, NULL if not found.\r
+\r
+--*/\r
+{\r
+  EFI_PERF_DATA_LIST  *Node;\r
+  EFI_PERF_DATA_LIST  *Temp;\r
+  EFI_PERF_DATA_LIST  *Temp2;\r
+  EFI_LIST_ENTRY      *CurrentLink;\r
+  EFI_GUID            NullGuid = EFI_NULL_GUID;\r
+\r
+  Node      = NULL;\r
+  Temp      = NULL;\r
+  Temp2     = NULL;\r
+\r
+  if (PrevGauge == NULL) {\r
+    CurrentLink = mPerfDataHead.ForwardLink;\r
+  } else {\r
+    Temp2       = GAUGE_DATA_FROM_GAUGE (PrevGauge);\r
+    CurrentLink = (Temp2->Link).ForwardLink;\r
+  }\r
+\r
+  while (CurrentLink && CurrentLink != &mPerfDataHead) {\r
+    Node = GAUGE_DATA_FROM_LINK (CurrentLink);\r
+\r
+    if (Handle == 0 && Token == NULL && Host == NULL && GuidName == NULL) {\r
+      return Node;\r
+    }\r
+\r
+    if (Handle != (Node->GaugeData).Handle) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (GuidName == NULL && !EfiCompareGuid (&((Node->GaugeData).GuidName), &NullGuid)) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (GuidName && !EfiCompareGuid (&((Node->GaugeData).GuidName), GuidName)) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (Token == NULL && EfiStrCmp (Node->GaugeData.Token, L"")) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (Token && EfiStrCmp (Node->GaugeData.Token, Token)) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (Host == NULL && EfiStrCmp (Node->GaugeData.Host, L"")) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    if (Host && EfiStrCmp (Node->GaugeData.Host, Host)) {\r
+      CurrentLink = CurrentLink->ForwardLink;\r
+      continue;\r
+    }\r
+\r
+    Temp = Node;\r
+    break;\r
+  }\r
+\r
+  return Temp;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+StartGauge (\r
+  IN EFI_PERFORMANCE_PROTOCOL         *This,\r
+  IN EFI_HANDLE                       Handle,\r
+  IN UINT16                           *Token,\r
+  IN UINT16                           *Host,\r
+  IN UINT64                           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a guage data node and initialized it.\r
+\r
+Arguments:\r
+\r
+  This    - Calling context\r
+  Handle  - Handle of gauge data\r
+  Token   - Token of gauge data\r
+  Host    - Host of gauge data\r
+  Ticker  - Set gauge data's StartTick. If 0, StartTick is current timer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Successfully create and initialized a guage data node.\r
+  EFI_OUT_OF_RESOURCES  - No enough resource to create a guage data node.\r
+\r
+--*/\r
+{\r
+  EFI_PERFORMANCE_INSTANCE  *PerfInstance;\r
+  EFI_PERF_DATA_LIST        *Node;\r
+  UINT64                    TimerValue;\r
+\r
+  TimerValue    = 0;\r
+  PerfInstance  = EFI_PERFORMANCE_FROM_THIS (This);\r
+\r
+  Node          = CreateDataNode (Handle, Token, Host);\r
+  if (!Node) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  if (Ticker != 0) {\r
+    TimerValue = Ticker;\r
+  } else {\r
+    GetTimerValue (&TimerValue);\r
+  }\r
+\r
+  Node->GaugeData.StartTick = TimerValue;\r
+\r
+  if (!EfiStrCmp (Token, DXE_TOK)) {\r
+    PerfInstance->Phase = DXE_PHASE;\r
+  }\r
+\r
+  if (!EfiStrCmp (Token, SHELL_TOK)) {\r
+    PerfInstance->Phase = SHELL_PHASE;\r
+  }\r
+\r
+  Node->GaugeData.Phase = PerfInstance->Phase;\r
+\r
+  InsertTailList (&mPerfDataHead, &(Node->Link));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EndGauge (\r
+  IN EFI_PERFORMANCE_PROTOCOL         *This,\r
+  IN EFI_HANDLE                       Handle,\r
+  IN UINT16                           *Token,\r
+  IN UINT16                           *Host,\r
+  IN UINT64                           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  End all unfinished gauge data node that match specified handle, token and host.\r
+\r
+Arguments:\r
+\r
+  This    - Calling context\r
+  Handle  - Handle to stop\r
+  Token   - Token to stop\r
+  Host    - Host to stop\r
+  Ticker  - End tick, if 0 then get current timer\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - Node not found\r
+  EFI_SUCCESS - Gauge data node successfully ended.\r
+\r
+--*/\r
+{\r
+  EFI_PERFORMANCE_INSTANCE  *PerfInstance;\r
+  EFI_PERF_DATA_LIST        *Node;\r
+  UINT64                    TimerValue;\r
+\r
+  TimerValue    = 0;\r
+  PerfInstance  = EFI_PERFORMANCE_FROM_THIS (This);\r
+\r
+  Node          = GetDataNode (Handle, Token, Host, NULL, NULL);\r
+  if (!Node) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  while (Node->GaugeData.EndTick != 0) {\r
+    Node = GetDataNode (Handle, Token, Host, NULL, &(Node->GaugeData));\r
+    if (!Node) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+  }\r
+\r
+  if (Ticker != 0) {\r
+    TimerValue = Ticker;\r
+  } else {\r
+    GetTimerValue (&TimerValue);\r
+  }\r
+\r
+  Node->GaugeData.EndTick = TimerValue;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_GAUGE_DATA *\r
+EFIAPI\r
+GetGauge (\r
+  IN EFI_PERFORMANCE_PROTOCOL         *This,\r
+  IN EFI_HANDLE                       Handle,\r
+  IN UINT16                           *Token,\r
+  IN UINT16                           *Host,\r
+  IN EFI_GAUGE_DATA                   *PrevGauge\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get gauge.\r
+\r
+Arguments:\r
+  This        - A pointer to the EFI_PERFORMANCE_PROTOCOL.\r
+  Handle      - A pointer of a efi handle.\r
+  Token       - A pointer to the token.\r
+  Host        - A pointer to the host.\r
+  PrevGauge   - A pointer to the EFI_GAUGE_DATA structure.\r
+\r
+\r
+Returns:\r
+  Status code.\r
+\r
+--*/\r
+{\r
+  EFI_PERFORMANCE_INSTANCE  *PerfInstance;\r
+  EFI_PERF_DATA_LIST        *Node;\r
+\r
+  PerfInstance  = EFI_PERFORMANCE_FROM_THIS (This);\r
+\r
+  Node          = GetDataNode (Handle, Token, Host, NULL, PrevGauge);\r
+  if (Node != NULL) {\r
+    return &(Node->GaugeData);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
+//\r
+// Driver entry point\r
+//\r
+EFI_STATUS\r
+InitializePerformanceInfrastructure (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN UINT64               Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install gEfiPerformanceProtocolGuid protocol and transfer PEI performance to gauge data nodes.\r
+\r
+Arguments:\r
+\r
+  ImageHandle - Standard driver entry point parameter\r
+  SystemTable - Standard driver entry point parameter\r
+  Ticker      - End tick for PEI performance\r
+\r
+Returns:\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough buffer to allocate\r
+  EFI_SUCCESS - Protocol installed.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_PERFORMANCE_INSTANCE  *PerfInstance;\r
+\r
+  //\r
+  // Allocate a new image structure\r
+  //\r
+  PerfInstance = EfiLibAllocateZeroPool (sizeof (EFI_PERFORMANCE_INSTANCE));\r
+  if (PerfInstance == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  PerfInstance->Signature       = EFI_PERFORMANCE_SIGNATURE;\r
+  PerfInstance->Perf.StartGauge = StartGauge;\r
+  PerfInstance->Perf.EndGauge   = EndGauge;\r
+  PerfInstance->Perf.GetGauge   = GetGauge;\r
+\r
+  //\r
+  // Install the protocol interfaces\r
+  //\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &PerfInstance->Handle,\r
+                  &gEfiPerformanceProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &PerfInstance->Perf\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    GetPeiPerformance (ImageHandle, SystemTable, Ticker);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+StartMeasure (\r
+  EFI_HANDLE          Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Start to gauge on a specified handle, token and host, with Ticker as start tick.\r
+\r
+Arguments:\r
+\r
+  Handle  - Handle to measure\r
+  Token   - Token to measure\r
+  Host    - Host to measure\r
+  Ticker  - Ticker as start tick\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_PERFORMANCE_PROTOCOL  *Perf;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return Perf->StartGauge (Perf, Handle, Token, Host, Ticker);\r
+\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EndMeasure (\r
+  EFI_HANDLE          Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  End gauging on a specified handle, token and host, with Ticker as end tick.\r
+\r
+Arguments:\r
+\r
+  Handle  - Handle to stop\r
+  Token   - Token to stop\r
+  Host    - Host to stop\r
+  Ticker  - Ticker as end tick\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_PERFORMANCE_PROTOCOL  *Perf;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf);\r
+  if (Status != EFI_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  return (Perf->EndGauge( Perf, Handle, Token, Host, Ticker)) ;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+UpdateMeasure (\r
+  EFI_HANDLE         Handle,\r
+  IN UINT16          *Token,\r
+  IN UINT16          *Host,\r
+  EFI_HANDLE         HandleNew,\r
+  IN UINT16          *TokenNew,\r
+  IN UINT16          *HostNew\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Update measure.\r
+\r
+Arguments:\r
+  Handle      - A pointer of an efi handle.\r
+  Token       - A pointer to the token.\r
+  Host        - A pointer to the host.\r
+  HandleNew   - A pointer of an new efi handle.\r
+  TokenNew    - A pointer to the new token.\r
+  HostNew     - A pointer to the new host.\r
+\r
+Returns:\r
+  Status code.\r
+\r
+  EFI_NOT_FOUND       - The speicified gauge data node not found.\r
+  \r
+  EFI_SUCCESS         - Update successfully.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_GAUGE_DATA            *GaugeData;\r
+  EFI_PERFORMANCE_PROTOCOL  *Perf;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  GaugeData = Perf->GetGauge (Perf, Handle, Token, Host, NULL);\r
+  if (!GaugeData) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  GaugeData->Handle = HandleNew;\r
+  if (HostNew != NULL) {\r
+    EfiStrCpy (GaugeData->Host, HostNew);\r
+  } else {\r
+    EfiStrCpy (GaugeData->Host, L"");\r
+  }\r
+\r
+  if (TokenNew != NULL) {\r
+    EfiStrCpy (GaugeData->Token, TokenNew);\r
+  } else {\r
+    EfiStrCpy (GaugeData->Token, L"");\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+GetPeiPerformance (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN UINT64               Ticker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Transfer PEI performance data to gauge data node.\r
+\r
+Arguments:\r
+\r
+  ImageHandle - Standard entry point parameter\r
+  SystemTable - Standard entry point parameter\r
+  Ticker      - Start tick\r
+\r
+Returns:\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough resource to create data node.\r
+  EFI_SUCCESS - Transfer done successfully.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  VOID                              *HobList;\r
+  EFI_HOB_GUID_DATA_PERFORMANCE_LOG *LogHob;\r
+  PEI_PERFORMANCE_MEASURE_LOG_ENTRY *LogEntry;\r
+  UINT32                            Index;\r
+  EFI_PERF_DATA_LIST                *Node;\r
+  UINT64                            TimerValue;\r
+\r
+  Node = CreateDataNode (0, PEI_TOK, NULL);\r
+  if (!Node) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  if (Ticker != 0) {\r
+    TimerValue = Ticker;\r
+  } else {\r
+    GetTimerValue (&TimerValue);\r
+  }\r
+  (Node->GaugeData).EndTick = TimerValue;\r
+\r
+  InsertTailList (&mPerfDataHead, &(Node->Link));\r
+\r
+  EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
+  do {\r
+    Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    for (Index = 0; Index < LogHob->NumberOfEntries; Index++) {\r
+      LogEntry  = &(LogHob->Log[Index]);\r
+      Node      = CreateDataNode (0, LogEntry->DescriptionString, NULL);\r
+      if (!Node) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+      (Node->GaugeData).StartTick = LogEntry->StartTimeCount;\r
+\r
+      EfiCopyMem (&(Node->GaugeData.GuidName), &LogEntry->Name, sizeof (EFI_GUID));\r
+\r
+      InsertTailList (&mPerfDataHead, &(Node->Link));\r
+\r
+      (Node->GaugeData).EndTick = LogEntry->StopTimeCount;\r
+    }\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
new file mode 100644 (file)
index 0000000..72efa4c
--- /dev/null
@@ -0,0 +1,141 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ReportStatusCode.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+STATIC EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+#endif\r
+\r
+EFI_STATUS\r
+EfiLibReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Report device path through status code.\r
+\r
+Arguments:\r
+\r
+  Type        - Code type\r
+  Value       - Code value\r
+  Instance    - Instance number\r
+  CallerId    - Caller name\r
+  DevicePath  - Device path that to be reported\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
+  if (gStatusCode == NULL) {\r
+    if (gBS == NULL) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+    if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+  Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
+  return Status;\r
+#else\r
+  if (gRT == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Check whether EFI_RUNTIME_SERVICES has Tiano Extension\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (gRT->Hdr.Revision     == EFI_SPECIFICATION_VERSION     &&\r
+      gRT->Hdr.HeaderSize   == sizeof (EFI_RUNTIME_SERVICES) &&\r
+      gRT->ReportStatusCode != NULL) {\r
+    Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
+  }\r
+  return Status;\r
+#endif\r
+}\r
+\r
+EFI_STATUS\r
+ReportStatusCodeWithDevicePath (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId OPTIONAL,\r
+  IN EFI_DEVICE_PATH_PROTOCOL * DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Report device path through status code.\r
+\r
+Arguments:\r
+\r
+  Type        - Code type\r
+  Value       - Code value\r
+  Instance    - Instance number\r
+  CallerId    - Caller name\r
+  DevicePath  - Device path that to be reported\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
+\r
+--*/\r
+{\r
+  UINT16                    Size;\r
+  UINT16                    DevicePathSize;\r
+  EFI_STATUS_CODE_DATA      *ExtendedData;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ExtendedDevicePath;\r
+  EFI_STATUS                Status;\r
+\r
+  DevicePathSize  = (UINT16) EfiDevicePathSize (DevicePath);\r
+  Size            = DevicePathSize + sizeof (EFI_STATUS_CODE_DATA);\r
+  ExtendedData    = (EFI_STATUS_CODE_DATA *) EfiLibAllocatePool (Size);\r
+  if (ExtendedData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  ExtendedDevicePath = EfiConstructStatusCodeData (Size, &gEfiStatusCodeSpecificDataGuid, ExtendedData);\r
+  EfiCopyMem (ExtendedDevicePath, DevicePath, DevicePathSize);\r
+\r
+  Status = EfiLibReportStatusCode (Type, Value, Instance, CallerId, (EFI_STATUS_CODE_DATA *) ExtendedData);\r
+\r
+  gBS->FreePool (ExtendedData);\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c
new file mode 100644 (file)
index 0000000..02d5ff8
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PerformancePrimitives.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance library\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "CpuIA32.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set TimerValue with current tick.\r
+\r
+Arguments:\r
+\r
+  TimerValue  - Timer value to be set\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TimerValue is set.\r
+\r
+--*/\r
+{\r
+  *TimerValue = EfiReadTsc ();\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c
new file mode 100644 (file)
index 0000000..929ddf1
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PerformancePrimitives.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance library\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "CpuIA32.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set TimerValue with current tick.\r
+\r
+Arguments:\r
+\r
+  TimerValue  - Timer value to be set\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TimerValue is set.\r
+\r
+--*/\r
+{\r
+  *TimerValue = EfiReadTsc ();\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
new file mode 100644 (file)
index 0000000..a4cc0ae
--- /dev/null
@@ -0,0 +1,51 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EfiIfrSupportLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = EfiIfrSupportLib\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  IfrCommon.c\r
+  IfrOnTheFly.c\r
+  IfrOpCodeCreation.c\r
+  IfrLibrary.h\r
+  IfrVariable.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\EfiDriverLib\r
+\r
+[libraries.common]\r
+  EfiGuidLib\r
+  EdkFrameworkProtocolLib\r
+\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c
new file mode 100644 (file)
index 0000000..030ab14
--- /dev/null
@@ -0,0 +1,1031 @@
+/*++\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  IfrCommon.c\r
+\r
+Abstract:\r
+\r
+  Common Library Routines to assist in IFR creation on-the-fly\r
+\r
+--*/\r
+\r
+#include "IfrLibrary.h"\r
+\r
+EFI_STATUS\r
+GetCurrentLanguage (\r
+  OUT     CHAR16              *Lang\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determine what is the current language setting\r
+  \r
+Arguments:\r
+  \r
+  Lang      - Pointer of system language\r
+  \r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Size;\r
+  UINTN       Index;\r
+  CHAR8       Language[4];\r
+\r
+  //\r
+  // Getting the system language and placing it into our Global Data\r
+  //\r
+  Size = sizeof (Language);\r
+\r
+  Status = gRT->GetVariable (\r
+                  L"Lang",\r
+                  &gEfiGlobalVariableGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  Language\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    EfiAsciiStrCpy (Language, "eng");\r
+  }\r
+\r
+  for (Index = 0; Index < 3; Index++) {\r
+    //\r
+    // Bitwise AND ascii value with 0xDF yields an uppercase value.\r
+    // Sign extend into a unicode value\r
+    //\r
+    Lang[Index] = (CHAR16) (Language[Index] & 0xDF);\r
+  }\r
+\r
+  //\r
+  // Null-terminate the value\r
+  //\r
+  Lang[3] = (CHAR16) 0;\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+AddString (\r
+  IN      VOID                *StringBuffer,\r
+  IN      CHAR16              *Language,\r
+  IN      CHAR16              *String,\r
+  IN OUT  STRING_REF          *StringToken\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a string to the incoming buffer and return the token and offset data\r
+  \r
+Arguments:\r
+  \r
+  StringBuffer      - The incoming buffer\r
+  \r
+  Language          - Currrent language\r
+  \r
+  String            - The string to be added\r
+  \r
+  StringToken       - The index where the string placed\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - String successfully added to the incoming buffer\r
+\r
+--*/\r
+{\r
+  EFI_HII_STRING_PACK *StringPack;\r
+  EFI_HII_STRING_PACK *StringPackBuffer;\r
+  VOID                *NewBuffer;\r
+  RELOFST             *PackSource;\r
+  RELOFST             *PackDestination;\r
+  UINT8               *Source;\r
+  UINT8               *Destination;\r
+  UINTN               Index;\r
+  BOOLEAN             Finished;\r
+\r
+  StringPack  = (EFI_HII_STRING_PACK *) StringBuffer;\r
+  Finished    = FALSE;\r
+\r
+  //\r
+  // Pre-allocate a buffer sufficient for us to work on.\r
+  // We will use it as a destination scratch pad to build data on\r
+  // and when complete shift the data back to the original buffer\r
+  //\r
+  NewBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);\r
+  if (NewBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  StringPackBuffer = (EFI_HII_STRING_PACK *) NewBuffer;\r
+\r
+  //\r
+  // StringPack is terminated with a length 0 entry\r
+  //\r
+  for (; StringPack->Header.Length != 0;) {\r
+    //\r
+    // If this stringpack's language is same as CurrentLanguage, use it\r
+    //\r
+    if (EfiCompareMem ((VOID *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language, 3) == 0) {\r
+      //\r
+      // We have some data in this string pack, copy the string package up to the string data\r
+      //\r
+      EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, sizeof (StringPack));\r
+\r
+      //\r
+      // These are references in the structure to tokens, need to increase them by the space occupied by an additional StringPointer\r
+      //\r
+      StringPackBuffer->LanguageNameString = (UINT16) (StringPackBuffer->LanguageNameString + (UINT16) sizeof (RELOFST));\r
+      StringPackBuffer->PrintableLanguageName = (UINT16) (StringPackBuffer->PrintableLanguageName + (UINT16) sizeof (RELOFST));\r
+\r
+      PackSource      = (RELOFST *) (StringPack + 1);\r
+      PackDestination = (RELOFST *) (StringPackBuffer + 1);\r
+      for (Index = 0; PackSource[Index] != 0x0000; Index++) {\r
+        //\r
+        // Copy the stringpointers from old to new buffer\r
+        // remember that we are adding a string, so the string offsets will all go up by sizeof (RELOFST)\r
+        //\r
+        PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST));\r
+      }\r
+      \r
+      //\r
+      // Add a new stringpointer in the new buffer since we are adding a string.  Null terminate it\r
+      //\r
+      PackDestination[Index] = (UINT16)(PackDestination[Index-1] + \r
+                                        EfiStrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1])));\r
+      PackDestination[Index + 1] = (UINT16) 0;\r
+\r
+      //\r
+      // Index is the token value for the new string\r
+      //\r
+      *StringToken = (UINT16) Index;\r
+\r
+      //\r
+      // Source now points to the beginning of the old buffer strings\r
+      // Destination now points to the beginning of the new buffer strings\r
+      //\r
+      Source      = (UINT8 *) &PackSource[Index + 1];\r
+      Destination = (UINT8 *) &PackDestination[Index + 2];\r
+\r
+      //\r
+      // This should copy all the strings from the old buffer to the new buffer\r
+      //\r
+      for (; Index != 0; Index--) {\r
+        //\r
+        // Copy Source string to destination buffer\r
+        //\r
+        EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) Source);\r
+\r
+        //\r
+        // Adjust the source/destination to the next string location\r
+        //\r
+        Destination = Destination + EfiStrSize ((CHAR16 *) Source);\r
+        Source      = Source + EfiStrSize ((CHAR16 *) Source);\r
+      }\r
+      \r
+      //\r
+      // This copies the new string to the destination buffer\r
+      //\r
+      EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) String);\r
+\r
+      //\r
+      // Adjust the size of the changed string pack by adding the size of the new string\r
+      // along with the size of the additional offset entry for the new string\r
+      //\r
+      StringPackBuffer->Header.Length = (UINT32) ((UINTN) StringPackBuffer->Header.Length + EfiStrSize (String) + sizeof (RELOFST));\r
+\r
+      //\r
+      // Advance the buffers to point to the next spots.\r
+      //\r
+      StringPackBuffer  = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPackBuffer->Header.Length);\r
+      StringPack        = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);\r
+      Finished          = TRUE;\r
+      continue;\r
+    }\r
+    //\r
+    // This isn't the language of the stringpack we were asked to add a string to\r
+    // so we need to copy it to the new buffer.\r
+    //\r
+    EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, StringPack->Header.Length);\r
+\r
+    //\r
+    // Advance the buffers to point to the next spots.\r
+    //\r
+    StringPackBuffer  = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length);\r
+    StringPack        = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);\r
+  }\r
+  \r
+  //\r
+  // If we didn't copy the new data to a stringpack yet\r
+  //\r
+  if (!Finished) {\r
+    PackDestination = (RELOFST *) (StringPackBuffer + 1);\r
+    //\r
+    // Pointing to a new string pack location\r
+    //\r
+    StringPackBuffer->Header.Length = (UINT32)\r
+      (\r
+        sizeof (EFI_HII_STRING_PACK) -\r
+        sizeof (EFI_STRING) +\r
+        sizeof (RELOFST) +\r
+        sizeof (RELOFST) +\r
+        EfiStrSize (Language) +\r
+        EfiStrSize (String)\r
+      );\r
+    StringPackBuffer->Header.Type           = EFI_HII_STRING;\r
+    StringPackBuffer->LanguageNameString    = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);\r
+    StringPackBuffer->PrintableLanguageName = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);\r
+    StringPackBuffer->Attributes            = 0;\r
+    PackDestination[0]                      = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);\r
+    PackDestination[1]                      = (UINT16) (PackDestination[0] + EfiStrSize (Language));\r
+    PackDestination[2]                      = (UINT16) 0;\r
+\r
+    //\r
+    // The first string location will be set to destination.  The minimum number of strings\r
+    // associated with a stringpack will always be token 0 stored as the languagename (e.g. ENG, SPA, etc)\r
+    // and token 1 as the new string being added and and null entry for the stringpointers\r
+    //\r
+    Destination = (CHAR8 *) &PackDestination[3];\r
+\r
+    //\r
+    // Copy the language name string to the new buffer\r
+    //\r
+    EfiStrCpy ((CHAR16 *) Destination, Language);\r
+\r
+    //\r
+    // Advance the destination to the new empty spot\r
+    //\r
+    Destination = Destination + EfiStrSize (Language);\r
+\r
+    //\r
+    // Copy the string to the new buffer\r
+    //\r
+    EfiStrCpy ((CHAR16 *) Destination, String);\r
+\r
+    //\r
+    // Since we are starting with a new string pack - we know the new string is token 1\r
+    //\r
+    *StringToken = (UINT16) 1;\r
+  }\r
+\r
+  //\r
+  // Zero out the original buffer and copy the updated data in the new buffer to the old buffer\r
+  //\r
+  EfiZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE);\r
+  EfiCopyMem (StringBuffer, NewBuffer, DEFAULT_STRING_BUFFER_SIZE);\r
+\r
+  //\r
+  // Free the newly created buffer since we don't need it anymore\r
+  //\r
+  gBS->FreePool (NewBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+AddOpCode (\r
+  IN      VOID                *FormBuffer,\r
+  IN OUT  VOID                *OpCodeData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add op-code data to the FormBuffer\r
+  \r
+Arguments:\r
+  \r
+  FormBuffer      - Form buffer to be inserted to\r
+  \r
+  OpCodeData      - Op-code data to be inserted\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - Op-code data successfully inserted\r
+\r
+--*/\r
+{\r
+  EFI_HII_PACK_HEADER *NewBuffer;\r
+  UINT8               *Source;\r
+  UINT8               *Destination;\r
+\r
+  //\r
+  // Pre-allocate a buffer sufficient for us to work on.\r
+  // We will use it as a destination scratch pad to build data on\r
+  // and when complete shift the data back to the original buffer\r
+  //\r
+  NewBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);\r
+  if (NewBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Source      = (UINT8 *) FormBuffer;\r
+  Destination = (UINT8 *) NewBuffer;\r
+\r
+  //\r
+  // Copy the IFR Package header to the new buffer\r
+  //\r
+  EfiCopyMem (Destination, Source, sizeof (EFI_HII_PACK_HEADER));\r
+\r
+  //\r
+  // Advance Source and Destination to next op-code\r
+  //\r
+  Source      = Source + sizeof (EFI_HII_PACK_HEADER);\r
+  Destination = Destination + sizeof (EFI_HII_PACK_HEADER);\r
+\r
+  //\r
+  // Copy data to the new buffer until we run into the end_form\r
+  //\r
+  for (; ((EFI_IFR_OP_HEADER *) Source)->OpCode != EFI_IFR_END_FORM_OP;) {\r
+    //\r
+    // If the this opcode is an end_form_set we better be creating and endform\r
+    // Nonetheless, we will add data before the end_form_set.  This also provides\r
+    // for interesting behavior in the code we will run, but has no bad side-effects\r
+    // since we will possibly do a 0 byte copy in this particular end-case.\r
+    //\r
+    if (((EFI_IFR_OP_HEADER *) Source)->OpCode == EFI_IFR_END_FORM_SET_OP) {\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Copy data to new buffer\r
+    //\r
+    EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);\r
+\r
+    //\r
+    // Adjust Source/Destination to next op-code location\r
+    //\r
+    Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;\r
+    Source      = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;\r
+  }\r
+\r
+  //\r
+  // Prior to the end_form is where we insert the new op-code data\r
+  //\r
+  EfiCopyMem (Destination, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);\r
+  Destination       = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
+\r
+  NewBuffer->Length = (UINT32) (NewBuffer->Length + (UINT32) (((EFI_IFR_OP_HEADER *) OpCodeData)->Length));\r
+\r
+  //\r
+  // Copy end-form data to new buffer\r
+  //\r
+  EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);\r
+\r
+  //\r
+  // Adjust Source/Destination to next op-code location\r
+  //\r
+  Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;\r
+  Source      = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;\r
+\r
+  //\r
+  // Copy end-formset data to new buffer\r
+  //\r
+  EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);\r
+\r
+  //\r
+  // Zero out the original buffer and copy the updated data in the new buffer to the old buffer\r
+  //\r
+  EfiZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE);\r
+  EfiCopyMem (FormBuffer, NewBuffer, DEFAULT_FORM_BUFFER_SIZE);\r
+\r
+  //\r
+  // Free the newly created buffer since we don't need it anymore\r
+  //\r
+  gBS->FreePool (NewBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+GetHiiInterface (\r
+  OUT     EFI_HII_PROTOCOL    **Hii\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get the HII protocol interface\r
+  \r
+Arguments:\r
+  \r
+  Hii     - HII protocol interface\r
+  \r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // There should only be one HII protocol\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiHiiProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) Hii\r
+                  );\r
+\r
+  return Status;;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+ExtractDataFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      HiiHandle,\r
+  IN OUT  UINT16              *ImageLength,\r
+  OUT     UINT8               *DefaultImage,\r
+  OUT     EFI_GUID            *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract information pertaining to the HiiHandle\r
+  \r
+Arguments:\r
+  \r
+  HiiHandle       - Hii handle\r
+  \r
+  ImageLength     - For input, length of DefaultImage;\r
+                    For output, length of actually required\r
+                    \r
+  DefaultImage    - Image buffer prepared by caller\r
+  \r
+  Guid            - Guid information about the form\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_BUFFER_TOO_SMALL    - DefualtImage has no enough ImageLength\r
+  \r
+  EFI_SUCCESS             - Successfully extract data from Hii database.\r
+  \r
+  \r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_HII_PROTOCOL  *Hii;\r
+  UINTN             DataLength;\r
+  UINT8             *RawData;\r
+  UINT8             *OldData;\r
+  UINTN             Index;\r
+  UINTN             Temp;\r
+  UINTN             SizeOfNvStore;\r
+  UINTN             CachedStart;\r
+\r
+  DataLength    = DEFAULT_FORM_BUFFER_SIZE;\r
+  SizeOfNvStore = 0;\r
+  CachedStart   = 0;\r
+\r
+  Status        = GetHiiInterface (&Hii);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Allocate space for retrieval of IFR data\r
+  //\r
+  RawData = EfiLibAllocateZeroPool ((UINTN) DataLength);\r
+  if (RawData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Get all the forms associated with this HiiHandle\r
+  //\r
+  Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (RawData);\r
+\r
+    //\r
+    // Allocate space for retrieval of IFR data\r
+    //\r
+    RawData = EfiLibAllocateZeroPool ((UINTN) DataLength);\r
+    if (RawData == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    //\r
+    // Get all the forms associated with this HiiHandle\r
+    //\r
+    Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData);\r
+  }\r
+\r
+  OldData = RawData;\r
+\r
+  //\r
+  // Point RawData to the beginning of the form data\r
+  //\r
+  RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER));\r
+\r
+  for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {\r
+    switch (RawData[Index]) {\r
+    case EFI_IFR_FORM_SET_OP:\r
+      //\r
+      // Copy the GUID information from this handle\r
+      //\r
+      EfiCopyMem (Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));\r
+      break;\r
+\r
+    case EFI_IFR_ONE_OF_OP:\r
+    case EFI_IFR_CHECKBOX_OP:\r
+    case EFI_IFR_NUMERIC_OP:\r
+    case EFI_IFR_DATE_OP:\r
+    case EFI_IFR_TIME_OP:\r
+    case EFI_IFR_PASSWORD_OP:\r
+    case EFI_IFR_STRING_OP:\r
+      //\r
+      // Remember, multiple op-codes may reference the same item, so let's keep a running\r
+      // marker of what the highest QuestionId that wasn't zero length.  This will accurately\r
+      // maintain the Size of the NvStore\r
+      //\r
+      if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) {\r
+        Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;\r
+        if (SizeOfNvStore < Temp) {\r
+          SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;\r
+        }\r
+      }\r
+    }\r
+\r
+    Index = RawData[Index + 1] + Index;\r
+  }\r
+    \r
+  //\r
+  // Return an error if buffer is too small\r
+  //\r
+  if (SizeOfNvStore > *ImageLength) {\r
+    gBS->FreePool (OldData);\r
+    *ImageLength = (UINT16) SizeOfNvStore;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  EfiZeroMem (DefaultImage, SizeOfNvStore);\r
+\r
+  //\r
+  // Copy the default image information to the user's buffer\r
+  //\r
+  for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {\r
+    switch (RawData[Index]) {\r
+    case EFI_IFR_ONE_OF_OP:\r
+      CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId;\r
+      break;\r
+\r
+    case EFI_IFR_ONE_OF_OPTION_OP:\r
+      if (((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Flags & EFI_IFR_FLAG_DEFAULT) {\r
+        EfiCopyMem (&DefaultImage[CachedStart], &((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value, 2);\r
+      }\r
+      break;\r
+\r
+    case EFI_IFR_CHECKBOX_OP:\r
+      DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId] = ((EFI_IFR_CHECK_BOX *) &RawData[Index])->Flags;\r
+      break;\r
+\r
+    case EFI_IFR_NUMERIC_OP:\r
+      EfiCopyMem (\r
+        &DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId],\r
+        &((EFI_IFR_NUMERIC *) &RawData[Index])->Default,\r
+        2\r
+        );\r
+      break;\r
+\r
+    }\r
+\r
+    Index = RawData[Index + 1] + Index;\r
+  }\r
+\r
+  *ImageLength = (UINT16) SizeOfNvStore;\r
+\r
+  //\r
+  // Free our temporary repository of form data\r
+  //\r
+  gBS->FreePool (OldData);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_HII_HANDLE\r
+FindHiiHandle (\r
+  IN OUT EFI_HII_PROTOCOL    **HiiProtocol, OPTIONAL\r
+  IN     EFI_GUID            *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Finds HII handle for given pack GUID previously registered with the HII.\r
+\r
+Arguments:\r
+  HiiProtocol - pointer to pointer to HII protocol interface. \r
+                If NULL, the interface will be found but not returned.\r
+                If it points to NULL, the interface will be found and \r
+                written back to the pointer that is pointed to.\r
+  Guid        - The GUID of the pack that registered with the HII.\r
+\r
+Returns:\r
+  Handle to the HII pack previously registered by the memory driver.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+\r
+  EFI_HII_HANDLE    *HiiHandleBuffer;\r
+  EFI_HII_HANDLE    HiiHandle;\r
+  UINT16            HiiHandleBufferLength;\r
+  UINT32            NumberOfHiiHandles;\r
+  EFI_GUID          HiiGuid;\r
+  EFI_HII_PROTOCOL  *HiiProt;\r
+  UINT32            Index;\r
+  UINT16            Length;\r
+\r
+  HiiHandle = 0;\r
+  if ((HiiProtocol != NULL) && (*HiiProtocol != NULL)) {\r
+    //\r
+    // The protocol has been passed in\r
+    //\r
+    HiiProt = *HiiProtocol;\r
+  } else {\r
+    gBS->LocateProtocol (\r
+          &gEfiHiiProtocolGuid,\r
+          NULL,\r
+          (VOID **) &HiiProt\r
+          );\r
+    if (HiiProt == NULL) {\r
+      return HiiHandle;\r
+    }\r
+\r
+    if (HiiProtocol != NULL) {\r
+      //\r
+      // Return back the HII protocol for the caller as promissed\r
+      //\r
+      *HiiProtocol = HiiProt;\r
+    }\r
+  }\r
+  //\r
+  // Allocate buffer\r
+  //\r
+  HiiHandleBufferLength = 10;\r
+  HiiHandleBuffer       = EfiLibAllocatePool (HiiHandleBufferLength);\r
+  ASSERT (HiiHandleBuffer != NULL);\r
+\r
+  //\r
+  // Get the Handles of the packages that were registered with Hii\r
+  //\r
+  Status = HiiProt->FindHandles (\r
+                      HiiProt,\r
+                      &HiiHandleBufferLength,\r
+                      HiiHandleBuffer\r
+                      );\r
+\r
+  //\r
+  // Get a bigger bugffer if this one is to small, and try again\r
+  //\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+\r
+    gBS->FreePool (HiiHandleBuffer);\r
+\r
+    HiiHandleBuffer = EfiLibAllocatePool (HiiHandleBufferLength);\r
+    ASSERT (HiiHandleBuffer != NULL);\r
+\r
+    Status = HiiProt->FindHandles (\r
+                        HiiProt,\r
+                        &HiiHandleBufferLength,\r
+                        HiiHandleBuffer\r
+                        );\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto lbl_exit;\r
+  }\r
+\r
+  NumberOfHiiHandles = HiiHandleBufferLength / sizeof (EFI_HII_HANDLE);\r
+\r
+  //\r
+  // Iterate Hii handles and look for the one that matches our Guid\r
+  //\r
+  for (Index = 0; Index < NumberOfHiiHandles; Index++) {\r
+\r
+    Length = 0;\r
+    ExtractDataFromHiiHandle (HiiHandleBuffer[Index], &Length, NULL, &HiiGuid);\r
+\r
+    if (EfiCompareGuid (&HiiGuid, Guid)) {\r
+\r
+      HiiHandle = HiiHandleBuffer[Index];\r
+      break;\r
+    }\r
+  }\r
+\r
+lbl_exit:\r
+  gBS->FreePool (HiiHandleBuffer);\r
+  return HiiHandle;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+ValidateDataFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      HiiHandle,\r
+  OUT     BOOLEAN             *Results\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Validate that the data associated with the HiiHandle in NVRAM is within\r
+  the reasonable parameters for that FormSet.  Values for strings and passwords\r
+  are not verified due to their not having the equivalent of valid range settings.\r
+  \r
+Arguments:\r
+\r
+  HiiHandle -   Handle of the HII database entry to query\r
+\r
+  Results -     If return Status is EFI_SUCCESS, Results provides valid data\r
+                TRUE  = NVRAM Data is within parameters\r
+                FALSE = NVRAM Data is NOT within parameters\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES      - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS               - Data successfully validated\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_HII_PROTOCOL  *Hii;\r
+  EFI_GUID          Guid;\r
+  UINT8             *RawData;\r
+  UINT8             *OldData;\r
+  UINTN             RawDataLength;\r
+  UINT8             *VariableData;\r
+  UINTN             Index;\r
+  UINTN             Temp;\r
+  UINTN             SizeOfNvStore;\r
+  UINTN             CachedStart;\r
+  BOOLEAN           GotMatch;\r
+\r
+  RawDataLength = DEFAULT_FORM_BUFFER_SIZE;\r
+  SizeOfNvStore = 0;\r
+  CachedStart   = 0;\r
+  GotMatch      = FALSE;\r
+  *Results      = TRUE;\r
+\r
+  Status        = GetHiiInterface (&Hii);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Allocate space for retrieval of IFR data\r
+  //\r
+  RawData = EfiLibAllocateZeroPool (RawDataLength);\r
+  if (RawData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Get all the forms associated with this HiiHandle\r
+  //\r
+  Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (RawData);\r
+\r
+    //\r
+    // Allocate space for retrieval of IFR data\r
+    //\r
+    RawData = EfiLibAllocateZeroPool (RawDataLength);\r
+    if (RawData == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    //\r
+    // Get all the forms associated with this HiiHandle\r
+    //\r
+    Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData);\r
+  }\r
+\r
+  OldData = RawData;\r
+\r
+  //\r
+  // Point RawData to the beginning of the form data\r
+  //\r
+  RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER));\r
+\r
+  for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {\r
+    if (RawData[Index] == EFI_IFR_FORM_SET_OP) {\r
+      EfiCopyMem (&Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));\r
+      break;\r
+    }\r
+\r
+    Index = RawData[Index + 1] + Index;\r
+  }\r
+\r
+  for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {\r
+    switch (RawData[Index]) {\r
+    case EFI_IFR_FORM_SET_OP:\r
+      break;\r
+\r
+    case EFI_IFR_ONE_OF_OP:\r
+    case EFI_IFR_CHECKBOX_OP:\r
+    case EFI_IFR_NUMERIC_OP:\r
+    case EFI_IFR_DATE_OP:\r
+    case EFI_IFR_TIME_OP:\r
+    case EFI_IFR_PASSWORD_OP:\r
+    case EFI_IFR_STRING_OP:\r
+      //\r
+      // Remember, multiple op-codes may reference the same item, so let's keep a running\r
+      // marker of what the highest QuestionId that wasn't zero length.  This will accurately\r
+      // maintain the Size of the NvStore\r
+      //\r
+      if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) {\r
+        Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;\r
+        if (SizeOfNvStore < Temp) {\r
+          SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;\r
+        }\r
+      }\r
+    }\r
+\r
+    Index = RawData[Index + 1] + Index;\r
+  }\r
+    \r
+  //\r
+  // Allocate memory for our File Form Tags\r
+  //\r
+  VariableData = EfiLibAllocateZeroPool (SizeOfNvStore);\r
+  if (VariableData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gRT->GetVariable (\r
+                  L"Setup",\r
+                  &Guid,\r
+                  NULL,\r
+                  &SizeOfNvStore,\r
+                  (VOID *) VariableData\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+\r
+    //\r
+    // If there is a variable that exists already and it is larger than what we calculated the\r
+    // storage needs to be, we must assume the variable size from GetVariable is correct and not\r
+    // allow the truncation of the variable.  It is very possible that the user who created the IFR\r
+    // we are cracking is not referring to a variable that was in a previous map, however we cannot\r
+    // allow it's truncation.\r
+    //\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      //\r
+      // Free the buffer that was allocated that was too small\r
+      //\r
+      gBS->FreePool (VariableData);\r
+\r
+      VariableData = EfiLibAllocatePool (SizeOfNvStore);\r
+      if (VariableData == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      Status = gRT->GetVariable (\r
+                      L"Setup",\r
+                      &Guid,\r
+                      NULL,\r
+                      &SizeOfNvStore,\r
+                      (VOID *) VariableData\r
+                      );\r
+    }\r
+  }\r
+\r
+  //\r
+  // Walk through the form and see that the variable data it refers to is ok.\r
+  // This allows for the possibility of stale (obsoleted) data in the variable\r
+  // can be overlooked without causing an error\r
+  //\r
+  for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {\r
+    switch (RawData[Index]) {\r
+    case EFI_IFR_ONE_OF_OP:\r
+      //\r
+      // A one_of has no data, its the option that does - cache the storage Id\r
+      //\r
+      CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId;\r
+      break;\r
+\r
+    case EFI_IFR_ONE_OF_OPTION_OP:\r
+      //\r
+      // A one_of_option can be any value\r
+      //\r
+      if (VariableData[CachedStart] == ((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value) {\r
+        GotMatch = TRUE;\r
+      }\r
+      break;\r
+\r
+    case EFI_IFR_END_ONE_OF_OP:\r
+      //\r
+      // At this point lets make sure that the data value in the NVRAM matches one of the options\r
+      //\r
+      if (!GotMatch) {\r
+        *Results = FALSE;\r
+        return EFI_SUCCESS;\r
+      }\r
+      break;\r
+\r
+    case EFI_IFR_CHECKBOX_OP:\r
+      //\r
+      // A checkbox is a boolean, so 0 and 1 are valid\r
+      // Remember, QuestionId corresponds to the offset location of the data in the variable\r
+      //\r
+      if (VariableData[((EFI_IFR_CHECK_BOX *) &RawData[Index])->QuestionId] > 1) {\r
+        *Results = FALSE;\r
+        return EFI_SUCCESS;\r
+      }\r
+      break;\r
+\r
+    case EFI_IFR_NUMERIC_OP:\r
+        if ((VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] < ((EFI_IFR_NUMERIC *)&RawData[Index])->Minimum) ||\r
+            (VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] > ((EFI_IFR_NUMERIC *)&RawData[Index])->Maximum)) {\r
+        *Results = FALSE;\r
+        return EFI_SUCCESS;\r
+      }\r
+      break;\r
+\r
+    }\r
+\r
+    Index = RawData[Index + 1] + Index;\r
+  }\r
+\r
+  //\r
+  // Free our temporary repository of form data\r
+  //\r
+  gBS->FreePool (OldData);\r
+  gBS->FreePool (VariableData);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_HII_PACKAGES *\r
+PreparePackages (\r
+  IN      UINTN               NumberOfPackages,\r
+  IN      EFI_GUID            *GuidId,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Assemble EFI_HII_PACKAGES according to the passed in packages.\r
+  \r
+Arguments:\r
+  \r
+  NumberOfPackages  -  Number of packages.\r
+  GuidId            -  Package GUID.\r
+  \r
+Returns: \r
+  \r
+  Pointer of EFI_HII_PACKAGES.\r
+  \r
+--*/\r
+{\r
+  VA_LIST           args;\r
+  EFI_HII_PACKAGES  *HiiPackages;\r
+  VOID              **Package;\r
+  UINTN             Index;\r
+\r
+  ASSERT (NumberOfPackages > 0);\r
+\r
+  HiiPackages                   = EfiLibAllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));\r
+\r
+  HiiPackages->GuidId           = GuidId;\r
+  HiiPackages->NumberOfPackages = NumberOfPackages;\r
+  Package                       = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));\r
+\r
+  VA_START (args, GuidId);\r
+\r
+  for (Index = 0; Index < NumberOfPackages; Index++) {\r
+    *Package = VA_ARG (args, VOID *);\r
+    Package++;\r
+  }\r
+\r
+  VA_END (args);\r
+\r
+  return HiiPackages;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h
new file mode 100644 (file)
index 0000000..a99bfc0
--- /dev/null
@@ -0,0 +1,1299 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  IfrLibrary.h\r
+\r
+Abstract:\r
+  The file contain all library function for Ifr Operations.\r
+\r
+--*/\r
+\r
+#ifndef _IFRLIBRARY_H\r
+#define _IFRLIBRARY_H\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+#include EFI_GUID_DEFINITION (GlobalVariable)\r
+\r
+#define DEFAULT_FORM_BUFFER_SIZE    0xFFFF\r
+#define DEFAULT_STRING_BUFFER_SIZE  0xFFFF\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  CHAR16      *OptionString;  // Passed in string to generate a token for in a truly dynamic form creation\r
+  STRING_REF  StringToken;    // This is used when creating a single op-code without generating a StringToken (have one already)\r
+  UINT16      Value;\r
+  UINT8       Flags;\r
+  UINT16      Key;\r
+} IFR_OPTION;\r
+#pragma pack()\r
+\r
+EFI_STATUS\r
+GetCurrentLanguage (\r
+  OUT     CHAR16              *Lang\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determine what is the current language setting\r
+  \r
+Arguments:\r
+\r
+  Lang      - Pointer of system language\r
+  \r
+Returns: \r
+  \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+AddString (\r
+  IN      VOID                *StringBuffer,\r
+  IN      CHAR16              *Language,\r
+  IN      CHAR16              *String,\r
+  IN OUT  STRING_REF          *StringToken\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a string to the incoming buffer and return the token and offset data\r
+  \r
+Arguments:\r
+\r
+  StringBuffer      - The incoming buffer\r
+  \r
+  Language          - Currrent language\r
+  \r
+  String            - The string to be added\r
+  \r
+  StringToken       - The index where the string placed\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - String successfully added to the incoming buffer\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+AddOpCode (\r
+  IN      VOID                *FormBuffer,\r
+  IN OUT  VOID                *OpCodeData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add op-code data to the FormBuffer\r
+  \r
+Arguments:\r
+\r
+  FormBuffer      - Form buffer to be inserted to\r
+  \r
+  OpCodeData      - Op-code data to be inserted\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - Op-code data successfully inserted\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateFormSet (\r
+  IN      CHAR16              *FormSetTitle,\r
+  IN      EFI_GUID            *Guid,\r
+  IN      UINT8               Class,\r
+  IN      UINT8               SubClass,\r
+  IN OUT  VOID                **FormBuffer,\r
+  IN OUT  VOID                **StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a formset\r
+  \r
+Arguments:\r
+\r
+  FormSetTitle        - Title of formset\r
+  \r
+  Guid                - Guid of formset\r
+  \r
+  Class               - Class of formset\r
+  \r
+  SubClass            - Sub class of formset\r
+  \r
+  FormBuffer          - Pointer of the formset created\r
+  \r
+  StringBuffer        - Pointer of FormSetTitile string created\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - Formset successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateForm (\r
+  IN      CHAR16              *FormTitle,\r
+  IN      UINT16              FormId,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a form\r
+  \r
+Arguments:\r
+\r
+  FormTitle       - Title of the form\r
+  \r
+  FormId          - Id of the form\r
+  \r
+  FormBuffer          - Pointer of the form created\r
+  \r
+  StringBuffer        - Pointer of FormTitil string created\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Form successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateSubTitle (\r
+  IN      CHAR16              *SubTitle,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a SubTitle\r
+  \r
+Arguments:\r
+\r
+  SubTitle        - Sub title to be created\r
+  \r
+  FormBuffer      - Where this subtitle to add to\r
+  \r
+  StringBuffer    - String buffer created for subtitle\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Subtitle successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateText (\r
+  IN      CHAR16              *String,\r
+  IN      CHAR16              *String2,\r
+  IN      CHAR16              *String3,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a line of text\r
+  \r
+Arguments:\r
+\r
+  String          - First string of the text\r
+  \r
+  String2         - Second string of the text\r
+  \r
+  String3         - Help string of the text\r
+  \r
+  Flags           - Flag of the text\r
+  \r
+  Key             - Key of the text\r
+  \r
+  FormBuffer      - The form where this text adds to\r
+  \r
+  StringBuffer    - String buffer created for String, String2 and String3\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Text successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateGoto (\r
+  IN      UINT16              FormId,\r
+  IN      CHAR16              *Prompt,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a hyperlink\r
+  \r
+Arguments:\r
+\r
+  FormId        - Form ID of the hyperlink\r
+  \r
+  Prompt        - Prompt of the hyperlink\r
+  \r
+  FormBuffer    - The form where this hyperlink adds to\r
+  \r
+  StringBuffer  - String buffer created for Prompt\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Hyperlink successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateOneOf (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of question with a set of options to choose from.  The\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the one-of box\r
+  \r
+  DataWidth       - DataWidth of the one-of box\r
+  \r
+  Prompt          - Prompt of the one-of box\r
+  \r
+  Help            - Help of the one-of box\r
+  \r
+  OptionsList     - Each string in it is an option of the one-of box\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - The form where this one-of box adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt, Help and Option strings\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR    - DataWidth > 2\r
+\r
+  EFI_SUCCESS         - One-Of box successfully created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateOrderedList (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               MaxEntries,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of question with a set of options to choose from.  The\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the ordered list\r
+  \r
+  MaxEntries      - MaxEntries of the ordered list\r
+  \r
+  Prompt          - Prompt of the ordered list\r
+  \r
+  Help            - Help of the ordered list\r
+  \r
+  OptionsList     - Each string in it is an option of the ordered list\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - The form where this ordered list adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt, Help and Option strings\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Ordered list successfully created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateCheckBox (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT8               Flags,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a checkbox\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the check box\r
+  \r
+  DataWidth       - DataWidth of the check box\r
+  \r
+  Prompt          - Prompt of the check box\r
+  \r
+  Help            - Help of the check box\r
+  \r
+  Flags           - Flags of the check box\r
+  \r
+  FormBuffer      - The form where this check box adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR    - DataWidth > 1\r
+\r
+  EFI_SUCCESS         - Check box successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateNumeric (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT16              Minimum,\r
+  IN      UINT16              Maximum,\r
+  IN      UINT16              Step,\r
+  IN      UINT16              Default,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the numeric\r
+  \r
+  DataWidth       - DataWidth of the numeric\r
+  \r
+  Prompt          - Prompt of the numeric\r
+  \r
+  Help            - Help of the numeric\r
+  \r
+  Minimum         - Minumun boundary of the numeric\r
+  \r
+  Maximum         - Maximum boundary of the numeric\r
+  \r
+  Step            - Step of the numeric\r
+   \r
+  Default         - Default value\r
+  \r
+  Flags           - Flags of the numeric\r
+  \r
+  Key             - Key of the numeric\r
+  \r
+  FormBuffer      - The form where this numeric adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR      - DataWidth > 2\r
+  \r
+  EFI_SUCCESS           - Numeric is successfully created\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateString (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT8               MinSize,\r
+  IN      UINT8               MaxSize,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a string\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the string\r
+  \r
+  DataWidth       - DataWidth of the string\r
+  \r
+  Prompt          - Prompt of the string\r
+  \r
+  Help            - Help of the string\r
+  \r
+  MinSize         - Min size boundary of the string\r
+  \r
+  MaxSize         - Max size boundary of the string\r
+    \r
+  Flags           - Flags of the string\r
+  \r
+  Key             - Key of the string\r
+  \r
+  FormBuffer      - The form where this string adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - String successfully created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ExtractDataFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      HiiHandle,\r
+  IN OUT  UINT16              *ImageLength,\r
+  OUT     UINT8               *DefaultImage,\r
+  OUT     EFI_GUID            *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract information pertaining to the HiiHandle\r
+  \r
+Arguments:\r
+\r
+  HiiHandle       - Hii handle\r
+  \r
+  ImageLength     - For input, length of DefaultImage;\r
+                    For output, length of actually required\r
+                    \r
+  DefaultImage    - Image buffer prepared by caller\r
+  \r
+  Guid            - Guid information about the form\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_BUFFER_TOO_SMALL    - DefualtImage has no enough ImageLength\r
+  \r
+  EFI_SUCCESS             - Successfully extract data from Hii database.\r
+  \r
+  \r
+--*/\r
+;\r
+\r
+EFI_HII_HANDLE\r
+FindHiiHandle (\r
+  IN OUT EFI_HII_PROTOCOL    **HiiProtocol, OPTIONAL\r
+  IN     EFI_GUID            *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Finds HII handle for given pack GUID previously registered with the HII.\r
+\r
+Arguments:\r
+  HiiProtocol - pointer to pointer to HII protocol interface. \r
+                If NULL, the interface will be found but not returned.\r
+                If it points to NULL, the interface will be found and \r
+                written back to the pointer that is pointed to.\r
+  Guid        - The GUID of the pack that registered with the HII.\r
+\r
+Returns:\r
+  Handle to the HII pack previously registered by the memory driver.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateSubTitleOpCode (\r
+  IN      STRING_REF          StringToken,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a SubTitle opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  StringToken     - StringToken of the subtitle\r
+  \r
+  FormBuffer      - Output of subtitle as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Subtitle created to be a form\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateTextOpCode (\r
+  IN      STRING_REF          StringToken,\r
+  IN      STRING_REF          StringTokenTwo,\r
+  IN      STRING_REF          StringTokenThree,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a Text opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  StringToken               - First string token of the text\r
+  \r
+  StringTokenTwo            - Second string token of the text\r
+  \r
+  StringTokenThree          - Help string token of the text\r
+  \r
+  Flags                     - Flag of the text\r
+  \r
+  Key                       - Key of the text\r
+  \r
+  FormBuffer                - Output of text as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - Text created to be a form\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateGotoOpCode (\r
+  IN      UINT16              FormId,\r
+  IN      STRING_REF          StringToken,\r
+  IN      STRING_REF          StringTokenTwo,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a hyperlink opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  FormId          - Form ID of the hyperlink\r
+  \r
+  StringToken     - Prompt string token of the hyperlink\r
+  \r
+  StringTokenTwo  - Help string token of the hyperlink\r
+  \r
+  Flags           - Flags of the hyperlink\r
+  \r
+  Key             - Key of the hyperlink\r
+  \r
+  FormBuffer      - Output of hyperlink as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS   - Hyperlink created to be a form\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateOneOfOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of opcode with a set of option op-codes to choose from independent of string creation.\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.  Ensure that OptionsList[x].StringToken\r
+  has been filled in since this routine will not generate StringToken values.\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the one-of box\r
+  \r
+  DataWidth       - DataWidth of the one-of box\r
+  \r
+  PromptToken     - Prompt string token of the one-of box\r
+  \r
+  HelpToken       - Help string token of the one-of box\r
+  \r
+  OptionsList     - Each string in it is an option of the one-of box\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - Output of One-Of box as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS         - One-Of box created to be a form\r
+  \r
+  EFI_DEVICE_ERROR    - DataWidth > 2\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateOrderedListOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               MaxEntries,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.  Ensure that OptionsList[x].StringToken\r
+  has been filled in since this routine will not generate StringToken values.\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the ordered list\r
+  \r
+  MaxEntries      - MaxEntries of the ordered list\r
+  \r
+  PromptToken     - Prompt string token of the ordered list\r
+  \r
+  HelpToken       - Help string token of the ordered list\r
+  \r
+  OptionsList     - Each string in it is an option of the ordered list\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - Output of ordered list as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Ordered list created to be a form\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateCheckBoxOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a checkbox opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the check box\r
+  \r
+  DataWidth       - DataWidth of the check box\r
+  \r
+  PromptToken     - Prompt string token of the check box\r
+  \r
+  HelpToken       - Help string token of the check box\r
+  \r
+  Flags           - Flags of the check box\r
+  \r
+  Key             - Key of the check box\r
+  \r
+  FormBuffer      - Output of the check box as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - Checkbox created to be a form\r
+  \r
+  EFI_DEVICE_ERROR  - DataWidth > 1\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateNumericOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT16              Minimum,\r
+  IN      UINT16              Maximum,\r
+  IN      UINT16              Step,\r
+  IN      UINT16              Default,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the numeric\r
+  \r
+  DataWidth       - DataWidth of the numeric\r
+  \r
+  PromptToken     - Prompt string token of the numeric\r
+  \r
+  HelpToken       - Help string token of the numeric\r
+  \r
+  Minimum         - Minumun boundary of the numeric\r
+  \r
+  Maximum         - Maximum boundary of the numeric\r
+  \r
+  Step            - Step of the numeric\r
+  \r
+  Default         - Default value of the numeric\r
+  \r
+  Flags           - Flags of the numeric\r
+  \r
+  Key             - Key of the numeric\r
+  \r
+  FormBuffer      - Output of the numeric as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - The numeric created to be a form.\r
+  \r
+  EFI_DEVICE_ERROR  - DataWidth > 2\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateStringOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT8               MinSize,\r
+  IN      UINT8               MaxSize,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+\r
+  QuestionId      - Question ID of the string\r
+  \r
+  DataWidth       - DataWidth of the string\r
+  \r
+  PromptToken     - Prompt token of the string\r
+  \r
+  HelpToken       - Help token of the string\r
+  \r
+  MinSize         - Min size boundary of the string\r
+  \r
+  MaxSize         - Max size boundary of the string\r
+    \r
+  Flags           - Flags of the string\r
+  \r
+  Key             - Key of the string\r
+  \r
+  FormBuffer      - Output of the string as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - String created to be a form.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ValidateDataFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      HiiHandle,\r
+  OUT     BOOLEAN             *Results\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Validate that the data associated with the HiiHandle in NVRAM is within\r
+  the reasonable parameters for that FormSet.  Values for strings and passwords\r
+  are not verified due to their not having the equivalent of valid range settings.\r
+  \r
+Arguments:\r
+\r
+  HiiHandle -   Handle of the HII database entry to query\r
+\r
+  Results -     If return Status is EFI_SUCCESS, Results provides valid data\r
+                TRUE  = NVRAM Data is within parameters\r
+                FALSE = NVRAM Data is NOT within parameters\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES      - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS               - Data successfully validated\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+CreateBannerOpCode (\r
+  IN      UINT16              Title,\r
+  IN      UINT16              LineNumber,\r
+  IN      UINT8               Alignment,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a banner opcode.  This is primarily used by the FrontPage implementation from BDS.\r
+  \r
+Arguments:\r
+\r
+  Title       - Title of the banner\r
+  \r
+  LineNumber  - LineNumber of the banner\r
+  \r
+  Alignment   - Alignment of the banner\r
+  \r
+  FormBuffer  - Output of banner as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Banner created to be a form.\r
+\r
+--*/\r
+;\r
+\r
+EFI_HII_PACKAGES  *\r
+PreparePackages (\r
+  IN      UINTN               NumberOfPackages,\r
+  IN      EFI_GUID            *GuidId,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Assemble EFI_HII_PACKAGES according to the passed in packages.\r
+  \r
+Arguments:\r
+  \r
+  NumberOfPackages  -  Number of packages.\r
+  GuidId            -  Package GUID.\r
+  \r
+Returns: \r
+  \r
+  Pointer of EFI_HII_PACKAGES.\r
+  \r
+--*/\r
+;\r
+\r
+VOID\r
+EfiLibHiiVariablePackGetMap (\r
+  IN    EFI_HII_VARIABLE_PACK        *Pack,  \r
+  OUT   CHAR16                       **Name,  OPTIONAL\r
+  OUT   EFI_GUID                     **Guid,  OPTIONAL\r
+  OUT   UINT16                       *Id,     OPTIONAL\r
+  OUT   VOID                         **Var,   OPTIONAL\r
+  OUT   UINTN                        *Size    OPTIONAL\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extracts a variable form a Pack.\r
+\r
+Arguments:\r
+\r
+  Pack - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns: \r
+\r
+  VOID.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiLibHiiVariablePackListGetMapCnt (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST   *List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a count of the variables/maps in the List.\r
+\r
+Arguments:\r
+\r
+  List - List of variables\r
+\r
+Returns: \r
+\r
+  Number of Map in the variable pack list.\r
+\r
+--*/\r
+;\r
+\r
+typedef VOID (EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK) (\r
+  IN CHAR16                      *Name,\r
+  IN EFI_GUID                    *Guid,\r
+  IN UINT16                      Id,\r
+  IN VOID                        *Var,\r
+  IN UINTN                       Size\r
+  )  \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  type definition for the callback to be \r
+  used with EfiLibHiiVariablePackListForEachVar().\r
+\r
+Arguments:\r
+\r
+  Id   - Variable/Map ID\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns: \r
+\r
+  VOID\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiLibHiiVariablePackListForEachVar (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST               *List,\r
+  IN    EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK  *Callback\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Will iterate all variable/maps as appearing \r
+  in List and for each, it will call the Callback.\r
+\r
+Arguments:\r
+\r
+  List     - List of variables\r
+  Callback - Routine to be called for each iterated variable.\r
+\r
+Returns: \r
+\r
+  VOID\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMapByIdx (\r
+  IN    UINTN                         Idx,  \r
+  IN    EFI_HII_VARIABLE_PACK_LIST    *List,  \r
+  OUT   CHAR16                        **Name,  OPTIONAL\r
+  OUT   EFI_GUID                      **Guid,  OPTIONAL\r
+  OUT   UINT16                        *Id,    OPTIONAL\r
+  OUT   VOID                          **Var,\r
+  OUT   UINTN                         *Size\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form List given \r
+  the order number as appears in the List.\r
+\r
+Arguments:\r
+\r
+  Idx  - The index of the variable/map to retrieve\r
+  List - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMapById (\r
+  IN    UINT16                        Id,  \r
+  IN    EFI_HII_VARIABLE_PACK_LIST    *List,\r
+  OUT   CHAR16                        **Name,  OPTIONAL\r
+  OUT   EFI_GUID                      **Guid,  OPTIONAL\r
+  OUT   VOID                          **Var,\r
+  OUT   UINTN                         *Size\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form List given the \r
+  order number as appears in the List.\r
+\r
+Arguments:\r
+\r
+  Id   - The ID of the variable/map to retrieve\r
+  List - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMap (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST   *List,\r
+  IN    CHAR16                       *Name,\r
+  IN    EFI_GUID                     *Guid,\r
+  OUT   UINT16                       *Id,\r
+  OUT   VOID                         **Var, \r
+  OUT   UINTN                        *Size\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID.\r
+\r
+Arguments:\r
+\r
+  List - List of variables\r
+  Name - Name of the variable/map to be found\r
+  Guid - GUID of the variable/map to be found\r
+  Var  - Pointer to the variable/map found\r
+  Size - Size of the variable/map in bytes found\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableRetrieveFromNv (\r
+  IN  CHAR16                     *Name,\r
+  IN  EFI_GUID                   *Guid,\r
+  IN  UINTN                       Size,\r
+  OUT VOID                      **Var\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Finds out if a variable of specific Name/Guid/Size exists in NV. \r
+  If it does, it will retrieve it into the Var. \r
+\r
+Arguments:\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into buffer pointed by this pointer.\r
+                     If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer.\r
+Returns:\r
+  EFI_SUCCESS    - The variable of exact Name/Guid/Size parameters was retrieved and written to Var.\r
+  EFI_NOT_FOUND  - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+;\r
+\r
+////\r
+//// Variable override support.\r
+////\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableOverrideIfSuffix (\r
+  IN  CHAR16                 *Suffix,\r
+  IN  CHAR16                 *Name,\r
+  IN  EFI_GUID               *Guid,\r
+  IN  UINTN                   Size,\r
+  OUT VOID                   *Var\r
+  )  \r
+/*++\r
+\r
+Routine Description:\r
+  Overrrides the variable with NV data if found.\r
+  But it only does it if the Name ends with specified Suffix.\r
+  For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride",\r
+  the Suffix matches the end of Name, so the variable will be loaded from NV\r
+  provided the variable exists and the GUID and Size matches.\r
+\r
+Arguments:\r
+  Suffix           - Suffix the Name should end with.\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into this buffer.\r
+                     Caller is responsible for providing storage of exactly Size size in bytes.\r
+Returns:\r
+  EFI_SUCCESS           - The variable was overriden with NV variable of same Name/Guid/Size.\r
+  EFI_INVALID_PARAMETER - The name of the variable does not end with <Suffix>.\r
+  EFI_NOT_FOUND         - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR        - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableOverrideBySuffix (\r
+  IN  CHAR16                 *Suffix,\r
+  IN  CHAR16                 *Name,\r
+  IN  EFI_GUID               *Guid,\r
+  IN  UINTN                   Size,\r
+  OUT VOID                   *Var\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Overrrides the variable with NV data if found.\r
+  But it only does it if the NV contains the same variable with Name is appended with Suffix.  \r
+  For example, if Suffix="MyOverride" and the Name="XyzSetup",\r
+  the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride"\r
+  will be loaded from NV provided the variable exists and the GUID and Size matches.\r
+\r
+Arguments:\r
+  Suffix           - Suffix the variable will be appended with.\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into this buffer.\r
+                     Caller is responsible for providing storage of exactly Size size in bytes.\r
+\r
+Returns:\r
+  EFI_SUCCESS    - The variable was overriden with NV variable of same Name/Guid/Size.\r
+  EFI_NOT_FOUND  - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c
new file mode 100644 (file)
index 0000000..51abde7
--- /dev/null
@@ -0,0 +1,974 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  IfrOnTheFly.c\r
+\r
+Abstract:\r
+\r
+  Library Routines to create IFR on-the-fly\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#include "IfrLibrary.h"\r
+\r
+EFI_STATUS\r
+CreateFormSet (\r
+  IN      CHAR16              *FormSetTitle,\r
+  IN      EFI_GUID            *Guid,\r
+  IN      UINT8               Class,\r
+  IN      UINT8               SubClass,\r
+  IN OUT  VOID                **FormBuffer,\r
+  IN OUT  VOID                **StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a formset\r
+  \r
+Arguments:\r
+  \r
+  FormSetTitle        - Title of formset\r
+  \r
+  Guid                - Guid of formset\r
+  \r
+  Class               - Class of formset\r
+  \r
+  SubClass            - Sub class of formset\r
+  \r
+  FormBuffer          - Pointer of the formset created\r
+  \r
+  StringBuffer        - Pointer of FormSetTitile string created\r
+  \r
+Returns: \r
+\r
+  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate\r
+  \r
+  EFI_SUCCESS             - Formset successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_HII_IFR_PACK      IfrPack;\r
+  EFI_IFR_FORM_SET      FormSet;\r
+  EFI_IFR_END_FORM_SET  EndFormSet;\r
+  UINT8                 *Destination;\r
+  CHAR16                CurrentLanguage[4];\r
+  STRING_REF            StringToken;\r
+\r
+  //\r
+  // Pre-allocate a buffer sufficient for us to work from.\r
+  //\r
+  FormBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);\r
+  if (FormBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Pre-allocate a buffer sufficient for us to work from.\r
+  //\r
+  StringBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);\r
+  if (StringBuffer == NULL) {\r
+    gBS->FreePool (FormBuffer);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add the FormSetTitle to the string buffer and get the StringToken\r
+  //\r
+  Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Initialize the Ifr Package header data\r
+  //\r
+  IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET);\r
+  IfrPack.Header.Type   = EFI_HII_IFR;\r
+\r
+  //\r
+  // Initialize FormSet with the appropriate information\r
+  //\r
+  FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP;\r
+  FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET);\r
+  FormSet.FormSetTitle  = StringToken;\r
+  FormSet.Class         = Class;\r
+  FormSet.SubClass      = SubClass;\r
+  EfiCopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID));\r
+\r
+  //\r
+  // Initialize the end formset data\r
+  //\r
+  EndFormSet.Header.Length  = sizeof (EFI_IFR_END_FORM_SET);\r
+  EndFormSet.Header.OpCode  = EFI_IFR_END_FORM_SET_OP;\r
+\r
+  Destination               = (CHAR8 *) *FormBuffer;\r
+\r
+  //\r
+  // Copy the formset/endformset data to the form buffer\r
+  //\r
+  EfiCopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));\r
+\r
+  Destination = Destination + sizeof (EFI_HII_PACK_HEADER);\r
+\r
+  EfiCopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET));\r
+\r
+  Destination = Destination + sizeof (EFI_IFR_FORM_SET);\r
+\r
+  EfiCopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET));\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateForm (\r
+  IN      CHAR16              *FormTitle,\r
+  IN      UINT16              FormId,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a form\r
+  \r
+Arguments:\r
+  \r
+  FormTitle       - Title of the form\r
+  \r
+  FormId          - Id of the form\r
+  \r
+  FormBuffer          - Pointer of the form created\r
+  \r
+  StringBuffer        - Pointer of FormTitil string created\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Form successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_IFR_FORM      Form;\r
+  EFI_IFR_END_FORM  EndForm;\r
+  CHAR16            CurrentLanguage[4];\r
+  STRING_REF        StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Form.Header.OpCode  = EFI_IFR_FORM_OP;\r
+  Form.Header.Length  = sizeof (EFI_IFR_FORM);\r
+  Form.FormId         = FormId;\r
+  Form.FormTitle      = StringToken;\r
+\r
+  Status              = AddOpCode (FormBuffer, &Form);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  EndForm.Header.OpCode = EFI_IFR_END_FORM_OP;\r
+  EndForm.Header.Length = sizeof (EFI_IFR_END_FORM);\r
+\r
+  Status                = AddOpCode (FormBuffer, &EndForm);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateSubTitle (\r
+  IN      CHAR16              *SubTitle,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a SubTitle\r
+  \r
+Arguments:\r
+  \r
+  SubTitle        - Sub title to be created\r
+  \r
+  FormBuffer      - Where this subtitle to add to\r
+  \r
+  StringBuffer    - String buffer created for subtitle\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Subtitle successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_IFR_SUBTITLE  Subtitle;\r
+  CHAR16            CurrentLanguage[4];\r
+  STRING_REF        StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Subtitle.Header.OpCode  = EFI_IFR_SUBTITLE_OP;\r
+  Subtitle.Header.Length  = sizeof (EFI_IFR_SUBTITLE);\r
+  Subtitle.SubTitle       = StringToken;\r
+\r
+  Status                  = AddOpCode (FormBuffer, &Subtitle);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateText (\r
+  IN      CHAR16              *String,\r
+  IN      CHAR16              *String2,\r
+  IN      CHAR16              *String3,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a line of text\r
+  \r
+Arguments:\r
+  \r
+  String          - First string of the text\r
+  \r
+  String2         - Second string of the text\r
+  \r
+  String3         - Help string of the text\r
+  \r
+  Flags           - Flag of the text\r
+  \r
+  Key             - Key of the text\r
+  \r
+  FormBuffer      - The form where this text adds to\r
+  \r
+  StringBuffer    - String buffer created for String, String2 and String3\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Text successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_IFR_TEXT  Text;\r
+  CHAR16        CurrentLanguage[4];\r
+  STRING_REF    StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Text.Header.OpCode  = EFI_IFR_TEXT_OP;\r
+  Text.Header.Length  = sizeof (EFI_IFR_TEXT);\r
+  Text.Text           = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Text.TextTwo  = StringToken;\r
+\r
+  Text.Flags    = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);\r
+  Text.Key      = Key;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Text.Help = StringToken;\r
+\r
+  Status    = AddOpCode (FormBuffer, &Text);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateGoto (\r
+  IN      UINT16              FormId,\r
+  IN      CHAR16              *Prompt,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a hyperlink\r
+  \r
+Arguments:\r
+  \r
+  FormId        - Form ID of the hyperlink\r
+  \r
+  Prompt        - Prompt of the hyperlink\r
+  \r
+  FormBuffer    - The form where this hyperlink adds to\r
+  \r
+  StringBuffer  - String buffer created for Prompt\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Hyperlink successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_IFR_REF Hyperlink;\r
+  CHAR16      CurrentLanguage[4];\r
+  STRING_REF  StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Hyperlink.Header.OpCode = EFI_IFR_REF_OP;\r
+  Hyperlink.Header.Length = sizeof (EFI_IFR_REF);\r
+  Hyperlink.FormId        = FormId;\r
+  Hyperlink.Prompt        = StringToken;\r
+\r
+  Status                  = AddOpCode (FormBuffer, &Hyperlink);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateOneOf (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of question with a set of options to choose from.  The\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the one-of box\r
+  \r
+  DataWidth       - DataWidth of the one-of box\r
+  \r
+  Prompt          - Prompt of the one-of box\r
+  \r
+  Help            - Help of the one-of box\r
+  \r
+  OptionsList     - Each string in it is an option of the one-of box\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - The form where this one-of box adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt, Help and Option strings\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR    - DataWidth > 2\r
+\r
+  EFI_SUCCESS         - One-Of box successfully created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  UINTN                 Index;\r
+  EFI_IFR_ONE_OF        OneOf;\r
+  EFI_IFR_ONE_OF_OPTION OneOfOption;\r
+  EFI_IFR_END_ONE_OF    EndOneOf;\r
+  CHAR16                CurrentLanguage[4];\r
+  STRING_REF            StringToken;\r
+\r
+  //\r
+  // We do not create op-code storage widths for one-of in excess of 16 bits for now\r
+  //\r
+  if (DataWidth > 2) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;\r
+  OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);\r
+  OneOf.QuestionId    = QuestionId;\r
+  OneOf.Width         = DataWidth;\r
+  OneOf.Prompt        = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  OneOf.Help  = StringToken;\r
+\r
+  Status      = AddOpCode (FormBuffer, &OneOf);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionCount; Index++) {\r
+    OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;\r
+    OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);\r
+\r
+    //\r
+    // Add string and get token back\r
+    //\r
+    Status              = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);\r
+\r
+    OneOfOption.Option  = StringToken;\r
+    OneOfOption.Value   = OptionsList[Index].Value;\r
+    OneOfOption.Flags   = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);\r
+    OneOfOption.Key     = OptionsList[Index].Key;\r
+\r
+    Status              = AddOpCode (FormBuffer, &OneOfOption);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  EndOneOf.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);\r
+  EndOneOf.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;\r
+\r
+  Status                  = AddOpCode (FormBuffer, &EndOneOf);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CreateOrderedList (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               MaxEntries,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of question with a set of options to choose from.  The\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the ordered list\r
+  \r
+  MaxEntries      - MaxEntries of the ordered list\r
+  \r
+  Prompt          - Prompt of the ordered list\r
+  \r
+  Help            - Help of the ordered list\r
+  \r
+  OptionsList     - Each string in it is an option of the ordered list\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - The form where this ordered list adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt, Help and Option strings\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Ordered list successfully created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  UINTN                 Index;\r
+  EFI_IFR_ORDERED_LIST  OrderedList;\r
+  EFI_IFR_ONE_OF_OPTION OrderedListOption;\r
+  EFI_IFR_END_ONE_OF    EndOrderedList;\r
+  CHAR16                CurrentLanguage[4];\r
+  STRING_REF            StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;\r
+  OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);\r
+  OrderedList.QuestionId    = QuestionId;\r
+  OrderedList.MaxEntries    = MaxEntries;\r
+  OrderedList.Prompt        = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  OrderedList.Help  = StringToken;\r
+\r
+  Status            = AddOpCode (FormBuffer, &OrderedList);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionCount; Index++) {\r
+    OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;\r
+    OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);\r
+\r
+    //\r
+    // Add string and get token back\r
+    //\r
+    Status                    = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);\r
+\r
+    OrderedListOption.Option  = StringToken;\r
+    OrderedListOption.Value   = OptionsList[Index].Value;\r
+    OrderedListOption.Flags   = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);\r
+    OrderedListOption.Key     = OptionsList[Index].Key;\r
+\r
+    Status                    = AddOpCode (FormBuffer, &OrderedListOption);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  EndOrderedList.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);\r
+  EndOrderedList.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;\r
+\r
+  Status                        = AddOpCode (FormBuffer, &EndOrderedList);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateCheckBox (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT8               Flags,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a checkbox\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the check box\r
+  \r
+  DataWidth       - DataWidth of the check box\r
+  \r
+  Prompt          - Prompt of the check box\r
+  \r
+  Help            - Help of the check box\r
+  \r
+  Flags           - Flags of the check box\r
+  \r
+  FormBuffer      - The form where this check box adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR    - DataWidth > 1\r
+\r
+  EFI_SUCCESS         - Check box successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_IFR_CHECK_BOX CheckBox;\r
+  CHAR16            CurrentLanguage[4];\r
+  STRING_REF        StringToken;\r
+\r
+  //\r
+  // We do not create op-code storage widths for checkbox in excess of 8 bits for now\r
+  //\r
+  if (DataWidth > 1) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CheckBox.Header.OpCode  = EFI_IFR_CHECKBOX_OP;\r
+  CheckBox.Header.Length  = sizeof (EFI_IFR_CHECK_BOX);\r
+  CheckBox.QuestionId     = QuestionId;\r
+  CheckBox.Width          = DataWidth;\r
+  CheckBox.Prompt         = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CheckBox.Help   = StringToken;\r
+  CheckBox.Flags  = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);\r
+\r
+  Status          = AddOpCode (FormBuffer, &CheckBox);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateNumeric (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT16              Minimum,\r
+  IN      UINT16              Maximum,\r
+  IN      UINT16              Step,\r
+  IN      UINT16              Default,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the numeric\r
+  \r
+  DataWidth       - DataWidth of the numeric\r
+  \r
+  Prompt          - Prompt of the numeric\r
+  \r
+  Help            - Help of the numeric\r
+  \r
+  Minimum         - Minumun boundary of the numeric\r
+  \r
+  Maximum         - Maximum boundary of the numeric\r
+  \r
+  Step            - Step of the numeric\r
+  \r
+  Default         - Default value\r
+  \r
+  Flags           - Flags of the numeric\r
+  \r
+  Key             - Key of the numeric\r
+  \r
+  FormBuffer      - The form where this numeric adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_DEVICE_ERROR      - DataWidth > 2\r
+  \r
+  EFI_SUCCESS           - Numeric is successfully created\r
+\r
+--*/\r
+{\r
+  EFI_STATUS      Status;\r
+  EFI_IFR_NUMERIC Numeric;\r
+  CHAR16          CurrentLanguage[4];\r
+  STRING_REF      StringToken;\r
+\r
+  //\r
+  // We do not create op-code storage widths for numerics in excess of 16 bits for now\r
+  //\r
+  if (DataWidth > 2) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;\r
+  Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);\r
+  Numeric.QuestionId    = QuestionId;\r
+  Numeric.Width         = DataWidth;\r
+  Numeric.Prompt        = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Numeric.Help    = StringToken;\r
+  Numeric.Minimum = Minimum;\r
+  Numeric.Maximum = Maximum;\r
+  Numeric.Step    = Step;\r
+  Numeric.Default = Default;\r
+  Numeric.Flags   = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);\r
+  Numeric.Key     = Key;\r
+\r
+  Status          = AddOpCode (FormBuffer, &Numeric);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateString (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      CHAR16              *Prompt,\r
+  IN      CHAR16              *Help,\r
+  IN      UINT8               MinSize,\r
+  IN      UINT8               MaxSize,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer,\r
+  IN OUT  VOID                *StringBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a string\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the string\r
+  \r
+  DataWidth       - DataWidth of the string\r
+  \r
+  Prompt          - Prompt of the string\r
+  \r
+  Help            - Help of the string\r
+  \r
+  MinSize         - Min size boundary of the string\r
+  \r
+  MaxSize         - Max size boundary of the string\r
+    \r
+  Flags           - Flags of the string\r
+  \r
+  Key             - Key of the string\r
+  \r
+  FormBuffer      - The form where this string adds to\r
+  \r
+  StringBuffer    - String buffer created for Prompt and Help.\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - String successfully created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS      Status;\r
+  EFI_IFR_STRING  String;\r
+  CHAR16          CurrentLanguage[4];\r
+  STRING_REF      StringToken;\r
+\r
+  //\r
+  // Obtain current language value\r
+  //\r
+  GetCurrentLanguage (CurrentLanguage);\r
+\r
+  //\r
+  // Add first string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  String.Header.OpCode  = EFI_IFR_STRING_OP;\r
+  String.Header.Length  = sizeof (EFI_IFR_STRING);\r
+  String.QuestionId     = QuestionId;\r
+  String.Width          = DataWidth;\r
+  String.Prompt         = StringToken;\r
+\r
+  //\r
+  // Add second string, get first string's token\r
+  //\r
+  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  String.Help     = StringToken;\r
+  String.MinSize  = MinSize;\r
+  String.MaxSize  = MaxSize;\r
+  String.Flags    = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);\r
+  String.Key      = Key;\r
+\r
+  Status          = AddOpCode (FormBuffer, &String);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
new file mode 100644 (file)
index 0000000..4241637
--- /dev/null
@@ -0,0 +1,615 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  IfrOpCodeCreation.c\r
+\r
+Abstract:\r
+\r
+  Library Routines to create IFR independent of string data - assume tokens already exist\r
+  Primarily to be used for exporting op-codes at a label in pre-defined forms.\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#include "IfrLibrary.h"\r
+\r
+EFI_STATUS\r
+CreateSubTitleOpCode (\r
+  IN      STRING_REF          StringToken,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a SubTitle opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  StringToken     - StringToken of the subtitle\r
+  \r
+  FormBuffer      - Output of subtitle as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Subtitle created to be a form\r
+\r
+--*/\r
+{\r
+  EFI_IFR_SUBTITLE  Subtitle;\r
+\r
+  Subtitle.Header.OpCode  = EFI_IFR_SUBTITLE_OP;\r
+  Subtitle.Header.Length  = sizeof (EFI_IFR_SUBTITLE);\r
+  Subtitle.SubTitle       = StringToken;\r
+\r
+  EfiCopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateTextOpCode (\r
+  IN      STRING_REF          StringToken,\r
+  IN      STRING_REF          StringTokenTwo,\r
+  IN      STRING_REF          StringTokenThree,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a Text opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  StringToken               - First string token of the text\r
+  \r
+  StringTokenTwo            - Second string token of the text\r
+  \r
+  StringTokenThree          - Help string token of the text\r
+  \r
+  Flags                     - Flag of the text\r
+  \r
+  Key                       - Key of the text\r
+  \r
+  FormBuffer                - Output of text as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - Text created to be a form\r
+\r
+--*/\r
+{\r
+  EFI_IFR_TEXT  Text;\r
+\r
+  Text.Header.OpCode  = EFI_IFR_TEXT_OP;\r
+  Text.Header.Length  = sizeof (EFI_IFR_TEXT);\r
+  Text.Text           = StringToken;\r
+\r
+  Text.TextTwo        = StringTokenTwo;\r
+  Text.Help           = StringTokenThree;\r
+  Text.Flags          = Flags;\r
+  Text.Key            = Key;\r
+\r
+  EfiCopyMem (FormBuffer, &Text, sizeof (EFI_IFR_TEXT));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateGotoOpCode (\r
+  IN      UINT16              FormId,\r
+  IN      STRING_REF          StringToken,\r
+  IN      STRING_REF          StringTokenTwo,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a hyperlink opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  FormId          - Form ID of the hyperlink\r
+  \r
+  StringToken     - Prompt string token of the hyperlink\r
+  \r
+  StringTokenTwo  - Help string token of the hyperlink\r
+  \r
+  Flags           - Flags of the hyperlink\r
+  \r
+  Key             - Key of the hyperlink\r
+  \r
+  FormBuffer      - Output of hyperlink as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS   - Hyperlink created to be a form\r
+\r
+--*/\r
+{\r
+  EFI_IFR_REF Hyperlink;\r
+\r
+  Hyperlink.Header.OpCode = EFI_IFR_REF_OP;\r
+  Hyperlink.Header.Length = sizeof (EFI_IFR_REF);\r
+  Hyperlink.FormId        = FormId;\r
+  Hyperlink.Prompt        = StringToken;\r
+  Hyperlink.Help          = StringTokenTwo;\r
+  Hyperlink.Key           = Key;\r
+  Hyperlink.Flags         = Flags;\r
+\r
+  EfiCopyMem (FormBuffer, &Hyperlink, sizeof (EFI_IFR_REF));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateOneOfOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a one-of opcode with a set of option op-codes to choose from independent of string creation.\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.  Ensure that OptionsList[x].StringToken\r
+  has been filled in since this routine will not generate StringToken values.\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the one-of box\r
+  \r
+  DataWidth       - DataWidth of the one-of box\r
+  \r
+  PromptToken     - Prompt string token of the one-of box\r
+  \r
+  HelpToken       - Help string token of the one-of box\r
+  \r
+  OptionsList     - Each string in it is an option of the one-of box\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - Output of One-Of box as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS         - One-Of box created to be a form\r
+  \r
+  EFI_DEVICE_ERROR    - DataWidth > 2\r
+\r
+--*/\r
+{\r
+  UINTN                 Index;\r
+  EFI_IFR_ONE_OF        OneOf;\r
+  EFI_IFR_ONE_OF_OPTION OneOfOption;\r
+  EFI_IFR_END_ONE_OF    EndOneOf;\r
+  UINT8                 *LocalBuffer;\r
+\r
+  //\r
+  // We do not create op-code storage widths for one-of in excess of 16 bits for now\r
+  //\r
+  if (DataWidth > 2) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;\r
+  OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);\r
+  OneOf.QuestionId    = QuestionId;\r
+  OneOf.Width         = DataWidth;\r
+  OneOf.Prompt        = PromptToken;\r
+\r
+  OneOf.Help          = HelpToken;\r
+\r
+  LocalBuffer         = (CHAR8 *) FormBuffer;\r
+\r
+  EfiCopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));\r
+\r
+  LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF));\r
+\r
+  for (Index = 0; Index < OptionCount; Index++) {\r
+    OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;\r
+    OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);\r
+\r
+    OneOfOption.Option        = OptionsList[Index].StringToken;\r
+    OneOfOption.Value         = OptionsList[Index].Value;\r
+    OneOfOption.Flags         = OptionsList[Index].Flags;\r
+    OneOfOption.Key           = OptionsList[Index].Key;\r
+\r
+    EfiCopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));\r
+\r
+    LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));\r
+  }\r
+\r
+  EndOneOf.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);\r
+  EndOneOf.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;\r
+\r
+  EfiCopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF));\r
+\r
+  LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CreateOrderedListOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               MaxEntries,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      IFR_OPTION          *OptionsList,\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+\r
+  OptionsList is a pointer to a null-terminated list of option descriptions.  Ensure that OptionsList[x].StringToken\r
+  has been filled in since this routine will not generate StringToken values.\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the ordered list\r
+  \r
+  MaxEntries      - MaxEntries of the ordered list\r
+  \r
+  PromptToken     - Prompt string token of the ordered list\r
+  \r
+  HelpToken       - Help string token of the ordered list\r
+  \r
+  OptionsList     - Each string in it is an option of the ordered list\r
+  \r
+  OptionCount     - Option string count\r
+  \r
+  FormBuffer      - Output of ordered list as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Ordered list created to be a form\r
+\r
+--*/\r
+{\r
+  UINTN                 Index;\r
+  EFI_IFR_ORDERED_LIST  OrderedList;\r
+  EFI_IFR_ONE_OF_OPTION OrderedListOption;\r
+  EFI_IFR_END_ONE_OF    EndOrderedList;\r
+  UINT8                 *LocalBuffer;\r
+\r
+  OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;\r
+  OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);\r
+  OrderedList.QuestionId    = QuestionId;\r
+  OrderedList.MaxEntries    = MaxEntries;\r
+  OrderedList.Prompt        = PromptToken;\r
+\r
+  OrderedList.Help          = HelpToken;\r
+\r
+  LocalBuffer               = (CHAR8 *) FormBuffer;\r
+\r
+  EfiCopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));\r
+\r
+  LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ORDERED_LIST));\r
+\r
+  for (Index = 0; Index < OptionCount; Index++) {\r
+    OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;\r
+    OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);\r
+\r
+    OrderedListOption.Option        = OptionsList[Index].StringToken;\r
+    OrderedListOption.Value         = OptionsList[Index].Value;\r
+    OrderedListOption.Flags         = OptionsList[Index].Flags;\r
+    OrderedListOption.Key           = OptionsList[Index].Key;\r
+\r
+    EfiCopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION));\r
+\r
+    LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));\r
+  }\r
+\r
+  EndOrderedList.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);\r
+  EndOrderedList.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;\r
+\r
+  EfiCopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF));\r
+\r
+  LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CreateCheckBoxOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a checkbox opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the check box\r
+  \r
+  DataWidth       - DataWidth of the check box\r
+  \r
+  PromptToken     - Prompt string token of the check box\r
+  \r
+  HelpToken       - Help string token of the check box\r
+  \r
+  Flags           - Flags of the check box\r
+  \r
+  Key             - Key of the check box\r
+  \r
+  FormBuffer      - Output of the check box as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - Checkbox created to be a form\r
+  \r
+  EFI_DEVICE_ERROR  - DataWidth > 1\r
+\r
+--*/\r
+{\r
+  EFI_IFR_CHECK_BOX CheckBox;\r
+\r
+  //\r
+  // We do not create op-code storage widths for checkbox in excess of 8 bits for now\r
+  //\r
+  if (DataWidth > 1) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  CheckBox.Header.OpCode  = EFI_IFR_CHECKBOX_OP;\r
+  CheckBox.Header.Length  = sizeof (EFI_IFR_CHECK_BOX);\r
+  CheckBox.QuestionId     = QuestionId;\r
+  CheckBox.Width          = DataWidth;\r
+  CheckBox.Prompt         = PromptToken;\r
+\r
+  CheckBox.Help           = HelpToken;\r
+  CheckBox.Flags          = Flags;\r
+  CheckBox.Key            = Key;\r
+\r
+  EfiCopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECK_BOX));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateNumericOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT16              Minimum,\r
+  IN      UINT16              Maximum,\r
+  IN      UINT16              Step,\r
+  IN      UINT16              Default,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the numeric\r
+  \r
+  DataWidth       - DataWidth of the numeric\r
+  \r
+  PromptToken     - Prompt string token of the numeric\r
+  \r
+  HelpToken       - Help string token of the numeric\r
+  \r
+  Minimum         - Minumun boundary of the numeric\r
+  \r
+  Maximum         - Maximum boundary of the numeric\r
+  \r
+  Step            - Step of the numeric\r
+  \r
+  Default         - Default value of the numeric\r
+  \r
+  Flags           - Flags of the numeric\r
+  \r
+  Key             - Key of the numeric\r
+  \r
+  FormBuffer      - Output of the numeric as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - The numeric created to be a form.\r
+  \r
+  EFI_DEVICE_ERROR  - DataWidth > 2\r
+\r
+--*/\r
+{\r
+  EFI_IFR_NUMERIC Numeric;\r
+\r
+  //\r
+  // We do not create op-code storage widths for numerics in excess of 16 bits for now\r
+  //\r
+  if (DataWidth > 2) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;\r
+  Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);\r
+  Numeric.QuestionId    = QuestionId;\r
+  Numeric.Width         = DataWidth;\r
+  Numeric.Prompt        = PromptToken;\r
+\r
+  Numeric.Help          = HelpToken;\r
+  Numeric.Minimum       = Minimum;\r
+  Numeric.Maximum       = Maximum;\r
+  Numeric.Step          = Step;\r
+  Numeric.Default       = Default;\r
+  Numeric.Flags         = Flags;\r
+  Numeric.Key           = Key;\r
+\r
+  EfiCopyMem (FormBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateStringOpCode (\r
+  IN      UINT16              QuestionId,\r
+  IN      UINT8               DataWidth,\r
+  IN      STRING_REF          PromptToken,\r
+  IN      STRING_REF          HelpToken,\r
+  IN      UINT8               MinSize,\r
+  IN      UINT8               MaxSize,\r
+  IN      UINT8               Flags,\r
+  IN      UINT16              Key,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a numeric opcode independent of string creation\r
+  This is used primarily by users who need to create just one particular valid op-code and the string\r
+  data will be assumed to exist in the HiiDatabase already.  (Useful when exporting op-codes at a label\r
+  location to pre-defined forms in HII)\r
+  \r
+Arguments:\r
+  \r
+  QuestionId      - Question ID of the string\r
+  \r
+  DataWidth       - DataWidth of the string\r
+  \r
+  PromptToken     - Prompt token of the string\r
+  \r
+  HelpToken       - Help token of the string\r
+  \r
+  MinSize         - Min size boundary of the string\r
+  \r
+  MaxSize         - Max size boundary of the string\r
+    \r
+  Flags           - Flags of the string\r
+  \r
+  Key             - Key of the string\r
+  \r
+  FormBuffer      - Output of the string as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS       - String created to be a form.\r
+\r
+--*/\r
+{\r
+  EFI_IFR_STRING  String;\r
+\r
+  String.Header.OpCode  = EFI_IFR_STRING_OP;\r
+  String.Header.Length  = sizeof (EFI_IFR_STRING);\r
+  String.QuestionId     = QuestionId;\r
+  String.Width          = DataWidth;\r
+  String.Prompt         = PromptToken;\r
+\r
+  String.Help           = HelpToken;\r
+  String.MinSize        = MinSize;\r
+  String.MaxSize        = MaxSize;\r
+  String.Flags          = Flags;\r
+  String.Key            = Key;\r
+\r
+  EfiCopyMem (FormBuffer, &String, sizeof (EFI_IFR_STRING));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CreateBannerOpCode (\r
+  IN      UINT16              Title,\r
+  IN      UINT16              LineNumber,\r
+  IN      UINT8               Alignment,\r
+  IN OUT  VOID                *FormBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a banner opcode.  This is primarily used by the FrontPage implementation from BDS.\r
+  \r
+Arguments:\r
+  \r
+  Title       - Title of the banner\r
+  \r
+  LineNumber  - LineNumber of the banner\r
+  \r
+  Alignment   - Alignment of the banner\r
+  \r
+  FormBuffer  - Output of banner as a form\r
+  \r
+Returns: \r
+\r
+  EFI_SUCCESS     - Banner created to be a form.\r
+\r
+--*/\r
+{\r
+  EFI_IFR_BANNER  Banner;\r
+\r
+  Banner.Header.OpCode  = EFI_IFR_BANNER_OP;\r
+  Banner.Header.Length  = sizeof (EFI_IFR_BANNER);\r
+  EfiCopyMem (&Banner.Title, &Title, sizeof (UINT16));\r
+  EfiCopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16));\r
+  Banner.Alignment = Alignment;\r
+\r
+  EfiCopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c
new file mode 100644 (file)
index 0000000..1340daf
--- /dev/null
@@ -0,0 +1,488 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  IfrVariable.c\r
+\r
+Abstract:\r
+  Variable/Map manipulations routines\r
+\r
+--*/\r
+\r
+#include "IfrLibrary.h"\r
+\r
+VOID\r
+EfiLibHiiVariablePackGetMap (\r
+  IN    EFI_HII_VARIABLE_PACK       *Pack,  \r
+  OUT   CHAR16                      **Name,  OPTIONAL\r
+  OUT   EFI_GUID                    **Guid,  OPTIONAL\r
+  OUT   UINT16                      *Id,     OPTIONAL\r
+  OUT   VOID                        **Var,   OPTIONAL\r
+  OUT   UINTN                       *Size    OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extracts a variable form a Pack.\r
+\r
+Arguments:\r
+\r
+  Pack - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns: \r
+\r
+  VOID\r
+  \r
+--*/\r
+{\r
+  if (NULL != Name) {\r
+    *Name = (VOID *) (Pack + 1);\r
+  }\r
+    \r
+  if (NULL != Guid) { \r
+    *Guid = &Pack->VariableGuid;\r
+  }\r
+    \r
+    \r
+  if (NULL != Id) {\r
+    *Id   = Pack->VariableId;\r
+  }\r
+    \r
+  if (NULL != Var) {\r
+    *Var  = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength);\r
+  }\r
+    \r
+  if (NULL != Size) {\r
+    *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength;\r
+  }\r
+}\r
+\r
+\r
+UINTN\r
+EfiLibHiiVariablePackListGetMapCnt (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST   *List\r
+  )\r
+  \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a count of the variables/maps in the List.\r
+\r
+Arguments:\r
+\r
+  List - List of variables\r
+\r
+Returns: \r
+\r
+  UINTN - The number of map count.\r
+\r
+--*/\r
+\r
+{\r
+  UINTN   Cnt = 0;\r
+  while (NULL != List) {\r
+    Cnt++;\r
+    List = List->NextVariablePack;\r
+  }\r
+  return Cnt;\r
+}\r
+\r
+\r
+VOID\r
+EfiLibHiiVariablePackListForEachVar (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST               *List,\r
+  IN    EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK  *Callback\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Will iterate all variable/maps as appearing \r
+  in List and for each, it will call the Callback.\r
+\r
+Arguments:\r
+\r
+  List     - List of variables\r
+  Callback - Routine to be called for each iterated variable.\r
+\r
+Returns: \r
+\r
+  VOID\r
+  \r
+--*/\r
+\r
+{\r
+  CHAR16    *MapName;\r
+  EFI_GUID  *MapGuid;\r
+  UINT16    MapId;\r
+  VOID      *Map;\r
+  UINTN     MapSize;\r
+\r
+  while (NULL != List) {\r
+    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
+    //\r
+    // call the callback\r
+    //\r
+    Callback (MapName, MapGuid, MapId, Map, MapSize); \r
+    List = List->NextVariablePack;\r
+  }\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMapByIdx (\r
+  IN    UINTN                       Idx,  \r
+  IN    EFI_HII_VARIABLE_PACK_LIST  *List,  \r
+  OUT   CHAR16                      **Name,  OPTIONAL\r
+  OUT   EFI_GUID                    **Guid,  OPTIONAL\r
+  OUT   UINT16                      *Id,     OPTIONAL\r
+  OUT   VOID                        **Var,\r
+  OUT   UINTN                       *Size\r
+  )\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form List given \r
+  the order number as appears in the List.\r
+\r
+Arguments:\r
+\r
+  Idx  - The index of the variable/map to retrieve\r
+  List - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+{\r
+  CHAR16     *MapName;\r
+  EFI_GUID   *MapGuid;\r
+  UINT16     MapId;\r
+  VOID       *Map;\r
+  UINTN      MapSize;\r
+\r
+  while (NULL != List) {\r
+    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
+    if (0 == Idx--) {\r
+      *Var  = Map;\r
+      *Size = MapSize;\r
+\r
+      if (NULL != Name) {\r
+        *Name = MapName;\r
+      }\r
+\r
+      if (NULL != Guid) {\r
+        *Guid = MapGuid;\r
+      }\r
+        \r
+      if (NULL != Id) {\r
+        *Id   = MapId;\r
+      }\r
+        \r
+      return EFI_SUCCESS; // Map found\r
+    }\r
+    List = List->NextVariablePack;\r
+  }\r
+  //\r
+  // If here, the map is not found\r
+  //\r
+  return EFI_NOT_FOUND; \r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMapById (\r
+  IN    UINT16                        Id,  \r
+  IN    EFI_HII_VARIABLE_PACK_LIST    *List,\r
+  OUT   CHAR16                        **Name,  OPTIONAL\r
+  OUT   EFI_GUID                      **Guid,  OPTIONAL\r
+  OUT   VOID                          **Var,\r
+  OUT   UINTN                         *Size\r
+  )\r
+  \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form List given the \r
+  order number as appears in the List.\r
+\r
+Arguments:\r
+\r
+  Id   - The ID of the variable/map to retrieve\r
+  List - List of variables\r
+  Name - Name of the variable/map\r
+  Guid - GUID of the variable/map\r
+  Var  - Pointer to the variable/map\r
+  Size - Size of the variable/map in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+\r
+{ \r
+  CHAR16    *MapName;\r
+  EFI_GUID  *MapGuid;\r
+  UINT16    MapId;\r
+  VOID      *Map;\r
+  UINTN     MapSize;\r
+\r
+  while (NULL != List) {\r
+    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
+    if (MapId == Id) {\r
+      *Var  = Map;\r
+      *Size = MapSize;\r
+      if (NULL != Name) {\r
+         *Name = MapName;\r
+      }\r
+      if (NULL != Guid) {\r
+        *Guid = MapGuid;\r
+      }\r
+      //\r
+      // Map found\r
+      //\r
+      return EFI_SUCCESS; \r
+    }\r
+    List = List->NextVariablePack;\r
+  }\r
+  //\r
+  // If here, the map is not found\r
+  //\r
+  return EFI_NOT_FOUND; \r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariablePackListGetMap (\r
+  IN    EFI_HII_VARIABLE_PACK_LIST   *List,\r
+  IN    CHAR16                       *Name,\r
+  IN    EFI_GUID                     *Guid,\r
+  OUT   UINT16                       *Id,\r
+  OUT   VOID                         **Var, \r
+  OUT   UINTN                        *Size\r
+  )\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID.\r
+\r
+Arguments:\r
+\r
+  List - List of variables\r
+  Name - Name of the variable/map to be found\r
+  Guid - GUID of the variable/map to be found\r
+  Var  - Pointer to the variable/map found\r
+  Size - Size of the variable/map in bytes found\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - variable is found, OUT parameters are valid\r
+  EFI_NOT_FOUND - variable is not found, OUT parameters are not valid\r
+\r
+--*/\r
+\r
+{ \r
+  VOID      *Map;\r
+  UINTN     MapSize;\r
+  UINT16    MapId;\r
+  CHAR16    *MapName;\r
+  EFI_GUID  *MapGuid;\r
+\r
+  while (NULL != List) {\r
+    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
+    if ((0 == EfiStrCmp (Name, MapName)) && EfiCompareGuid (Guid, MapGuid)) {\r
+      *Id   = MapId;\r
+      *Var  = Map;\r
+      *Size = MapSize;\r
+      return EFI_SUCCESS;\r
+    }\r
+    List = List->NextVariablePack;\r
+  }\r
+  //\r
+  // If here, the map is not found\r
+  //\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableRetrieveFromNv (\r
+  IN  CHAR16                 *Name,\r
+  IN  EFI_GUID               *Guid,\r
+  IN  UINTN                   Size,\r
+  OUT VOID                  **Var\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Finds out if a variable of specific Name/Guid/Size exists in NV. \r
+  If it does, it will retrieve it into the Var. \r
+\r
+Arguments:\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into buffer pointed by this pointer.\r
+                     If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer.\r
+Returns:\r
+  EFI_SUCCESS    - The variable of exact Name/Guid/Size parameters was retrieved and written to Var.\r
+  EFI_NOT_FOUND  - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  UINTN                       SizeNv;\r
+\r
+  //\r
+  // Test for existence of the variable.\r
+  //\r
+  SizeNv = 0;\r
+  Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL);\r
+  if (EFI_BUFFER_TOO_SMALL != Status) {\r
+    ASSERT (EFI_SUCCESS != Status);\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  if (SizeNv != Size) {\r
+    //\r
+    // The variable is considered corrupt, as it has different size from expected.\r
+    //\r
+    return EFI_LOAD_ERROR; \r
+  }\r
+\r
+  if (NULL == *Var) {\r
+    *Var = EfiLibAllocatePool (Size);\r
+    ASSERT (NULL != *Var);\r
+  }\r
+  SizeNv = Size;\r
+  //\r
+  // Final read into the Var\r
+  //\r
+  Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var); \r
+  //\r
+  // No tolerance for random failures. Such behavior is undetermined and not validated.\r
+  //\r
+  ASSERT_EFI_ERROR (Status); \r
+  ASSERT (SizeNv == Size);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableOverrideIfSuffix (\r
+  IN  CHAR16                 *Suffix,\r
+  IN  CHAR16                 *Name,\r
+  IN  EFI_GUID               *Guid,\r
+  IN  UINTN                   Size,\r
+  OUT VOID                   *Var\r
+  )  \r
+/*++\r
+\r
+Routine Description:\r
+  Overrrides the variable with NV data if found.\r
+  But it only does it if the Name ends with specified Suffix.\r
+  For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride",\r
+  the Suffix matches the end of Name, so the variable will be loaded from NV\r
+  provided the variable exists and the GUID and Size matches.\r
+\r
+Arguments:\r
+  Suffix           - Suffix the Name should end with.\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into this buffer.\r
+                     Caller is responsible for providing storage of exactly Size size in bytes.\r
+Returns:\r
+  EFI_SUCCESS           - The variable was overriden with NV variable of same Name/Guid/Size.\r
+  EFI_INVALID_PARAMETER - The name of the variable does not end with <Suffix>.\r
+  EFI_NOT_FOUND         - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR        - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+{\r
+  UINTN         StrLen;\r
+  UINTN         StrLenSuffix;\r
+\r
+  StrLen       = EfiStrLen (Name);\r
+  StrLenSuffix = EfiStrLen (Suffix);\r
+  if ((StrLen <= StrLenSuffix) || (0 != EfiStrCmp (Suffix, &Name[StrLen - StrLenSuffix]))) {\r
+    //\r
+    // Not ending with <Suffix>.\r
+    //\r
+    return EFI_INVALID_PARAMETER; \r
+  }\r
+  return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var);\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EfiLibHiiVariableOverrideBySuffix (\r
+  IN  CHAR16                 *Suffix,\r
+  IN  CHAR16                 *Name,\r
+  IN  EFI_GUID               *Guid,\r
+  IN  UINTN                   Size,\r
+  OUT VOID                   *Var\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Overrrides the variable with NV data if found.\r
+  But it only does it if the NV contains the same variable with Name is appended with Suffix.  \r
+  For example, if Suffix="MyOverride" and the Name="XyzSetup",\r
+  the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride"\r
+  will be loaded from NV provided the variable exists and the GUID and Size matches.\r
+\r
+Arguments:\r
+  Suffix           - Suffix the variable will be appended with.\r
+  Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.\r
+  Var              - Variable will be retrieved into this buffer.\r
+                     Caller is responsible for providing storage of exactly Size size in bytes.\r
+\r
+Returns:\r
+  EFI_SUCCESS    - The variable was overriden with NV variable of same Name/Guid/Size.\r
+  EFI_NOT_FOUND  - The variable of this Name/Guid was not found in the NV.\r
+  EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS    Status;\r
+  CHAR16       *NameSuffixed;\r
+\r
+  //\r
+  // enough to concatenate both strings.\r
+  //\r
+  NameSuffixed = EfiLibAllocateZeroPool ((EfiStrLen (Name) + EfiStrLen (Suffix) + 1) * sizeof (CHAR16)); \r
+  \r
+  EfiStrCpy (NameSuffixed, Name);\r
+  EfiStrCat (NameSuffixed, Suffix);\r
+  \r
+  Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var);\r
+  gBS->FreePool (NameSuffixed);\r
+  \r
+  return Status;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c
new file mode 100644 (file)
index 0000000..49720ec
--- /dev/null
@@ -0,0 +1,597 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+  \r
+    EfiScriptLib.c\r
+\r
+Abstract:\r
+\r
+  Support for EFI script. \r
+\r
+--*/\r
+\r
+#include "EfiScriptLib.h"\r
+\r
+EFI_BOOT_SCRIPT_SAVE_PROTOCOL *mBootScriptSave;\r
+\r
+EFI_STATUS\r
+BootScriptSaveInitialize (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Boot Script Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    ImageHandle - add argument and description to function comment\r
+// GC_TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_BOOT_SERVICES *BS;\r
+\r
+  BS      = SystemTable->BootServices;\r
+\r
+  Status  = BS->LocateProtocol (&gEfiBootScriptSaveGuid, NULL, &mBootScriptSave);\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    mBootScriptSave = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveIoWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI IO write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Count - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_IO_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Count,\r
+                    Buffer\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveIoReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI IO read write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Data - add argument and description to function comment\r
+// GC_TODO:    DataMask - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Data,\r
+                    DataMask\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveMemWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI MEM write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Count - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Count,\r
+                    Buffer\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveMemReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI MEM read write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Data - add argument and description to function comment\r
+// GC_TODO:    DataMask - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Data,\r
+                    DataMask\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSavePciCfgWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI PCI write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Count - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Count,\r
+                    Buffer\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSavePciCfgReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI PCI read write script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Width - add argument and description to function comment\r
+// GC_TODO:    Address - add argument and description to function comment\r
+// GC_TODO:    Data - add argument and description to function comment\r
+// GC_TODO:    DataMask - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,\r
+                    Width,\r
+                    Address,\r
+                    Data,\r
+                    DataMask\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveSmbusExecute (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_SMBUS_DEVICE_ADDRESS          SlaveAddress,\r
+  IN  EFI_SMBUS_DEVICE_COMMAND          Command,\r
+  IN  EFI_SMBUS_OPERATION               Operation,\r
+  IN  BOOLEAN                           PecCheck,\r
+  IN  UINTN                             *Length,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI Smbus execute script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    SlaveAddress - add argument and description to function comment\r
+// GC_TODO:    Command - add argument and description to function comment\r
+// GC_TODO:    Operation - add argument and description to function comment\r
+// GC_TODO:    PecCheck - add argument and description to function comment\r
+// GC_TODO:    Length - add argument and description to function comment\r
+// GC_TODO:    Buffer - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE,\r
+                    SlaveAddress,\r
+                    Command,\r
+                    Operation,\r
+                    PecCheck,\r
+                    Length,\r
+                    Buffer\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveStall (\r
+  IN  UINT16                            TableName,\r
+  IN  UINTN                             Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script \r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  (Standard EFI stall script parameter) \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+// GC_TODO:    Duration - add argument and description to function comment\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_STALL_OPCODE,\r
+                    Duration\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BootScriptSaveDispatch (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_PHYSICAL_ADDRESS              EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  TableName   - GC_TODO: add argument description\r
+  EntryPoint  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - GC_TODO: Add description for return value\r
+  EFI_SUCCESS - GC_TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_DISPATCH_OPCODE,\r
+                    EntryPoint\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformation (\r
+  IN  UINT16                                 TableName,\r
+  IN  UINT32                                 Length, \r
+  IN  EFI_PHYSICAL_ADDRESS                   Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  Length         - Length of information in bytes\r
+  Buffer          - Content of information that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  if (mBootScriptSave == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  mBootScriptSave->Write (\r
+                    mBootScriptSave,\r
+                    TableName,\r
+                    EFI_BOOT_SCRIPT_INFORMATION_OPCODE,\r
+                    Length,\r
+                    Buffer\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformationUnicodeString (\r
+  IN        UINT16              TableName,\r
+  IN        CHAR16              *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName, the information\r
+  is a unicode string.\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  String          - The string that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return BootScriptSaveInformation (      \r
+           TableName,\r
+           (UINT32) EfiStrLen (String) * 2 + 2, \r
+           (EFI_PHYSICAL_ADDRESS)String\r
+           );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformationAsciiString (\r
+  IN        UINT16              TableName,\r
+  IN        CHAR8               *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName, the information\r
+  is a ascii string.\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  String          - The string that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return BootScriptSaveInformation (      \r
+           TableName,\r
+           (UINT32) EfiAsciiStrLen (String) + 1, \r
+           (EFI_PHYSICAL_ADDRESS)String\r
+           );\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
new file mode 100644 (file)
index 0000000..645e046
--- /dev/null
@@ -0,0 +1,46 @@
+#/*++\r
+#\r
+# Copyright (c) 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+#\r
+#  Module Name:\r
+#\r
+#    EfiScriptLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = EfiScriptLib\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  EfiScriptLib.c\r
+\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EFI_SOURCE)\Framework\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EFI_SOURCE)\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+  EdkFrameworkProtocolLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
new file mode 100644 (file)
index 0000000..69fc8f7
--- /dev/null
@@ -0,0 +1,492 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  EfiUiLib.c\r
+\r
+Abstract:\r
+  Collection of usefull UI functions.\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#include "EfiUiLib.h"\r
+\r
+#define IS_DIGIT(Ch)  (((Ch) >= L'0') && ((Ch) <= L'9'))\r
+\r
+STATIC\r
+EFI_STATUS\r
+EfiStringToValue (\r
+  OUT UINT64        *Val,\r
+  IN  CHAR16        *String,\r
+  OUT UINT8         *EndIdx OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parses and converts Unicode string to decimal value.\r
+  The returned value is 64-bit.\r
+  The string is expected in decimal format,\r
+  the string is parsed and format verified.\r
+  This function is missing from the libs. One day it maybe\r
+  replaced with a lib function when it'll become available.\r
+\r
+Arguments:\r
+  Val    - pointer to the variable to store the value to\r
+  String - string that contains the value to parse and convert\r
+  EndIdx - index on which the parsing stopped. It points to the\r
+           first character that was not part of the returned Val.\r
+           It's valid only if the function returns success.\r
+           It's optional and it could be NULL.\r
+\r
+Returns:\r
+  EFI_SUCCESS           - if successful\r
+  EFI_INVALID_PARAMETER - if String is in unexpected format\r
+\r
+--*/\r
+{\r
+  UINT8   i;\r
+  UINT64  TempVal;\r
+\r
+  TempVal = 0;\r
+  //\r
+  // Iterate upto 20 digits, only so many could fit in the UINT64\r
+  //\r
+  for (i = 0; i <= 20; i++) {\r
+    //\r
+    // test if the next character is not a digit\r
+    //\r
+    if (!IS_DIGIT (String[i])) {\r
+      //\r
+      // If here, there is no more digits,\r
+      // return with success if there was at least one to process\r
+      //\r
+      if (i == 0) {\r
+        break;\r
+      }\r
+\r
+      *Val = TempVal;\r
+\r
+      if (EndIdx != NULL) {\r
+        *EndIdx = i;\r
+      }\r
+\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // If here, there is a digit to process\r
+    //\r
+    TempVal = MultU64x32 (TempVal, 10) + String[i] - L'0';\r
+  }\r
+  //\r
+  // if here, there was some sort of format error\r
+  //\r
+  return EFI_INVALID_PARAMETER;\r
+}\r
+\r
+CHAR16 *\r
+StrHzToString (\r
+  OUT CHAR16          *String,\r
+  IN  UINT64          Val\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts frequency in Hz to Unicode string. \r
+  Three significant digits are delivered. \r
+  Used for things like processor info display.\r
+\r
+Arguments:\r
+  String - string that will contain the frequency.\r
+  Val    - value to convert, minimum is  100000 i.e., 0.1 MHz.\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Returns:'\r
+{\r
+  CHAR16        HlpStr[8];\r
+  UINT32        i;\r
+  UINT32        IdxPoint;\r
+  UINT32        IdxUnits;\r
+  static CHAR16 *FreqUnits[] = { L" Hz", L" kHz", L" MHz", L" GHz", L" THz", L" PHz" };\r
+\r
+  //\r
+  // Normalize to 9999 or less.\r
+  //\r
+  i = 0;\r
+  while (Val >= 10000) {\r
+    Val = DivU64x32 (Val, 10, NULL);\r
+    i++;\r
+  }\r
+  //\r
+  // Make it rounded to the nearest, but only by\r
+  // a .3. This assures that .6 is not rounded.\r
+  //\r
+  if (Val >= 1000) {\r
+    Val += 3;\r
+    Val = DivU64x32 (Val, 10, NULL);\r
+    i++;\r
+  }\r
+\r
+  EfiValueToString (String, Val, 0, 0);\r
+\r
+  //\r
+  // Get rid of that cursed number!\r
+  //\r
+  if (!EfiStrCmp (&String[1], L"66")) {\r
+    String[2] = L'7';\r
+  }\r
+  //\r
+  // Compute index to the units substrings.\r
+  //\r
+  IdxUnits = (i + 2) / 3;\r
+\r
+  if (IdxUnits >= (sizeof (FreqUnits) / sizeof (FreqUnits)[0])) {\r
+    //\r
+    // Frequency is too high.\r
+    //\r
+    EfiStrCpy (String, L"OVERFLOW");\r
+    return String;\r
+  }\r
+  //\r
+  // Compute the position of the decimal point.\r
+  //\r
+  IdxPoint = i % 3;\r
+\r
+  //\r
+  // Test if decimal point needs to be inserted.\r
+  //\r
+  if (IdxPoint != 0) {\r
+    //\r
+    // Save the part after decimal point.\r
+    //\r
+    EfiStrCpy (HlpStr, &String[IdxPoint]);\r
+\r
+    //\r
+    // Insert the point.\r
+    //\r
+    String[IdxPoint] = L'.';\r
+\r
+    //\r
+    // Reattach the saved part.\r
+    //\r
+    EfiStrCpy (&String[IdxPoint + 1], HlpStr);\r
+\r
+    //\r
+    // Clear the insignificant zero.\r
+    //\r
+    if (String[3] == L'0') {\r
+      String[4 - IdxPoint] = L'\0';\r
+    }\r
+  }\r
+  //\r
+  // Attach units.\r
+  //\r
+  EfiStrCat (String, FreqUnits[IdxUnits]);\r
+\r
+  return String;\r
+}\r
+\r
+CHAR16 *\r
+StrBytesToString (\r
+  OUT CHAR16          *String,\r
+  IN  UINT64          Val\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts size in bytes to Unicode string.\r
+  Used for memory/cache size display.\r
+\r
+Arguments:\r
+  String - string that will contain the value\r
+  Val    - value to convert in bytes\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Returns:'\r
+{\r
+  UINTN         i;\r
+  UINTN         Rem;\r
+  static CHAR16 *SizeUnits[] = { L" B", L" kB", L" MB", L" GB", L" TB", L" PB" };\r
+\r
+  for (i = 0; i < (sizeof (SizeUnits) / sizeof (SizeUnits)[0]); i++) {\r
+\r
+    DivU64x32 (Val, 1024, &Rem);\r
+\r
+    //\r
+    // Done if:\r
+    // 1. less than 1k\r
+    // 2. less than 8k and there are fractions of 1k\r
+    //\r
+    if ((Val < 1024) || ((Val < 8192) && (Rem != 0))) {\r
+\r
+      EfiValueToString (String, Val, 0, 0);\r
+\r
+      //\r
+      // attach units\r
+      //\r
+      EfiStrCat (String, SizeUnits[i]);\r
+      return String;\r
+    }\r
+    //\r
+    // prescale down by 1k with rounding to the nearest\r
+    //\r
+    Val = DivU64x32 (Val + 511, 1024, NULL);\r
+  }\r
+\r
+  EfiStrCpy (String, L"OVERFLOW");\r
+\r
+  return String;\r
+}\r
+\r
+CHAR16 *\r
+StrVersionToString (\r
+  OUT CHAR16          *String,\r
+  IN  UINT8           Version\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts 8 bit version value to Unicode string.\r
+  The upper nibble contains the upper part, the lower nibble contains the minor part.\r
+  The output format is <major>.<minor>.\r
+\r
+Arguments:\r
+  String  - string that will contain the value\r
+  Version - value to convert\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Returns:'\r
+{\r
+  CHAR16  HlpStr[4];\r
+\r
+  EfiValueToString (String, 0x0F & Version, 0, 0);\r
+  EfiStrCat (String, L".");\r
+  EfiValueToString (HlpStr, 0x0F & (Version >> 4), 0, 0);\r
+  EfiStrCat (String, HlpStr);\r
+\r
+  return String;\r
+}\r
+\r
+CHAR16 *\r
+StrMacToString (\r
+  OUT CHAR16              *String,\r
+  IN  EFI_MAC_ADDRESS     *MacAddr,\r
+  IN  UINT32              AddrSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts MAC address to Unicode string.\r
+  The value is 64-bit and the resulting string will be 12\r
+  digit hex number in pairs of digits separated by dashes.\r
+\r
+Arguments:\r
+  String - string that will contain the value\r
+  Val    - value to convert\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Returns:'\r
+// GC_TODO:    MacAddr - add argument and description to function comment\r
+// GC_TODO:    AddrSize - add argument and description to function comment\r
+{\r
+  UINT32  i;\r
+\r
+  for (i = 0; i < AddrSize; i++) {\r
+\r
+    EfiValueToHexStr (\r
+      &String[2 * i],\r
+      MacAddr->Addr[i] & 0xFF,\r
+      PREFIX_ZERO,\r
+      2\r
+      );\r
+  }\r
+  //\r
+  // Terminate the string.\r
+  //\r
+  String[2 * AddrSize] = L'\0';\r
+\r
+  return String;\r
+}\r
+\r
+CHAR16 *\r
+StrIp4AdrToString (\r
+  OUT CHAR16             *String,\r
+  IN  EFI_IPv4_ADDRESS   *Ip4Addr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts IP v4 address to Unicode string.\r
+  The value is 64-bit and the resulting string will\r
+  be four decimal values 0-255 separated by dots.\r
+\r
+Arguments:\r
+  String  - string that will contain the value\r
+  Ip4Addr - value to convert from\r
+\r
+--*/\r
+// GC_TODO: function comment is missing 'Returns:'\r
+{\r
+  INT32   i;\r
+  CHAR16  HlpStr[4];\r
+\r
+  String[0] = L'\0';\r
+\r
+  for (i = 0; i < 4; i++) {\r
+\r
+    EfiValueToString (HlpStr, Ip4Addr->Addr[i], 0, 0);\r
+    EfiStrCat (String, HlpStr);\r
+\r
+    if (i < 3) {\r
+      EfiStrCat (String, L".");\r
+    }\r
+  }\r
+\r
+  return String;\r
+}\r
+\r
+EFI_STATUS\r
+StrStringToIp4Adr (\r
+  OUT EFI_IPv4_ADDRESS   *Ip4Addr,\r
+  IN  CHAR16             *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parses and converts Unicode string to IP v4 address.\r
+  The value will 64-bit.\r
+  The string must be four decimal values 0-255 separated by dots.\r
+  The string is parsed and format verified.\r
+\r
+Arguments:\r
+  Ip4Addr - pointer to the variable to store the value to\r
+  String  - string that contains the value to parse and convert\r
+\r
+Returns:\r
+  EFI_SUCCESS           - if successful\r
+  EFI_INVALID_PARAMETER - if String contains invalid IP v4 format\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+\r
+  EFI_IPv4_ADDRESS  RetVal;\r
+  UINT64            TempVal;\r
+  UINT8             Idx;\r
+  UINT8             i;\r
+\r
+  //\r
+  // Iterate the decimal values separated by dots\r
+  //\r
+  for (i = 0; i < 4; i++) {\r
+    //\r
+    // get the value of a decimal\r
+    //\r
+    Status = EfiStringToValue (&TempVal, String, &Idx);\r
+    if ((EFI_ERROR (Status)) || (TempVal > 255)) {\r
+      break;\r
+    }\r
+\r
+    RetVal.Addr[i] = (UINT8) TempVal;\r
+    String += Idx;\r
+\r
+    //\r
+    // test if it is the last decimal value\r
+    //\r
+    if (i == 3) {\r
+      if (String[0] != L'\0') {\r
+        //\r
+        // the string must end with string termination character\r
+        //\r
+        break;\r
+      }\r
+\r
+      *Ip4Addr = RetVal;\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // Test for presence of a dot, it is required between the values\r
+    //\r
+    if (String++[0] != L'.') {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return EFI_INVALID_PARAMETER;\r
+}\r
+\r
+CHAR16 *\r
+Ascii2Unicode (\r
+  OUT CHAR16         *UnicodeStr,\r
+  IN  CHAR8          *AsciiStr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts ASCII characters to Unicode.\r
+\r
+Arguments:\r
+  UnicodeStr - the Unicode string to be written to. The buffer must be large enough.\r
+  AsciiStr   - The ASCII string to be converted.\r
+\r
+Returns:\r
+  The address to the Unicode string - same as UnicodeStr.\r
+\r
+--*/\r
+{\r
+  CHAR16  *Str;\r
+\r
+  Str = UnicodeStr;\r
+\r
+  while (TRUE) {\r
+\r
+    *(UnicodeStr++) = (CHAR16) *AsciiStr;\r
+\r
+    if (*(AsciiStr++) == '\0') {\r
+      return Str;\r
+    }\r
+  }\r
+}\r
+\r
+CHAR8 *\r
+Unicode2Ascii (\r
+  OUT CHAR8          *AsciiStr,\r
+  IN  CHAR16         *UnicodeStr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts ASCII characters to Unicode.\r
+  Assumes that the Unicode characters are only these defined in the ASCII set.\r
+\r
+Arguments:\r
+  AsciiStr   - The ASCII string to be written to. The buffer must be large enough.\r
+  UnicodeStr - the Unicode string to be converted.\r
+\r
+Returns:\r
+  The address to the ASCII string - same as AsciiStr.\r
+\r
+--*/\r
+{\r
+  CHAR8 *Str;\r
+\r
+  Str = AsciiStr;\r
+\r
+  while (TRUE) {\r
+\r
+    *AsciiStr = (CHAR8) *(UnicodeStr++);\r
+\r
+    if (*(AsciiStr++) == '\0') {\r
+      return Str;\r
+    }\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf
new file mode 100644 (file)
index 0000000..87af7f7
--- /dev/null
@@ -0,0 +1,43 @@
+#/*++\r
+#\r
+# Copyright (c) 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EfiUiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = EfiUiLib\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  EfiUiLib.c\r
+\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h
new file mode 100644 (file)
index 0000000..65087c1
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Ascii\r
+  STRING_W is ""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR8 CHAR_W;\r
+#define STRING_W(_s)                                  _s\r
+\r
+#define ASPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define AvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         StrLen,\r
+  IN  CONST CHAR16  *Format,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  StrLen               - Maximum number of characters to put into buffer.\r
+  Format               - Format string\r
+  Marker               - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16      *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR16 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c
new file mode 100644 (file)
index 0000000..7c44ad5
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    AsciiFormat[Index] = (CHAR8) FormatString[Index];\r
+  }\r
+\r
+  AsciiFormat[Index]  = '\0';\r
+\r
+  Index               = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR16) AsciiResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
new file mode 100644 (file)
index 0000000..80d9b72
--- /dev/null
@@ -0,0 +1,619 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Graphics.c\r
+\r
+Abstract:\r
+\r
+  Support for Basic Graphics operations.\r
+\r
+  BugBug: Currently *.BMP files are supported. This will be replaced\r
+          when Tiano graphics format is supported.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "GraphicsLib.h"\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFV (\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+{\r
+  return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);\r
+}\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFVEx (\r
+  IN  EFI_HANDLE    ImageHandle,\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  ImageHandle   - The driver image handle of the caller. The parameter is used to\r
+                  optimize the loading of the image file so that the FV from which\r
+                  the driver image is loaded will be tried first. \r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+{\r
+  return GetImageEx (\r
+           ImageHandle,\r
+           &gEfiDefaultBmpLogoGuid,\r
+           EFI_SECTION_RAW,\r
+           Image,\r
+           ImageSize,\r
+           FALSE\r
+           );\r
+}\r
+\r
+\r
+EFI_STATUS\r
+ConvertBmpToGopBlt (\r
+  IN  VOID      *BmpImage,\r
+  IN  UINTN     BmpImageSize,\r
+  IN OUT VOID   **GopBlt,\r
+  IN OUT UINTN  *GopBltSize,\r
+  OUT UINTN     *PixelHeight,\r
+  OUT UINTN     *PixelWidth\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer\r
+  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
+  buffer is passed in it will be used if it is big enough.\r
+\r
+Arguments:\r
+\r
+  BmpImage      - Pointer to BMP file\r
+\r
+  BmpImageSize  - Number of bytes in BmpImage\r
+\r
+  GopBlt        - Buffer containing GOP version of BmpImage.\r
+\r
+  GopBltSize    - Size of GopBlt in bytes.\r
+\r
+  PixelHeight   - Height of GopBlt/BmpImage in pixels\r
+\r
+  PixelWidth    - Width of GopBlt/BmpImage in pixels\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - GopBlt and GopBltSize are returned. \r
+  EFI_UNSUPPORTED       - BmpImage is not a valid *.BMP image\r
+  EFI_BUFFER_TOO_SMALL  - The passed in GopBlt buffer is not big enough.\r
+                          GopBltSize will contain the required size.\r
+  EFI_OUT_OF_RESOURCES  - No enough buffer to allocate\r
+\r
+--*/\r
+{\r
+  UINT8                         *Image;\r
+  UINT8                         *ImageHeader;\r
+  BMP_IMAGE_HEADER              *BmpHeader;\r
+  BMP_COLOR_MAP                 *BmpColorMap;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+  UINTN                         BltBufferSize;\r
+  UINTN                         Index;\r
+  UINTN                         Height;\r
+  UINTN                         Width;\r
+  UINTN                         ImageIndex;\r
+  BOOLEAN                       IsAllocated;\r
+\r
+  BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
+  if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (BmpHeader->CompressionType != 0) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Calculate Color Map offset in the image.\r
+  //\r
+  Image       = BmpImage;\r
+  BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));\r
+\r
+  //\r
+  // Calculate graphics image data address in the image\r
+  //\r
+  Image         = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
+  ImageHeader   = Image;\r
+\r
+  BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+  IsAllocated   = FALSE;\r
+  if (*GopBlt == NULL) {\r
+    *GopBltSize = BltBufferSize;\r
+    *GopBlt     = EfiLibAllocatePool (*GopBltSize);\r
+    IsAllocated = TRUE;\r
+    if (*GopBlt == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  } else {\r
+    if (*GopBltSize < BltBufferSize) {\r
+      *GopBltSize = BltBufferSize;\r
+      return EFI_BUFFER_TOO_SMALL;\r
+    }\r
+  }\r
+\r
+  *PixelWidth   = BmpHeader->PixelWidth;\r
+  *PixelHeight  = BmpHeader->PixelHeight;\r
+\r
+  //\r
+  // Convert image from BMP to Blt buffer format\r
+  //\r
+  BltBuffer = *GopBlt;\r
+  for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {\r
+    Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];\r
+    for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {\r
+      switch (BmpHeader->BitPerPixel) {\r
+      case 1:\r
+        //\r
+        // Convert 1bit BMP to 24-bit color\r
+        //\r
+        for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
+          Blt->Red    = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
+          Blt->Green  = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;\r
+          Blt->Blue   = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;\r
+          Blt++;\r
+          Width++;\r
+        }\r
+\r
+        Blt --;\r
+        Width --;\r
+        break;\r
+\r
+      case 4:\r
+        //\r
+        // Convert BMP Palette to 24-bit color\r
+        //\r
+        Index       = (*Image) >> 4;\r
+        Blt->Red    = BmpColorMap[Index].Red;\r
+        Blt->Green  = BmpColorMap[Index].Green;\r
+        Blt->Blue   = BmpColorMap[Index].Blue;\r
+        if (Width < (BmpHeader->PixelWidth - 1)) {\r
+          Blt++;\r
+          Width++;\r
+          Index       = (*Image) & 0x0f;\r
+          Blt->Red    = BmpColorMap[Index].Red;\r
+          Blt->Green  = BmpColorMap[Index].Green;\r
+          Blt->Blue   = BmpColorMap[Index].Blue;\r
+        }\r
+        break;\r
+\r
+      case 8:\r
+        //\r
+        // Convert BMP Palette to 24-bit color\r
+        //\r
+        Blt->Red    = BmpColorMap[*Image].Red;\r
+        Blt->Green  = BmpColorMap[*Image].Green;\r
+        Blt->Blue   = BmpColorMap[*Image].Blue;\r
+        break;\r
+\r
+      case 24:\r
+        Blt->Blue   = *Image++;\r
+        Blt->Green  = *Image++;\r
+        Blt->Red    = *Image;\r
+        break;\r
+\r
+      default:\r
+        if (IsAllocated) {\r
+          gBS->FreePool (*GopBlt);\r
+          *GopBlt = NULL;\r
+        }\r
+        return EFI_UNSUPPORTED;\r
+        break;\r
+      };\r
+\r
+    }\r
+\r
+    ImageIndex = (UINTN) (Image - ImageHeader);\r
+    if ((ImageIndex % 4) != 0) {\r
+      //\r
+      // Bmp Image starts each row on a 32-bit boundary!\r
+      //\r
+      Image = Image + (4 - (ImageIndex % 4));\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
+  This is the ConInHandle and ConIn handle in the EFI system table. All key\r
+  presses will be ignored until the Password is typed in. The only way to\r
+  disable the password is to type it in to a ConIn device.\r
+\r
+Arguments:\r
+  Password - Password used to lock ConIn device\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = ConsoleControl->LockStdIn (ConsoleControl, Password);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EnableQuietBoot (\r
+  IN  EFI_GUID  *LogoFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+  to the UGA device. Put up LogoFile on every UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile - File name of logo to display on the center of the screen.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  return EnableQuietBootEx (LogoFile, NULL);\r
+}\r
+\r
+EFI_STATUS\r
+EnableQuietBootEx (\r
+  IN  EFI_GUID    *LogoFile,\r
+  IN  EFI_HANDLE  ImageHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going\r
+  to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile    - File name of logo to display on the center of the screen.\r
+  ImageHandle - The driver image handle of the caller. The parameter is used to\r
+                optimize the loading of the logo file so that the FV from which\r
+                the driver image is loaded will be tried first.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+  EFI_OEM_BADGING_PROTOCOL      *Badging;\r
+  UINT32                        SizeOfX;\r
+  UINT32                        SizeOfY;\r
+  INTN                          DestX;\r
+  INTN                          DestY;\r
+  UINT8                         *ImageData;\r
+  UINTN                         ImageSize;\r
+  UINTN                         BltSize;\r
+  UINT32                        Instance;\r
+  EFI_BADGING_FORMAT            Format;\r
+  EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
+  UINTN                         CoordinateX;\r
+  UINTN                         CoordinateY;\r
+  UINTN                         Height;\r
+  UINTN                         Width;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
+  UINT32                        ColorDepth;\r
+  UINT32                        RefreshRate;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  UgaDraw = NULL;\r
+  //\r
+  // Try to open GOP first\r
+  //\r
+  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput);\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+    //\r
+    // Open GOP failed, try to open UGA\r
+    //\r
+    Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID**)&UgaDraw);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  Badging = NULL;\r
+  Status  = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID**)&Badging);\r
+\r
+  ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else {\r
+    Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  Instance = 0;\r
+  while (1) {\r
+    ImageData = NULL;\r
+    ImageSize = 0;\r
+\r
+    if (Badging != NULL) {\r
+      Status = Badging->GetImage (\r
+                          Badging,\r
+                          &Instance,\r
+                          &Format,\r
+                          &ImageData,\r
+                          &ImageSize,\r
+                          &Attribute,\r
+                          &CoordinateX,\r
+                          &CoordinateY\r
+                          );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      //\r
+      // Currently only support BMP format\r
+      //\r
+      if (Format != EfiBadgingFormatBMP) {\r
+        gBS->FreePool (ImageData);\r
+        continue;\r
+      }\r
+    } else {\r
+      Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, &ImageData, &ImageSize);\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+\r
+      CoordinateX = 0;\r
+      CoordinateY = 0;\r
+      Attribute   = EfiBadgingDisplayAttributeCenter;\r
+    }\r
+\r
+    Blt = NULL;\r
+    Status = ConvertBmpToGopBlt (\r
+              ImageData,\r
+              ImageSize,\r
+              (VOID**)&Blt,\r
+              &BltSize,\r
+              &Height,\r
+              &Width\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool (ImageData);\r
+      if (Badging == NULL) {\r
+        return Status;\r
+      } else {\r
+        continue;\r
+      }\r
+    }\r
+\r
+    switch (Attribute) {\r
+    case EfiBadgingDisplayAttributeLeftTop:\r
+      DestX = CoordinateX;\r
+      DestY = CoordinateY;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterTop:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = CoordinateY;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeRightTop:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = CoordinateY;;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterRight:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeRightBottom:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterBottom:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeLeftBottom:\r
+      DestX = CoordinateX;\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterLeft:\r
+      DestX = CoordinateX;\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenter:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    default:\r
+      DestX = CoordinateX;\r
+      DestY = CoordinateY;\r
+      break;\r
+    }\r
+\r
+    if ((DestX >= 0) && (DestY >= 0)) {\r
+      if (GraphicsOutput != NULL) {\r
+        Status = GraphicsOutput->Blt (\r
+                            GraphicsOutput,\r
+                            Blt,\r
+                            EfiBltBufferToVideo,\r
+                            0,\r
+                            0,\r
+                            (UINTN) DestX,\r
+                            (UINTN) DestY,\r
+                            Width,\r
+                            Height,\r
+                            Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                            );\r
+      } else {\r
+        Status = UgaDraw->Blt (\r
+                            UgaDraw,\r
+                            (EFI_UGA_PIXEL *) Blt,\r
+                            EfiUgaBltBufferToVideo,\r
+                            0,\r
+                            0,\r
+                            (UINTN) DestX,\r
+                            (UINTN) DestY,\r
+                            Width,\r
+                            Height,\r
+                            Width * sizeof (EFI_UGA_PIXEL)\r
+                            );\r
+      }\r
+    }\r
+\r
+    gBS->FreePool (ImageData);\r
+    gBS->FreePool (Blt);\r
+\r
+    if (Badging == NULL) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+DisableQuietBoot (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA \r
+  Simple Text Out screens will now be synced up with all non GOP/UGA output devices\r
+\r
+Arguments:\r
+\r
+  NONE\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - GOP/UGA devices are back in text mode and synced up.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf
new file mode 100644 (file)
index 0000000..2e0cd20
--- /dev/null
@@ -0,0 +1,50 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    Graphics.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = Graphics\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  Graphics.c\r
+  Print.c\r
+  Print.h\r
+  Unicode\PrintWidth.h\r
+  Unicode\Sprint.c\r
+\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+  EfiDriverLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
new file mode 100644 (file)
index 0000000..5cbcb53
--- /dev/null
@@ -0,0 +1,889 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+STATIC\r
+CHAR_W                *\r
+GetFlagsAndWidth (\r
+  IN  CHAR_W      *Format,\r
+  OUT UINTN       *Flags,\r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN OUT CHAR_W *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN  EFI_TIME  *Time,\r
+  IN OUT CHAR_W *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR_W      *Buffer,\r
+  IN  UINTN       BufferSize\r
+  );\r
+\r
+static EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mEfiColors[16] = {\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x98, 0x00, 0x00, 0x00,\r
+  0x00, 0x98, 0x00, 0x00,\r
+  0x98, 0x98, 0x00, 0x00,\r
+  0x00, 0x00, 0x98, 0x00,\r
+  0x98, 0x00, 0x98, 0x00,\r
+  0x00, 0x98, 0x98, 0x00,\r
+  0x98, 0x98, 0x98, 0x00,\r
+  0x10, 0x10, 0x10, 0x00,\r
+  0xff, 0x10, 0x10, 0x00,\r
+  0x10, 0xff, 0x10, 0x00,\r
+  0xff, 0xff, 0x10, 0x00,\r
+  0x10, 0x10, 0xff, 0x00,\r
+  0xf0, 0x10, 0xff, 0x00,\r
+  0x10, 0xff, 0xff, 0x00,\r
+  0xff, 0xff, 0xff, 0x00,\r
+};\r
+\r
+\r
+UINTN\r
+_IPrint (\r
+  IN EFI_GRAPHICS_OUTPUT_PROTOCOL     *GraphicsOutput,\r
+  IN EFI_UGA_DRAW_PROTOCOL            *UgaDraw,\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL     *Sto,\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background,\r
+  IN CHAR16                           *fmt,\r
+  IN VA_LIST                          args\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
+\r
+Arguments:\r
+\r
+  GraphicsOutput  - Graphics output protocol interface\r
+\r
+  UgaDraw         - UGA draw protocol interface\r
+  \r
+  Sto             - Simple text out protocol interface\r
+  \r
+  X               - X coordinate to start printing\r
+  \r
+  Y               - Y coordinate to start printing\r
+  \r
+  Foreground      - Foreground color\r
+  \r
+  Background      - Background color\r
+  \r
+  fmt             - Format string\r
+  \r
+  args            - Print arguments\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS             -  success\r
+  EFI_OUT_OF_RESOURCES    -  out of resources\r
+\r
+--*/\r
+{\r
+  VOID                           *Buffer;\r
+  EFI_STATUS                     Status;\r
+  UINT16                         GlyphWidth;\r
+  UINT32                         GlyphStatus;\r
+  UINT16                         StringIndex;\r
+  UINTN                          Index;\r
+  CHAR16                         *UnicodeWeight;\r
+  EFI_NARROW_GLYPH               *Glyph;\r
+  EFI_HII_PROTOCOL               *Hii;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *LineBuffer;\r
+  UINT32                         HorizontalResolution;\r
+  UINT32                         VerticalResolution;\r
+  UINT32                         ColorDepth;\r
+  UINT32                         RefreshRate;\r
+  UINTN                          BufferLen;\r
+  UINTN                          LineBufferLen;\r
+\r
+  GlyphStatus = 0;\r
+\r
+  //\r
+  // For now, allocate an arbitrarily long buffer\r
+  //\r
+  Buffer = EfiLibAllocateZeroPool (0x10000);\r
+  if (Buffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else {\r
+    UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
+  }\r
+  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
+  \r
+  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;\r
+  LineBuffer = EfiLibAllocatePool (LineBufferLen);\r
+  if (LineBuffer == NULL) {\r
+    gBS->FreePool (Buffer);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  VSPrint (Buffer, 0x10000, fmt, args);\r
+  \r
+  UnicodeWeight = (CHAR16 *) Buffer;\r
+\r
+  for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
+    if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
+        UnicodeWeight[Index] == CHAR_LINEFEED  ||\r
+        UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
+      UnicodeWeight[Index] = 0;\r
+    }\r
+  }\r
+\r
+  BufferLen = EfiStrLen (Buffer);\r
+  \r
+  if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
+     Status = EFI_INVALID_PARAMETER;\r
+     goto Error;\r
+  }\r
+\r
+  for (Index = 0; Index < BufferLen; Index++) {\r
+    StringIndex = (UINT16) Index;\r
+    Status      = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus);\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+\r
+    if (Foreground == NULL || Background == NULL) {\r
+      Status = Hii->GlyphToBlt (\r
+                      Hii,\r
+                      (UINT8 *) Glyph,\r
+                      mEfiColors[Sto->Mode->Attribute & 0x0f],\r
+                      mEfiColors[Sto->Mode->Attribute >> 4],\r
+                      BufferLen,\r
+                      GlyphWidth,\r
+                      GLYPH_HEIGHT,\r
+                      &LineBuffer[Index * GLYPH_WIDTH]\r
+                      );\r
+    } else {\r
+      Status = Hii->GlyphToBlt (\r
+                      Hii,\r
+                      (UINT8 *) Glyph,\r
+                      *Foreground,\r
+                      *Background,\r
+                      BufferLen,\r
+                      GlyphWidth,\r
+                      GLYPH_HEIGHT,\r
+                      &LineBuffer[Index * GLYPH_WIDTH]\r
+                      );\r
+    }\r
+  }\r
+\r
+  //\r
+  // Blt a character to the screen\r
+  //\r
+  if (GraphicsOutput != NULL) {\r
+    Status = GraphicsOutput->Blt (\r
+                        GraphicsOutput,\r
+                        LineBuffer,\r
+                        EfiBltBufferToVideo,\r
+                        0,\r
+                        0,\r
+                        X,\r
+                        Y,\r
+                        GLYPH_WIDTH * BufferLen,\r
+                        GLYPH_HEIGHT,\r
+                        GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                        );\r
+  } else {\r
+    Status = UgaDraw->Blt (\r
+                        UgaDraw,\r
+                        (EFI_UGA_PIXEL *) LineBuffer,\r
+                        EfiUgaBltBufferToVideo,\r
+                        0,\r
+                        0,\r
+                        X,\r
+                        Y,\r
+                        GLYPH_WIDTH * BufferLen,\r
+                        GLYPH_HEIGHT,\r
+                        GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL)\r
+                        );\r
+  }\r
+\r
+Error:\r
+  gBS->FreePool (LineBuffer);\r
+  gBS->FreePool (Buffer);\r
+  return Status;\r
+}\r
+\r
+\r
+UINTN\r
+PrintXY (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
+  IN CHAR_W                           *Fmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Prints a formatted unicode string to the default console\r
+\r
+Arguments:\r
+\r
+    X           - X coordinate to start printing\r
+    \r
+    Y           - Y coordinate to start printing\r
+    \r
+    ForeGround  - Foreground color\r
+    \r
+    BackGround  - Background color\r
+\r
+    Fmt         - Format string\r
+\r
+    ...         - Print arguments\r
+\r
+Returns:\r
+\r
+    Length of string printed to the console\r
+\r
+--*/\r
+{\r
+  EFI_HANDLE                    Handle;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Sto;\r
+  EFI_STATUS                    Status;\r
+  VA_LIST                       Args;\r
+\r
+  VA_START (Args, Fmt);\r
+\r
+  Handle = gST->ConsoleOutHandle;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID**)&GraphicsOutput\r
+                  );\r
+\r
+  UgaDraw = NULL;\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    Handle,\r
+                    &gEfiUgaDrawProtocolGuid,\r
+                    (VOID**)&UgaDraw\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  (VOID**)&Sto\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+}\r
+\r
+\r
+UINTN\r
+SPrint (\r
+  OUT CHAR_W        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+VSPrint (\r
+  OUT CHAR_W        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  CHAR16    TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR_W    *Buffer;\r
+  CHAR8     *AsciiStr;\r
+  CHAR16    *UnicodeStr;\r
+  CHAR_W    *Format;\r
+  UINTN     Index;\r
+  UINTN     Flags;\r
+  UINTN     Width;\r
+  UINTN     Count;\r
+  UINTN     NumberOfCharacters;\r
+  UINTN     BufferLeft;\r
+  UINT64    Value;\r
+  EFI_GUID  *TmpGUID;\r
+\r
+  //\r
+  // Process the format string. Stop if Buffer is over run.\r
+  //\r
+\r
+  Buffer              = StartOfBuffer;\r
+  Format              = (CHAR_W *) FormatString;\r
+  NumberOfCharacters  = BufferSize / sizeof (CHAR_W);\r
+  BufferLeft          = BufferSize;\r
+  for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) {\r
+    if (*Format != '%') {\r
+      if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) {\r
+        //\r
+        // If carage return add line feed\r
+        //\r
+        Buffer[Index++] = '\r';\r
+        BufferLeft -= sizeof (CHAR_W);\r
+      }\r
+\r
+      Buffer[Index++] = *Format;\r
+      BufferLeft -= sizeof (CHAR_W);\r
+    } else {\r
+      \r
+      //\r
+      // Now it's time to parse what follows after %\r
+      //\r
+      Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);\r
+      switch (*Format) {\r
+      case 'X':\r
+        Flags |= PREFIX_ZERO;\r
+        Width = sizeof (UINT64) * 2;\r
+\r
+      //\r
+      // break skiped on purpose\r
+      //\r
+      case 'x':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        EfiValueToHexStr (TempBuffer, Value, Flags, Width);\r
+        UnicodeStr = TempBuffer;\r
+\r
+        for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        break;\r
+\r
+      case 'd':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = (UINTN) VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        EfiValueToString (TempBuffer, Value, Flags, Width);\r
+        UnicodeStr = TempBuffer;\r
+\r
+        for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        break;\r
+\r
+      case 's':\r
+      case 'S':\r
+        UnicodeStr = (CHAR16 *) VA_ARG (Marker, CHAR_W *);\r
+        if (UnicodeStr == NULL) {\r
+          UnicodeStr = L"<null string>";\r
+        }\r
+\r
+        for (Count = 0; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+\r
+        break;\r
+\r
+      case 'a':\r
+        AsciiStr = (CHAR8 *) VA_ARG (Marker, CHAR8 *);\r
+        if (AsciiStr == NULL) {\r
+          AsciiStr = "<null string>";\r
+        }\r
+\r
+        for (Count = 0; (*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) {\r
+          Buffer[Index++] = (CHAR_W) * AsciiStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+        break;\r
+\r
+      case 'c':\r
+        Buffer[Index++] = (CHAR_W) VA_ARG (Marker, UINTN);\r
+        break;\r
+\r
+      case 'g':\r
+        TmpGUID = VA_ARG (Marker, EFI_GUID *);\r
+        if (TmpGUID != NULL) {\r
+          Index += GuidToString (\r
+                    TmpGUID,\r
+                    &Buffer[Index],\r
+                    BufferLeft\r
+                    );\r
+        }\r
+        break;\r
+\r
+      case 't':\r
+        Index += TimeToString (\r
+                  VA_ARG (Marker, EFI_TIME *), \r
+                  &Buffer[Index],\r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case 'r':\r
+        Index += EfiStatusToString (\r
+                  VA_ARG (Marker, EFI_STATUS), \r
+                  &Buffer[Index],\r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case '%':\r
+        Buffer[Index++] = *Format;\r
+        break;\r
+\r
+      default:\r
+        //\r
+        // if the type is unknown print it to the screen\r
+        //\r
+        Buffer[Index++] = *Format;\r
+      }\r
+\r
+      BufferLeft = BufferSize - Index * sizeof (CHAR_W);\r
+    }\r
+  }\r
+\r
+  Buffer[Index++] = '\0';\r
+\r
+  return &Buffer[Index] - StartOfBuffer;\r
+}\r
+\r
+STATIC\r
+CHAR_W *\r
+GetFlagsAndWidth (\r
+  IN  CHAR_W      *Format,\r
+  OUT UINTN       *Flags,\r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that parses flag and width information from the \r
+  Format string and returns the next index into the Format string that needs\r
+  to be parsed. See file headed for details of Flag and Width.\r
+\r
+Arguments:\r
+\r
+  Format - Current location in the VSPrint format string.\r
+\r
+  Flags  - Returns flags\r
+\r
+  Width  - Returns width of element\r
+\r
+  Marker - Vararg list that may be paritally consumed and returned.\r
+\r
+Returns: \r
+\r
+  Pointer indexed into the Format string for all the information parsed\r
+  by this routine.\r
+\r
+--*/\r
+{\r
+  UINTN   Count;\r
+  BOOLEAN Done;\r
+\r
+  *Flags  = 0;\r
+  *Width  = 0;\r
+  for (Done = FALSE; !Done;) {\r
+    Format++;\r
+\r
+    switch (*Format) {\r
+\r
+    case '-':\r
+      *Flags |= LEFT_JUSTIFY;\r
+      break;\r
+\r
+    case '+':\r
+      *Flags |= PREFIX_SIGN;\r
+      break;\r
+\r
+    case ' ':\r
+      *Flags |= PREFIX_BLANK;\r
+      break;\r
+\r
+    case ',':\r
+      *Flags |= COMMA_TYPE;\r
+      break;\r
+\r
+    case 'L':\r
+    case 'l':\r
+      *Flags |= LONG_TYPE;\r
+      break;\r
+\r
+    case '*':\r
+      *Width = VA_ARG (*Marker, UINTN);\r
+      break;\r
+\r
+    case '0':\r
+      *Flags |= PREFIX_ZERO;\r
+\r
+    case '1':\r
+    case '2':\r
+    case '3':\r
+    case '4':\r
+    case '5':\r
+    case '6':\r
+    case '7':\r
+    case '8':\r
+    case '9':\r
+      Count = 0;\r
+      do {\r
+        Count = (Count * 10) +*Format - '0';\r
+        Format++;\r
+      } while ((*Format >= '0') && (*Format <= '9'));\r
+      Format--;\r
+      *Width = Count;\r
+      break;\r
+\r
+    default:\r
+      Done = TRUE;\r
+    }\r
+  }\r
+\r
+  return Format;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN  CHAR_W    *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints an EFI_GUID.\r
+\r
+Arguments:\r
+\r
+  Guid       - Pointer to GUID to print.\r
+\r
+  Buffer     - Buffe to print Guid into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN Size;\r
+\r
+  Size = SPrint (\r
+          Buffer,\r
+          BufferSize,\r
+          STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),\r
+          (UINTN)Guid->Data1,\r
+          (UINTN)Guid->Data2,\r
+          (UINTN)Guid->Data3,\r
+          (UINTN)Guid->Data4[0],\r
+          (UINTN)Guid->Data4[1],\r
+          (UINTN)Guid->Data4[2],\r
+          (UINTN)Guid->Data4[3],\r
+          (UINTN)Guid->Data4[4],\r
+          (UINTN)Guid->Data4[5],\r
+          (UINTN)Guid->Data4[6],\r
+          (UINTN)Guid->Data4[7]\r
+          );\r
+\r
+  //\r
+  // SPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+}\r
+\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN EFI_TIME   *Time,\r
+  OUT CHAR_W    *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints EFI_TIME.\r
+\r
+Arguments:\r
+\r
+  Time       - Pointer to EFI_TIME sturcture to print.\r
+\r
+  Buffer     - Buffer to print Time into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN Size;\r
+\r
+  Size = SPrint (\r
+          Buffer,\r
+          BufferSize,\r
+          STRING_W ("%02d/%02d/%04d  %02d:%02d"),\r
+          (UINTN)Time->Month,\r
+          (UINTN)Time->Day,\r
+          (UINTN)Time->Year,\r
+          (UINTN)Time->Hour,\r
+          (UINTN)Time->Minute\r
+          );\r
+\r
+  //\r
+  // SPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR_W      *Buffer,\r
+  IN  UINTN       BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints EFI_STATUS as a string. If string is\r
+  not known a hex value will be printed.\r
+\r
+Arguments:\r
+\r
+  Status     -  EFI_STATUS sturcture to print.\r
+\r
+  Buffer     - Buffer to print EFI_STATUS message string into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN   Size;\r
+  CHAR8   *Desc;\r
+\r
+  Desc = NULL;\r
+  \r
+  //\r
+  // Can't use global Status String Array as UINTN is not constant for EBC\r
+  //\r
+  if (Status == EFI_SUCCESS) { Desc = "Success"; } else \r
+  if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else\r
+  if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else\r
+  if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else\r
+  if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else\r
+  if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else\r
+  if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else\r
+  if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else\r
+  if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else\r
+  if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else\r
+  if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else\r
+  if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else\r
+  if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else\r
+  if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else\r
+  if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else\r
+  if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else\r
+  if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else\r
+  if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else\r
+  if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else\r
+  if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else\r
+  if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else\r
+  if (Status == EFI_ABORTED) { Desc = "Aborted"; } else\r
+  if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else\r
+  if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else\r
+  if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else\r
+  if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else\r
+  if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else\r
+  if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else\r
+  if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; } \r
+\r
+  //\r
+  // If we found a match, copy the message to the user's buffer. Otherwise\r
+  // sprint the hex status code to their buffer.\r
+  //\r
+  if (Desc != NULL) {\r
+    Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc);\r
+  } else {\r
+    Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status);\r
+  }\r
+\r
+  return Size - 1;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h
new file mode 100644 (file)
index 0000000..7d4394e
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  Private data for Print.c\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_H_\r
+#define _PRINT_H_\r
+\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Largest number of characters that can be printed out.\r
+//\r
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h
new file mode 100644 (file)
index 0000000..14052f0
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Unicode\r
+  STRING_W is L""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR16  CHAR_W;\r
+#define STRING_W(_s)                                  L##_s\r
+\r
+#define USPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define UvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+#include "EfiCommonLib.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
new file mode 100644 (file)
index 0000000..6b70aa6
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = AvSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of ASPrint. \r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index]  = '\0';\r
+\r
+  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h
new file mode 100644 (file)
index 0000000..65087c1
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Ascii\r
+  STRING_W is ""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR8 CHAR_W;\r
+#define STRING_W(_s)                                  _s\r
+\r
+#define ASPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define AvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         StrLen,\r
+  IN  CONST CHAR16  *Format,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  StrLen               - Maximum number of characters to put into buffer.\r
+  Format               - Format string\r
+  Marker               - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16      *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR16 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c
new file mode 100644 (file)
index 0000000..7c44ad5
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    AsciiFormat[Index] = (CHAR8) FormatString[Index];\r
+  }\r
+\r
+  AsciiFormat[Index]  = '\0';\r
+\r
+  Index               = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR16) AsciiResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c
new file mode 100644 (file)
index 0000000..0cae8e9
--- /dev/null
@@ -0,0 +1,618 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Graphics.c\r
+\r
+Abstract:\r
+\r
+  Support for Basic Graphics operations.\r
+\r
+  BugBug: Currently *.BMP files are supported. This will be replaced\r
+          when Tiano graphics format is supported.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "GraphicsLib.h"\r
+\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFV (\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+{\r
+  return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);\r
+}\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFVEx (\r
+  IN  EFI_HANDLE    ImageHandle,\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  ImageHandle   - The driver image handle of the caller. The parameter is used to\r
+                  optimize the loading of the image file so that the FV from which\r
+                  the driver image is loaded will be tried first. \r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+{\r
+  return GetImageEx (\r
+           ImageHandle,\r
+           &gEfiDefaultBmpLogoGuid,\r
+           EFI_SECTION_RAW,\r
+           Image,\r
+           ImageSize,\r
+           FALSE\r
+           );\r
+}\r
+\r
+\r
+EFI_STATUS\r
+ConvertBmpToGopBlt (\r
+  IN  VOID      *BmpImage,\r
+  IN  UINTN     BmpImageSize,\r
+  IN OUT VOID   **GopBlt,\r
+  IN OUT UINTN  *GopBltSize,\r
+  OUT UINTN     *PixelHeight,\r
+  OUT UINTN     *PixelWidth\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer\r
+  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
+  buffer is passed in it will be used if it is big enough.\r
+\r
+Arguments:\r
+\r
+  BmpImage      - Pointer to BMP file\r
+\r
+  BmpImageSize  - Number of bytes in BmpImage\r
+\r
+  GopBlt        - Buffer containing GOP version of BmpImage.\r
+\r
+  GopBltSize    - Size of GopBlt in bytes.\r
+\r
+  PixelHeight   - Height of GopBlt/BmpImage in pixels\r
+\r
+  PixelWidth    - Width of GopBlt/BmpImage in pixels\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - GopBlt and GopBltSize are returned. \r
+  EFI_UNSUPPORTED       - BmpImage is not a valid *.BMP image\r
+  EFI_BUFFER_TOO_SMALL  - The passed in GopBlt buffer is not big enough.\r
+                          GopBltSize will contain the required size.\r
+  EFI_OUT_OF_RESOURCES  - No enough buffer to allocate\r
+\r
+--*/\r
+{\r
+  UINT8                         *Image;\r
+  UINT8                         *ImageHeader;\r
+  BMP_IMAGE_HEADER              *BmpHeader;\r
+  BMP_COLOR_MAP                 *BmpColorMap;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+  UINTN                         BltBufferSize;\r
+  UINTN                         Index;\r
+  UINTN                         Height;\r
+  UINTN                         Width;\r
+  UINTN                         ImageIndex;\r
+  BOOLEAN                       IsAllocated;\r
+\r
+  BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
+  if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (BmpHeader->CompressionType != 0) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Calculate Color Map offset in the image.\r
+  //\r
+  Image       = BmpImage;\r
+  BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));\r
+\r
+  //\r
+  // Calculate graphics image data address in the image\r
+  //\r
+  Image         = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
+  ImageHeader   = Image;\r
+\r
+  BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+  IsAllocated   = FALSE;\r
+  if (*GopBlt == NULL) {\r
+    *GopBltSize = BltBufferSize;\r
+    *GopBlt     = EfiLibAllocatePool (*GopBltSize);\r
+    IsAllocated = TRUE;\r
+    if (*GopBlt == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  } else {\r
+    if (*GopBltSize < BltBufferSize) {\r
+      *GopBltSize = BltBufferSize;\r
+      return EFI_BUFFER_TOO_SMALL;\r
+    }\r
+  }\r
+\r
+  *PixelWidth   = BmpHeader->PixelWidth;\r
+  *PixelHeight  = BmpHeader->PixelHeight;\r
+\r
+  //\r
+  // Convert image from BMP to Blt buffer format\r
+  //\r
+  BltBuffer = *GopBlt;\r
+  for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {\r
+    Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];\r
+    for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {\r
+      switch (BmpHeader->BitPerPixel) {\r
+      case 1:\r
+        //\r
+        // Convert 1bit BMP to 24-bit color\r
+        //\r
+        for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
+          Blt->Red    = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
+          Blt->Green  = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;\r
+          Blt->Blue   = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;\r
+          Blt++;\r
+          Width++;\r
+        }\r
+\r
+        Blt --;\r
+        Width --;\r
+        break;\r
+\r
+      case 4:\r
+        //\r
+        // Convert BMP Palette to 24-bit color\r
+        //\r
+        Index       = (*Image) >> 4;\r
+        Blt->Red    = BmpColorMap[Index].Red;\r
+        Blt->Green  = BmpColorMap[Index].Green;\r
+        Blt->Blue   = BmpColorMap[Index].Blue;\r
+        if (Width < (BmpHeader->PixelWidth - 1)) {\r
+          Blt++;\r
+          Width++;\r
+          Index       = (*Image) & 0x0f;\r
+          Blt->Red    = BmpColorMap[Index].Red;\r
+          Blt->Green  = BmpColorMap[Index].Green;\r
+          Blt->Blue   = BmpColorMap[Index].Blue;\r
+        }\r
+        break;\r
+\r
+      case 8:\r
+        //\r
+        // Convert BMP Palette to 24-bit color\r
+        //\r
+        Blt->Red    = BmpColorMap[*Image].Red;\r
+        Blt->Green  = BmpColorMap[*Image].Green;\r
+        Blt->Blue   = BmpColorMap[*Image].Blue;\r
+        break;\r
+\r
+      case 24:\r
+        Blt->Blue   = *Image++;\r
+        Blt->Green  = *Image++;\r
+        Blt->Red    = *Image;\r
+        break;\r
+\r
+      default:\r
+        if (IsAllocated) {\r
+          gBS->FreePool (*GopBlt);\r
+          *GopBlt = NULL;\r
+        }\r
+        return EFI_UNSUPPORTED;\r
+        break;\r
+      };\r
+\r
+    }\r
+\r
+    ImageIndex = (UINTN) (Image - ImageHeader);\r
+    if ((ImageIndex % 4) != 0) {\r
+      //\r
+      // Bmp Image starts each row on a 32-bit boundary!\r
+      //\r
+      Image = Image + (4 - (ImageIndex % 4));\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
+  This is the ConInHandle and ConIn handle in the EFI system table. All key\r
+  presses will be ignored until the Password is typed in. The only way to\r
+  disable the password is to type it in to a ConIn device.\r
+\r
+Arguments:\r
+  Password - Password used to lock ConIn device\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = ConsoleControl->LockStdIn (ConsoleControl, Password);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EnableQuietBoot (\r
+  IN  EFI_GUID  *LogoFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+  to the UGA device. Put up LogoFile on every UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile - File name of logo to display on the center of the screen.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  return EnableQuietBootEx (LogoFile, NULL);\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EnableQuietBootEx (\r
+  IN  EFI_GUID    *LogoFile,\r
+  IN  EFI_HANDLE  ImageHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going\r
+  to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile - File name of logo to display on the center of the screen.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+  EFI_OEM_BADGING_PROTOCOL      *Badging;\r
+  UINT32                        SizeOfX;\r
+  UINT32                        SizeOfY;\r
+  INTN                          DestX;\r
+  INTN                          DestY;\r
+  UINT8                         *ImageData;\r
+  UINTN                         ImageSize;\r
+  UINTN                         BltSize;\r
+  UINT32                        Instance;\r
+  EFI_BADGING_FORMAT            Format;\r
+  EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
+  UINTN                         CoordinateX;\r
+  UINTN                         CoordinateY;\r
+  UINTN                         Height;\r
+  UINTN                         Width;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
+  UINT32                        ColorDepth;\r
+  UINT32                        RefreshRate;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  UgaDraw = NULL;\r
+  //\r
+  // Try to open GOP first\r
+  //\r
+  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, &GraphicsOutput);\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+    //\r
+    // Open GOP failed, try to open UGA\r
+    //\r
+    Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, &UgaDraw);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  Badging = NULL;\r
+  Status  = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, &Badging);\r
+\r
+  ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else {\r
+    Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  Instance = 0;\r
+  while (1) {\r
+    ImageData = NULL;\r
+    ImageSize = 0;\r
+\r
+    if (Badging != NULL) {\r
+      Status = Badging->GetImage (\r
+                          Badging,\r
+                          &Instance,\r
+                          &Format,\r
+                          &ImageData,\r
+                          &ImageSize,\r
+                          &Attribute,\r
+                          &CoordinateX,\r
+                          &CoordinateY\r
+                          );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      //\r
+      // Currently only support BMP format\r
+      //\r
+      if (Format != EfiBadgingFormatBMP) {\r
+        gBS->FreePool (ImageData);\r
+        continue;\r
+      }\r
+    } else {\r
+      Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, &ImageData, &ImageSize);\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+\r
+      CoordinateX = 0;\r
+      CoordinateY = 0;\r
+      Attribute   = EfiBadgingDisplayAttributeCenter;\r
+    }\r
+\r
+    Blt = NULL;\r
+    Status = ConvertBmpToGopBlt (\r
+              ImageData,\r
+              ImageSize,\r
+              &Blt,\r
+              &BltSize,\r
+              &Height,\r
+              &Width\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool (ImageData);\r
+      if (Badging == NULL) {\r
+        return Status;\r
+      } else {\r
+        continue;\r
+      }\r
+    }\r
+\r
+    switch (Attribute) {\r
+    case EfiBadgingDisplayAttributeLeftTop:\r
+      DestX = CoordinateX;\r
+      DestY = CoordinateY;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterTop:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = CoordinateY;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeRightTop:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = CoordinateY;;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterRight:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeRightBottom:\r
+      DestX = (SizeOfX - Width - CoordinateX);\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterBottom:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeLeftBottom:\r
+      DestX = CoordinateX;\r
+      DestY = (SizeOfY - Height - CoordinateY);\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenterLeft:\r
+      DestX = CoordinateX;\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    case EfiBadgingDisplayAttributeCenter:\r
+      DestX = (SizeOfX - Width) / 2;\r
+      DestY = (SizeOfY - Height) / 2;\r
+      break;\r
+\r
+    default:\r
+      DestX = CoordinateX;\r
+      DestY = CoordinateY;\r
+      break;\r
+    }\r
+\r
+    if ((DestX >= 0) && (DestY >= 0)) {\r
+      if (GraphicsOutput != NULL) {\r
+        Status = GraphicsOutput->Blt (\r
+                            GraphicsOutput,\r
+                            Blt,\r
+                            EfiBltBufferToVideo,\r
+                            0,\r
+                            0,\r
+                            (UINTN) DestX,\r
+                            (UINTN) DestY,\r
+                            Width,\r
+                            Height,\r
+                            Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                            );\r
+      } else {\r
+        Status = UgaDraw->Blt (\r
+                            UgaDraw,\r
+                            (EFI_UGA_PIXEL *) Blt,\r
+                            EfiUgaBltBufferToVideo,\r
+                            0,\r
+                            0,\r
+                            (UINTN) DestX,\r
+                            (UINTN) DestY,\r
+                            Width,\r
+                            Height,\r
+                            Width * sizeof (EFI_UGA_PIXEL)\r
+                            );\r
+      }\r
+    }\r
+\r
+    gBS->FreePool (ImageData);\r
+    gBS->FreePool (Blt);\r
+\r
+    if (Badging == NULL) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+DisableQuietBoot (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA \r
+  Simple Text Out screens will now be synced up with all non GOP/UGA output devices\r
+\r
+Arguments:\r
+\r
+  NONE\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - GOP/UGA devices are back in text mode and synced up.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf
new file mode 100644 (file)
index 0000000..02df84a
--- /dev/null
@@ -0,0 +1,50 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    Graphics.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = GraphicsLite\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  Graphics.c\r
+  Print.c\r
+  Print.h\r
+  Unicode\PrintWidth.h\r
+  Unicode\Sprint.c\r
+\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+  EfiDriverLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
new file mode 100644 (file)
index 0000000..94a1adb
--- /dev/null
@@ -0,0 +1,436 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+static EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mEfiColors[16] = {\r
+  0x00, 0x00, 0x00, 0x00,\r
+  0x98, 0x00, 0x00, 0x00,\r
+  0x00, 0x98, 0x00, 0x00,\r
+  0x98, 0x98, 0x00, 0x00,\r
+  0x00, 0x00, 0x98, 0x00,\r
+  0x98, 0x00, 0x98, 0x00,\r
+  0x00, 0x98, 0x98, 0x00,\r
+  0x98, 0x98, 0x98, 0x00,\r
+  0x10, 0x10, 0x10, 0x00,\r
+  0xff, 0x10, 0x10, 0x00,\r
+  0x10, 0xff, 0x10, 0x00,\r
+  0xff, 0xff, 0x10, 0x00,\r
+  0x10, 0x10, 0xff, 0x00,\r
+  0xf0, 0x10, 0xff, 0x00,\r
+  0x10, 0xff, 0xff, 0x00,\r
+  0xff, 0xff, 0xff, 0x00,\r
+};\r
+\r
+\r
+UINTN\r
+_IPrint (\r
+  IN EFI_GRAPHICS_OUTPUT_PROTOCOL     *GraphicsOutput,\r
+  IN EFI_UGA_DRAW_PROTOCOL            *UgaDraw,\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL     *Sto,\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background,\r
+  IN CHAR16                           *fmt,\r
+  IN VA_LIST                          args\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
+\r
+Arguments:\r
+\r
+  GraphicsOutput  - Graphics output protocol interface\r
+\r
+  UgaDraw         - UGA draw protocol interface\r
+  \r
+  Sto             - Simple text out protocol interface\r
+  \r
+  X               - X coordinate to start printing\r
+  \r
+  Y               - Y coordinate to start printing\r
+  \r
+  Foreground      - Foreground color\r
+  \r
+  Background      - Background color\r
+  \r
+  fmt             - Format string\r
+  \r
+  args            - Print arguments\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS             -  success\r
+  EFI_OUT_OF_RESOURCES    -  out of resources\r
+\r
+--*/\r
+{\r
+  VOID                           *Buffer;\r
+  EFI_STATUS                     Status;\r
+  UINT16                         GlyphWidth;\r
+  UINT32                         GlyphStatus;\r
+  UINT16                         StringIndex;\r
+  UINTN                          Index;\r
+  CHAR16                         *UnicodeWeight;\r
+  EFI_NARROW_GLYPH               *Glyph;\r
+  EFI_HII_PROTOCOL               *Hii;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *LineBuffer;\r
+  UINT32                         HorizontalResolution;\r
+  UINT32                         VerticalResolution;\r
+  UINT32                         ColorDepth;\r
+  UINT32                         RefreshRate;\r
+  UINTN                          BufferLen;\r
+  UINTN                          LineBufferLen;\r
+\r
+  GlyphStatus = 0;\r
+\r
+  //\r
+  // For now, allocate an arbitrarily long buffer\r
+  //\r
+  Buffer = EfiLibAllocateZeroPool (0x10000);\r
+  if (Buffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else {\r
+    UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
+  }\r
+  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
+  \r
+  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;\r
+  LineBuffer = EfiLibAllocatePool (LineBufferLen);\r
+  if (LineBuffer == NULL) {\r
+    gBS->FreePool (Buffer);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  VSPrint (Buffer, 0x10000, fmt, args);\r
+  \r
+  UnicodeWeight = (CHAR16 *) Buffer;\r
+\r
+  for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
+    if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
+        UnicodeWeight[Index] == CHAR_LINEFEED  ||\r
+        UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
+      UnicodeWeight[Index] = 0;\r
+    }\r
+  }\r
+\r
+  BufferLen = EfiStrLen (Buffer);\r
+\r
+  if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
+     Status = EFI_INVALID_PARAMETER;\r
+     goto Error;\r
+  }\r
+\r
+  for (Index = 0; Index < BufferLen; Index++) {\r
+    StringIndex = (UINT16) Index;\r
+    Status      = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus);\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+\r
+    if (Foreground == NULL || Background == NULL) {\r
+      Status = Hii->GlyphToBlt (\r
+                      Hii,\r
+                      (UINT8 *) Glyph,\r
+                      mEfiColors[Sto->Mode->Attribute & 0x0f],\r
+                      mEfiColors[Sto->Mode->Attribute >> 4],\r
+                      BufferLen,\r
+                      GlyphWidth,\r
+                      GLYPH_HEIGHT,\r
+                      &LineBuffer[Index * GLYPH_WIDTH]\r
+                      );\r
+    } else {\r
+      Status = Hii->GlyphToBlt (\r
+                      Hii,\r
+                      (UINT8 *) Glyph,\r
+                      *Foreground,\r
+                      *Background,\r
+                      BufferLen,\r
+                      GlyphWidth,\r
+                      GLYPH_HEIGHT,\r
+                      &LineBuffer[Index * GLYPH_WIDTH]\r
+                      );\r
+    }\r
+  }\r
+\r
+  //\r
+  // Blt a character to the screen\r
+  //\r
+  if (GraphicsOutput != NULL) {\r
+    Status = GraphicsOutput->Blt (\r
+                        GraphicsOutput,\r
+                        LineBuffer,\r
+                        EfiBltBufferToVideo,\r
+                        0,\r
+                        0,\r
+                        X,\r
+                        Y,\r
+                        GLYPH_WIDTH * BufferLen,\r
+                        GLYPH_HEIGHT,\r
+                        GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                        );\r
+  } else {\r
+    Status = UgaDraw->Blt (\r
+                        UgaDraw,\r
+                        (EFI_UGA_PIXEL *) LineBuffer,\r
+                        EfiUgaBltBufferToVideo,\r
+                        0,\r
+                        0,\r
+                        X,\r
+                        Y,\r
+                        GLYPH_WIDTH * BufferLen,\r
+                        GLYPH_HEIGHT,\r
+                        GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL)\r
+                        );\r
+  }\r
+\r
+Error:\r
+  gBS->FreePool (LineBuffer);\r
+  gBS->FreePool (Buffer);\r
+  return Status;\r
+}\r
+\r
+\r
+UINTN\r
+PrintXY (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
+  IN CHAR_W                           *Fmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Prints a formatted unicode string to the default console\r
+\r
+Arguments:\r
+\r
+    X           - X coordinate to start printing\r
+    \r
+    Y           - Y coordinate to start printing\r
+    \r
+    ForeGround  - Foreground color\r
+    \r
+    BackGround  - Background color\r
+\r
+    Fmt         - Format string\r
+\r
+    ...         - Print arguments\r
+\r
+Returns:\r
+\r
+    Length of string printed to the console\r
+\r
+--*/\r
+{\r
+  EFI_HANDLE                    Handle;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Sto;\r
+  EFI_STATUS                    Status;\r
+  VA_LIST                       Args;\r
+\r
+  VA_START (Args, Fmt);\r
+\r
+  Handle = gST->ConsoleOutHandle;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  &GraphicsOutput\r
+                  );\r
+\r
+  UgaDraw = NULL;\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    Handle,\r
+                    &gEfiUgaDrawProtocolGuid,\r
+                    &UgaDraw\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  &Sto\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+}\r
+\r
+\r
+UINTN\r
+SPrint (\r
+  OUT CHAR_W        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+VSPrint (\r
+  OUT CHAR_W        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_PRINT_PROTOCOL  *PrintProtocol;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiPrintProtocolGuid,\r
+                  NULL,\r
+                  &PrintProtocol\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  } else {\r
+    return PrintProtocol->VSPrint (\r
+                            StartOfBuffer,\r
+                            BufferSize,\r
+                            FormatString,\r
+                            Marker\r
+                            );\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h
new file mode 100644 (file)
index 0000000..7d4394e
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  Private data for Print.c\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_H_\r
+#define _PRINT_H_\r
+\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Largest number of characters that can be printed out.\r
+//\r
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h
new file mode 100644 (file)
index 0000000..e8e8d6f
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Unicode\r
+  STRING_W is L""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR16  CHAR_W;\r
+#define STRING_W(_s)                                  L##_s\r
+\r
+#define USPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define UvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+#include "EfiCommonLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
new file mode 100644 (file)
index 0000000..6b70aa6
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = AvSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of ASPrint. \r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index]  = '\0';\r
+\r
+  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf
new file mode 100644 (file)
index 0000000..6f34527
--- /dev/null
@@ -0,0 +1,46 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#   HobLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = HobLib\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  Hob.c\r
+\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+  EdkGuidLib\r
+  EdkFrameworkGuidLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c
new file mode 100644 (file)
index 0000000..ecfc7a2
--- /dev/null
@@ -0,0 +1,521 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  hob.c\r
+\r
+Abstract:\r
+\r
+  Support for hob operation\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "PeiHob.h"\r
+#include EFI_GUID_DEFINITION (IoBaseHob)\r
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)\r
+\r
+VOID *\r
+GetHob (\r
+  IN UINT16  Type,\r
+  IN VOID    *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the first instance of a HOB type in a HOB list.\r
+  \r
+Arguments:\r
+\r
+  Type          The HOB type to return.\r
+  HobStart      The first HOB in the HOB list.\r
+    \r
+Returns:\r
+\r
+  HobStart      There were no HOBs found with the requested type.\r
+  else          Returns the first HOB with the matching type.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (HobStart == NULL) {\r
+    return HobStart;\r
+  }\r
+\r
+  //\r
+  // Parse the HOB list, stop if end of list or matching type found.\r
+  //\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+\r
+    if (Hob.Header->HobType == Type) {\r
+      break;\r
+    }\r
+\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+  \r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (END_OF_HOB_LIST (Hob)) {\r
+    return HobStart;\r
+  }\r
+\r
+  return (VOID *) (Hob.Raw);\r
+}\r
+\r
+UINTN\r
+GetHobListSize (\r
+  IN VOID  *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get size of hob list.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+\r
+Returns:\r
+\r
+  Size of hob list.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+  UINTN                 Size;\r
+\r
+  Hob.Raw = HobStart;\r
+  Size    = 0;\r
+\r
+  while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {\r
+    Size += Hob.Header->HobLength;\r
+    Hob.Raw += Hob.Header->HobLength;\r
+  }\r
+\r
+  Size += Hob.Header->HobLength;\r
+\r
+  return Size;\r
+}\r
+\r
+UINT32\r
+GetHobVersion (\r
+  IN VOID  *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get hob version.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+\r
+Returns:\r
+\r
+  Hob version.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  return Hob.HandoffInformationTable->Version;\r
+}\r
+\r
+EFI_STATUS\r
+GetHobBootMode (\r
+  IN  VOID           *HobStart,\r
+  OUT EFI_BOOT_MODE  *BootMode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get current boot mode.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  \r
+  BootMode      - Current boot mode recorded in PHIT hob\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND     - Invalid hob header\r
+  \r
+  EFI_SUCCESS       - Boot mode found\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  *BootMode = Hob.HandoffInformationTable->BootMode;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetCpuHobInfo (\r
+  IN  VOID   *HobStart,\r
+  OUT UINT8  *SizeOfMemorySpace,\r
+  OUT UINT8  *SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get information recorded in CPU hob (Memory space size, Io space size)\r
+\r
+Arguments:\r
+\r
+  HobStart            - Start pointer of hob list\r
+  \r
+  SizeOfMemorySpace   - Size of memory size\r
+  \r
+  SizeOfIoSpace       - Size of IO size\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND     - CPU hob not found\r
+  \r
+  EFI_SUCCESS       - CPU hob found and information got.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  CpuHob;\r
+\r
+  CpuHob.Raw  = HobStart;\r
+  CpuHob.Raw  = GetHob (EFI_HOB_TYPE_CPU, CpuHob.Raw);\r
+  if (CpuHob.Header->HobType != EFI_HOB_TYPE_CPU) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  *SizeOfMemorySpace  = CpuHob.Cpu->SizeOfMemorySpace;\r
+  *SizeOfIoSpace      = CpuHob.Cpu->SizeOfIoSpace;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetDxeCoreHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                *Length,\r
+  OUT VOID                  **EntryPoint,\r
+  OUT EFI_GUID              **FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get memory allocation hob created for DXE core and extract its information\r
+\r
+Arguments:\r
+\r
+  HobStart        - Start pointer of the hob list\r
+  BaseAddress     - Start address of memory allocated for DXE core\r
+  Length          - Length of memory allocated for DXE core\r
+  EntryPoint      - DXE core file name\r
+  FileName        - File Name\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND   - DxeCoreHob not found  \r
+  EFI_SUCCESS     - DxeCoreHob found and information got\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  DxeCoreHob;\r
+  \r
+  \r
+  DxeCoreHob.Raw  = HobStart;\r
+  DxeCoreHob.Raw  = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);\r
+  while (DxeCoreHob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION && \r
+         !EfiCompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name, \r
+                          &gEfiHobMemeryAllocModuleGuid)) {\r
+\r
+    DxeCoreHob.Raw  = GET_NEXT_HOB (DxeCoreHob);\r
+    DxeCoreHob.Raw  = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);\r
+\r
+  }\r
+\r
+  if (DxeCoreHob.Header->HobType != EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  *BaseAddress  = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress;\r
+  *Length       = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;\r
+  *EntryPoint   = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;\r
+  *FileName     = &DxeCoreHob.MemoryAllocationModule->ModuleName;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetNextFirmwareVolumeHob (\r
+  IN OUT VOID                  **HobStart,\r
+  OUT    EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT    UINT64                *Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get next firmware volume hob from HobStart\r
+\r
+Arguments:\r
+\r
+  HobStart        - Start pointer of hob list\r
+  \r
+  BaseAddress     - Start address of next firmware volume\r
+  \r
+  Length          - Length of next firmware volume\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND   - Next firmware volume not found\r
+  \r
+  EFI_SUCCESS     - Next firmware volume found with address information\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  FirmwareVolumeHob;\r
+\r
+  FirmwareVolumeHob.Raw = *HobStart;\r
+  if (END_OF_HOB_LIST (FirmwareVolumeHob)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV, *HobStart);\r
+  if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  *BaseAddress  = FirmwareVolumeHob.FirmwareVolume->BaseAddress;\r
+  *Length       = FirmwareVolumeHob.FirmwareVolume->Length;\r
+\r
+  *HobStart     = GET_NEXT_HOB (FirmwareVolumeHob);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+EFI_STATUS\r
+GetNextFirmwareVolume2Hob (\r
+  IN OUT VOID                  **HobStart,\r
+  OUT    EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT    UINT64                *Length,\r
+  OUT    EFI_GUID              *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get next firmware volume2 hob from HobStart\r
+\r
+Arguments:\r
+\r
+  HobStart        - Start pointer of hob list\r
+  \r
+  BaseAddress     - Start address of next firmware volume\r
+  \r
+  Length          - Length of next firmware volume\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND   - Next firmware volume not found\r
+  \r
+  EFI_SUCCESS     - Next firmware volume found with address information\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  FirmwareVolumeHob;\r
+\r
+  FirmwareVolumeHob.Raw = *HobStart;\r
+  if (END_OF_HOB_LIST (FirmwareVolumeHob)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV2, *HobStart);\r
+  if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV2) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  *BaseAddress  = FirmwareVolumeHob.FirmwareVolume2->BaseAddress;\r
+  *Length       = FirmwareVolumeHob.FirmwareVolume2->Length;\r
+  EfiCommonLibCopyMem(FileName,&FirmwareVolumeHob.FirmwareVolume2->FileName,sizeof(EFI_GUID));\r
+\r
+  *HobStart     = GET_NEXT_HOB (FirmwareVolumeHob);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+#endif\r
+\r
+EFI_STATUS\r
+GetNextGuidHob (\r
+  IN OUT VOID      **HobStart,\r
+  IN     EFI_GUID  * Guid,\r
+  OUT    VOID      **Buffer,\r
+  OUT    UINTN     *BufferSize OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the next guid hob.\r
+  \r
+Arguments:\r
+  HobStart        A pointer to the start hob.\r
+  Guid            A pointer to a guid.\r
+  Buffer          A pointer to the buffer.\r
+  BufferSize      Buffer size.\r
+  \r
+Returns:\r
+  Status code.\r
+\r
+  EFI_NOT_FOUND          - Next Guid hob not found\r
+  \r
+  EFI_SUCCESS            - Next Guid hob found and data for this Guid got\r
+  \r
+  EFI_INVALID_PARAMETER  - invalid parameter\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  if (Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {\r
+\r
+    GuidHob.Raw = *HobStart;\r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    GuidHob.Raw = GetHob (EFI_HOB_TYPE_GUID_EXTENSION, *HobStart);\r
+    if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+      if (EfiCompareGuid (Guid, &GuidHob.Guid->Name)) {\r
+        Status  = EFI_SUCCESS;\r
+        *Buffer = (VOID *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        if (BufferSize != NULL) {\r
+          *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);\r
+        }\r
+      }\r
+    }\r
+\r
+    *HobStart = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+#define PAL_ENTRY_HOB {0xe53cb8cc, 0xd62c, 0x4f74, 0xbd, 0xda, 0x31, 0xe5, 0x8d, 0xe5, 0x3e, 0x2}\r
+EFI_GUID  gPalEntryHob = PAL_ENTRY_HOB;\r
+\r
+EFI_STATUS\r
+GetPalEntryHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *PalEntry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PAL entry from PalEntryHob\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  \r
+  PalEntry      - Pointer to PAL entry\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+--*/\r
+{\r
+  VOID        *Buffer;\r
+  UINTN       BufferSize;\r
+  EFI_STATUS  Status;\r
+  VOID        *HobStart2;\r
+\r
+  HobStart2 = HobStart;\r
+  Status = GetNextGuidHob (\r
+            &HobStart2,\r
+            &gPalEntryHob,\r
+            &Buffer,\r
+            &BufferSize\r
+            );\r
+\r
+  *PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+GetIoPortSpaceAddressHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *IoPortSpaceAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get IO port space address from IoBaseHob.\r
+\r
+Arguments:\r
+\r
+  HobStart              - Start pointer of hob list\r
+  \r
+  IoPortSpaceAddress    - IO port space address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+\r
+  VOID        *Buffer;\r
+  UINTN       BufferSize;\r
+  EFI_STATUS  Status;\r
+  VOID        *HobStart2;\r
+\r
+  HobStart2 = HobStart;\r
+  Status = GetNextGuidHob (\r
+            &HobStart2,\r
+            &gEfiIoBaseHobGuid,\r
+            &Buffer,\r
+            &BufferSize\r
+            );\r
+\r
+  *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h
new file mode 100644 (file)
index 0000000..9509d25
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ProcDep.h\r
+\r
+Abstract:\r
+\r
+  EBC- specific runtime lib. Only used to get a clean build of \r
+  EFI libraries.\r
+\r
+--*/\r
+\r
+#ifndef _PROC_DEP_H_\r
+#define _PROC_DEP_H_\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h
new file mode 100644 (file)
index 0000000..a2e9f66
--- /dev/null
@@ -0,0 +1,294 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiCombinationLib.h\r
+\r
+Abstract:\r
+\r
+  Library functions that can be called in both PEI and DXE phase\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMBINATION_LIB_H_\r
+#define _EFI_COMBINATION_LIB_H_\r
+\r
+EFI_STATUS\r
+EfiInitializeCommonDriverLib (\r
+  IN EFI_HANDLE   ImageHandle,\r
+  IN VOID         *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize lib function calling phase: PEI or DXE\r
+  \r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+       \r
+  SystemTable     -    A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonIoRead (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io read operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of read operation\r
+  Address - Start IO address to read\r
+  Count   - Read count\r
+  Buffer  - Buffer to store result\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonIoWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io write operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of write operation\r
+  Address - Start IO address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonPciRead (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci read operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI read\r
+  Address - PCI address to read\r
+  Count   - Read count\r
+  Buffer  - Output buffer for the read\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonPciWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci write operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI write\r
+  Address - PCI address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonStall (\r
+  IN  UINTN      Microseconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Induces a fine-grained stall.\r
+\r
+Arguments:\r
+\r
+  Microseconds  - The number of microseconds to stall execution.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonCopyMem (\r
+  IN VOID       *Destination,\r
+  IN VOID       *Source,\r
+  IN UINTN      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonAllocatePages (\r
+  IN EFI_ALLOCATE_TYPE          Type,\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *Memory\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocates memory pages from the system.\r
+\r
+Arguments:\r
+\r
+  Type        - The type of allocation to perform.\r
+  MemoryType  - The type of memory to allocate.\r
+  Pages       - The number of contiguous pages to allocate.\r
+  Memory      - Pointer to a physical address.\r
+\r
+Returns:\r
+\r
+  EFI_OUT_OF_RESOURCES                 -       The pages could not be allocated.\r
+  \r
+  EFI_INVALID_PARAMETER                        -       Invalid parameter\r
+  \r
+  EFI_NOT_FOUND                                                        -       The requested pages could not be found.\r
+  \r
+  EFI_SUCCESS                                                          -       The requested pages were allocated.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonLocateInterface (\r
+  IN EFI_GUID                   *Guid,\r
+  OUT VOID                      **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the first protocol instance that matches the given protocol.\r
+\r
+Arguments:\r
+\r
+  Guid      - Provides the protocol to search for.\r
+  Interface - On return, a pointer to the first interface that matches Protocol\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+  \r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+       Status code\r
+       \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h
new file mode 100644 (file)
index 0000000..4eaacc5
--- /dev/null
@@ -0,0 +1,1359 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiCommonLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMMON_LIB_H_\r
+#define _EFI_COMMON_LIB_H_\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  IN OUT VOID **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the EFI 1.0 System Tabl entry with TableGuid\r
+\r
+Arguments:\r
+\r
+  TableGuid - Name of entry to return in the system table\r
+  Table     - Pointer in EFI system table associated with TableGuid\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Table returned;\r
+  EFI_NOT_FOUND - TableGuid not in EFI system table\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// ASPrint and AvSPrint definitions you must include the specific library\r
+// to get the expected behavior from the two functions\r
+// PEI:  PeiLib\r
+// Graphics:  Dxe\Graphics\Unicode  Dxe\Graphics\ASCII\r
+// ASCII: Dxe\Print\ASCII\r
+// Unicode: Dxe\Print\Unicode\r
+//\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8       *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8       *StartOfBuffer,\r
+  IN  UINTN       StrSize,\r
+  IN  CONST CHAR8 *Format,\r
+  IN  VA_LIST     Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of ASPrint. \r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Narrow char buffer to print the results of the parsing of Format into.\r
+  StrSize       - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Lib functions which can be used in both PEI and DXE pahse\r
+//\r
+EFI_STATUS\r
+EfiInitializeCommonDriverLib (\r
+  IN EFI_HANDLE   ImageHandle,\r
+  IN VOID         *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize lib function calling phase: PEI or DXE\r
+  \r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonIoRead (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io read operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of read operation\r
+  Address - Start IO address to read\r
+  Count   - Read count\r
+  Buffer  - Buffer to store result\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonIoWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io write operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of write operation\r
+  Address - Start IO address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonPciRead (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci read operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI read\r
+  Address - PCI address to read\r
+  Count   - Read count\r
+  Buffer  - Output buffer for the read\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCommonPciWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci write operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI write\r
+  Address - PCI address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+EfiCompareGuid (\r
+  IN EFI_GUID *Guid1,\r
+  IN EFI_GUID *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  TRUE     if Guid1 == Guid2\r
+  FALSE    if Guid1 != Guid2\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCommonLibSetMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size,\r
+  IN UINT8  Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to Value for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+  Value   - Value of the set operation.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCommonLibCopyMem (\r
+  IN VOID     *Destination,\r
+  IN VOID     *Source,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+INTN\r
+EfiCompareMem (\r
+  IN VOID     *MemOne,\r
+  IN VOID     *MemTwo,\r
+  IN UINTN    Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two memory buffers of a given length.\r
+\r
+Arguments:\r
+\r
+  MemOne - First memory buffer\r
+\r
+  MemTwo - Second memory buffer\r
+\r
+  Len    - Length of Mem1 and Mem2 memory regions to compare\r
+\r
+Returns:\r
+\r
+  = 0     if MemOne == MemTwo\r
+  \r
+  > 0     if MemOne > MemTwo\r
+  \r
+  < 0     if MemOne < MemTwo\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCommonLibZeroMem (\r
+  IN VOID     *Buffer,\r
+  IN UINTN    Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Min Max\r
+//\r
+#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))\r
+#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b))\r
+\r
+//\r
+// Align a pointer. The pointer represented by ptr is aligned to the bound.\r
+// The resulting pointer is always equal or greater (by no more than bound-1)\r
+// than the ptr. I.e., if the ptr is already aligned, the result will be equal to ptr.\r
+// Valid values for bound are powers of two: 2, 4, 8, 16, 32 etc.\r
+// The returned pointer is VOID* this assignment-compatible with all pointer types.\r
+//\r
+#define EFI_ALIGN(ptr, bound) ((VOID *) (((UINTN) (ptr) + ((UINTN) (bound) - 1)) &~((UINTN) (bound) - 1)))\r
+\r
+//\r
+// Alignment tests.\r
+//\r
+#define EFI_UINTN_ALIGN_MASK    (sizeof (UINTN) - 1)\r
+#define EFI_UINTN_ALIGNED(ptr)  (((UINTN) (ptr)) & EFI_UINTN_ALIGN_MASK)\r
+\r
+//\r
+// Integer division with rounding to the nearest rather than truncating.\r
+// For example 8/3=2 but EFI_IDIV_ROUND(8,3)=3. 1/3=0 and EFI_IDIV_ROUND(1,3)=0.\r
+// A half is rounded up e.g., EFI_IDIV_ROUND(1,2)=1 but 1/2=0.\r
+//\r
+#define EFI_IDIV_ROUND(r, s)  ((r) / (s) + (((2 * ((r) % (s))) < (s)) ? 0 : 1))\r
+\r
+//\r
+// ReportStatusCode.c init\r
+//\r
+VOID  *\r
+EfiConstructStatusCodeData (\r
+  IN  UINT16                    DataSize,\r
+  IN  EFI_GUID                  *TypeGuid,\r
+  IN OUT  EFI_STATUS_CODE_DATA  *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Construct stanader header for optional data passed into ReportStatusCode\r
+\r
+Arguments:\r
+\r
+  DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header\r
+  TypeGuid - GUID to place in EFI_STATUS_CODE_DATA\r
+  Data     - Buffer to use.\r
+\r
+Returns:\r
+\r
+  Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiDebugVPrintWorker (\r
+  IN  UINTN                   ErrorLevel,\r
+  IN  CHAR8                   *Format,\r
+  IN  VA_LIST                 Marker,\r
+  IN  UINTN                   BufferSize,\r
+  IN OUT VOID                 *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  Marker     - VarArgs\r
+\r
+  BufferSize - Size of Buffer.\r
+\r
+  Buffer     - Caller allocated buffer, contains ReportStatusCode extended data\r
+  \r
+Returns:\r
+  \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiDebugAssertWorker (\r
+  IN CHAR8                    *FileName,\r
+  IN INTN                     LineNumber,\r
+  IN CHAR8                    *Description,\r
+  IN UINTN                    BufferSize,\r
+  IN OUT VOID                 *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded DEADLOOP ().\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  FileName    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT().\r
+\r
+  Description - Description, usually the assertion,\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+  Buffer     - Caller allocated buffer, contains ReportStatusCode extendecd data\r
+\r
+Returns:\r
+  \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+ReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN EFI_STATUS_CODE_DATA     *Data,\r
+  OUT CHAR8                   **Filename,\r
+  OUT CHAR8                   **Description,\r
+  OUT UINT32                  *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract assert information from status code data.\r
+\r
+Arguments:\r
+\r
+  CodeType    - Code type\r
+  Value       - Code value\r
+  Data        - Optional data associated with this status code.\r
+  Filename    - Filename extracted from Data\r
+  Description - Description extracted from Data\r
+  LineNumber  - Line number extracted from Data\r
+\r
+Returns:\r
+\r
+  TRUE      - Successfully extracted\r
+  \r
+  FALSE     - Extraction failed\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+ReportStatusCodeExtractDebugInfo (\r
+  IN EFI_STATUS_CODE_DATA     *Data,\r
+  OUT UINT32                  *ErrorLevel,\r
+  OUT VA_LIST                 *Marker,\r
+  OUT CHAR8                   **Format\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract debug information from status code data.\r
+\r
+Arguments:\r
+\r
+  Data        - Optional data associated with status code.\r
+  ErrorLevel  - Error level extracted from Data\r
+  Marker      - VA_LIST extracted from Data\r
+  Format      - Format string extracted from Data\r
+\r
+Returns:\r
+\r
+  TRUE      - Successfully extracted\r
+  \r
+  FALSE     - Extraction failed\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+CodeTypeToPostCode (\r
+  IN  EFI_STATUS_CODE_TYPE    CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  OUT UINT8                   *PostCode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert code value to an 8 bit post code\r
+\r
+Arguments:\r
+\r
+  CodeType  - Code type\r
+  Value     - Code value\r
+  PostCode  - Post code as output\r
+\r
+Returns:\r
+\r
+  TRUE    - Successfully converted\r
+\r
+  FALSE   - Convertion failed\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// math.c\r
+//\r
+UINT64\r
+MultU64x32 (\r
+  IN  UINT64  Multiplicand,\r
+  IN  UINTN   Multiplier\r
+  )\r
+/*++  \r
+  \r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+;\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN  UINT64  Dividend,\r
+  IN  UINTN   Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
\r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN  UINT64  Operand,\r
+  IN  UINTN   Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN  UINT64  Operand,\r
+  IN  UINTN   Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
\r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+Power10U64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Power\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raise 10 to the power of Power, and multiply the result with Operand\r
+\r
+Arguments:\r
+\r
+  Operand  - multiplicand\r
+  Power    - power\r
+\r
+Returns:\r
+\r
+  Operand * 10 ^ Power\r
+\r
+--*/\r
+;\r
+\r
+UINT8\r
+Log2 (\r
+  IN UINT64   Operand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculates and floors logarithms based on 2\r
+\r
+Arguments:\r
+\r
+  Operand - value to calculate logarithm\r
\r
+Returns:\r
+\r
+  The largest integer that is less than or equal\r
+  to the logarithm of Operand based on 2 \r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+GetPowerOfTwo (\r
+  IN  UINT64  Input\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculates the largest integer that is both \r
+  a power of two and less than Input\r
+\r
+Arguments:\r
+\r
+  Input  - value to calculate power of two\r
+\r
+Returns:\r
+\r
+  the largest integer that is both  a power of \r
+  two and less than Input\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Unicode String primatives\r
+//\r
+VOID\r
+EfiStrCpy (\r
+  IN CHAR16   *Destination,\r
+  IN CHAR16   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Unicode string Source to Destination.\r
+\r
+Arguments:\r
+  Destination - Location to copy string\r
+  Source      - String to copy\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiStrnCpy (\r
+  OUT CHAR16    *Dst,\r
+  IN  CHAR16    *Src,\r
+  IN  UINTN     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy a string from source to destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiStrLen (\r
+  IN CHAR16   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number of Unicode characters in String. This is not the same as\r
+  the length of the string in bytes.\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of Unicode characters in String\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiStrSize (\r
+  IN CHAR16   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number bytes in the Unicode String. This is not the same as\r
+  the length of the string in characters. The string size includes the NULL\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of bytes in String\r
+\r
+--*/\r
+;\r
+\r
+INTN\r
+EfiStrCmp (\r
+  IN CHAR16   *String,\r
+  IN CHAR16   *String2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the alphabetic relationship between two stirngs. \r
+\r
+Arguments:\r
+  String - Compare to String2\r
+  \r
+  String2 - Compare to String\r
+\r
+Returns:\r
+  0     - Identical\r
+  \r
+  > 0   - String is alphabeticly greater than String2\r
+  \r
+  < 0   - String is alphabeticly less than String2\r
+\r
+--*/\r
+;\r
+\r
+INTN\r
+EfiStrnCmp (\r
+  IN CHAR16   *String,\r
+  IN CHAR16   *String2,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function compares the Unicode string String to the Unicode\r
+  string String2 for len characters.  If the first len characters\r
+  of String is identical to the first len characters of String2,\r
+  then 0 is returned.  If substring of String sorts lexicographically\r
+  after String2, the function returns a number greater than 0. If\r
+  substring of String sorts lexicographically before String2, the\r
+  function returns a number less than 0.\r
+\r
+Arguments:\r
+  String  - Compare to String2\r
+  String2 - Compare to String\r
+  Length  - Number of Unicode characters to compare\r
+\r
+Returns:\r
+  0     - The substring of String and String2 is identical.\r
+  > 0   - The substring of String sorts lexicographically after String2\r
+  < 0   - The substring of String sorts lexicographically before String2\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiStrCat (\r
+  IN CHAR16   *Destination,\r
+  IN CHAR16   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiStrnCat (\r
+  IN CHAR16   *Dest,\r
+  IN CHAR16   *Src,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiAsciiStrLen (\r
+  IN CHAR8   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number of Ascii characters in String. This is not the same as\r
+  the length of the string in bytes.\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of Unicode characters in String\r
+\r
+--*/\r
+;\r
+\r
+CHAR8 *\r
+EfiAsciiStrCpy (\r
+  IN CHAR8    *Destination,\r
+  IN CHAR8    *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Ascii string Source to Destination.\r
+\r
+Arguments:\r
+  Destination - Location to copy string\r
+  Source      - String to copy\r
+\r
+Returns:\r
+  Pointer just pass the end of Destination\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiAsciiStrnCpy (\r
+  OUT CHAR8     *Dst,\r
+  IN  CHAR8     *Src,\r
+  IN  UINTN     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Ascii string from source to destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiAsciiStrSize (\r
+  IN CHAR8   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number bytes in the Ascii String. This is not the same as\r
+  the length of the string in characters. The string size includes the NULL\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of bytes in String\r
+\r
+--*/\r
+;\r
+\r
+\r
+INTN\r
+EfiAsciiStrCmp (\r
+  IN CHAR8   *String,\r
+  IN CHAR8   *String2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare the Ascii string pointed by String to the string pointed by String2. \r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+  String2 - The other string to process\r
+\r
+Returns:\r
+  Return a positive integer if String is lexicall greater than String2; Zero if \r
+  the two strings are identical; and a negative interger if String is lexically \r
+  less than String2.\r
+--*/\r
+;\r
+\r
+INTN\r
+EfiAsciiStrnCmp (\r
+  IN CHAR8    *String,\r
+  IN CHAR8    *String2,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function compares the ASCII string String to the ASCII\r
+  string String2 for len characters.  If the first len characters\r
+  of String is identical to the first len characters of String2,\r
+  then 0 is returned.  If substring of String sorts lexicographically\r
+  after String2, the function returns a number greater than 0. If\r
+  substring of String sorts lexicographically before String2, the\r
+  function returns a number less than 0.\r
+\r
+Arguments:\r
+  String  - Compare to String2\r
+  String2 - Compare to String\r
+  Length  - Number of ASCII characters to compare\r
+\r
+Returns:\r
+  0     - The substring of String and String2 is identical.\r
+  > 0   - The substring of String sorts lexicographically after String2\r
+  < 0   - The substring of String sorts lexicographically before String2\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiAsciiStrCat (\r
+  IN CHAR8   *Destination,\r
+  IN CHAR8   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiAsciiStrnCat (\r
+  IN CHAR8   *Destination,\r
+  IN CHAR8   *Source,\r
+  IN UINTN   Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Print primitives\r
+//\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Length of temp string buffer to store value string.\r
+//\r
+#define CHARACTER_NUMBER_FOR_VALUE  30\r
+\r
+UINTN\r
+EfiValueToHexStr (\r
+  IN  OUT CHAR16  *Buffer,\r
+  IN  UINT64      Value,\r
+  IN  UINTN       Flags,\r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints a Value as a hex number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii hex string of Value.\r
+\r
+  Value  - Hex value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing Hex string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiValueToString (\r
+  IN  OUT CHAR16  *Buffer,\r
+  IN  INT64       Value,\r
+  IN  UINTN       Flags,\r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints a Value as a decimal number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii decimal number string of Value.\r
+\r
+  Value  - Decimal value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing decimal string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+IsHexDigit (\r
+  OUT UINT8       *Digit,\r
+  IN  CHAR16      Char\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Determines if a Unicode character is a hexadecimal digit.\r
+    The test is case insensitive.\r
+\r
+  Arguments:\r
+    Digit - Pointer to byte that receives the value of the hex character.\r
+    Char  - Unicode character to test.\r
+\r
+  Returns:\r
+    TRUE  - If the character is a hexadecimal digit.\r
+    FALSE - Otherwise.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16\r
+NibbleToHexChar (\r
+  UINT8 Nibble\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts the low nibble of a byte  to hex unicode character.\r
+\r
+  Arguments:\r
+    Nibble - lower nibble of a byte.\r
+\r
+  Returns:\r
+    Hex unicode character.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+HexStringToBuf (\r
+  IN OUT UINT8                     *Buf,\r
+  IN OUT UINTN                     *Len,\r
+  IN     CHAR16                    *Str,\r
+  OUT    UINTN                     *ConvertedStrLen OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts Unicode string to binary buffer.\r
+    The conversion may be partial.\r
+    The first character in the string that is not hex digit stops the conversion.\r
+    At a minimum, any blob of data could be represented as a hex string.\r
+\r
+  Arguments:\r
+    Buf    - Pointer to buffer that receives the data.\r
+    Len    - Length in bytes of the buffer to hold converted data.\r
+                If routine return with EFI_SUCCESS, containing length of converted data.\r
+                If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.\r
+    Str    - String to be converted from.\r
+    ConvertedStrLen - Length of the Hex String consumed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS: Routine Success.\r
+    EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.\r
+    EFI_\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BufToHexString (\r
+  IN OUT CHAR16                     *Str,\r
+  IN OUT UINTN                      *HexStringBufferLength,\r
+  IN     UINT8                      *Buf,\r
+  IN     UINTN                      Len\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts binary buffer to Unicode string.\r
+    At a minimum, any blob of data could be represented as a hex string.\r
+\r
+  Arguments:\r
+    Str - Pointer to the string.\r
+    HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.\r
+                                        If routine return with EFI_SUCCESS, containing length of hex string buffer.\r
+                                        If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.\r
+    Buf - Buffer to be converted from.\r
+    Len - Length in bytes of the buffer to be converted.\r
+\r
+  Returns:\r
+    EFI_SUCCESS: Routine success.\r
+    EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiStrTrim (\r
+  IN OUT CHAR16   *str,\r
+  IN     CHAR16   CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Removes (trims) specified leading and trailing characters from a string.\r
+  \r
+Arguments: \r
+  \r
+  str     - Pointer to the null-terminated string to be trimmed. On return, \r
+            str will hold the trimmed string. \r
+  CharC       - Character will be trimmed from str.\r
+  \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+CHAR16*\r
+EfiStrStr (\r
+  IN  CHAR16  *String,\r
+  IN  CHAR16  *StrCharSet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Find a substring.\r
+  \r
+Arguments: \r
+  \r
+  String      - Null-terminated string to search.\r
+  StrCharSet  - Null-terminated string to search for.\r
+  \r
+Returns:\r
+  The address of the first occurrence of the matching substring if successful, or NULL otherwise.\r
+--*/\r
+;\r
+\r
+CHAR8*\r
+EfiAsciiStrStr (\r
+  IN  CHAR8  *String,\r
+  IN  CHAR8  *StrCharSet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Find a Ascii substring.\r
+  \r
+Arguments: \r
+  \r
+  String      - Null-terminated Ascii string to search.\r
+  StrCharSet  - Null-terminated Ascii string to search for.\r
+  \r
+Returns:\r
+  The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise.\r
+--*/\r
+;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
new file mode 100644 (file)
index 0000000..03e660b
--- /dev/null
@@ -0,0 +1,1203 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiDriverLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_DRIVER_LIB_H_\r
+#define _EFI_DRIVER_LIB_H_\r
+\r
+#include "EfiStatusCode.h"\r
+#include "EfiCommonLib.h"\r
+#include "EfiPerf.h"\r
+#include "LinkedList.h"\r
+#include "GetImage.h"\r
+#include "EfiImageFormat.h"\r
+\r
+#include EFI_GUID_DEFINITION (DxeServices)\r
+#include EFI_GUID_DEFINITION (EventGroup)\r
+#include EFI_GUID_DEFINITION (EventLegacyBios)\r
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
+#include EFI_PROTOCOL_DEFINITION (DataHub)\r
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName)\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)\r
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)\r
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)\r
+\r
+#include EFI_PROTOCOL_DEFINITION (DebugMask)\r
+\r
+typedef struct {\r
+  CHAR8   *Language;\r
+  CHAR16  *UnicodeString;\r
+} EFI_UNICODE_STRING_TABLE;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#define LANGUAGE_RFC_3066\r
+#define LANGUAGE_CODE_ENGLISH    "en-US"\r
+#else\r
+#define LANGUAGE_ISO_639_2\r
+#define LANGUAGE_CODE_ENGLISH    "eng"\r
+#endif\r
+\r
+//\r
+// Macros for EFI Driver Library Functions that are really EFI Boot Services\r
+//\r
+#define EfiCopyMem(_Destination, _Source, _Length)  gBS->CopyMem ((_Destination), (_Source), (_Length))\r
+#define EfiSetMem(_Destination, _Length, _Value)    gBS->SetMem ((_Destination), (_Length), (_Value))\r
+#define EfiZeroMem(_Destination, _Length)           gBS->SetMem ((_Destination), (_Length), 0)\r
+\r
+//\r
+// Driver Lib Globals.\r
+//\r
+extern EFI_BOOT_SERVICES        *gBS;\r
+extern EFI_DXE_SERVICES         *gDS;\r
+extern EFI_RUNTIME_SERVICES     *gRT;\r
+extern EFI_SYSTEM_TABLE         *gST;\r
+extern UINTN                    gErrorLevel;\r
+extern EFI_GUID                 gEfiCallerIdGuid;\r
+extern EFI_DEBUG_MASK_PROTOCOL  *gDebugMaskInterface;\r
+\r
+EFI_STATUS\r
+EfiInitializeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DxeInitializeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibInstallDriverBinding (\r
+  IN EFI_HANDLE                   ImageHandle,\r
+  IN EFI_SYSTEM_TABLE             *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,\r
+  IN EFI_HANDLE                   DriverBindingHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibInstallAllDriverProtocols (\r
+  IN EFI_HANDLE                         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL        *DriverBinding,\r
+  IN EFI_HANDLE                         DriverBindingHandle,\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  IN EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName,\r
+#else\r
+  IN EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,\r
+#endif\r
+  IN EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration,\r
+  IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize a driver by installing the Driver Binding Protocol onto the \r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The image handle of the driver\r
+\r
+  SystemTable         - The EFI System Table that was passed to the driver's entry point\r
+\r
+  DriverBinding       - A Driver Binding Protocol instance that this driver is producing\r
+\r
+  DriverBindingHandle - The handle that DriverBinding is to be installe onto.  If this\r
+                        parameter is NULL, then a new handle is created.\r
+\r
+  ComponentName       - A Component Name Protocol instance that this driver is producing\r
+\r
+  DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
+  \r
+  DriverDiagnostics   - A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
+\r
+  Otherwise, then return status from gBS->InstallProtocolInterface()\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  OUT VOID **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the EFI 1.0 System Tabl entry with TableGuid\r
+\r
+Arguments:\r
+\r
+  TableGuid - Name of entry to return in the system table\r
+  Table     - Pointer in EFI system table associated with TableGuid\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Table returned;\r
+  EFI_NOT_FOUND - TableGuid not in EFI system table\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+EfiLibCompareLanguage (\r
+  CHAR8  *Language1,\r
+  CHAR8  *Language2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compare two languages to say whether they are identical.\r
+\r
+Arguments:\r
+\r
+  Language1 - first language\r
+  Language2 - second language\r
+\r
+Returns:\r
+\r
+  TRUE      - identical\r
+  FALSE     - not identical\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// DevicePath.c\r
+//\r
+BOOLEAN\r
+EfiIsDevicePathMultiInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE is this is a multi instance device path.\r
+\r
+Arguments:\r
+  DevicePath  - A pointer to a device path data structure.\r
+\r
+\r
+Returns:\r
+  TRUE - If DevicePath is multi instance. \r
+  FALSE - If DevicePath is not multi instance.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
+  OUT UINTN                         *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function retrieves the next device path instance from a device path data structure.\r
+\r
+Arguments:\r
+  DevicePath           - A pointer to a device path data structure.\r
+\r
+  Size                 - A pointer to the size of a device path instance in bytes.\r
+\r
+Returns:\r
+\r
+  This function returns a pointer to the current device path instance.\r
+  In addition, it returns the size in bytes of the current device path instance in Size,\r
+  and a pointer to the next device path instance in DevicePath.\r
+  If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+EfiDevicePathSize (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculate the size of a whole device path.    \r
+    \r
+Arguments:\r
+\r
+  DevPath - The pointer to the device path data.\r
+    \r
+Returns:\r
+\r
+  Size of device path data structure..\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiAppendDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a Src1 and Src2 together.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  A pointer to the new device path is returned.\r
+  NULL is returned if space for the new device path could not be allocated from pool.\r
+  It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiDevicePathFromHandle (\r
+  IN EFI_HANDLE       Handle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Locate device path protocol interface on a device handle.\r
+\r
+Arguments:\r
+\r
+  Handle  - The device handle\r
+\r
+Returns:\r
+\r
+  Device path protocol interface located.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiDuplicateDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Duplicate a new device path data structure from the old one.\r
+\r
+Arguments:\r
+  DevPath  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  A pointer to the new allocated device path data.\r
+  Caller must free the memory used by DevicePath if it is no longer needed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiAppendDevicePathNode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a device path node to the end of another device path.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2 - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  This function returns a pointer to the new device path.\r
+  If there is not enough temporary pool memory available to complete this function,\r
+  then NULL is returned.\r
+\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiFileDevicePath (\r
+  IN EFI_HANDLE               Device  OPTIONAL,\r
+  IN CHAR16                   *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a device path that appends a MEDIA_DEVICE_PATH with\r
+  FileNameGuid to the device path of DeviceHandle.\r
+\r
+Arguments:\r
+  Device   - Optional Device Handle to use as Root of the Device Path\r
+\r
+  FileName - FileName\r
+\r
+Returns:\r
+  EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory\r
+  or NULL pointer.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+EfiAppendDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Append a device path instance to another.\r
+\r
+Arguments:\r
+\r
+  Src       - The device path instance to be appended with.\r
+  Instance  - The device path instance appending the other.\r
+\r
+Returns:\r
+\r
+  The contaction of these two.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Lock.c\r
+//\r
+typedef struct {\r
+  EFI_TPL Tpl;\r
+  EFI_TPL OwnerTpl;\r
+  UINTN   Lock;\r
+} EFI_LOCK;\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  Note on a check build ASSERT()s are used to ensure proper\r
+  lock usage.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - The task priority level of the lock\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Macro to initialize the state of a lock when a lock variable is declared\r
+//\r
+#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock, and\r
+    restores the previous task priority level.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    None\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocatePool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate EfiBootServicesData pool of size AllocationSize\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - Pool size\r
+\r
+Returns:\r
+\r
+  Pointer to the pool allocated\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocateRuntimePool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate EfiRuntimeServicesData pool of size AllocationSize\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - Pool size\r
+\r
+Returns:\r
+\r
+  Pointer to the pool allocated\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocateZeroPool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate EfiBootServicesData pool of size AllocationSize and set memory to zero.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - Pool size\r
+\r
+Returns:\r
+\r
+  Pointer to the pool allocated\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocateRuntimeZeroPool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate EfiRuntimeServicesData pool of size AllocationSize and set memory to zero.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - Pool size\r
+\r
+Returns:\r
+\r
+  Pointer to the pool allocated\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocateCopyPool (\r
+  IN  UINTN   AllocationSize,\r
+  IN  VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool and use a buffer provided by \r
+  caller to fill it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+  \r
+  Buffer          - Buffer that will be filled into the buffer allocated\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EfiLibAllocateRuntimeCopyPool (\r
+  IN  UINTN            AllocationSize,\r
+  IN  VOID             *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate RuntimeServicesData pool and use a buffer provided by \r
+  caller to fill it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+  \r
+  Buffer          - Buffer that will be filled into the buffer allocated\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Event.c\r
+//\r
+EFI_EVENT\r
+EfiLibCreateProtocolNotifyEvent (\r
+  IN EFI_GUID             *ProtocolGuid,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext,\r
+  OUT VOID                **Registration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a protocol notification event and return it.\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid    - Protocol to register notification event on.\r
+\r
+  NotifyTpl       - Maximum TPL to single the NotifyFunction.\r
+\r
+  NotifyFunction  - EFI notification routine.\r
+\r
+  NotifyContext   - Context passed into Event when it is created.\r
+\r
+  Registration    - Registration key returned from RegisterProtocolNotify().\r
+\r
+Returns:\r
+\r
+  The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
+  is added to the system.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibNamedEventSignal (\r
+  IN EFI_GUID            *Name\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Signals a named event. All registered listeners will run.\r
+  The listeners should register using EfiLibNamedEventListen() function.\r
+\r
+  NOTE: For now, the named listening/signalling is implemented\r
+  on a protocol interface being installed and uninstalled.\r
+  In the future, this maybe implemented based on a dedicated mechanism.\r
+\r
+Arguments:\r
+  Name - Name to perform the signaling on. The name is a GUID.\r
+\r
+Returns:\r
+  EFI_SUCCESS if successfull.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibNamedEventListen (\r
+  IN EFI_GUID             * Name,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Listenes to signals on the name.\r
+  EfiLibNamedEventSignal() signals the event.\r
+\r
+  NOTE: For now, the named listening/signalling is implemented\r
+  on a protocol interface being installed and uninstalled.\r
+  In the future, this maybe implemented based on a dedicated mechanism.\r
+\r
+Arguments:\r
+  Name            - Name to register the listener on.\r
+  NotifyTpl       - Maximum TPL to singnal the NotifyFunction.\r
+  NotifyFunction  - The listener routine.\r
+  NotifyContext   - Context passed into the listener routine.\r
+\r
+Returns:\r
+  EFI_SUCCESS if successful.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Handle.c\r
+//\r
+EFI_STATUS\r
+EfiLibLocateHandleProtocolByProtocols (\r
+  IN OUT EFI_HANDLE        * Handle, OPTIONAL\r
+  OUT    VOID              **Interface, OPTIONAL\r
+  ...\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Function locates Protocol and/or Handle on which all Protocols specified\r
+  as a variable list are installed.\r
+  It supports continued search. The caller must assure that no handles are added\r
+  or removed while performing continued search, by e.g., rising the TPL and not\r
+  calling any handle routines. Otherwise the behavior is undefined.\r
+\r
+Arguments:\r
+\r
+  Handle        - The address of handle to receive the handle on which protocols\r
+                  indicated by the variable list are installed.\r
+                  If points to NULL, all handles are searched. If pointing to a\r
+                  handle returned from previous call, searches starting from next handle.\r
+                  If NULL, the parameter is ignored.\r
+\r
+  Interface     - The address of a pointer to a protocol interface that will receive\r
+                  the interface indicated by first variable argument.\r
+                  If NULL, the parameter is ignored.\r
+\r
+  ...           - A variable argument list containing protocol GUIDs. Must end with NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS  - All the protocols where found on same handle.\r
+  EFI_NOT_FOUND - A Handle with all the protocols installed was not found.\r
+  Other values as may be returned from LocateHandleBuffer() or HandleProtocol().\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Debug.c init\r
+//\r
+EFI_STATUS\r
+EfiDebugAssertInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Locate Debug Assert Protocol and set as mDebugAssert\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Unicode String Support\r
+//\r
+EFI_STATUS\r
+EfiLibLookupUnicodeString (\r
+  CHAR8                     *Language,\r
+  CHAR8                     *SupportedLanguages,\r
+  EFI_UNICODE_STRING_TABLE  *UnicodeStringTable,\r
+  CHAR16                    **UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Translate a unicode string to a specified language if supported.\r
+  \r
+Arguments:\r
+\r
+  Language              - The name of language to translate to\r
+  SupportedLanguages    - Supported languages set\r
+  UnicodeStringTable    - Pointer of one item in translation dictionary\r
+  UnicodeString         - The translated string\r
+\r
+Returns: \r
+\r
+  EFI_INVALID_PARAMETER - Invalid parameter\r
+  EFI_UNSUPPORTED       - System not supported this language or this string translation\r
+  EFI_SUCCESS           - String successfully translated\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibAddUnicodeString (\r
+  CHAR8                     *Language,\r
+  CHAR8                     *SupportedLanguages,\r
+  EFI_UNICODE_STRING_TABLE  **UnicodeStringTable,\r
+  CHAR16                    *UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add an translation to the dictionary if this language if supported.\r
+  \r
+Arguments:\r
+\r
+  Language              - The name of language to translate to\r
+  SupportedLanguages    - Supported languages set\r
+  UnicodeStringTable    - Translation dictionary\r
+  UnicodeString         - The corresponding string for the language to be translated to\r
+\r
+Returns: \r
+\r
+  EFI_INVALID_PARAMETER - Invalid parameter\r
+  EFI_UNSUPPORTED       - System not supported this language\r
+  EFI_ALREADY_STARTED   - Already has a translation item of this language\r
+  EFI_OUT_OF_RESOURCES  - No enough buffer to be allocated\r
+  EFI_SUCCESS           - String successfully translated\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibFreeUnicodeStringTable (\r
+  EFI_UNICODE_STRING_TABLE  *UnicodeStringTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free a string table.\r
+\r
+Arguments:\r
+\r
+  UnicodeStringTable      - The string table to be freed.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS       - The table successfully freed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Report status code.\r
+\r
+Arguments:\r
+\r
+  Type        - Code type\r
+  Value       - Code value\r
+  Instance    - Instance number\r
+  CallerId    - Caller name\r
+  DevicePath  - Device path that to be reported\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ReportStatusCodeWithDevicePath (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId OPTIONAL,\r
+  IN EFI_DEVICE_PATH_PROTOCOL * DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Report device path through status code.\r
+\r
+Arguments:\r
+\r
+  Type        - Code type\r
+  Value       - Code value\r
+  Instance    - Instance number\r
+  CallerId    - Caller name\r
+  DevicePath  - Device path that to be reported\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+  EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventLegacyBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *LegacyBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Legacy Boot Event.  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Returns:\r
+  EFI_SUCCESS   Event was created.\r
+  Other         Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventReadyToBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *ReadyToBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  @param LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Return:\r
+  EFI_SUCCESS   - Event was created.\r
+  Other         - Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+EfiInitializeFwVolDevicepathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,\r
+  IN EFI_GUID                               *NameGuid\r
+  )\r
+/*++\r
+Routine Description:\r
+  Initialize a Firmware Volume (FV) Media Device Path node.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability.\r
+\r
+Arguments:\r
+  FvDevicePathNode   - Pointer to a FV device path node to initialize\r
+  NameGuid           - FV file name to use in FvDevicePathNode\r
+\r
+--*/\r
+;\r
+\r
+EFI_GUID *\r
+EFIAPI\r
+EfiGetNameGuidFromFwVolDevicePathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH   *FvDevicePathNode\r
+  )\r
+/*++\r
+Routine Description:\r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability. The return value to this\r
+  function points to a location in FvDevicePathNode and it does not allocate\r
+  new memory for the GUID pointer that is returned.\r
+\r
+Arguments:\r
+  FvDevicePathNode   - Pointer to FV device path to check\r
+\r
+Return:\r
+  NULL    - FvDevicePathNode is not valid.\r
+  Other   - FvDevicePathNode is valid and pointer to NameGuid was returned.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiLibSafeFreePool (\r
+  IN  VOID             *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free pool safely.\r
+\r
+Arguments:\r
+  \r
+  Buffer          - The allocated pool entry to free\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibTestManagedDevice (\r
+  IN EFI_HANDLE       ControllerHandle,\r
+  IN EFI_HANDLE       DriverBindingHandle,\r
+  IN EFI_GUID         *ManagedProtocolGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test to see if the controller is managed by a specific driver.\r
+\r
+Arguments:\r
+\r
+  ControllerHandle          - Handle for controller to test\r
+\r
+  DriverBindingHandle       - Driver binding handle for controller\r
+\r
+  ManagedProtocolGuid       - The protocol guid the driver opens on controller\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - The controller is managed by the driver\r
+\r
+  EFI_UNSUPPORTED - The controller is not managed by the driver\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibTestChildHandle (\r
+  IN EFI_HANDLE       ControllerHandle,\r
+  IN EFI_HANDLE       ChildHandle,\r
+  IN EFI_GUID         *ConsumedGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test to see if the child handle is the child of the controller\r
+\r
+Arguments:\r
+\r
+  ControllerHandle          - Handle for controller (parent)\r
+\r
+  ChildHandle               - Child handle to test\r
+\r
+  ConsumsedGuid             - Protocol guid consumed by child from controller\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - The child handle is the child of the controller\r
+\r
+  EFI_UNSUPPORTED - The child handle is not the child of the controller\r
+\r
+--*/\r
+;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h
new file mode 100644 (file)
index 0000000..cbf1c8d
--- /dev/null
@@ -0,0 +1,298 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    EfiHobLib.h\r
+\r
+Abstract:\r
+\r
\r
+--*/\r
+\r
+#ifndef _EFI_HOB_LIB_H_\r
+#define _EFI_HOB_LIB_H_\r
+\r
+#include "PeiHob.h"\r
+\r
+VOID  *\r
+GetHob (\r
+  IN UINT16  Type,\r
+  IN VOID    *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the first instance of a HOB type in a HOB list.\r
+  \r
+Arguments:\r
+\r
+  Type          The HOB type to return.\r
+  HobStart      The first HOB in the HOB list.\r
+    \r
+Returns:\r
+\r
+  HobStart      There were no HOBs found with the requested type.\r
+  else          Returns the first HOB with the matching type.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+GetHobListSize (\r
+  IN VOID  *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get size of hob list.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+\r
+Returns:\r
+\r
+  Size of hob list.\r
+\r
+--*/\r
+;\r
+\r
+UINT32\r
+GetHobVersion (\r
+  IN VOID  *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get hob version.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+\r
+Returns:\r
+\r
+  Hob version.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetHobBootMode (\r
+  IN  VOID           *HobStart,\r
+  OUT EFI_BOOT_MODE  *BootMode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get current boot mode.\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  \r
+  BootMode      - Current boot mode recorded in PHIT hob\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND     - Invalid hob header\r
+  \r
+  EFI_SUCCESS       - Boot mode found\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetCpuHobInfo (\r
+  IN  VOID   *HobStart,\r
+  OUT UINT8  *SizeOfMemorySpace,\r
+  OUT UINT8  *SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get information recorded in CPU hob (Memory space size, Io space size)\r
+\r
+Arguments:\r
+\r
+  HobStart            - Start pointer of hob list\r
+  \r
+  SizeOfMemorySpace   - Size of memory size\r
+  \r
+  SizeOfIoSpace       - Size of IO size\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND     - CPU hob not found\r
+  \r
+  EFI_SUCCESS       - CPU hob found and information got.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetDxeCoreHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                *Length,\r
+  OUT VOID                  **EntryPoint,\r
+  OUT EFI_GUID              **FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get memory allocation hob created for DXE core and extract its information\r
+\r
+Arguments:\r
+\r
+  HobStart        - Start pointer of the hob list\r
+  \r
+  BaseAddress     - Start address of memory allocated for DXE core\r
+  \r
+  Length          - Length of memory allocated for DXE core\r
+  \r
+  EntryPoint      - DXE core file name\r
+\r
+  FileName        - FileName  \r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND   - DxeCoreHob not found\r
+  \r
+  EFI_SUCCESS     - DxeCoreHob found and information got\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetNextFirmwareVolumeHob (\r
+  IN OUT VOID                  **HobStart,\r
+  OUT    EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT    UINT64                *Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get next firmware volume hob from HobStart\r
+\r
+Arguments:\r
+\r
+  HobStart        - Start pointer of hob list\r
+  \r
+  BaseAddress     - Start address of next firmware volume\r
+  \r
+  Length          - Length of next firmware volume\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND   - Next firmware volume not found\r
+  \r
+  EFI_SUCCESS     - Next firmware volume found with address information\r
+\r
+--*/\r
+;\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+EFI_STATUS\r
+GetNextFirmwareVolume2Hob (\r
+  IN OUT VOID                  **HobStart,\r
+  OUT    EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT    UINT64                *Length,\r
+  OUT    EFI_GUID              *FileName\r
+  )\r
+;\r
+#endif\r
+\r
+EFI_STATUS\r
+GetNextGuidHob (\r
+  IN OUT VOID      **HobStart,\r
+  IN     EFI_GUID  * Guid,\r
+  OUT    VOID      **Buffer,\r
+  OUT    UINTN     *BufferSize OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the next guid hob.\r
+  \r
+Arguments:\r
+  HobStart        A pointer to the start hob.\r
+  Guid            A pointer to a guid.\r
+  Buffer          A pointer to the buffer.\r
+  BufferSize      Buffer size.\r
+  \r
+Returns:\r
+  Status code.\r
+  \r
+  EFI_NOT_FOUND       - Next Guid hob not found\r
+  \r
+  EFI_SUCCESS         - Next Guid hob found and data for this Guid got\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetPalEntryHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *PalEntry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PAL entry from PalEntryHob\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  \r
+  PalEntry      - Pointer to PAL entry\r
+\r
+Returns:\r
+\r
+  Status code.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetIoPortSpaceAddressHobInfo (\r
+  IN  VOID                  *HobStart,\r
+  OUT EFI_PHYSICAL_ADDRESS  *IoPortSpaceAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get IO port space address from IoBaseHob.\r
+\r
+Arguments:\r
+\r
+  HobStart              - Start pointer of hob list\r
+  \r
+  IoPortSpaceAddress    - IO port space address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h
new file mode 100644 (file)
index 0000000..a5191f8
--- /dev/null
@@ -0,0 +1,429 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    EfiMgmtModeRuntimeLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_RT_SUPPORT_LIB_H_\r
+#define _EFI_RT_SUPPORT_LIB_H_\r
+\r
+#ifndef EFI_LOAD_IMAGE_SMM\r
+#define EFI_LOAD_DRIVER_SMM FALSE\r
+#else\r
+#define EFI_LOAD_DRIVER_SMM TRUE\r
+#endif\r
+\r
+#ifndef EFI_NO_LOAD_IMAGE_RT\r
+#define EFI_NO_LOAD_DRIVER_RT FALSE\r
+#else\r
+#define EFI_NO_LOAD_DRIVER_RT TRUE\r
+#endif\r
+\r
+#include "EfiCommonLib.h"\r
+#include "LinkedList.h"\r
+#include "ProcDep.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+\r
+//\r
+// Driver Lib Globals.\r
+//\r
+extern EFI_BOOT_SERVICES        *gBS;\r
+extern EFI_SYSTEM_TABLE         *gST;\r
+extern UINTN                    gRtErrorLevel;\r
+extern BOOLEAN                  mEfiLoadDriverSmm;\r
+extern BOOLEAN                  mEfiNoLoadDriverRt;\r
+extern EFI_DEVICE_PATH_PROTOCOL *mFilePath;\r
+\r
+//\r
+// Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only)\r
+//\r
+EFI_STATUS\r
+EfiAllocateRuntimeMemoryPool (\r
+  IN UINTN                          Size,\r
+  OUT VOID                          **Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate EfiRuntimeServicesData pool of specified size.\r
+\r
+Arguments:\r
+\r
+  Size      - Pool size\r
+  Buffer    - Memory pointer for output\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFreeRuntimeMemoryPool (\r
+  IN VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free allocated pool\r
+\r
+Arguments:\r
+\r
+  Buffer  - Pool to be freed\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLocateProtocolHandleBuffers (\r
+  IN EFI_GUID                       *Protocol,\r
+  IN OUT UINTN                      *NumberHandles,\r
+  OUT EFI_HANDLE                    **Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns an array of handles that support the requested protocol in a buffer allocated from pool.\r
+\r
+Arguments:\r
+\r
+  Protocol      - Provides the protocol to search by.\r
+  NumberHandles - The number of handles returned in Buffer.\r
+  Buffer        - A pointer to the buffer to return the requested array of handles that\r
+                  support Protocol.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiHandleProtocol (\r
+  IN EFI_HANDLE                     Handle,\r
+  IN EFI_GUID                       *Protocol,\r
+  OUT VOID                          **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Queries a handle to determine if it supports a specified protocol.\r
+\r
+Arguments:\r
+\r
+  Handle    - The handle being queried.\r
+  Protocol  - The published unique identifier of the protocol.\r
+  Interface - Supplies the address where a pointer to the corresponding Protocol\r
+              Interface is returned. NULL will be returned in *Interface if a\r
+              structure is not associated with Protocol.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInstallProtocolInterface (\r
+  IN OUT EFI_HANDLE                 *Handle,\r
+  IN EFI_GUID                       *Protocol,\r
+  IN EFI_INTERFACE_TYPE             InterfaceType,\r
+  IN VOID                           *Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs a protocol interface on a device handle. If the handle does not exist, it is created and added\r
+to the list of handles in the system.\r
+\r
+Arguments:\r
+\r
+  Handle        - A pointer to the EFI_HANDLE on which the interface is to be installed.\r
+  Protocol      - The numeric ID of the protocol interface.\r
+  InterfaceType - Indicates whether Interface is supplied in native form.\r
+  Interface     - A pointer to the protocol interface.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiReinstallProtocolInterface (\r
+  IN EFI_HANDLE                     SmmProtocolHandle,\r
+  IN EFI_GUID                       *Protocol,\r
+  IN VOID                           *OldInterface,\r
+  IN VOID                           *NewInterface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reinstalls a protocol interface on a device handle.\r
+\r
+Arguments:\r
+\r
+  SmmProtocolHandle - Handle on which the interface is to be reinstalled.\r
+  Protocol          - The numeric ID of the interface.\r
+  OldInterface      - A pointer to the old interface.\r
+  NewInterface      - A pointer to the new interface.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLocateProtocolInterface (\r
+  EFI_GUID  *Protocol,\r
+  VOID      *Registration, OPTIONAL\r
+  VOID      **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the first protocol instance that matches the given protocol.\r
+\r
+Arguments:\r
+\r
+  Protocol      - Provides the protocol to search for.\r
+  Registration  - Optional registration key returned from\r
+                  RegisterProtocolNotify(). If Registration is NULL, then\r
+                  it is ignored.\r
+  Interface     - On return, a pointer to the first interface that matches Protocol and\r
+                  Registration.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UninstallProtocolInterface (\r
+  IN EFI_HANDLE                     SmmProtocolHandle,\r
+  IN EFI_GUID                       *Protocol,\r
+  IN VOID                           *Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes a protocol interface from a device handle.\r
+\r
+Arguments:\r
+\r
+  SmmProtocolHandle - The handle on which the interface was installed.\r
+  Protocol          - The numeric ID of the interface.\r
+  Interface         - A pointer to the interface.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiRegisterProtocolCallback (\r
+  IN  EFI_EVENT_NOTIFY              CallbackFunction,\r
+  IN  VOID                          *Context,\r
+  IN  EFI_GUID                      *ProtocolGuid,\r
+  IN  EFI_TPL                       NotifyTpl,\r
+  OUT VOID                          **Registeration,\r
+  OUT EFI_EVENT                     *Event\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register a callback function to be signaled whenever an interface is installed for \r
+  a specified protocol.\r
+\r
+Arguments:\r
+\r
+  CallbackFunction  - Call back function\r
+  Context           - Context of call back function\r
+  ProtocolGuid      - The numeric ID of the protocol for which the callback function\r
+                      is to be registered.\r
+  NotifyTpl         - Notify tpl of callback function\r
+  Registeration     - A pointer to a memory location to receive the registration value.\r
+  Event             - Event that is to be signaled whenever a protocol interface is registered\r
+                      for Protocol.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiSignalProtocolEvent (\r
+  EFI_EVENT                         Event\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Signals an event.\r
+\r
+Arguments:\r
+\r
+  Event - The event to signal.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInstallVendorConfigurationTable (\r
+  IN EFI_GUID                       *Guid,\r
+  IN VOID                           *Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Adds, updates, or removes a configuration table entry from the EFI System Table.\r
+\r
+Arguments:\r
+\r
+  Guid  - A pointer to the GUID for the entry to add, update, or remove.\r
+  Table - A pointer to the configuration table for the entry to add, update, or\r
+          remove. May be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetVendorConfigurationTable (\r
+  IN EFI_GUID                       *Guid,\r
+  OUT VOID                          **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the EFI 1.0 System Tabl entry with TableGuid\r
+\r
+Arguments:\r
+\r
+  Guid      - Name of entry to return in the system table\r
+  Table     - Pointer in EFI system table associated with TableGuid\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Table returned;\r
+  EFI_NOT_FOUND - TableGuid not in EFI system table\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInitializeUtilsRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     GoVirtualChildEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+EfiInManagementInterrupt (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Indicate whether the caller is already in SMM or not.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TRUE      - In SMM\r
+  FALSE     - Not in SMM\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// This MACRO initializes the RUNTIME invironment and optionally loads Image to SMM or Non-SMM space\r
+// based upon the presence of build flags EFI_LOAD_DRIVER_SMM and EFI_NO_LOAD_DRIVER_RT.\r
+//\r
+#define EFI_INITIALIZE_RUNTIME_DRIVER_LIB(ImageHandle, SystemTable, GoVirtualChildEvent, FilePath) \\r
+  mEfiLoadDriverSmm = EFI_LOAD_DRIVER_SMM; \\r
+  mEfiNoLoadDriverRt = EFI_NO_LOAD_DRIVER_RT; \\r
+  mFilePath = (EFI_DEVICE_PATH_PROTOCOL*) FilePath; \\r
+  EfiInitializeUtilsRuntimeDriverLib ((EFI_HANDLE) ImageHandle, (EFI_SYSTEM_TABLE*) SystemTable, (EFI_EVENT_NOTIFY) GoVirtualChildEvent); \\r
+  if (!EfiInManagementInterrupt()) { \\r
+    if (mEfiNoLoadDriverRt) { \\r
+      return EFI_SUCCESS; \\r
+    } \\r
+  }  \r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h
new file mode 100644 (file)
index 0000000..42a6ec8
--- /dev/null
@@ -0,0 +1,326 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiPrintLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PRINT_LIB_H_\r
+#define _EFI_PRINT_LIB_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)\r
+#include EFI_PROTOCOL_DEFINITION(UgaDraw)\r
+#include EFI_PROTOCOL_DEFINITION(Print)\r
+\r
+UINTN\r
+ErrorPrint (\r
+  IN CONST CHAR16 *ErrorString,\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  ErrorString   - Error message printed first\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+ErrorDumpHex (\r
+  IN UINTN        Indent,\r
+  IN UINTN        Offset,\r
+  IN UINTN        DataSize,\r
+  IN VOID         *UserData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump error info by hex.\r
+\r
+Arguments:\r
+\r
+  Indent    - Indent number\r
+  Offset    - Offset number\r
+  DataSize  - Size of user data\r
+  UserData  - User data to dump\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+Print (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Prints a formatted unicode string to the default console\r
+\r
+Arguments:\r
+\r
+    fmt         - Format string\r
+\r
+Returns:\r
+\r
+    Length of string printed to the console\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+PrintXY (\r
+  IN UINTN                            X,\r
+  IN UINTN                            Y,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground, OPTIONAL\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background, OPTIONAL\r
+  IN CHAR16                           *Fmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Prints a formatted unicode string to the default console\r
+\r
+Arguments:\r
+\r
+    X           - X coordinate to start printing\r
+    \r
+    Y           - Y coordinate to start printing\r
+    \r
+    ForeGround  - Foreground color\r
+    \r
+    BackGround  - Background color\r
+\r
+    Fmt         - Format string\r
+    \r
+    ...         - Print arguments\r
+\r
+Returns:\r
+\r
+    Length of string printed to the console\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+Aprint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+UPrint (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+VSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         StrLen,\r
+  IN  CONST CHAR16  *Format,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Prints a formatted unicode string to a buffer\r
+\r
+Arguments:\r
+\r
+    StartOfBuffer   - Output buffer to print the formatted string into\r
+    StrLen          - Size of Str.  String is truncated to this size.\r
+                      A size of 0 means there is no limit\r
+    Format          - The format string\r
+    Marker          - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+    String length returned in buffer\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+SPrint (\r
+  OUT CHAR16      *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR16 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// BoxDraw support\r
+//\r
+BOOLEAN\r
+IsValidEfiCntlChar (\r
+  IN  CHAR16  CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test whether a wide char is a valid control char.\r
+\r
+Arguments:\r
+\r
+  CharC - A char\r
+\r
+Returns:\r
+\r
+  TRUE    - A control char\r
+  \r
+  FALSE   - Not a control char\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+IsValidAscii (\r
+  IN  CHAR16  Ascii\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test whether a wide char is a normal printable char\r
+\r
+Arguments:\r
+\r
+  Ascii - A char\r
+\r
+Returns:\r
+\r
+  True      - A normal, printable char\r
+  FALSE     - Not a normal, printable char\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+LibIsValidTextGraphics (\r
+  IN  CHAR16  Graphic,\r
+  OUT CHAR8   *PcAnsi,    OPTIONAL\r
+  OUT CHAR8   *Ascii      OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Detects if a Unicode char is for Box Drawing text graphics.\r
+\r
+Arguments:\r
+\r
+    Graphic - Unicode char to test.\r
+\r
+    PcAnsi  - Optional pointer to return PCANSI equivalent of Graphic.\r
+\r
+    Ascii   - Optional pointer to return Ascii equivalent of Graphic.\r
+\r
+Returns:\r
+\r
+    TRUE if Gpaphic is a supported Unicode Box Drawing character.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h
new file mode 100644 (file)
index 0000000..dece937
--- /dev/null
@@ -0,0 +1,205 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiRegTableLib.h\r
+  \r
+Abstract: \r
+\r
+  Definitions and macros for building register tables for chipset \r
+  initialization..\r
+  \r
+  Components linking this lib must include CpuIo, PciRootBridgeIo, and \r
+  BootScriptSave protocols in their DPX.\r
+  \r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef EFI_REG_TABLE_H\r
+#define EFI_REG_TABLE_H\r
+\r
+#include "Tiano.h"\r
+#include "EfiScriptLib.h"\r
+#include EFI_PROTOCOL_CONSUMER (CpuIo)\r
+#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)\r
+\r
+//\r
+// RegTable OpCodes are encoded as follows:\r
+//\r
+//  |31----------------------------16|15---------8|7-------0|\r
+//                                 \             \         \\r
+//                                 \             \         \\r
+//  31:16 defined by Base OpCode---+             \         \\r
+//                                Opcode Flags---+         \\r
+//                                           Base OpCode---+\r
+//\r
+#define OPCODE_BASE(OpCode)       ((UINT8)((OpCode) & 0xFF))\r
+#define OPCODE_FLAGS(OpCode)      ((UINT8)(((OpCode) >> 8) & 0xFF)) \r
+#define OPCODE_EXTRA_DATA(OpCode) ((UINT16)((OpCode) >> 16)) \r
+\r
+//\r
+// RegTable Base OpCodes\r
+//\r
+#define OP_TERMINATE_TABLE                0\r
+#define OP_MEM_WRITE                      1\r
+#define OP_MEM_READ_MODIFY_WRITE          2\r
+#define OP_IO_WRITE                       3\r
+#define OP_IO_READ_MODIFY_WRITE           4\r
+#define OP_PCI_WRITE                      5\r
+#define OP_PCI_READ_MODIFY_WRITE          6\r
+#define OP_STALL                          7\r
+\r
+//\r
+// RegTable OpCode Flags\r
+//\r
+#define OPCODE_FLAG_S3SAVE                1\r
+\r
+\r
+#define TERMINATE_TABLE { (UINT32) OP_TERMINATE_TABLE, (UINT32) 0, (UINT32) 0 }\r
+\r
+\r
+//\r
+// REG_TABLE_ENTRY_PCI_WRITE encodes the width in the upper bits of the OpCode\r
+// as one of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH values\r
+//\r
+typedef struct {\r
+  UINT32                                OpCode;\r
+  UINT32                                PciAddress;\r
+  UINT32                                Data;\r
+} EFI_REG_TABLE_PCI_WRITE;\r
+\r
+#define PCI_WRITE(Bus, Dev, Fnc, Reg, Width, Data, S3Flag)                    \\r
+  {                                                                           \\r
+    (UINT32) (OP_PCI_WRITE | ((S3Flag) << 8) | ((Width) << 16)),              \\r
+    (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))),                  \\r
+    (UINT32) (Data),                                                          \\r
+    (UINT32) (0)                                                              \\r
+  }\r
+\r
+typedef struct {\r
+  UINT32                                OpCode;\r
+  UINT32                                PciAddress;\r
+  UINT32                                OrMask;\r
+  UINT32                                AndMask;\r
+} EFI_REG_TABLE_PCI_READ_MODIFY_WRITE;\r
+\r
+#define PCI_READ_MODIFY_WRITE(Bus, Dev, Fnc, Reg, Width, OrMask, AndMask, S3Flag)  \\r
+  {                                                                           \\r
+    (UINT32) (OP_PCI_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)),  \\r
+    (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))),                  \\r
+    (UINT32) (OrMask),                                                        \\r
+    (UINT32) (AndMask)                                                        \\r
+  }\r
+\r
+typedef struct {\r
+  UINT32                                OpCode;\r
+  UINT32                                MemAddress;\r
+  UINT32                                OrMask;\r
+  UINT32                                AndMask;\r
+} EFI_REG_TABLE_MEM_READ_MODIFY_WRITE;\r
+\r
+#define MEM_READ_MODIFY_WRITE(Address, Width, OrMask, AndMask, S3Flag)  \\r
+  {                                                                           \\r
+    (UINT32) (OP_MEM_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)),  \\r
+    (UINT32) (Address),                  \\r
+    (UINT32) (OrMask),                                                        \\r
+    (UINT32) (AndMask)                                                        \\r
+  }\r
+  \r
+typedef struct {\r
+  UINT32                                OpCode;\r
+  UINT32                                Field2;\r
+  UINT32                                Field3;\r
+  UINT32                                Field4;\r
+} EFI_REG_TABLE_GENERIC;\r
+\r
+typedef union {\r
+  EFI_REG_TABLE_GENERIC                 Generic;\r
+  EFI_REG_TABLE_PCI_WRITE               PciWrite;\r
+  EFI_REG_TABLE_PCI_READ_MODIFY_WRITE   PciReadModifyWrite;\r
+  EFI_REG_TABLE_MEM_READ_MODIFY_WRITE   MemReadModifyWrite;\r
+} EFI_REG_TABLE;\r
+\r
+VOID\r
+ProcessRegTablePci (\r
+  EFI_REG_TABLE                   * RegTableEntry,\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * PciRootBridgeIo,\r
+  EFI_CPU_IO_PROTOCOL             * CpuIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Processes register table assuming which may contain PCI, IO, MEM, and STALL\r
+  entries.\r
+  \r
+  No parameter checking is done so the caller must be careful about omitting\r
+  values for PciRootBridgeIo or CpuIo parameters.  If the regtable does\r
+  not contain any PCI accesses, it is safe to omit the PciRootBridgeIo (supply\r
+  NULL).  If the regtable does not contain any IO or Mem entries, it is safe to\r
+  omit the CpuIo (supply NULL).\r
+  \r
+  The RegTableEntry parameter is not checked, but is required.\r
+  \r
+  gBS is assumed to have been defined and is used when processing stalls.\r
+  \r
+  The function processes each entry sequentially until an OP_TERMINATE_TABLE\r
+  entry is encountered.\r
+\r
+Arguments:\r
+  RegTableEntry - A pointer to the register table to process\r
+  \r
+  PciRootBridgeIo - A pointer to the instance of PciRootBridgeIo that is used\r
+                  when processing PCI table entries\r
+                  \r
+  CpuIo - A pointer to the instance of CpuIo that is used when processing IO and\r
+                  MEM table entries\r
+\r
+Returns:\r
+  Nothing.  \r
+  \r
+--*/\r
+;\r
+\r
+VOID\r
+ProcessRegTableCpu (\r
+  EFI_REG_TABLE                   * RegTableEntry,\r
+  EFI_CPU_IO_PROTOCOL             * CpuIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Processes register table assuming which may contain IO, MEM, and STALL\r
+  entries, but must NOT contain any PCI entries.  Any PCI entries cause an\r
+  ASSERT in a DEBUG build and are skipped in a free build.\r
+  \r
+  No parameter checking is done.  Both RegTableEntry and CpuIo parameters are\r
+  required.\r
+  \r
+  gBS is assumed to have been defined and is used when processing stalls.\r
+\r
+  The function processes each entry sequentially until an OP_TERMINATE_TABLE\r
+  entry is encountered.\r
+\r
+Arguments:\r
+  RegTableEntry - A pointer to the register table to process\r
+  \r
+  CpuIo - A pointer to the instance of CpuIo that is used when processing IO and\r
+                  MEM table entries\r
+\r
+Returns:\r
+  Nothing.  \r
+  \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h
new file mode 100644 (file)
index 0000000..25b0d6e
--- /dev/null
@@ -0,0 +1,1693 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiRuntimeLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_RUNTIME_LIB_H_\r
+#define _EFI_RUNTIME_LIB_H_\r
+#define MAX_FVB_COUNT 16\r
+#include "EfiStatusCode.h"\r
+#include "EfiCommonLib.h"\r
+\r
+#include "LinkedList.h"\r
+#include "GetImage.h"\r
+#include "RtDevicePath.h"\r
+\r
+#include EFI_GUID_DEFINITION (DxeServices)\r
+#include EFI_GUID_DEFINITION (EventGroup)\r
+#include EFI_GUID_DEFINITION (EventLegacyBios)\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)\r
+#include "ProcDep.h"\r
+\r
+typedef struct {\r
+  EFI_HANDLE                          Handle;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
+  EFI_FVB_EXTENSION_PROTOCOL          *FvbExtension;\r
+} FVB_ENTRY;\r
+\r
+//\r
+// Driver Lib Globals.\r
+//\r
+extern EFI_BOOT_SERVICES  *gBS;\r
+extern EFI_SYSTEM_TABLE   *gST;\r
+extern EFI_DXE_SERVICES   *gDS;\r
+extern UINTN              gRtErrorLevel;\r
+extern FVB_ENTRY          *mFvbEntry;\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibFvbVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Notify function to convert pointers to Fvb functions after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - Event whose notification function is being invoked.\r
+  Context - Pointer to the notification function¡¯s context, which is\r
+            implementation-dependent.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     RuntimeNotifyEventHandler\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+  \r
+  RuntimeNotifyEventHandler     - Virtual address change notification event\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiShutdownRuntimeDriverLib (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInitializeSmmDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Smm Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  IN OUT VOID **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the EFI 1.0 System Tabl entry with TableGuid\r
+\r
+Arguments:\r
+\r
+  TableGuid - Name of entry to return in the system table\r
+  Table     - Pointer in EFI system table associated with TableGuid\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Table returned;\r
+  EFI_NOT_FOUND - TableGuid not in EFI system table\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Am I at runtime?\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TRUE      - At runtime\r
+  FALSE     - Not at runtime\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+  FALSE - If SetVirtualAddressMap () has not been called\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  IN OUT VOID **Table\r
+  )\r
+/*++\r
+\r
\r
+\r
+Routine Description:\r
+\r
\r
+\r
+  Get table from configuration table by name\r
+\r
\r
+\r
+Arguments:\r
+\r
\r
+\r
+  TableGuid       - Table name to search\r
+\r
+  \r
+\r
+  Table           - Pointer to the table caller wants\r
+\r
\r
+\r
+Returns: \r
+\r
\r
+\r
+  EFI_NOT_FOUND   - Not found the table\r
+\r
+  \r
+\r
+  EFI_SUCCESS     - Found the table\r
+\r
\r
+\r
+--*/\r
+\r
+;\r
+\r
+EFI_EVENT\r
+RtEfiLibCreateProtocolNotifyEvent (\r
+  IN EFI_GUID             *ProtocolGuid,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext,\r
+  OUT VOID                **Registration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a protocol notification event and return it.\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid    - Protocol to register notification event on.\r
+\r
+  NotifyTpl       - Maximum TPL to single the NotifyFunction.\r
+\r
+  NotifyFunction  - EFI notification routine.\r
+\r
+  NotifyContext   - Context passed into Event when it is created.\r
+\r
+  Registration    - Registration key returned from RegisterProtocolNotify().\r
+\r
+Returns: \r
+\r
+  The EFI_EVENT that has been registered to be signaled when a ProtocolGuid \r
+  is added to the system.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Lock.c\r
+//\r
+typedef struct {\r
+  EFI_TPL Tpl;\r
+  EFI_TPL OwnerTpl;\r
+  UINTN   Lock;\r
+} EFI_LOCK;\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  Note on a check build ASSERT()s are used to ensure proper\r
+  lock usage.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - The task priority level of the lock\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Macro to initialize the state of a lock when a lock variable is declared\r
+//\r
+#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}\r
+\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  Lock owned\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock, and\r
+    restores the previous task priority level.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    None\r
+\r
+--*/\r
+;\r
+\r
+#define EfiCopyMem  EfiCommonLibCopyMem\r
+#define EfiSetMem   EfiCommonLibSetMem\r
+#define EfiZeroMem  EfiCommonLibZeroMem\r
+\r
+INTN\r
+EfiCompareMem (\r
+  IN VOID     *MemOne,\r
+  IN VOID     *MemTwo,\r
+  IN UINTN    Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two memory buffers of a given length.\r
+\r
+Arguments:\r
+\r
+  MemOne - First memory buffer\r
+\r
+  MemTwo - Second memory buffer\r
+\r
+  Len    - Length of Mem1 and Mem2 memory regions to compare\r
+\r
+Returns:\r
+\r
+  = 0     if MemOne == MemTwo\r
+  \r
+  > 0     if MemOne > MemTwo\r
+  \r
+  < 0     if MemOne < MemTwo\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Debug.c init\r
+//\r
+EFI_STATUS\r
+EfiDebugAssertInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Locate Debug Assert Protocol and set as mDebugAssert\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Wrapper for EFI runtime functions\r
+//\r
+VOID\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform¡¯s monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device¡¯s\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiSetTime (\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+EFI_STATUS\r
+EfiQueryVariableInfo (\r
+  IN UINT32           Attributes,\r
+  OUT UINT64          *MaximumVariableStorageSize,\r
+  OUT UINT64          *RemainingVariableStorageSize,\r
+  OUT UINT64          *MaximumVariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+#endif\r
+\r
+\r
+EFI_STATUS\r
+EfiReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+  \r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+  Status code\r
+  \r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiConvertPointer (\r
+  IN UINTN                     DebugDisposition,\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT EFI_LIST_ENTRY   *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Conver the standard Lib double linked list to a virtual mapping.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)\r
+\r
+  ListHead         - Head of linked list to convert\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Base IO Class Functions\r
+//\r
+EFI_STATUS\r
+EfiIoRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of read transaction, and repeat operation to use\r
+  Address - IO address to read\r
+  Count   - Number of times to read the IO address.\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+UINT8\r
+IoRead8 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+UINT16\r
+IoRead16 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+UINT32\r
+IoRead32 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiIoWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+IoWrite8 (\r
+  IN  UINT64    Address,\r
+  IN  UINT8     Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+IoWrite16 (\r
+  IN  UINT64    Address,\r
+  IN  UINT16    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+IoWrite32 (\r
+  IN  UINT64    Address,\r
+  IN  UINT32    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiMemRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN  OUT VOID                      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a Memory mapped IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of each read transaction.\r
+  Address - Memory mapped IO address to read\r
+  Count   - Number of Width quanta to read\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+UINT8\r
+MemRead8 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+UINT16\r
+MemRead16 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+UINT32\r
+MemRead32 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+MemRead64 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a eight byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiMemWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a memory mapped IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+MemWrite8 (\r
+  IN  UINT64    Address,\r
+  IN  UINT8     Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+MemWrite16 (\r
+  IN  UINT64    Address,\r
+  IN  UINT16    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+MemWrite32 (\r
+  IN  UINT64    Address,\r
+  IN  UINT32    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+MemWrite64 (\r
+  IN  UINT64    Address,\r
+  IN  UINT64    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a eight byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Platform specific functions\r
+//\r
+UINT8\r
+PciRead8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+;\r
+\r
+UINT16\r
+PciRead16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+;\r
+\r
+UINT32\r
+PciRead32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PciWrite8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT8   Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PciWrite16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT16  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PciWrite32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT32  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle write\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiStall (\r
+  IN  UINTN   Microseconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+ Delay for at least the request number of microseconds\r
+    \r
+Arguments:\r
+  Microseconds - Number of microseconds to delay.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  FVB Services.\r
+//\r
+EFI_STATUS\r
+EfiFvbInitialize (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Initialize globals and register Fvb Protocol notification function.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbShutdown (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Release resources allocated in EfiFvbInitialize.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  Offset                - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  Offset                - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+  \r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN EFI_FVB_ATTRIBUTES                   Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiFvbGetBlockSize (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  OUT UINTN                               *BlockSize,\r
+  OUT UINTN                               *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose block size is going to be\r
+                          returned\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+\r
+--*/\r
+;\r
+EFI_STATUS\r
+EfiFvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetLastLba         - Offset into the last block at which to end erasing\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiCpuFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS          Start,\r
+  IN UINT64                        Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush cache with specified range.\r
+\r
+Arguments:\r
+\r
+  Start   - Start address\r
+  Length  - Length in bytes\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RtEfiCreateEventLegacyBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *LegacyBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Legacy Boot Event.  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Returns:\r
+  EFI_SUCCESS   Event was created.\r
+  Other         Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RtEfiCreateEventReadyToBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *ReadyToBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  ReadyToBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Return:\r
+  EFI_SUCCESS   - Event was created.\r
+  Other         - Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h
new file mode 100644 (file)
index 0000000..fbf9699
--- /dev/null
@@ -0,0 +1,517 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    EfiScriptLib.h\r
+\r
+Abstract:\r
+\r
\r
+--*/\r
+\r
+#ifndef _EFI_SCRIPT_LIB_H_\r
+#define _EFI_SCRIPT_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "EfiCommonLib.h"\r
+#include "EfiBootScript.h"\r
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)\r
+\r
+\r
+EFI_STATUS\r
+BootScriptSaveInitialize (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Boot Script Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveIoWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O write to boot script with opcode EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the I/O operations.\r
+  \r
+  Address - The base address of the I/O operations.\r
+  \r
+  Count   - The number of I/O operations to perform.\r
+  \r
+  Buffer  - The source buffer from which to write data. \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveIoReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save I/O modify to boot script with opcode EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the I/O operations.\r
+  \r
+  Address - The base address of the I/O operations.\r
+  \r
+  Data    - A pointer to the data to be OR-ed.\r
+  \r
+  DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.\r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveMemWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save memory write to boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the memory operations.\r
+  \r
+  Address - The base address of the memory operations.\r
+  \r
+  Count   - The number of memory operations to perform.\r
+  \r
+  Buffer  - The source buffer from which to write the data. \r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveMemReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save memory modify to boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the memory operations.\r
+  \r
+  Address - The base address of the memory operations.\r
+  \r
+  Data    - A pointer to the data to be OR-ed.\r
+  \r
+  DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.\r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSavePciCfgWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PCI configuration space write operation to boot script with opcode \r
+  EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the PCI operations\r
+  \r
+  Address - The address within the PCI configuration space.\r
+  \r
+  Count   - The number of PCI operations to perform.\r
+  \r
+  Buffer  - The source buffer from which to write the data.\r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSavePciCfgReadWrite (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_BOOT_SCRIPT_WIDTH             Width,\r
+  IN  UINT64                            Address,\r
+  IN  VOID                              *Data,\r
+  IN  VOID                              *DataMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PCI configuration space modify operation to boot script with opcode \r
+  EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName - Desired boot script table\r
+\r
+  Width   - The width of the PCI operations\r
+  \r
+  Address - The address within the PCI configuration space.\r
+  \r
+  Data    - A pointer to the data to be OR-ed.\r
+  \r
+  DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.\r
+\r
+Returns: \r
+  \r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveSmbusExecute (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_SMBUS_DEVICE_ADDRESS          SlaveAddress,\r
+  IN  EFI_SMBUS_DEVICE_COMMAND          Command,\r
+  IN  EFI_SMBUS_OPERATION               Operation,\r
+  IN  BOOLEAN                           PecCheck,\r
+  IN  UINTN                             *Length,\r
+  IN  VOID                              *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save SMBus command execution to boot script with opcode \r
+  EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName     - Desired boot script table\r
+  SlaveAddress  - The SMBus address for the slave device that the operation is targeting.\r
+  Command       - The command that is transmitted by the SMBus host controller to the \r
+                  SMBus slave device.\r
+  Operation     - Indicates which particular SMBus protocol it will use to execute the \r
+                  SMBus transactions.\r
+  PecCheck      - Defines if Packet Error Code (PEC) checking is required for this operation.\r
+  Length        - A pointer to signify the number of bytes that this operation will do.\r
+  Buffer        - Contains the value of data to execute to the SMBUS slave device.\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveStall (\r
+  IN  UINT16                            TableName,\r
+  IN  UINTN                             Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save execution stall on the processor to boot script with opcode \r
+  EFI_BOOT_SCRIPT_STALL_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName     - Desired boot script table\r
+  \r
+  Duration      - Duration in microseconds of the stall.\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BootScriptSaveDispatch (\r
+  IN  UINT16                            TableName,\r
+  IN  EFI_PHYSICAL_ADDRESS              EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save dispatching specified arbitrary code to boot script with opcode \r
+  EFI_BOOT_SCRIPT_DISPATCH_OPCODE\r
+\r
+Arguments:\r
+\r
+  TableName     - Desired boot script table\r
+  \r
+  EntryPoint    - Entry point of the code to be dispatched.\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformation (\r
+  IN  UINT16                                 TableName,\r
+  IN  UINT32                                 Length, \r
+  IN  EFI_PHYSICAL_ADDRESS                   Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  Length         - Length of information in bytes\r
+  Buffer          - Content of information that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformationUnicodeString (\r
+  IN        UINT16              TableName,\r
+  IN        CHAR16              *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName, the information\r
+  is a unicode string.\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  String          - The string that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootScriptSaveInformationAsciiString (\r
+  IN        UINT16              TableName,\r
+  IN        CHAR8               *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save a Information Opcode record in table specified with TableName, the information\r
+  is a ascii string.\r
+\r
+Arguments:\r
+\r
+  TableName   - Desired boot script table\r
+  String          - The string that will be saved in script table\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND - BootScriptSave Protocol not exist.\r
+  \r
+  EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+  \r
+#ifdef EFI_S3_RESUME\r
+  \r
+#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) \\r
+          BootScriptSaveInitialize(ImageHandle, SystemTable)\r
+\r
+#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \\r
+          BootScriptSaveIoWrite(TableName, Width, Address, Count, Buffer)\r
+\r
+#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \\r
+          BootScriptSaveIoReadWrite(TableName, Width, Address, Data, DataMask)\r
+\r
+#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \\r
+          BootScriptSaveMemWrite(TableName, Width, Address, Count, Buffer)\r
+\r
+#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) \\r
+          BootScriptSaveMemWrite(TableName, Width, Address, Count, (VOID*)(UINTN)Address)\r
+\r
+#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \\r
+          BootScriptSaveMemReadWrite(TableName, Width, Address, Data, DataMask)\r
+\r
+#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \\r
+          BootScriptSavePciCfgWrite(TableName, Width, Address, Count, Buffer)\r
+\r
+#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \\r
+          BootScriptSavePciCfgReadWrite(TableName, Width, Address, Data, DataMask)\r
+\r
+#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \\r
+          BootScriptSaveSmbusExecute(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer)\r
+\r
+#define SCRIPT_STALL(TableName, Duration) \\r
+          BootScriptSaveStall(TableName, Duration)\r
+\r
+#define SCRIPT_DISPATCH(TableName, EntryPoint) \\r
+          BootScriptSaveDispatch(TableName, EntryPoint)\r
+\r
+#define SCRIPT_INOFRMATION(TableName, Length, Buffer) \\r
+          BootScriptSaveInformation(TableName, Length, Buffer)\r
+\r
+#define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String) \\r
+          BootScriptSaveInformationUnicodeString(TableName, String)\r
+\r
+#define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String) \\r
+          BootScriptSaveInformationAsciiString(TableName, String)\r
+          \r
+#else\r
+\r
+#define INITIALIZE_SCRIPT(ImageHandle, SystemTable)          \r
+\r
+#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \r
+\r
+#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \r
+          \r
+#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \r
+\r
+#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count)\r
+\r
+#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \r
+\r
+#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \r
+\r
+#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \r
+\r
+#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \r
+\r
+#define SCRIPT_STALL(TableName, Duration)           \r
+\r
+#define SCRIPT_DISPATCH(TableName, EntryPoint) \r
+\r
+#define SCRIPT_INOFRMATION(TableName, Length, Buffer)\r
+\r
+#define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String)\r
+\r
+#define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String)\r
+\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h
new file mode 100644 (file)
index 0000000..239fb38
--- /dev/null
@@ -0,0 +1,220 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiSmmDriverLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support EFI Smm drivers.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_SMM_DRIVER_LIB_H_\r
+#define _EFI_SMM_DRIVER_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "GetImage.h"\r
+#include "EfiCommonLib.h"\r
+#include EFI_GUID_DEFINITION (EventLegacyBios)\r
+#include EFI_GUID_DEFINITION (EventGroup)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
+#include EFI_PROTOCOL_DEFINITION (SmmBase)\r
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)\r
+//\r
+// Driver Lib Globals.\r
+//\r
+extern EFI_BOOT_SERVICES            *gBS;\r
+extern EFI_SYSTEM_TABLE             *gST;\r
+extern EFI_RUNTIME_SERVICES         *gRT;\r
+extern EFI_SMM_BASE_PROTOCOL        *gSMM;\r
+extern EFI_SMM_STATUS_CODE_PROTOCOL *mSmmDebug;\r
+extern UINTN                        gErrorLevel;\r
+\r
+#define EfiCopyMem  EfiCommonLibCopyMem\r
+#define EfiSetMem   EfiCommonLibSetMem\r
+#define EfiZeroMem  EfiCommonLibZeroMem\r
+\r
+EFI_STATUS\r
+EfiInitializeSmmDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN OUT BOOLEAN          *InSmm\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize Smm Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+  \r
+  InSmm           - If InSmm is NULL, it will not register Image to SMM.\r
+                    If InSmm is not NULL, it will register Image to SMM and\r
+                      return information on currently in SMM mode or not.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiDebugAssert (\r
+  IN CHAR8    *FileName,\r
+  IN INTN     LineNumber,\r
+  IN CHAR8    *Description\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded DEADLOOP ().\r
+  \r
+Arguments:\r
+\r
+  FileName    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT().\r
+\r
+  Description - Description, usually the assertion,\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiDebugVPrint (\r
+  IN  UINTN   ErrorLevel,\r
+  IN  CHAR8   *Format,\r
+  IN  VA_LIST Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+  \r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  Marker     - VarArgs\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EfiDebugPrint (\r
+  IN  UINTN                   ErrorLevel,\r
+  IN  CHAR8                   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+\r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  ...        - VAR args for Format\r
+\r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEfiCreateEventLegacyBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *LegacyBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Legacy Boot Event.  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Returns:\r
+  EFI_SUCCESS   Event was created.\r
+  Other         Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEfiCreateEventReadyToBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *ReadyToBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  ReadyToBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Return:\r
+  EFI_SUCCESS   - Event was created.\r
+  Other         - Event was not created.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
new file mode 100644 (file)
index 0000000..1403bbb
--- /dev/null
@@ -0,0 +1,205 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  EfiUiLib.h\r
+\r
+Abstract:\r
+  Collection of usefull UI functions.\r
+\r
+Revision History:\r
+\r
+--*/\r
+\r
+#ifndef _EFI_UI_LIB_H_\r
+#define _EFI_UI_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "TianoTypes.h"\r
+#include "EfiDriverLib.h"\r
+\r
+CHAR16  *\r
+StrHzToString (\r
+  OUT CHAR16         *String,\r
+  IN  UINT64         Val\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts frequency in Hz to Unicode string. \r
+  Three significant digits are delivered. Used for processor info display.\r
+\r
+Arguments:\r
+  String - string that will contain the frequency.\r
+  Val    - value to convert, minimum is  100000 i.e., 0.1 MHz.\r
+\r
+Returns:\r
+  String that contains the frequency.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16  *\r
+StrBytesToString (\r
+  OUT CHAR16         *String,\r
+  IN  UINT64         Val\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts size in bytes to Unicode string.\r
+  Used for memory/cache size display.\r
+\r
+Arguments:\r
+  String - string that will contain the value\r
+  Val    - value to convert in bytes\r
+\r
+Returns:\r
+  String that contains the value.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16  *\r
+StrVersionToString (\r
+  OUT CHAR16          *String,\r
+  IN  UINT8           Version\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts 8 bit version value to Unicode string.\r
+  The upper nibble contains the upper part, the lower nibble contains the minor part.\r
+  The output format is <major>.<minor>.\r
+\r
+Arguments:\r
+  String  - string that will contain the version value\r
+  Version - Version value to convert\r
+  \r
+Returns:\r
+  String that contains the version value.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16  *\r
+StrMacToString (\r
+  OUT CHAR16              *String,\r
+  IN  EFI_MAC_ADDRESS     *MacAddr,\r
+  IN  UINT32              AddrSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts MAC address to Unicode string.\r
+  The value is 64-bit and the resulting string will be 12\r
+  digit hex number in pairs of digits separated by dashes.\r
+\r
+Arguments:\r
+  String - string that will contain the value\r
+  MacAddr     - MAC address to convert\r
+  AddrSize    - Size of address\r
+  \r
+Returns:\r
+  String that contains the value.\r
+\r
+--*/\r
+;\r
+\r
+CHAR16  *\r
+StrIp4AdrToString (\r
+  OUT CHAR16             *String,\r
+  IN  EFI_IPv4_ADDRESS   *Ip4Addr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts IP v4 address to Unicode string.\r
+  The value is 64-bit and the resulting string will\r
+  be four decimal values 0-255 separated by dots.\r
+\r
+Arguments:\r
+  String  - string that will contain the value\r
+  Ip4Addr - IP v4 address to convert from\r
+\r
+Returns:\r
+\r
+  String that contain the value\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+StrStringToIp4Adr (\r
+  OUT EFI_IPv4_ADDRESS   *Ip4Addr,\r
+  IN  CHAR16             *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parses and converts Unicode string to IP v4 address.\r
+  The value will 64-bit.\r
+  The string must be four decimal values 0-255 separated by dots.\r
+  The string is parsed and format verified.\r
+\r
+Arguments:\r
+  Ip4Addr - pointer to the variable to store the value to\r
+  String  - string that contains the value to parse and convert\r
+\r
+Returns:\r
+  EFI_SUCCESS           - if successful\r
+  EFI_INVALID_PARAMETER - if String contains invalid IP v4 format\r
+\r
+--*/\r
+;\r
+\r
+CHAR16  *\r
+Ascii2Unicode (\r
+  OUT CHAR16         *UnicodeStr,\r
+  IN  CHAR8          *AsciiStr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts ASCII characters to Unicode.\r
+\r
+Arguments:\r
+  UnicodeStr - the Unicode string to be written to. The buffer must be large enough.\r
+  AsciiStr   - The ASCII string to be converted.\r
+\r
+Returns:\r
+  The address to the Unicode string - same as UnicodeStr.\r
+\r
+--*/\r
+;\r
+\r
+CHAR8   *\r
+Unicode2Ascii (\r
+  OUT CHAR8          *AsciiStr,\r
+  IN  CHAR16         *UnicodeStr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts ASCII characters to Unicode.\r
+  Assumes that the Unicode characters are only these defined in the ASCII set.\r
+\r
+Arguments:\r
+  AsciiStr   - The ASCII string to be written to. The buffer must be large enough.\r
+  UnicodeStr - the Unicode string to be converted.\r
+\r
+Returns:\r
+  The address to the ASCII string - same as AsciiStr.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h
new file mode 100644 (file)
index 0000000..b118c8e
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiWinNtLib.h\r
+\r
+Abstract:\r
+\r
+  Set up gWinNt pointer so we can call WinNT APIs.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_WIN_NT_LIB_H_\r
+#define _EFI_WIN_NT_LIB_H_\r
+\r
+extern EFI_WIN_NT_THUNK_PROTOCOL  *gWinNt;\r
+\r
+EFI_STATUS\r
+EfiInitializeWinNtDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize gWinNt and initialize debug console. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// NTDebugConsole Prototypes\r
+//\r
+VOID\r
+NtDebugConsoleInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Nt debug console initialize.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h
new file mode 100644 (file)
index 0000000..b8f70d0
--- /dev/null
@@ -0,0 +1,104 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  GetImage.h\r
+\r
+Abstract:\r
+\r
+  Image data retrieval support for common use.\r
+\r
+--*/\r
+\r
+#ifndef _GET_IMAGE_H_\r
+#define _GET_IMAGE_H_\r
+#include "EfiImageFormat.h"\r
+\r
+EFI_STATUS\r
+GetImage (\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Enumerate all the FVs, and fill Buffer with the SectionType section content in NameGuid file.\r
+\r
+  Note:\r
+  1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on \r
+      reading EFI_SECTION_PE32 section.\r
+  2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on\r
+      reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file.\r
+  3. Callee allocates memory, which caller is responsible to free.\r
+\r
+Arguments:\r
+\r
+  NameGuid            - Pointer to EFI_GUID, which is file name.\r
+  SectionType         - Required section type.\r
+  Buffer              - Pointer to a pointer in which the read content is returned.\r
+                          Caller is responsible to free Buffer.\r
+  Size                - Pointer to a UINTN, which indicates the size of returned *Buffer.\r
+\r
+Returns:\r
+  EFI_NOT_FOUND       - Required content can not be found.\r
+  EFI_SUCCESS         - Required content can be found, but whether the Buffer is filled \r
+                          with section content or not depends on the Buffer and Size.\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetImageEx (\r
+  IN  EFI_HANDLE         ImageHandle,\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size,\r
+  BOOLEAN                WithinImageFv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Search FVs, and fill Buffer with the SectionType section content in NameGuid file.\r
+  If ImageHandle is not NULL, the FV from which the ImageHandle is loaded is searched\r
+  first. If WithinImageFv is TRUE, only the FV from which the ImageHandle is loaded\r
+  is searched. If ImageHandle is NULL or WithinImageFv is FALSE, all FVs in the system\r
+  is searched.\r
+\r
+  Note:\r
+  1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on \r
+      reading EFI_SECTION_PE32 section.\r
+  2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on\r
+      reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file.\r
+  3. Callee allocates memory, which caller is responsible to free.\r
+\r
+Arguments:\r
+\r
+  ImageHandle         - The caller's driver image handle.\r
+  NameGuid            - Pointer to EFI_GUID, which is file name.\r
+  SectionType         - Required section type.\r
+  Buffer              - Pointer to a pointer in which the read content is returned.\r
+                          Caller is responsible to free Buffer.\r
+  Size                - Pointer to a UINTN, which indicates the size of returned *Buffer.\r
+  WithinImageFv       - Whether the search only performs on the FV from which the caller's\r
+                        driver image is loaded.\r
+\r
+Returns:\r
+  EFI_INVALID_PARAMETER - ImageHandle is NULL and WithinImageFv is TRUE.\r
+  EFI_NOT_FOUND         - Required content can not be found.\r
+  EFI_SUCCESS           - Required content can be found, but whether the Buffer is filled \r
+                          with section content or not depends on the Buffer and Size.\r
+--*/\r
+;\r
+\r
+#endif //_GET_IMAGE_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h
new file mode 100644 (file)
index 0000000..74dbf87
--- /dev/null
@@ -0,0 +1,250 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GraphicsLib.h\r
+\r
+Abstract:\r
+\r
\r
+--*/\r
+\r
+#ifndef _EFI_GRAPHICS_LIB_H_\r
+#define _EFI_GRAPHICS_LIB_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ConsoleControl)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging)\r
+\r
+#include EFI_GUID_DEFINITION (Bmp)\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFV (\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFVEx (\r
+  IN  EFI_HANDLE    ImageHandle,\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the graphics image file named FileNameGuid into Image and return it's\r
+  size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+  file name.\r
+\r
+Arguments:\r
+\r
+  ImageHandle   - The driver image handle of the caller. The parameter is used to\r
+                  optimize the loading of the image file so that the FV from which\r
+                  the driver image is loaded will be tried first. \r
+\r
+  FileNameGuid  - File Name of graphics file in the FV(s).\r
+\r
+  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
+                  buffer will be allocated.\r
+\r
+  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS          - Image and ImageSize are valid. \r
+  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  EFI_NOT_FOUND        - FileNameGuid not found\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+ConvertBmpToGopBlt (\r
+  IN  VOID      *BmpImage,\r
+  IN  UINTN     BmpImageSize,\r
+  IN OUT VOID   **GopBlt,\r
+  IN OUT UINTN  *GopBltSize,\r
+  OUT UINTN     *PixelHeight,\r
+  OUT UINTN     *PixelWidth\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer\r
+  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
+  buffer is passed in it will be used if it is big enough.\r
+\r
+Arguments:\r
+\r
+  BmpImage      - Pointer to BMP file\r
+\r
+  BmpImageSize  - Number of bytes in BmpImage\r
+\r
+  GopBlt        - Buffer containing GOP version of BmpImage.\r
+\r
+  GopBltSize    - Size of GopBlt in bytes.\r
+\r
+  PixelHeight   - Height of GopBlt/BmpImage in pixels\r
+\r
+  PixelWidth    - Width of GopBlt/BmpImage in pixels\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - GopBlt and GopBltSize are returned. \r
+  EFI_UNSUPPORTED       - BmpImage is not a valid *.BMP image\r
+  EFI_BUFFER_TOO_SMALL  - The passed in GopBlt buffer is not big enough.\r
+                          GopBltSize will contain the required size.\r
+  EFI_OUT_OF_RESOURCES  - No enough buffer to allocate\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EnableQuietBoot (\r
+  IN  EFI_GUID  *LogoFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+  to the UGA device. Put up LogoFile on every UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile - File name of logo to display on the center of the screen.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EnableQuietBootEx (\r
+  IN  EFI_GUID    *LogoFile,\r
+  IN  EFI_HANDLE  ImageHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+  to the UGA device. Put up LogoFile on every UGA device that is a console\r
+\r
+Arguments:\r
+\r
+  LogoFile    - File name of logo to display on the center of the screen.\r
+  ImageHandle - The driver image handle of the caller. The parameter is used to\r
+                optimize the loading of the logo file so that the FV from which\r
+                the driver image is loaded will be tried first.\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                          displayed.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+DisableQuietBoot (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
+  Simple Text Out screens will now be synced up with all non UGA output devices\r
+\r
+Arguments:\r
+\r
+  NONE\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - UGA devices are back in text mode and synced up.\r
+  EFI_UNSUPPORTED       - Logo not found\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
+  This is the ConInHandle and ConIn handle in the EFI system table. All key\r
+  presses will be ignored until the Password is typed in. The only way to\r
+  disable the password is to type it in to a ConIn device.\r
+\r
+Arguments:\r
+  Password - Password used to lock ConIn device\r
+\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - ConsoleControl has been flipped to graphics and logo\r
+                    displayed.\r
+  EFI_UNSUPPORTED - Logo not found\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h
new file mode 100644 (file)
index 0000000..8ddc018
--- /dev/null
@@ -0,0 +1,260 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuFuncs.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _CPU_FUNCS_H_\r
+#define _CPU_FUNCS_H_\r
+\r
+#define EFI_CPUID_SIGNATURE         0x0\r
+#define EFI_CPUID_VERSION_INFO      0x1\r
+#define EFI_CPUID_CACHE_INFO        0x2\r
+#define EFI_CPUID_SERIAL_NUMBER     0x3\r
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000\r
+#define EFI_CPUID_EXTENDED_CPU_SIG  0x80000001\r
+#define EFI_CPUID_BRAND_STRING1     0x80000002\r
+#define EFI_CPUID_BRAND_STRING2     0x80000003\r
+#define EFI_CPUID_BRAND_STRING3     0x80000004\r
+\r
+//\r
+// CPUID version information masks\r
+// Note: leaving masks here is for the compatibility\r
+//       use EfiCpuVersion (...) instead\r
+//\r
+#define EFI_CPUID_FAMILY                      0x0F00\r
+#define EFI_CPUID_MODEL                       0x00F0\r
+#define EFI_CPUID_STEPPING                    0x000F\r
+\r
+#define EFI_CPUID_PENTIUM_M                   0x0600\r
+#define EFI_CPUID_BANIAS                      0x0090\r
+#define EFI_CPUID_DOTHAN                      0x00D0\r
+#define EFI_CPUID_NETBURST                    0x0F00\r
+\r
+#define EFI_MSR_IA32_PLATFORM_ID              0x17\r
+#define EFI_MSR_IA32_APIC_BASE                0x1B\r
+#define EFI_MSR_EBC_HARD_POWERON              0x2A\r
+#define EFI_MSR_EBC_SOFT_POWERON              0x2B\r
+#define BINIT_DRIVER_DISABLE                  0x40\r
+#define INTERNAL_MCERR_DISABLE                0x20\r
+#define INITIATOR_MCERR_DISABLE               0x10\r
+#define EFI_MSR_EBC_FREQUENCY_ID              0x2C\r
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG           0x79\r
+#define EFI_MSR_IA32_BIOS_SIGN_ID             0x8B\r
+#define EFI_MSR_PSB_CLOCK_STATUS              0xCD\r
+#define EFI_APIC_GLOBAL_ENABLE                0x800\r
+#define EFI_MSR_IA32_MISC_ENABLE              0x1A0\r
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT         0x00400000\r
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT  0x00000008\r
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT      0x00000004\r
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002\r
+#define FAST_STRING_ENABLE_BIT                0x00000001\r
+\r
+#define EFI_CACHE_VARIABLE_MTRR_BASE          0x200\r
+#define EFI_CACHE_VARIABLE_MTRR_END           0x20F\r
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE          0x2FF\r
+#define EFI_CACHE_VALID_ADDRESS               0xFFFFFF000\r
+#define EFI_CACHE_MTRR_VALID                  0x800\r
+#define EFI_CACHE_FIXED_MTRR_VALID            0x400\r
+#define EFI_MSR_VALID_MASK                    0xFFFFFFFFF\r
+\r
+#define EFI_IA32_MTRR_FIX64K_00000            0x250\r
+#define EFI_IA32_MTRR_FIX16K_80000            0x258\r
+#define EFI_IA32_MTRR_FIX16K_A0000            0x259\r
+#define EFI_IA32_MTRR_FIX4K_C0000             0x268\r
+#define EFI_IA32_MTRR_FIX4K_C8000             0x269\r
+#define EFI_IA32_MTRR_FIX4K_D0000             0x26A\r
+#define EFI_IA32_MTRR_FIX4K_D8000             0x26B\r
+#define EFI_IA32_MTRR_FIX4K_E0000             0x26C\r
+#define EFI_IA32_MTRR_FIX4K_E8000             0x26D\r
+#define EFI_IA32_MTRR_FIX4K_F0000             0x26E\r
+#define EFI_IA32_MTRR_FIX4K_F8000             0x26F\r
+\r
+#define EFI_IA32_MCG_CAP                      0x179\r
+#define EFI_IA32_MCG_CTL                      0x17B\r
+#define EFI_IA32_MC0_CTL                      0x400\r
+#define EFI_IA32_MC0_STATUS                   0x401\r
+\r
+#define EFI_CACHE_UNCACHEABLE                 0\r
+#define EFI_CACHE_WRITECOMBINING              1\r
+#define EFI_CACHE_WRITETHROUGH                4\r
+#define EFI_CACHE_WRITEPROTECTED              5\r
+#define EFI_CACHE_WRITEBACK                   6\r
+\r
+//\r
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number\r
+//\r
+#define EfiMakeCpuVersion(f, m, s)            \\r
+  (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))\r
+\r
+typedef struct {\r
+  UINT32  HeaderVersion;\r
+  UINT32  UpdateRevision;\r
+  UINT32  Date;\r
+  UINT32  ProcessorId;\r
+  UINT32  Checksum;\r
+  UINT32  LoaderRevision;\r
+  UINT32  ProcessorFlags;\r
+  UINT32  DataSize;\r
+  UINT32  TotalSize;\r
+  UINT8   Reserved[12];\r
+} EFI_CPU_MICROCODE_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  ExtSigCount;\r
+  UINT32  ExtChecksum;\r
+  UINT8   Reserved[12];\r
+  UINT32  ProcessorId;\r
+  UINT32  ProcessorFlags;\r
+  UINT32  Checksum;\r
+} EFI_CPU_MICROCODE_EXT_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  RegEax;\r
+  UINT32  RegEbx;\r
+  UINT32  RegEcx;\r
+  UINT32  RegEdx;\r
+} EFI_CPUID_REGISTER;\r
+\r
+VOID\r
+EfiWriteMsr (\r
+  IN  UINT32      Input,\r
+  IN  UINT64      Value\r
+  )\r
+/*++                               \r
+                                                                                           \r
+Routine Description:                                                \r
+\r
+  Write Cpu MSR\r
+  \r
+Arguments:                \r
+\r
+  Input  -The index value to select the register\r
+  Value  -The value to write to the selected register                      \r
+  \r
+Returns:                                                            \r
+\r
+   None                                                \r
+   \r
+--*/\r
+;\r
+\r
+UINT64\r
+EfiReadMsr (\r
+  IN  UINT32      Input\r
+  )\r
+/*++                                 \r
+                                                                                         \r
+Routine Description:                                                \r
+\r
+  Read Cpu MSR.\r
+  \r
+Arguments:                \r
+\r
+  Input: -The index value to select the register\r
+                       \r
+Returns:                                                            \r
+\r
+   Return the read data                                                \r
+   \r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCpuid (\r
+  IN  UINT32                    RegEax,\r
+  OUT EFI_CPUID_REGISTER        *Reg\r
+  )\r
+/*++                                      \r
+                                                                                    \r
+Routine Description:                                     \r
+           \r
+  Get the Cpu info by excute the CPUID instruction.\r
+  \r
+Arguments:                \r
+\r
+   RegEax  -The input value to put into register EAX\r
+   Reg     -The Output value                      \r
+   \r
+Returns:                         \r
+                                   \r
+   None                          \r
+                         \r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCpuVersion (\r
+  IN   UINT16  *FamilyId,    OPTIONAL\r
+  IN   UINT8   *Model,       OPTIONAL\r
+  IN   UINT8   *SteppingId,  OPTIONAL\r
+  IN   UINT8   *Processor    OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract CPU detail version infomation\r
+\r
+Arguments:\r
+  FamilyId   - FamilyId, including ExtendedFamilyId\r
+  Model      - Model, including ExtendedModel\r
+  SteppingId - SteppingId\r
+  Processor  - Processor\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+EfiReadTsc (\r
+  VOID\r
+  )\r
+/*++                   \r
+                                                                                                       \r
+Routine Description:                                                \r
+\r
+  Read Time stamp.\r
+  \r
+Arguments:                \r
+\r
+  None                 \r
+  \r
+Returns:                                                            \r
+\r
+   Return the read data                                                \r
+   \r
+--*/\r
+;\r
+VOID\r
+EfiCpuidExt (\r
+  IN  UINT32                 RegisterInEax,\r
+  IN  UINT32                 CacheLevel,\r
+  OUT EFI_CPUID_REGISTER     *Regs\r
+  )\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  When RegisterInEax != 4, the functionality is the same as EfiCpuid.\r
+  When RegisterInEax == 4, the function return the deterministic cache\r
+  parameters by excuting the CPUID instruction\r
+Arguments:                \r
+   RegisterInEax: - The input value to put into register EAX\r
+   CacheLevel:      - The deterministic cache level\r
+   Regs:          - The Output value                      \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h
new file mode 100644 (file)
index 0000000..950b966
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ProcDep.h\r
+\r
+Abstract:\r
+\r
+  IA-32 specific Runtime Lib code. At this time there is non. \r
+  IPF has different code due to extra API requirements.\r
+\r
+--*/\r
+\r
+#ifndef _PROC_DEP_H_\r
+#define _PROC_DEP_H_\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h
new file mode 100644 (file)
index 0000000..976d3dc
--- /dev/null
@@ -0,0 +1,111 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Ia32EfiRuntimeDriverLib.h\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support IA32 EFI Libraries.\r
+\r
+--*/\r
+\r
+#ifndef _IA32_EFI_RUNTIME_LIB_H_\r
+#define _IA32_EFI_RUNTIME_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *COMMON_PROC_ENTRY) (\r
+  IN  UINTN                      FunctionId,\r
+  IN  UINTN                      Arg2,\r
+  IN  UINTN                      Arg3,\r
+  IN  UINTN                      Arg4,\r
+  IN  UINTN                      Arg5,\r
+  IN  UINTN                      Arg6,\r
+  IN  UINTN                      Arg7,\r
+  IN  UINTN                      Arg8\r
+  );\r
+\r
+typedef struct {\r
+  COMMON_PROC_ENTRY CommonProcEntry;\r
+} COMMON_PROC_ENTRY_STRUCT;\r
+\r
+EFI_STATUS\r
+InstallPlatformRuntimeLib (\r
+  IN  EFI_GUID                      *Guid,\r
+  IN  COMMON_PROC_ENTRY_STRUCT      *CommonEntry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install platform runtime lib.\r
+\r
+Arguments:\r
+\r
+  Guid                  - Guid for runtime lib\r
+  CommonEntry           - Common entry\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetPlatformRuntimeLib (\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get platform runtime lib.\r
+\r
+Arguments:\r
+\r
+  SystemTable           - Pointer to system table\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ConvertPlatformRuntimeLibPtr (\r
+  IN EFI_RUNTIME_SERVICES  *mRT\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert platform runtime lib pointer.  \r
+\r
+Arguments:\r
+\r
+  mRT                   - Pointer to runtime service table.\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h
new file mode 100644 (file)
index 0000000..a2a9ec1
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuFuncs.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _CPU_FUNCS_H\r
+#define _CPU_FUNCS_H\r
+\r
+#define EFI_CPUID_SIGNATURE           0x0\r
+#define EFI_CPUID_VERSION_INFO        0x1\r
+#define EFI_CPUID_CACHE_INFO          0x2\r
+#define EFI_CPUID_SERIAL_NUMBER       0x3\r
+#define EFI_CPUID_EXTENDED_FUNCTION   0x80000000\r
+#define EFI_CPUID_EXTENDED_CPU_SIG    0x80000001\r
+#define EFI_CPUID_BRAND_STRING1       0x80000002\r
+#define EFI_CPUID_BRAND_STRING2       0x80000003\r
+#define EFI_CPUID_BRAND_STRING3       0x80000004\r
+\r
+#define EFI_MSR_IA32_APIC_BASE        0x1B\r
+#define EFI_MSR_EBC_HARD_POWERON      0x2A\r
+#define EFI_MSR_EBC_SOFT_POWERON      0x2B\r
+#define EFI_MSR_EBC_FREQUENCY_ID      0x2C\r
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG   0x79\r
+#define EFI_MSR_IA32_BIOS_SIGN_ID     0x8B\r
+#define EFI_APIC_GLOBAL_ENABLE        0x800\r
+\r
+#define EFI_CACHE_VARIABLE_MTRR_BASE  0x200\r
+#define EFI_CACHE_VARIABLE_MTRR_END   0x20F\r
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE  0x2FF\r
+#define EFI_CACHE_VALID_ADDRESS       0xFFFFFF000\r
+#define EFI_CACHE_MTRR_VALID          0x800\r
+#define EFI_CACHE_FIXED_MTRR_VALID    0x400\r
+#define EFI_MSR_VALID_MASK            0xFFFFFFFFF\r
+\r
+#define EFI_IA32_MTRR_FIX64K_00000    0x250\r
+#define EFI_IA32_MTRR_FIX16K_80000    0x258\r
+#define EFI_IA32_MTRR_FIX16K_A0000    0x259\r
+#define EFI_IA32_MTRR_FIX4K_C0000     0x268\r
+#define EFI_IA32_MTRR_FIX4K_C8000     0x269\r
+#define EFI_IA32_MTRR_FIX4K_D0000     0x26A\r
+#define EFI_IA32_MTRR_FIX4K_D8000     0x26B\r
+#define EFI_IA32_MTRR_FIX4K_E0000     0x26C\r
+#define EFI_IA32_MTRR_FIX4K_E8000     0x26D\r
+#define EFI_IA32_MTRR_FIX4K_F0000     0x26E\r
+#define EFI_IA32_MTRR_FIX4K_F8000     0x26F\r
+\r
+#define EFI_IA32_MCG_CAP              0x179\r
+#define EFI_IA32_MCG_CTL              0x17B\r
+#define EFI_IA32_MC0_CTL              0x400\r
+#define EFI_IA32_MC0_STATUS           0x401\r
+\r
+#define EFI_CACHE_UNCACHEABLE         0\r
+#define EFI_CACHE_WRITECOMBINING      1\r
+#define EFI_CACHE_WRITETHROUGH        4\r
+#define EFI_CACHE_WRITEPROTECTED      5\r
+#define EFI_CACHE_WRITEBACK           6\r
+\r
+UINT64\r
+EfiReadTsc (\r
+  VOID\r
+  )\r
+/*++                   \r
+                                                                                                       \r
+Routine Description:                                                \r
+\r
+  Read Time stamp.\r
+  \r
+Arguments:                \r
+\r
+  None                 \r
+  \r
+Returns:                                                            \r
+\r
+   Return the read data                                                \r
+   \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h
new file mode 100644 (file)
index 0000000..c46ffbc
--- /dev/null
@@ -0,0 +1,1305 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EsalRuntimeLib.h\r
+  \r
+Abstract:\r
+\r
+  SAL Driver Lib\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _ESAL_RUNTIME_LIB_H_\r
+#define _ESAL_RUNTIME_LIB_H_\r
+\r
+#include "SalApi.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+\r
+VOID\r
+EsalRuntimeLibVirtualNotify (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - Image Handle\r
+  SystemTable - the System Table \r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+SAL_RETURN_REGS\r
+CallEsalService (\r
+  IN  EFI_GUID                                       *ClassGuid,\r
+  IN   UINT64                                        FunctionId,\r
+  IN  UINT64                                         Arg2,\r
+  IN  UINT64                                         Arg3,\r
+  IN  UINT64                                         Arg4,\r
+  IN  UINT64                                         Arg5,\r
+  IN  UINT64                                         Arg6,\r
+  IN  UINT64                                         Arg7,\r
+  IN  UINT64                                         Arg8\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ClassGuid   - TODO: add argument description\r
+  FunctionId  - TODO: add argument description\r
+  Arg2        - TODO: add argument description\r
+  Arg3        - TODO: add argument description\r
+  Arg4        - TODO: add argument description\r
+  Arg5        - TODO: add argument description\r
+  Arg6        - TODO: add argument description\r
+  Arg7        - TODO: add argument description\r
+  Arg8        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Assembly Functions\r
+//\r
+\r
+SAL_RETURN_REGS\r
+EsalGetEntryPoint (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalSetPhysicalEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  EntryPoint  - TODO: add argument description\r
+  Gp          - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalSetVirtualEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  EntryPoint  - TODO: add argument description\r
+  Gp          - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalSetPhysicalModuleGlobal (\r
+  IN  VOID    *Global\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Global  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalSetVirtualModuleGlobal (\r
+  IN  VOID    *Global\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Global  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalGetModuleGlobal (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetIrrData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetPsrData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetProcIdData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+SwitchCpuStack (\r
+  IN  UINT64  NewBsp,\r
+  IN  UINT64  OldBsp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  NewBsp  - TODO: add argument description\r
+  OldBsp  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  PAL PROC Class\r
+//\r
+\r
+SAL_RETURN_REGS\r
+SalPalProc (\r
+  IN  UINT64            Arg1,\r
+  IN  UINT64            Arg2,\r
+  IN  UINT64            Arg3,\r
+  IN  UINT64            Arg4\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Arg1  - TODO: add argument description\r
+  Arg2  - TODO: add argument description\r
+  Arg3  - TODO: add argument description\r
+  Arg4  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalRegisterNewPalEntry (\r
+  IN  BOOLEAN                     PhysicalPalAddress,\r
+  IN  EFI_PHYSICAL_ADDRESS        NewPalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  PhysicalPalAddress  - TODO: add argument description\r
+  NewPalAddress       - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalGetPalEntryPointer (\r
+  IN  BOOLEAN                     PhysicalPalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  PhysicalPalAddress  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  SAL BASE Class\r
+//\r
+\r
+SAL_RETURN_REGS\r
+SalProcSetVectors (\r
+  IN  UINT64                      SalVectorType,\r
+  IN  UINT64                      PhyAddr1,\r
+  IN  UINT64                      Gp1,\r
+  IN  UINT64                      LengthCs1,\r
+  IN  UINT64                      PhyAddr2,\r
+  IN  UINT64                      Gp2,\r
+  IN  UINT64                      LengthCs2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SalVectorType - TODO: add argument description\r
+  PhyAddr1      - TODO: add argument description\r
+  Gp1           - TODO: add argument description\r
+  LengthCs1     - TODO: add argument description\r
+  PhyAddr2      - TODO: add argument description\r
+  Gp2           - TODO: add argument description\r
+  LengthCs2     - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalProcMcRendez (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalProcMcSetParams (\r
+  IN  UINT64                      ParamType,\r
+  IN  UINT64                      IntOrMem,\r
+  IN  UINT64                      IntOrMemVal,\r
+  IN  UINT64                      Timeout,\r
+  IN  UINT64                      McaOpt\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ParamType   - TODO: add argument description\r
+  IntOrMem    - TODO: add argument description\r
+  IntOrMemVal - TODO: add argument description\r
+  Timeout     - TODO: add argument description\r
+  McaOpt      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcGetVectors (\r
+  IN  UINT64                      VectorType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  VectorType  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcMcGetParams (\r
+  IN  UINT64                      ParamInfoType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ParamInfoType - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcMcGetMcParams (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcGetMcCheckinFlags (\r
+  IN  UINT64                      ProcessorUnit\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ProcessorUnit - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Sal Base Class enums\r
+//\r
+\r
+typedef enum {\r
+  McaVector,\r
+  BspInitVector,\r
+  BootRendezVector,\r
+  ApInitVector\r
+} ESAL_GET_VECTOR_TYPE;\r
+\r
+SAL_RETURN_REGS\r
+SalInitializeThreshold (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct - TODO: add argument description\r
+  Count           - TODO: add argument description\r
+  Duration        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalBumpThresholdCount (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct - TODO: add argument description\r
+  Count           - TODO: add argument description\r
+  Duration        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalGetThresholdCount (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct - TODO: add argument description\r
+  Count           - TODO: add argument description\r
+  Duration        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Common Lib Function\r
+//\r
+\r
+EFI_STATUS\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FunctionId    - TODO: add argument description\r
+  ClassGuid     - TODO: add argument description\r
+  Function      - TODO: add argument description\r
+  ModuleGlobal  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+RegisterEsalClass (\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  VOID                                      *ModuleGlobal,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ClassGuid     - TODO: add argument description\r
+  ModuleGlobal  - TODO: add argument description\r
+  ...           - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  MP Class Functions\r
+//\r
+SAL_RETURN_REGS\r
+LibMpAddCpuData (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     Enabled,\r
+  IN    UINT64      PalCompatability\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId       - TODO: add argument description\r
+  Enabled           - TODO: add argument description\r
+  PalCompatability  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpRemoveCpuData (\r
+  IN    UINT64      CpuGlobalId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpModifyCpuData (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     Enabled,\r
+  IN    UINT64      PalCompatability\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId       - TODO: add argument description\r
+  Enabled           - TODO: add argument description\r
+  PalCompatability  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpGetCpuDataByID (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId       - TODO: add argument description\r
+  IndexByEnabledCpu - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpGetCpuDataByIndex (\r
+  IN    UINT64      Index,\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Index             - TODO: add argument description\r
+  IndexByEnabledCpu - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpSendIpi (\r
+  IN  UINT64                ProcessorNumber,\r
+  IN  UINT64                VectorNumber,\r
+  IN  EFI_DELIVERY_MODE     DeliveryMode,\r
+  IN  BOOLEAN               IRFlag\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ProcessorNumber - TODO: add argument description\r
+  VectorNumber    - TODO: add argument description\r
+  DeliveryMode    - TODO: add argument description\r
+  IRFlag          - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpCurrentProcessor (\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  IndexByEnabledCpu - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibGetNumProcessors (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpSaveMinStatePointer (\r
+  IN    UINT64                CpuGlobalId,\r
+  IN    EFI_PHYSICAL_ADDRESS  MinStatePointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId     - TODO: add argument description\r
+  MinStatePointer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpRestoreMinStatePointer (\r
+  IN    UINT64                CpuGlobalId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuGlobalId - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  MCA Class Functions\r
+//\r
+\r
+EFI_STATUS\r
+LibMcaGetStateInfo (\r
+  IN  UINT64                                      CpuId,\r
+  OUT EFI_PHYSICAL_ADDRESS                        *StateBufferPointer,\r
+  OUT UINT64                                      *RequiredStateBufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuId                   - TODO: add argument description\r
+  StateBufferPointer      - TODO: add argument description\r
+  RequiredStateBufferSize - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibMcaRegisterCpu (\r
+  IN  UINT64                                      CpuId,\r
+  IN  EFI_PHYSICAL_ADDRESS                        StateBufferAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  CpuId               - TODO: add argument description\r
+  StateBufferAddress  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// FVB Variables Class\r
+//\r
+EFI_STATUS\r
+EsalReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance  - TODO: add argument description\r
+  Lba       - TODO: add argument description\r
+  Offset    - TODO: add argument description\r
+  NumBytes  - TODO: add argument description\r
+  Buffer    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance  - TODO: add argument description\r
+  Lba       - TODO: add argument description\r
+  Offset    - TODO: add argument description\r
+  NumBytes  - TODO: add argument description\r
+  Buffer    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN UINTN                                Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance  - TODO: add argument description\r
+  Lba       - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance    - TODO: add argument description\r
+  Attributes  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN EFI_FVB_ATTRIBUTES                   Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance    - TODO: add argument description\r
+  Attributes  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance  - TODO: add argument description\r
+  Address   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EsalGetBlockSize (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  OUT UINTN                               *BlockSize,\r
+  OUT UINTN                               *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Instance    - TODO: add argument description\r
+  Lba         - TODO: add argument description\r
+  BlockSize   - TODO: add argument description\r
+  NumOfBlocks - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// SAL ELOG Functions\r
+//\r
+EFI_STATUS\r
+LibSalGetStateInfo (\r
+  IN  UINT64                                      McaType,\r
+  IN  UINT8                                       *McaBuffer,\r
+  OUT UINTN                                       *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  McaType   - TODO: add argument description\r
+  McaBuffer - TODO: add argument description\r
+  Size      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibSalGetStateInfoSize (\r
+  IN  UINT64                                      McaType,\r
+  OUT UINTN                                       *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  McaType - TODO: add argument description\r
+  Size    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibSalClearStateInfo (\r
+  IN  UINT64                                      McaType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  McaType - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibEsalGetStateBuffer (\r
+  IN  UINT64                                      McaType,\r
+  OUT UINT8                                       **McaBuffer,\r
+  OUT UINTN                                       *Index\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  McaType   - TODO: add argument description\r
+  McaBuffer - TODO: add argument description\r
+  Index     - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibEsalSaveStateBuffer (\r
+  IN  UINT64                                      McaType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  McaType - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h
new file mode 100644 (file)
index 0000000..a882044
--- /dev/null
@@ -0,0 +1,119 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ProcDep.h\r
+\r
+Abstract:\r
+\r
+  IPF specific Runtime Lib code. IPF has a SAL API that does not\r
+  exit on IA-32. Thus\r
+\r
+--*/\r
+\r
+#ifndef _PROC_DEP_H_\r
+#define _PROC_DEP_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+#include "SalApi.h"\r
+\r
+EFI_STATUS\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class Function and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  FunctionId    - ID of function to register\r
+  ClassGuid     - GUID of function class \r
+  Function      - Function to register under ClassGuid/FunctionId pair\r
+  ModuleGlobal  - Module global for Function.\r
+\r
+Returns: \r
+  EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+RegisterEsalClass (\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  VOID                                      *ModuleGlobal,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  ClassGuid     - GUID of function class \r
+  ModuleGlobal  - Module global for Function.\r
+  ..            - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r
+                  indicates the end of the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS - All members of ClassGuid registered\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EfiCallEsalService (\r
+  IN  EFI_GUID                                      *ClassGuid,\r
+  IN  UINT64                                        FunctionId,\r
+  IN  UINT64                                        Arg2,\r
+  IN  UINT64                                        Arg3,\r
+  IN  UINT64                                        Arg4,\r
+  IN  UINT64                                        Arg5,\r
+  IN  UINT64                                        Arg6,\r
+  IN  UINT64                                        Arg7,\r
+  IN  UINT64                                        Arg8\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call module that is not linked direclty to this module. This code is IP \r
+  relative and hides the binding issues of virtual or physical calling. The\r
+  function that gets dispatched has extra arguments that include the registered\r
+  module global and a boolean flag to indicate if the system is in virutal mode.\r
+\r
+Arguments:\r
+  ClassGuid   - GUID of function\r
+  FunctionId  - Function in ClassGuid to call\r
+  Arg2        - Argument 2 ClassGuid/FunctionId defined\r
+  Arg3        - Argument 3 ClassGuid/FunctionId defined\r
+  Arg4        - Argument 4 ClassGuid/FunctionId defined\r
+  Arg5        - Argument 5 ClassGuid/FunctionId defined\r
+  Arg6        - Argument 6 ClassGuid/FunctionId defined\r
+  Arg7        - Argument 7 ClassGuid/FunctionId defined\r
+  Arg8        - Argument 8 ClassGuid/FunctionId defined\r
+\r
+Returns: \r
+  Status of ClassGuid/FuncitonId\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h
new file mode 100644 (file)
index 0000000..473cbfb
--- /dev/null
@@ -0,0 +1,1454 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SalDriverLib.h\r
+  \r
+Abstract:\r
+\r
+  SAL Driver Lib\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _SAL_DRIVER_LIB_H_\r
+#define _SAL_DRIVER_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "SalApi.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+\r
+//\r
+//  Assembly Functions\r
+//\r
+SAL_RETURN_REGS\r
+LibGetEsalPhyData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get Esal global data in physical mode.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibGetEsalVirtData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get Esal global data in virtual mode.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibSetEsalPhyData (\r
+  IN  VOID                        *Ptr,\r
+  IN  UINT64                      GP\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Esal global data in physical mode.\r
+\r
+Arguments:\r
+\r
+  Ptr            - Pointer to the data\r
+  GP             - Global pointer\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibSetEsalVirtData (\r
+  IN  VOID                        *Ptr,\r
+  IN  UINT64                      GP\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Esal global data in virtual mode.\r
+\r
+Arguments:\r
+\r
+  Ptr            - Pointer to the data\r
+  GP             - Global pointer\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibGetGlobalPhyData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get Esal global data in physical mode.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibGetGlobalVirtData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get Esal global data in virtual mode.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibSetGlobalPhyData (\r
+  IN  VOID                        *Ptr,\r
+  IN  UINT64                      GP\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Esal global data in physical mode.\r
+\r
+Arguments:\r
+\r
+  Ptr            - Pointer to the data\r
+  GP             - Global pointer\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibSetGlobalVirtData (\r
+  IN  VOID                        *Ptr,\r
+  IN  UINT64                      GP\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Esal global data in virtual mode.\r
+\r
+Arguments:\r
+\r
+  Ptr            - Pointer to the data\r
+  GP             - Global pointer\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetIrrData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get interrupt request register.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PrepareApsForHandOverToOS (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Prepare AP info for hand over to OS.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+HandOverApsToOS (\r
+  IN UINT64  a1,\r
+  IN UINT64  a2,\r
+  IN UINT64  a3\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Hand over AP info to OS.\r
+\r
+Arguments:\r
+\r
+  a1    - Address to call into\r
+  \r
+  a2    - GP\r
+  \r
+  a3    - Undefined\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetPsrData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PSR register.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs.\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+GetProcIdData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get LID\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+SwitchCpuStack (\r
+  IN  UINT64  NewBsp,\r
+  IN  UINT64  OldBsp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Switch BSP\r
+\r
+Arguments:\r
+\r
+  NewBsp    - New BSP index\r
+  OldBsp    - Old BSP index\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  SAL Reset Class\r
+//\r
+VOID\r
+SalResetSystem (\r
+  IN EFI_RESET_TYPE                ResetType,\r
+  IN EFI_STATUS                    ResetStatus,\r
+  IN UINTN                         DataSize,\r
+  IN CHAR16                        *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reset system\r
+\r
+Arguments:\r
+\r
+  ResetType     - Reset type\r
+  ResetStatus   - Reset status\r
+  DataSize      - Size of ResetData\r
+  ResetData     - Description string\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  PAL PROC Class\r
+//\r
+SAL_RETURN_REGS\r
+SalPalProc (\r
+  IN  UINT64            Arg1,\r
+  IN  UINT64            Arg2,\r
+  IN  UINT64            Arg3,\r
+  IN  UINT64            Arg4\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call pal proc.\r
+\r
+Arguments:\r
+\r
+  Arg1          - Pal call index\r
+  Arg2          - First arg\r
+  Arg3          - Second arg\r
+  Arg4          - Third arg\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalRegisterNewPalEntry (\r
+  IN  BOOLEAN                     PhysicalPalAddress,\r
+  IN  EFI_PHYSICAL_ADDRESS        NewPalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register Pal entry.\r
+\r
+Arguments:\r
+\r
+  PhysicalPalAddress      - The address is physical or virtual\r
+  NewPalAddress           - New Pal entry address\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalGetPalEntryPointer (\r
+  IN  BOOLEAN                     PhysicalPalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get Pal entry.\r
+\r
+Arguments:\r
+\r
+  PhysicalPalAddress      - The address is physical or virtual\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  SAL MTC Class\r
+//\r
+EFI_STATUS\r
+SalGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get next high 32 bits of monotonic count.\r
+\r
+Arguments:\r
+\r
+  HighCount     - High 32 bits of monotonic count.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  SAL BASE Class\r
+//\r
+SAL_RETURN_REGS\r
+SalProcSetVectors (\r
+  IN  UINT64                      SalVectorType,\r
+  IN  UINT64                      PhyAddr1,\r
+  IN  UINT64                      Gp1,\r
+  IN  UINT64                      LengthCs1,\r
+  IN  UINT64                      PhyAddr2,\r
+  IN  UINT64                      Gp2,\r
+  IN  UINT64                      LengthCs2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set vectors.\r
+\r
+Arguments:\r
+\r
+  SalVectorType     - Vector type\r
+  PhyAddr1          - OS MCA entry point\r
+  Gp1               - GP for OS MCA entry\r
+  LengthCs1         - Length of OS MCA \r
+  PhyAddr2          - OS INIT entry point\r
+  Gp2               - GP for OS Init entry\r
+  LengthCs2         - Length of OS INIT\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalProcMcRendez (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Mc rendezvous function.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalProcMcSetParams (\r
+  IN  UINT64                      ParamType,\r
+  IN  UINT64                      IntOrMem,\r
+  IN  UINT64                      IntOrMemVal,\r
+  IN  UINT64                      Timeout,\r
+  IN  UINT64                      McaOpt\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set MCA parameters.\r
+\r
+Arguments:\r
+\r
+  ParamType     - Parameter type\r
+  IntOrMem      - Interrupt or memory address\r
+  IntOrMemVal   - Interrupt number or memory address value\r
+  Timeout       - Time out value\r
+  McaOpt        - Option for MCA\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcGetVectors (\r
+  IN  UINT64                      VectorType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get OS MCA vector.\r
+\r
+Arguments:\r
+\r
+  VectorType      - Vector type\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcMcGetParams (\r
+  IN  UINT64                      ParamInfoType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get MCA parameter.\r
+\r
+Arguments:\r
+\r
+  ParamInfoType     - Parameter info type\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcMcGetMcParams (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get MCA parameter.\r
+\r
+Arguments:\r
+\r
+  \r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EsalProcGetMcCheckinFlags (\r
+  IN  UINT64                      ProcessorUnit\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get process status.\r
+\r
+Arguments:\r
+\r
+  ProcessorUnit     - Processor Index\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Sal Base Class enums\r
+//\r
+typedef enum {\r
+  McaVector,\r
+  BspInitVector,\r
+  BootRendezVector,\r
+  ApInitVector\r
+} ESAL_GET_VECTOR_TYPE;\r
+\r
+//\r
+//  Sal RTC Class\r
+//\r
+EFI_STATUS\r
+SalGetTime (\r
+  OUT EFI_TIME                     *Time,\r
+  OUT EFI_TIME_CAPABILITIES        *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device¡¯s\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SalSetTime (\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SalGetWakeupTime (\r
+  OUT BOOLEAN                      *Enabled,\r
+  OUT BOOLEAN                      *Pending,\r
+  OUT EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SalSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalInitializeThreshold (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Init threshold structure.\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct     - Threshold structure\r
+  Count               - Threshold count\r
+  Duration            - Duration\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalBumpThresholdCount (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Bump threshold count.\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct     - Threshold structure\r
+  Count               - Threshold count\r
+  Duration            - Duration\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalGetThresholdCount (\r
+  IN  VOID                        *ThresholdStruct,\r
+  IN  UINT64                      Count,\r
+  IN  UINT64                      Duration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get threshold structure.\r
+\r
+Arguments:\r
+\r
+  ThresholdStruct     - Threshold structure\r
+  Count               - Threshold count\r
+  Duration            - Duration\r
+\r
+Returns:\r
+\r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Common Lib Function\r
+//\r
+EFI_STATUS\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class Function and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  FunctionId    - ID of function to register\r
+  ClassGuid     - GUID of function class \r
+  Function      - Function to register under ClassGuid/FunctionId pair\r
+  ModuleGlobal  - Module global for Function.\r
+\r
+Returns: \r
+  EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EfiInitializeSalDriverLib (\r
+  IN  BOOLEAN   Runtime\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize Sal driver lib.\r
+\r
+Arguments:\r
+  Runtime     - At runtime or not?\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// MCA PMI INIT Registeration Functions.\r
+//\r
+EFI_STATUS\r
+LibRegisterMcaFunction (\r
+  IN  EFI_SAL_MCA_HANDLER                   McaHandler,\r
+  IN  VOID                                  *ModuleGlobal,\r
+  IN  BOOLEAN                               MakeFirst,\r
+  IN  BOOLEAN                               MakeLast\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register MCA handler.\r
+\r
+Arguments:\r
+  McaHandler      - MCA handler\r
+  ModuleGlobal    - Module global for function\r
+  MakeFirst       - Make it as first?\r
+  MakeLast        - Make it as last?\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibRegisterPmiFunction (\r
+  IN  EFI_SAL_PMI_HANDLER                   PmiHandler,\r
+  IN  VOID                                  *ModuleGlobal,\r
+  IN  BOOLEAN                               MakeFirst,\r
+  IN  BOOLEAN                               MakeLast\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register PMI handler.\r
+\r
+Arguments:\r
+  PmiHandler      - PMI handler\r
+  ModuleGlobal    - Module global for function\r
+  MakeFirst       - Make it as first?\r
+  MakeLast        - Make it as last?\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibRegisterInitFunction (\r
+  IN  EFI_SAL_INIT_HANDLER                  InitHandler,\r
+  IN  VOID                                  *ModuleGlobal,\r
+  IN  BOOLEAN                               MakeFirst,\r
+  IN  BOOLEAN                               MakeLast\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register INIT handler.\r
+\r
+Arguments:\r
+  InitHandler     - INIT handler\r
+  ModuleGlobal    - Module global for function\r
+  MakeFirst       - Make it as first?\r
+  MakeLast        - Make it as last?\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  Base IO Class Functions\r
+//\r
+EFI_STATUS\r
+ESalIoRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io read operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of read operation\r
+  Address - Start IO address to read\r
+  Count   - Read count\r
+  Buffer  - Buffer to store result\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ESalIoWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io write operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of write operation\r
+  Address - Start IO address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ESalMemRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN     UINT64                      Address,\r
+  IN     UINTN                       Count,\r
+  IN  OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a Memory mapped IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of each read transaction.\r
+  Address - Memory mapped IO address to read\r
+  Count   - Number of Width quanta to read\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ESalMemWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN     UINT64                      Address,\r
+  IN     UINTN                       Count,\r
+  IN OUT VOID                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a memory mapped IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  PCI Class Functions\r
+//\r
+SAL_RETURN_REGS\r
+SalPCIConfigRead (\r
+  IN  UINT64              Address,\r
+  IN  UINT64              Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Pci config space read.\r
+\r
+Arguments:\r
+  Address - PCI address to read\r
+  Size    - Size to read\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+SalPCIConfigWrite (\r
+  IN  UINT64              Address,\r
+  IN  UINT64              Size,\r
+  IN  UINT64              Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Pci config space write.\r
+\r
+Arguments:\r
+  Address - PCI address to write\r
+  Size    - Size to write\r
+  Value   - Value to write\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  MP Class Functions\r
+//\r
+SAL_RETURN_REGS\r
+LibMPAddCpuData (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     Enabled,\r
+  IN    UINT64      PalCompatability\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Add CPU data.\r
+\r
+Arguments:\r
+  CpuGlobalId         - CPU ID\r
+  Enabled             - Enabled or not\r
+  PalCompatability    - Pal compatability\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMPRemoveCpuData (\r
+  IN    UINT64      CpuGlobalId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Remove CPU data.\r
+\r
+Arguments:\r
+  CpuGlobalId         - CPU ID\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMPModifyCpuData (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     Enabled,\r
+  IN    UINT64      PalCompatability\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modify CPU data.\r
+\r
+Arguments:\r
+  CpuGlobalId         - CPU ID\r
+  Enabled             - Enabled or not\r
+  PalCompatability    - Pal compatability\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMPGetCpuDataByID (\r
+  IN    UINT64      CpuGlobalId,\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get CPU data.\r
+\r
+Arguments:\r
+  CpuGlobalId         - CPU ID\r
+  IndexByEnabledCpu   - Whether indexed by enabled CPU\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMPGetCpuDataByIndex (\r
+  IN    UINT64      Index,\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get CPU data.\r
+\r
+Arguments:\r
+  Index               - CPU index\r
+  IndexByEnabledCpu   - Whether indexed by enabled CPU\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMPSendIpi (\r
+  IN  UINT64                ProcessorNumber,\r
+  IN  UINT64                VectorNumber,\r
+  IN  EFI_DELIVERY_MODE     DeliveryMode,\r
+  IN  BOOLEAN               IRFlag\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Send IPI.\r
+\r
+Arguments:\r
+  ProcessorNumber         - Processor number\r
+  VectorNumber            - Vector number\r
+  DeliveryMode            - Delivery mode\r
+  IRFlag                  - Interrupt Redirection flag\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpCurrentProcessor (\r
+  IN    BOOLEAN     IndexByEnabledCpu\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get current processor index.\r
+\r
+Arguments:\r
+  IndexByEnabledCpu       - Whether indexed by enabled CPU\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibGetNumProcessors (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get number of processors.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpSaveMinStatePointer (\r
+  IN    UINT64                CpuGlobalId,\r
+  IN    EFI_PHYSICAL_ADDRESS  MinStatePointer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Register pointer to save min state.\r
+\r
+Arguments:\r
+  CpuGlobalId       - CPU global ID\r
+  MinStatePointer   - Pointer to save min state\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+LibMpRestoreMinStatePointer (\r
+  IN    UINT64                CpuGlobalId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Restore pointer to save min state.\r
+\r
+Arguments:\r
+  CpuGlobalId       - CPU global ID\r
+\r
+Returns: \r
+  Output regs\r
+\r
+--*/\r
+;\r
+\r
+//\r
+//  MCA Class Functions\r
+//\r
+EFI_STATUS\r
+LibMcaGetStateInfo (\r
+  IN  UINT64                                      CpuId,\r
+  OUT EFI_PHYSICAL_ADDRESS                        *StateBufferPointer,\r
+  OUT UINT64                                      *RequiredStateBufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  MCA get state info.\r
+\r
+Arguments:\r
+  CpuId                   - CPU ID\r
+  StateBufferPointer      - Pointer of state buffer\r
+  RequiredStateBufferSize - Size of required state buffer\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibMcaRegisterCpu (\r
+  IN  UINT64                                      CpuId,\r
+  IN  EFI_PHYSICAL_ADDRESS                        StateBufferAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  MCA register CPU state info.\r
+\r
+Arguments:\r
+  CpuId                   - CPU ID\r
+  StateBufferAddress      - Pointer of state buffer\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// SAL ELOG Functions\r
+//\r
+EFI_STATUS\r
+LibSalGetStateInfo (\r
+  IN  UINT64                                      McaType,\r
+  IN  UINT8                                       *McaBuffer,\r
+  OUT UINTN                                       *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get state info.\r
+\r
+Arguments:\r
+  McaType                 - MCA type\r
+  McaBuffer               - Info buffer provided by caller\r
+  Size                    - Size of info\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibSalGetStateInfoSize (\r
+  IN  UINT64                                      McaType,\r
+  OUT UINTN                                       *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get state info size.\r
+\r
+Arguments:\r
+  McaType                   - MCA type\r
+  Size                      - Size required\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibSalClearStateInfo (\r
+  IN  UINT64                                      McaType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Clear state info.\r
+\r
+Arguments:\r
+  McaType                   - MCA type\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibEsalGetStateBuffer (\r
+  IN  UINT64                                      McaType,\r
+  OUT UINT8                                       **McaBuffer,\r
+  OUT UINTN                                       *Index\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get state buffer.\r
+\r
+Arguments:\r
+  McaType                   - MCA type\r
+  McaBuffer                 - MCA buffer\r
+  Index                     - CPU index\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibEsalSaveStateBuffer (\r
+  IN  UINT64                                      McaType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Save state buffer.\r
+\r
+Arguments:\r
+  McaType                   - MCA type\r
+\r
+Returns: \r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h
new file mode 100644 (file)
index 0000000..4293820
--- /dev/null
@@ -0,0 +1,310 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LinkedList.h\r
+\r
+Abstract:\r
+\r
+  This implementation of a linked list provides data structures for the\r
+  list itself and for list nodes.  It provides operations for initializing\r
+  the list, modifying the list, and walking the list.  \r
+  \r
+--*/\r
+\r
+//\r
+// Prevent multiple includes in the same source file\r
+//\r
+#ifndef _LINKED_LIST_H_\r
+#define _LINKED_LIST_H_\r
+\r
+\r
+typedef struct _EFI_LIST_ENTRY {\r
+  struct _EFI_LIST_ENTRY  *ForwardLink;\r
+  struct _EFI_LIST_ENTRY  *BackLink;\r
+} EFI_LIST_ENTRY;\r
+\r
+typedef EFI_LIST_ENTRY EFI_LIST;      \r
+typedef EFI_LIST_ENTRY EFI_LIST_NODE;\r
+\r
+#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&ListHead, &ListHead}\r
+\r
+//\r
+//  EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
+//\r
+   \r
+#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
+\r
+//\r
+// A lock structure\r
+//\r
+\r
+typedef struct {\r
+    EFI_TPL     Tpl;\r
+    EFI_TPL     OwnerTpl;\r
+    UINTN       Lock;\r
+} FLOCK;\r
+\r
+VOID\r
+InitializeListHead (\r
+  EFI_LIST_ENTRY       *List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the head of the List.  The caller must allocate the memory \r
+  for the EFI_LIST. This function must be called before the other linked\r
+  list macros can be used.\r
+    \r
+Arguments:\r
+\r
+  List - Pointer to list head to initialize\r
+   \r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+IsListEmpty (\r
+  EFI_LIST_ENTRY  *List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
+  The list must have been initialized with InitializeListHead () before using \r
+  this function.\r
+    \r
+Arguments:\r
+\r
+  List - Pointer to list head to test\r
+\r
+   \r
+Returns:\r
+\r
+  Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+RemoveEntryList (\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Remove Node from the doubly linked list. It is the caller's responsibility\r
+  to free any memory used by the entry if needed. The list must have been \r
+  initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  Entry - Element to remove from the list.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+InsertTailList (\r
+  EFI_LIST_ENTRY  *ListHead,\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert a Node into the end of a doubly linked list. The list must have \r
+  been initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  ListHead - Head of doubly linked list\r
+\r
+  Entry    - Element to insert at the end of the list.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+InsertHeadList (\r
+  EFI_LIST_ENTRY  *ListHead,\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert a Node into the start of a doubly linked list. The list must have \r
+  been initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  ListHead - Head of doubly linked list\r
+\r
+  Entry    - Element to insert to beginning of list\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+SwapListEntries (\r
+  EFI_LIST_ENTRY  *Entry1,\r
+  EFI_LIST_ENTRY  *Entry2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Swap the location of the two elements of a doubly linked list. Node2 \r
+  is placed in front of Node1. The list must have been initialized with \r
+  InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  Entry1 - Element in the doubly linked list in front of Node2. \r
+\r
+  Entry2 - Element in the doubly linked list behind Node1.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_LIST_ENTRY *\r
+GetFirstNode (\r
+  EFI_LIST_ENTRY  *List \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the first node pointed to by the list head.  The list must \r
+  have been initialized with InitializeListHead () before using this \r
+  function and must contain data.\r
+    \r
+Arguments:\r
+\r
+  List - The head of the doubly linked list.\r
+   \r
+Returns:\r
+  \r
+  Pointer to the first node, if the list contains nodes.  The list will\r
+  return a null value--that is, the value of List--when the list is empty.\r
+    See the description of IsNull for more information.\r
+\r
+\r
+--*/\r
+;\r
+\r
+EFI_LIST_ENTRY *\r
+GetNextNode (\r
+  EFI_LIST_ENTRY  *List,\r
+  EFI_LIST_ENTRY  *Node\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the node following Node in the list. The list must \r
+  have been initialized with InitializeListHead () before using this \r
+  function and must contain data.\r
+    \r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node in the list.  This value MUST NOT be the literal value NULL.\r
+    See the description of IsNull for more information.\r
+   \r
+Returns:\r
+  \r
+  Pointer to the next node, if one exists.  Otherwise, returns a null value,\r
+  which is actually a pointer to List.\r
+    See the description of IsNull for more information.\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN \r
+IsNull ( \r
+  EFI_LIST_ENTRY  *List,\r
+  EFI_LIST_ENTRY  *Node \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines whether the given node is null.  Note that Node is null\r
+  when its value is equal to the value of List.  It is an error for\r
+  Node to be the literal value NULL [(VOID*)0x0].\r
+\r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node to test.  MUST NOT be the literal value NULL.  See\r
+    the description above.\r
+   \r
+Returns:\r
+  \r
+  Returns true if the node is null.\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN \r
+IsNodeAtEnd ( \r
+  EFI_LIST_ENTRY  *List, \r
+  EFI_LIST_ENTRY  *Node \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines whether the given node is at the end of the list.  Used\r
+  to walk the list.  The list must have been initialized with \r
+  InitializeListHead () before using this function and must contain \r
+  data.\r
+\r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node to test.  MUST NOT be the literal value NULL.\r
+    See the description of IsNull for more information.\r
+   \r
+Returns:\r
+  \r
+  Returns true if the list is the tail.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h
new file mode 100644 (file)
index 0000000..7c00bd5
--- /dev/null
@@ -0,0 +1,231 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RtDevicePath.h\r
+\r
+Abstract:\r
+\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+--*/\r
+#ifndef _RT_DEVICE_PATH_H_\r
+#define _RT_DEVICE_PATH_H_\r
+\r
+BOOLEAN\r
+RtEfiIsDevicePathMultiInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE is this is a multi instance device path.\r
+\r
+Arguments:\r
+  DevicePath  - A pointer to a device path data structure.\r
+\r
+\r
+Returns:\r
+  TRUE - If DevicePath is multi instance. \r
+  FALSE - If DevicePath is not multi instance.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
+  OUT UINTN                         *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function retrieves the next device path instance from a device path data structure.\r
+\r
+Arguments:\r
+  DevicePath           - A pointer to a device path data structure.\r
+\r
+  Size                 - A pointer to the size of a device path instance in bytes.\r
+\r
+Returns:\r
+\r
+  This function returns a pointer to the current device path instance.\r
+  In addition, it returns the size in bytes of the current device path instance in Size,\r
+  and a pointer to the next device path instance in DevicePath.\r
+  If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+RtEfiDevicePathSize (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculate the size of a whole device path.    \r
+    \r
+Arguments:\r
+\r
+  DevPath - The pointer to the device path data.\r
+    \r
+Returns:\r
+\r
+  Size of device path data structure..\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiAppendDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a Src1 and Src2 together.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  A pointer to the new device path is returned.\r
+  NULL is returned if space for the new device path could not be allocated from pool.\r
+  It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiDevicePathFromHandle (\r
+  IN EFI_HANDLE       Handle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Locate device path protocol interface on a device handle.\r
+\r
+Arguments:\r
+\r
+  Handle  - The device handle\r
+\r
+Returns:\r
+\r
+  Device path protocol interface located.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiDuplicateDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Duplicate a new device path data structure from the old one.\r
+\r
+Arguments:\r
+  DevPath  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  A pointer to the new allocated device path data.\r
+  Caller must free the memory used by DevicePath if it is no longer needed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiAppendDevicePathNode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a device path node to the end of another device path.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2 - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  This function returns a pointer to the new device path.\r
+  If there is not enough temporary pool memory available to complete this function,\r
+  then NULL is returned.\r
+\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiFileDevicePath (\r
+  IN EFI_HANDLE               Device  OPTIONAL,\r
+  IN CHAR16                   *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a device path that appends a MEDIA_DEVICE_PATH with\r
+  FileNameGuid to the device path of DeviceHandle.\r
+\r
+Arguments:\r
+  Device   - Optional Device Handle to use as Root of the Device Path\r
+\r
+  FileName - FileName\r
+\r
+Returns:\r
+  EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory\r
+  or NULL pointer.\r
+\r
+--*/\r
+;\r
+\r
+EFI_DEVICE_PATH_PROTOCOL        *\r
+RtEfiAppendDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Append a device path instance to another.\r
+\r
+Arguments:\r
+\r
+  Src       - The device path instance to be appended with.\r
+  Instance  - The device path instance appending the other.\r
+\r
+Returns:\r
+\r
+  The contaction of these two.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h
new file mode 100644 (file)
index 0000000..6412a6b
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SmmRuntimeLib.h\r
+\r
+Abstract:\r
+\r
+  SMM Related prototypes that can be referenced for Preboot Configuration only.\r
+\r
+--*/\r
+\r
+#ifndef _SMM_RUNTIME_LIB_H_\r
+#define _SMM_RUNTIME_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+\r
+BOOLEAN\r
+EfiInSmm (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Test whether in Smm mode currently.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TRUE      - In Smm mode\r
+  FALSE     - Not in Smm mode\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+RegisterSmmRuntimeDriver (\r
+  IN EFI_HANDLE             ImageHandle,\r
+  IN EFI_SYSTEM_TABLE       *SystemTable,\r
+  OUT EFI_HANDLE            *SmmImageHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Registers a Driver with the SMM.\r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+  SmmImageHandle  - Image handle returned by the SMM driver.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h
new file mode 100644 (file)
index 0000000..f3b9e41
--- /dev/null
@@ -0,0 +1,262 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuFuncs.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _CPU_FUNCS_H_\r
+#define _CPU_FUNCS_H_\r
+\r
+#define EFI_CPUID_SIGNATURE         0x0\r
+#define EFI_CPUID_VERSION_INFO      0x1\r
+#define EFI_CPUID_CACHE_INFO        0x2\r
+#define EFI_CPUID_SERIAL_NUMBER     0x3\r
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000\r
+#define EFI_CPUID_EXTENDED_CPU_SIG  0x80000001\r
+#define EFI_CPUID_BRAND_STRING1     0x80000002\r
+#define EFI_CPUID_BRAND_STRING2     0x80000003\r
+#define EFI_CPUID_BRAND_STRING3     0x80000004\r
+\r
+//\r
+// CPUID version information masks\r
+// Note: leaving masks here is for the compatibility\r
+//       use EfiCpuVersion (...) instead\r
+//\r
+\r
+#define EFI_CPUID_FAMILY                      0x0F00\r
+#define EFI_CPUID_MODEL                       0x00F0\r
+#define EFI_CPUID_STEPPING                    0x000F\r
+\r
+#define EFI_CPUID_PENTIUM_M                   0x0600\r
+#define EFI_CPUID_BANIAS                      0x0090\r
+#define EFI_CPUID_DOTHAN                      0x00D0\r
+#define EFI_CPUID_NETBURST                    0x0F00\r
+\r
+#define EFI_MSR_IA32_PLATFORM_ID              0x17\r
+#define EFI_MSR_IA32_APIC_BASE                0x1B\r
+#define EFI_MSR_EBC_HARD_POWERON              0x2A\r
+#define EFI_MSR_EBC_SOFT_POWERON              0x2B\r
+#define BINIT_DRIVER_DISABLE                  0x40\r
+#define INTERNAL_MCERR_DISABLE                0x20\r
+#define INITIATOR_MCERR_DISABLE               0x10\r
+#define EFI_MSR_EBC_FREQUENCY_ID              0x2C\r
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG           0x79\r
+#define EFI_MSR_IA32_BIOS_SIGN_ID             0x8B\r
+#define EFI_MSR_PSB_CLOCK_STATUS              0xCD\r
+#define EFI_APIC_GLOBAL_ENABLE                0x800\r
+#define EFI_MSR_IA32_MISC_ENABLE              0x1A0\r
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT         0x00400000\r
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT  0x00000008\r
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT      0x00000004\r
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002\r
+#define FAST_STRING_ENABLE_BIT                0x00000001\r
+\r
+#define EFI_CACHE_VARIABLE_MTRR_BASE          0x200\r
+#define EFI_CACHE_VARIABLE_MTRR_END           0x20F\r
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE          0x2FF\r
+#define EFI_CACHE_VALID_ADDRESS               0xFFFFFF000\r
+#define EFI_CACHE_MTRR_VALID                  0x800\r
+#define EFI_CACHE_FIXED_MTRR_VALID            0x400\r
+#define EFI_MSR_VALID_MASK                    0xFFFFFFFFF\r
+\r
+#define EFI_IA32_MTRR_FIX64K_00000            0x250\r
+#define EFI_IA32_MTRR_FIX16K_80000            0x258\r
+#define EFI_IA32_MTRR_FIX16K_A0000            0x259\r
+#define EFI_IA32_MTRR_FIX4K_C0000             0x268\r
+#define EFI_IA32_MTRR_FIX4K_C8000             0x269\r
+#define EFI_IA32_MTRR_FIX4K_D0000             0x26A\r
+#define EFI_IA32_MTRR_FIX4K_D8000             0x26B\r
+#define EFI_IA32_MTRR_FIX4K_E0000             0x26C\r
+#define EFI_IA32_MTRR_FIX4K_E8000             0x26D\r
+#define EFI_IA32_MTRR_FIX4K_F0000             0x26E\r
+#define EFI_IA32_MTRR_FIX4K_F8000             0x26F\r
+\r
+#define EFI_IA32_MCG_CAP                      0x179\r
+#define EFI_IA32_MCG_CTL                      0x17B\r
+#define EFI_IA32_MC0_CTL                      0x400\r
+#define EFI_IA32_MC0_STATUS                   0x401\r
+\r
+#define EFI_CACHE_UNCACHEABLE                 0\r
+#define EFI_CACHE_WRITECOMBINING              1\r
+#define EFI_CACHE_WRITETHROUGH                4\r
+#define EFI_CACHE_WRITEPROTECTED              5\r
+#define EFI_CACHE_WRITEBACK                   6\r
+\r
+//\r
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number\r
+//\r
+#define EfiMakeCpuVersion(f, m, s)         \\r
+  (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))\r
+\r
+\r
+typedef struct {\r
+  UINT32  HeaderVersion;\r
+  UINT32  UpdateRevision;\r
+  UINT32  Date;\r
+  UINT32  ProcessorId;\r
+  UINT32  Checksum;\r
+  UINT32  LoaderRevision;\r
+  UINT32  ProcessorFlags;\r
+  UINT32  DataSize;\r
+  UINT32  TotalSize;\r
+  UINT8   Reserved[12];\r
+} EFI_CPU_MICROCODE_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  ExtSigCount;\r
+  UINT32  ExtChecksum;\r
+  UINT8   Reserved[12];\r
+  UINT32  ProcessorId;\r
+  UINT32  ProcessorFlags;\r
+  UINT32  Checksum;\r
+} EFI_CPU_MICROCODE_EXT_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  RegEax;\r
+  UINT32  RegEbx;\r
+  UINT32  RegEcx;\r
+  UINT32  RegEdx;\r
+} EFI_CPUID_REGISTER;\r
+\r
+VOID\r
+EfiWriteMsr (\r
+  IN  UINT32      Input,\r
+  IN  UINT64      Value\r
+  )\r
+/*++                               \r
+                                                                                           \r
+Routine Description:                                                \r
+\r
+  Write Cpu MSR\r
+  \r
+Arguments:                \r
+\r
+  Input  -The index value to select the register\r
+  Value  -The value to write to the selected register                      \r
+  \r
+Returns:                                                            \r
+\r
+   None                                                \r
+   \r
+--*/\r
+;\r
+\r
+UINT64\r
+EfiReadMsr (\r
+  IN  UINT32      Input\r
+  )\r
+/*++                                 \r
+                                                                                         \r
+Routine Description:                                                \r
+\r
+  Read Cpu MSR.\r
+  \r
+Arguments:                \r
+\r
+  Input: -The index value to select the register\r
+                       \r
+Returns:                                                            \r
+\r
+   Return the read data                                                \r
+   \r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCpuid (\r
+  IN  UINT32                    RegEax,\r
+  OUT EFI_CPUID_REGISTER        *Reg\r
+  )\r
+/*++                                      \r
+                                                                                    \r
+Routine Description:                                     \r
+           \r
+  Get the Cpu info by excute the CPUID instruction.\r
+  \r
+Arguments:                \r
+\r
+   RegEax  -The input value to put into register EAX\r
+   Reg     -The Output value                      \r
+   \r
+Returns:                         \r
+                                   \r
+   None                          \r
+                         \r
+--*/\r
+;\r
+\r
+VOID\r
+EfiCpuVersion (\r
+  IN   UINT16  *FamilyId,    OPTIONAL\r
+  IN   UINT8   *Model,       OPTIONAL\r
+  IN   UINT8   *SteppingId,  OPTIONAL\r
+  IN   UINT8   *Processor    OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract CPU detail version infomation\r
+\r
+Arguments:\r
+  FamilyId   - FamilyId, including ExtendedFamilyId\r
+  Model      - Model, including ExtendedModel\r
+  SteppingId - SteppingId\r
+  Processor  - Processor\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+EfiReadTsc (\r
+  VOID\r
+  )\r
+/*++                   \r
+                                                                                                       \r
+Routine Description:                                                \r
+\r
+  Read Time stamp.\r
+  \r
+Arguments:                \r
+\r
+  None                 \r
+  \r
+Returns:                                                            \r
+\r
+   Return the read data                                                \r
+   \r
+--*/\r
+;\r
+VOID\r
+EfiCpuidExt (\r
+  IN  UINT32                 RegisterInEax,\r
+  IN  UINT32                 CacheLevel,\r
+  OUT EFI_CPUID_REGISTER     *Regs\r
+  )\r
+/*++                                                                                                                          \r
+Routine Description:                                                \r
+  When RegisterInEax != 4, the functionality is the same as EfiCpuid.\r
+  When RegisterInEax == 4, the function return the deterministic cache\r
+  parameters by excuting the CPUID instruction\r
+Arguments:                \r
+   RegisterInEax: - The input value to put into register EAX\r
+   CacheLevel:      - The deterministic cache level\r
+   Regs:          - The Output value                      \r
+Returns:                                                            \r
+   None                                                \r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h
new file mode 100644 (file)
index 0000000..969ac02
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  ProcDep.h\r
+\r
+Abstract:\r
+\r
+  x64 specific Runtime Lib code. At this time there is non. \r
+  IPF has different code due to extra API requirements.\r
+\r
+--*/\r
+\r
+#ifndef _PROC_DEP_H_\r
+#define _PROC_DEP_H_\r
+\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h
new file mode 100644 (file)
index 0000000..65087c1
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Ascii\r
+  STRING_W is ""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR8 CHAR_W;\r
+#define STRING_W(_s)                                  _s\r
+\r
+#define ASPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define AvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         StrLen,\r
+  IN  CONST CHAR16  *Format,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  StrLen               - Maximum number of characters to put into buffer.\r
+  Format               - Format string\r
+  Marker               - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16      *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR16 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c
new file mode 100644 (file)
index 0000000..7c44ad5
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    AsciiFormat[Index] = (CHAR8) FormatString[Index];\r
+  }\r
+\r
+  AsciiFormat[Index]  = '\0';\r
+\r
+  Index               = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR16) AsciiResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c
new file mode 100644 (file)
index 0000000..bad5639
--- /dev/null
@@ -0,0 +1,212 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BoxDraw.c\r
+\r
+Abstract:\r
+  Lib functions to support Box Draw Unicode code pages.\r
+\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+\r
+\r
+typedef struct {\r
+  CHAR16  Unicode;\r
+  CHAR8   PcAnsi;\r
+  CHAR8   Ascii;\r
+} UNICODE_TO_CHAR;\r
+\r
+\r
+//\r
+// This list is used to define the valid extend chars.\r
+// It also provides a mapping from Unicode to PCANSI or\r
+// ASCII. The ASCII mapping we just made up.\r
+//\r
+//\r
+\r
+static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r
+  BOXDRAW_HORIZONTAL,                 0xc4, L'-', \r
+  BOXDRAW_VERTICAL,                   0xb3, L'|',\r
+  BOXDRAW_DOWN_RIGHT,                 0xda, L'/',\r
+  BOXDRAW_DOWN_LEFT,                  0xbf, L'\\',\r
+  BOXDRAW_UP_RIGHT,                   0xc0, L'\\',\r
+  BOXDRAW_UP_LEFT,                    0xd9, L'/',\r
+  BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|',\r
+  BOXDRAW_VERTICAL_LEFT,              0xb4, L'|',\r
+  BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+',\r
+  BOXDRAW_UP_HORIZONTAL,              0xc1, L'+',\r
+  BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+',\r
+  BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-',\r
+  BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|',\r
+  BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/',\r
+  BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/',\r
+  BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/',\r
+  BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\',\r
+  BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\',\r
+  BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\',\r
+  BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\',\r
+  BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\',\r
+  BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\',\r
+  BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/',\r
+  BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/',\r
+  BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/',\r
+  BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|',\r
+  BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|',\r
+  BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|',\r
+  BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|',\r
+  BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|',\r
+  BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|',\r
+  BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+',\r
+  BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+',\r
+  BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+',\r
+  BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+',\r
+  BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+',\r
+  BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+',\r
+  BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',\r
+  BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',\r
+  BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',\r
+\r
+  BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*',\r
+  BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+',\r
+\r
+  GEOMETRICSHAPE_UP_TRIANGLE,         0x1e, L'^',\r
+  GEOMETRICSHAPE_RIGHT_TRIANGLE,      0x10, L'>',\r
+  GEOMETRICSHAPE_DOWN_TRIANGLE,       0x1f, L'v',\r
+  GEOMETRICSHAPE_LEFT_TRIANGLE,       0x11, L'<',\r
+\r
+  ARROW_LEFT,                         0x3c, L'<',\r
+\r
+  ARROW_UP,                           0x18, L'^',\r
+\r
+  ARROW_RIGHT,                        0x3e, L'>',\r
+\r
+  ARROW_DOWN,                         0x19, L'v',\r
+  \r
+  0x0000, 0x00\r
+};\r
+\r
+\r
+BOOLEAN\r
+LibIsValidTextGraphics (\r
+  IN  CHAR16  Graphic,\r
+  OUT CHAR8   *PcAnsi,    OPTIONAL\r
+  OUT CHAR8   *Ascii      OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Detects if a Unicode char is for Box Drawing text graphics.\r
+\r
+Arguments:\r
+\r
+    Grphic  - Unicode char to test.\r
+\r
+    PcAnsi  - Optional pointer to return PCANSI equivalent of Graphic.\r
+\r
+    Asci    - Optional pointer to return Ascii equivalent of Graphic.\r
+\r
+Returns:\r
+\r
+    TRUE if Gpaphic is a supported Unicode Box Drawing character.\r
+\r
+--*/\r
+{\r
+  UNICODE_TO_CHAR     *Table;\r
+\r
+  if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r
+   \r
+    //\r
+    // Unicode drawing code charts are all in the 0x25xx range, \r
+    //  arrows are 0x21xx\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r
+    if (Graphic == Table->Unicode) {\r
+      if (PcAnsi != NULL) {\r
+        *PcAnsi = Table->PcAnsi; \r
+      }\r
+      if (Ascii != NULL) {\r
+        *Ascii = Table->Ascii;\r
+      }\r
+      return TRUE;\r
+    }\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+BOOLEAN\r
+IsValidAscii (\r
+  IN  CHAR16  Ascii\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Is it valid ascii char?  \r
+\r
+Arguments:\r
+\r
+  Ascii                 - The char to check\r
+\r
+Returns: \r
+\r
+  TRUE                  - Is a ascii char\r
+  FALSE                 - Not a ascii char\r
+\r
+--*/\r
+{\r
+  if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {\r
+    return TRUE;\r
+  }              \r
+  return FALSE;\r
+}\r
+\r
+\r
+BOOLEAN\r
+IsValidEfiCntlChar (\r
+  IN  CHAR16  CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Is it valid EFI control char?  \r
+\r
+Arguments:\r
+\r
+  Ascii                 - The char to check\r
+\r
+Returns: \r
+\r
+  TRUE                  - Is a valid EFI control char\r
+  FALSE                 - Not a valid EFI control char\r
+\r
+--*/\r
+{\r
+  if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) {\r
+    return TRUE;\r
+  }              \r
+  return FALSE;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c
new file mode 100644 (file)
index 0000000..d2bea32
--- /dev/null
@@ -0,0 +1,585 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+STATIC\r
+CHAR_W *\r
+GetFlagsAndWidth (\r
+  IN  CHAR_W      *Format, \r
+  OUT UINTN       *Flags, \r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN OUT CHAR_W *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN  EFI_TIME  *Time,\r
+  IN OUT CHAR_W *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR_W      *Buffer,\r
+  IN  UINTN       BufferSize\r
+  );\r
+\r
+UINTN\r
+SPrint (\r
+  OUT CHAR_W        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+  \r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+VSPrint (\r
+  OUT CHAR_W        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  CHAR16    TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR_W    *Buffer;\r
+  CHAR8     *AsciiStr;\r
+  CHAR16    *UnicodeStr;\r
+  CHAR_W    *Format;\r
+  UINTN     Index;\r
+  UINTN     Flags;\r
+  UINTN     Width;\r
+  UINTN     Count;\r
+  UINTN     NumberOfCharacters;\r
+  UINTN     BufferLeft;\r
+  UINT64    Value;\r
+  EFI_GUID  *TmpGUID;\r
+\r
+  //\r
+  // Process the format string. Stop if Buffer is over run.\r
+  //\r
+\r
+  Buffer = StartOfBuffer;\r
+  Format = (CHAR_W *)FormatString; \r
+  NumberOfCharacters = BufferSize/sizeof(CHAR_W);\r
+  BufferLeft = BufferSize;\r
+  for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) {\r
+    if (*Format != '%') {\r
+      if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) {                  \r
+        //\r
+        // If carage return add line feed\r
+        //\r
+        Buffer[Index++] = '\r';\r
+        BufferLeft -= sizeof(CHAR_W);\r
+      }\r
+      Buffer[Index++] = *Format;\r
+      BufferLeft -= sizeof(CHAR_W);\r
+    } else {\r
+      \r
+      //\r
+      // Now it's time to parse what follows after %\r
+      //\r
+      Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);\r
+      switch (*Format) {\r
+      case 'X':\r
+        Flags |= PREFIX_ZERO;\r
+        Width = sizeof (UINT64) * 2;\r
+        //\r
+        // break skiped on purpose\r
+        //\r
+      case 'x':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        EfiValueToHexStr (TempBuffer, Value, Flags, Width);\r
+        UnicodeStr = TempBuffer;\r
+\r
+        for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        break;\r
+\r
+      case 'd':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = (UINTN)VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        EfiValueToString (TempBuffer, Value, Flags, Width);\r
+        UnicodeStr = TempBuffer;                              \r
+\r
+        for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        break;\r
+\r
+      case 's':\r
+      case 'S':\r
+        UnicodeStr = (CHAR16 *)VA_ARG (Marker, CHAR_W *);\r
+        if (UnicodeStr == NULL) {\r
+          UnicodeStr = L"<null string>";\r
+        }\r
+        for (Count = 0 ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) {\r
+          Buffer[Index++] = *UnicodeStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+\r
+        break;\r
+\r
+      case 'a':\r
+        AsciiStr = (CHAR8 *)VA_ARG (Marker, CHAR8 *);\r
+        if (AsciiStr == NULL) {\r
+          AsciiStr = "<null string>";\r
+        }\r
+        for (Count = 0 ;(*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) {\r
+          Buffer[Index++] = (CHAR_W)*AsciiStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (;(Count < Width) && (Index < NumberOfCharacters - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+        break;\r
+\r
+      case 'c':\r
+        Buffer[Index++] = (CHAR_W)VA_ARG (Marker, UINTN);\r
+        break;\r
+\r
+      case 'g':\r
+        TmpGUID = VA_ARG (Marker, EFI_GUID *); \r
+        if (TmpGUID != NULL) {\r
+          Index += GuidToString (\r
+                    TmpGUID, \r
+                    &Buffer[Index], \r
+                    BufferLeft\r
+                    );\r
+        }\r
+        break;\r
+\r
+      case 't':\r
+        Index += TimeToString (\r
+                  VA_ARG (Marker, EFI_TIME *), \r
+                  &Buffer[Index], \r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case 'r':\r
+        Index += EfiStatusToString (\r
+                  VA_ARG (Marker, EFI_STATUS), \r
+                  &Buffer[Index], \r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case '%':\r
+        Buffer[Index++] = *Format;\r
+        break;\r
+    \r
+      default:\r
+        //\r
+        // if the type is unknown print it to the screen\r
+        //\r
+        Buffer[Index++] = *Format;\r
+      }\r
+      BufferLeft = BufferSize - Index * sizeof(CHAR_W) ;\r
+    } \r
+  }\r
+  Buffer[Index++] = '\0'; \r
+   \r
+  return &Buffer[Index] - StartOfBuffer;\r
+}\r
+\r
+\r
+\r
+STATIC\r
+CHAR_W *\r
+GetFlagsAndWidth (\r
+  IN  CHAR_W      *Format, \r
+  OUT UINTN       *Flags, \r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that parses flag and width information from the \r
+  Format string and returns the next index into the Format string that needs\r
+  to be parsed. See file headed for details of Flag and Width.\r
+\r
+Arguments:\r
+\r
+  Format - Current location in the VSPrint format string.\r
+\r
+  Flags  - Returns flags\r
+\r
+  Width  - Returns width of element\r
+\r
+  Marker - Vararg list that may be paritally consumed and returned.\r
+\r
+Returns: \r
+\r
+  Pointer indexed into the Format string for all the information parsed\r
+  by this routine.\r
+\r
+--*/\r
+{\r
+  UINTN   Count;\r
+  BOOLEAN Done;\r
+\r
+  *Flags = 0;\r
+  *Width = 0;\r
+  for (Done = FALSE; !Done; ) {\r
+    Format++;\r
+\r
+    switch (*Format) {\r
+\r
+    case '-': *Flags |= LEFT_JUSTIFY; break;\r
+    case '+': *Flags |= PREFIX_SIGN;  break;\r
+    case ' ': *Flags |= PREFIX_BLANK; break;\r
+    case ',': *Flags |= COMMA_TYPE;   break;\r
+    case 'L':\r
+    case 'l': *Flags |= LONG_TYPE;    break;\r
+\r
+    case '*':\r
+      *Width = VA_ARG (*Marker, UINTN);\r
+      break;\r
+\r
+    case '0':\r
+      *Flags |= PREFIX_ZERO;\r
+    case '1':\r
+    case '2':\r
+    case '3':\r
+    case '4':\r
+    case '5':\r
+    case '6':\r
+    case '7':\r
+    case '8':\r
+    case '9':\r
+      Count = 0;\r
+      do {\r
+        Count = (Count * 10) + *Format - '0';\r
+        Format++;\r
+      } while ((*Format >= '0')  &&  (*Format <= '9'));\r
+      Format--;\r
+      *Width = Count;\r
+      break;\r
+\r
+    default:\r
+      Done = TRUE;\r
+    }\r
+  }\r
+  return Format;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN  CHAR_W    *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints an EFI_GUID.\r
+\r
+Arguments:\r
+\r
+  Guid       - Pointer to GUID to print.\r
+\r
+  Buffer     - Buffe to print Guid into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN Size;\r
+\r
+  Size = SPrint (\r
+            Buffer,\r
+            BufferSize, \r
+            STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),\r
+            (UINTN)Guid->Data1,                    \r
+            (UINTN)Guid->Data2,\r
+            (UINTN)Guid->Data3,\r
+            (UINTN)Guid->Data4[0],\r
+            (UINTN)Guid->Data4[1],\r
+            (UINTN)Guid->Data4[2],\r
+            (UINTN)Guid->Data4[3],\r
+            (UINTN)Guid->Data4[4],\r
+            (UINTN)Guid->Data4[5],\r
+            (UINTN)Guid->Data4[6],\r
+            (UINTN)Guid->Data4[7]\r
+            );\r
+\r
+  //\r
+  // SPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+}\r
+\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN EFI_TIME   *Time,\r
+  OUT CHAR_W    *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints EFI_TIME.\r
+\r
+Arguments:\r
+\r
+  Time       - Pointer to EFI_TIME sturcture to print.\r
+\r
+  Buffer     - Buffer to print Time into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{ \r
+  UINTN Size;\r
+\r
+  Size = SPrint (\r
+            Buffer,\r
+            BufferSize, \r
+            STRING_W ("%02d/%02d/%04d  %02d:%02d"),\r
+            (UINTN)Time->Month,\r
+            (UINTN)Time->Day,\r
+            (UINTN)Time->Year,\r
+            (UINTN)Time->Hour,\r
+            (UINTN)Time->Minute\r
+            );\r
+\r
+  //\r
+  // SPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+} \r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR_W      *Buffer,\r
+  IN  UINTN       BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints EFI_STATUS as a string. If string is\r
+  not known a hex value will be printed.\r
+\r
+Arguments:\r
+\r
+  Status     -  EFI_STATUS sturcture to print.\r
+\r
+  Buffer     - Buffer to print EFI_STATUS message string into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN   Size;\r
+  CHAR8   *Desc;\r
+  \r
+  Desc = NULL;\r
+\r
+  //\r
+  // Can't use global Status String Array as UINTN is not constant for EBC\r
+  //\r
+  if (Status == EFI_SUCCESS) { Desc = "Success"; } else \r
+  if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else\r
+  if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else\r
+  if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else\r
+  if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else\r
+  if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else\r
+  if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else\r
+  if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else\r
+  if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else\r
+  if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else\r
+  if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else\r
+  if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else\r
+  if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else\r
+  if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else\r
+  if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else\r
+  if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else\r
+  if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else\r
+  if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else\r
+  if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else\r
+  if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else\r
+  if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else\r
+  if (Status == EFI_ABORTED) { Desc = "Aborted"; } else\r
+  if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else\r
+  if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else\r
+  if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else\r
+  if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else\r
+  if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else\r
+  if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else\r
+  if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; } \r
+  \r
+  //\r
+  // If we found a match, copy the message to the user's buffer. Otherwise\r
+  // sprint the hex status code to their buffer.\r
+  //\r
+  if (Desc != NULL) {\r
+    Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc);\r
+  } else {\r
+    Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status);\r
+  }\r
+  return Size - 1;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h
new file mode 100644 (file)
index 0000000..7d4394e
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  Private data for Print.c\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_H_\r
+#define _PRINT_H_\r
+\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Largest number of characters that can be printed out.\r
+//\r
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf
new file mode 100644 (file)
index 0000000..e5c6f37
--- /dev/null
@@ -0,0 +1,49 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    PrintLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = PrintLib\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  BoxDraw.c\r
+  Print.c\r
+  Print.h\r
+  StdErr.c\r
+  Unicode\PrintWidth.h\r
+  Unicode\SPrint.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c
new file mode 100644 (file)
index 0000000..e4a649d
--- /dev/null
@@ -0,0 +1,284 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StdErr.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiCommonLib.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ErrorPrint (\r
+  IN CONST CHAR16 *ErrorString,\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  ErrorString - String of error infomation.\r
+\r
+  Format      - Ascii format string see file header for more details.\r
+\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  UINTN   Index;\r
+  UINTN   MaxIndex;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
+  if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
+    //\r
+    // Format string was too long for use to process.\r
+    //\r
+    return 0;\r
+  }\r
+\r
+  if (ErrorString != '\0') {\r
+    if (gST->StdErr != NULL) {\r
+      //\r
+      // To be extra safe make sure StdErr has been initialized\r
+      //\r
+      gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK));\r
+      gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString);\r
+      gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK));\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < MaxIndex; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) Format[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index] = 0;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
+  VA_END (Marker);\r
+\r
+  //\r
+  // Need to convert to Unicode to do an OutputString\r
+  //\r
+\r
+  if (gST->StdErr != NULL) {\r
+    //\r
+    // To be extra safe make sure StdErr has been initialized\r
+    //\r
+    gST->StdErr->OutputString (gST->StdErr, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+Aprint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  UINTN   Index;\r
+  UINTN   MaxIndex;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
+  if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
+    //\r
+    // Format string was too long for use to process.\r
+    //\r
+    return 0;\r
+  }\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) Format[Index];\r
+  }\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
+  VA_END (Marker);\r
+\r
+  //\r
+  // Need to convert to Unicode to do an OutputString\r
+  //\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+Print (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+UPrint (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h
new file mode 100644 (file)
index 0000000..e8e8d6f
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Unicode\r
+  STRING_W is L""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR16  CHAR_W;\r
+#define STRING_W(_s)                                  L##_s\r
+\r
+#define USPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define UvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+#include "EfiCommonLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c
new file mode 100644 (file)
index 0000000..6b70aa6
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = AvSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of ASPrint. \r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index]  = '\0';\r
+\r
+  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h
new file mode 100644 (file)
index 0000000..65087c1
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Ascii\r
+  STRING_W is ""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR8 CHAR_W;\r
+#define STRING_W(_s)                                  _s\r
+\r
+#define ASPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define AvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         StrLen,\r
+  IN  CONST CHAR16  *Format,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  StrLen               - Maximum number of characters to put into buffer.\r
+  Format               - Format string\r
+  Marker               - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16      *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR16 *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c
new file mode 100644 (file)
index 0000000..fc74c7c
--- /dev/null
@@ -0,0 +1,142 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+UINTN\r
+USPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+UvSPrint (\r
+  OUT CHAR16        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of USPrint. \r
+  Process format and place the results in Buffer for wide chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Wide char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    AsciiFormat[Index] = (CHAR8) FormatString[Index];\r
+  }\r
+\r
+  AsciiFormat[Index]  = '\0';\r
+\r
+  Index               = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR16) AsciiResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c
new file mode 100644 (file)
index 0000000..0fb5378
--- /dev/null
@@ -0,0 +1,212 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BoxDraw.c\r
+\r
+Abstract:\r
+  Lib functions to support Box Draw Unicode code pages.\r
+\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+\r
+\r
+typedef struct {\r
+  CHAR16  Unicode;\r
+  CHAR8   PcAnsi;\r
+  CHAR8   Ascii;\r
+} UNICODE_TO_CHAR;\r
+\r
+\r
+//\r
+// This list is used to define the valid extend chars.\r
+// It also provides a mapping from Unicode to PCANSI or\r
+// ASCII. The ASCII mapping we just made up.\r
+//\r
+//\r
+\r
+static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {\r
+  BOXDRAW_HORIZONTAL,                 0xc4, L'-', \r
+  BOXDRAW_VERTICAL,                   0xb3, L'|',\r
+  BOXDRAW_DOWN_RIGHT,                 0xda, L'/',\r
+  BOXDRAW_DOWN_LEFT,                  0xbf, L'\\',\r
+  BOXDRAW_UP_RIGHT,                   0xc0, L'\\',\r
+  BOXDRAW_UP_LEFT,                    0xd9, L'/',\r
+  BOXDRAW_VERTICAL_RIGHT,             0xc3, L'|',\r
+  BOXDRAW_VERTICAL_LEFT,              0xb4, L'|',\r
+  BOXDRAW_DOWN_HORIZONTAL,            0xc2, L'+',\r
+  BOXDRAW_UP_HORIZONTAL,              0xc1, L'+',\r
+  BOXDRAW_VERTICAL_HORIZONTAL,        0xc5, L'+',\r
+  BOXDRAW_DOUBLE_HORIZONTAL,          0xcd, L'-',\r
+  BOXDRAW_DOUBLE_VERTICAL,            0xba, L'|',\r
+  BOXDRAW_DOWN_RIGHT_DOUBLE,          0xd5, L'/',\r
+  BOXDRAW_DOWN_DOUBLE_RIGHT,          0xd6, L'/',\r
+  BOXDRAW_DOUBLE_DOWN_RIGHT,          0xc9, L'/',\r
+  BOXDRAW_DOWN_LEFT_DOUBLE,           0xb8, L'\\',\r
+  BOXDRAW_DOWN_DOUBLE_LEFT,           0xb7, L'\\',\r
+  BOXDRAW_DOUBLE_DOWN_LEFT,           0xbb, L'\\',\r
+  BOXDRAW_UP_RIGHT_DOUBLE,            0xd4, L'\\',\r
+  BOXDRAW_UP_DOUBLE_RIGHT,            0xd3, L'\\',\r
+  BOXDRAW_DOUBLE_UP_RIGHT,            0xc8, L'\\',\r
+  BOXDRAW_UP_LEFT_DOUBLE,             0xbe, L'/',\r
+  BOXDRAW_UP_DOUBLE_LEFT,             0xbd, L'/',\r
+  BOXDRAW_DOUBLE_UP_LEFT,             0xbc, L'/',\r
+  BOXDRAW_VERTICAL_RIGHT_DOUBLE,      0xc6, L'|',\r
+  BOXDRAW_VERTICAL_DOUBLE_RIGHT,      0xc7, L'|',\r
+  BOXDRAW_DOUBLE_VERTICAL_RIGHT,      0xcc, L'|',\r
+  BOXDRAW_VERTICAL_LEFT_DOUBLE,       0xb5, L'|',\r
+  BOXDRAW_VERTICAL_DOUBLE_LEFT,       0xb6, L'|',\r
+  BOXDRAW_DOUBLE_VERTICAL_LEFT,       0xb9, L'|',\r
+  BOXDRAW_DOWN_HORIZONTAL_DOUBLE,     0xd1, L'+',\r
+  BOXDRAW_DOWN_DOUBLE_HORIZONTAL,     0xd2, L'+',\r
+  BOXDRAW_DOUBLE_DOWN_HORIZONTAL,     0xcb, L'+',\r
+  BOXDRAW_UP_HORIZONTAL_DOUBLE,       0xcf, L'+',\r
+  BOXDRAW_UP_DOUBLE_HORIZONTAL,       0xd0, L'+',\r
+  BOXDRAW_DOUBLE_UP_HORIZONTAL,       0xca, L'+',\r
+  BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',\r
+  BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',\r
+  BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',\r
+\r
+  BLOCKELEMENT_FULL_BLOCK,            0xdb, L'*',\r
+  BLOCKELEMENT_LIGHT_SHADE,           0xb0, L'+',\r
+\r
+  GEOMETRICSHAPE_UP_TRIANGLE,         0x1e, L'^',\r
+  GEOMETRICSHAPE_RIGHT_TRIANGLE,      0x10, L'>',\r
+  GEOMETRICSHAPE_DOWN_TRIANGLE,       0x1f, L'v',\r
+  GEOMETRICSHAPE_LEFT_TRIANGLE,       0x11, L'<',\r
+\r
+  ARROW_LEFT,                         0x3c, L'<',\r
+\r
+  ARROW_UP,                           0x18, L'^',\r
+\r
+  ARROW_RIGHT,                        0x3e, L'>',\r
+\r
+  ARROW_DOWN,                         0x19, L'v',\r
+  \r
+  0x0000, 0x00\r
+};\r
+\r
+\r
+BOOLEAN\r
+LibIsValidTextGraphics (\r
+  IN  CHAR16  Graphic,\r
+  OUT CHAR8   *PcAnsi,    OPTIONAL\r
+  OUT CHAR8   *Ascii      OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Detects if a Unicode char is for Box Drawing text graphics.\r
+\r
+Arguments:\r
+\r
+    Graphic - Unicode char to test.\r
+\r
+    PcAnsi  - Optional pointer to return PCANSI equivalent of Graphic.\r
+\r
+    Asci    - Optional pointer to return Ascii equivalent of Graphic.\r
+\r
+Returns:\r
+\r
+    TRUE if Gpaphic is a supported Unicode Box Drawing character.\r
+\r
+--*/\r
+{\r
+  UNICODE_TO_CHAR     *Table;\r
+\r
+  if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {\r
+   \r
+    //\r
+    // Unicode drawing code charts are all in the 0x25xx range, \r
+    //  arrows are 0x21xx\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {\r
+    if (Graphic == Table->Unicode) {\r
+      if (PcAnsi != NULL) {\r
+        *PcAnsi = Table->PcAnsi; \r
+      }\r
+      if (Ascii != NULL) {\r
+        *Ascii = Table->Ascii;\r
+      }\r
+      return TRUE;\r
+    }\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+BOOLEAN\r
+IsValidAscii (\r
+  IN  CHAR16  Ascii\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Is it valid ascii char?  \r
+\r
+Arguments:\r
+\r
+  Ascii                 - The char to check\r
+\r
+Returns: \r
+\r
+  TRUE                  - Is a ascii char\r
+  FALSE                 - Not a ascii char\r
+\r
+--*/\r
+{\r
+  if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {\r
+    return TRUE;\r
+  }              \r
+  return FALSE;\r
+}\r
+\r
+\r
+BOOLEAN\r
+IsValidEfiCntlChar (\r
+  IN  CHAR16  CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Is it valid EFI control char?  \r
+\r
+Arguments:\r
+\r
+  CharC                 - The char to check\r
+\r
+Returns: \r
+\r
+  TRUE                  - Is a valid EFI control char\r
+  FALSE                 - Not a valid EFI control char\r
+\r
+--*/\r
+{\r
+  if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) {\r
+    return TRUE;\r
+  }              \r
+  return FALSE;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c
new file mode 100644 (file)
index 0000000..c648e25
--- /dev/null
@@ -0,0 +1,153 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+UINTN\r
+SPrint (\r
+  OUT CHAR_W        *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+VSPrint (\r
+  OUT CHAR_W        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR_W  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_PRINT_PROTOCOL  *PrintProtocol;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiPrintProtocolGuid,\r
+                  NULL,\r
+                  (VOID*)&PrintProtocol\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  } else {\r
+    return PrintProtocol->VSPrint (\r
+                            StartOfBuffer,\r
+                            BufferSize,\r
+                            FormatString,\r
+                            Marker\r
+                            );\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h
new file mode 100644 (file)
index 0000000..7d4394e
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  Private data for Print.c\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_H_\r
+#define _PRINT_H_\r
+\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Largest number of characters that can be printed out.\r
+//\r
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf
new file mode 100644 (file)
index 0000000..6f79123
--- /dev/null
@@ -0,0 +1,50 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    PrintLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME           = PrintLibLite\r
+COMPONENT_TYPE      = LIBRARY\r
+\r
+[sources.common]\r
+  BoxDraw.c\r
+  Print.c\r
+  Print.h\r
+  StdErr.c\r
+  Unicode\PrintWidth.h\r
+  Unicode\SPrint.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+\r
+[libraries.common]\r
+  EdkProtocolLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c
new file mode 100644 (file)
index 0000000..e4a649d
--- /dev/null
@@ -0,0 +1,284 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StdErr.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiCommonLib.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ErrorPrint (\r
+  IN CONST CHAR16 *ErrorString,\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  ErrorString - String of error infomation.\r
+\r
+  Format      - Ascii format string see file header for more details.\r
+\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  UINTN   Index;\r
+  UINTN   MaxIndex;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
+  if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
+    //\r
+    // Format string was too long for use to process.\r
+    //\r
+    return 0;\r
+  }\r
+\r
+  if (ErrorString != '\0') {\r
+    if (gST->StdErr != NULL) {\r
+      //\r
+      // To be extra safe make sure StdErr has been initialized\r
+      //\r
+      gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK));\r
+      gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString);\r
+      gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK));\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < MaxIndex; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) Format[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index] = 0;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
+  VA_END (Marker);\r
+\r
+  //\r
+  // Need to convert to Unicode to do an OutputString\r
+  //\r
+\r
+  if (gST->StdErr != NULL) {\r
+    //\r
+    // To be extra safe make sure StdErr has been initialized\r
+    //\r
+    gST->StdErr->OutputString (gST->StdErr, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+Aprint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  UINTN   Index;\r
+  UINTN   MaxIndex;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);\r
+  if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {\r
+    //\r
+    // Format string was too long for use to process.\r
+    //\r
+    return 0;\r
+  }\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) Format[Index];\r
+  }\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);\r
+  VA_END (Marker);\r
+\r
+  //\r
+  // Need to convert to Unicode to do an OutputString\r
+  //\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+Print (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+UPrint (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii \r
+  characters.\r
+\r
+Arguments:\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  VA_START (Marker, Format);\r
+  Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  if (gST->ConOut != NULL) {\r
+    //\r
+    // To be extra safe make sure ConOut has been initialized\r
+    //\r
+    gST->ConOut->OutputString (gST->ConOut, Buffer);\r
+  }\r
+\r
+  return Return;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h
new file mode 100644 (file)
index 0000000..e8e8d6f
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PrintWidth.h\r
+\r
+Abstract:\r
+\r
+  Unicde option for generic width.\r
+  CHAR_W is Unicode\r
+  STRING_W is L""\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_WIDTH_H_\r
+#define _PRINT_WIDTH_H_\r
+\r
+typedef CHAR16  CHAR_W;\r
+#define STRING_W(_s)                                  L##_s\r
+\r
+#define USPrint(Buffer, BufferSize, Format)           SPrint (Buffer, BufferSize, Format)\r
+#define UvSPrint(Buffer, BufferSize, Format, Marker)  VSPrint (Buffer, BufferSize, Format, Marker)\r
+\r
+#include "EfiCommonLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c
new file mode 100644 (file)
index 0000000..6b70aa6
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Sprint.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
+  simple implemenation of SPrint() and Print() to support debug. \r
+\r
+  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  VSPrint, Print, SPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S','s' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PrintWidth.h"\r
+#include "EfiPrintLib.h"\r
+#include "Print.h"\r
+\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer      - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize  - Maximum number of characters to put into buffer.\r
+  Format      - Format string\r
+  ...         - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  Return = AvSPrint (Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Internal implementation of ASPrint. \r
+  Process format and place the results in Buffer for narrow chars.\r
+\r
+Arguments:\r
+\r
+  Buffer        - Narrow char buffer to print the results of the parsing of Format into.\r
+  BufferSize    - Maximum number of characters to put into buffer.\r
+  FormatString  - Format string\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+\r
+  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
+    UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
+  }\r
+\r
+  UnicodeFormat[Index]  = '\0';\r
+\r
+  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+\r
+  for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
+    Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
+  }\r
+\r
+  Buffer[Index] = '\0';\r
+\r
+  return Index++;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
new file mode 100644 (file)
index 0000000..d3e30df
--- /dev/null
@@ -0,0 +1,556 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxeDriverEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  DXE Driver entry point template file\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+#include "Common/EdkIIGlueDependencies.h"\r
+\r
+STATIC EFI_EVENT  _mDriverExitBootServicesNotifyEvent;\r
+\r
+//\r
+// Driver Model related definitions.\r
+// LIMITATION: only support one instance of Driver Model protocols per driver.\r
+// In case where multiple Driver Model protocols need to be installed in a single driver,\r
+// manually edit this file and compile/link the modified file with the driver.\r
+//\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__\r
+extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__;\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+extern EFI_COMPONENT_NAME2_PROTOCOL  __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;\r
+#else\r
+extern EFI_COMPONENT_NAME_PROTOCOL   __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;\r
+#endif\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__\r
+extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__;\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__\r
+extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__;\r
+#endif\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[] = {\r
+ {\r
+#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__\r
+  &__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__\r
+  &__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__\r
+  &__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__\r
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+  }\r
+};\r
+\r
+//\r
+// NOTE: Limitation:\r
+// Only one handler for SetVirtualAddressMap Event and ExitBootServices Event each\r
+//\r
+#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__\r
+VOID\r
+__EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  );\r
+#endif\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r
+#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__\r
+  __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__,\r
+#endif\r
+  NULL\r
+};\r
+\r
+#ifdef __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__\r
+VOID\r
+__EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__ (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  );\r
+#endif\r
+\r
+/**\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+  \r
+  @param[in]  Event   The Event that is being processed\r
+  @param[in]  Context Event Context\r
+**/\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  );\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__  \r
+  //\r
+  // only Runtime drivers need to link EdkDxeRuntimeDriverLib\r
+  //\r
+  RuntimeDriverExitBootServices,\r
+#endif\r
+#ifdef __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__\r
+  __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__,\r
+#endif\r
+  NULL\r
+};\r
+\r
+\r
+//\r
+// Module Unload Handler\r
+//\r
+\r
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__\r
+EFI_STATUS\r
+EFIAPI\r
+__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (\r
+  EFI_HANDLE        ImageHandle\r
+  );\r
+#endif\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleUnloadList (\r
+  EFI_HANDLE  ImageHandle\r
+  )\r
+{\r
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__\r
+  return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle));\r
+#else\r
+  return EFI_SUCCESS;\r
+#endif\r
+}\r
+\r
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__\r
+  GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;\r
+#endif\r
+\r
+//\r
+// Library constructors\r
+//\r
+VOID\r
+ProcessLibraryConstructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+//\r
+// Declare "Status" if any of the following libraries are used\r
+//\r
+#if defined(__EDKII_GLUE_DXE_HOB_LIB__)                     \\r
+    || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \\r
+    || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__)        \\r
+    || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__)   \\r
+    || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__)       \\r
+    || defined(__EDKII_GLUE_DXE_SMBUS_LIB__)                \\r
+    || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \\r
+    || defined(__EDKII_GLUE_EDK_DXE_SAL_LIB__)              \\r
+    || defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__)\r
+  EFI_STATUS  Status;\r
+#endif\r
+\r
+//\r
+// EdkII Glue Library Constructors: \r
+// NOTE: the constructors must be called according to dependency order\r
+//\r
+// UefiBootServicesTableLib     UefiBootServicesTableLibConstructor()\r
+// DxeIoLibCpuIo                IoLibConstructor()\r
+// DxeSalLib                    DxeSalLibConstructor(), IPF only\r
+// EdkDxeRuntimeDriverLib       RuntimeDriverLibConstruct()\r
+// DxeHobLib                    HobLibConstructor()\r
+// UefiDriverModelLib           UefiDriverModelLibConstructor()\r
+// DxeSmbusLib                  SmbusLibConstructor()    \r
+// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
+// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
+// \r
+\r
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  Status = IoLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__\r
+  Status = DxeSalLibConstructor(ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+  Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+  Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+  Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+  Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status); \r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__\r
+  Status = HobLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__\r
+  Status = SmbusLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+}\r
+\r
+//\r
+// Library Destructors\r
+//\r
+VOID\r
+ProcessLibraryDestructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+#if defined (__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) || defined (__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__)\r
+  EFI_STATUS  Status;    \r
+#endif\r
+\r
+//\r
+// NOTE: the destructors must be called according to dependency order\r
+//\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+  Status = UefiDriverModelLibDestructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+  Status = RuntimeDriverLibDeconstruct (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+}\r
+\r
+\r
+/**\r
+  Unload function that is registered in the LoadImage protocol.  It un-installs\r
+  protocols produced and deallocates pool used by the driver.  Called by the core\r
+  when unloading the driver.\r
+\r
+  @param  ImageHandle\r
+\r
+  @retval EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_DriverUnloadHandler (\r
+  EFI_HANDLE ImageHandle\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // If an UnloadImage() handler is specified, then call it\r
+  //\r
+  Status = ProcessModuleUnloadList (ImageHandle);\r
+\r
+  //\r
+  // If the driver specific unload handler does not return an error, then call all of the\r
+  // library destructors.  If the unload handler returned an error, then the driver can not be\r
+  // unloaded, and the library destructors should not be called\r
+  //\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Close our ExitBootServices () notify function\r
+    //\r
+    if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+      ASSERT (gBS != NULL);\r
+      Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+\r
+    //\r
+    // NOTE: To allow passing in gST here, any library instance having a destructor\r
+    // must depend on EfiDriverLib\r
+    //\r
+    ProcessLibraryDestructorList (ImageHandle, gST);\r
+  }\r
+\r
+  //\r
+  // Return the status from the driver specific unload handler\r
+  //\r
+  return Status;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+_DriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;\r
+  UINTN             Index;\r
+\r
+  for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) {\r
+    ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index];\r
+    ChildNotifyEventHandler (Event, NULL);\r
+  }\r
+}\r
+\r
+EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint);\r
+\r
+//\r
+// Module Entry Point\r
+//\r
+#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
+EFI_STATUS\r
+EFIAPI\r
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (\r
+  EFI_HANDLE        ImageHandle,\r
+  EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+/**\r
+  Enrty point to DXE Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;\r
+\r
+//  if (_gUefiDriverRevision != 0) {\r
+//    //\r
+//    // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver\r
+//    //\r
+//    if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
+//      return EFI_INCOMPATIBLE_VERSION;\r
+//    }\r
+//  }\r
+\r
+//  DEBUG ((EFI_D_ERROR, "EdkII Glue Driver Entry - 0\n"));\r
+\r
+  //\r
+  // Call constructor for all libraries\r
+  //\r
+  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
+  //\r
+  // Register our ExitBootServices () notify function\r
+  //\r
+  if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+    Status = SystemTable->BootServices->CreateEvent (\r
+                    EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                    EFI_TPL_NOTIFY,\r
+                    _DriverExitBootServices,\r
+                    NULL,\r
+                    &_mDriverExitBootServicesNotifyEvent\r
+                    );\r
+\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  //  Install unload handler...\r
+  //\r
+  Status = SystemTable->BootServices->HandleProtocol (\r
+                  ImageHandle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **)&LoadedImage\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  LoadedImage->Unload = _DriverUnloadHandler;\r
+\r
+  //\r
+  // Call the driver entry point\r
+  //\r
+  #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
+  Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));\r
+  #else\r
+  Status = EFI_SUCCESS;\r
+  #endif\r
+\r
+  //\r
+  // If all of the drivers returned errors, then invoke all of the library destructors\r
+  //\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Close our ExitBootServices () notify function\r
+    //\r
+    if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+       EFI_STATUS CloseEventStatus;\r
+      CloseEventStatus = SystemTable->BootServices->CloseEvent (_mDriverExitBootServicesNotifyEvent);\r
+      ASSERT_EFI_ERROR (CloseEventStatus);\r
+    }\r
+\r
+    ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
+  }\r
+\r
+  //\r
+  // Return the cummalative return status code from all of the driver entry points\r
+  //\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Enrty point wrapper of DXE Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+  EBC build envrionment has /D $(IMAGE_ENTRY_POINT)=EfiMain which overrides what GlueLib \r
+  defines: /D IMAGE_ENTRY_POINT=_ModuleEntryPoint, so _ModuleEntryPoint will be replaced with\r
+  EfiMain thus the function below isn't needed in EBC envrionment.\r
+\r
+**/\r
+#ifndef MDE_CPU_EBC\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  return _ModuleEntryPoint (ImageHandle, SystemTable);\r
+}\r
+#endif\r
+\r
+//\r
+// Guids not present in R8.6 code base\r
+//\r
+\r
+//\r
+// Protocol/Arch Protocol GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid             = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid               = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid                              = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid                = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid                            = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid              = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid                              = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid                = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid                        = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid                   = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid     = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid                           = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid             = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid                             = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };     \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid               = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid                             = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid               = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid               = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid               = { 0x5c99a21,  0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid                 = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid              = { 0x379be4e,  0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid                             = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid               = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid               = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid                  = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid                           = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid                           = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };\r
+#endif\r
+\r
+//\r
+// PPI GUID globals\r
+//\r
+\r
+//\r
+// GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid              = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid                 = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid                = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid            = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid             = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid                   = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid                 = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid                 = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid                 = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid                 = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid                    = { 0xaf7c79c,  0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid         = { 0xedd35e31, 0x7b9,  0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid                   = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid                             = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid                      = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c
new file mode 100644 (file)
index 0000000..b84c883
--- /dev/null
@@ -0,0 +1,183 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeimEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  PEIM entry point template file\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+#include "Common/EdkIIGlueDependencies.h"\r
+\r
+\r
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__\r
+  GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;\r
+#endif\r
+\r
+//\r
+// Library constructors\r
+//\r
+VOID\r
+ProcessLibraryConstructorList (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+{\r
+//\r
+// Declare "Status" if any of the following libraries are used\r
+//\r
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__)    \\r
+    || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) \\r
+    || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__)\r
+  EFI_STATUS  Status;\r
+#endif\r
+\r
+//\r
+// EdkII Glue Library Constructors: \r
+// PeiServicesTablePointerLib      PeiServicesTablePointerLibConstructor()\r
+// PeiServicesTablePointerLibMm7   PeiServicesTablePointerLibConstructor()\r
+// PeiServicesTablePointerLibKr1   PeiServicesTablePointerLibConstructor()\r
+//\r
+\r
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__)    \\r
+    || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) \\r
+    || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__)\r
+  Status = PeiServicesTablePointerLibConstructor (FfsHeader, PeiServices);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+}\r
+\r
+EFI_PEIM_ENTRY_POINT (_ModuleEntryPoint);\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  );\r
+\r
+/**\r
+  Image entry point of Peim.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @return  Status returned by entry points of Peims.\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+{\r
+//  if (_gPeimRevision != 0) {\r
+//    //\r
+//    // Make sure that the PEI spec revision of the platform is >= PEI spec revision of the driver\r
+//    //\r
+//    ASSERT ((*PeiServices)->Hdr.Revision >= _gPeimRevision);\r
+//  }\r
+\r
+  //\r
+  // Call constructor for all libraries\r
+  //\r
+  ProcessLibraryConstructorList (FfsHeader, PeiServices);\r
+\r
+  //\r
+  // Call the driver entry point\r
+  //\r
+  return __EDKII_GLUE_MODULE_ENTRY_POINT__ (FfsHeader, PeiServices);\r
+}\r
+\r
+\r
+/**\r
+  Wrapper of Peim image entry point.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @return  Status returned by entry points of Peims.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  return _ModuleEntryPoint (FfsHeader, PeiServices);\r
+}\r
+\r
+//\r
+// Guids not present in R8.6 code base\r
+//\r
+\r
+//\r
+// Protocol/Arch Protocol GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid             = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid               = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid                              = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid                = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid                            = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid              = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid                              = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid                = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid                        = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid                   = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid     = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid                           = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid             = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid                             = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };     \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid               = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid                             = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid               = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid               = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid               = { 0x5c99a21,  0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid                 = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid              = { 0x379be4e,  0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid                             = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid               = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid               = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid                  = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid                           = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid                           = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };\r
+\r
+//\r
+// PPI GUID globals\r
+//\r
+\r
+//\r
+// GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid              = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid                 = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid                = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid            = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid             = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid                   = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid                 = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid                 = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid                 = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid                 = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid                    = { 0xaf7c79c,  0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid         = { 0xedd35e31, 0x7b9,  0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid                   = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid                             = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid                      = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
new file mode 100644 (file)
index 0000000..f8c8f9c
--- /dev/null
@@ -0,0 +1,480 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueSmmDriverEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  Smm Driver entry point template file\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+#include "Common/EdkIIGlueDependencies.h"\r
+\r
+\r
+//\r
+// Module Unload Handler\r
+//\r
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__\r
+EFI_STATUS\r
+EFIAPI\r
+__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (\r
+  EFI_HANDLE        ImageHandle\r
+  );\r
+#endif\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleUnloadList (\r
+  EFI_HANDLE  ImageHandle\r
+  )\r
+{\r
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__\r
+  return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle));\r
+#else\r
+  return EFI_SUCCESS;\r
+#endif\r
+}\r
+\r
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__\r
+  GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;\r
+#endif\r
+\r
+//\r
+// Library constructors\r
+//\r
+VOID\r
+ProcessLibraryConstructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+//\r
+// Declare "Status" if any of the following libraries are used\r
+//\r
+#if defined(__EDKII_GLUE_DXE_HOB_LIB__)                     \\r
+    || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \\r
+    || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__)        \\r
+    || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__)   \\r
+    || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__)       \\r
+    || defined(__EDKII_GLUE_DXE_SMBUS_LIB__)                \\r
+    || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \\r
+    || defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__)\r
+  EFI_STATUS  Status;\r
+#endif\r
+\r
+//\r
+// EdkII Glue Library Constructors: \r
+// NOTE: the constructors must be called according to dependency order\r
+//\r
+// UefiBootServicesTableLib     UefiBootServicesTableLibConstructor()\r
+// DxeIoLibCpuIo                IoLibConstructor \r
+//   EdkDxeRuntimeDriverLib       RuntimeDriverLibConstruct()   \r
+// DxeHobLib                    HobLibConstructor()\r
+//   UefiDriverModelLib           UefiDriverModelLibConstructor()\r
+// DxeSmbusLib                  SmbusLibConstructor()    \r
+// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
+// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
+// check here: check lib usage\r
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  Status = IoLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+  Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+  Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+  Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+  Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status); \r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__\r
+  Status = HobLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__\r
+  Status = SmbusLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+}\r
+\r
+//\r
+// Library destructors\r
+//\r
+VOID\r
+ProcessLibraryDestructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+}\r
+\r
+EFI_BOOT_SERVICES  *mBS;\r
+\r
+/**\r
+  This function returns the size, in bytes, \r
+  of the device path data structure specified by DevicePath.\r
+  If DevicePath is NULL, then 0 is returned.\r
+\r
+  @param  DevicePath A pointer to a device path data structure.\r
+\r
+  @return The size of a device path in bytes.\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+EFIAPI\r
+SmmGetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  if (DevicePath == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!EfiIsDevicePathEnd (DevicePath)) {\r
+    DevicePath = EfiNextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Compute the size and add back in the size of the end device path structure\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+}\r
+\r
+/**\r
+  This function appends the device path SecondDevicePath\r
+  to every device path instance in FirstDevicePath. \r
+\r
+  @param  FirstDevicePath A pointer to a device path data structure.\r
+  \r
+  @param  SecondDevicePath A pointer to a device path data structure.\r
+\r
+  @return A pointer to the new device path is returned.\r
+          NULL is returned if space for the new device path could not be allocated from pool.\r
+          It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath\r
+          if they are no longer needed.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+SmmAppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Size;\r
+  UINTN                     Size1;\r
+  UINTN                     Size2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
+\r
+  ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL);\r
+\r
+  //\r
+  // Allocate space for the combined device path. It only has one end node of\r
+  // length EFI_DEVICE_PATH_PROTOCOL\r
+  //\r
+  Size1         = SmmGetDevicePathSize (FirstDevicePath);\r
+  Size2         = SmmGetDevicePathSize (SecondDevicePath);\r
+  Size          = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+\r
+  Status = (mBS->AllocatePool) (EfiBootServicesData, Size, (VOID **) &NewDevicePath);\r
+\r
+  if (EFI_SUCCESS == Status) {\r
+    (mBS->CopyMem) ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);\r
+    //\r
+    // Over write Src1 EndNode and do the copy\r
+    //\r
+    DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
+    (mBS->CopyMem) ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Unload function that is registered in the LoadImage protocol.  It un-installs\r
+  protocols produced and deallocates pool used by the driver.  Called by the core\r
+  when unloading the driver.\r
+\r
+  @param  ImageHandle   ImageHandle of the unloaded driver\r
+\r
+  @return Status of the ProcessModuleUnloadList.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_DriverUnloadHandler (\r
+  EFI_HANDLE ImageHandle\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Call the unload handlers for all the modules\r
+  //\r
+  Status = ProcessModuleUnloadList (ImageHandle);\r
+\r
+  //\r
+  // If the driver specific unload handler does not return an error, then call all of the\r
+  // library destructors.  If the unload handler returned an error, then the driver can not be\r
+  // unloaded, and the library destructors should not be called\r
+  //\r
+  if (!EFI_ERROR (Status)) {\r
+  //\r
+  // NOTE: To allow passing in gST here, any library instance having a destructor\r
+  // must depend on EfiDriverLib\r
+  //\r
+  }\r
+\r
+  //\r
+  // Return the status from the driver specific unload handler\r
+  //\r
+  return Status;\r
+}\r
+\r
+EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint);\r
+\r
+//\r
+// Module Entry Point\r
+//\r
+#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
+EFI_STATUS\r
+EFIAPI\r
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (\r
+  EFI_HANDLE        ImageHandle,\r
+  EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+/**\r
+  Enrty point to DXE SMM Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;\r
+  EFI_SMM_BASE_PROTOCOL      *SmmBase;\r
+  BOOLEAN                    InSmm;\r
+  EFI_DEVICE_PATH_PROTOCOL   *CompleteFilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL   *ImageDevicePath;\r
+  EFI_HANDLE                 Handle;\r
+\r
+  //\r
+  // Cache a pointer to the Boot Services Table \r
+  //\r
+  mBS = SystemTable->BootServices;\r
+\r
+  //\r
+  // Retrieve the Loaded Image Protocol\r
+  //\r
+  Status = mBS->HandleProtocol (\r
+                  ImageHandle, \r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID*)&LoadedImage\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Retrieve SMM Base Protocol\r
+  //\r
+  Status = mBS->LocateProtocol (\r
+                  &gEfiSmmBaseProtocolGuid, \r
+                  NULL, \r
+                  (VOID **) &SmmBase\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Check to see if we are already in SMM\r
+  //\r
+  SmmBase->InSmm (SmmBase, &InSmm);\r
+\r
+  //\r
+  //\r
+  //\r
+  if (!InSmm) {\r
+    //\r
+    // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from\r
+    //\r
+    Status = mBS->HandleProtocol (\r
+                    LoadedImage->DeviceHandle, \r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID*)&ImageDevicePath\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    //\r
+    // Build the full device path to the currently execuing image\r
+    //\r
+    CompleteFilePath = SmmAppendDevicePath (ImageDevicePath, LoadedImage->FilePath);\r
+\r
+    //\r
+    // Load the image in memory to SMRAM; it will automatically generate the\r
+    // SMI.\r
+    //\r
+    Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);\r
+    ASSERT_EFI_ERROR (Status);\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Call constructor for all libraries\r
+  //\r
+  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
+  //\r
+  // Install the unload handler\r
+  //\r
+  Status = mBS->HandleProtocol (\r
+                    ImageHandle,\r
+                    &gEfiLoadedImageProtocolGuid,\r
+                    (VOID **)&LoadedImage\r
+                    );\r
+  ASSERT_EFI_ERROR (Status);\r
+  LoadedImage->Unload = _DriverUnloadHandler;\r
+\r
+  //\r
+  // Call the list of driver entry points\r
+  //\r
+  #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
+  Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));\r
+  #else\r
+  Status = EFI_SUCCESS;\r
+  #endif\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Enrty point wrapper of DXE SMM Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  return _ModuleEntryPoint (ImageHandle, SystemTable);\r
+}\r
+\r
+//\r
+// Guids not present in R8.6 code base\r
+//\r
+\r
+//\r
+// Protocol/Arch Protocol GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid             = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid               = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid                              = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid                = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid                            = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid              = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid                              = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid                = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid                        = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid                   = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid     = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid                           = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid             = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid                             = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };     \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid               = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid                             = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid               = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid               = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid               = { 0x5c99a21,  0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid                 = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid              = { 0x379be4e,  0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid                             = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid               = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid               = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid                  = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid                           = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid                           = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };\r
+\r
+//\r
+// PPI GUID globals\r
+//\r
+\r
+//\r
+// GUID globals\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid              = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid                 = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid                = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid            = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid             = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid                   = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid                 = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid                 = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid                 = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid                 = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };  \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid                    = { 0xaf7c79c,  0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid         = { 0xedd35e31, 0x7b9,  0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid                   = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid                             = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid                      = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h
new file mode 100644 (file)
index 0000000..f0b5e16
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  AutoGen.h\r
+  \r
+Abstract: \r
+\r
+  This file is supposed to be used by a .dxe file. To write common .dxs file for R8.x \r
+  and R9, a header file named AutoGen.h musted be present. In R8.x-GlueLib code base, \r
+  this AutoGen.h plays the role as the AutoGen.h in R9. Here the AutoGen.h isn't auto-generated \r
+  by any tool.\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUELIB_AUTOGEN_H__\r
+#define __EDKII_GLUELIB_AUTOGEN_H__\r
+\r
+\r
+//\r
+//  Explanation:\r
+//    BUILD_WITH_GLUELIB was used at the very beginning of EdkIIGlueLib development and \r
+//    BUILD_WITH_EDKII_GLUE_LIB was introduced later with newer EDK. The old one, BUILD_WITH_GLUELIB, \r
+//    is remained here only to keep source level compatibility with modules which already use it.\r
+//\r
+//  Both macros are of same effect: to indicate a module it's using EdkIIGlueLib. For newly created \r
+//  modules, BUILD_WITH_EDKII_GLUE_LIB is recommended to use.\r
+//\r
+//  The macros can be used in .dxs files and source files.\r
+//\r
+\r
+#ifndef BUILD_WITH_EDKII_GLUE_LIB\r
+  #define BUILD_WITH_EDKII_GLUE_LIB\r
+#endif\r
+\r
+#ifndef BUILD_WITH_GLUELIB\r
+  #define BUILD_WITH_GLUELIB\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h
new file mode 100644 (file)
index 0000000..957c9d6
--- /dev/null
@@ -0,0 +1,90 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueBaseTypes.h\r
+  \r
+Abstract: \r
+\r
+  Defines additional data types for use by Base modules\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_BASE_TYPES_H__\r
+#define __EDKII_GLUE_BASE_TYPES_H__\r
+\r
+#include "..\EdkIIGlueConfig.h"\r
+\r
+#define BREAKPOINT      EFI_BREAKPOINT\r
+#define DEADLOOP        EFI_DEADLOOP\r
+\r
+#define   MAX_BIT       EFI_MAX_BIT\r
+#define   MAX_ADDRESS   EFI_MAX_ADDRESS\r
+\r
+#ifndef UINT8_MAX\r
+  #define UINT8_MAX   0xff\r
+#endif\r
+\r
+//\r
+// EFI Error Codes common to all execution phases\r
+//\r
+\r
+typedef INTN RETURN_STATUS;\r
+\r
+///\r
+/// Set the upper bit to indicate EFI Error.\r
+///\r
+#define ENCODE_ERROR(a)              (MAX_BIT | (a))\r
+\r
+#define ENCODE_WARNING(a)            (a)\r
+#define RETURN_ERROR(a)              ((a) < 0)\r
+\r
+#define RETURN_SUCCESS               0\r
+#define RETURN_LOAD_ERROR            ENCODE_ERROR (1)\r
+#define RETURN_INVALID_PARAMETER     ENCODE_ERROR (2)\r
+#define RETURN_UNSUPPORTED           ENCODE_ERROR (3)\r
+#define RETURN_BAD_BUFFER_SIZE       ENCODE_ERROR (4)\r
+#define RETURN_BUFFER_TOO_SMALL      ENCODE_ERROR (5)\r
+#define RETURN_NOT_READY             ENCODE_ERROR (6)\r
+#define RETURN_DEVICE_ERROR          ENCODE_ERROR (7)\r
+#define RETURN_WRITE_PROTECTED       ENCODE_ERROR (8)\r
+#define RETURN_OUT_OF_RESOURCES      ENCODE_ERROR (9)\r
+#define RETURN_VOLUME_CORRUPTED      ENCODE_ERROR (10)\r
+#define RETURN_VOLUME_FULL           ENCODE_ERROR (11)\r
+#define RETURN_NO_MEDIA              ENCODE_ERROR (12)\r
+#define RETURN_MEDIA_CHANGED         ENCODE_ERROR (13)\r
+#define RETURN_NOT_FOUND             ENCODE_ERROR (14)\r
+#define RETURN_ACCESS_DENIED         ENCODE_ERROR (15)\r
+#define RETURN_NO_RESPONSE           ENCODE_ERROR (16)\r
+#define RETURN_NO_MAPPING            ENCODE_ERROR (17)\r
+#define RETURN_TIMEOUT               ENCODE_ERROR (18)\r
+#define RETURN_NOT_STARTED           ENCODE_ERROR (19)\r
+#define RETURN_ALREADY_STARTED       ENCODE_ERROR (20)\r
+#define RETURN_ABORTED               ENCODE_ERROR (21)\r
+#define RETURN_ICMP_ERROR            ENCODE_ERROR (22)\r
+#define RETURN_TFTP_ERROR            ENCODE_ERROR (23)\r
+#define RETURN_PROTOCOL_ERROR        ENCODE_ERROR (24)\r
+#define RETURN_INCOMPATIBLE_VERSION  ENCODE_ERROR (25)\r
+#define RETURN_SECURITY_VIOLATION    ENCODE_ERROR (26)\r
+#define RETURN_CRC_ERROR             ENCODE_ERROR (27)\r
+#define RETURN_END_OF_MEDIA          ENCODE_ERROR (28)\r
+#define RETURN_END_OF_FILE           ENCODE_ERROR (31)\r
+\r
+#define RETURN_WARN_UNKNOWN_GLYPH    ENCODE_WARNING (1)\r
+#define RETURN_WARN_DELETE_FAILURE   ENCODE_WARNING (2)\r
+#define RETURN_WARN_WRITE_FAILURE    ENCODE_WARNING (3)\r
+#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)\r
+\r
+typedef UINT64 PHYSICAL_ADDRESS;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h
new file mode 100644 (file)
index 0000000..3c30769
--- /dev/null
@@ -0,0 +1,113 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDefinitionChangesBase.h\r
+  \r
+Abstract: \r
+\r
+  Data structure definition changes from EDK to EDKII\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__\r
+#define __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__\r
+\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "EfiPxe.h"\r
+\r
+\r
+// ----------------------------------------------------------------------------------\r
+// Data Hub Record GUID Name changes\r
+// ----------------------------------------------------------------------------------\r
+#define gEfiProcessorSubClassGuid   gProcessorSubClassName\r
+#define gEfiCacheSubClassGuid       gCacheSubClassName\r
+#define gEfiMiscSubClassGuid        gMiscSubClassName\r
+#define gEfiProcessorProducerGuid   gProcessorProducerGuid\r
+#define gEfiMemoryProducerGuid      gMemoryProducerGuid\r
+#define gEfiMiscProducerGuid        gMiscProducerGuid\r
+\r
+\r
+// ----------------------------------------------------------------------------------\r
+// Hob.h: Get the data and data size field of GUID\r
+// ----------------------------------------------------------------------------------\r
+#define GET_GUID_HOB_DATA(GuidHob)      ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))\r
+#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))\r
+\r
+// ----------------------------------------------------------------------------------\r
+// InternalFormRepresentation.h:\r
+// ----------------------------------------------------------------------------------\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_CHECKBOX;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT8             Flags;\r
+} EFI_IFR_GRAY_OUT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_EXPR;\r
+\r
+// ------------------------\r
+// define GUID as EFI_GUID\r
+// ------------------------\r
+typedef EFI_GUID GUID;\r
+\r
+\r
+// -------------------\r
+// EdkII Names - Edk Names\r
+// -------------------\r
+#define EFI_GLOBAL_VARIABLE                           EFI_GLOBAL_VARIABLE_GUID\r
+#define MPS_TABLE_GUID                                EFI_MPS_TABLE_GUID\r
+#define SAL_SYSTEM_TABLE_GUID                         EFI_SAL_SYSTEM_TABLE_GUID\r
+#define SMBIOS_TABLE_GUID                             EFI_SMBIOS_TABLE_GUID\r
+#define EFI_OPTIONAL_PTR                              EFI_OPTIONAL_POINTER\r
+#define PXE_FRAME_TYPE_FILTERED_MULTICAST             PXE_FRAME_TYPE_MULTICAST\r
+#define IMAGE_FILE_MACHINE_I386                       EFI_IMAGE_MACHINE_IA32\r
+#define IMAGE_FILE_MACHINE_IA64                       EFI_IMAGE_MACHINE_IA64\r
+#define IMAGE_FILE_MACHINE_EBC                        EFI_IMAGE_MACHINE_EBC\r
+#define IMAGE_FILE_MACHINE_X64                        EFI_IMAGE_MACHINE_X64\r
+#define EVENT_TIMER                                   EFI_EVENT_TIMER\r
+#define EVENT_RUNTIME                                 EFI_EVENT_RUNTIME\r
+#define EVENT_RUNTIME_CONTEXT                         EFI_EVENT_RUNTIME_CONTEXT\r
+#define EVENT_NOTIFY_WAIT                             EFI_EVENT_NOTIFY_WAIT\r
+#define EVENT_NOTIFY_SIGNAL                           EFI_EVENT_NOTIFY_SIGNAL\r
+#define EVENT_SIGNAL_EXIT_BOOT_SERVICES               EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES\r
+#define EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE           EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r
+#define TPL_APPLICATION                               EFI_TPL_APPLICATION\r
+#define TPL_CALLBACK                                  EFI_TPL_CALLBACK\r
+#define TPL_NOTIFY                                    EFI_TPL_NOTIFY\r
+#define TPL_HIGH_LEVEL                                EFI_TPL_HIGH_LEVEL\r
+\r
+//\r
+// Typos in R8.x\r
+//\r
+#define gEfiHobMemoryAllocModuleGuid        gEfiHobMemeryAllocModuleGuid\r
+#define gEfiHobMemoryAllocStackGuid         gEfiHobMemeryAllocStackGuid\r
+#define gEfiHobMemoryAllocBspStoreGuid      gEfiHobMemeryAllocBspStoreGuid\r
+\r
+//\r
+// typedef Edk types - EdkII types\r
+//\r
+typedef PXE_CPB_START                                PXE_CPB_START_30;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h
new file mode 100644 (file)
index 0000000..0f2cadd
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDefinitionChangesDxe.h\r
+  \r
+Abstract: \r
+\r
+  Data structure definition changes from EDK to EDKII\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__\r
+#define __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__\r
+\r
+#include "EfiInternalFormRepresentation.h"\r
+\r
+#include "EdkIIGlueDefinitionChangesBase.h"\r
+\r
+#if (TIANO_RELEASE_VERSION <= 0x00080005)\r
+  #define gEfiStatusCodeRuntimeProtocolGuid         gEfiStatusCodeArchProtocolGuid\r
+#endif\r
+\r
+//\r
+// typedef Edk types - EdkII types\r
+//\r
+typedef EFI_MEMORY_ARRAY_START_ADDRESS               EFI_MEMORY_ARRAY_START_ADDRESS_DATA;\r
+typedef EFI_MEMORY_DEVICE_START_ADDRESS              EFI_MEMORY_DEVICE_START_ADDRESS_DATA;\r
+typedef EFI_MISC_LAST_PCI_BUS                        EFI_MISC_LAST_PCI_BUS_DATA;\r
+typedef EFI_MISC_BIOS_VENDOR                         EFI_MISC_BIOS_VENDOR_DATA;\r
+typedef EFI_MISC_SYSTEM_MANUFACTURER                 EFI_MISC_SYSTEM_MANUFACTURER_DATA;\r
+typedef EFI_MISC_BASE_BOARD_MANUFACTURER             EFI_MISC_BASE_BOARD_MANUFACTURER_DATA;\r
+typedef EFI_MISC_CHASSIS_MANUFACTURER                EFI_MISC_CHASSIS_MANUFACTURER_DATA;\r
+typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA;\r
+typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION             EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA;\r
+typedef EFI_MISC_ONBOARD_DEVICE                      EFI_MISC_ONBOARD_DEVICE_DATA;\r
+typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA            EFI_MISC_PORTING_DEVICE_TYPE_DATA;\r
+typedef EFI_MISC_OEM_STRING                          EFI_MISC_OEM_STRING_DATA;\r
+typedef EFI_MISC_SYSTEM_OPTION_STRING                EFI_MISC_SYSTEM_OPTION_STRING_DATA;\r
+typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES     EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA;\r
+typedef EFI_MISC_SYSTEM_LANGUAGE_STRING              EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA;\r
+typedef EFI_MISC_BIS_ENTRY_POINT                     EFI_MISC_BIS_ENTRY_POINT_DATA;\r
+typedef EFI_MISC_BOOT_INFORMATION_STATUS             EFI_MISC_BOOT_INFORMATION_STATUS_DATA;\r
+typedef EFI_MISC_SYSTEM_POWER_SUPPLY                 EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ;\r
+typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION         EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA;            \r
+\r
+// -------------------\r
+// EdkII Names - Edk Names\r
+// -------------------\r
+#define gEfiAcpiSupportProtocolGuid                   gEfiAcpiSupportGuid\r
+#define gEfiLoadPeImageProtocolGuid                   gEfiLoadPeImageGuid\r
+#define EFI_GLYPH_NON_SPACING                         GLYPH_NON_SPACING\r
+#define EFI_GLYPH_WIDE                                GLYPH_NON_BREAKING\r
+#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID        BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE\r
+#define EFI_EBC_PROTOCOL_GUID                         EFI_EBC_INTERPRETER_PROTOCOL_GUID\r
+#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID               EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID\r
+#define EFI_LOADED_IMAGE_PROTOCOL_REVISION            EFI_LOADED_IMAGE_INFORMATION_REVISION\r
+#define EFI_LOAD_FILE_PROTOCOL_GUID                   LOAD_FILE_PROTOCOL_GUID\r
+#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION           EFI_PXE_BASE_CODE_INTERFACE_REVISION\r
+#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION  EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION\r
+#define EFI_SERIAL_IO_PROTOCOL_REVISION               SERIAL_IO_INTERFACE_REVISION\r
+#define EFI_FILE_PROTOCOL_REVISION                    EFI_FILE_HANDLE_REVISION\r
+#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID           EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID\r
+\r
+\r
+//\r
+// typedef Edk types - EdkII types\r
+//\r
+typedef EFI_VOLUME_OPEN                              EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME;\r
+typedef EFI_TEXT_OUTPUT_STRING                       EFI_TEXT_STRING;\r
+typedef SCREEN_DESCRIPTOR                            EFI_SCREEN_DESCRIPTOR;\r
+typedef EFI_SIMPLE_TEXT_IN_PROTOCOL                  EFI_SIMPLE_TEXT_INPUT_PROTOCOL;\r
+typedef EFI_SIMPLE_TEXT_OUT_PROTOCOL                 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;\r
+//typedef EFI_TO_LEGACY16_INIT_TABLE                   EFI_TO_COMPATIBILITY16_INIT_TABLE;\r
+//typedef DISPATCH_OPROM_TABLE                         EFI_DISPATCH_OPROM_TABLE;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h
new file mode 100644 (file)
index 0000000..353fe36
--- /dev/null
@@ -0,0 +1,158 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDefinitionChangesPeim.h\r
+  \r
+Abstract: \r
+\r
+  Data structure definition changes from EDK to EDKII\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__\r
+#define __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__\r
+\r
+#include "EfiInternalFormRepresentation.h"\r
+\r
+#include "EdkIIGlueDefinitionChangesBase.h"\r
+#include "EfiPciCfg.h"\r
+\r
+//\r
+// typedef Edk types - EdkII types\r
+//\r
+typedef EFI_MEMORY_ARRAY_START_ADDRESS               EFI_MEMORY_ARRAY_START_ADDRESS_DATA;\r
+typedef EFI_MEMORY_DEVICE_START_ADDRESS              EFI_MEMORY_DEVICE_START_ADDRESS_DATA;\r
+typedef EFI_MISC_LAST_PCI_BUS                        EFI_MISC_LAST_PCI_BUS_DATA;\r
+typedef EFI_MISC_BIOS_VENDOR                         EFI_MISC_BIOS_VENDOR_DATA;\r
+typedef EFI_MISC_SYSTEM_MANUFACTURER                 EFI_MISC_SYSTEM_MANUFACTURER_DATA;\r
+typedef EFI_MISC_BASE_BOARD_MANUFACTURER             EFI_MISC_BASE_BOARD_MANUFACTURER_DATA;\r
+typedef EFI_MISC_CHASSIS_MANUFACTURER                EFI_MISC_CHASSIS_MANUFACTURER_DATA;\r
+typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA;\r
+typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION             EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA;\r
+typedef EFI_MISC_ONBOARD_DEVICE                      EFI_MISC_ONBOARD_DEVICE_DATA;\r
+typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA            EFI_MISC_PORTING_DEVICE_TYPE_DATA;\r
+typedef EFI_MISC_OEM_STRING                          EFI_MISC_OEM_STRING_DATA;\r
+typedef EFI_MISC_SYSTEM_OPTION_STRING                EFI_MISC_SYSTEM_OPTION_STRING_DATA;\r
+typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES     EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA;\r
+typedef EFI_MISC_SYSTEM_LANGUAGE_STRING              EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA;\r
+typedef EFI_MISC_BIS_ENTRY_POINT                     EFI_MISC_BIS_ENTRY_POINT_DATA;\r
+typedef EFI_MISC_BOOT_INFORMATION_STATUS             EFI_MISC_BOOT_INFORMATION_STATUS_DATA;\r
+typedef EFI_MISC_SYSTEM_POWER_SUPPLY                 EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ;\r
+typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION         EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA;            \r
+\r
+// -------------------\r
+// EdkII Names - Edk Names\r
+// -------------------\r
+#define gEfiPeiCpuIoPpiInServiceTableGuid             gPeiCpuIoPpiInServiceTableGuid   \r
+#define gEfiEndOfPeiSignalPpiGuid                     gEndOfPeiSignalPpiGuid           \r
+#define gEfiPeiFvFileLoaderPpiGuid                    gPeiFvFileLoaderPpiGuid          \r
+#define gEfiPeiMasterBootModePpiGuid                  gPeiMasterBootModePpiGuid        \r
+#define gEfiPeiMemoryDiscoveredPpiGuid                gPeiMemoryDiscoveredPpiGuid      \r
+#define gEfiPciCfgPpiInServiceTableGuid               gPeiPciCfgPpiInServiceTableGuid     \r
+#define gEfiPeiReadOnlyVariablePpiGuid                gPeiReadOnlyVariablePpiGuid      \r
+#define gEfiPeiRecoveryModulePpiGuid                  gPeiRecoveryModulePpiGuid        \r
+#define gEfiPeiResetPpiGuid                           gPeiResetPpiGuid                 \r
+#define gEfiPeiS3ResumePpiGuid                        gPeiS3ResumePpiGuid              \r
+#define gEfiPeiSectionExtractionPpiGuid               gPeiSectionExtractionPpiGuid     \r
+#define gEfiPeiSecurityPpiGuid                        gPeiSecurityPpiGuid              \r
+#define gEfiPeiStatusCodePpiGuid                      gPeiStatusCodePpiGuid            \r
+#define gEfiPeiBootScriptExecuterPpiGuid              gPeiBootScriptExecuterPpiGuid    \r
+#define gEfiPeiSmbusPpiGuid                           gPeiSmbusPpiGuid                 \r
+#define gEfiPeiBlockIoPpiGuid                         gPeiBlockIoPpiGuid               \r
+#define gEfiPeiDeviceRecoveryModulePpiGuid            gPeiDeviceRecoveryModulePpiGuid\r
+#define gEfiPeiStallPpiGuid                           gPeiStallPpiGuid                 \r
+#define gEfiPeiPciCfgPpiInServiceTableGuid            gPeiPciCfgPpiInServiceTableGuid\r
+#define gEfiPeiAtaControllerPpiGuid                   gPeiAtaControllerPpiGuid\r
+#define EFI_PEI_CPU_IO_PPI_INSTALLED_GUID             PEI_CPU_IO_PPI_GUID\r
+#define EFI_PEI_RESET_PPI_GUID                        PEI_RESET_PPI_GUID           \r
+#define EFI_PEI_PCI_CFG_PPI_INSTALLED_GUID            PEI_PCI_CFG_PPI_GUID\r
+#define EFI_PEI_REPORT_PROGRESS_CODE_PPI_GUID         PEI_STATUS_CODE_PPI_GUID\r
+#define EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI        PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI\r
+#define EFI_PEI_END_OF_PEI_PHASE_PPI_GUID             PEI_END_OF_PEI_PHASE_PPI_GUID\r
+#define EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI             PEI_MASTER_BOOT_MODE_PEIM_PPI\r
+#define EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID   PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID\r
+#define EFI_PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID    PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID\r
+#define EFI_PEI_RECOVERY_MODULE_PPI_GUID              PEI_RECOVERY_MODULE_INTERFACE_PPI\r
+#define EFI_PEI_S3_RESUME_PPI_GUID                    PEI_S3_RESUME_PPI_GUID\r
+#define EFI_PEI_SECURITY_PPI_GUID                     PEI_SECURITY_PPI_GUID\r
+#define EFI_PEI_STALL_PPI_GUID                        PEI_STALL_PPI_GUID\r
+#define EFI_PEI_SMBUS_PPI_GUID                        PEI_SMBUS_PPI_GUID\r
+#define EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID         PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID\r
+#define EFI_PEI_FIND_FV_PPI_GUID                      EFI_FIND_FV_PPI_GUID\r
+#define EFI_PEI_VIRTUAL_BLOCK_IO_PPI                  PEI_BLOCK_IO_PPI_GUID\r
+#define EFI_PEI_DEVICE_RECOVERY_MODULE_PPI_GUID       PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI\r
+\r
+\r
+//\r
+// typedef Edk types - EdkII types\r
+//\r
+typedef PEI_RECOVERY_MODULE_INTERFACE                EFI_PEI_RECOVERY_MODULE_PPI;\r
+typedef PEI_CPU_IO_PPI                               EFI_PEI_CPU_IO_PPI;\r
+typedef PEI_STALL_PPI                                EFI_PEI_STALL_PPI;\r
+typedef PEI_SMBUS_PPI                                EFI_PEI_SMBUS_PPI;\r
+typedef PEI_READ_ONLY_VARIABLE_PPI                   EFI_PEI_READ_ONLY_VARIABLE_PPI;\r
+typedef PEI_PCI_CFG_PPI                              EFI_PEI_PCI_CFG_PPI;\r
+typedef PEI_STATUS_CODE_PPI                          EFI_PEI_PROGRESS_CODE_PPI;\r
+typedef PEI_CPU_IO_PPI_WIDTH                         EFI_PEI_CPU_IO_PPI_WIDTH;\r
+typedef PEI_CPU_IO_PPI_IO_MEM                        EFI_PEI_CPU_IO_PPI_IO_MEM;\r
+typedef PEI_CPU_IO_PPI_ACCESS                        EFI_PEI_CPU_IO_PPI_ACCESS;\r
+typedef PEI_CPU_IO_PPI_IO_READ8                      EFI_PEI_CPU_IO_PPI_IO_READ8;\r
+typedef PEI_CPU_IO_PPI_IO_READ16                     EFI_PEI_CPU_IO_PPI_IO_READ16;\r
+typedef PEI_CPU_IO_PPI_IO_READ32                     EFI_PEI_CPU_IO_PPI_IO_READ32;\r
+typedef PEI_CPU_IO_PPI_IO_READ64                     EFI_PEI_CPU_IO_PPI_IO_READ64;\r
+typedef PEI_CPU_IO_PPI_IO_WRITE8                     EFI_PEI_CPU_IO_PPI_IO_WRITE8;\r
+typedef PEI_CPU_IO_PPI_IO_WRITE16                    EFI_PEI_CPU_IO_PPI_IO_WRITE16;\r
+typedef PEI_CPU_IO_PPI_IO_WRITE32                    EFI_PEI_CPU_IO_PPI_IO_WRITE32;\r
+typedef PEI_CPU_IO_PPI_IO_WRITE64                    EFI_PEI_CPU_IO_PPI_IO_WRITE64;\r
+typedef PEI_CPU_IO_PPI_MEM_READ8                     EFI_PEI_CPU_IO_PPI_MEM_READ8;\r
+typedef PEI_CPU_IO_PPI_MEM_READ16                    EFI_PEI_CPU_IO_PPI_MEM_READ16;\r
+typedef PEI_CPU_IO_PPI_MEM_READ32                    EFI_PEI_CPU_IO_PPI_MEM_READ32;\r
+typedef PEI_CPU_IO_PPI_MEM_READ64                    EFI_PEI_CPU_IO_PPI_MEM_READ64;\r
+typedef PEI_CPU_IO_PPI_MEM_WRITE8                    EFI_PEI_CPU_IO_PPI_MEM_WRITE8;\r
+typedef PEI_CPU_IO_PPI_MEM_WRITE16                   EFI_PEI_CPU_IO_PPI_MEM_WRITE16;\r
+typedef PEI_CPU_IO_PPI_MEM_WRITE32                   EFI_PEI_CPU_IO_PPI_MEM_WRITE32;\r
+typedef PEI_CPU_IO_PPI_MEM_WRITE64                   EFI_PEI_CPU_IO_PPI_MEM_WRITE64;\r
+typedef PEI_GET_VARIABLE                             EFI_PEI_GET_VARIABLE;\r
+typedef PEI_GET_NEXT_VARIABLE_NAME                   EFI_PEI_GET_NEXT_VARIABLE_NAME;\r
+typedef PEI_LOAD_RECOVERY_CAPSULE                    EFI_PEI_LOAD_RECOVERY_CAPSULE;\r
+typedef PEI_RESET_PPI                                EFI_PEI_RESET_PPI;\r
+typedef PEI_S3_RESUME_PPI                            EFI_PEI_S3_RESUME_PPI;\r
+typedef PEI_S3_RESUME_PPI_RESTORE_CONFIG             EFI_PEI_S3_RESUME_PPI_RESTORE_CONFIG;\r
+typedef SEC_PLATFORM_INFORMATION                     EFI_SEC_PLATFORM_INFORMATION;\r
+typedef PEI_SECURITY_PPI                             EFI_PEI_SECURITY_PPI;\r
+typedef PEI_SECURITY_AUTHENTICATION_STATE            EFI_PEI_SECURITY_AUTHENTICATION_STATE;\r
+typedef PEI_STALL                                    EFI_PEI_STALL;\r
+typedef PEI_SMBUS_PPI_EXECUTE_OPERATION              EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION;     \r
+typedef PEI_SMBUS_NOTIFY_FUNCTION                    EFI_PEI_SMBUS_NOTIFY_FUNCTION;           \r
+typedef PEI_SMBUS_PPI_ARP_DEVICE                     EFI_PEI_SMBUS_PPI_ARP_DEVICE;            \r
+typedef PEI_SMBUS_PPI_GET_ARP_MAP                    EFI_PEI_SMBUS_PPI_GET_ARP_MAP;           \r
+typedef PEI_SMBUS_PPI_NOTIFY                         EFI_PEI_SMBUS_PPI_NOTIFY;                \r
+typedef PEI_BOOT_SCRIPT_EXECUTE                      EFI_PEI_BOOT_SCRIPT_EXECUTE;       \r
+typedef PEI_BOOT_SCRIPT_EXECUTER_PPI                 EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI;  \r
+typedef EFI_FIND_FV_FINDFV                           EFI_PEI_FIND_FV_FINDFV;                    \r
+typedef EFI_FIND_FV_PPI                              EFI_PEI_FIND_FV_PPI;                       \r
+typedef PEI_RECOVERY_BLOCK_IO_INTERFACE              EFI_PEI_RECOVERY_BLOCK_IO_PPI;             \r
+typedef PEI_LBA                                      EFI_PEI_LBA;                               \r
+typedef PEI_BLOCK_IO_MEDIA                           EFI_PEI_BLOCK_IO_MEDIA;                    \r
+typedef PEI_BLOCK_DEVICE_TYPE                        EFI_PEI_BLOCK_DEVICE_TYPE;                 \r
+typedef PEI_GET_NUMBER_BLOCK_DEVICES                 EFI_PEI_GET_NUMBER_BLOCK_DEVICES;          \r
+typedef PEI_GET_DEVICE_MEDIA_INFORMATION             EFI_PEI_GET_DEVICE_MEDIA_INFORMATION;      \r
+typedef PEI_READ_BLOCKS                              EFI_PEI_READ_BLOCKS;                       \r
+typedef PEI_DEVICE_RECOVERY_MODULE_INTERFACE         EFI_PEI_DEVICE_RECOVERY_MODULE_PPI;        \r
+typedef PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE       EFI_PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE;\r
+typedef PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO         EFI_PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO;  \r
+typedef PEI_DEVICE_LOAD_RECOVERY_CAPSULE             EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE;      \r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
new file mode 100644 (file)
index 0000000..1f59b35
--- /dev/null
@@ -0,0 +1,777 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDepedencies.h\r
+\r
+Abstract:\r
+\r
+  Header file that lists dependency relations among library instances\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEPENDENCIES_H__\r
+#define __EDKII_GLUE_DEPENDENCIES_H__\r
+\r
+#include "EdkIIGlueProcessorBind.h"\r
+\r
+//\r
+// Declarations of dependencies among EdkII Glue Library instances and R8 Libraries\r
+// Pay attention to the order of following #define structures\r
+//\r
+\r
+\r
+//\r
+// PeiDxeDebugLibReportStatusCode\r
+// Actually almost every module and GlueLib instance needs this library, but GlueLib\r
+// instances don't have to list this library in their own inf files. Module inf\r
+// does this.\r
+//\r
+#ifdef __EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+//  BaseDebugLibNull\r
+//\r
+#ifdef __EDKII_GLUE_BASE_DEBUG_LIB_NULL__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_PRINT_LIB__\r
+  #define __EDKII_GLUE_BASE_PRINT_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// EdkDxeRuntimeDriverLib\r
+//\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+  #ifndef __EDKII_GLUE_UEFI_LIB__\r
+  #define __EDKII_GLUE_UEFI_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#ifdef MDE_CPU_IPF // IPF\r
+  #ifndef __EDKII_GLUE_EDK_DXE_SAL_LIB__\r
+  #define __EDKII_GLUE_EDK_DXE_SAL_LIB__\r
+  #endif\r
+#endif // IPF\r
+#endif\r
+\r
+//\r
+//  EdkDxeSalLib\r
+//\r
+#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BasePciLibCf8\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PCI_LIB_CF8__\r
+  #ifndef __EDKII_GLUE_BASE_PCI_CF8_LIB__\r
+  #define __EDKII_GLUE_BASE_PCI_CF8_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BasePciLibPciExpress\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__\r
+  #ifndef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__\r
+  #define __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BasePciCf8Lib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PCI_CF8_LIB__\r
+#ifndef MDE_CPU_EBC\r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif  \r
+#endif\r
+\r
+//\r
+// BasePciExpressLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__\r
+#ifndef MDE_CPU_EBC\r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif\r
+#endif\r
+\r
+//\r
+// BaseTimerLibLocalApic\r
+//\r
+#ifdef __EDKII_GLUE_BASE_TIMER_LIB_LOCAL_APIC__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#ifndef MDE_CPU_EBC  \r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif  \r
+#endif\r
+\r
+//\r
+// DxeReportStatusCodeLib\r
+//\r
+#ifdef  __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#ifndef MDE_CPU_EBC\r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif  \r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// PeiReportStatusCodeLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#ifndef MDE_CPU_EBC  \r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif  \r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)  \r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #endif\r
+#elif defined(MDE_CPU_IPF)\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #endif\r
+#endif  \r
+  //\r
+  //  If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or\r
+  //  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be\r
+  //  replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+  //\r
+#endif\r
+\r
+//\r
+// BasePeCoffLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PE_COFF_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BaseUefiDecompressLib\r
+//\r
+#ifdef  __EDKII_GLUE_BASE_UEFI_DECOMPRESS_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// DxeHobLib\r
+//\r
+#ifdef  __EDKII_GLUE_DXE_HOB_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_LIB__\r
+  #define __EDKII_GLUE_UEFI_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// HiiLib\r
+//\r
+#ifdef  __EDKII_GLUE_HII_LIB__\r
+  #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// UefiDevicePathLib\r
+//\r
+#ifdef  __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// UefiLib\r
+//\r
+#ifdef  __EDKII_GLUE_UEFI_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// DxeMemoryAllocationLib\r
+//\r
+#ifdef  __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// DxeSmbusLib\r
+//\r
+#ifdef  __EDKII_GLUE_DXE_SMBUS_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// PeiHobLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_HOB_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__\r
+  #define __EDKII_GLUE_PEI_SERVICES_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// PeiMemoryAllocationLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)  \r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #endif\r
+#elif defined(MDE_CPU_IPF)\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #endif\r
+#endif  \r
+  //\r
+  //  If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or\r
+  //  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be\r
+  //  replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+  //\r
+#endif\r
+\r
+//\r
+// PeiResourcePublicationLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_RESOURCE_PUBLICATION_LIB__\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__\r
+  #define __EDKII_GLUE_PEI_SERVICES_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// PeiServicesLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_SERVICES_LIB__\r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)  \r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #endif\r
+#elif defined(MDE_CPU_IPF)\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #endif\r
+#endif  \r
+  //\r
+  //  If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or\r
+  //  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be\r
+  //  replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+  //\r
+#endif\r
+\r
+//\r
+// PeiSmbusLib\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_SMBUS_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #define __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #endif\r
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)  \r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #endif\r
+#elif defined(MDE_CPU_IPF)\r
+  #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #endif\r
+#endif  \r
+  //\r
+  //  If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or\r
+  //  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be\r
+  //  replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+  //\r
+#endif\r
+\r
+//\r
+// PeiServicesTablePointerLibMm7\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// PeiServicesTablePointerLibKr1\r
+//\r
+#ifdef  __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+\r
+//\r
+// UefiDriverModelLib\r
+//\r
+#ifdef  __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// DxeServicesTableLib\r
+//\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+  #ifndef __EDKII_GLUE_UEFI_LIB__\r
+  #define __EDKII_GLUE_UEFI_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BasePrintLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PRINT_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BaseMemoryLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_MEMORY_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BasePostCodeLibPort80\r
+//\r
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__\r
+#ifndef MDE_CPU_EBC\r
+  #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #endif\r
+#else\r
+  #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #endif\r
+#endif  \r
+#endif\r
+\r
+//\r
+// BaseIoLibIntrinsic\r
+//\r
+#ifdef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// DxeIoLibCpuIo\r
+//\r
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+  #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// UefiBootServicesTableLib\r
+//\r
+#ifdef  __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+#endif\r
+\r
+//\r
+// BaseCacheMaintenanceLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_CACHE_MAINTENANCE_LIB__\r
+  #ifndef __EDKII_GLUE_BASE_LIB__\r
+  #define __EDKII_GLUE_BASE_LIB__\r
+  #endif\r
+#endif\r
+\r
+//\r
+// BaseLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_LIB__\r
+#endif\r
+\r
+//\r
+// UefiRuntimeServicesTableLib\r
+//\r
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+#endif\r
+\r
+//\r
+// BasePeCoffGetEntryPointLib\r
+//\r
+#ifdef __EDKII_GLUE_BASE_PE_COFF_GET_ENTRY_POINT_LIB__\r
+#endif\r
+\r
+//\r
+// PeiServicesTablePointerLib\r
+//\r
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+#endif\r
+\r
+//\r
+// BasePostCodeLibDebug\r
+//\r
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__\r
+  //\r
+  // A DebugLib instance\r
+  // Usually EdkIIGluePeiDxeDebugLibReportStatusCodeLib is listed in module inf\r
+  //\r
+#endif\r
+\r
+//\r
+// PeiDxePostCodeLibReportStatusCode\r
+//\r
+#ifdef __EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__\r
+  //\r
+  // PEI or DXE ReportStatusCodeLib instance\r
+  // Usually EdkIIGluePei/DxeReportStatusCodeLib is listed in module inf\r
+  //\r
+#endif\r
+\r
+\r
+//\r
+// Check against multiple instances of same library class being used\r
+//\r
+#if defined(__EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__)\r
+  #error EdkIIGluePeiDxeDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__) && defined(__EDKII_GLUE_BASE_PCI_LIB_CF8__)\r
+  #error EdkIIGluePciLibPciExpress and EdkIIGluePciLibCf8: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined (__EDKII_GLUE_DXE_HOB_LIB__) && (__EDKII_GLUE_PEI_HOB_LIB__)\r
+  #error EdkIIGlueDxeHobLib and EdkIIGluePeiHobLib: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__)\r
+  #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGlueBasePostCodeLibDebug: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__)\r
+  #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__)\r
+  #error EdkIIGlueBasePostCodeLibDebug and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__)\r
+  #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibMm7: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__)\r
+  #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibKr1: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__)\r
+  #error EdkIIGluePeiServicesTablePointerLibMm7 and EdkIIGluePeiServicesTablePointerLibKr1: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__)\r
+  #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__) && defined(__EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__)\r
+  #error EdkIIGlueDxeMemoryAllocationLib and EdkIIGluePeiMemoryAllocationLib: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DXE_SMBUS_LIB__) && defined(__EDKII_GLUE_PEI_SMBUS_LIB__)\r
+  #error EdkIIGlueDxeSmbusLib and EdkIIGluePeiSmbusLib: can only be mutual exclusively used.\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_BASE_IO_LIB_INTRINSIC__) && defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__)\r
+  #error EdkIIGlueBaseIoLibIntrinsic and EdkIIGlueDxeIoLibCpuIo: can only be mutual exclusively used.\r
+#endif\r
+\r
+//\r
+// Some instances must be supplied\r
+//\r
+#ifdef __EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__\r
+  #if !defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && !defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__)\r
+    #error You use EdkIIGluePeiDxeDebugLibReportStatusCode, so either EdkIIGlueDxeReportStatusCodeLib or EdkIIGluePeiReportStatusCodeLib must be supplied\r
+  #endif\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__\r
+  #if !defined(__EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && !defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__)\r
+    #error You use EdkIIGlueBasePostCodeLibDebug, so either EdkIIGluePeiDxeDebugLibReportStatusCode or EdkIIGlueBaseDebugLibNull must be supplied\r
+  #endif\r
+#endif\r
+\r
+//\r
+//  EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined\r
+//\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+  #ifndef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__\r
+    #error "EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined. Please define __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__."\r
+  #endif\r
+#endif\r
+\r
+//\r
+// EdkII Glue Library Constructors:\r
+// NOTE: the constructors must be called according to dependency order\r
+//\r
+// UefiBootServicesTableLib         UefiBootServicesTableLibConstructor()\r
+// DxeIoLibCpuIo                    IoLibConstructor()\r
+// UefiRuntimeServicesTableLib      UefiRuntimeServicesTableLibConstructor()\r
+// EdkDxeRuntimeDriverLib           RuntimeDriverLibConstruct()\r
+// DxeHobLib                        HobLibConstructor()\r
+// UefiDriverModelLib               UefiDriverModelLibConstructor()\r
+// PeiServicesTablePointerLib       PeiServicesTablePointerLibConstructor()\r
+// PeiServicesTablePointerLibMm7    PeiServicesTablePointerLibConstructor()\r
+// PeiServicesTablePointerLibKr1    PeiServicesTablePointerLibConstructor()\r
+// DxeSmbusLib                      SmbusLibConstructor()\r
+// DxeServicesTableLib              DxeServicesTableLibConstructor()\r
+// DxeSalLib                        DxeSalLibConstructor()\r
+//\r
+\r
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
+EFI_STATUS\r
+UefiBootServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+EFI_STATUS\r
+EFIAPI\r
+IoLibConstructor (\r
+  IN      EFI_HANDLE                ImageHandle,\r
+  IN      EFI_SYSTEM_TABLE          *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+EFI_STATUS\r
+UefiRuntimeServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+EFI_STATUS\r
+RuntimeDriverLibConstruct (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__\r
+EFI_STATUS\r
+HobLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+EFI_STATUS\r
+UefiDriverModelLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__\r
+EFI_STATUS\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__\r
+EFI_STATUS\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__\r
+EFI_STATUS\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__\r
+EFI_STATUS\r
+EFIAPI\r
+SmbusLibConstructor (\r
+  IN EFI_HANDLE                ImageHandle,\r
+  IN EFI_SYSTEM_TABLE          *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+EFI_STATUS\r
+DxeServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__\r
+EFI_STATUS\r
+EFIAPI\r
+DxeSalLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+//\r
+// EdkII Glue Library Destructors:\r
+// NOTE: the destructors must be called according to dependency order\r
+//\r
+// UefiDriverModelLibDestructor    UefiDriverModelLibDestructor()\r
+// EdkDxeRuntimeDriverLib          RuntimeDriverLibDeconstruct()\r
+//\r
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__\r
+EFI_STATUS\r
+UefiDriverModelLibDestructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\r
+EFI_STATUS\r
+RuntimeDriverLibDeconstruct (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h
new file mode 100644 (file)
index 0000000..0a63106
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DxeDepex.h\r
+  \r
+Abstract: \r
+\r
+  This file is used by .dxs file. To write common .dxs for R8.x and R9, a \r
+  header file named DxeDepex.h musted be present. \r
+\r
+--*/\r
+\r
+\r
+#ifndef __EDKII_GLUELIB_DXEDEPEX_H__\r
+#define __EDKII_GLUELIB_DXEDEPEX_H__\r
+\r
+\r
+//\r
+//  this file is used by .dxs file, just a place holder\r
+//\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h
new file mode 100644 (file)
index 0000000..a96b57f
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueProcessorBind.h\r
+  \r
+Abstract: \r
+\r
+  Processor specific definitions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__\r
+#define __EDKII_GLUE_PROCESSOR_BIND_H__\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#ifndef MDE_CPU_EBC\r
+  #define MDE_CPU_EBC\r
+#endif   \r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h
new file mode 100644 (file)
index 0000000..605c845
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueBase.h\r
+  \r
+Abstract: \r
+\r
+  Root include file for Base modules\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_BASE_H__\r
+#define __EDKII_GLUE_BASE_H__\r
+\r
+//\r
+// Using this header means building with EdkIIGlueLib\r
+//\r
+#ifndef BUILD_WITH_EDKII_GLUE_LIB\r
+  #define BUILD_WITH_EDKII_GLUE_LIB\r
+#endif\r
+\r
+//\r
+// General Type & API definitions\r
+//\r
+\r
+#include "EfiBind.h"\r
+#include "EfiTypes.h"\r
+#include "EfiError.h"\r
+#include "Common\EdkIIGlueBaseTypes.h"\r
+#include "EfiImage.h"\r
+#include "EfiPeOptionalHeader.h"\r
+#include "EfiStdArg.h"\r
+#include "EfiDebug.h"\r
+#include "EdkIIGlueProcessorBind.h"\r
+\r
+//\r
+// Some Status Code data type definitions are in TianoSpecTypes.h in R8.5\r
+//\r
+#if (TIANO_RELEASE_VERSION <= 0x00080005)\r
+#include "TianoSpecTypes.h"\r
+#endif\r
+#include "EfiStatusCode.h"\r
+\r
+//\r
+// R8.x Library headers used by EdkII Glue Libraries\r
+//\r
+#include "LinkedList.h"\r
+#include "EfiCommonLib.h"\r
+\r
+#include "Common\EdkIIGlueDefinitionChangesBase.h"\r
+\r
+//\r
+// EdkII Glue Library Class headers\r
+//\r
+\r
+#include "Library\EdkIIGlueBaseLib.h"\r
+#include "Library\EdkIIGlueBaseMemoryLib.h"\r
+#include "Library\EdkIIGlueCacheMaintenanceLib.h"\r
+#include "Library\EdkIIGlueIoLib.h"\r
+#include "Library\EdkIIGluePciCf8Lib.h"\r
+#include "Library\EdkIIGluePciExpressLib.h"\r
+#include "Library\EdkIIGluePciLib.h"\r
+#include "Library\EdkIIGluePeCoffGetEntryPointLib.h"\r
+#include "Library\EdkIIGluePeCoffLib.h"\r
+#include "Library\EdkIIGluePostCodeLib.h"\r
+#include "Library\EdkIIGluePrintLib.h"\r
+#include "Library\EdkIIGlueTimerLib.h"\r
+#include "Library\EdkIIGlueUefiDecompressLib.h"\r
+#include "Library\EdkIIGlueDebugLib.h"\r
+\r
+//\r
+// Publish MDE Library PCDs\r
+//\r
+#include "Pcd\EdkIIGluePcdBaseLib.h"\r
+#include "Pcd\EdkIIGluePcdDebugLib.h"\r
+#include "Pcd\EdkIIGluePcdIoLib.h"\r
+#include "Pcd\EdkIIGluePcdPciExpressLib.h"\r
+#include "Pcd\EdkIIGluePcdPostCodeLib.h"\r
+#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h"\r
+#include "Pcd\EdkIIGluePcdTimerLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
new file mode 100644 (file)
index 0000000..6bbcfee
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueConfig.h\r
+  \r
+Abstract: \r
+\r
+  Configurable items provided by GlueLib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_CONFIG_H__\r
+#define __EDKII_GLUE_CONFIG_H__\r
+\r
+#include "EdkIIGlueProcessorBind.h"\r
+\r
+//\r
+//  Glue Library version\r
+//\r
+//  0x3000  - the 3rd release\r
+//  0x5000  - support IPF. Jan, 2007\r
+//  0x6000  - support EBC. Feb, 2007\r
+//\r
+//  For reference only, don't change the value\r
+//\r
+#define EDKII_GLUE_LIBRARY_VERSION 0x6000\r
+\r
+\r
+//\r
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
+//\r
+#if !defined(EFI_SPECIFICATION_VERSION)\r
+  #error EFI_SPECIFICATION_VERSION not defined\r
+#elif !defined(TIANO_RELEASE_VERSION)\r
+  #error TIANO_RELEASE_VERSION not defined\r
+#elif (TIANO_RELEASE_VERSION == 0)\r
+  #error TIANO_RELEASE_VERSION can not be zero\r
+#endif\r
+\r
+\r
+//\r
+//  Glue Library debug flag\r
+//\r
+//  Controls debug ON/OFF of GlueLib itself, no\r
+//  effect on any other libraries or modules\r
+//\r
+//  Values:\r
+//    FALSE           : debug off\r
+//    any TRUE value  : debug on\r
+//\r
+#define EDKII_GLUE_LIBRARY_DEBUG_ENABLE  0\r
+\r
+\r
+//\r
+// max unicode string length\r
+//\r
+#define EDKII_GLUE_MaximumUnicodeStringLength   1000000\r
+\r
+//\r
+// max ascii string length\r
+//\r
+#define EDKII_GLUE_MaximumAsciiStringLength     1000000\r
+\r
+//\r
+// spin lock timeout\r
+//\r
+#define EDKII_GLUE_SpinLockTimeout              10000000\r
+\r
+//\r
+// max linked list length\r
+//\r
+#define EDKII_GLUE_MaximumLinkedListLength      1000000\r
+\r
+//\r
+// debug print level\r
+// only when EFI_DEBUG is defined, the mask is effective\r
+//\r
+#define EDKII_GLUE_DebugPrintErrorLevel         EFI_D_ERROR\r
+\r
+//\r
+// debug propery mask\r
+// only when EFI_DEBUG is defined, the mask is effective\r
+//\r
+#define EDKII_GLUE_DebugPropertyMask            (  DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED                \\r
+                                                   | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED               \\r
+                                                   | DEBUG_PROPERTY_DEBUG_CODE_ENABLED                \\r
+                                                   | DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED              \\r
+                                                   | DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED         \\r
+                                                   | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED           \\r
+                                                )\r
+\r
+//\r
+// clear memory value\r
+//\r
+#define EDKII_GLUE_DebugClearMemoryValue        0xAF\r
+\r
+//\r
+// pci express base address\r
+//\r
+#define EDKII_GLUE_PciExpressBaseAddress        0xE0000000\r
+\r
+//\r
+//\r
+// This value is FSB Clock frequency. Its unit is Hz and its \r
+// default value is 200000000, that means FSB frequency is 200Mhz.\r
+//\r
+#define EDKII_GLUE_FSBClock                  200000000\r
+\r
+//\r
+// post code property mask\r
+//\r
+#define EDKII_GLUE_PostCodePropertyMask         (  POST_CODE_PROPERTY_POST_CODE_ENABLED               \\r
+                                                   | POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED \\r
+                                                )\r
+\r
+//\r
+// status code property mask\r
+//\r
+#define EDKII_GLUE_ReportStatusCodePropertyMask (  REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED  \\r
+                                                   | REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED   \\r
+                                                   | REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED   \\r
+                                                )\r
+\r
+\r
+//\r
+// for IPF only\r
+// The base address of IPF IO Block\r
+//\r
+#ifdef MDE_CPU_IPF\r
+#define EDKII_GLUE_IoBlockBaseAddressForIpf     0x0ffffc000000\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h
new file mode 100644 (file)
index 0000000..8aa355e
--- /dev/null
@@ -0,0 +1,251 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxe.h\r
+  \r
+Abstract: \r
+\r
+  Root include file for DXE modules\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DXE_H__\r
+#define __EDKII_GLUE_DXE_H__\r
+\r
+\r
+//\r
+// General Type & API definitions\r
+//\r
+\r
+#include "Tiano.h"\r
+#include "BootMode.h"\r
+#include "EfiBootScript.h"\r
+#include "EfiCapsule.h"\r
+#include "EfiDependency.h"\r
+#include "EfiImageFormat.h"\r
+#include "EfiImage.h"\r
+#include "EfiPeOptionalHeader.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "PeiHob.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "EfiStatusCode.h"\r
+\r
+//\r
+// IPF only\r
+//\r
+#ifdef MDE_CPU_IPF\r
+#include "SalApi.h"\r
+#endif\r
+\r
+//\r
+// GUID definitions\r
+//\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#include EFI_GUID_DEFINITION (EventGroup)\r
+#include EFI_GUID_DEFINITION (EventLegacybios)\r
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
+\r
+#include EFI_PROTOCOL_DEFINITION (EdidActive)\r
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)\r
+#include EFI_PROTOCOL_DEFINITION (EdidOverride)  \r
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)  \r
+#include EFI_PROTOCOL_DEFINITION (Hash)  \r
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt)  \r
+#include EFI_PROTOCOL_DEFINITION (TapeIo)\r
+#endif\r
+\r
+#include EFI_GUID_DEFINITION (Acpi)\r
+#include EFI_GUID_DEFINITION (AcpiTableStorage)\r
+#include EFI_GUID_DEFINITION (Apriori)\r
+#include EFI_GUID_DEFINITION (Capsule)\r
+#include EFI_GUID_DEFINITION (DataHubRecords)\r
+#include EFI_GUID_DEFINITION (DebugImageInfoTable)\r
+#include EFI_GUID_DEFINITION (DxeServices)\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
+#include EFI_GUID_DEFINITION (GlobalVariable)\r
+#include EFI_GUID_DEFINITION (Gpt)\r
+#include EFI_GUID_DEFINITION (Hob)\r
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)\r
+#include EFI_GUID_DEFINITION (Mps)\r
+#include EFI_GUID_DEFINITION (PcAnsi)\r
+#include EFI_GUID_DEFINITION (SalSystemTable)\r
+#include EFI_GUID_DEFINITION (Smbios)\r
+//#include EFI_GUID_DEFINITION (SmmCommunicate)\r
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)\r
+//\r
+// *** NOTE ***: StatusCodeDataTypeId definition differences need to be \r
+// resolved when porting a module to real EDK II\r
+//\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+//\r
+// Protocol definitions\r
+//\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathFromText)\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathToText)\r
+#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities)\r
+#include EFI_PROTOCOL_DEFINITION (Dhcp4)\r
+#include EFI_PROTOCOL_DEFINITION (Ip4)\r
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)\r
+#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName)\r
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)\r
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)\r
+#include EFI_PROTOCOL_DEFINITION (Mtftp4)\r
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)\r
+#include EFI_PROTOCOL_DEFINITION (Tcp4)\r
+#include EFI_PROTOCOL_DEFINITION (Udp4)\r
+#include EFI_PROTOCOL_DEFINITION (Arp)\r
+// check here: currently not implementated\r
+//#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo)\r
+#endif\r
+\r
+#include EFI_PROTOCOL_DEFINITION (AcpiSupport)\r
+#include EFI_PROTOCOL_DEFINITION (Bis)\r
+#include EFI_PROTOCOL_DEFINITION (BlockIo)\r
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)\r
+#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride)\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName)\r
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+#include EFI_PROTOCOL_DEFINITION (DataHub)\r
+#include EFI_PROTOCOL_DEFINITION (DebugPort)\r
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)\r
+#include EFI_PROTOCOL_DEFINITION (Decompress)\r
+#include EFI_PROTOCOL_DEFINITION (DeviceIo)\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath) \r
+#include EFI_PROTOCOL_DEFINITION (DiskIo)\r
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)\r
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)\r
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)\r
+#include EFI_PROTOCOL_DEFINITION (Ebc)\r
+#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier)\r
+#include EFI_PROTOCOL_DEFINITION (FileInfo)\r
+#include EFI_PROTOCOL_DEFINITION (FileSystemInfo)\r
+#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)\r
+#include EFI_PROTOCOL_DEFINITION (FormCallback)\r
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+#include EFI_PROTOCOL_DEFINITION (IdeControllerInit)\r
+#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport)\r
+#include EFI_PROTOCOL_DEFINITION (Legacy8259)\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform)\r
+#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt)\r
+#include EFI_PROTOCOL_DEFINITION (LegacyRegion)\r
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)\r
+#include EFI_PROTOCOL_DEFINITION (LoadFile)\r
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)\r
+#include EFI_PROTOCOL_DEFINITION (PciHotplugInit)\r
+#include EFI_PROTOCOL_DEFINITION (PciIo)\r
+#include EFI_PROTOCOL_DEFINITION (PciPlatform)\r
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)\r
+#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)\r
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCode)\r
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)\r
+#include EFI_PROTOCOL_DEFINITION (ScsiIo)\r
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThru)\r
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)\r
+#include EFI_PROTOCOL_DEFINITION (SerialIo)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleFilesystem)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)\r
+#include EFI_PROTOCOL_DEFINITION (SimplePointer)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)\r
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)\r
+#include EFI_PROTOCOL_DEFINITION (Smbus)\r
+#include EFI_PROTOCOL_DEFINITION (SmmAccess)\r
+#include EFI_PROTOCOL_DEFINITION (SmmBase)\r
+#include EFI_PROTOCOL_DEFINITION (SmmControl)\r
+#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)\r
+#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch)\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation)\r
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)\r
+#include EFI_PROTOCOL_DEFINITION (UsbIo)\r
+#include EFI_PROTOCOL_DEFINITION (SecurityPolicy)\r
+#include EFI_PROTOCOL_DEFINITION (LoadPe32Image)\r
+\r
+//\r
+// Arch Protocol definitions\r
+//\r
+\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Bds)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Monotoniccounter)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Reset)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Security)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Timer)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variablewrite)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer)\r
+\r
+//\r
+// IPF only\r
+//\r
+#ifdef MDE_CPU_IPF\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+#endif\r
+\r
+//\r
+// R8.x Library headers used by EdkII Glue Libraries\r
+//\r
+#include "EfiDriverLib.h"\r
+#include "EfiCapsule.h"\r
+\r
+#include "Common\EdkIIGlueDefinitionChangesDxe.h"\r
+\r
+\r
+//\r
+// EdkII Glue Library Class headers\r
+//\r
+\r
+#include "EdkIIGlueBase.h"\r
+#include "Library\EdkIIGlueDebugLib.h"\r
+#include "Library\EdkIIGluePostCodeLib.h"\r
+#include "Library\EdkIIGlueReportStatusCodeLib.h"\r
+#include "Library\EdkIIGlueHiiLib.h"\r
+#include "Library\EdkIIGlueHobLib.h"\r
+#include "Library\EdkIIGlueMemoryAllocationLib.h"\r
+#include "Library\EdkIIGlueSmbusLib.h"\r
+#include "Library\EdkIIGlueDxeRuntimeDriverLib.h"\r
+#include "Library\EdkIIGlueDxeServicesTableLib.h"\r
+#include "Library\EdkIIGlueDxeSmmDriverEntryPoint.h"\r
+#include "Library\EdkIIGlueDevicePathLib.h"\r
+#include "Library\EdkIIGlueUefiLib.h"\r
+#include "Library\EdkIIGlueUefiDecompressLib.h"\r
+#include "Library\EdkIIGlueUefiDriverModelLib.h"\r
+#include "Library\EdkIIGlueUefiBootServicesTableLib.h"\r
+#include "Library\EdkIIGlueUefiDriverEntryPoint.h"\r
+#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h
new file mode 100644 (file)
index 0000000..617364f
--- /dev/null
@@ -0,0 +1,113 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeim.h\r
+  \r
+Abstract: \r
+\r
+  Root include file for PEI Modules\r
+\r
+**/\r
+\r
+\r
+#ifndef __EDKII_GLUE_PEIM_H__\r
+#define __EDKII_GLUE_PEIM_H__\r
+\r
+\r
+//\r
+// Check to make sure TIANO_RELEASE_VERSION is defined\r
+//\r
+#if !defined(TIANO_RELEASE_VERSION)\r
+  #error TIANO_RELEASE_VERSION not defined\r
+#elif (TIANO_RELEASE_VERSION == 0)\r
+  #error TIANO_RELEASE_VERSION can not be zero\r
+#endif\r
+\r
+//\r
+// General Type & API definitions\r
+//\r
+\r
+#include "Pei.h"\r
+#include "EfiBootScript.h"\r
+#include "EfiImage.h"\r
+#include "EfiPeOptionalHeader.h"\r
+#include "EfiCapsule.h"\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+#include "TianoDevicePath.h"\r
+\r
+//\r
+// GUID definitions\r
+//\r
+\r
+#include EFI_GUID_DEFINITION (Apriori)\r
+#include EFI_GUID_DEFINITION (Capsule)\r
+#include EFI_GUID_DEFINITION (DxeServices)\r
+#include EFI_GUID_DEFINITION (Hob)\r
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)\r
+#include EFI_GUID_DEFINITION (DataHubRecords)\r
+//\r
+// *** NOTE ***: StatusCodeDataTypeId definition differences need to be \r
+// resolved when porting a module to real EDK II\r
+//\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+//\r
+// Ppi definitions\r
+//\r
+\r
+#include EFI_PPI_DEFINITION (BlockIo)\r
+#include EFI_PPI_DEFINITION (BootInRecoveryMode)\r
+#include EFI_PPI_DEFINITION (BootScriptExecuter)\r
+#include EFI_PPI_DEFINITION (CpuIo)\r
+#include EFI_PPI_DEFINITION (DeviceRecoveryModule)\r
+#include EFI_PPI_DEFINITION (DxeIpl)\r
+#include EFI_PPI_DEFINITION (EndOfPeiSignal)\r
+#include EFI_PPI_DEFINITION (FindFv)\r
+#include EFI_PPI_DEFINITION (LoadFile)\r
+#include EFI_PPI_DEFINITION (BootMode)\r
+#include EFI_PPI_DEFINITION (MemoryDiscovered)\r
+#include EFI_PPI_DEFINITION (PciCfg)\r
+#include EFI_PPI_DEFINITION (Variable)\r
+#include EFI_PPI_DEFINITION (RecoveryModule)\r
+#include EFI_PPI_DEFINITION (Reset)\r
+#include EFI_PPI_DEFINITION (S3Resume)\r
+#include EFI_PPI_DEFINITION (SecPlatforminformation)\r
+#include EFI_PPI_DEFINITION (SectionExtraction)\r
+#include EFI_PPI_DEFINITION (Security)\r
+#include EFI_PPI_DEFINITION (Smbus)\r
+#include EFI_PPI_DEFINITION (Stall)\r
+#include EFI_PPI_DEFINITION (StatusCode)\r
+\r
+\r
+#include "Common\EdkIIGlueDefinitionChangesPeim.h"\r
+\r
+//\r
+// EdkII Glue Library Class headers\r
+//\r
+\r
+#include "EdkIIGlueBase.h"\r
+#include "Library\EdkIIGlueDebugLib.h"\r
+#include "Library\EdkIIGluePostCodeLib.h"\r
+#include "Library\EdkIIGlueReportStatusCodeLib.h"\r
+#include "Library\EdkIIGlueHobLib.h"\r
+#include "Library\EdkIIGlueMemoryAllocationLib.h"\r
+#include "Library\EdkIIGlueSmbusLib.h"\r
+#include "Library\EdkIIGluePeiServicesLib.h"\r
+#include "Library\EdkIIGluePeiServicesTablePointerLib.h"\r
+#include "Library\EdkIIGlueResourcePublicationLib.h"\r
+#include "Library\EdkIIGluePeimEntryPoint.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
new file mode 100644 (file)
index 0000000..e71020e
--- /dev/null
@@ -0,0 +1,174 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefi.h\r
+  \r
+Abstract: \r
+\r
+  Root include file for UEFI modules.\r
+\r
+**/\r
+\r
+\r
+#ifndef __EDKII_GLUE_UEFI_H__\r
+#define __EDKII_GLUE_UEFI_H__\r
+\r
+\r
+//\r
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
+//  also check for legal combinations\r
+//\r
+#if !defined(EFI_SPECIFICATION_VERSION)\r
+  #error EFI_SPECIFICATION_VERSION not defined\r
+#elif !defined(TIANO_RELEASE_VERSION)\r
+  #error TIANO_RELEASE_VERSION not defined\r
+#elif TIANO_RELEASE_VERSION == 0x00000000\r
+\r
+//\r
+// UEFI mode with no Tiano extensions is legal\r
+//\r
+#elif (TIANO_RELEASE_VERSION <= 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  #error Illegal combination of EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION versions\r
+#endif\r
+\r
+//\r
+// General Type & API definitions\r
+//\r
+\r
+#include "EfiSpec.h"\r
+#include "EfiPxe.h"\r
+\r
+\r
+//\r
+// Protocols from EFI 1.10 that got thier names fixed in UEFI 2.0\r
+//\r
+#include EFI_PROTOCOL_DEFINITION(LoadedImage)\r
+#include EFI_PROTOCOL_DEFINITION(SimpleTextIn)\r
+#include EFI_PROTOCOL_DEFINITION(SimpleTextOut)\r
+#include EFI_PROTOCOL_DEFINITION(SerialIo)\r
+#include EFI_PROTOCOL_DEFINITION(LoadFile)\r
+#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem)\r
+#include EFI_PROTOCOL_DEFINITION(DiskIo)\r
+#include EFI_PROTOCOL_DEFINITION(BlockIo)\r
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation)\r
+#include EFI_PROTOCOL_DEFINITION(SimpleNetwork)\r
+#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier)\r
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCode)\r
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCodeCallBack)\r
+\r
+//\r
+// EFI 1.10 Protocols\r
+//\r
+#include EFI_PROTOCOL_DEFINITION(Bis)\r
+#include EFI_PROTOCOL_DEFINITION(BusSpecificDriverOverride)\r
+#include EFI_PROTOCOL_DEFINITION(ComponentName)\r
+#include EFI_PROTOCOL_DEFINITION(ComponentName2)\r
+#include EFI_PROTOCOL_DEFINITION(DebugPort)\r
+#include EFI_PROTOCOL_DEFINITION(DebugSupport)\r
+#include EFI_PROTOCOL_DEFINITION(Decompress)\r
+#include EFI_PROTOCOL_DEFINITION(DriverBinding)\r
+#include EFI_PROTOCOL_DEFINITION(DriverConfiguration)\r
+#include EFI_PROTOCOL_DEFINITION(DriverDiagnostics)\r
+#include EFI_PROTOCOL_DEFINITION(Ebc)\r
+#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier)\r
+#include EFI_PROTOCOL_DEFINITION(FileInfo)\r
+#include EFI_PROTOCOL_DEFINITION(FileSystemInfo)\r
+#include EFI_PROTOCOL_DEFINITION(FileSystemVolumeLabelInfo)\r
+#include EFI_PROTOCOL_DEFINITION(PciIo)\r
+#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo)\r
+#include EFI_PROTOCOL_DEFINITION(PlatformDriverOverride)\r
+#include EFI_PROTOCOL_DEFINITION(SimplePointer)\r
+#include EFI_PROTOCOL_DEFINITION(ScsiPassThru)\r
+#include EFI_PROTOCOL_DEFINITION(UsbIo)\r
+#include EFI_PROTOCOL_DEFINITION(UsbHostController)\r
+#include EFI_PROTOCOL_DEFINITION(UgaDraw)\r
+\r
+//\r
+// EFI 1.10 GUIDs\r
+//\r
+#include EFI_GUID_DEFINITION(Acpi)\r
+#include EFI_GUID_DEFINITION(DebugImageInfoTable)\r
+#include EFI_GUID_DEFINITION(GlobalVariable)\r
+#include EFI_GUID_DEFINITION(Gpt)\r
+#include EFI_GUID_DEFINITION(PcAnsi)\r
+#include EFI_GUID_DEFINITION(SmBios)\r
+#include EFI_GUID_DEFINITION(SalSystemTable)\r
+\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+//\r
+// UEFI 2.0 Protocols and GUIDs\r
+//\r
+// check here: currently not implementated\r
+//#include EFI_PROTOCOL_DEFINITION(AuthenticationInfo)\r
+#include EFI_PROTOCOL_DEFINITION(DevicePathUtilities)\r
+#include EFI_PROTOCOL_DEFINITION(DevicePathToText)\r
+#include EFI_PROTOCOL_DEFINITION(DevicePathFromText)\r
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)\r
+#include EFI_PROTOCOL_DEFINITION(EdidDiscovered)\r
+#include EFI_PROTOCOL_DEFINITION(EdidActive)\r
+#include EFI_PROTOCOL_DEFINITION(EdidOverride)\r
+#include EFI_PROTOCOL_DEFINITION(ScsiIo)\r
+#include EFI_PROTOCOL_DEFINITION(ScsiPassThruExt)\r
+#include EFI_PROTOCOL_DEFINITION(IScsiInitiatorName)\r
+#include EFI_PROTOCOL_DEFINITION(UsbHostController)\r
+#include EFI_PROTOCOL_DEFINITION(TapeIo)\r
+#include EFI_PROTOCOL_DEFINITION(ManagedNetwork)\r
+#include EFI_PROTOCOL_DEFINITION(Arp)\r
+#include EFI_PROTOCOL_DEFINITION(Dhcp4)\r
+#include EFI_PROTOCOL_DEFINITION(IP4)\r
+#include EFI_PROTOCOL_DEFINITION(IP4Config)\r
+#include EFI_PROTOCOL_DEFINITION(Tcp4)\r
+#include EFI_PROTOCOL_DEFINITION(Udp4)\r
+#include EFI_PROTOCOL_DEFINITION(Mtftp4)\r
+#include EFI_PROTOCOL_DEFINITION(ServiceBinding)\r
+#include EFI_PROTOCOL_DEFINITION(Hash)\r
+#include EFI_GUID_DEFINITION(EventGroup)\r
+//#include <Guid/WinCertificateUefi.h>\r
+#endif\r
+\r
+#if (TIANO_RELEASE_VERSION > 0x00080005) \r
+//\r
+// Need due to R8.5 Tiano contamination of UEFI enumes. \r
+// There is a UEFI library that does things the new way and the old way\r
+// This is why these definitions are need in Uefi.h\r
+//\r
+#include EFI_GUID_DEFINITION (EventLegacyBios)\r
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
+#endif\r
+\r
+//\r
+// R8.x Library headers used by EdkII Glue Libraries\r
+//\r
+#include "TianoSpecTypes.h"\r
+#include "TianoSpecApi.h"\r
+#include "TianoSpecDevicePath.h"\r
+#include "EfiDriverLib.h"\r
+\r
+#include "Common\EdkIIGlueDefinitionChangesBase.h"\r
+\r
+//\r
+// EdkII Glue Library Class headers\r
+//\r
+\r
+#include "EdkIIGlueBase.h"\r
+#include "Library\EdkIIGlueUefiDecompressLib.h"\r
+#include "Library\EdkIIGlueDevicePathLib.h"\r
+#include "Library\EdkIIGlueUefiBootServicesTableLib.h"\r
+#include "Library\EdkIIGlueUefiDriverEntryPoint.h"\r
+#include "Library\EdkIIGlueUefiDriverModelLib.h"\r
+#include "Library\EdkIIGlueUefiLib.h"\r
+#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h
new file mode 100644 (file)
index 0000000..b6f55b7
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueProcessorBind.h\r
+  \r
+Abstract: \r
+\r
+  Processor specific definitions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__\r
+#define __EDKII_GLUE_PROCESSOR_BIND_H__\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#ifndef MDE_CPU_IA32\r
+  #define MDE_CPU_IA32\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h
new file mode 100644 (file)
index 0000000..8c6ef88
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueProcessorBind.h\r
+  \r
+Abstract: \r
+\r
+  Processor specific definitions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__\r
+#define __EDKII_GLUE_PROCESSOR_BIND_H__\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#ifndef MDE_CPU_IPF\r
+  #define MDE_CPU_IPF\r
+#endif\r
+  \r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h
new file mode 100644 (file)
index 0000000..4c95c85
--- /dev/null
@@ -0,0 +1,5842 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueBaseLib.h\r
+  \r
+Abstract: \r
+\r
+  Memory-only library functions with no library constructor/destructor\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_BASE_LIB_H__\r
+#define __EDKII_GLUE_BASE_LIB_H__\r
+\r
+\r
+//\r
+// String Functions\r
+//\r
+#define StrCpy(_Dest, _Source)                        GlueStrCpy(_Dest, _Source)\r
+#define StrnCpy(_Dest, _Source, _Length)              GlueStrnCpy(_Dest, _Source, _Length)\r
+#define StrLen(_String)                               GlueStrLen(_String)\r
+#define StrSize(_String)                              GlueStrSize(_String)\r
+#define StrCmp(_FristString, _SecondString)           GlueStrCmp(_FristString, _SecondString)\r
+#define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length)\r
+#define StrCat(_Dest, _Source)                        GlueStrCat(_Dest, _Source)\r
+#define StrnCat(_Dest, _Source, _Length)              GlueStrnCat(_Dest, _Source, _Length)\r
+\r
+//\r
+// Linked List\r
+//\r
+#define InitializeListHead(_ListHead)                 GlueInitializeListHead(_ListHead)\r
+#define InsertHeadList(_ListHead, _Entry )            GlueInsertHeadList(_ListHead, _Entry)\r
+#define InsertTailList(_ListHead, _Entry)             GlueInsertTailList(_ListHead, _Entry)\r
+#define GetFirstNode(_List)                           GlueGetFirstNode(_List)\r
+#define GetNextNode(_List, _Node)                     GlueGetNextNode(_List, _Node)\r
+#define IsListEmpty(_ListHead)                        GlueIsListEmpty(_ListHead)\r
+#define IsNull(_List, _Node)                          GlueIsNull(_List, _Node)\r
+#define IsNodeAtEnd(_List, _Node)                     GlueIsNodeAtEnd(_List, _Node)\r
+#define SwapListEntries(_FirstEntry, _SecondEntry)    GlueSwapListEntries(_FirstEntry, _SecondEntry)\r
+#define RemoveEntryList(_Entry)                       GlueRemoveEntryList(_Entry)\r
+\r
+//\r
+// Math Functions\r
+//\r
+#define LShiftU64(_Op, _Count)                        GlueLShiftU64(_Op, _Count)\r
+#define RShiftU64(_Op, _Count)                        GlueRShiftU64(_Op, _Count)\r
+#define MultU64x32(_Multiplicand, _Multiplier)        GlueMultU64x32(_Multiplicand, _Multiplier)\r
+#define DivU64x32(_Dividend, _Divisor)                GlueDivU64x32(_Dividend, _Divisor)\r
+\r
+//\r
+// Others\r
+//\r
+#define GetInterruptState()                           GlueGetInterruptState()\r
+\r
+\r
+//\r
+// Definitions for architecture specific types\r
+// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER\r
+//\r
+\r
+//\r
+// SPIN_LOCK\r
+//\r
+typedef UINTN                       SPIN_LOCK;\r
+\r
+#if   defined (MDE_CPU_IA32)\r
+//\r
+// IA32 context buffer used by SetJump() and LongJump()\r
+//\r
+typedef struct {\r
+  UINT32                            Ebx;\r
+  UINT32                            Esi;\r
+  UINT32                            Edi;\r
+  UINT32                            Ebp;\r
+  UINT32                            Esp;\r
+  UINT32                            Eip;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
+\r
+#elif defined (MDE_CPU_IPF)\r
+//\r
+// IPF context buffer used by SetJump() and LongJump()\r
+//\r
+typedef struct {\r
+  UINT64                            F2[2];\r
+  UINT64                            F3[2];\r
+  UINT64                            F4[2];\r
+  UINT64                            F5[2];\r
+  UINT64                            F16[2];\r
+  UINT64                            F17[2];\r
+  UINT64                            F18[2];\r
+  UINT64                            F19[2];\r
+  UINT64                            F20[2];\r
+  UINT64                            F21[2];\r
+  UINT64                            F22[2];\r
+  UINT64                            F23[2];\r
+  UINT64                            F24[2];\r
+  UINT64                            F25[2];\r
+  UINT64                            F26[2];\r
+  UINT64                            F27[2];\r
+  UINT64                            F28[2];\r
+  UINT64                            F29[2];\r
+  UINT64                            F30[2];\r
+  UINT64                            F31[2];\r
+  UINT64                            R4;\r
+  UINT64                            R5;\r
+  UINT64                            R6;\r
+  UINT64                            R7;\r
+  UINT64                            SP;\r
+  UINT64                            BR0;\r
+  UINT64                            BR1;\r
+  UINT64                            BR2;\r
+  UINT64                            BR3;\r
+  UINT64                            BR4;\r
+  UINT64                            BR5;\r
+  UINT64                            InitialUNAT;\r
+  UINT64                            AfterSpillUNAT;\r
+  UINT64                            PFS;\r
+  UINT64                            BSP;\r
+  UINT64                            Predicates;\r
+  UINT64                            LoopCount;\r
+  UINT64                            FPSR;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r
+\r
+#elif defined (MDE_CPU_X64)\r
+//\r
+// X64 context buffer used by SetJump() and LongJump()\r
+//\r
+typedef struct {\r
+  UINT64                            Rbx;\r
+  UINT64                            Rsp;\r
+  UINT64                            Rbp;\r
+  UINT64                            Rdi;\r
+  UINT64                            Rsi;\r
+  UINT64                            R12;\r
+  UINT64                            R13;\r
+  UINT64                            R14;\r
+  UINT64                            R15;\r
+  UINT64                            Rip;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
+\r
+#elif defined (MDE_CPU_EBC)\r
+//\r
+// EBC context buffer used by SetJump() and LongJump()\r
+//\r
+typedef struct {\r
+  UINT64                            R0;\r
+  UINT64                            R1;\r
+  UINT64                            R2;\r
+  UINT64                            R3;\r
+  UINT64                            IP;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
+\r
+#else\r
+#error Unknown Processor Type\r
+#endif\r
+\r
+//\r
+// String Services\r
+//\r
+\r
+/**\r
+  Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
+  string and returns the new Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destiantion\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  );\r
+/**\r
+  Copies one Null-terminated Unicode string with a maximum length to another\r
+  Null-terminated Unicode string with a maximum length and returns the new\r
+  Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. At most, Length Unicode\r
+  characters are copied from Source to Destination. If Length is 0, then\r
+  Destination is returned unmodified. If Length is greater that the number of\r
+  Unicode characters in Source, then Destination is padded with Null Unicode\r
+  characters. If Source and Destination overlap, then the results are\r
+  undefined.\r
+\r
+  If Length > 0 and Destination is NULL, then ASSERT().\r
+  If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrnCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  );\r
+/**\r
+  Returns the length of a Null-terminated Unicode string.\r
+\r
+  This function returns the number of Unicode characters in the Null-terminated\r
+  Unicode string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueStrLen (\r
+  IN      CONST CHAR16              *String\r
+  );\r
+/**\r
+  Returns the size of a Null-terminated Unicode string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated Unicode\r
+  string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueStrSize (\r
+  IN      CONST CHAR16              *String\r
+  );\r
+/**\r
+  Compares two Null-terminated Unicode strings, and returns the difference\r
+  between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched Unicode character in SecondString subtracted from the first\r
+  mismatched Unicode character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueStrCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString\r
+  );\r
+/**\r
+  Compares two Null-terminated Unicode strings with maximum lengths, and\r
+  returns the difference between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. At most, Length Unicode\r
+  characters will be compared. If Length is 0, then 0 is returned. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched Unicode character in SecondString\r
+  subtracted from the first mismatched Unicode character in FirstString.\r
+\r
+  If Length > 0 and FirstString is NULL, then ASSERT().\r
+  If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If Length > 0 and SecondString is NULL, then ASSERT().\r
+  If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+  @param  Length        Maximum number of Unicode characters to compare.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueStrnCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString,\r
+  IN      UINTN                     Length\r
+  );\r
+/**\r
+  Concatenates one Null-terminated Unicode string to another Null-terminated\r
+  Unicode string, and returns the concatenated Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination. The Null-terminated concatenated\r
+  Unicode String is returned. If Source and Destination overlap, then the\r
+  results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Destination is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
+  and Source results in a Unicode string with more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  );\r
+/**\r
+  Concatenates one Null-terminated Unicode string with a maximum length to the\r
+  end of another Null-terminated Unicode string, and returns the concatenated\r
+  Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination, and Destination is returned. At\r
+  most, Length Unicode characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
+  and Source results in a Unicode string with more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrnCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Returns the first occurance of a Null-terminated Unicode sub-string \r
+  in a Null-terminated Unicode string.\r
+\r
+  This function scans the contents of the Null-terminated Unicode string \r
+  specified by String and returns the first occurrence of SearchString.  \r
+  If SearchString is not found in String, then NULL is returned.  If \r
+  the length of SearchString is zero, then String is \r
+  returned.\r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If SearchString is NULL, then ASSERT().\r
+  If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and SearchString \r
+  or String contains more than PcdMaximumUnicodeStringLength Unicode \r
+  characters not including the Null-terminator, then ASSERT().\r
+\r
+  @param  String                                 Pointer to a Null-terminated Unicode string.\r
+  @param  SearchString Pointer to a Null-terminated Unicode string to search for.\r
+\r
+  @retval NULL            If the SearchString does not appear in String.\r
+  @retval !NULL           If there is a match.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrStr (\r
+  IN      CONST CHAR16               *String,\r
+  IN      CONST CHAR16               *SearchString\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of \r
+  type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the Unicode string specified by String as a decimal number. The format \r
+  of the input Unicode string String is:\r
+  \r
+                  [spaces] [decimal digits].\r
+                  \r
+  The valid decimal digit character is in the range [0-9]. The \r
+  function will ignore the pad space, which includes spaces or \r
+  tab characters, before [decimal digits]. The running zero in the \r
+  beginning of [decimal digits] will be ignored. Then, the function \r
+  stops at the first character that is a not a valid decimal character \r
+  or a Null-terminator, whichever one comes first. \r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, \r
+  then 0 is returned.\r
+  If the number represented by String overflows according \r
+  to the range defined by UINTN, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINTN           \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrDecimalToUintn (\r
+  IN      CONST CHAR16               *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of \r
+  type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the Unicode string specified by String as a decimal number. The format \r
+  of the input Unicode string String is:\r
+  \r
+                  [spaces] [decimal digits].\r
+                  \r
+  The valid decimal digit character is in the range [0-9]. The \r
+  function will ignore the pad space, which includes spaces or \r
+  tab characters, before [decimal digits]. The running zero in the \r
+  beginning of [decimal digits] will be ignored. Then, the function \r
+  stops at the first character that is a not a valid decimal character \r
+  or a Null-terminator, whichever one comes first. \r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, \r
+  then 0 is returned.\r
+  If the number represented by String overflows according \r
+  to the range defined by UINT64, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINT64           \r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+StrDecimalToUint64 (\r
+  IN      CONST CHAR16               *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the Unicode string specified by String as a hexadecimal number. \r
+  The format of the input Unicode string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits]. \r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. \r
+  If "x" appears in the input string, it must be prefixed with at least one 0. \r
+  The function will ignore the pad space, which includes spaces or tab characters, \r
+  before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or \r
+  [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the \r
+  first valid hexadecimal digit. Then, the function stops at the first character that is \r
+  a not a valid hexadecimal character or NULL, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If String has only pad spaces, then zero is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, \r
+  then zero is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINTN, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINTN\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrHexToUintn (\r
+  IN      CONST CHAR16               *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the Unicode string specified by String as a hexadecimal number. \r
+  The format of the input Unicode string String is \r
+  \r
+                  [spaces][zeros][x][hexadecimal digits]. \r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. \r
+  If "x" appears in the input string, it must be prefixed with at least one 0. \r
+  The function will ignore the pad space, which includes spaces or tab characters, \r
+  before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or \r
+  [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the \r
+  first valid hexadecimal digit. Then, the function stops at the first character that is \r
+  a not a valid hexadecimal character or NULL, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If String has only pad spaces, then zero is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, \r
+  then zero is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINT64, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINT64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+StrHexToUint64 (\r
+  IN      CONST CHAR16               *String\r
+  );\r
+\r
+/**\r
+  Convert one Null-terminated Unicode string to a Null-terminated \r
+  ASCII string and returns the ASCII string.\r
+  \r
+  This function converts the content of the Unicode string Source \r
+  to the ASCII string Destination by copying the lower 8 bits of \r
+  each Unicode character. It returns Destination. \r
+\r
+  If any Unicode characters in Source contain non-zero value in \r
+  the upper 8 bits, then ASSERT().\r
+  \r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+  \r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more \r
+  than PcdMaximumAsciiStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Source        Pointer to a Null-terminated Unicode string.\r
+  @param  Destination   Pointer to a Null-terminated ASCII string.\r
+\r
+  @reture Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+UnicodeStrToAsciiStr (\r
+  IN      CONST CHAR16               *Source,\r
+  OUT    CHAR8                           *Destination\r
+  );\r
+\r
+/**\r
+  Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
+  string and returns the new ASCII string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source\r
+  );\r
+/**\r
+  Copies one Null-terminated ASCII string with a maximum length to another\r
+  Null-terminated ASCII string with a maximum length and returns the new ASCII\r
+  string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. At most, Length ASCII characters\r
+  are copied from Source to Destination. If Length is 0, then Destination is\r
+  returned unmodified. If Length is greater that the number of ASCII characters\r
+  in Source, then Destination is padded with Null ASCII characters. If Source\r
+  and Destination overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  );\r
+/**\r
+  Returns the length of a Null-terminated ASCII string.\r
+\r
+  This function returns the number of ASCII characters in the Null-terminated\r
+  ASCII string specified by String.\r
+\r
+  If Length > 0 and Destination is NULL, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and String contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrLen (\r
+  IN      CONST CHAR8               *String\r
+  );\r
+/**\r
+  Returns the size of a Null-terminated ASCII string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated ASCII string\r
+  specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and String contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrSize (\r
+  IN      CONST CHAR8               *String\r
+  );\r
+/**\r
+  Compares two Null-terminated ASCII strings, and returns the difference\r
+  between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched ASCII character in SecondString subtracted from the first\r
+  mismatched ASCII character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  );\r
+/**\r
+  Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
+  and returns the difference between the first mismatched ASCII characters.\r
+\r
+  This function performs a case insensitive comparison of the Null-terminated\r
+  ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched lower case ASCII character in\r
+  SecondString subtracted from the first mismatched lower case ASCII character\r
+  in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString using case insensitive\r
+              comparisons.\r
+  @retval !=0 FirstString is not identical to SecondString using case\r
+              insensitive comparisons.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStriCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  );\r
+/**\r
+  Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
+  the difference between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII  string SecondString. At most, Length ASCII characters\r
+  will be compared. If Length is 0, then 0 is returned. If FirstString is\r
+  identical to SecondString, then 0 is returned. Otherwise, the value returned\r
+  is the first mismatched ASCII character in SecondString subtracted from the\r
+  first mismatched ASCII character in FirstString.\r
+\r
+  If Length > 0 and FirstString is NULL, then ASSERT().\r
+  If Length > 0 and SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrnCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString,\r
+  IN      UINTN                     Length\r
+  );\r
+/**\r
+  Concatenates one Null-terminated ASCII string to another Null-terminated\r
+  ASCII string, and returns the concatenated ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents of\r
+  Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
+  String is returned.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
+  Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
+  ASCII characters, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCat (\r
+  IN OUT CHAR8    *Destination,\r
+  IN CONST CHAR8  *Source\r
+  );\r
+/**\r
+  Concatenates one Null-terminated ASCII string with a maximum length to the\r
+  end of another Null-terminated ASCII string, and returns the concatenated\r
+  ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents\r
+  of Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination, and Destination is returned. At most,\r
+  Length ASCII characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Length > 0 and Destination is NULL, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
+  Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
+  ASCII characters not including the Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCat (\r
+  IN OUT  CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Returns the first occurance of a Null-terminated ASCII sub-string \r
+  in a Null-terminated ASCII string.\r
+\r
+  This function scans the contents of the ASCII string specified by String \r
+  and returns the first occurrence of SearchString. If SearchString is not \r
+  found in String, then NULL is returned. If the length of SearchString is zero, \r
+  then String is returned.\r
+  \r
+  If String is NULL, then ASSERT().\r
+  If SearchString is NULL, then ASSERT().\r
+\r
+  If PcdMaximumAsciiStringLength is not zero, and SearchString or \r
+  String contains more than PcdMaximumAsciiStringLength Unicode characters \r
+  not including the Null-terminator, then ASSERT().\r
+\r
+  @param  String                                 Pointer to a Null-terminated ASCII string.\r
+  @param  SearchString   Pointer to a Null-terminated ASCII string to search for.\r
+\r
+  @retval NULL            If the SearchString does not appear in String.\r
+  @retval !NULL           If there is a match.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrStr (\r
+  IN      CONST CHAR8                  *String,\r
+  IN      CONST CHAR8                  *SearchString\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII decimal string to a value of type \r
+  UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the ASCII string String as a decimal number. The format of the input \r
+  ASCII string String is:\r
+  \r
+                    [spaces] [decimal digits].\r
+  \r
+  The valid decimal digit character is in the range [0-9]. The function will \r
+  ignore the pad space, which includes spaces or tab characters, before the digits. \r
+  The running zero in the beginning of [decimal digits] will be ignored. Then, the \r
+  function stops at the first character that is a not a valid decimal character or \r
+  Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, then 0 is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINTN, then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINTN           \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrDecimalToUintn (\r
+  IN      CONST CHAR8               *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII decimal string to a value of type \r
+  UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the ASCII string String as a decimal number. The format of the input \r
+  ASCII string String is:\r
+  \r
+                    [spaces] [decimal digits].\r
+  \r
+  The valid decimal digit character is in the range [0-9]. The function will \r
+  ignore the pad space, which includes spaces or tab characters, before the digits. \r
+  The running zero in the beginning of [decimal digits] will be ignored. Then, the \r
+  function stops at the first character that is a not a valid decimal character or \r
+  Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, then 0 is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINT64, then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINT64           \r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsciiStrDecimalToUint64 (\r
+  IN      CONST CHAR8                *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents of \r
+  the ASCII string String as a hexadecimal number. The format of the input ASCII \r
+  string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits].\r
+                  \r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" \r
+  appears in the input string, it must be prefixed with at least one 0. The function \r
+  will ignore the pad space, which includes spaces or tab characters, before [zeros], \r
+  [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] \r
+  will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal \r
+  digit. Then, the function stops at the first character that is a not a valid \r
+  hexadecimal character or Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
+  0 is returned.\r
+\r
+  If the number represented by String overflows according to the range defined by UINTN, \r
+  then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, \r
+  and String contains more than PcdMaximumAsciiStringLength ASCII characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINTN\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrHexToUintn (\r
+  IN      CONST CHAR8                *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents of \r
+  the ASCII string String as a hexadecimal number. The format of the input ASCII \r
+  string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits].\r
+                  \r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" \r
+  appears in the input string, it must be prefixed with at least one 0. The function \r
+  will ignore the pad space, which includes spaces or tab characters, before [zeros], \r
+  [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] \r
+  will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal \r
+  digit. Then, the function stops at the first character that is a not a valid \r
+  hexadecimal character or Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
+  0 is returned.\r
+\r
+  If the number represented by String overflows according to the range defined by UINT64, \r
+  then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, \r
+  and String contains more than PcdMaximumAsciiStringLength ASCII characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINT64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsciiStrHexToUint64 (\r
+  IN      CONST CHAR8                  *String\r
+  );\r
+\r
+/**\r
+  Convert one Null-terminated ASCII string to a Null-terminated \r
+  Unicode string and returns the Unicode string.\r
+\r
+  This function converts the contents of the ASCII string Source to the Unicode \r
+  string Destination, and returns Destination.  The function terminates the \r
+  Unicode string Destination by appending a Null-terminator character at the end. \r
+  The caller is responsible to make sure Destination points to a buffer with size \r
+  equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
+  \r
+  If Destination is NULL, then ASSERT().\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Source        Pointer to a Null-terminated ASCII string.\r
+  @param  Destination   Pointer to a Null-terminated Unicode string.\r
+\r
+  @reture Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+AsciiStrToUnicodeStr (\r
+  IN      CONST CHAR8                *Source,\r
+  OUT    CHAR16                        *Destination\r
+  );\r
+\r
+/**\r
+  Converts an 8-bit value to an 8-bit BCD value.\r
+\r
+  Converts the 8-bit value specified by Value to BCD. The BCD value is\r
+  returned.\r
+\r
+  If Value >= 100, then ASSERT().\r
+\r
+  @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
+\r
+  @return The BCD value\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DecimalToBcd8 (\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Converts an 8-bit BCD value to an 8-bit value.\r
+\r
+  Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
+  value is returned.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
+\r
+  @return The 8-bit value is returned.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BcdToDecimal8 (\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+//\r
+// LIST_ENTRY definition\r
+//\r
+typedef struct _LIST_ENTRY LIST_ENTRY;\r
+\r
+struct _LIST_ENTRY {\r
+  LIST_ENTRY  *ForwardLink;\r
+  LIST_ENTRY  *BackLink;\r
+};\r
+\r
+//\r
+// Linked List Functions and Macros\r
+//\r
+\r
+/**\r
+  Initializes the head node of a doubly linked list that is declared as a\r
+  global variable in a module.\r
+\r
+  Initializes the forward and backward links of a new linked list. After\r
+  initializing a linked list with this macro, the other linked list functions\r
+  may be used to add and remove nodes from the linked list. This macro results\r
+  in smaller executables by initializing the linked list in the data section,\r
+  instead if calling the InitializeListHead() function to perform the\r
+  equivalent operation.\r
+\r
+  @param  ListHead  The head note of a list to initiailize.\r
+\r
+**/\r
+#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&ListHead, &ListHead}\r
+\r
+/**\r
+  Initializes the head node of a doubly linked list, and returns the pointer to\r
+  the head node of the doubly linked list.\r
+\r
+  Initializes the forward and backward links of a new linked list. After\r
+  initializing a linked list with this function, the other linked list\r
+  functions may be used to add and remove nodes from the linked list. It is up\r
+  to the caller of this function to allocate the memory for ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a new doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInitializeListHead (\r
+  IN      LIST_ENTRY                *ListHead\r
+  );\r
+\r
+/**\r
+  Adds a node to the beginning of a doubly linked list, and returns the pointer\r
+  to the head node of the doubly linked list.\r
+\r
+  Adds the node Entry at the beginning of the doubly linked list denoted by\r
+  ListHead, and returns ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If Entry is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+  @param  Entry     A pointer to a node that is to be inserted at the beginning\r
+                    of a doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInsertHeadList (\r
+  IN      LIST_ENTRY                *ListHead,\r
+  IN      LIST_ENTRY                *Entry\r
+  );\r
+\r
+/**\r
+  Adds a node to the end of a doubly linked list, and returns the pointer to\r
+  the head node of the doubly linked list.\r
+\r
+  Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r
+  and returns ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If Entry is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+  @param  Entry     A pointer to a node that is to be added at the end of the\r
+                    doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInsertTailList (\r
+  IN      LIST_ENTRY                *ListHead,\r
+  IN      LIST_ENTRY                *Entry\r
+  );\r
+\r
+/**\r
+  Retrieves the first node of a doubly linked list.\r
+\r
+  Returns the first node of a doubly linked list. List must have been\r
+  initialized with InitializeListHead(). If List is empty, then NULL is\r
+  returned.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+\r
+  @return The first node of a doubly linked list.\r
+  @retval NULL  The list is empty.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueGetFirstNode (\r
+  IN      CONST LIST_ENTRY          *List\r
+  );\r
+\r
+/**\r
+  Retrieves the next node of a doubly linked list.\r
+\r
+  Returns the node of a doubly linked list that follows Node. List must have\r
+  been initialized with InitializeListHead(). If List is empty, then List is\r
+  returned.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
+  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If Node is not a node in List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @return Pointer to the next node if one exists. Otherwise a null value which\r
+          is actually List is returned.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueGetNextNode (\r
+  IN      CONST LIST_ENTRY          *List,\r
+  IN      CONST LIST_ENTRY          *Node\r
+  );\r
+\r
+/**\r
+  Checks to see if a doubly linked list is empty or not.\r
+\r
+  Checks to see if the doubly linked list is empty. If the linked list contains\r
+  zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+\r
+  @retval TRUE  The linked list is empty.\r
+  @retval FALSE The linked list is not empty.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsListEmpty (\r
+  IN      CONST LIST_ENTRY          *ListHead\r
+  );\r
+\r
+/**\r
+  Determines if a node in a doubly linked list is null.\r
+\r
+  Returns FALSE if Node is one of the nodes in the doubly linked list specified\r
+  by List. Otherwise, TRUE is returned. List must have been initialized with\r
+  InitializeListHead().\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+  If Node is not a node in List and Node is not equal to List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @retval TRUE  Node is one of the nodes in the doubly linked list.\r
+  @retval FALSE Node is not one of the nodes in the doubly linked list.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsNull (\r
+  IN      CONST LIST_ENTRY          *List,\r
+  IN      CONST LIST_ENTRY          *Node\r
+  );\r
+\r
+/**\r
+  Determines if a node the last node in a doubly linked list.\r
+\r
+  Returns TRUE if Node is the last node in the doubly linked list specified by\r
+  List. Otherwise, FALSE is returned. List must have been initialized with\r
+  InitializeListHead().\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+  If Node is not a node in List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @retval TRUE  Node is the last node in the linked list.\r
+  @retval FALSE Node is not the last node in the linked list.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsNodeAtEnd (\r
+  IN      CONST LIST_ENTRY          *List,\r
+  IN      CONST LIST_ENTRY          *Node\r
+  );\r
+\r
+/**\r
+  Swaps the location of two nodes in a doubly linked list, and returns the\r
+  first node after the swap.\r
+\r
+  If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r
+  Otherwise, the location of the FirstEntry node is swapped with the location\r
+  of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r
+  same double linked list as FirstEntry and that double linked list must have\r
+  been initialized with InitializeListHead(). SecondEntry is returned after the\r
+  nodes are swapped.\r
+\r
+  If FirstEntry is NULL, then ASSERT().\r
+  If SecondEntry is NULL, then ASSERT().\r
+  If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing the FirstEntry and SecondEntry nodes, including\r
+  the FirstEntry and SecondEntry nodes, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  FirstEntry  A pointer to a node in a linked list.\r
+  @param  SecondEntry A pointer to another node in the same linked list.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueSwapListEntries (\r
+  IN      LIST_ENTRY                *FirstEntry,\r
+  IN      LIST_ENTRY                *SecondEntry\r
+  );\r
+\r
+/**\r
+  Removes a node from a doubly linked list, and returns the node that follows\r
+  the removed node.\r
+\r
+  Removes the node Entry from a doubly linked list. It is up to the caller of\r
+  this function to release the memory used by this node if that is required. On\r
+  exit, the node following Entry in the doubly linked list is returned. If\r
+  Entry is the only node in the linked list, then the head node of the linked\r
+  list is returned.\r
+\r
+  If Entry is NULL, then ASSERT().\r
+  If Entry is the head node of an empty list, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing Entry, including the Entry node, is greater than\r
+  or equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  Entry A pointer to a node in a linked list\r
+\r
+  @return Entry\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueRemoveEntryList (\r
+  IN      CONST LIST_ENTRY          *Entry\r
+  );\r
+\r
+//\r
+// Math Services\r
+//\r
+\r
+/**\r
+  Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r
+  with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are set to zero. The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift left.\r
+  @param  Count   The number of bits to shift left.\r
+\r
+  @return Operand << Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueLShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r
+  filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to zero. The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueRShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r
+  with original integer's bit 63. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to bit 63 of Operand.  The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+ARShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r
+  with the high bits that were rotated.\r
+\r
+  This function rotates the 32-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 31, then ASSERT().\r
+\r
+  @param  Operand The 32-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LRotU32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r
+  with the low bits that were rotated.\r
+\r
+  This function rotates the 32-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 31, then ASSERT().\r
+\r
+  @param  Operand The 32-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+RRotU32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r
+  with the high bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r
+  with the high low bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+RRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Returns the bit position of the lowest bit set in a 32-bit value.\r
+\r
+  This function computes the bit position of the lowest bit set in the 32-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 31 is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return Position of the lowest bit set in Operand if found.\r
+  @retval -1 Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+LowBitSet32 (\r
+  IN      UINT32                    Operand\r
+  );\r
+\r
+/**\r
+  Returns the bit position of the lowest bit set in a 64-bit value.\r
+\r
+  This function computes the bit position of the lowest bit set in the 64-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 63 is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return Position of the lowest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+LowBitSet64 (\r
+  IN      UINT64                    Operand\r
+  );\r
+\r
+/**\r
+  Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r
+  to log2(x).\r
+\r
+  This function computes the bit position of the highest bit set in the 32-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 31 is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return Position of the highest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+HighBitSet32 (\r
+  IN      UINT32                    Operand\r
+  );\r
+\r
+/**\r
+  Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r
+  to log2(x).\r
+\r
+  This function computes the bit position of the highest bit set in the 64-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 63 is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return Position of the highest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+HighBitSet64 (\r
+  IN      UINT64                    Operand\r
+  );\r
+\r
+/**\r
+  Returns the value of the highest bit set in a 32-bit value. Equivalent to\r
+  1 << HighBitSet32(x).\r
+\r
+  This function computes the value of the highest bit set in the 32-bit value\r
+  specified by Operand. If Operand is zero, then zero is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return 1 << HighBitSet32(Operand)\r
+  @retval 0 Operand is zero.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GetPowerOfTwo32 (\r
+  IN      UINT32                    Operand\r
+  );\r
+\r
+/**\r
+  Returns the value of the highest bit set in a 64-bit value. Equivalent to\r
+  1 << HighBitSet64(x).\r
+\r
+  This function computes the value of the highest bit set in the 64-bit value\r
+  specified by Operand. If Operand is zero, then zero is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return 1 << HighBitSet64(Operand)\r
+  @retval 0 Operand is zero.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPowerOfTwo64 (\r
+  IN      UINT64                    Operand\r
+  );\r
+\r
+/**\r
+  Switches the endianess of a 16-bit integer.\r
+\r
+  This function swaps the bytes in a 16-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 16-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SwapBytes16 (\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Switches the endianess of a 32-bit integer.\r
+\r
+  This function swaps the bytes in a 32-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 32-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+SwapBytes32 (\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Switches the endianess of a 64-bit integer.\r
+\r
+  This function swaps the bytes in a 64-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 64-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+SwapBytes64 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  If the result overflows, then ASSERT().\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 32-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueMultU64x32 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT32                    Multiplier\r
+  );\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  If the result overflows, then ASSERT().\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 64-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MultU64x64 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT64                    Multiplier\r
+  );\r
+\r
+/**\r
+  Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r
+  64-bit signed result.\r
+\r
+  This function multiples the 64-bit signed value Multiplicand by the 64-bit\r
+  signed value Multiplier and generates a 64-bit signed result. This 64-bit\r
+  signed result is returned.\r
+\r
+  If the result overflows, then ASSERT().\r
+\r
+  @param  Multiplicand  A 64-bit signed value.\r
+  @param  Multiplier    A 64-bit signed value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+INT64\r
+EFIAPI\r
+MultS64x64 (\r
+  IN      INT64                     Multiplicand,\r
+  IN      INT64                     Multiplier\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 64-bit unsigned result.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
+  function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueDivU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 32-bit remainder. This function\r
+  returns the 32-bit unsigned remainder.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend % Divisor\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ModU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+DivU64x32Remainder (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor,\r
+  OUT     UINT32                    *Remainder  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r
+  a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 64-bit unsigned value.\r
+  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+DivU64x64Remainder (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT64                    Divisor,\r
+  OUT     UINT64                    *Remainder  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r
+  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit signed value Dividend by the 64-bit signed\r
+  value Divisor and generates a 64-bit signed quotient. If Remainder is not\r
+  NULL, then the 64-bit signed remainder is returned in Remainder. This\r
+  function returns the 64-bit signed quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+INT64\r
+EFIAPI\r
+DivS64x64Remainder (\r
+  IN      INT64                     Dividend,\r
+  IN      INT64                     Divisor,\r
+  OUT     INT64                     *Remainder  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 16-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+\r
+  @return *Uint16\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+ReadUnaligned16 (\r
+  IN      CONST UINT16              *Uint16\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 16-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+  @param  Value   16-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+WriteUnaligned16 (\r
+  OUT     UINT16                    *Uint16,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 24-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 24-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned24 (\r
+  IN      CONST UINT32              *Buffer\r
+  );\r
+\r
+/**\r
+  Writes a 24-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 24-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+  @param  Value   24-bit value to write to Buffer.\r
+\r
+  @return The value written.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned24 (\r
+  OUT     UINT32                    *Buffer,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 32-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+\r
+  @return *Uint32\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned32 (\r
+  IN      CONST UINT32              *Uint32\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 32-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+  @param  Value   32-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned32 (\r
+  OUT     UINT32                    *Uint32,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 64-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+\r
+  @return *Uint64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+ReadUnaligned64 (\r
+  IN      CONST UINT64              *Uint64\r
+  );\r
+\r
+/**\r
+  Writes a 64-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 64-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+  @param  Value   64-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+WriteUnaligned64 (\r
+  OUT     UINT64                    *Uint64,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+//\r
+// Bit Field Functions\r
+//\r
+\r
+/**\r
+  Returns a bit field from an 8-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldRead8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an 8-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 8-bit value is\r
+  returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldWrite8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldOr8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldAnd8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldAndThenOr8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Returns a bit field from a 16-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldRead16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a 16-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 16-bit value is\r
+  returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldWrite16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldOr16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldAnd16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldAndThenOr16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Returns a bit field from a 32-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldRead32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a 32-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 32-bit value is\r
+  returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldWrite32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldOr32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldAnd32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldAndThenOr32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Returns a bit field from a 64-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldRead64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a 64-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 64-bit value is\r
+  returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldWrite64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldOr64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldAnd64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldAndThenOr64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+//\r
+// Base Library Synchronization Functions\r
+//\r
+\r
+/**\r
+  Retrieves the architecture specific spin lock alignment requirements for\r
+  optimal spin lock performance.\r
+\r
+  This function retrieves the spin lock alignment requirements for optimal\r
+  performance on a given CPU architecture. The spin lock alignment must be a\r
+  power of two and is returned by this function. If there are no alignment\r
+  requirements, then 1 must be returned. The spin lock synchronization\r
+  functions must function correctly if the spin lock size and alignment values\r
+  returned by this function are not used at all. These values are hints to the\r
+  consumers of the spin lock synchronization functions to obtain optimal spin\r
+  lock performance.\r
+\r
+  @return The architecture specific spin lock alignment.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetSpinLockProperties (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Initializes a spin lock to the released state and returns the spin lock.\r
+\r
+  This function initializes the spin lock specified by SpinLock to the released\r
+  state, and returns SpinLock. Optimal performance can be achieved by calling\r
+  GetSpinLockProperties() to determine the size and alignment requirements for\r
+  SpinLock.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to initialize to the released\r
+                    state.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+InitializeSpinLock (\r
+  IN      SPIN_LOCK                 *SpinLock\r
+  );\r
+\r
+/**\r
+  Waits until a spin lock can be placed in the acquired state.\r
+\r
+  This function checks the state of the spin lock specified by SpinLock. If\r
+  SpinLock is in the released state, then this function places SpinLock in the\r
+  acquired state and returns SpinLock. Otherwise, this function waits\r
+  indefinitely for the spin lock to be released, and then places it in the\r
+  acquired state and returns SpinLock. All state transitions of SpinLock must\r
+  be performed using MP safe mechanisms.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+  If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r
+  PcdSpinLockTimeout microseconds, then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to place in the acquired state.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+AcquireSpinLock (\r
+  IN      SPIN_LOCK                 *SpinLock\r
+  );\r
+\r
+/**\r
+  Attempts to place a spin lock in the acquired state.\r
+\r
+  This function checks the state of the spin lock specified by SpinLock. If\r
+  SpinLock is in the released state, then this function places SpinLock in the\r
+  acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r
+  transitions of SpinLock must be performed using MP safe mechanisms.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to place in the acquired state.\r
+\r
+  @retval TRUE  SpinLock was placed in the acquired state.\r
+  @retval FALSE SpinLock could not be acquired.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AcquireSpinLockOrFail (\r
+  IN      SPIN_LOCK                 *SpinLock\r
+  );\r
+\r
+/**\r
+  Releases a spin lock.\r
+\r
+  This function places the spin lock specified by SpinLock in the release state\r
+  and returns SpinLock.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to release.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+ReleaseSpinLock (\r
+  IN      SPIN_LOCK                 *SpinLock\r
+  );\r
+\r
+/**\r
+  Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic increment of the 32-bit unsigned integer specified by\r
+  Value and returns the incremented value. The increment operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value A pointer to the 32-bit value to increment.\r
+\r
+  @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedIncrement (\r
+  IN      UINT32                    *Value\r
+  );\r
+\r
+/**\r
+  Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+  Value and returns the decremented value. The decrement operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value A pointer to the 32-bit value to decrement.\r
+\r
+  @return The decremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedDecrement (\r
+  IN      UINT32                    *Value\r
+  );\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
+  specified by Value.  If Value is equal to CompareValue, then Value is set to\r
+  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,\r
+  then Value is returned.  The compare exchange operation must be performed using\r
+  MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the 32-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  32-bit value used in compare operation.\r
+  @param  ExchangeValue 32-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedCompareExchange32 (\r
+  IN OUT  UINT32                    *Value,\r
+  IN      UINT32                    CompareValue,\r
+  IN      UINT32                    ExchangeValue\r
+  );\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned.\r
+  The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the 64-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  64-bit value used in compare operation.\r
+  @param  ExchangeValue 64-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InterlockedCompareExchange64 (\r
+  IN OUT  UINT64                    *Value,\r
+  IN      UINT64                    CompareValue,\r
+  IN      UINT64                    ExchangeValue\r
+  );\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a pointer value.\r
+\r
+  Performs an atomic compare exchange operation on the pointer value specified\r
+  by Value. If Value is equal to CompareValue, then Value is set to\r
+  ExchangeValue and CompareValue is returned. If Value is not equal to\r
+  CompareValue, then Value is returned. The compare exchange operation must be\r
+  performed using MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the pointer value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  Pointer value used in compare operation.\r
+  @param  ExchangeValue Pointer value used in exchange operation.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InterlockedCompareExchangePointer (\r
+  IN OUT  VOID                      **Value,\r
+  IN      VOID                      *CompareValue,\r
+  IN      VOID                      *ExchangeValue\r
+  );\r
+\r
+//\r
+// Base Library Checksum Functions\r
+//\r
+\r
+/**\r
+  Calculate the sum of all elements in a buffer in unit of UINT8. \r
+  During calculation, the carry bits are dropped.\r
+\r
+  This function calculates the sum of all elements in a buffer \r
+  in unit of UINT8. The carry bits in result of addition are dropped. \r
+  The result is returned as UINT8. If Length is Zero, then Zero is \r
+  returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
+  @param  Length           The size, in bytes, of Buffer .\r
+\r
+  @return Sum         The sum of Buffer with carry bits dropped during additions.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+CalculateSum8 (\r
+  IN      CONST UINT8                  *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+\r
+/**\r
+  Returns the two's complement checksum of all elements in a buffer \r
+  of 8-bit values.\r
+\r
+  This function first calculates the sum of the 8-bit values in the \r
+  buffer specified by Buffer and Length.  The carry bits in the result \r
+  of addition are dropped. Then, the two's complement of the sum is \r
+  returned.  If Length is 0, then 0 is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Checksum       The 2's complement checksum of Buffer.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+CalculateCheckSum8 (\r
+  IN      CONST UINT8                  *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the sum of all elements in a buffer of 16-bit values.  During \r
+  calculation, the carry bits are dropped.\r
+\r
+  This function calculates the sum of the 16-bit values in the buffer \r
+  specified by Buffer and Length. The carry bits in result of addition are dropped. \r
+  The 16-bit result is returned.  If Length is 0, then 0 is returned.  \r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Sum         The sum of Buffer with carry bits dropped during additions.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+CalculateSum16 (\r
+  IN      CONST UINT16                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the two's complement checksum of all elements in a buffer of \r
+  16-bit values.\r
+\r
+  This function first calculates the sum of the 16-bit values in the buffer \r
+  specified by Buffer and Length.  The carry bits in the result of addition \r
+  are dropped. Then, the two's complement of the sum is returned.  If Length \r
+  is 0, then 0 is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Checksum       The 2's complement checksum of Buffer.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+CalculateCheckSum16 (\r
+  IN      CONST UINT16                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the sum of all elements in a buffer of 32-bit values.  During \r
+  calculation, the carry bits are dropped.\r
+\r
+  This function calculates the sum of the 32-bit values in the buffer \r
+  specified by Buffer and Length. The carry bits in result of addition are dropped. \r
+  The 32-bit result is returned.  If Length is 0, then 0 is returned.  \r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Sum         The sum of Buffer with carry bits dropped during additions.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+CalculateSum32 (\r
+  IN      CONST UINT32                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the two's complement checksum of all elements in a buffer of \r
+  32-bit values.\r
+\r
+  This function first calculates the sum of the 32-bit values in the buffer \r
+  specified by Buffer and Length.  The carry bits in the result of addition \r
+  are dropped. Then, the two's complement of the sum is returned.  If Length \r
+  is 0, then 0 is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Checksum       The 2's complement checksum of Buffer.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+CalculateCheckSum32 (\r
+  IN      CONST UINT32                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the sum of all elements in a buffer of 64-bit values.  During \r
+  calculation, the carry bits are dropped.\r
+\r
+  This function calculates the sum of the 64-bit values in the buffer \r
+  specified by Buffer and Length. The carry bits in result of addition are dropped. \r
+  The 64-bit result is returned.  If Length is 0, then 0 is returned.  \r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the sum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Sum         The sum of Buffer with carry bits dropped during additions.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+CalculateSum64 (\r
+  IN      CONST UINT64                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+/**\r
+  Returns the two's complement checksum of all elements in a buffer of \r
+  64-bit values.\r
+\r
+  This function first calculates the sum of the 64-bit values in the buffer \r
+  specified by Buffer and Length.  The carry bits in the result of addition \r
+  are dropped. Then, the two's complement of the sum is returned.  If Length \r
+  is 0, then 0 is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer                       Pointer to the buffer to carry out the checksum operation.\r
+  @param  Length           The size, in bytes, of Buffer.\r
+\r
+  @return Checksum       The 2's complement checksum of Buffer.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+CalculateCheckSum64 (\r
+  IN      CONST UINT64                 *Buffer,\r
+  IN      UINTN                                      Length\r
+  );\r
+\r
+//\r
+// Base Library CPU Functions\r
+//\r
+typedef\r
+VOID\r
+(EFIAPI *SWITCH_STACK_ENTRY_POINT) (\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2   OPTIONAL\r
+  );\r
+\r
+/**\r
+  Used to serialize load and store operations.\r
+\r
+  All loads and stores that proceed calls to this function are guaranteed to be\r
+  globally visible when this function returns.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MemoryFence (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Saves the current CPU context that can be restored with a call to LongJump()\r
+  and returns 0.\r
+\r
+  Saves the current CPU context in the buffer specified by JumpBuffer and\r
+  returns 0. The initial call to SetJump() must always return 0. Subsequent\r
+  calls to LongJump() cause a non-zero value to be returned by SetJump().\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  JumpBuffer  A pointer to CPU context buffer.\r
+\r
+  @retval 0 Indicates a return from SetJump().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SetJump (\r
+  OUT     BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+  );\r
+\r
+/**\r
+  Restores the CPU context that was saved with SetJump().\r
+\r
+  Restores the CPU context from the buffer specified by JumpBuffer. This\r
+  function never returns to the caller. Instead is resumes execution based on\r
+  the state of JumpBuffer.\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+  If Value is 0, then ASSERT().\r
+\r
+  @param  JumpBuffer  A pointer to CPU context buffer.\r
+  @param  Value       The value to return when the SetJump() context is\r
+                      restored and must be non-zero.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LongJump (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+  IN      UINTN                     Value\r
+  );\r
+\r
+/**\r
+  Enables CPU interrupts.\r
+\r
+  Enables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableInterrupts (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Disables CPU interrupts.\r
+\r
+  Disables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableInterrupts (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Disables CPU interrupts and returns the interrupt state prior to the disable\r
+  operation.\r
+\r
+  Disables CPU interrupts and returns the interrupt state prior to the disable\r
+  operation.\r
+\r
+  @retval TRUE  CPU interrupts were enabled on entry to this call.\r
+  @retval FALSE CPU interrupts were disabled on entry to this call.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SaveAndDisableInterrupts (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableDisableInterrupts (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Retrieves the current CPU interrupt state.\r
+\r
+  Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r
+  currently enabled. Otherwise returns FALSE.\r
+\r
+  @retval TRUE  CPU interrupts are enabled.\r
+  @retval FALSE CPU interrupts are disabled.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueGetInterruptState (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Set the current CPU interrupt state.\r
+\r
+  Sets the current CPU interrupt state to the state specified by\r
+  InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r
+  InterruptState is FALSE, then interrupts are disabled. InterruptState is\r
+  returned.\r
+\r
+  @param  InterruptState  TRUE if interrupts should enabled. FALSE if\r
+                          interrupts should be disabled.\r
+\r
+  @return InterruptState\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SetInterruptState (\r
+  IN      BOOLEAN                   InterruptState\r
+  );\r
+\r
+/**\r
+  Places the CPU in a sleep state until an interrupt is received.\r
+\r
+  Places the CPU in a sleep state until an interrupt is received. If interrupts\r
+  are disabled prior to calling this function, then the CPU will be placed in a\r
+  sleep state indefinitely.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuSleep (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Requests CPU to pause for a short period of time.\r
+\r
+  Requests CPU to pause for a short period of time. Typically used in MP\r
+  systems to prevent memory starvation while waiting for a spin lock.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuPause (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFlushTlb (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+/**\r
+  Generates a breakpoint on the CPU.\r
+\r
+  Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
+  that code can resume normal execution after the breakpoint.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuBreakpoint (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Executes an infinite loop.\r
+\r
+  Forces the CPU to execute an infinite loop. A debugger may be used to skip\r
+  past the loop and the code that follows the loop must execute properly. This\r
+  implies that the infinite loop must not cause the code that follow it to be\r
+  optimized away.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuDeadLoop (\r
+  VOID\r
+  );\r
+\r
+//\r
+// IA32 and X64 Specific Functions\r
+//\r
+//\r
+// Byte packed structure for 16-bit Real Mode EFLAGS\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  CF:1;           // Carry Flag\r
+    UINT32  Reserved_0:1;   // Reserved\r
+    UINT32  PF:1;           // Parity Flag\r
+    UINT32  Reserved_1:1;   // Reserved\r
+    UINT32  AF:1;           // Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   // Reserved\r
+    UINT32  ZF:1;           // Zero Flag\r
+    UINT32  SF:1;           // Sign Flag\r
+    UINT32  TF:1;           // Trap Flag\r
+    UINT32  IF:1;           // Interrupt Enable Flag\r
+    UINT32  DF:1;           // Direction Flag\r
+    UINT32  OF:1;           // Overflow Flag\r
+    UINT32  IOPL:2;         // I/O Privilege Level\r
+    UINT32  NT:1;           // Nested Task\r
+    UINT32  Reserved_3:1;   // Reserved\r
+  } Bits;\r
+  UINT16    Uint16;\r
+} IA32_FLAGS16;\r
+\r
+//\r
+// Byte packed structure for EFLAGS/RFLAGS\r
+// 32-bits on IA-32\r
+// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  CF:1;           // Carry Flag\r
+    UINT32  Reserved_0:1;   // Reserved\r
+    UINT32  PF:1;           // Parity Flag\r
+    UINT32  Reserved_1:1;   // Reserved\r
+    UINT32  AF:1;           // Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   // Reserved\r
+    UINT32  ZF:1;           // Zero Flag\r
+    UINT32  SF:1;           // Sign Flag\r
+    UINT32  TF:1;           // Trap Flag\r
+    UINT32  IF:1;           // Interrupt Enable Flag\r
+    UINT32  DF:1;           // Direction Flag\r
+    UINT32  OF:1;           // Overflow Flag\r
+    UINT32  IOPL:2;         // I/O Privilege Level\r
+    UINT32  NT:1;           // Nested Task\r
+    UINT32  Reserved_3:1;   // Reserved\r
+    UINT32  RF:1;           // Resume Flag\r
+    UINT32  VM:1;           // Virtual 8086 Mode\r
+    UINT32  AC:1;           // Alignment Check\r
+    UINT32  VIF:1;          // Virtual Interrupt Flag\r
+    UINT32  VIP:1;          // Virtual Interrupt Pending\r
+    UINT32  ID:1;           // ID Flag\r
+    UINT32  Reserved_4:10;  // Reserved\r
+  } Bits;\r
+  UINTN     UintN;\r
+} IA32_EFLAGS32;\r
+\r
+//\r
+// Byte packed structure for Control Register 0 (CR0)\r
+// 32-bits on IA-32\r
+// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  PE:1;           // Protection Enable\r
+    UINT32  MP:1;           // Monitor Coprocessor\r
+    UINT32  EM:1;           // Emulation\r
+    UINT32  TS:1;           // Task Switched\r
+    UINT32  ET:1;           // Extension Type\r
+    UINT32  NE:1;           // Numeric Error\r
+    UINT32  Reserved_0:10;  // Reserved\r
+    UINT32  WP:1;           // Write Protect\r
+    UINT32  Reserved_1:1;   // Reserved\r
+    UINT32  AM:1;           // Alignment Mask\r
+    UINT32  Reserved_2:10;  // Reserved\r
+    UINT32  NW:1;           // Mot Write-through\r
+    UINT32  CD:1;           // Cache Disable\r
+    UINT32  PG:1;           // Paging\r
+  } Bits;\r
+  UINTN     UintN;\r
+} IA32_CR0;\r
+\r
+//\r
+// Byte packed structure for Control Register 4 (CR4)\r
+// 32-bits on IA-32\r
+// 64-bits on X64.  The upper 32-bits on X64 are reserved\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  VME:1;          // Virtual-8086 Mode Extensions\r
+    UINT32  PVI:1;          // Protected-Mode Virtual Interrupts\r
+    UINT32  TSD:1;          // Time Stamp Disable\r
+    UINT32  DE:1;           // Debugging Extensions\r
+    UINT32  PSE:1;          // Page Size Extensions\r
+    UINT32  PAE:1;          // Physical Address Extension\r
+    UINT32  MCE:1;          // Machine Check Enable\r
+    UINT32  PGE:1;          // Page Global Enable\r
+    UINT32  PCE:1;          // Performance Monitoring Counter\r
+                            // Enable\r
+    UINT32  OSFXSR:1;       // Operating System Support for\r
+                            // FXSAVE and FXRSTOR instructions\r
+    UINT32  OSXMMEXCPT:1;   // Operating System Support for\r
+                            // Unmasked SIMD Floating Point\r
+                            // Exceptions\r
+    UINT32  Reserved_0:2;   // Reserved\r
+    UINT32  VMXE:1;         // VMX Enable\r
+    UINT32  Reserved_1:18;  // Reseved\r
+  } Bits;\r
+  UINTN     UintN;\r
+} IA32_CR4;\r
+\r
+//\r
+// Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
+/// @bug  How to make this structure byte-packed in a compiler independent way?\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT16  Limit;\r
+  UINTN   Base;\r
+} IA32_DESCRIPTOR;\r
+#pragma pack ()\r
+\r
+#define IA32_IDT_GATE_TYPE_TASK          0x85\r
+#define IA32_IDT_GATE_TYPE_INTERRUPT_16  0x86\r
+#define IA32_IDT_GATE_TYPE_TRAP_16       0x87\r
+#define IA32_IDT_GATE_TYPE_INTERRUPT_32  0x8E\r
+#define IA32_IDT_GATE_TYPE_TRAP_32       0x8F\r
+\r
+//\r
+// Byte packed structure for an Interrupt Gate Descriptor\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  OffsetLow:16;   // Offset bits 15..0\r
+    UINT32  Selector:16;    // Selector\r
+    UINT32  Reserved_0:8;   // Reserved\r
+    UINT32  GateType:8;     // Gate Type.  See #defines above\r
+    UINT32  OffsetHigh:16;  // Offset bits 31..16\r
+  } Bits;\r
+  UINT64  Uint64;\r
+} IA32_IDT_GATE_DESCRIPTOR;\r
+\r
+//\r
+// Byte packed structure for an FP/SSE/SSE2 context\r
+//\r
+typedef struct {\r
+  UINT8  Buffer[512];\r
+} IA32_FX_BUFFER;\r
+\r
+//\r
+// Structures for the 16-bit real mode thunks\r
+//\r
+typedef struct {\r
+  UINT32                            Reserved1;\r
+  UINT32                            Reserved2;\r
+  UINT32                            Reserved3;\r
+  UINT32                            Reserved4;\r
+  UINT8                             BL;\r
+  UINT8                             BH;\r
+  UINT16                            Reserved5;\r
+  UINT8                             DL;\r
+  UINT8                             DH;\r
+  UINT16                            Reserved6;\r
+  UINT8                             CL;\r
+  UINT8                             CH;\r
+  UINT16                            Reserved7;\r
+  UINT8                             AL;\r
+  UINT8                             AH;\r
+  UINT16                            Reserved8;\r
+} IA32_BYTE_REGS;\r
+\r
+typedef struct {\r
+  UINT16                            DI;\r
+  UINT16                            Reserved1;\r
+  UINT16                            SI;\r
+  UINT16                            Reserved2;\r
+  UINT16                            BP;\r
+  UINT16                            Reserved3;\r
+  UINT16                            SP;\r
+  UINT16                            Reserved4;\r
+  UINT16                            BX;\r
+  UINT16                            Reserved5;\r
+  UINT16                            DX;\r
+  UINT16                            Reserved6;\r
+  UINT16                            CX;\r
+  UINT16                            Reserved7;\r
+  UINT16                            AX;\r
+  UINT16                            Reserved8;\r
+} IA32_WORD_REGS;\r
+\r
+typedef struct {\r
+  UINT32                            EDI;\r
+  UINT32                            ESI;\r
+  UINT32                            EBP;\r
+  UINT32                            ESP;\r
+  UINT32                            EBX;\r
+  UINT32                            EDX;\r
+  UINT32                            ECX;\r
+  UINT32                            EAX;\r
+  UINT16                            DS;\r
+  UINT16                            ES;\r
+  UINT16                            FS;\r
+  UINT16                            GS;\r
+  IA32_EFLAGS32                     EFLAGS;\r
+  UINT32                            Eip;\r
+  UINT16                            CS;\r
+  UINT16                            SS;\r
+} IA32_DWORD_REGS;\r
+\r
+typedef union {\r
+  IA32_DWORD_REGS                   E;\r
+  IA32_WORD_REGS                    X;\r
+  IA32_BYTE_REGS                    H;\r
+} IA32_REGISTER_SET;\r
+\r
+//\r
+// Byte packed structure for an 16-bit real mode thunks\r
+//\r
+typedef struct {\r
+  IA32_REGISTER_SET                 *RealModeState;\r
+  VOID                              *RealModeBuffer;\r
+  UINT32                            RealModeBufferSize;\r
+  UINT32                            ThunkAttributes;\r
+} THUNK_CONTEXT;\r
+\r
+#define THUNK_ATTRIBUTE_BIG_REAL_MODE             0x00000001\r
+#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15   0x00000002\r
+#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
+\r
+/**\r
+  Retrieves CPUID information.\r
+\r
+  Executes the CPUID instruction with EAX set to the value specified by Index.\r
+  This function always returns Index.\r
+  If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
+  If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
+  If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
+  If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit value to load into EAX prior to invoking the CPUID\r
+                instruction.\r
+  @param  Eax   Pointer to the 32-bit EAX value returned by the CPUID\r
+                instruction. This is an optional parameter that may be NULL.\r
+  @param  Ebx   Pointer to the 32-bit EBX value returned by the CPUID\r
+                instruction. This is an optional parameter that may be NULL.\r
+  @param  Ecx   Pointer to the 32-bit ECX value returned by the CPUID\r
+                instruction. This is an optional parameter that may be NULL.\r
+  @param  Edx   Pointer to the 32-bit EDX value returned by the CPUID\r
+                instruction. This is an optional parameter that may be NULL.\r
+\r
+  @return Index\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmCpuid (\r
+  IN      UINT32                    Index,\r
+  OUT     UINT32                    *Eax,  OPTIONAL\r
+  OUT     UINT32                    *Ebx,  OPTIONAL\r
+  OUT     UINT32                    *Ecx,  OPTIONAL\r
+  OUT     UINT32                    *Edx   OPTIONAL\r
+  );\r
+\r
+/**\r
+  Retrieves CPUID information using an extended leaf identifier.\r
+\r
+  Executes the CPUID instruction with EAX set to the value specified by Index\r
+  and ECX set to the value specified by SubIndex. This function always returns\r
+  Index. This function is only available on IA-32 and x64.\r
+\r
+  If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
+  If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
+  If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
+  If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
+\r
+  @param  Index     The 32-bit value to load into EAX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  SubIndex  The 32-bit value to load into ECX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  Eax       Pointer to the 32-bit EAX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ebx       Pointer to the 32-bit EBX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ecx       Pointer to the 32-bit ECX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Edx       Pointer to the 32-bit EDX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+\r
+  @return Index\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmCpuidEx (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    SubIndex,\r
+  OUT     UINT32                    *Eax,  OPTIONAL\r
+  OUT     UINT32                    *Ebx,  OPTIONAL\r
+  OUT     UINT32                    *Ecx,  OPTIONAL\r
+  OUT     UINT32                    *Edx   OPTIONAL\r
+  );\r
+\r
+/**\r
+  Returns the lower 32-bits of a Machine Specific Register(MSR).\r
+\r
+  Reads and returns the lower 32-bits of the MSR specified by Index.\r
+  No parameter checking is performed on Index, and some Index values may cause\r
+  CPU exceptions. The caller must either guarantee that Index is valid, or the\r
+  caller must set up exception handlers to catch the exceptions. This function\r
+  is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to read.\r
+\r
+  @return The lower 32 bits of the MSR identified by Index.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmReadMsr32 (\r
+  IN      UINT32                    Index\r
+  );\r
+\r
+/**\r
+  Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
+\r
+  Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
+  upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
+  the MSR is returned. No parameter checking is performed on Index or Value,\r
+  and some of these may cause CPU exceptions. The caller must either guarantee\r
+  that Index and Value are valid, or the caller must establish proper exception\r
+  handlers. This function is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to write.\r
+  @param  Value The 32-bit value to write to the MSR.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmWriteMsr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
+  writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the lower 32-bits of the read result and the value specified by\r
+  OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
+  32-bits of the value written to the MSR is returned. No parameter checking is\r
+  performed on Index or OrData, and some of these may cause CPU exceptions. The\r
+  caller must either guarantee that Index and OrData are valid, or the caller\r
+  must establish proper exception handlers. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  OrData  The value to OR with the read value from the MSR.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
+  the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  lower 32-bits of the read result and the value specified by AndData, and\r
+  writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
+  the value written to the MSR is returned. No parameter checking is performed\r
+  on Index or AndData, and some of these may cause CPU exceptions. The caller\r
+  must either guarantee that Index and AndData are valid, or the caller must\r
+  establish proper exception handlers. This function is only available on IA-32\r
+  and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAnd32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
+  on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  lower 32-bits of the read result and the value specified by AndData\r
+  preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
+  result of the AND operation and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
+  written to the MSR is returned. No parameter checking is performed on Index,\r
+  AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
+  must either guarantee that Index, AndData, and OrData are valid, or the\r
+  caller must establish proper exception handlers. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAndThenOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an MSR.\r
+\r
+  Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned. The caller must either guarantee that Index is valid, or the caller\r
+  must set up exception handlers to catch the exceptions. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The bit field read from the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldRead32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an MSR.\r
+\r
+  Writes Value to a bit field in the lower 32-bits of a  64-bit MSR. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination MSR are preserved. The lower 32-bits of the MSR written is\r
+  returned. Extra left bits in Value are stripped. The caller must either\r
+  guarantee that Index and the data written is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldWrite32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
+  written to the MSR are returned. Extra left bits in OrData are stripped. The\r
+  caller must either guarantee that Index and the data written is valid, or\r
+  the caller must set up exception handlers to catch the exceptions. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the MSR.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by AndData, and writes the result to the\r
+  64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
+  MSR are returned. Extra left bits in AndData are stripped. The caller must\r
+  either guarantee that Index and the data written is valid, or the caller must\r
+  set up exception handlers to catch the exceptions. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the MSR.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldAnd32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+  lower 32-bits of the value written to the MSR are returned. Extra left bits\r
+  in both AndData and OrData are stripped. The caller must either guarantee\r
+  that Index and the data written is valid, or the caller must set up exception\r
+  handlers to catch the exceptions. This function is only available on IA-32\r
+  and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the MSR.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldAndThenOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Returns a 64-bit Machine Specific Register(MSR).\r
+\r
+  Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
+  performed on Index, and some Index values may cause CPU exceptions. The\r
+  caller must either guarantee that Index is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to read.\r
+\r
+  @return The value of the MSR identified by Index.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMsr64 (\r
+  IN      UINT32                    Index\r
+  );\r
+\r
+/**\r
+  Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
+  value.\r
+\r
+  Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
+  64-bit value written to the MSR is returned. No parameter checking is\r
+  performed on Index or Value, and some of these may cause CPU exceptions. The\r
+  caller must either guarantee that Index and Value are valid, or the caller\r
+  must establish proper exception handlers. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to write.\r
+  @param  Value The 64-bit value to write to the MSR.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmWriteMsr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
+  back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+  returned. No parameter checking is performed on Index or OrData, and some of\r
+  these may cause CPU exceptions. The caller must either guarantee that Index\r
+  and OrData are valid, or the caller must establish proper exception handlers.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  OrData  The value to OR with the read value from the MSR.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by OrData, and writes the result to the\r
+  64-bit MSR specified by Index. The value written to the MSR is returned. No\r
+  parameter checking is performed on Index or OrData, and some of these may\r
+  cause CPU exceptions. The caller must either guarantee that Index and OrData\r
+  are valid, or the caller must establish proper exception handlers. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAnd64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r
+  OR, and writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
+  result and the value specified by AndData, performs a bitwise inclusive OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 64-bit MSR specified by Index. The value written\r
+  to the MSR is returned. No parameter checking is performed on Index, AndData,\r
+  or OrData, and some of these may cause CPU exceptions. The caller must either\r
+  guarantee that Index, AndData, and OrData are valid, or the caller must\r
+  establish proper exception handlers. This function is only available on IA-32\r
+  and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAndThenOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an MSR.\r
+\r
+  Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
+  StartBit and the EndBit. The value of the bit field is returned. The caller\r
+  must either guarantee that Index is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read from the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldRead64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an MSR.\r
+\r
+  Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
+  the StartBit and the EndBit. All other bits in the destination MSR are\r
+  preserved. The MSR written is returned. Extra left bits in Value are\r
+  stripped. The caller must either guarantee that Index and the data written is\r
+  valid, or the caller must set up exception handlers to catch the exceptions.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldWrite64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
+  writes the result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+  returned. Extra left bits in OrData are stripped. The caller must either\r
+  guarantee that Index and the data written is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by AndData, and writes the result to the\r
+  64-bit MSR specified by Index. The value written to the MSR is returned.\r
+  Extra left bits in AndData are stripped. The caller must either guarantee\r
+  that Index and the data written is valid, or the caller must set up exception\r
+  handlers to catch the exceptions. This function is only available on IA-32\r
+  and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldAnd64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
+  a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+  value written to the MSR is returned. Extra left bits in both AndData and\r
+  OrData are stripped. The caller must either guarantee that Index and the data\r
+  written is valid, or the caller must set up exception handlers to catch the\r
+  exceptions. This function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the bit field.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldAndThenOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads the current value of the EFLAGS register.\r
+\r
+  Reads and returns the current value of the EFLAGS register. This function is\r
+  only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r
+  64-bit value on X64.\r
+\r
+  @return EFLAGS on IA-32 or RFLAGS on X64.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadEflags (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of the Control Register 0 (CR0).\r
+\r
+  Reads and returns the current value of CR0. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of the Control Register 0 (CR0).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadCr0 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of the Control Register 2 (CR2).\r
+\r
+  Reads and returns the current value of CR2. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of the Control Register 2 (CR2).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadCr2 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of the Control Register 3 (CR3).\r
+\r
+  Reads and returns the current value of CR3. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of the Control Register 3 (CR3).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadCr3 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of the Control Register 4 (CR4).\r
+\r
+  Reads and returns the current value of CR4. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of the Control Register 4 (CR4).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadCr4 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes a value to Control Register 0 (CR0).\r
+\r
+  Writes and returns a new value to CR0. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Cr0 The value to write to CR0.\r
+\r
+  @return The value written to CR0.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteCr0 (\r
+  UINTN  Cr0\r
+  );\r
+\r
+/**\r
+  Writes a value to Control Register 2 (CR2).\r
+\r
+  Writes and returns a new value to CR2. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Cr2 The value to write to CR2.\r
+\r
+  @return The value written to CR2.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteCr2 (\r
+  UINTN  Cr2\r
+  );\r
+\r
+/**\r
+  Writes a value to Control Register 3 (CR3).\r
+\r
+  Writes and returns a new value to CR3. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Cr3 The value to write to CR3.\r
+\r
+  @return The value written to CR3.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteCr3 (\r
+  UINTN  Cr3\r
+  );\r
+\r
+/**\r
+  Writes a value to Control Register 4 (CR4).\r
+\r
+  Writes and returns a new value to CR4. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Cr4 The value to write to CR4.\r
+\r
+  @return The value written to CR4.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteCr4 (\r
+  UINTN  Cr4\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 0 (DR0).\r
+\r
+  Reads and returns the current value of DR0. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 0 (DR0).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr0 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 1 (DR1).\r
+\r
+  Reads and returns the current value of DR1. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 1 (DR1).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr1 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 2 (DR2).\r
+\r
+  Reads and returns the current value of DR2. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 2 (DR2).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr2 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 3 (DR3).\r
+\r
+  Reads and returns the current value of DR3. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 3 (DR3).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr3 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 4 (DR4).\r
+\r
+  Reads and returns the current value of DR4. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 4 (DR4).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr4 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 5 (DR5).\r
+\r
+  Reads and returns the current value of DR5. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 5 (DR5).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr5 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 6 (DR6).\r
+\r
+  Reads and returns the current value of DR6. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 6 (DR6).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr6 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Debug Register 7 (DR7).\r
+\r
+  Reads and returns the current value of DR7. This function is only available\r
+  on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
+  X64.\r
+\r
+  @return The value of Debug Register 7 (DR7).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmReadDr7 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 0 (DR0).\r
+\r
+  Writes and returns a new value to DR0. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr0 The value to write to Dr0.\r
+\r
+  @return The value written to Debug Register 0 (DR0).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr0 (\r
+  UINTN  Dr0\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 1 (DR1).\r
+\r
+  Writes and returns a new value to DR1. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr1 The value to write to Dr1.\r
+\r
+  @return The value written to Debug Register 1 (DR1).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr1 (\r
+  UINTN  Dr1\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 2 (DR2).\r
+\r
+  Writes and returns a new value to DR2. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr2 The value to write to Dr2.\r
+\r
+  @return The value written to Debug Register 2 (DR2).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr2 (\r
+  UINTN  Dr2\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 3 (DR3).\r
+\r
+  Writes and returns a new value to DR3. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr3 The value to write to Dr3.\r
+\r
+  @return The value written to Debug Register 3 (DR3).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr3 (\r
+  UINTN  Dr3\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 4 (DR4).\r
+\r
+  Writes and returns a new value to DR4. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr4 The value to write to Dr4.\r
+\r
+  @return The value written to Debug Register 4 (DR4).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr4 (\r
+  UINTN  Dr4\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 5 (DR5).\r
+\r
+  Writes and returns a new value to DR5. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr5 The value to write to Dr5.\r
+\r
+  @return The value written to Debug Register 5 (DR5).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr5 (\r
+  UINTN  Dr5\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 6 (DR6).\r
+\r
+  Writes and returns a new value to DR6. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr6 The value to write to Dr6.\r
+\r
+  @return The value written to Debug Register 6 (DR6).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr6 (\r
+  UINTN  Dr6\r
+  );\r
+\r
+/**\r
+  Writes a value to Debug Register 7 (DR7).\r
+\r
+  Writes and returns a new value to DR7. This function is only available on\r
+  IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
+\r
+  @param  Dr7 The value to write to Dr7.\r
+\r
+  @return The value written to Debug Register 7 (DR7).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmWriteDr7 (\r
+  UINTN  Dr7\r
+  );\r
+\r
+/**\r
+  Reads the current value of Code Segment Register (CS).\r
+\r
+  Reads and returns the current value of CS. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of CS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadCs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Data Segment Register (DS).\r
+\r
+  Reads and returns the current value of DS. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of DS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadDs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Extra Segment Register (ES).\r
+\r
+  Reads and returns the current value of ES. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of ES.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadEs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of FS Data Segment Register (FS).\r
+\r
+  Reads and returns the current value of FS. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of FS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadFs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of GS Data Segment Register (GS).\r
+\r
+  Reads and returns the current value of GS. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of GS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadGs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Stack Segment Register (SS).\r
+\r
+  Reads and returns the current value of SS. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of SS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadSs (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of Task Register (TR).\r
+\r
+  Reads and returns the current value of TR. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @return The current value of TR.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadTr (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If Gdtr is NULL, then ASSERT().\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmReadGdtr (\r
+  OUT     IA32_DESCRIPTOR           *Gdtr\r
+  );\r
+\r
+/**\r
+  Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
+\r
+  Writes and the current GDTR descriptor specified by Gdtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Gdtr is NULL, then ASSERT().\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteGdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Gdtr\r
+  );\r
+\r
+/**\r
+  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If Idtr is NULL, then ASSERT().\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmReadIdtr (\r
+  OUT     IA32_DESCRIPTOR           *Idtr\r
+  );\r
+\r
+/**\r
+  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Writes the current IDTR descriptor and returns it in Idtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Idtr is NULL, then ASSERT().\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteIdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Idtr\r
+  );\r
+\r
+/**\r
+  Reads the current Local Descriptor Table Register(LDTR) selector.\r
+\r
+  Reads and returns the current 16-bit LDTR descriptor value. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @return The current selector of LDT.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+AsmReadLdtr (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes the current Local Descriptor Table Register (GDTR) selector.\r
+\r
+  Writes and the current LDTR descriptor specified by Ldtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Ldtr  16-bit LDTR selector value.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteLdtr (\r
+  IN      UINT16                    Ldtr\r
+  );\r
+\r
+/**\r
+  Save the current floating point/SSE/SSE2 context to a buffer.\r
+\r
+  Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
+  Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmFxSave (\r
+  OUT     IA32_FX_BUFFER            *Buffer\r
+  );\r
+\r
+/**\r
+  Restores the current floating point/SSE/SSE2 context from a buffer.\r
+\r
+  Restores the current floating point/SSE/SSE2 state from the buffer specified\r
+  by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
+  If Buffer was not saved with AsmFxSave(), then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmFxRestore (\r
+  IN      CONST IA32_FX_BUFFER      *Buffer\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #0 (MM0).\r
+\r
+  Reads and returns the current value of MM0. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM0.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm0 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #1 (MM1).\r
+\r
+  Reads and returns the current value of MM1. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM1.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm1 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #2 (MM2).\r
+\r
+  Reads and returns the current value of MM2. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM2.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm2 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #3 (MM3).\r
+\r
+  Reads and returns the current value of MM3. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM3.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm3 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #4 (MM4).\r
+\r
+  Reads and returns the current value of MM4. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM4.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm4 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #5 (MM5).\r
+\r
+  Reads and returns the current value of MM5. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM5.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm5 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #6 (MM6).\r
+\r
+  Reads and returns the current value of MM6. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM6.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm6 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of 64-bit MMX Register #7 (MM7).\r
+\r
+  Reads and returns the current value of MM7. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of MM7.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadMm7 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #0 (MM0).\r
+\r
+  Writes the current value of MM0. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM0.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm0 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #1 (MM1).\r
+\r
+  Writes the current value of MM1. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM1.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm1 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #2 (MM2).\r
+\r
+  Writes the current value of MM2. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM2.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm2 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #3 (MM3).\r
+\r
+  Writes the current value of MM3. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM3.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm3 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #4 (MM4).\r
+\r
+  Writes the current value of MM4. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM4.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm4 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #5 (MM5).\r
+\r
+  Writes the current value of MM5. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM5.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm5 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #6 (MM6).\r
+\r
+  Writes the current value of MM6. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM6.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm6 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Writes the current value of 64-bit MMX Register #7 (MM7).\r
+\r
+  Writes the current value of MM7. This function is only available on IA32 and\r
+  X64.\r
+\r
+  @param  Value The 64-bit value to write to MM7.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteMm7 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads the current value of Time Stamp Counter (TSC).\r
+\r
+  Reads and returns the current value of TSC. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  @return The current value of TSC\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadTsc (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Reads the current value of a Performance Counter (PMC).\r
+\r
+  Reads and returns the current value of performance counter specified by\r
+  Index. This function is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit Performance Counter index to read.\r
+\r
+  @return The value of the PMC specified by Index.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadPmc (\r
+  IN      UINT32                    Index\r
+  );\r
+\r
+/**\r
+  Sets up a monitor buffer that is used by AsmMwait().\r
+\r
+  Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
+  and Edx. Returns Eax. This function is only available on IA-32 and X64.\r
+\r
+  @param  Eax The value to load into EAX or RAX before executing the MONITOR\r
+              instruction.\r
+  @param  Ecx The value to load into ECX or RCX before executing the MONITOR\r
+              instruction.\r
+  @param  Edx The value to load into EDX or RDX before executing the MONITOR\r
+              instruction.\r
+\r
+  @return Eax\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmMonitor (\r
+  IN      UINTN                     Eax,\r
+  IN      UINTN                     Ecx,\r
+  IN      UINTN                     Edx\r
+  );\r
+\r
+/**\r
+  Executes an MWAIT instruction.\r
+\r
+  Executes an MWAIT instruction with the register state specified by Eax and\r
+  Ecx. Returns Eax. This function is only available on IA-32 and X64.\r
+\r
+  @param  Eax The value to load into EAX or RAX before executing the MONITOR\r
+              instruction.\r
+  @param  Ecx The value to load into ECX or RCX before executing the MONITOR\r
+              instruction.\r
+\r
+  @return Eax\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmMwait (\r
+  IN      UINTN                     Eax,\r
+  IN      UINTN                     Ecx\r
+  );\r
+\r
+/**\r
+  Executes a WBINVD instruction.\r
+\r
+  Executes a WBINVD instruction. This function is only available on IA-32 and\r
+  X64.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWbinvd (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Executes a INVD instruction.\r
+\r
+  Executes a INVD instruction. This function is only available on IA-32 and\r
+  X64.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmInvd (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Flushes a cache line from all the instruction and data caches within the\r
+  coherency domain of the CPU.\r
+\r
+  Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  @param  LinearAddress The address of the cache line to flush. If the CPU is\r
+                        in a physical addressing mode, then LinearAddress is a\r
+                        physical address. If the CPU is in a virtual\r
+                        addressing mode, then LinearAddress is a virtual\r
+                        address.\r
+\r
+  @return LinearAddress\r
+**/\r
+VOID *\r
+EFIAPI\r
+AsmFlushCacheLine (\r
+  IN      VOID                      *LinearAddress\r
+  );\r
+\r
+/**\r
+  Enables the 32-bit paging mode on the CPU.\r
+\r
+  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode. This function is\r
+  only available on IA-32. After the 32-bit paging mode is enabled, control is\r
+  transferred to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit protected mode, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit protected mode with flat descriptors. This\r
+      means all descriptors must have a base of 0 and a limit of 4GB.\r
+  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
+      descriptors.\r
+  4)  CR3 must point to valid page tables that will be used once the transition\r
+      is complete, and those page tables must guarantee that the pages for this\r
+      function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is enabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is enabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is enabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmEnablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+/**\r
+  Disables the 32-bit paging mode on the CPU.\r
+\r
+  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 32-paged protected\r
+  mode. This function is only available on IA-32. After the 32-bit paging mode\r
+  is disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be NULL. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit paged mode, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit paged mode.\r
+  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
+  4)  CR3 must point to valid page tables that guarantee that the pages for\r
+      this function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is disabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is disabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is\r
+                      disabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmDisablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+/**\r
+  Enables the 64-bit paging mode on the CPU.\r
+\r
+  Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode with flat\r
+  descriptors. This function is only available on IA-32. After the 64-bit\r
+  paging mode is enabled, control is transferred to the function specified by\r
+  EntryPoint using the new stack specified by NewStack and passing in the\r
+  parameters specified by Context1 and Context2. Context1 and Context2 are\r
+  optional and may be 0. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit protected mode with flat\r
+  descriptors, then ASSERT().\r
+  If EntryPoint is 0, then ASSERT().\r
+  If NewStack is 0, then ASSERT().\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for long mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is enabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is enabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is enabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmEnablePaging64 (\r
+  IN      UINT16                    CodeSelector,\r
+  IN      UINT64                    EntryPoint,\r
+  IN      UINT64                    Context1,  OPTIONAL\r
+  IN      UINT64                    Context2,  OPTIONAL\r
+  IN      UINT64                    NewStack\r
+  );\r
+\r
+/**\r
+  Disables the 64-bit paging mode on the CPU.\r
+\r
+  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 64-paging mode.\r
+  This function is only available on X64. After the 64-bit paging mode is\r
+  disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be 0. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 64-bit paged mode, then ASSERT().\r
+  If EntryPoint is 0, then ASSERT().\r
+  If NewStack is 0, then ASSERT().\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for 32-bit protected mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is disabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is disabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is disabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmDisablePaging64 (\r
+  IN      UINT16                    CodeSelector,\r
+  IN      UINT32                    EntryPoint,\r
+  IN      UINT32                    Context1,  OPTIONAL\r
+  IN      UINT32                    Context2,  OPTIONAL\r
+  IN      UINT32                    NewStack\r
+  );\r
+\r
+//\r
+// 16-bit thunking services\r
+//\r
+\r
+/**\r
+  Retrieves the properties for 16-bit thunk functions.\r
+\r
+  Computes the size of the buffer and stack below 1MB required to use the\r
+  AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
+  buffer size is returned in RealModeBufferSize, and the stack size is returned\r
+  in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
+  then the actual minimum stack size is ExtraStackSize plus the maximum number\r
+  of bytes that need to be passed to the 16-bit real mode code.\r
+\r
+  If RealModeBufferSize is NULL, then ASSERT().\r
+  If ExtraStackSize is NULL, then ASSERT().\r
+\r
+  @param  RealModeBufferSize  A pointer to the size of the buffer below 1MB\r
+                              required to use the 16-bit thunk functions.\r
+  @param  ExtraStackSize      A pointer to the extra size of stack below 1MB\r
+                              that the 16-bit thunk functions require for\r
+                              temporary storage in the transition to and from\r
+                              16-bit real mode.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmGetThunk16Properties (\r
+  OUT     UINT32                    *RealModeBufferSize,\r
+  OUT     UINT32                    *ExtraStackSize\r
+  );\r
+\r
+/**\r
+  Prepares all structures a code required to use AsmThunk16().\r
+\r
+  Prepares all structures and code required to use AsmThunk16().\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmPrepareThunk16 (\r
+  OUT     THUNK_CONTEXT             *ThunkContext\r
+  );\r
+\r
+/**\r
+  Transfers control to a 16-bit real mode entry point and returns the results.\r
+\r
+  Transfers control to a 16-bit real mode entry point and returns the results.\r
+  AsmPrepareThunk16() must be called with ThunkContext before this function is\r
+  used.\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+  If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmThunk16 (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  );\r
+\r
+/**\r
+  Prepares all structures and code for a 16-bit real mode thunk, transfers\r
+  control to a 16-bit real mode entry point, and returns the results.\r
+\r
+  Prepares all structures and code for a 16-bit real mode thunk, transfers\r
+  control to a 16-bit real mode entry point, and returns the results. If the\r
+  caller only need to perform a single 16-bit real mode thunk, then this\r
+  service should be used. If the caller intends to make more than one 16-bit\r
+  real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
+  once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmPrepareAndThunk16 (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  );\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+  @param  NewBsp      A pointer to the new memory location for RSE backing\r
+                      store.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmSwitchStackAndBackingStore (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack,\r
+  IN      VOID                      *NewBsp\r
+  );\r
+\r
+typedef struct {\r
+  UINT64                            Status;\r
+  UINT64                            r9;\r
+  UINT64                            r10;\r
+  UINT64                            r11;\r
+} PAL_PROC_RETURN;\r
+\r
+//\r
+// IPF Specific functions\r
+//\r
+\r
+\r
+/**\r
+  Performs a PAL call using static calling convention.\r
+\r
+  An internal function to perform a PAL call using static calling convention.\r
+\r
+  @param  PalEntryPoint The entry point address of PAL. The address in ar.kr5\r
+                        would be used if this parameter were NULL on input.\r
+  @param  Arg1          The first argument of a PAL call.\r
+  @param  Arg1          The second argument of a PAL call.\r
+  @param  Arg1          The third argument of a PAL call.\r
+  @param  Arg1          The fourth argument of a PAL call.\r
+\r
+  @return The values returned in r8, r9, r10 and r11.\r
+\r
+**/\r
+PAL_PROC_RETURN\r
+PalCallStatic (\r
+  IN      CONST VOID                *PalEntryPoint,\r
+  IN      UINT64                    Arg1,\r
+  IN      UINT64                    Arg2,\r
+  IN      UINT64                    Arg3,\r
+  IN      UINT64                    Arg4\r
+  );\r
+\r
+\r
+/**\r
+  Returns the current value of ar.itc.\r
+\r
+  An internal function to return the current value of ar.itc, which is the\r
+  timer tick on IPF.\r
+\r
+  @return The currect value of ar.itc\r
+\r
+**/\r
+INT64\r
+IpfReadItc (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Flush a range of  cache lines in the cache coherency domain of the calling \r
+  CPU.\r
+\r
+  Invalidates the  cache lines specified by Address and Length. If Address is \r
+  not aligned on a cache line boundary, then entire cache line containing \r
+  Address is invalidated. If Address + Length is not aligned on a cache line \r
+  boundary, then the entire instruction cache line containing Address + Length\r
+  -1 is invalidated. This function may choose to invalidate the entire \r
+  instruction cache if that is more efficient than invalidating the specified \r
+  range. If Length is 0, the no instruction cache lines are invalidated. \r
+  Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction lines to invalidate. If \r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+IpfFlushCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h
new file mode 100644 (file)
index 0000000..5c8c144
--- /dev/null
@@ -0,0 +1,391 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueBaseMemoryLib.h\r
+  \r
+Abstract: \r
+\r
+  Memory-only library functions with no library constructor/destructor\r
+                                      \r
+--*/                                  \r
+                                      \r
+#ifndef __EDKII_GLUE_BASE_MEMORY_LIB_H__\r
+#define __EDKII_GLUE_BASE_MEMORY_LIB_H__\r
+\r
+\r
+#define CopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)     GlueCopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)\r
+#define ZeroMem(_BUFFER, _LENGTH)                               GlueZeroMem(_BUFFER, _LENGTH)\r
+#define SetMem(_BUFFER, _LENGTH, _VALUE)                        GlueSetMem(_BUFFER, _LENGTH, _VALUE)\r
+#define CompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)  GlueCompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)\r
+#define CompareGuid(_GUID1, _GUID2)                             GlueCompareGuid(_GUID1, _GUID2)\r
+\r
+\r
+/**\r
+  Copies a source buffer to a destination buffer, and returns the destination buffer.\r
+\r
+  This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r
+  DestinationBuffer.  The implementation must be reentrant, and it must handle the case\r
+  where SourceBuffer overlaps DestinationBuffer.\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
+\r
+  @param  DestinationBuffer   Pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        Pointer to the source buffer of the memory copy.\r
+  @param  Length              Number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @return DestinationBuffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueCopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a byte value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with Value, and returns Buffer.\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer    Memory to set.\r
+  @param  Length    Number of bytes to set.\r
+  @param  Value     Value of the set operation.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueSetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 16-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 16-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem16 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT16  Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 32-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 32-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem32 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT32  Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 64-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 64-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem64 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT64  Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with zeros, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with zeros, and returns Buffer.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to fill with zeros.\r
+  @param  Length      Number of bytes in Buffer to fill with zeros.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueZeroMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  );\r
+\r
+/**\r
+  Compares the contents of two buffers.\r
+\r
+  This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
+  If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the\r
+  value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
+  mismatched byte in DestinationBuffer.\r
+  If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().\r
+  If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
+\r
+  @param  DestinationBuffer Pointer to the destination buffer to compare.\r
+  @param  SourceBuffer      Pointer to the source buffer to compare.\r
+  @param  Length            Number of bytes to compare.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueCompareMem (\r
+  IN CONST VOID  *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for an 8-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem8 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT8       Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 16-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem16 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT16      Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 32-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem32 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT32      Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 64-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem64 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT64      Value\r
+  );\r
+\r
+/**\r
+  Copies a source GUID to a destination GUID.\r
+\r
+  This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
+  DestinationGuid, and returns DestinationGuid.\r
+  If DestinationGuid is NULL, then ASSERT().\r
+  If SourceGuid is NULL, then ASSERT().\r
+\r
+  @param  DestinationGuid   Pointer to the destination GUID.\r
+  @param  SourceGuid        Pointer to the source GUID.\r
+\r
+  @return DestinationGuid.\r
+\r
+**/\r
+GUID *\r
+EFIAPI\r
+CopyGuid (\r
+  OUT GUID       *DestinationGuid,\r
+  IN CONST GUID  *SourceGuid\r
+  );\r
+\r
+/**\r
+  Compares two GUIDs.\r
+\r
+  This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.\r
+  If there are any bit differences in the two GUIDs, then FALSE is returned.\r
+  If Guid1 is NULL, then ASSERT().\r
+  If Guid2 is NULL, then ASSERT().\r
+\r
+  @param  Guid1       A pointer to a 128 bit GUID.\r
+  @param  Guid2       A pointer to a 128 bit GUID.\r
+\r
+  @retval TRUE        Guid1 and Guid2 are identical.\r
+  @retval FALSE       Guid1 and Guid2 are not identical.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueCompareGuid (\r
+  IN CONST GUID  *Guid1,\r
+  IN CONST GUID  *Guid2\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan.\r
+  @param  Guid    Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN CONST GUID  *Guid\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h
new file mode 100644 (file)
index 0000000..db1702f
--- /dev/null
@@ -0,0 +1,224 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueCacheMaintenanceLib.h\r
+  \r
+Abstract: \r
+\r
+  Cache Maintenance Functions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__\r
+#define __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__\r
+\r
+\r
+#define InvalidateInstructionCache() GlueInvalidateInstructionCache()\r
+\r
+\r
+/**\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueInvalidateInstructionCache (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU. This function guarantees that all dirty cache lines are\r
+  written back to system memory, and also invalidates all the data cache lines\r
+  in the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackInvalidateDataCache (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes Back and Invalidates a range of data cache lines in the cache\r
+  coherency domain of the calling CPU.\r
+\r
+  Writes Back and Invalidate the data cache lines specified by Address and\r
+  Length. If Address is not aligned on a cache line boundary, then entire data\r
+  cache line containing Address is written back and invalidated. If Address +\r
+  Length is not aligned on a cache line boundary, then the entire data cache\r
+  line containing Address + Length -1 is written back and invalidated. This\r
+  function may choose to write back and invalidate the entire data cache if\r
+  that is more efficient than writing back and invalidating the specified\r
+  range. If Length is 0, the no data cache lines are written back and\r
+  invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back and\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back and invalidate from the\r
+                  data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackInvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU. This function guarantees that all dirty cache lines are written back to\r
+  system memory. This function may also invalidate all the data cache lines in\r
+  the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackDataCache (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes Back a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Writes Back the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is written back. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is written back. This function may choose to write back the entire\r
+  data cache if that is more efficient than writing back the specified range.\r
+  If Length is 0, the no data cache lines are written back. This function may\r
+  also invalidate all the data cache lines in the specified range of the cache\r
+  coherency domain of the calling CPU. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing\r
+                  mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU. This function must be used with care because dirty cache lines are not\r
+  written back to system memory. It is typically used for cache diagnostics. If\r
+  the CPU does not support invalidation of the entire data cache, then a write\r
+  back and invalidate operation should be performed on the entire data cache.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InvalidateDataCache (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Invalidates a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is invalidated. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is invalidated. This function must never invalidate any cache lines\r
+  outside the specified range. If Length is 0, the no data cache lines are\r
+  invalidated. Address is returned. This function must be used with care\r
+  because dirty cache lines are not written back to system memory. It is\r
+  typically used for cache diagnostics. If the CPU does not support\r
+  invalidation of a data cache range, then a write back and invalidate\r
+  operation should be performed on the data cache range.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to invalidate. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+  @param  Length  The number of bytes to invalidate from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h
new file mode 100644 (file)
index 0000000..577b28d
--- /dev/null
@@ -0,0 +1,571 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDebugLib.h\r
+  \r
+Abstract: \r
+\r
+  Public include file for the Debug Library\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEBUG_LIB_H__\r
+#define __EDKII_GLUE_DEBUG_LIB_H__\r
+\r
+//\r
+// To use EdkII code, these R8.x macros are undefined\r
+//\r
+#undef ASSERT\r
+#undef DEBUG\r
+#undef ASSERT_EFI_ERROR\r
+#undef ASSERT_PROTOCOL_ALREADY_INSTALLED\r
+#undef DEBUG_CODE\r
+#undef CR\r
+\r
+#undef EFI_D_INIT\r
+#undef EFI_D_WARN\r
+#undef EFI_D_LOAD\r
+#undef EFI_D_FS\r
+#undef EFI_D_POOL\r
+#undef EFI_D_PAGE\r
+#undef EFI_D_INFO\r
+#undef EFI_D_VARIABLE\r
+#undef EFI_D_BM   \r
+#undef EFI_D_BLKIO\r
+#undef EFI_D_NET    \r
+#undef EFI_D_UNDI\r
+#undef EFI_D_LOADFILE\r
+#undef EFI_D_EVENT\r
+#undef EFI_D_ERROR\r
+\r
+//\r
+// Declare bits for PcdDebugPropertyMask\r
+//\r
+#define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED       0x01\r
+#define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED        0x02\r
+#define DEBUG_PROPERTY_DEBUG_CODE_ENABLED         0x04\r
+#define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED       0x08\r
+#define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED  0x10\r
+#define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED    0x20\r
+\r
+//\r
+// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint()\r
+//\r
+#define DEBUG_INIT      0x00000001  // Initialization\r
+#define DEBUG_WARN      0x00000002  // Warnings\r
+#define DEBUG_LOAD      0x00000004  // Load events\r
+#define DEBUG_FS        0x00000008  // EFI File system\r
+#define DEBUG_POOL      0x00000010  // Alloc & Free's\r
+#define DEBUG_PAGE      0x00000020  // Alloc & Free's\r
+#define DEBUG_INFO      0x00000040  // Verbose\r
+#define DEBUG_VARIABLE  0x00000100  // Variable\r
+#define DEBUG_BM        0x00000400  // Boot Manager\r
+#define DEBUG_BLKIO     0x00001000  // BlkIo Driver\r
+#define DEBUG_NET       0x00004000  // SNI Driver\r
+#define DEBUG_UNDI      0x00010000  // UNDI Driver\r
+#define DEBUG_LOADFILE  0x00020000  // UNDI Driver\r
+#define DEBUG_EVENT     0x00080000  // Event messages\r
+#define DEBUG_ERROR     0x80000000  // Error\r
+\r
+//\r
+// Aliases of debug message mask bits\r
+//\r
+#define EFI_D_INIT      DEBUG_INIT\r
+#define EFI_D_WARN      DEBUG_WARN\r
+#define EFI_D_LOAD      DEBUG_LOAD\r
+#define EFI_D_FS        DEBUG_FS\r
+#define EFI_D_POOL      DEBUG_POOL\r
+#define EFI_D_PAGE      DEBUG_PAGE\r
+#define EFI_D_INFO      DEBUG_INFO\r
+#define EFI_D_VARIABLE  DEBUG_VARIABLE\r
+#define EFI_D_BM        DEBUG_BM\r
+#define EFI_D_BLKIO     DEBUG_BLKIO\r
+#define EFI_D_NET       DEBUG_NET\r
+#define EFI_D_UNDI      DEBUG_UNDI\r
+#define EFI_D_LOADFILE  DEBUG_LOADFILE\r
+#define EFI_D_EVENT     DEBUG_EVENT\r
+#define EFI_D_ERROR     DEBUG_ERROR\r
+\r
+/**\r
+\r
+  Prints a debug message to the debug output device if the specified error level is enabled.\r
+\r
+  If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r
+  the message specified by Format and the associated variable argument list to \r
+  the debug output device.\r
+\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  ErrorLevel  The error level of the debug message.\r
+  @param  Format      Format string for the debug message to print.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugPrint (\r
+  IN  UINTN        ErrorLevel,\r
+  IN  CONST CHAR8  *Format,\r
+  ...\r
+  );\r
+\r
+\r
+/**\r
+\r
+  Prints an assert message containing a filename, line number, and description.  \r
+  This may be followed by a breakpoint or a dead loop.\r
+\r
+  Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r
+  to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of \r
+  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if \r
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then \r
+  CpuDeadLoop() is called.  If neither of these bits are set, then this function \r
+  returns immediately after the message is printed to the debug output device.\r
+  DebugAssert() must actively prevent recusrsion.  If DebugAssert() is called while\r
+  processing another DebugAssert(), then DebugAssert() must return immediately.\r
+\r
+  If FileName is NULL, then a <FileName> string of ?NULL) Filename?is printed.\r
+\r
+  If Description is NULL, then a <Description> string of ?NULL) Description?is printed.\r
+\r
+  @param  FileName     Pointer to the name of the source file that generated the assert condition.\r
+  @param  LineNumber   The line number in the source file that generated the assert condition\r
+  @param  Description  Pointer to the description of the assert condition.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugAssert (\r
+  IN CONST CHAR8  *FileName,\r
+  IN UINTN        LineNumber,\r
+  IN CONST CHAR8  *Description\r
+  );\r
+\r
+\r
+/**\r
+\r
+  Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the value specified by \r
+  PcdDebugClearMemoryValue, and returns Buffer.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). \r
+\r
+  @param   Buffer  Pointer to the target buffer to fill with PcdDebugClearMemoryValue.\r
+  @param   Length  Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r
+\r
+  @return  Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+DebugClearMemory (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  );\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if ASSERT() macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugAssertEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugPrintEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CODE()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugCodeEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugClearMemoryEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  \r
+  Internal worker macro that calls DebugAssert().\r
+\r
+  This macro calls DebugAssert() passing in the filename, line number, and \r
+  expression that evailated to FALSE.\r
+\r
+  @param  Expression  Boolean expression that evailated to FALSE\r
+\r
+**/\r
+#define _ASSERT(Expression)  DebugAssert (__FILE__, __LINE__, #Expression)\r
+\r
+\r
+/**\r
+  \r
+  Internal worker macro that calls DebugPrint().\r
+\r
+  This macro calls DebugPrint() passing in the debug error level, a format \r
+  string, and a variable argument list.\r
+\r
+  @param  Expression  Expression containing an error level, a format string, \r
+                      and a variable argument list based on the format string.\r
+\r
+**/\r
+#define _DEBUG(Expression)   DebugPrint Expression\r
+\r
+\r
+/**\r
+  \r
+  Macro that calls DebugAssert() if a expression evaluates to FALSE.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro evaluates the Boolean expression specified by Expression.  If \r
+  Expression evaluates to FALSE, then DebugAssert() is called passing in the \r
+  source filename, source line number, and Expression.\r
+\r
+  @param  Expression  Boolean expression\r
+\r
+**/\r
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  // Glue Library internal\r
+  \r
+  #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE\r
+    #ifdef EFI_DEBUG\r
+    #define ASSERT(Expression)        \\r
+      do {                            \\r
+        if (DebugAssertEnabled ()) {  \\r
+          if (!(Expression)) {        \\r
+            _ASSERT (Expression);     \\r
+          }                           \\r
+        }                             \\r
+      } while (FALSE)\r
+    #endif\r
+  #else\r
+    #define ASSERT(Expression) do{} while(0)\r
+  #endif    \r
+\r
+#else\r
+  // External usage\r
+\r
+  #ifdef EFI_DEBUG\r
+    #define ASSERT(Expression)        \\r
+      do {                            \\r
+        if (DebugAssertEnabled ()) {  \\r
+          if (!(Expression)) {        \\r
+            _ASSERT (Expression);     \\r
+          }                           \\r
+        }                             \\r
+      } while (FALSE)\r
+  #else\r
+    #define ASSERT(Expression) do{} while(0)\r
+  #endif\r
+\r
+#endif\r
+\r
+/**\r
+  \r
+  Macro that calls DebugPrint().\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro passes Expression to DebugPrint().\r
+\r
+  @param  Expression  Expression containing an error level, a format string, \r
+                      and a variable argument list based on the format string.\r
+  \r
+\r
+**/\r
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  // Glue Library internal\r
+  \r
+  #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE\r
+    #ifdef EFI_DEBUG\r
+    #define DEBUG(Expression)        \\r
+      do {                           \\r
+        if (DebugPrintEnabled ()) {  \\r
+          _DEBUG (Expression);       \\r
+        }                            \\r
+      } while (FALSE)\r
+    #endif\r
+  #else\r
+    #define DEBUG(Expression) do{} while(0)\r
+  #endif    \r
+\r
+#else\r
+  // External usage\r
+\r
+  #ifdef EFI_DEBUG\r
+    #define DEBUG(Expression)        \\r
+      do {                           \\r
+        if (DebugPrintEnabled ()) {  \\r
+          _DEBUG (Expression);       \\r
+        }                            \\r
+      } while (FALSE)\r
+  #else\r
+    #define DEBUG(Expression) do{} while(0)\r
+  #endif\r
+\r
+#endif\r
+\r
+\r
+/**\r
+  \r
+  Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro evaluates the EFI_STATUS value specified by StatusParameter.  \r
+  If StatusParameter is an error code, then DebugAssert() is called passing in \r
+  the source filename, source line number, and StatusParameter.\r
+\r
+  @param  StatusParameter  EFI_STATUS value to evaluate.\r
+\r
+**/\r
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  // Glue Library internal\r
+  \r
+  #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE\r
+    #ifdef EFI_DEBUG\r
+    #define ASSERT_EFI_ERROR(StatusParameter)                                              \\r
+      do {                                                                                 \\r
+        if (DebugAssertEnabled ()) {                                                       \\r
+          if (EFI_ERROR (StatusParameter)) {                                               \\r
+            DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter));  \\r
+            _ASSERT (!EFI_ERROR (StatusParameter));                                        \\r
+          }                                                                                \\r
+        }                                                                                  \\r
+      } while (FALSE)\r
+    #endif\r
+  #else\r
+    #define ASSERT_EFI_ERROR(Expression) do{} while(0)\r
+  #endif    \r
+\r
+#else\r
+  // External usage\r
+\r
+  #ifdef EFI_DEBUG\r
+    #define ASSERT_EFI_ERROR(StatusParameter)                                              \\r
+      do {                                                                                 \\r
+        if (DebugAssertEnabled ()) {                                                       \\r
+          if (EFI_ERROR (StatusParameter)) {                                               \\r
+            DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter));  \\r
+            _ASSERT (!EFI_ERROR (StatusParameter));                                        \\r
+          }                                                                                \\r
+        }                                                                                  \\r
+      } while (FALSE)\r
+  #else\r
+    #define ASSERT_EFI_ERROR(Expression) do{} while(0)\r
+  #endif\r
+\r
+#endif\r
+\r
+\r
+/**\r
+  \r
+  Macro that calls DebugAssert() if a protocol is already installed in the \r
+  handle database.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, \r
+  then return.\r
+\r
+  If Handle is NULL, then a check is made to see if the protocol specified by Guid \r
+  is present on any handle in the handle database.  If Handle is not NULL, then \r
+  a check is made to see if the protocol specified by Guid is present on the \r
+  handle specified by Handle.  If the check finds the protocol, then DebugAssert() \r
+  is called passing in the source filename, source line number, and Guid.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  Handle  The handle to check for the protocol.  This is an optional \r
+                  parameter that may be NULL.  If it is NULL, then the entire \r
+                  handle database is searched.\r
+\r
+  @param  Guid    Pointer to a protocol GUID.\r
+\r
+**/\r
+#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)                               \\r
+  do {                                                                                \\r
+    if (DebugAssertEnabled ()) {                                                      \\r
+      VOID  *Instance;                                                                \\r
+      ASSERT (Guid != NULL);                                                          \\r
+      if (Handle == NULL) {                                                           \\r
+        if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) {   \\r
+          _ASSERT (Guid already installed in database);                               \\r
+        }                                                                             \\r
+      } else {                                                                        \\r
+        if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \\r
+          _ASSERT (Guid already installed on Handle);                                 \\r
+        }                                                                             \\r
+      }                                                                               \\r
+    }                                                                                 \\r
+  } while (FALSE)\r
+\r
+\r
+/**\r
+  Macro that marks the beginning of debug source code.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro marks the beginning of source code that is included in a module.\r
+  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r
+  are not included in a module.\r
+\r
+**/\r
+#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  __DebugCodeLocal\r
+\r
+\r
+/**\r
+  \r
+  Macro that marks the end of debug source code.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro marks the end of source code that is included in a module.  \r
+  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r
+  are not included in a module.\r
+\r
+**/\r
+#define DEBUG_CODE_END()    __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)\r
+\r
+\r
+/**\r
+  \r
+  Macro that declares a section of debug source code.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r
+  then the source code specified by Expression is included in a module.  \r
+  Otherwise, the source specified by Expression is not included in a module.\r
+\r
+**/\r
+#define DEBUG_CODE(Expression)  \\r
+  DEBUG_CODE_BEGIN ();          \\r
+  Expression                    \\r
+  DEBUG_CODE_END ()\r
+\r
+\r
+/**\r
+  \r
+  Macro that calls DebugClearMemory() to clear a buffer to a default value.\r
+\r
+  If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro calls DebugClearMemory() passing in Address and Length.\r
+\r
+  @param  Address  Pointer to a buffer.\r
+  @param  Length   The number of bytes in the buffer to set.\r
+\r
+**/\r
+#define DEBUG_CLEAR_MEMORY(Address, Length)  \\r
+  do {                                       \\r
+    if (DebugClearMemoryEnabled ()) {        \\r
+      DebugClearMemory (Address, Length);    \\r
+    }                                        \\r
+  } while (FALSE)\r
+\r
+\r
+/**\r
+\r
+  Macro that calls DebugAssert() if the containing record does not have a \r
+  matching signature.  If the signatures matches, then a pointer to the data \r
+  structure that contains a specified field of that data structure is returned.  \r
+  This is a light weight method hide information by placing a public data \r
+  structure inside a larger private data structure and using a pointer to the \r
+  public data structure to retrieve a pointer to the private data structure.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, \r
+  then this macro computes the offset, in bytes, of field specified by Field \r
+  from the beginning of the  data structure specified by TYPE.  This offset is \r
+  subtracted from Record, and is used to return a pointer to a data structure \r
+  of the type specified by TYPE.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,  \r
+  then this macro computes the offset, in bytes, of field specified by Field from \r
+  the beginning of the data structure specified by TYPE.  This offset is \r
+  subtracted from Record, and is used to compute a pointer to a data structure of \r
+  the type specified by TYPE.  The Signature field of the data structure specified \r
+  by TYPE is compared to TestSignature.  If the signatures match, then a pointer \r
+  to the pointer to a data structure of the type specified by TYPE is returned.  \r
+  If the signatures do not match, then DebugAssert() is called with a description \r
+  of "CR has a bad signature" and Record is returned.  \r
+\r
+  If the data type specified by TYPE does not contain the field specified by Field, \r
+  then the module will not compile.\r
+\r
+  If TYPE does not contain a field called Signature, then the module will not \r
+  compile.\r
+\r
+  @param  Record         Pointer to the field specified by Field within a data \r
+                         structure of type TYPE.\r
+\r
+  @param  TYPE           The name of the data structure type to return  This \r
+                         data structure must contain the field specified by Field. \r
+\r
+  @param  Field          The name of the field in the data structure specified \r
+                         by TYPE to which Record points.\r
+\r
+  @param  TestSignature  The 32-bit signature value to match.\r
+\r
+**/\r
+#define CR(Record, TYPE, Field, TestSignature)                                          \\r
+  (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ?  \\r
+  (TYPE *) (_ASSERT (CR has Bad Signature), Record) :                                   \\r
+  _CR (Record, TYPE, Field)\r
+    \r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h
new file mode 100644 (file)
index 0000000..42adebe
--- /dev/null
@@ -0,0 +1,269 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+  \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDevicePathLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Device Path Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DEVICE_PATH_LIB_H__\r
+#define __EDKII_GLUE_DEVICE_PATH_LIB_H__\r
+\r
+\r
+#define GetDevicePathSize(_DEVICEPATH)                      GlueGetDevicePathSize(_DEVICEPATH)\r
+#define DuplicateDevicePath(_DEVICEPATH)                    GlueDuplicateDevicePath(_DEVICEPATH)\r
+#define AppendDevicePath(_FIRSTPATH, _SECONDPATH)           GlueAppendDevicePath(_FIRSTPATH, _SECONDPATH)\r
+#define AppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE)  GlueAppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE)\r
+#define AppendDevicePathInstance(_SOURCE, _INSTANCE)        GlueAppendDevicePathInstance(_SOURCE,_INSTANCE)\r
+#define GetNextDevicePathInstance(_DEVICEPATH, _SIZE)       GlueGetNextDevicePathInstance(_DEVICEPATH, _SIZE)\r
+#define IsDevicePathMultiInstance(_DEVICEPATH)              GlueIsDevicePathMultiInstance(_DEVICEPATH)\r
+#define DevicePathFromHandle(_HANDLE)                       GlueDevicePathFromHandle(_HANDLE)\r
+#define FileDevicePath(_DEVICE, _FILENAME)                  GlueFileDevicePath(_DEVICE, _FILENAME)\r
+\r
+\r
+/**\r
+  Returns the size of a device path in bytes.\r
+\r
+  This function returns the size, in bytes, of the device path data structure specified by\r
+  DevicePath including the end of device path node.  If DevicePath is NULL, then 0 is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @return The size of a device path in bytes.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueGetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  If\r
+  DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the\r
+  contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
+  is returned.  Otherwise, NULL is returned.  \r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @return A pointer to the duplicated device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueDuplicateDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
+  FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from\r
+  SecondDevicePath is retained. The newly created device path is returned.  \r
+  If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.  \r
+  If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.  \r
+  If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.  \r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. It is the\r
+  responsibility of the caller to free the memory allocated.\r
+\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node specified by\r
+  DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device node.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If DevicePathNode is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePathNode (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
\r
+  This function creates a new device path by appending a copy of the device path instance specified\r
+  by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device path instance\r
+  and a new end-of-device-path-instance node is inserted between. \r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePathInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates DevicePath to\r
+  point to the next device path instance in the device path (or NULL if no more) and updates Size\r
+  to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
\r
+  @param  DevicePath                 On input, this holds the pointer to the current device path\r
+                                     instance. On output, this holds the pointer to the next device\r
+                                     path instance or NULL if there are no more device path\r
+                                     instances in the device path pointer to a device path data\r
+                                     structure.\r
+  @param  Size                       On output, this holds the size of the device path instance, in\r
+                                     bytes or zero, if DevicePath is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueGetNextDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,\r
+  OUT UINTN                          *Size\r
+  );\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a new device node in a newly allocated buffer of size NodeLength and\r
+  initializes the device path node header with NodeType and NodeSubType.  The new device path node\r
+  is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.  \r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
+\r
+  @return The new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+CreateDeviceNode (\r
+  IN UINT8                           NodeType,\r
+  IN UINT8                           NodeSubType,\r
+  IN UINT16                          NodeLength\r
+  );\r
+\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
+\r
+  This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
+  Otherwise, FALSE is returned.  If DevicePath is NULL, then FALSE is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance or DevicePath is NULL.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsDevicePathMultiInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+/**\r
+  Retrieves the device path protocol from a handle.\r
+\r
+  This function returns the device path protocol from the handle specified by Handle.  If Handle is\r
+  NULL or Handle does not contain a device path protocol, then NULL is returned.\r
\r
+  @param  Handle                     The handle from which to retrieve the device path protocol.\r
+\r
+  @return The device path protocol from the handle specified by Handle.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueDevicePathFromHandle (\r
+  IN EFI_HANDLE                      Handle\r
+  );\r
+\r
+/**\r
+  Allocates a device path for a file and appends it to an existing device path.\r
+\r
+  If Device is a valid device handle that contains a device path protocol, then a device path for\r
+  the file specified by FileName  is allocated and appended to the device path associated with the\r
+  handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle\r
+  that does not support the device path protocol, then a device path containing a single device\r
+  path node for the file specified by FileName is allocated and returned.\r
+  If FileName is NULL, then ASSERT().\r
+\r
+  @param  Device                     A pointer to a device handle.  This parameter is optional and\r
+                                     may be NULL.\r
+  @param  FileName                   A pointer to a Null-terminated Unicode string.\r
+\r
+  @return The allocated device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueFileDevicePath (\r
+  IN EFI_HANDLE                      Device,     OPTIONAL\r
+  IN CONST CHAR16                    *FileName\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h
new file mode 100644 (file)
index 0000000..f5ee0bc
--- /dev/null
@@ -0,0 +1,454 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+  \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxeRuntimeDriverLib.h\r
+  \r
+Abstract: \r
+\r
+  Library that abstracts runtime services\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__\r
+#define __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__\r
+\r
+#ifdef MDE_CPU_IPF\r
+#include "EdkIIGlueEdkDxeSalLib.h"\r
+#endif\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+\r
+typedef struct {\r
+  EFI_GUID  CapsuleGuid;\r
+  UINT32    HeaderSize;\r
+  UINT32    Flags;\r
+  UINT32    CapsuleImageSize;\r
+} UEFI_CAPSULE_HEADER;\r
+\r
+#else\r
+\r
+typedef EFI_CAPSULE_HEADER UEFI_CAPSULE_HEADER;\r
+\r
+#endif\r
+\r
+extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[];\r
+\r
+extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[];\r
+\r
+/**\r
+  Check to see if the execute context is in Runtime phase or not.\r
+\r
+  @param  None.\r
+\r
+  @retval  TRUE  The driver is in SMM.\r
+  @retval  FALSE The driver is not in SMM.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiAtRuntime (\r
+  VOID \r
+  );\r
+\r
+/**\r
+  Check to see if the SetVirtualAddressMsp() is invoked or not.\r
+\r
+  @retval  TRUE  SetVirtualAddressMsp() has been called.\r
+  @retval  FALSE SetVirtualAddressMsp() has not been called.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiGoneVirtual (\r
+  VOID \r
+  );\r
+\r
+/**\r
+  Return current time and date information, and time-keeping \r
+  capabilities of hardware platform.\r
+\r
+  @param  Time         A pointer to storage to receive a snapshot of the current time.\r
+  @param  Capabilities An optional pointer to a buffer to receive the real time clock device's\r
+                       capabilities.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  );\r
+\r
+/**\r
+  Set current time and date information.\r
+\r
+  @param  Time         A pointer to cache of time setting.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to execute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  );\r
+\r
+/**\r
+  Return current wakeup alarm clock setting.\r
+\r
+  @param  Enabled Indicate if the alarm clock is enabled or disabled.\r
+  @param  Pending Indicate if the alarm signal is pending and requires acknowledgement.\r
+  @param  Time    Current alarm clock setting.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  );\r
+\r
+/**\r
+  Set current wakeup alarm clock.\r
+\r
+  @param  Enable Enable or disable current alarm clock..\r
+  @param  Time   Point to alarm clock setting.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  );\r
+\r
+/**\r
+  Return value of variable.\r
+\r
+  @param  VariableName the name of the vendor's variable, it's a \r
+                       Null-Terminated Unicode String\r
+  @param  VendorGuid   Unify identifier for vendor.\r
+  @param  Attributes   Point to memory location to return the attributes of variable. If the point \r
+                       is NULL, the parameter would be ignored.\r
+  @param  DataSize     As input, point to the maxinum size of return Data-Buffer.\r
+                       As output, point to the actual size of the returned Data-Buffer.\r
+  @param  Data         Point to return Data-Buffer.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetVariable (\r
+  IN      CHAR16                   *VariableName,\r
+  IN      EFI_GUID                 *VendorGuid,\r
+  OUT     UINT32                   *Attributes,\r
+  IN OUT  UINTN                    *DataSize,\r
+  OUT     VOID                     *Data\r
+  )\r
+;\r
+\r
+/**\r
+  Enumerates variable's name.\r
+\r
+  @param  VariableNameSize As input, point to maxinum size of variable name.\r
+                           As output, point to actual size of varaible name.\r
+  @param  VariableName     As input, supplies the last VariableName that was returned by \r
+                           GetNextVariableName().\r
+                           As output, returns the name of variable. The name \r
+                           string is Null-Terminated Unicode string.\r
+  @param  VendorGuid       As input, supplies the last VendorGuid that was returned by \r
+                           GetNextVriableName().\r
+                           As output, returns the VendorGuid of the current variable.\r
\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  );\r
+\r
+/**\r
+  Sets value of variable.\r
+\r
+  @param  VariableName the name of the vendor's variable, it's a \r
+                       Null-Terminated Unicode String\r
+  @param  VendorGuid   Unify identifier for vendor.\r
+  @param  Attributes   Point to memory location to return the attributes of variable. If the point \r
+                       is NULL, the parameter would be ignored.\r
+  @param  DataSize     The size in bytes of Data-Buffer.\r
+  @param  Data         Point to the content of the variable.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  );\r
+\r
+/**\r
+  Returns the next high 32 bits of platform's monotonic counter.\r
+\r
+  @param  HighCount Pointer to returned value.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  );\r
+\r
+/**\r
+  Resets the entire platform.\r
+\r
+  @param  ResetType   The type of reset to perform.\r
+  @param  ResetStatus The status code for reset.\r
+  @param  DataSize    The size in bytes of reset data.\r
+  @param  ResetData   Pointer to data buffer that includes \r
+                      Null-Terminated Unicode string.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+VOID\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  );\r
+\r
+/**\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+  @param  DebugDisposition   Supplies type information for the pointer being converted.\r
+  @param  Address            The pointer to a pointer that is to be fixed to be the \r
+                             value needed for the new virtual address mapping being \r
+                             applied.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertPointer (\r
+  IN UINTN                  DebugDisposition,\r
+  IN OUT VOID               **Address\r
+  );\r
+\r
+\r
+/**\r
+  Change the runtime addressing mode of EFI firmware from physical to virtual.\r
+\r
+  @param  MemoryMapSize         The size in bytes of VirtualMap.\r
+  @param  DescriptorSize        The size in bytes of an entry in the VirtualMap.\r
+  @param  DescriptorVersion     The version of the structure entries in VirtualMap.\r
+  @param  VirtualMap            An array of memory descriptors which contain new virtual\r
+                                address mapping information for all runtime ranges. Type\r
+                                EFI_MEMORY_DESCRIPTOR is defined in the\r
+                                GetMemoryMap() function description.\r
+\r
+  @retval EFI_SUCCESS           The virtual address map has been applied.\r
+  @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in\r
+                                virtual address mapped mode.\r
+  @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r
+                                invalid.\r
+  @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory\r
+                                map that requires a mapping.\r
+  @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found\r
+                                in the memory map.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVirtualAddressMap (\r
+  IN UINTN                          MemoryMapSize,\r
+  IN UINTN                          DescriptorSize,\r
+  IN UINT32                         DescriptorVersion,\r
+  IN CONST EFI_MEMORY_DESCRIPTOR    *VirtualMap\r
+  );\r
+\r
+\r
+/**\r
+  Conver the standard Lib double linked list to a virtual mapping.\r
+\r
+  @param  DebugDisposition   Supplies type information for the pointer being converted.\r
+  @param  ListHead           Head of linked list to convert.\r
+\r
+  @retval  EFI_SUCCESS  Success to execute the function.\r
+  @retval  !EFI_SUCCESS Failed to e3xecute the function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT LIST_ENTRY       *ListHead\r
+  );\r
+\r
+/**\r
\r
+  Passes capsules to the firmware with both virtual and physical mapping. \r
+  Depending on the intended consumption, the firmware may\r
+  process the capsule immediately. If the payload should persist across a\r
+  system reset, the reset value returned from EFI_QueryCapsuleCapabilities must\r
+  be passed into ResetSystem() and will cause the capsule to be processed by \r
+  the firmware as part of the reset process.\r
+  \r
+  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules\r
+                                being passed into update capsule. Each capsules is assumed to\r
+                                stored in contiguous virtual memory. The capsules in the\r
+                                CapsuleHeaderArray must be the same capsules as the\r
+                                ScatterGatherList. The CapsuleHeaderArray must\r
+                                have the capsules in the same order as the ScatterGatherList.\r
+  @param  CapsuleCount          Number of pointers to EFI_CAPSULE_HEADER in\r
+                                CaspuleHeaderArray.\r
+  @param  ScatterGatherList     Physical pointer to a set of\r
+                                EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the\r
+                                location in physical memory of a set of capsules. See Related\r
+                                Definitions for an explanation of how more than one capsule is\r
+                                passed via this interface. The capsules in the\r
+                                ScatterGatherList must be in the same order as the\r
+                                CapsuleHeaderArray. This parameter is only referenced if\r
+                                the capsules are defined to persist across system reset.\r
+\r
+  @retval EFI_SUCCESS           Valid capsule was passed. I Valid capsule was passed. If\r
+                                CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the\r
+                                capsule has been successfully processed by the firmware.\r
+  @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.\r
+  @retval EFI_DEVICE_ERROR      The capsule update was started, but failed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiUpdateCapsule (\r
+  IN UEFI_CAPSULE_HEADER      **CapsuleHeaderArray,\r
+  IN UINTN                    CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS     ScatterGatherList\r
+  );\r
+\r
+\r
+/**\r
\r
+  The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or\r
+  capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and\r
+  size of the entire capsule is checked.\r
+  If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be\r
+  constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof\r
+  (EFI_CAPSULE_HEADER). To determine reset requirements,\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the\r
+  EFI_CAPSULE_HEADER.\r
+  The firmware must support any capsule that has the\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The\r
+  firmware sets the policy for what capsules are supported that do not have the\r
+  CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.\r
+  \r
+  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules\r
+                                being passed into update capsule. The capsules are assumed to\r
+                                stored in contiguous virtual memory.\r
+  @param  CapsuleCount          Number of pointers to EFI_CAPSULE_HEADER in\r
+                                CaspuleHeaderArray.\r
+  @param  MaxiumCapsuleSize     On output the maximum size that UpdateCapsule() can\r
+                                support as an argument to UpdateCapsule() via\r
+                                CapsuleHeaderArray and ScatterGatherList.\r
+                                Undefined on input.\r
+  @param  ResetType             Returns the type of reset required for the capsule update.\r
+\r
+  @retval EFI_SUCCESS           Valid answer returned..\r
+  @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.\r
+  @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform, and\r
+                                MaximumCapsuleSize and ResetType are undefined.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryCapsuleCapabilities (\r
+  IN UEFI_CAPSULE_HEADER       **CapsuleHeaderArray,\r
+  IN UINTN                     CapsuleCount,\r
+  OUT UINT64                   *MaximumCapsuleSize,\r
+  OUT EFI_RESET_TYPE           *ResetType\r
+  );\r
+\r
+\r
+/**\r
\r
+  The QueryVariableInfo() function allows a caller to obtain the information about the\r
+  maximum size of the storage space available for the EFI variables, the remaining size of the storage\r
+  space available for the EFI variables and the maximum size of each individual EFI variable,\r
+  associated with the attributes specified.\r
+  The returned MaximumVariableStorageSize, RemainingVariableStorageSize,\r
+  MaximumVariableSize information may change immediately after the call based on other\r
+  runtime activities including asynchronous error events. Also, these values associated with different\r
+  attributes are not additive in nature.\r
+  \r
+  @param  Attributes            Attributes bitmask to specify the type of variables on\r
+                                which to return information. Refer to the\r
+                                GetVariable() function description.\r
+  @param  MaximumVariableStorageSize  \r
+                                On output the maximum size of the storage space\r
+                                available for the EFI variables associated with the\r
+                                attributes specified.\r
+  @param  RemainingVariableStorageSize \r
+                                Returns the remaining size of the storage space\r
+                                available for the EFI variables associated with the\r
+                                attributes specified..\r
+  @param  MaximumVariableSize   Returns the maximum size of the individual EFI\r
+                                variables associated with the attributes specified.\r
+\r
+  @retval EFI_SUCCESS           Valid answer returned.\r
+  @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r
+  @retval EFI_UNSUPPORTED       EFI_UNSUPPORTED The attribute is not supported on this platform, and the\r
+                                MaximumVariableStorageSize,\r
+                                RemainingVariableStorageSize, MaximumVariableSize\r
+                                are undefined.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryVariableInfo (\r
+  IN UINT32   Attrubutes,\r
+  OUT UINT64  *MaximumVariableStorageSize,\r
+  OUT UINT64  *RemainingVariableStorageSize,\r
+  OUT UINT64  *MaximumVariableSize\r
+  );\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h
new file mode 100644 (file)
index 0000000..fd4412f
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+       \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxeServicesTableLib.h\r
+  \r
+Abstract: \r
+\r
+  Library that provides a global pointer to the DXE Services Table\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__\r
+#define __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__\r
+\r
+//\r
+// Cache copy of the DXE Services Table\r
+//\r
+extern EFI_DXE_SERVICES  *gDS;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h
new file mode 100644 (file)
index 0000000..fb72b97
--- /dev/null
@@ -0,0 +1,147 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxeSmmDriverEntryPoint.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for DXE SMM Driver Entry Point Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_MODULE_ENTRY_POINT_H__\r
+#define __EDKII_GLUE_MODULE_ENTRY_POINT_H__\r
+\r
+//\r
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented \r
+//\r
+extern const UINT32                   _gUefiDriverRevision;\r
+\r
+//\r
+// Declare the number of entry points in the image. \r
+//\r
+extern const UINT8                    _gDriverEntryPointCount;\r
+\r
+//\r
+// Declare the number of unload handler in the image. \r
+//\r
+extern const UINT8                    _gDriverUnloadImageCount;\r
+\r
+/**\r
+  Enrty point to DXE SMM Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+/**\r
+  Enrty point wrapper of DXE SMM Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+/**\r
+  Computes the cummulative return status for the driver entry point and perform\r
+  a long jump back into DriverEntryPoint().\r
+\r
+  @param  Status Status returned by the driver that is exiting.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ExitDriver (\r
+  IN EFI_STATUS  Status\r
+  );\r
+\r
+/**\r
+  Call constructs for all libraries. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryConstructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+/**\r
+  Call destructors for all libraries. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryDestructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Call the list of driver entry points. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @return Status returned by entry points of drivers.  \r
\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Call the unload handlers for all the modules. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
\r
+  @return Status returned by unload handlers of drivers.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleUnloadList (\r
+  IN EFI_HANDLE  ImageHandle\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h
new file mode 100644 (file)
index 0000000..b88c919
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueEdkDxeSalLib.h\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+\r
+#ifndef __EDKII_GLUE_ESAL_SERVICE_LIB_H__\r
+#define __EDKII_GLUE_ESAL_SERVICE_LIB_H__\r
+\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class Function and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  FunctionId    - ID of function to register\r
+  ClassGuid     - GUID of function class \r
+  Function      - Function to register under ClassGuid/FunctionId pair\r
+  ModuleGlobal  - Module global for Function.\r
+\r
+Returns: \r
+  EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterEsalClass (\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  VOID                                      *ModuleGlobal,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  ClassGuid     - GUID of function class \r
+  ModuleGlobal  - Module global for Function.\r
+  ..            - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r
+                  indicates the end of the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS - All members of ClassGuid registered\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EFIAPI\r
+EfiCallEsalService (\r
+  IN  EFI_GUID                                      *ClassGuid,\r
+  IN  UINT64                                        FunctionId,\r
+  IN  UINT64                                        Arg2,\r
+  IN  UINT64                                        Arg3,\r
+  IN  UINT64                                        Arg4,\r
+  IN  UINT64                                        Arg5,\r
+  IN  UINT64                                        Arg6,\r
+  IN  UINT64                                        Arg7,\r
+  IN  UINT64                                        Arg8\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call module that is not linked direclty to this module. This code is IP \r
+  relative and hides the binding issues of virtual or physical calling. The\r
+  function that gets dispatched has extra arguments that include the registered\r
+  module global and a boolean flag to indicate if the system is in virutal mode.\r
+\r
+Arguments:\r
+  ClassGuid   - GUID of function\r
+  FunctionId  - Function in ClassGuid to call\r
+  Arg2        - Argument 2 ClassGuid/FunctionId defined\r
+  Arg3        - Argument 3 ClassGuid/FunctionId defined\r
+  Arg4        - Argument 4 ClassGuid/FunctionId defined\r
+  Arg5        - Argument 5 ClassGuid/FunctionId defined\r
+  Arg6        - Argument 6 ClassGuid/FunctionId defined\r
+  Arg7        - Argument 7 ClassGuid/FunctionId defined\r
+  Arg8        - Argument 8 ClassGuid/FunctionId defined\r
+\r
+Returns: \r
+  Status of ClassGuid/FuncitonId\r
+\r
+--*/\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EFIAPI\r
+SetEsalVirtualEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  )\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EFIAPI\r
+SetEsalPhysicalEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  )\r
+;\r
+\r
+SAL_RETURN_REGS\r
+EFIAPI\r
+GetEsalEntryPoint (\r
+  VOID\r
+  )\r
+;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h
new file mode 100644 (file)
index 0000000..6016569
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+  \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueHiiLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Hii Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_HII_LIB_H__\r
+#define __EDKII_GLUE_HII_LIB_H__\r
+\r
+\r
+#define PreparePackages GluePreparePackages\r
+\r
+\r
+/**\r
+  This function allocates pool for an EFI_HII_PACKAGES structure\r
+  with enough space for the variable argument list of package pointers.\r
+  The allocated structure is initialized using NumberOfPackages, Guid, \r
+  and the variable length argument list of package pointers.\r
+\r
+  @param  NumberOfPackages The number of HII packages to prepare.\r
+  @param  Guid Package GUID.\r
+\r
+  @return\r
+  The allocated and initialized packages.\r
+\r
+**/\r
+EFI_HII_PACKAGES *\r
+EFIAPI\r
+GluePreparePackages (\r
+  IN UINTN           NumberOfPackages,\r
+  IN CONST EFI_GUID  *Guid OPTIONAL,\r
+  ...\r
+  )\r
+;\r
+\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h
new file mode 100644 (file)
index 0000000..694eb5f
--- /dev/null
@@ -0,0 +1,384 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+  \r
+\r
+Module Name:\r
+\r
+  EdkIIGlueHobLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Hob Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_HOB_LIB_H__\r
+#define __EDKII_GLUE_HOB_LIB_H__\r
+\r
+\r
+#define GetFirstGuidHob(_GUID)                                                                                                                                                         GlueGetFirstGuidHob(_GUID)\r
+#define GetNextGuidHob(_GUID, _HobStart)                                                                                                       GlueGetNextGuidHob(_GUID, _HobStart)\r
+#define BuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT)               GlueBuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT)\r
+#define BuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE)   GlueBuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE)\r
+\r
+\r
+/**\r
+  Returns the pointer to the HOB list.\r
+\r
+  This function returns the pointer to first HOB in the list.\r
+\r
+  @return The pointer to the HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetHobList (\r
+  VOID\r
+  )\r
+;\r
+\r
+/**\r
+  Returns the next instance of a HOB type from the starting HOB.\r
+\r
+  This function searches the first instance of a HOB type from the starting HOB pointer. \r
+  If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Type          The HOB type to return.\r
+  @param  HobStart      The starting HOB pointer to search from.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetNextHob (\r
+  IN UINT16                 Type,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+;\r
+\r
+/**\r
+  Returns the first instance of a HOB type among the whole HOB list.\r
+\r
+  This function searches the first instance of a HOB type among the whole HOB list. \r
+  If there does not exist such HOB type in the HOB list, it will return NULL. \r
+\r
+  @param  Type          The HOB type to return.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFirstHob (\r
+  IN UINT16                 Type\r
+  )\r
+;\r
+\r
+/**\r
+  This function searches the first instance of a HOB from the starting HOB pointer. \r
+  Such HOB should satisfy two conditions: \r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If Guid is NULL, then ASSERT().\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+  @param  HobStart      A pointer to a Guid.\r
+\r
+  @return The next instance of the matched GUID HOB from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetNextGuidHob (\r
+  IN CONST EFI_GUID         *Guid,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+;\r
+\r
+/**\r
+  This function searches the first instance of a HOB among the whole HOB list. \r
+  Such HOB should satisfy two conditions:\r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+\r
+  @return The first instance of the matched GUID HOB among the whole HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetFirstGuidHob (\r
+  IN CONST EFI_GUID         *Guid\r
+  )\r
+;\r
+\r
+/**\r
+  Get the Boot Mode from the HOB list.\r
+\r
+  This function returns the system boot mode information from the \r
+  PHIT HOB in HOB list.\r
+\r
+  @param  VOID\r
+\r
+  @return The Boot Mode.\r
+\r
+**/\r
+EFI_BOOT_MODE\r
+EFIAPI\r
+GetBootModeHob (\r
+  VOID\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB for a loaded PE32 module.\r
+\r
+  This function builds a HOB for a loaded PE32 module.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If ModuleName is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ModuleName              The GUID File Name of the module.\r
+  @param  MemoryAllocationModule  The 64 bit physical address of the module.\r
+  @param  ModuleLength            The length of the module in bytes.\r
+  @param  EntryPoint              The 64 bit physical address of the module entry point.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildModuleHob (\r
+  IN CONST EFI_GUID         *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB that describes a chunk of system memory.\r
+\r
+  This function builds a HOB that describes a chunk of system memory.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ResourceType        The type of resource described by this HOB.\r
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.\r
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.\r
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildResourceDescriptorHob (\r
+  IN EFI_RESOURCE_TYPE            ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
+  IN UINT64                       NumberOfBytes\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a GUID HOB with a certain data length.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification \r
+  and returns the start address of GUID HOB data so that caller can fill the customized data. \r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN UINTN                       DataLength\r
+  )\r
+;\r
+\r
+/**\r
+  Copies a data buffer to a newly-built HOB.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification,\r
+  copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If Data is NULL and DataLength > 0, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  Data          The data to be copied into the data field of the GUID HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidDataHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a Firmware Volume HOB.\r
+\r
+  This function builds a Firmware Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Firmware Volume.\r
+  @param  Length        The size of the Firmware Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildFvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a Capsule Volume HOB.\r
+\r
+  This function builds a Capsule Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Capsule Volume.\r
+  @param  Length        The size of the Capsule Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB for the CPU.\r
+\r
+  This function builds a HOB for the CPU.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.\r
+  @param  SizeOfIoSpace       The maximum physical I/O addressability of the processor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCpuHob (\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB for the Stack.\r
+\r
+  This function builds a HOB for the stack.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the Stack.\r
+  @param  Length        The length of the stack in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildStackHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB for the BSP store.\r
+\r
+  This function builds a HOB for BSP store.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the BSP.\r
+  @param  Length        The length of the BSP store in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildBspStoreHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+;\r
+\r
+/**\r
+  Builds a HOB for the memory allocation.\r
+\r
+  This function builds a HOB for the memory allocation.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the memory.\r
+  @param  Length        The length of the memory allocation in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildMemoryAllocationHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h
new file mode 100644 (file)
index 0000000..354efef
--- /dev/null
@@ -0,0 +1,2563 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueIoLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for IO Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_IO_LIB_H__\r
+#define __EDKII_GLUE_IO_LIB_H__\r
+\r
+\r
+#define IoRead8(_PORT)            GlueIoRead8(_PORT)\r
+#define IoWrite8(_PORT,_VALUE)    GlueIoWrite8(_PORT,_VALUE)\r
+#define IoRead16(_PORT)           GlueIoRead16(_PORT)\r
+#define IoWrite16(_PORT,_VALUE)   GlueIoWrite16(_PORT,_VALUE)\r
+#define IoRead32(_PORT)           GlueIoRead32(_PORT)\r
+#define IoWrite32(_PORT,_VALUE)   GlueIoWrite32(_PORT,_VALUE)\r
+\r
+\r
+#define IO_LIB_ADDRESS(Segment,Port) \\r
+  ( ((Port) & 0xffff) | (((Segment) & 0xffff) << 16) )\r
+\r
+/**\r
+  Reads an 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+GlueIoRead8 (\r
+  IN      UINTN                     Port\r
+  );\r
+\r
+/**\r
+  Writes an 8-bit I/O port.\r
+\r
+  Writes the 8-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+GlueIoWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 8-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in an 8-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldRead8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 8-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+GlueIoRead16 (\r
+  IN      UINTN                     Port\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit I/O port.\r
+\r
+  Writes the 16-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+GlueIoWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 16-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 16-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldRead16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 16-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GlueIoRead32 (\r
+  IN      UINTN                     Port\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit I/O port.\r
+\r
+  Writes the 32-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GlueIoWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 32-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 32-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldRead32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 32-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoRead64 (\r
+  IN      UINTN                     Port\r
+  );\r
+\r
+/**\r
+  Writes a 64-bit I/O port.\r
+\r
+  Writes the 64-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 64-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 64-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldRead64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioRead8 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes an 8-bit MMIO register.\r
+\r
+  Writes the 8-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 8-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in an 8-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 8-bit register is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 8-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioRead16 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit MMIO register.\r
+\r
+  Writes the 16-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 16-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 16-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 16-bit register is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 16-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioRead32 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit MMIO register.\r
+\r
+  Writes the 32-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 32-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 32-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 32-bit register is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 32-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioRead64 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 64-bit MMIO register.\r
+\r
+  Writes the 64-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 64-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 64-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldRead64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 64-bit register is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 64-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  );\r
+\r
+/**\r
+  Copy data from MMIO region to system memory by using 8-bit access.\r
+\r
+  Copy data from MMIO region specified by starting address StartAddress \r
+  to system memory specified by Buffer by using 8-bit access. The total \r
+  number of byte to be copied is specified by Length. Buffer is returned.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied from.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer receiving the data read.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+MmioReadBuffer8 (\r
+  IN  UINTN       StartAddress,\r
+  IN  UINTN       Length,\r
+  OUT UINT8       *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from MMIO region to system memory by using 16-bit access.\r
+\r
+  Copy data from MMIO region specified by starting address StartAddress \r
+  to system memory specified by Buffer by using 16-bit access. The total \r
+  number of byte to be copied is specified by Length. Buffer is returned.\r
+  \r
+  If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied from.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer receiving the data read.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+UINT16 *\r
+EFIAPI\r
+MmioReadBuffer16 (\r
+  IN  UINTN       StartAddress,\r
+  IN  UINTN       Length,\r
+  OUT UINT16      *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from MMIO region to system memory by using 32-bit access.\r
+\r
+  Copy data from MMIO region specified by starting address StartAddress \r
+  to system memory specified by Buffer by using 32-bit access. The total \r
+  number of byte to be copied is specified by Length. Buffer is returned.\r
+  \r
+  If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied from.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer receiving the data read.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+UINT32 *\r
+EFIAPI\r
+MmioReadBuffer32 (\r
+  IN  UINTN       StartAddress,\r
+  IN  UINTN       Length,\r
+  OUT UINT32      *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from MMIO region to system memory by using 64-bit access.\r
+\r
+  Copy data from MMIO region specified by starting address StartAddress \r
+  to system memory specified by Buffer by using 64-bit access. The total \r
+  number of byte to be copied is specified by Length. Buffer is returned.\r
+  \r
+  If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied from.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer receiving the data read.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+UINT64 *\r
+EFIAPI\r
+MmioReadBuffer64 (\r
+  IN  UINTN       StartAddress,\r
+  IN  UINTN       Length,\r
+  OUT UINT64      *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from system memory to MMIO region by using 8-bit access.\r
+\r
+  Copy data from system memory specified by Buffer to MMIO region specified \r
+  by starting address StartAddress by using 8-bit access. The total number \r
+  of byte to be copied is specified by Length. Buffer is returned.\r
+  \r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
+\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied to.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer containing the data to write.\r
+\r
+  @return Size in bytes of the copy.\r
+\r
+**/\r
+UINT8 *\r
+EFIAPI\r
+MmioWriteBuffer8 (\r
+  IN  UINTN         StartAddress,\r
+  IN  UINTN         Length,\r
+  IN  CONST UINT8   *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from system memory to MMIO region by using 16-bit access.\r
+\r
+  Copy data from system memory specified by Buffer to MMIO region specified \r
+  by starting address StartAddress by using 16-bit access. The total number \r
+  of byte to be copied is specified by Length. Length is returned.\r
+  \r
+  If StartAddress is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied to.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer containing the data to write.\r
+\r
+  @return Size in bytes of the copy.\r
+\r
+**/\r
+UINT16 *\r
+EFIAPI\r
+MmioWriteBuffer16 (\r
+  IN  UINTN        StartAddress,\r
+  IN  UINTN        Length,\r
+  IN  CONST UINT16 *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from system memory to MMIO region by using 32-bit access.\r
+\r
+  Copy data from system memory specified by Buffer to MMIO region specified \r
+  by starting address StartAddress by using 32-bit access. The total number \r
+  of byte to be copied is specified by Length. Length is returned.\r
+  \r
+  If StartAddress is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied to.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer containing the data to write.\r
+\r
+  @return Size in bytes of the copy.\r
+\r
+**/\r
+UINT32 *\r
+EFIAPI\r
+MmioWriteBuffer32 (\r
+  IN  UINTN        StartAddress,\r
+  IN  UINTN        Length,\r
+  IN  CONST UINT32 *Buffer\r
+  );\r
+\r
+/**\r
+  Copy data from system memory to MMIO region by using 64-bit access.\r
+\r
+  Copy data from system memory specified by Buffer to MMIO region specified \r
+  by starting address StartAddress by using 64-bit access. The total number \r
+  of byte to be copied is specified by Length. Length is returned.\r
+  \r
+  If StartAddress is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().\r
+\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  StartAddress    Starting address for the MMIO region to be copied to.\r
+  @param  Length          Size in bytes of the copy.\r
+  @param  Buffer          Pointer to a system memory buffer containing the data to write.\r
+\r
+  @return Size in bytes of the copy.\r
+\r
+**/\r
+UINT64 *\r
+EFIAPI\r
+MmioWriteBuffer64 (\r
+  IN  UINTN        StartAddress,\r
+  IN  UINTN        Length,\r
+  IN  CONST UINT64 *Buffer\r
+  );\r
+\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h
new file mode 100644 (file)
index 0000000..51607be
--- /dev/null
@@ -0,0 +1,637 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueMemoryAllocationLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Memory Allocation Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__\r
+#define __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__\r
+\r
+\r
+#define AllocatePages(_PAGES)                       GlueAllocatePages(_PAGES)\r
+#define FreePages(_BUFFER, _PAGES)                  GlueFreePages(_BUFFER, _PAGES)\r
+#define AllocatePool(_SIZE)                         GlueAllocatePool(_SIZE)\r
+#define AllocateZeroPool(_ALLOCATIONSIZE)           GlueAllocateZeroPool(_ALLOCATIONSIZE)\r
+#define AllocateCopyPool(_ALLOCATIONSIZE, _BUFFER)  GlueAllocateCopyPool(_ALLOCATIONSIZE, _BUFFER)\r
+#define FreePool(_BUFFER)                           GlueFreePool(_BUFFER)\r
+\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePages (\r
+  IN UINTN  Pages\r
+  );\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+  IN UINTN  Pages\r
+  );\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+  IN UINTN  Pages\r
+  );\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+  functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
\r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  );\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+  allocation functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
+  \r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateZeroPool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  );\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+  Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePool (\r
+  IN VOID   *Buffer\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  );\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  );\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
+  in the Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  aligned pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPool (\r
+  IN VOID   *Buffer\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h
new file mode 100644 (file)
index 0000000..8916a0f
--- /dev/null
@@ -0,0 +1,1055 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePciCf8Lib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Pci Cf8 Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCI_CF8_LIB_H__\r
+#define __EDKII_GLUE_PCI_CF8_LIB_H__\r
+\r
+\r
+/**\r
+  Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an\r
+  address that can be passed to the PCI Library functions.\r
+\r
+  Computes an address that is compatible with the PCI Library functions. The\r
+  unused upper bits of Bus, Device, Function and Register are stripped prior to\r
+  the generation of the address.\r
+\r
+  @param  Bus       PCI Bus number. Range 0..255.\r
+  @param  Device    PCI Device number. Range 0..31.\r
+  @param  Function  PCI Function number. Range 0..7.\r
+  @param  Register  PCI Register number. Range 0..255.\r
+\r
+  @return The encode PCI address.\r
+\r
+**/\r
+#define PCI_CF8_LIB_ADDRESS(Bus,Device,Function,Offset) \\r
+  (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Read8 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Write8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Or8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8And8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8AndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Read16 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Write16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Or16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8And16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8AndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Read32 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Write32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Or32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8And32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8AndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by StartAddress >= 0x100, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciCf8ReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by StartAddress >= 0x100, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciCf8WriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h
new file mode 100644 (file)
index 0000000..8396576
--- /dev/null
@@ -0,0 +1,1023 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePciExpressLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Pci Express Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCI_EXPRESS_LIB_H__\r
+#define __EDKII_GLUE_PCI_EXPRESS_LIB_H__\r
+\r
+\r
+/**\r
+  Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an\r
+  address that can be passed to the PCI Library functions.\r
+\r
+  Computes an address that is compatible with the PCI Library functions. The\r
+  unused upper bits of Bus, Device, Function and Register are stripped prior to\r
+  the generation of the address.\r
+\r
+  @param  Bus       PCI Bus number. Range 0..255.\r
+  @param  Device    PCI Device number. Range 0..31.\r
+  @param  Function  PCI Function number. Range 0..7.\r
+  @param  Register  PCI Register number. Range 0..4095.\r
+\r
+  @return The encode PCI address.\r
+\r
+**/\r
+#define PCI_EXPRESS_LIB_ADDRESS(Bus,Device,Function,Offset) \\r
+  (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressRead8 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressRead16 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressRead32 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciExpressReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciExpressWriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h
new file mode 100644 (file)
index 0000000..d51ceb7
--- /dev/null
@@ -0,0 +1,1019 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePciLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Pci Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCI_LIB_H__\r
+#define __EDKII_GLUE_PCI_LIB_H__\r
+\r
+/**\r
+  Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an\r
+  address that can be passed to the PCI Library functions.\r
+\r
+  @param  Bus       PCI Bus number. Range 0..255.\r
+  @param  Device    PCI Device number. Range 0..31.\r
+  @param  Function  PCI Function number. Range 0..7.\r
+  @param  Register  PCI Register number. Range 0..255 for PCI. Range 0..4095\r
+                    for PCI Express.\r
+\r
+  @return The encoded PCI address.\r
+\r
+**/\r
+#define PCI_LIB_ADDRESS(Bus,Device,Function,Offset)   \\r
+  (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciRead8 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  );\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciRead16 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciRead32 (\r
+  IN      UINTN                     Address\r
+  );\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Data\r
+  );\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  );\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  );\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciWriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h
new file mode 100644 (file)
index 0000000..d7861f3
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeCoffGetEntryPointLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for PeCoff Get Entry Point Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__\r
+#define __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__\r
+\r
+/**\r
+  Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded\r
+  into system memory with the PE/COFF Loader Library functions.\r
+\r
+  Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry\r
+  point in EntryPoint.  If the entry point could not be retrieved from the PE/COFF image, then\r
+  return RETURN_INVALID_PARAMETER.  Otherwise return RETURN_SUCCESS.\r
+  If Pe32Data is NULL, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data                  Pointer to the PE/COFF image that is loaded in system memory.\r
+  @param  EntryPoint                Pointer to entry point to the PE/COFF image to return.\r
+\r
+  @retval RETURN_SUCCESS            EntryPoint was returned.\r
+  @retval RETURN_INVALID_PARAMETER  The entry point could not be found in the PE/COFF image.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetEntryPoint (\r
+  IN  VOID  *Pe32Data,\r
+  OUT VOID  **EntryPoint\r
+  );\r
+\r
+/**\r
+  Returns the machine type of a PE/COFF image.\r
+\r
+  Returns the machine type from the PE/COFF image specified by Pe32Data.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return Machine type or zero if not a valid iamge.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PeCoffLoaderGetMachineType (\r
+  IN VOID  *Pe32Data\r
+  );\r
+\r
+/**\r
+  Returns a pointer to the PDB file name for a PE/COFF image that has been\r
+  loaded into system memory with the PE/COFF Loader Library functions. \r
+\r
+  Returns the PDB file name for the PE/COFF image specified by Pe32Data.  If\r
+  the PE/COFF image specified by Pe32Data is not a valid, then NULL is\r
+  returned.  If the PE/COFF image specified by Pe32Data does not contain a\r
+  debug directory entry, then NULL is returned.  If the debug directory entry\r
+  in the PE/COFF image specified by Pe32Data does not contain a PDB file name,\r
+  then NULL is returned.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL\r
+          if it cannot be retrieved.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+PeCoffLoaderGetPdbPointer (\r
+  IN VOID  *Pe32Data\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h
new file mode 100644 (file)
index 0000000..4ac6659
--- /dev/null
@@ -0,0 +1,226 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeCoffLib.h\r
+\r
+Abstract: \r
+\r
+  Public header file for PeCoff Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_BASE_PE_COFF_LIB_H__\r
+#define __EDKII_GLUE_BASE_PE_COFF_LIB_H__\r
+\r
+\r
+#define PeCoffLoaderGetImageInfo(_IMAGECONTEXT)       GluePeCoffLoaderGetImageInfo(_IMAGECONTEXT)\r
+#define PeCoffLoaderRelocateImage(_IMAGECONTEXT)      GluePeCoffLoaderRelocateImage(_IMAGECONTEXT)\r
+#define PeCoffLoaderLoadImage(_IMAGECONTEXT)          GluePeCoffLoaderLoadImage(_IMAGECONTEXT)\r
+#define PeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR)  GluePeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR)\r
+#define PeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) GluePeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR)\r
+#define PeCoffLoaderRelocateImage(_IMAGECONTEXT)      GluePeCoffLoaderRelocateImage(_IMAGECONTEXT)\r
+#define PeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \\r
+                                                      GluePeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST)\r
+#define PeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \\r
+                                                      GluePeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST)\r
+\r
+\r
+//\r
+// Return status codes from the PE/COFF Loader services\r
+// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes\r
+//\r
+#define IMAGE_ERROR_SUCCESS                      0\r
+#define IMAGE_ERROR_IMAGE_READ                   1  \r
+#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE  2\r
+#define IMAGE_ERROR_INVALID_MACHINE_TYPE         3\r
+#define IMAGE_ERROR_INVALID_SUBSYSTEM            4\r
+#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS        5\r
+#define IMAGE_ERROR_INVALID_IMAGE_SIZE           6\r
+#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT    7\r
+#define IMAGE_ERROR_SECTION_NOT_LOADED           8\r
+#define IMAGE_ERROR_FAILED_RELOCATION            9\r
+#define IMAGE_ERROR_FAILED_ICACHE_FLUSH          10\r
+\r
+//\r
+// PE/COFF Loader Read Function passed in by caller\r
+//\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *PE_COFF_LOADER_READ_FILE) (\r
+  IN     VOID   *FileHandle,\r
+  IN     UINTN  FileOffset,\r
+  IN OUT UINTN  *ReadSize,\r
+  OUT    VOID   *Buffer\r
+  );\r
+\r
+//\r
+// Context structure used while PE/COFF image is being loaded and relocated\r
+//\r
+typedef struct {\r
+  PHYSICAL_ADDRESS                  ImageAddress;\r
+  UINT64                            ImageSize;\r
+  PHYSICAL_ADDRESS                  DestinationAddress;\r
+  PHYSICAL_ADDRESS                  EntryPoint;\r
+  PE_COFF_LOADER_READ_FILE          ImageRead;\r
+  VOID                              *Handle;\r
+  VOID                              *FixupData;\r
+  UINT32                            SectionAlignment;\r
+  UINT32                            PeCoffHeaderOffset;\r
+  UINT32                            DebugDirectoryEntryRva;\r
+  VOID                              *CodeView;\r
+  CHAR8                             *PdbPointer;\r
+  UINTN                             SizeOfHeaders;\r
+  UINT32                            ImageCodeMemoryType;\r
+  UINT32                            ImageDataMemoryType;\r
+  UINT32                            ImageError;\r
+  UINTN                             FixupDataSize;\r
+  UINT16                            Machine;\r
+  UINT16                            ImageType;\r
+  BOOLEAN                           RelocationsStripped;\r
+  BOOLEAN                           IsTeImage;\r
+} PE_COFF_LOADER_IMAGE_CONTEXT;\r
+\r
+/**\r
+  Retrieves information about a PE/COFF image.\r
+\r
+  Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,\r
+  PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva\r
+  fields of the ImageContext structure.  If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.\r
+  If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not\r
+  a supported PE/COFF image type, then return RETURN_UNSUPPORTED.  If any errors occur while\r
+  computing the fields of ImageContext, then the error status is returned in the ImageError field of\r
+  ImageContext. \r
+\r
+  @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
+                                    image that needs to be examined by this function.\r
+\r
+  @retval RETURN_SUCCESS            The information on the PE/COFF image was collected.\r
+  @retval RETURN_INVALID_PARAMETER  ImageContext is NULL.\r
+  @retval RETURN_UNSUPPORTED        The PE/COFF image is not supported.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderGetImageInfo (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+/**\r
+  Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().\r
+\r
+  If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of\r
+  ImageContext as the relocation base address.  Otherwise, use the DestinationAddress field\r
+  of ImageContext as the relocation base address.  The caller must allocate the relocation\r
+  fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.  \r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext        Pointer to the image context structure that describes the PE/COFF\r
+                              image that is being relocated.\r
+\r
+  @retval RETURN_SUCCESS      The PE/COFF image was relocated.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_LOAD_ERROR   The image in not a valid PE/COFF image.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_UNSUPPORTED  A relocation record type is not supported.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderRelocateImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+/**\r
+  Loads a PE/COFF image into memory.\r
+\r
+  Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer\r
+  specified by the ImageAddress and ImageSize fields of ImageContext.  The caller must allocate\r
+  the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.\r
+  The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
+                                    image that is being loaded.\r
+\r
+  @retval RETURN_SUCCESS            The PE/COFF image was loaded into the buffer specified by\r
+                                    the ImageAddress and ImageSize fields of ImageContext.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The caller did not provide a large enough buffer.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_LOAD_ERROR         The PE/COFF image is an EFI Runtime image with no relocations.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_INVALID_PARAMETER  The image address is invalid.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderLoadImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  ImageRead function that operates on a memory buffer whos base is passed into\r
+  FileHandle. \r
+\r
+  @param  FileHandle        Ponter to baes of the input stream\r
+  @param  FileOffset        Offset to the start of the buffer\r
+  @param  ReadSize          Number of bytes to copy into the buffer\r
+  @param  Buffer            Location to place results of read\r
+\r
+  @retval RETURN_SUCCESS    Data is read from FileOffset from the Handle into \r
+                            the buffer.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderImageReadFromMemory (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+;\r
+\r
+\r
+/**\r
+  Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI\r
+  runtime. \r
+  \r
+  PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply\r
+  the fixups with a virtual mapping.\r
+\r
+\r
+  @param  ImageBase          Base address of relocated image\r
+  @param  VirtImageBase      Virtual mapping for ImageBase\r
+  @param  ImageSize          Size of the image to relocate\r
+  @param  RelocationData     Location to place results of read\r
+  \r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderRelocateImageForRuntime (\r
+  IN  PHYSICAL_ADDRESS        ImageBase,\r
+  IN  PHYSICAL_ADDRESS        VirtImageBase,\r
+  IN  UINTN                   ImageSize,\r
+  IN  VOID                    *RelocationData\r
+  )\r
+;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h
new file mode 100644 (file)
index 0000000..3737233
--- /dev/null
@@ -0,0 +1,306 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeiServicesLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for PEI Services Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PEI_SERVICES_LIB_H__\r
+#define __EDKII_GLUE_PEI_SERVICES_LIB_H__\r
+\r
+/**\r
+  This service enables a given PEIM to register an interface into the PEI Foundation. \r
+\r
+  @param  PpiList               A pointer to the list of interfaces that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPpi (\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *PpiList\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
+\r
+  @param  OldPpi                Pointer to the old PEI PPI Descriptors.\r
+  @param  NewPpi                Pointer to the new PEI PPI Descriptors.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+  @retval EFI_NOT_FOUND         The PPI for which the reinstallation was requested has not been\r
+                                installed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesReInstallPpi (\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *OldPpi,\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *NewPpi\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to discover a given instance of an interface.\r
+\r
+  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be\r
+                                found.\r
+  @param  Instance              The N-th instance of the interface that is required.\r
+  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
+  @param  Ppi                   A pointer to the instance of the interface.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully returned.\r
+  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN EFI_GUID                   *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to register a given service to be invoked when another service is\r
+  installed or reinstalled.\r
+\r
+  @param  NotifyList            A pointer to the list of notification interfaces that the caller\r
+                                shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesNotifyPpi (\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to ascertain the present value of the boot mode.  \r
+\r
+  @param  BootMode              A pointer to contain the value of the boot mode.\r
+\r
+  @retval EFI_SUCCESS           The boot mode was returned successfully.\r
+  @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetBootMode (\r
+  IN OUT EFI_BOOT_MODE          *BootMode\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to update the boot mode variable.    \r
+\r
+  @param  BootMode              The value of the boot mode to set.\r
+\r
+  @retval EFI_SUCCESS           The value was successfully updated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesSetBootMode (\r
+  IN EFI_BOOT_MODE              BootMode\r
+  );\r
+\r
+/**\r
+  This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
+\r
+  @param  HobList               A pointer to the list of HOBs that the PEI Foundation will initialize.\r
+\r
+  @retval EFI_SUCCESS           The list was successfully returned.\r
+  @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetHobList (\r
+  IN OUT VOID                   **HobList\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to create various types of HOBs.\r
+\r
+  @param  Type                  The type of HOB to be installed.\r
+  @param  Length                The length of the HOB to be added.\r
+  @param  Hob                   The address of a pointer that will contain the HOB header.\r
+\r
+  @retval EFI_SUCCESS           The HOB was successfully created.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesCreateHob (\r
+  IN UINT16                     Type,\r
+  IN UINT16                     Length,\r
+  IN OUT VOID                   **Hob\r
+  );\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+/**\r
+  This service enables PEIMs to discover additional firmware volumes.\r
+\r
+  @param  Instance              This instance of the firmware volume to find.  The value 0 is the\r
+                                Boot Firmware Volume (BFV).\r
+  @param  FwVolHeader           Pointer to the firmware volume header of the volume to return.\r
+\r
+  @retval EFI_SUCCESS           The volume was found.\r
+  @retval EFI_NOT_FOUND         The volume was not found.\r
+  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware files.\r
+\r
+  @param  SearchType            A filter to find files only of this type.\r
+  @param  FwVolHeader           Pointer to the firmware volume header of the volume to search.\r
+                                This parameter must point to a valid FFS volume.\r
+  @param  FileHeader            Pointer to the current file from which to begin searching.\r
+\r
+  @retval EFI_SUCCESS           The file was found.\r
+  @retval EFI_NOT_FOUND         The file was not found.\r
+  @retval EFI_NOT_FOUND         The header checksum was not zero.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER    **FileHeader\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
+\r
+  @param  SearchType            The value of the section type to find.\r
+  @param  FfsFileHeader         A pointer to the file header that contains the set of sections to\r
+                                be searched.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+\r
+  @retval EFI_SUCCESS           The section was found.\r
+  @retval EFI_NOT_FOUND         The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_FFS_FILE_HEADER        *FfsFileHeader,\r
+  IN OUT VOID                   **SectionData\r
+  );\r
+#endif\r
+\r
+/**\r
+  This service enables PEIMs to register the permanent memory configuration\r
+  that has been initialized with the PEI Foundation.\r
+\r
+  @param  MemoryBegin           The value of a region of installed memory.\r
+  @param  MemoryLength          The corresponding length of a region of installed memory.\r
+\r
+  @retval EFI_SUCCESS           The region was successfully installed in a HOB.\r
+  @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPeiMemory (\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  );\r
+\r
+/**\r
+  This service enables PEIMs to allocate memory after the permanent memory has been installed by a\r
+  PEIM.\r
+\r
+  @param  MemoryType            Type of memory to allocate.\r
+  @param  Pages                 Number of pages to allocate.\r
+  @param  Memory                Pointer of memory allocated.\r
+\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
+  @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePages (\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *Memory\r
+  );\r
+\r
+/**\r
+  This service allocates memory from the Hand-Off Block (HOB) heap.\r
+\r
+  @param  Size                  The number of bytes to allocate from the pool.\r
+  @param  Buffer                If the call succeeds, a pointer to a pointer to the allocate\r
+                                buffer; undefined otherwise.\r
+\r
+  @retval EFI_SUCCESS           The allocation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough heap to allocate the requested size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePool (\r
+  IN UINTN                      Size,\r
+  OUT VOID                      **Buffer\r
+  );\r
+\r
+/**\r
+  This service resets the entire platform, including all processors and devices, and reboots the\r
+  system. \r
+\r
+  @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesResetSystem (\r
+  VOID\r
+  );\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h
new file mode 100644 (file)
index 0000000..a839dad
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeiServicesTablePointerLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for PEI Services Table Pointer Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__\r
+#define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__\r
+\r
+/**\r
+  The function returns the pointer to PEI services.\r
+\r
+  The function returns the pointer to PEI services.\r
+  It will ASSERT() if the pointer to PEI services is NULL.\r
+\r
+  @retval  The pointer to PeiServices.\r
+\r
+**/\r
+EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  );\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h
new file mode 100644 (file)
index 0000000..2ed64c5
--- /dev/null
@@ -0,0 +1,111 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePeimEntryPoint.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for PEIM Entry Point Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PEIM_ENTRY_POINT_H__\r
+#define __EDKII_GLUE_PEIM_ENTRY_POINT_H__\r
+\r
+//\r
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented \r
+//\r
+extern const UINT32                   _gPeimRevision;\r
+\r
+/**\r
+  Image entry point of Peim.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @return  Status returned by entry points of Peims.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+\r
+/**\r
+  Wrapper of Peim image entry point.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @return  Status returned by entry points of Peims.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+\r
+/**\r
+  Call constructs for all libraries. Automatics Generated by tool.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryConstructorList (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+\r
+/**\r
+  Call destructors for all libraries. Automatics Generated by tool.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryDestructorList (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+\r
+/**\r
+  Call the list of driver entry points. Automatics Generated by tool.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @return Status returned by entry points of drivers.  \r
\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h
new file mode 100644 (file)
index 0000000..34da75a
--- /dev/null
@@ -0,0 +1,165 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePostCodeLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Post Code Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_POST_CODE_LIB_H__\r
+#define __EDKII_GLUE_POST_CODE_LIB_H__\r
+\r
+\r
+#define PostCode(_VALUE)                          GluePostCode(_VALUE)\r
+#define PostCodeWithDescription(_VALUE, _DESC)    GluePostCodeWithDescription(_VALUE, _DESC)\r
+#define PostCodeEnabled()                         GluePostCodeEnabled()\r
+#define PostCodeDescriptionEnabled()              GluePostCodeDescriptionEnabled()\r
+\r
+\r
+#define POST_CODE_PROPERTY_POST_CODE_ENABLED              0x00000008\r
+#define POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED  0x00000010\r
+\r
+/**\r
+  Sends an 32-bit value to a POST card.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.  \r
+  Some implementations of this library function may perform I/O operations \r
+  directly to a POST card device.  Other implementations may send Value to \r
+  ReportStatusCode(), and the status code reporting mechanism will eventually \r
+  display the 32-bit value on the status reporting device.\r
+  \r
+  PostCode() must actively prevent recursion.  If PostCode() is called while \r
+  processing another any other Report Status Code Library function, then \r
+  PostCode() must return Value immediately.\r
+\r
+  @param  Value  The 32-bit value to write to the POST card.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCode (\r
+  IN UINT32  Value\r
+  );\r
+\r
+\r
+/**\r
+  Sends an 32-bit value to a POST and associated ASCII string.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.\r
+  If Description is not NULL, then the ASCII string specified by Description is \r
+  also passed to the handler that displays the POST card value.  Some \r
+  implementations of this library function may perform I/O operations directly \r
+  to a POST card device.  Other implementations may send Value to ReportStatusCode(), \r
+  and the status code reporting mechanism will eventually display the 32-bit \r
+  value on the status reporting device.  \r
+\r
+  PostCodeWithDescription()must actively prevent recursion.  If \r
+  PostCodeWithDescription() is called while processing another any other Report \r
+  Status Code Library function, then PostCodeWithDescription() must return Value \r
+  immediately.\r
+\r
+  @param  Value        The 32-bit value to write to the POST card.\r
+  @param  Description  Pointer to an ASCII string that is a description of the \r
+                       POST code value.  This is an optional parameter that may \r
+                       be NULL.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCodeWithDescription (\r
+  IN UINT32       Value,\r
+  IN CONST CHAR8  *Description  OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if POST Codes are enabled.\r
+\r
+  This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+  bit of PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if POST code descriptions are enabled.\r
+\r
+  This function returns TRUE if the \r
+  POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+  PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeDescriptionEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Sends an 32-bit value to a POST card.\r
+\r
+  If POST codes are enabled in PcdPostCodeProperyMask, then call PostCode() \r
+  passing in Value.  Value is returned.\r
+\r
+  @param  Value  The 32-bit value to write to the POST card.\r
+\r
+  @return  Value\r
+\r
+**/\r
+#define POST_CODE(Value)  PostCodeEnabled() ? PostCode(Value) : Value\r
+\r
+/**\r
+  Sends an 32-bit value to a POST and associated ASCII string.\r
+\r
+  If POST codes and POST code descriptions are enabled in \r
+  PcdPostCodeProperyMask, then call PostCodeWithDescription() passing in \r
+  Value and Description.  If only POST codes are enabled, then call PostCode() \r
+  passing in Value.  Value is returned.\r
+\r
+  @param  Value        The 32-bit value to write to the POST card.\r
+  @param  Description  Pointer to an ASCII string that is a description of the \r
+                       POST code value.\r
+\r
+**/\r
+#define POST_CODE_WITH_DESCRIPTION(Value,Description)  \\r
+  PostCodeEnabled()                              ?     \\r
+    (PostCodeDescriptionEnabled()                ?     \\r
+      PostCodeWithDescription(Value,Description) :     \\r
+      PostCode(Value))                           :     \\r
+    Value\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h
new file mode 100644 (file)
index 0000000..3409af9
--- /dev/null
@@ -0,0 +1,481 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePrintLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file Print Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PRINT_LIB_H__\r
+#define __EDKII_GLUE_PRINT_LIB_H__\r
+\r
+///\r
+/// Define the maximum number of characters that are required to\r
+/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL \r
+/// terminator.\r
+///  \r
+///  Maximum Length Decimal String     = 28\r
+///    "-9,223,372,036,854,775,808"\r
+///  Maximum Length Hexidecimal String = 17\r
+///    "FFFFFFFFFFFFFFFF"\r
+///  Maximum Length GUID               = 37\r
+///    "00000000-0000-0000-0000-000000000000"\r
+///  Maximum Length TIME               = 18\r
+///    "12/12/2006  12:12"\r
+///\r
+#define MAXIMUM_VALUE_CHARACTERS  38\r
+\r
+///\r
+/// Flags bitmask values use in UnicodeValueToString() and \r
+/// AsciiValueToString()\r
+///\r
+#define LEFT_JUSTIFY      0x01\r
+#define COMMA_TYPE        0x08\r
+#define PREFIX_ZERO       0x20\r
+#define RADIX_HEX         0x80\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on \r
+  a Null-terminated Unicode format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.  \r
+  The Unicode string is produced by parsing the format string specified by FormatString.  \r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.  \r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  Unicode format string and variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  IN  VA_LIST      Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated Unicode string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated Unicode \r
+  string specified by Buffer containing at most Width characters. No padding of spaces \r
+  is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
+  If the conversion contains more than Width characters, then only the first\r
+  Width characters are returned, and the total number of characters \r
+  required to perform the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If HEX_RADIX is set in Flags, then the output buffer will be \r
+  formatted in hexadecimal format.\r
+  If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  Unicode string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of Unicode characters to place in Buffer, not including\r
+                  the Null-terminator.\r
+  \r
+  @return The number of Unicode characters in Buffer not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeValueToString (\r
+  IN OUT CHAR16  *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated ASCII string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated ASCII string \r
+  specified by Buffer containing at most Width characters. No padding of spaces \r
+  is ever performed.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
+  If the conversion contains more than Width characters, then only the first Width\r
+  characters are returned, and the total number of characters required to perform\r
+  the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If HEX_RADIX is set in Flags, then the output buffer will be \r
+  formatted in hexadecimal format.\r
+  If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  ASCII string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of ASCII characters to place in Buffer, not including\r
+                  the Null-terminator.\r
+  \r
+  @return The number of ASCII characters in Buffer not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN UINTN      Flags,\r
+  IN INT64      Value,\r
+  IN UINTN      Width\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h
new file mode 100644 (file)
index 0000000..d7bc47b
--- /dev/null
@@ -0,0 +1,659 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueReportStatusCodeLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Report Status Code Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__\r
+#define __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__\r
+\r
+\r
+\r
+#define CodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE)    GlueCodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE)\r
+#define ReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER)  \\r
+                                                            GlueReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER)\r
+#define ReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT)                      \\r
+                                                            GlueReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT)\r
+#define ReportStatusCode(_TYPE, _VALUE)                     GlueReportStatusCode(_TYPE, _VALUE)\r
+#define ReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH)                                  \\r
+                                                            GlueReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH)\r
+#define ReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE)                       \\r
+                                                            GlueReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE)\r
+#define ReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE)  \\r
+                                                            GlueReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE)\r
+#define ReportProgressCodeEnabled()                         GlueReportProgressCodeEnabled()\r
+#define ReportErrorCodeEnabled()                            GlueReportErrorCodeEnabled()\r
+#define ReportDebugCodeEnabled()                            GlueReportDebugCodeEnabled()\r
+\r
+\r
+//\r
+// Declare bits for PcdReportStatusCodePropertyMask\r
+//\r
+#define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED          0x00000001\r
+#define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED             0x00000002\r
+#define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED             0x00000004\r
+\r
+//\r
+// Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed\r
+//\r
+\r
+///\r
+/// Voltage Extended Error Data\r
+///\r
+typedef struct {\r
+  EFI_EXP_BASE10_DATA   Voltage;\r
+  EFI_EXP_BASE10_DATA   Threshold;\r
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_VOLTAGE_ERROR_DATA;\r
+\r
+///\r
+/// Microcode Update Extended Error Data\r
+///\r
+typedef struct {\r
+  UINT32                Version;\r
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA;\r
+\r
+///\r
+/// Asynchronous Timer Extended Error Data\r
+///\r
+typedef struct {\r
+  EFI_EXP_BASE10_DATA   TimerLimit;\r
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA;\r
+\r
+///\r
+/// Host Processor Mismatch Extended Error Data\r
+///\r
+typedef struct {\r
+  UINT32                Instance;\r
+  UINT16                Attributes;\r
+} REPORT_STATUS_CODE_LIBRARY_HOST_PROCESSOR_MISMATCH_ERROR_DATA;\r
+\r
+///\r
+/// Thermal Extended Error Data\r
+///\r
+typedef struct {\r
+  EFI_EXP_BASE10_DATA   Temperature;\r
+  EFI_EXP_BASE10_DATA   Threshold;\r
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_THERMAL_ERROR_DATA;\r
+\r
+///\r
+/// Processor Disabled Extended Error Data\r
+///\r
+typedef struct {\r
+  UINT32                Cause;\r
+  BOOLEAN               SoftwareDisabled;\r
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA;\r
+\r
+///\r
+/// Embedded cache init extended data\r
+///\r
+typedef struct {\r
+  UINT32                Level;\r
+  EFI_INIT_CACHE_TYPE   Type;\r
+} REPORT_STATUS_CODE_LIBRARY_CACHE_INIT_DATA;\r
+\r
+///\r
+/// Memory Extended Error Data\r
+///\r
+typedef struct {\r
+  EFI_MEMORY_ERROR_GRANULARITY  Granularity;\r
+  EFI_MEMORY_ERROR_OPERATION    Operation;\r
+  UINTN                         Syndrome;\r
+  EFI_PHYSICAL_ADDRESS          Address;\r
+  UINTN                         Resolution;\r
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_EXTENDED_ERROR_DATA;\r
+\r
+///\r
+/// DIMM number\r
+///\r
+typedef struct {\r
+  UINT16                Array;\r
+  UINT16                Device;\r
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_DIMM_NUMBER;\r
+\r
+///\r
+/// Memory Module Mismatch Extended Error Data\r
+///\r
+typedef struct {\r
+  EFI_STATUS_CODE_DIMM_NUMBER Instance;\r
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_MODULE_MISMATCH_ERROR_DATA;\r
+\r
+///\r
+/// Memory Range Extended Data\r
+///\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  Start;\r
+  EFI_PHYSICAL_ADDRESS  Length;\r
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_RANGE_EXTENDED_DATA;\r
+\r
+///\r
+/// Device handle Extended Data. Used for many\r
+/// errors and progress codes to point to the device.\r
+///\r
+typedef struct {\r
+  EFI_HANDLE            Handle;\r
+} REPORT_STATUS_CODE_LIBRARY_DEVICE_HANDLE_EXTENDED_DATA;\r
+\r
+typedef struct {\r
+  UINT8                                *DevicePath;\r
+} REPORT_STATUS_CODE_LIBRARY_DEVICE_PATH_EXTENDED_DATA;\r
+\r
+typedef struct {\r
+  EFI_HANDLE                     ControllerHandle;\r
+  EFI_HANDLE                     DriverBindingHandle;\r
+  UINT16                         DevicePathSize;\r
+  UINT8                          *RemainingDevicePath;\r
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_START_EXTENDED_DATA;\r
+\r
+///\r
+/// Resource Allocation Failure Extended Error Data\r
+///\r
+typedef struct {\r
+  UINT32                             Bar;\r
+  UINT16                             DevicePathSize;\r
+  UINT16                             ReqResSize;\r
+  UINT16                             AllocResSize;\r
+  UINT8                              *DevicePath;\r
+  UINT8                              *ReqRes;\r
+  UINT8                              *AllocRes;\r
+} REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA;\r
+\r
+///\r
+/// Extended Error Data for Assert\r
+///\r
+typedef struct {\r
+  UINT32                      LineNumber;\r
+  UINT32                      FileNameSize;\r
+  EFI_STATUS_CODE_STRING_DATA *FileName;\r
+} REPORT_STATUS_CODE_LIBRARY_DEBUG_ASSERT_DATA;\r
+\r
+///\r
+/// System Context Data EBC/IA32/IPF\r
+///\r
+typedef struct {\r
+  EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT  Context;\r
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_EXCEP_EXTENDED_DATA;\r
+\r
+///\r
+/// Legacy Oprom extended data\r
+///\r
+typedef struct {\r
+  EFI_HANDLE            DeviceHandle;\r
+  EFI_PHYSICAL_ADDRESS  RomImageBase;\r
+} REPORT_STATUS_CODE_LIBRARY_LEGACY_OPROM_EXTENDED_DATA;\r
+\r
+//\r
+// Extern for the modules Caller ID GUID\r
+//\r
+extern EFI_GUID gEfiCallerIdGuid;\r
+\r
+/**\r
+  Converts a status code to an 8-bit POST code value.\r
+\r
+  Converts the status code specified by CodeType and Value to an 8-bit POST code \r
+  and returns the 8-bit POST code in PostCode.  If CodeType is an \r
+  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode \r
+  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits \r
+  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.  \r
+\r
+  If PostCode is NULL, then ASSERT().\r
+\r
+  @param  CodeType  The type of status code being converted.\r
+  @param  Value     The status code value being converted.\r
+  @param  PostCode  A pointer to the 8-bit POST code value to return. \r
+\r
+  @retval  TRUE   The status code specified by CodeType and Value was converted \r
+                  to an 8-bit POST code and returned in  PostCode.\r
+  @retval  FALSE  The status code specified by CodeType and Value could not be \r
+                  converted to an 8-bit POST code value.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueCodeTypeToPostCode (\r
+  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
+  IN  EFI_STATUS_CODE_VALUE  Value,\r
+  OUT UINT8                  *PostCode\r
+  );\r
+\r
+\r
+/**\r
+  Extracts ASSERT() information from a status code structure.\r
+\r
+  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
+  arguments specified by Filename, Description, and LineNumber.  If CodeType is \r
+  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r
+  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r
+  Filename, Description, and LineNumber from the optional data area of the \r
+  status code buffer specified by Data.  The optional data area of Data contains \r
+  a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r
+  ASCII string for the Description, followed by a 32-bit LineNumber.  If the \r
+  ASSERT() information could be extracted from Data, then return TRUE.  \r
+  Otherwise, FALSE is returned.  \r
+\r
+  If Data is NULL, then ASSERT().\r
+  If Filename is NULL, then ASSERT().\r
+  If Description is NULL, then ASSERT().\r
+  If LineNumber is NULL, then ASSERT().\r
+\r
+  @param  CodeType     The type of status code being converted.\r
+  @param  Value        The status code value being converted.\r
+  @param  Data         Pointer to status code data buffer. \r
+  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
+  @param  Description  Pointer to the description of the ASSERT().\r
+  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
+\r
+  @retval  TRUE   The status code specified by CodeType, Value, and Data was \r
+                  converted ASSERT() arguments specified by Filename, Description, \r
+                  and LineNumber.\r
+  @retval  FALSE  The status code specified by CodeType, Value, and Data could \r
+                  not be converted to ASSERT() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE        CodeType,\r
+  IN EFI_STATUS_CODE_VALUE       Value,  \r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT CHAR8                      **Filename,\r
+  OUT CHAR8                      **Description,\r
+  OUT UINT32                     *LineNumber\r
+  );\r
+\r
+\r
+/**\r
+  Extracts DEBUG() information from a status code structure.\r
+\r
+  Converts the status code specified by Data to the DEBUG() arguments specified \r
+  by ErrorLevel, Marker, and Format.  If type GUID in Data is \r
+  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and \r
+  Format from the optional data area of the status code buffer specified by Data.  \r
+  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker \r
+  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for \r
+  the Format.  If the DEBUG() information could be extracted from Data, then \r
+  return TRUE.  Otherwise, FALSE is returned.\r
+\r
+  If Data is NULL, then ASSERT().\r
+  If ErrorLevel is NULL, then ASSERT().\r
+  If Marker is NULL, then ASSERT().\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  Data        Pointer to status code data buffer. \r
+  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
+  @param  Marker      Pointer to the variable argument list associated with Format.\r
+  @param  Format      Pointer to a Null-terminated ASCII format string of a \r
+                      debug message.\r
+\r
+  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments \r
+                  specified by ErrorLevel, Marker, and Format.\r
+  @retval  FALSE  The status code specified by Data could not be converted to \r
+                  DEBUG() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractDebugInfo (\r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT UINT32                     *ErrorLevel,\r
+  OUT VA_LIST                    *Marker,\r
+  OUT CHAR8                      **Format\r
+  );\r
+\r
+\r
+/**\r
+  Reports a status code.\r
+\r
+  Reports the status code specified by the parameters Type and Value.  Status \r
+  code also require an instance, caller ID, and extended data.  This function \r
+  passed in a zero instance, NULL extended data, and a caller ID of \r
+  gEfiCallerIdGuid, which is the GUID for the module.  \r
+  \r
+  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode() \r
+  is called while processing another any other Report Status Code Library function,\r
+  then ReportStatusCode() must return immediately.\r
+\r
+  @param  Type   Status code type. \r
+  @param  Value  Status code value.\r
+\r
+  @retval  EFI_SUCCESS       The status code was reported.\r
+  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a \r
+                             device error.\r
+  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value\r
+  );\r
+\r
+\r
+/**\r
+  Reports a status code with a Device Path Protocol as the extended data.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  Device Path Protocol specified by DevicePath.  This function is responsible \r
+  for allocating a buffer large enough for the standard header and the device \r
+  path.  The standard header is filled in with a GUID of \r
+  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero \r
+  instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If \r
+  ReportStatusCodeWithDevicePath() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithDevicePath() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If DevicePath is NULL, then ASSERT().\r
+\r
+  @param  Type        Status code type. \r
+  @param  Value       Status code value.\r
+  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by DevicePath.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithDevicePath (\r
+  IN EFI_STATUS_CODE_TYPE            Type,\r
+  IN EFI_STATUS_CODE_VALUE           Value,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+\r
+/**\r
+  Reports a status code with an extended data buffer.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData \r
+  is assumed to be one of the data structures specified in Related Definitions.  \r
+  These data structure do not have the standard header, so this function is \r
+  responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled \r
+  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported \r
+  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If \r
+  ReportStatusCodeWithExtendedData() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithExtendedData() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL, then ASSERT().\r
+  If ExtendedDataSize is 0, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to \r
+                            be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by ExtendedData and ExtendedDataSize.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithExtendedData (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN CONST VOID             *ExtendedData,\r
+  IN UINTN                  ExtendedDataSize\r
+  );\r
+\r
+\r
+/**\r
+  Reports a status code with full parameters.\r
+\r
+  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize \r
+  is 0, then an extended data buffer is not reported.  If ExtendedData is not \r
+  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.  \r
+  ExtendedData is assumed not have the standard status code header, so this function \r
+  is responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled in \r
+  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a \r
+  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with \r
+  an instance specified by Instance and a caller ID specified by CallerId.  If \r
+  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
+\r
+  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx() \r
+  is called while processing another any other Report Status Code Library function, \r
+  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
+  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  If this parameter is NULL, then a caller \r
+                            ID of gEfiCallerIdGuid is used.\r
+  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.  \r
+                            If this parameter is NULL, then a the status code \r
+                            standard header is filled in with \r
+                            gEfiStatusCodeSpecificDataGuid.\r
+  @param  ExtendedData      Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate \r
+                                 the extended data section if it was specified.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeEx (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN UINT32                 Instance,\r
+  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
+  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
+  IN CONST VOID             *ExtendedData      OPTIONAL,\r
+  IN UINTN                  ExtendedDataSize\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportProgressCodeEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportErrorCodeEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportDebugCodeEnabled (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Reports a status code with minimal parameters if the status code type is enabled.\r
+\r
+  If the status code type specified by Type is enabled in \r
+  PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type \r
+  and Value.\r
+\r
+  @param  Type   Status code type. \r
+  @param  Value  Status code value.\r
+\r
+  @retval  EFI_SUCCESS       The status code was reported.\r
+  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a device error.\r
+  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
+\r
+**/\r
+#define REPORT_STATUS_CODE(Type,Value)                                                          \\r
+  (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ?  \\r
+  ReportStatusCode(Type,Value)                                                               :  \\r
+  (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ?  \\r
+  ReportStatusCode(Type,Value)                                                               :  \\r
+  (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)       ?  \\r
+  ReportStatusCode(Type,Value)                                                               :  \\r
+  EFI_UNSUPPORTED\r
+\r
+\r
+/**\r
+  Reports a status code with a Device Path Protocol as the extended data if the \r
+  status code type is enabled.\r
+\r
+  If the status code type specified by Type is enabled in \r
+  PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath() \r
+  passing in Type, Value, and DevicePath.\r
+\r
+  @param  Type        Status code type. \r
+  @param  Value       Status code value.\r
+  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by DevicePath.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter)                     \\r
+  (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ?  \\r
+  ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter)                             :  \\r
+  (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ?  \\r
+  ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter)                             :  \\r
+  (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)       ?  \\r
+  ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter)                             :  \\r
+  EFI_UNSUPPORTED\r
+\r
+\r
+/**\r
+  Reports a status code with an extended data buffer if the status code type \r
+  is enabled.\r
+\r
+  If the status code type specified by Type is enabled in \r
+  PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData() \r
+  passing in Type, Value, ExtendedData, and ExtendedDataSize.\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to\r
+                            be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by ExtendedData and ExtendedDataSize.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize)         \\r
+  (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ?  \\r
+  ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize)                 :  \\r
+  (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ?  \\r
+  ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize)                 :  \\r
+  (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)       ?  \\r
+  ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize)                 :  \\r
+  EFI_UNSUPPORTED\r
+\r
+/**\r
+  Reports a status code specifying all parameters if the status code type is enabled.\r
+\r
+  If the status code type specified by Type is enabled in \r
+  PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type, \r
+  Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  If this parameter is NULL, then a caller \r
+                            ID of gEfiCallerIdGuid is used.\r
+  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.  \r
+                            If this parameter is NULL, then a the status code \r
+                            standard header is filled in with \r
+                            gEfiStatusCodeSpecificDataGuid.\r
+  @param  ExtendedData      Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section if it was specified.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+#define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize)  \\r
+  (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)             ?  \\r
+  ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize)        :  \\r
+  (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)                   ?  \\r
+  ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize)        :  \\r
+  (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)                   ?  \\r
+  ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize)        :  \\r
+  EFI_UNSUPPORTED\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h
new file mode 100644 (file)
index 0000000..f2ea2fd
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueResourcePublicationLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Resource Publication Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__\r
+#define __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__\r
+\r
+/**\r
+  \r
+  Declares the presence of permanent system memory in the platform.\r
+\r
+  Declares that the system memory buffer specified by MemoryBegin and MemoryLength\r
+  as permanent memory that may be used for general purpose use by software.\r
+  The amount of memory available to software may be less than MemoryLength\r
+  if published memory has alignment restrictions.  \r
+\r
+  @param  MemoryBegin               The start address of the memory being declared.\r
+  @param  MemoryLength              The number of bytes of memory being declared.\r
+\r
+  @retval  RETURN_SUCCESS           The memory buffer was published.\r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to publish the memory buffer\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PublishSystemMemory (\r
+  IN PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                 MemoryLength\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h
new file mode 100644 (file)
index 0000000..3ae42e6
--- /dev/null
@@ -0,0 +1,394 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueSmbusLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Smbus Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_SMBUS_LIB_H__\r
+#define __EDKII_GLUE_SMBUS_LIB_H__\r
+\r
+//\r
+// PEC BIT is bit 22 in SMBUS address\r
+//\r
+#define SMBUS_LIB_PEC_BIT   (1 << 22)\r
+\r
+/**\r
+  Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
+  and PEC to a value that can be passed to the SMBUS Library functions.\r
+\r
+  Computes an address that is compatible with the SMBUS Library functions.\r
+  The unused upper bits of SlaveAddress, Command, and Length are stripped\r
+  prior to the generation of the address.\r
+  \r
+  @param  SlaveAddress    SMBUS Slave Address.  Range 0..127.\r
+  @param  Command         SMBUS Command.  Range 0..255.\r
+  @param  Length          SMBUS Data Length.  Range 0..32.\r
+  @param  Pec             TRUE if Packet Error Checking is enabled.  Otherwise FALSE.\r
+\r
+**/\r
+#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec)  \\r
+  ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0)      | \\r
+    (((SlaveAddress) & 0x7f) << 1)      | \\r
+    (((Command)      & 0xff) << 8)      | \\r
+    (((Length)       & 0x3f) << 16)       \\r
+  )\r
+\r
+/**\r
+  Executes an SMBUS quick read command.\r
+\r
+  Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickRead (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS quick write command.\r
+\r
+  Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickWrite (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS receive byte command.\r
+\r
+  Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  The byte received from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte received from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReceiveByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS send byte command.\r
+\r
+  Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
+  The byte specified by Value is sent.\r
+  Only the SMBUS slave address field of SmBusAddress is required.  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to send.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusSendByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS read data byte command.\r
+\r
+  Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 8-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReadDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS write data byte command.\r
+\r
+  Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
+  The 8-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusWriteDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS read data word command.\r
+\r
+  Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+  \r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusReadDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS write data word command.\r
+\r
+  Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusWriteDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS process call command.\r
+\r
+  Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value returned by the process call command is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The 16-bit value returned by the process call command.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS read block command.\r
+\r
+  Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Bytes are read from the SMBUS and stored in Buffer.\r
+  The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusReadBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS write block command.\r
+\r
+  Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from Buffer.\r
+  The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.  \r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusWriteBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+/**\r
+  Executes an SMBUS block process call command.\r
+\r
+  Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  WriteBuffer     Pointer to the buffer of bytes to write to the SMBUS.\r
+  @param  ReadBuffer      Pointer to the buffer of bytes to read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusBlockProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h
new file mode 100644 (file)
index 0000000..6e5e110
--- /dev/null
@@ -0,0 +1,106 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueTimerLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for Timer Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_TIMER_LIB_H__\r
+#define __EDKII_GLUE_TIMER_LIB_H__\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  );\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  );\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h
new file mode 100644 (file)
index 0000000..fa044ea
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiBootServicesTableLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for UEFI Boot Services Table Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__\r
+#define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__\r
+\r
+//\r
+// Cache the Image Handle\r
+//\r
+extern EFI_HANDLE         gImageHandle;\r
+\r
+//\r
+// Cache pointer to the EFI System Table\r
+//\r
+extern EFI_SYSTEM_TABLE   *gST;\r
+\r
+//\r
+// Cache pointer to the EFI Boot Services Table\r
+//\r
+extern EFI_BOOT_SERVICES  *gBS;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h
new file mode 100644 (file)
index 0000000..865b2a8
--- /dev/null
@@ -0,0 +1,113 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiDecompressLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for UEFI Decompress Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__\r
+#define __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__\r
+\r
+#define FillBuf(_SD, _NUMOFBITS)                GlueFillBuf(_SD, _NUMOFBITS)\r
+#define GetBits(_SD, _NUMOFBITS)                GlueGetBits(_SD, _NUMOFBITS)\r
+#define MakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) GlueMakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE)\r
+#define DecodeP(_SD)                            GlueDecodeP(_SD)\r
+#define ReadPTLen( _SD, _NN, _NBIT, _SPECIAL)   GlueReadPTLen( _SD, _NN, _NBIT, _SPECIAL)\r
+#define ReadCLen(_SD)                           GlueReadCLen(_SD)\r
+#define DecodeC(_SD)                            GlueDecodeC(_SD)\r
+#define Decode(_SD)                             GlueDecode(_SD)\r
+\r
+\r
+\r
+/**\r
+  Retrieves the size of the uncompressed buffer and the size of the scratch buffer.\r
+\r
+  Retrieves the size of the uncompressed buffer and the temporary scratch buffer \r
+  required to decompress the buffer specified by Source and SourceSize.\r
+  If the size of the uncompressed buffer or the size of the scratch buffer cannot\r
+  be determined from the compressed data specified by Source and SourceData, \r
+  then RETURN_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
+  buffer is returned in DestinationSize, the size of the scratch buffer is returned\r
+  in ScratchSize, and RETURN_SUCCESS is returned.\r
+  This function does not have scratch buffer available to perform a thorough \r
+  checking of the validity of the source data.  It just retrieves the "Original Size"\r
+  field from the beginning bytes of the source data and output it as DestinationSize.\r
+  And ScratchSize is specific to the decompression implementation.\r
+\r
+  If Source is NULL, then ASSERT().\r
+  If DestinationSize is NULL, then ASSERT().\r
+  If ScratchSize is NULL, then ASSERT().\r
+\r
+  @param  Source          The source buffer containing the compressed data.\r
+  @param  SourceSize      The size, in bytes, of the source buffer.\r
+  @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer\r
+                          that will be generated when the compressed buffer specified\r
+                          by Source and SourceSize is decompressed..\r
+  @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
+                          is required to decompress the compressed buffer specified \r
+                          by Source and SourceSize.\r
+\r
+  @retval  RETURN_SUCCESS The size of destination buffer and the size of scratch \r
+                          buffer are successull retrieved.\r
+  @retval  RETURN_INVALID_PARAMETER The source data is corrupted\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UefiDecompressGetInfo (\r
+  IN  CONST VOID  *Source,\r
+  IN  UINT32      SourceSize,\r
+  OUT UINT32      *DestinationSize,\r
+  OUT UINT32      *ScratchSize\r
+  );\r
+\r
+/**\r
+  Decompresses a compressed source buffer.\r
+\r
+  This function is designed so that the decompression algorithm can be implemented\r
+  without using any memory services.  As a result, this function is not allowed to\r
+  call any memory allocation services in its implementation.  It is the caller's r\r
+  esponsibility to allocate and free the Destination and Scratch buffers.\r
+  If the compressed source data specified by Source is sucessfully decompressed \r
+  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data \r
+  specified by Source is not in a valid compressed data format,\r
+  then RETURN_INVALID_PARAMETER is returned.\r
+\r
+  If Source is NULL, then ASSERT().\r
+  If Destination is NULL, then ASSERT().\r
+  If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().\r
+\r
+  @param  Source      The source buffer containing the compressed data.\r
+  @param  Destination The destination buffer to store the decompressed data\r
+  @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
+                      This is an optional parameter that may be NULL if the \r
+                      required scratch buffer size is 0.\r
+                     \r
+  @retval  RETURN_SUCCESS Decompression is successfull\r
+  @retval  RETURN_INVALID_PARAMETER The source data is corrupted\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UefiDecompress (\r
+  IN CONST VOID  *Source,\r
+  IN OUT VOID    *Destination,\r
+  IN OUT VOID    *Scratch\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h
new file mode 100644 (file)
index 0000000..967e45c
--- /dev/null
@@ -0,0 +1,162 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiDriverEntryPoint.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for UEFI Driver Entry Point Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__\r
+#define __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__\r
+\r
+//\r
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented \r
+//\r
+extern const UINT32                   _gUefiDriverRevision;\r
+\r
+//\r
+// Declare the number of entry points in the image. \r
+//\r
+extern const UINT8                    _gDriverEntryPointCount;\r
+\r
+//\r
+// Declare the number of unload handler in the image. \r
+//\r
+extern const UINT8                    _gDriverUnloadImageCount;\r
+\r
+//\r
+// Declare the arrary of Boot Sevice Exit Event callbacks . \r
+//\r
+extern const EFI_EVENT_NOTIFY         _gDriverExitBootServicesEvent[];\r
+\r
+//\r
+// Declare the arrary of Virtual Address Change Event callbacks . \r
+//\r
+extern const EFI_EVENT_NOTIFY         _gDriverSetVirtualAddressMapEvent[];\r
+\r
+/**\r
+  Enrty point to DXE SMM Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Enrty point wrapper of DXE Driver.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
+  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Computes the cummulative return status for the driver entry point and perform\r
+  a long jump back into DriverEntryPoint().\r
+\r
+  @param  Status Status returned by the driver that is exiting.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ExitDriver (\r
+  IN EFI_STATUS  Status\r
+  );\r
+\r
+\r
+/**\r
+  Call constructs for all libraries. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryConstructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Call destructors for all libraries. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryDestructorList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+/**\r
+  Call the list of driver entry points. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
+  @param  SystemTable Pointer to the EFI System Table.\r
+\r
+  @return Status returned by entry points of drivers.  \r
\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleEntryPointList (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+\r
+/**\r
+  Call the unload handlers for all the modules. Automatics Generated by tool.\r
+\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
\r
+  @return Status returned by unload handlers of drivers.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessModuleUnloadList (\r
+  IN EFI_HANDLE  ImageHandle\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
new file mode 100644 (file)
index 0000000..2038303
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiDriverModelLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for UEFI Driver Model Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__\r
+#define __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__\r
+\r
+//\r
+// Declare bitmask values for the protocols that are enabled \r
+//\r
+#define UEFI_DRIVER_MODEL_LIBRARY_COMPONENT_NAME_PROTOCOL_ENABLED        0x01\r
+#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_DIAGNOSTICS_PROTOCOL_ENABLED    0x02\r
+#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_CONFIGURATION_PROTOCOL_ENABLED  0x04\r
+\r
+//\r
+// Data structure that declares pointers to the Driver Model \r
+// Protocols.\r
+//\r
+typedef struct {\r
+  const EFI_DRIVER_BINDING_PROTOCOL        *DriverBinding;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  const EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName;\r
+#else\r
+  const EFI_COMPONENT_NAME_PROTOCOL        *ComponentName;\r
+#endif\r
+  const EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration;\r
+  const EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics;\r
+} EFI_DRIVER_MODEL_PROTOCOL_LIST;\r
+\r
+//\r
+// UEFI Driver Model Protocols arrary\r
+//\r
+extern const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[];\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
new file mode 100644 (file)
index 0000000..eba1f1a
--- /dev/null
@@ -0,0 +1,722 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiLib.h\r
+  \r
+Abstract: \r
+\r
+  Public header file for UEFI Lib\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_LIB_H__\r
+#define __EDKII_GLUE_UEFI_LIB_H__\r
+\r
+\r
+#define EfiInitializeLock(_LOCK, _PRIORITY)                             GlueEfiInitializeLock(_LOCK, _PRIORITY)\r
+#define EfiAcquireLock(_LOCK)                                           GlueEfiAcquireLock(_LOCK)\r
+#define EfiAcquireLockOrFail(_LOCK)                                     GlueEfiAcquireLockOrFail(_LOCK)\r
+#define EfiReleaseLock(_LOCK)                                           GlueEfiReleaseLock(_LOCK)\r
+#define GetGlyphWidth(_UNICODECHAR)                                     GlueGetGlyphWidth(_UNICODECHAR)\r
+#define EfiCreateEventLegacyBoot(_LEGACYBOOT)                           GlueEfiCreateEventLegacyBoot(_LEGACYBOOT)\r
+#define EfiCreateEventReadyToBoot(_READYTOBOOTEVENT)                    GlueEfiCreateEventReadyToBoot(_READYTOBOOTEVENT)\r
+#define EfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE)        GlueEfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE)\r
+#define EfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID)  GlueEfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID)\r
+\r
+\r
+//\r
+// EFI Lock Status\r
+//\r
+typedef enum {\r
+  EfiLockUninitialized = 0,\r
+  EfiLockReleased      = 1,\r
+  EfiLockAcquired      = 2\r
+} EFI_LOCK_STATE;\r
+\r
+\r
+/**\r
+  This function searches the list of configuration tables stored in the EFI System \r
+  Table for a table with a GUID that matches TableGuid.  If a match is found, \r
+  then a pointer to the configuration table is returned in Table, and EFI_SUCCESS \r
+  is returned.  If a matching GUID is not found, then EFI_NOT_FOUND is returned.\r
+\r
+  @param  TableGuid       Pointer to table's GUID type..\r
+  @param  Table           Pointer to the table associated with TableGuid in the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS     A configuration table matching TableGuid was found.\r
+  @retval EFI_NOT_FOUND   A configuration table matching TableGuid could not be found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetSystemConfigurationTable (  \r
+  IN  EFI_GUID  *TableGuid,\r
+  OUT VOID      **Table\r
+  );\r
+\r
+/**\r
+  This function causes the notification function to be executed for every protocol \r
+  of type ProtocolGuid instance that exists in the system when this function is \r
+  invoked.  In addition, every time a protocol of type ProtocolGuid instance is \r
+  installed or reinstalled, the notification function is also executed.\r
+\r
+  @param  ProtocolGuid    Supplies GUID of the protocol upon whose installation the event is fired.\r
+  @param  NotifyTpl       Supplies the task priority level of the event notifications.\r
+  @param  NotifyFunction  Supplies the function to notify when the event is signaled.\r
+  @param  NotifyContext   The context parameter to pass to NotifyFunction.\r
+  @param  Registration    A pointer to a memory location to receive the registration value.\r
+\r
+  @return The notification event that was created. \r
+\r
+**/\r
+EFI_EVENT\r
+EFIAPI\r
+EfiCreateProtocolNotifyEvent(\r
+  IN  EFI_GUID          *ProtocolGuid,\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT VOID              **Registration\r
+  );\r
+\r
+/**\r
+  This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
+  This event is signaled with EfiNamedEventSignal().  This provide the ability for \r
+  one or more listeners on the same event named by the GUID specified by Name.\r
+\r
+  @param  Name                  Supplies GUID name of the event.\r
+  @param  NotifyTpl             Supplies the task priority level of the event notifications.\r
+  @param  NotifyFunction        Supplies the function to notify when the event is signaled.\r
+  @param  NotifyContext         The context parameter to pass to NotifyFunction. \r
+  @param  Registration          A pointer to a memory location to receive the registration value.\r
+\r
+  @retval EFI_SUCCESS           A named event was created.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resource to create the named event.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNamedEventListen (\r
+  IN CONST EFI_GUID    *Name,\r
+  IN EFI_TPL           NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY  NotifyFunction,\r
+  IN CONST VOID        *NotifyContext,  OPTIONAL\r
+  OUT VOID             *Registration OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function signals the named event specified by Name.  The named event must \r
+  have been created with EfiNamedEventListen().\r
+\r
+  @param  Name                  Supplies GUID name of the event.\r
+\r
+  @retval EFI_SUCCESS           A named event was signaled.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resource to signal the named event.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNamedEventSignal (\r
+  IN CONST EFI_GUID  *Name\r
+  );\r
+\r
+/** \r
+  Returns the current TPL.\r
+\r
+  This function returns the current TPL.  There is no EFI service to directly \r
+  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level \r
+  can then immediately be restored back to the current TPL level with a call \r
+  to RestoreTPL().\r
+\r
+  @param  VOID\r
+\r
+  @retvale EFI_TPL              The current TPL.\r
+\r
+**/\r
+EFI_TPL\r
+EFIAPI\r
+EfiGetCurrentTpl (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function initializes a basic mutual exclusion lock to the released state \r
+  and returns the lock.  Each lock provides mutual exclusion access at its task \r
+  priority level.  Since there is no preemption or multiprocessor support in EFI,\r
+  acquiring the lock only consists of raising to the locks TPL.\r
+\r
+  @param  Lock       A pointer to the lock data structure to initialize.\r
+  @param  Priority   EFI TPL associated with the lock.\r
+\r
+  @return The lock.\r
+\r
+**/\r
+EFI_LOCK *\r
+EFIAPI\r
+GlueEfiInitializeLock (\r
+  IN OUT EFI_LOCK  *Lock,\r
+  IN EFI_TPL        Priority\r
+  );\r
+\r
+/**\r
+  This macro initializes the contents of a basic mutual exclusion lock to the \r
+  released state.  Each lock provides mutual exclusion access at its task \r
+  priority level.  Since there is no preemption or multiprocessor support in EFI,\r
+  acquiring the lock only consists of raising to the locks TPL.\r
+\r
+  @param  Lock      A pointer to the lock data structure to initialize.\r
+  @param  Priority  The task priority level of the lock.\r
+\r
+  @return The lock.\r
+\r
+**/\r
+#ifdef EFI_INITIALIZE_LOCK_VARIABLE\r
+#undef EFI_INITIALIZE_LOCK_VARIABLE\r
+#endif\r
+\r
+#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \\r
+  {Priority, EFI_TPL_APPLICATION, EfiLockReleased }\r
+\r
+\r
+/**\r
+  \r
+  Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.\r
+\r
+  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
+  then this macro evaluates the EFI_LOCK structure specified by Lock.  If Lock \r
+  is not in the locked state, then DebugAssert() is called passing in the source \r
+  filename, source line number, and Lock.\r
+\r
+  If Lock is NULL, then ASSERT().\r
+\r
+  @param  LockParameter  A pointer to the lock to acquire.\r
+\r
+**/\r
+#ifdef ASSERT_LOCKED\r
+#undef ASSERT_LOCKED\r
+#endif\r
+\r
+#define ASSERT_LOCKED(LockParameter)                  \\r
+  do {                                                \\r
+    if (DebugAssertEnabled ()) {                      \\r
+      ASSERT (LockParameter != NULL);                 \\r
+      if ((LockParameter)->Lock != EfiLockAcquired) { \\r
+        _ASSERT (LockParameter not locked);           \\r
+      }                                               \\r
+    }                                                 \\r
+  } while (FALSE)\r
+\r
+\r
+/**\r
+  This function raises the system's current task priority level to the task \r
+  priority level of the mutual exclusion lock.  Then, it places the lock in the \r
+  acquired state.\r
+\r
+  @param  Priority  The task priority level of the lock.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+/**\r
+  This function raises the system's current task priority level to the task \r
+  priority level of the mutual exclusion lock.  Then, it attempts to place the \r
+  lock in the acquired state.\r
+\r
+  @param  Lock              A pointer to the lock to acquire.\r
+\r
+  @retval EFI_SUCCESS       The lock was acquired.\r
+  @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+/**\r
+  This function transitions a mutual exclusion lock from the acquired state to \r
+  the released state, and restores the system's task priority level to its \r
+  previous level.\r
+\r
+  @param  Lock  A pointer to the lock to release.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  );\r
+\r
+/**\r
+  Tests whether a controller handle is being managed by a specific driver.\r
+\r
+  This function tests whether the driver specified by DriverBindingHandle is\r
+  currently managing the controller specified by ControllerHandle.  This test\r
+  is performed by evaluating if the the protocol specified by ProtocolGuid is\r
+  present on ControllerHandle and is was opened by DriverBindingHandle with an\r
+  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
+  If ProtocolGuid is NULL, then ASSERT().\r
+\r
+  @param  ControllerHandle     A handle for a controller to test.\r
+  @param  DriverBindingHandle  Specifies the driver binding handle for the\r
+                               driver.\r
+  @param  ProtocolGuid         Specifies the protocol that the driver specified\r
+                               by DriverBindingHandle opens in its Start()\r
+                               function.\r
+\r
+  @retval EFI_SUCCESS          ControllerHandle is managed by the driver\r
+                               specifed by DriverBindingHandle.\r
+  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver\r
+                               specifed by DriverBindingHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestManagedDevice (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       DriverBindingHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  );\r
+\r
+/**\r
+  Tests whether a child handle is a child device of the controller.\r
+\r
+  This function tests whether ChildHandle is one of the children of\r
+  ControllerHandle.  This test is performed by checking to see if the protocol\r
+  specified by ProtocolGuid is present on ControllerHandle and opened by\r
+  ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  If ProtocolGuid is NULL, then ASSERT().\r
+\r
+  @param  ControllerHandle     A handle for a (parent) controller to test. \r
+  @param  ChildHandle          A child handle to test.\r
+  @param  ConsumsedGuid        Supplies the protocol that the child controller\r
+                               opens on its parent controller. \r
+\r
+  @retval EFI_SUCCESS          ChildHandle is a child of the ControllerHandle.\r
+  @retval EFI_UNSUPPORTED      ChildHandle is not a child of the\r
+                               ControllerHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestChildHandle (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       ChildHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  );\r
+\r
+/**\r
+  This function looks up a Unicode string in UnicodeStringTable.  If Language is \r
+  a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
+  that matches the language code specified by Language, then it is returned in \r
+  UnicodeString.\r
+\r
+  @param  Language                A pointer to the ISO 639-2 language code for the \r
+                                  Unicode string to look up and return.\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes \r
+                                  that the Unicode string table supports.  Language \r
+                                  must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string from UnicodeStringTable\r
+                                  that matches the language specified by Language.\r
+\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found\r
+                                  in the table of Unicoide strings UnicodeStringTable, \r
+                                  and it was returned in UnicodeString.\r
+  @retval EFI_INVALID_PARAMETER   Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
+  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
+  @retval EFI_UNSUPPORTED         UnicodeStringTable is NULL.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not \r
+                                  supported by UnicodeStringTable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LookupUnicodeString (\r
+  IN CONST CHAR8                     *Language,\r
+  IN CONST CHAR8                     *SupportedLanguages,\r
+  IN CONST EFI_UNICODE_STRING_TABLE  *UnicodeStringTable,\r
+  OUT CHAR16                         **UnicodeString\r
+  );\r
+\r
+/**\r
+  This function adds a Unicode string to UnicodeStringTable.\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to \r
+  UnicodeStringTable.  New buffers are allocated for both Language and \r
+  UnicodeString.  The contents of Language and UnicodeString are copied into \r
+  these new buffers.  These buffers are automatically freed when \r
+  FreeUnicodeStringTable() is called.\r
+\r
+  @param  Language                A pointer to the ISO 639-2 language code for the Unicode \r
+                                  string to add.\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes\r
+                                  that the Unicode string table supports.\r
+                                  Language must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string to add.\r
+\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found in the table of \r
+                                  Unicode strings UnicodeStringTable, and it was \r
+                                  returned in UnicodeString.\r
+  @retval EFI_INVALID_PARAMETER   Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.\r
+  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
+  @retval EFI_ALREADY_STARTED     A Unicode string with language Language is \r
+                                  already present in UnicodeStringTable.\r
+  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to add another \r
+                                  Unicode string to UnicodeStringTable.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddUnicodeString (\r
+  IN CONST CHAR8               *Language,\r
+  IN CONST CHAR8               *SupportedLanguages,\r
+  IN EFI_UNICODE_STRING_TABLE  **UnicodeStringTable,\r
+  IN CONST CHAR16              *UnicodeString\r
+  );\r
+\r
+/**\r
+  This function frees the table of Unicode strings in UnicodeStringTable.\r
+  If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
+  Otherwise, each language code, and each Unicode string in the Unicode string \r
+  table are freed, and EFI_SUCCESS is returned.\r
+\r
+  @param  UnicodeStringTable  A pointer to the table of Unicode strings.\r
+\r
+  @retval EFI_SUCCESS         The Unicode string table was freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FreeUnicodeStringTable (\r
+  IN EFI_UNICODE_STRING_TABLE  *UnicodeStringTable\r
+  );\r
+\r
+/**\r
+  This function computes and returns the width of the Unicode character \r
+  specified by UnicodeChar.\r
+\r
+  @param  UnicodeChar   A Unicode character.\r
+\r
+  @retval 0             The width if UnicodeChar could not be determined.\r
+  @retval 1             UnicodeChar is a narrow glyph.\r
+  @retval 2             UnicodeChar is a wide glyph.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueGetGlyphWidth (\r
+  IN CHAR16  UnicodeChar\r
+  );\r
+\r
+/**\r
+  This function computes and returns the display length of\r
+  the Null-terminated Unicode string specified by String.\r
+  If String is NULL, then 0 is returned.\r
+  If any of the widths of the Unicode characters in String\r
+  can not be determined, then 0 is returned.\r
+\r
+  @param  String      A pointer to a Null-terminated Unicode string.\r
+\r
+  @return The display length of the Null-terminated Unicode string specified by String.\r
+  \r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeStringDisplayLength (\r
+  IN CONST CHAR16  *String\r
+  );\r
+\r
+//\r
+// Functions that abstract early Framework contamination of UEFI.\r
+//\r
+/**\r
+  Signal a Ready to Boot Event.  \r
+  \r
+  Create a Ready to Boot Event. Signal it and close it. This causes other \r
+  events of the same event group to be signaled in other modules. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiSignalEventReadyToBoot (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Signal a Legacy Boot Event.  \r
+  \r
+  Create a legacy Boot Event. Signal it and close it. This causes other \r
+  events of the same event group to be signaled in other modules. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiSignalEventLegacyBoot (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Create a Legacy Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiCreateEventLegacyBoot (\r
+  OUT EFI_EVENT  *LegacyBootEvent\r
+  );\r
+\r
+/**\r
+  Create an EFI event in the Legacy Boot Event Group and allows\r
+  the caller to specify a notification function.  \r
+  \r
+  This function abstracts the creation of the Legacy Boot Event.\r
+  The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
+  This library abstracts the caller from how this event is created to prevent\r
+  to code form having to change with the version of the specification supported.\r
+  If LegacyBootEvent is NULL, then ASSERT().\r
+\r
+  @param  NotifyTpl         The task priority level of the event.\r
+  @param  NotifyFunction    The notification function to call when the event is signaled.\r
+  @param  NotifyContext     The content to pass to NotifyFunction when the event is signaled.\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventLegacyBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *LegacyBootEvent\r
+  );\r
+\r
+/**\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiCreateEventReadyToBoot (\r
+  OUT EFI_EVENT  *ReadyToBootEvent\r
+  );\r
+\r
+/**\r
+  Create an EFI event in the Ready To Boot Event Group and allows\r
+  the caller to specify a notification function.  \r
+  \r
+  This function abstracts the creation of the Ready to Boot Event.\r
+  The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
+  This library abstracts the caller from how this event is created to prevent\r
+  to code form having to change with the version of the specification supported.\r
+  If ReadyToBootEvent is NULL, then ASSERT().\r
+\r
+  @param  NotifyTpl         The task priority level of the event.\r
+  @param  NotifyFunction    The notification function to call when the event is signaled.\r
+  @param  NotifyContext     The content to pass to NotifyFunction when the event is signaled.\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventReadyToBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *ReadyToBootEvent\r
+  );\r
+\r
+/**\r
+  Initialize a Firmware Volume (FV) Media Device Path node.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for Tiano extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability.\r
+\r
+  @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
+  @param  NameGuid          FV file name to use in FvDevicePathNode\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiInitializeFwVolDevicepathNode (\r
+  IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode,\r
+  IN CONST EFI_GUID                         *NameGuid\r
+  );\r
+\r
+/**\r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid \r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for Tiano extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability. The return value to this\r
+  function points to a location in FvDevicePathNode and it does not allocate\r
+  new memory for the GUID pointer that is returned.\r
+\r
+  @param  FvDevicePathNode  Pointer to FV device path to check.\r
+\r
+  @retval NULL              FvDevicePathNode is not valid.\r
+  @retval Other             FvDevicePathNode is valid and pointer to NameGuid was returned.\r
+\r
+**/\r
+EFI_GUID *\r
+EFIAPI\r
+GlueEfiGetNameGuidFromFwVolDevicePathNode (\r
+  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
+  );\r
+\r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
+  ConOut defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to ConOut.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+\r
+  @param Format   Null-terminated Unicode format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Print (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
+  StdErr defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to StdErr.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+\r
+  @param Format   Null-terminated Unicode format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+ErrorPrint (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
+  ConOut defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to ConOut.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+\r
+  @param Format   Null-terminated ASCII format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiPrint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
+  StdErr defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to StdErr.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+\r
+  @param Format   Null-terminated ASCII format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiErrorPrint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h
new file mode 100644 (file)
index 0000000..f4bace1
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueUefiRuntimeServicesTableLib.h\r
+  \r
+Abstract: \r
+\r
+  Library that provides a global pointer to the UEFI Runtime Services Tables\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__\r
+#define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__\r
+\r
+//\r
+// Cached copy of the EFI Runtime Services Table\r
+//\r
+extern EFI_RUNTIME_SERVICES  *gRT;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h
new file mode 100644 (file)
index 0000000..e60daa5
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcd.h\r
+  \r
+Abstract: \r
+\r
+  Fixed-at-build PCD macro expansion definitions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_H__\r
+#define __EDKII_GLUE_PCD_H__\r
+\r
+//\r
+// Redefine Pcd functions into compile time hardcoded values\r
+//\r
+#define FixedPcdGet8(TokenName)     __EDKII_GLUE_PCD_##TokenName##__\r
+#define FixedPcdGet16(TokenName)    __EDKII_GLUE_PCD_##TokenName##__\r
+#define FixedPcdGet32(TokenName)    __EDKII_GLUE_PCD_##TokenName##__\r
+#define FixedPcdGet64(TokenName)    __EDKII_GLUE_PCD_##TokenName##__\r
+#define FixedPcdGetBool(TokenName)  __EDKII_GLUE_PCD_##TokenName##__\r
+\r
+#define PcdGet8(TokenName)          __EDKII_GLUE_PCD_##TokenName##__\r
+#define PcdGet16(TokenName)         __EDKII_GLUE_PCD_##TokenName##__\r
+#define PcdGet32(TokenName)         __EDKII_GLUE_PCD_##TokenName##__\r
+#define PcdGet64(TokenName)         __EDKII_GLUE_PCD_##TokenName##__\r
+#define PcdGetPtr(TokenName)        __EDKII_GLUE_PCD_##TokenName##__\r
+#define PcdGetBool(TokenName)       __EDKII_GLUE_PCD_##TokenName##__\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h
new file mode 100644 (file)
index 0000000..6e89978
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdBaseLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD vadues for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_BASE_LIB_H__\r
+#define __EDKII_GLUE_PCD_BASE_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+#ifndef __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__\r
+#define __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ EDKII_GLUE_MaximumUnicodeStringLength\r
+#endif\r
+\r
+#ifndef __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__\r
+#define __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__   EDKII_GLUE_MaximumAsciiStringLength\r
+#endif\r
+\r
+//\r
+// SpinLock Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdSpinLockTimeout__\r
+#define __EDKII_GLUE_PCD_PcdSpinLockTimeout__            EDKII_GLUE_SpinLockTimeout\r
+#endif\r
+\r
+// Linked List\r
+#ifndef  __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__\r
+#define  __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__   EDKII_GLUE_MaximumLinkedListLength\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h
new file mode 100644 (file)
index 0000000..0128575
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdDebugLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_DEBUG_LIB_H__\r
+#define __EDKII_GLUE_PCD_DEBUG_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+\r
+//\r
+// Debug Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__\r
+#define __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__        EDKII_GLUE_DebugPrintErrorLevel\r
+#endif\r
+\r
+\r
+#ifndef __EDKII_GLUE_PCD_PcdDebugPropertyMask__\r
+#define __EDKII_GLUE_PCD_PcdDebugPropertyMask__           EDKII_GLUE_DebugPropertyMask\r
+#endif\r
+\r
+\r
+#ifndef __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__\r
+#define __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__       EDKII_GLUE_DebugClearMemoryValue\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h
new file mode 100644 (file)
index 0000000..1de1434
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdIoLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_IO_LIB_H__\r
+#define __EDKII_GLUE_PCD_IO_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+\r
+//\r
+// IoBlockBaseAddressForIpf Pcd\r
+//\r
+#ifdef MDE_CPU_IPF\r
+#ifndef __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__\r
+#define __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__   EDKII_GLUE_IoBlockBaseAddressForIpf\r
+#endif\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h
new file mode 100644 (file)
index 0000000..7593ceb
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdPciExpressLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__\r
+#define __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+\r
+//\r
+// PciExpress Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__\r
+#define __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__   EDKII_GLUE_PciExpressBaseAddress\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h
new file mode 100644 (file)
index 0000000..401cc55
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdPostCodeLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_POST_CODE_LIB_H__\r
+#define __EDKII_GLUE_PCD_POST_CODE_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+//\r
+// PostCode Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdPostCodePropertyMask__\r
+#define __EDKII_GLUE_PCD_PcdPostCodePropertyMask__     EDKII_GLUE_PostCodePropertyMask\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h
new file mode 100644 (file)
index 0000000..6d4306f
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdReportStatusCodeLib.h\r
+  \r
+Abstract: \r
+\r
+  Pcd values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__\r
+#define __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+//\r
+// ReportStatusCode Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__\r
+#define __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__   EDKII_GLUE_ReportStatusCodePropertyMask\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h
new file mode 100644 (file)
index 0000000..47d8c1c
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGluePcdTimerLib.h\r
+  \r
+Abstract: \r
+\r
+  PCD values for library customization\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PCD_TIMER_LIB_H__\r
+#define __EDKII_GLUE_PCD_TIMER_LIB_H__\r
+\r
+//\r
+// Following Pcd values are hard coded at compile time.\r
+// Override these through compiler option "/D" in PlatformTools.env if needed\r
+//\r
+\r
+\r
+//\r
+// Timer Lib Pcds\r
+//\r
+#ifndef __EDKII_GLUE_PCD_PcdFSBClock__\r
+#define __EDKII_GLUE_PCD_PcdFSBClock__   EDKII_GLUE_FSBClock\r
+#endif\r
+\r
+#include "Pcd/EdkIIGluePcd.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h
new file mode 100644 (file)
index 0000000..d9e0b20
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeimDepex.h\r
+  \r
+Abstract: \r
+\r
+  This file is used by .dxs file. To write common .dxs for R8.x and R9, a \r
+  header file named PeimDepex.h musted be present. \r
+\r
+--*/\r
+\r
+\r
+#ifndef __EDKII_GLUELIB_PEIMDEPEX_H__\r
+#define __EDKII_GLUELIB_PEIMDEPEX_H__\r
+\r
+\r
+//\r
+//  this file is used by .dxs file, just a place holder\r
+//\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h
new file mode 100644 (file)
index 0000000..7d58bd3
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueProcessorBind.h\r
+  \r
+Abstract: \r
+\r
+  Processor specific definitions\r
+\r
+--*/\r
+\r
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__\r
+#define __EDKII_GLUE_PROCESSOR_BIND_H__\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#ifndef MDE_CPU_X64\r
+  #define MDE_CPU_X64\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
new file mode 100644 (file)
index 0000000..c24ff0c
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseCacheMaintenanceLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseCacheMaintenanceLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseCacheMaintenanceLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ia32]\r
+  x86Cache.c\r
+\r
+[sources.x64]\r
+  x86Cache.c \r
+\r
+[sources.ipf]\r
+  IpfCache.c\r
+\r
+[sources.ebc]\r
+  EbcCache.c\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\Include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
+  
\ 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 (file)
index 0000000..585c6b4
--- /dev/null
@@ -0,0 +1,241 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86Cache.c\r
+  \r
+Abstract: \r
+\r
+  Cache Maintenance Functions.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueInvalidateInstructionCache (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU. This function guarantees that all dirty cache lines are\r
+  written back to system memory, and also invalidates all the data cache lines\r
+  in the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackInvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates a range of data cache lines in the cache\r
+  coherency domain of the calling CPU.\r
+\r
+  Writes Back and Invalidate the data cache lines specified by Address and\r
+  Length. If Address is not aligned on a cache line boundary, then entire data\r
+  cache line containing Address is written back and invalidated. If Address +\r
+  Length is not aligned on a cache line boundary, then the entire data cache\r
+  line containing Address + Length -1 is written back and invalidated. This\r
+  function may choose to write back and invalidate the entire data cache if\r
+  that is more efficient than writing back and invalidating the specified\r
+  range. If Length is 0, the no data cache lines are written back and\r
+  invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back and\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back and invalidate from the\r
+                  data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackInvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU. This function guarantees that all dirty cache lines are written back to\r
+  system memory. This function may also invalidate all the data cache lines in\r
+  the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackDataCache (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Writes Back a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Writes Back the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is written back. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is written back. This function may choose to write back the entire\r
+  data cache if that is more efficient than writing back the specified range.\r
+  If Length is 0, the no data cache lines are written back. This function may\r
+  also invalidate all the data cache lines in the specified range of the cache\r
+  coherency domain of the calling CPU. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing\r
+                  mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU. This function must be used with care because dirty cache lines are not\r
+  written back to system memory. It is typically used for cache diagnostics. If\r
+  the CPU does not support invalidation of the entire data cache, then a write\r
+  back and invalidate operation should be performed on the entire data cache.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Invalidates a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is invalidated. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is invalidated. This function must never invalidate any cache lines\r
+  outside the specified range. If Length is 0, the no data cache lines are\r
+  invalidated. Address is returned. This function must be used with care\r
+  because dirty cache lines are not written back to system memory. It is\r
+  typically used for cache diagnostics. If the CPU does not support\r
+  invalidation of a data cache range, then a write back and invalidate\r
+  operation should be performed on the data cache range.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to invalidate. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+  @param  Length  The number of bytes to invalidate from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return Address;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c
new file mode 100644 (file)
index 0000000..ebfaebd
--- /dev/null
@@ -0,0 +1,245 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86Cache.c\r
+  \r
+Abstract: \r
+\r
+  Cache Maintenance Functions.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueInvalidateInstructionCache (\r
+  VOID\r
+  )\r
+{\r
+  PalCallStatic (NULL, 1, 1, 1, 0);\r
+}\r
+\r
+/**\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return IpfFlushCacheRange (Address, Length);\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU. This function guarantees that all dirty cache lines are\r
+  written back to system memory, and also invalidates all the data cache lines\r
+  in the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackInvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+  PalCallStatic (NULL, 1, 2, 1, 0);\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates a range of data cache lines in the cache\r
+  coherency domain of the calling CPU.\r
+\r
+  Writes Back and Invalidate the data cache lines specified by Address and\r
+  Length. If Address is not aligned on a cache line boundary, then entire data\r
+  cache line containing Address is written back and invalidated. If Address +\r
+  Length is not aligned on a cache line boundary, then the entire data cache\r
+  line containing Address + Length -1 is written back and invalidated. This\r
+  function may choose to write back and invalidate the entire data cache if\r
+  that is more efficient than writing back and invalidating the specified\r
+  range. If Length is 0, the no data cache lines are written back and\r
+  invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back and\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back and invalidate from the\r
+                  data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackInvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+\r
+  return IpfFlushCacheRange (Address, Length);\r
+}\r
+\r
+/**\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU. This function guarantees that all dirty cache lines are written back to\r
+  system memory. This function may also invalidate all the data cache lines in\r
+  the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackDataCache (\r
+  VOID\r
+  )\r
+{\r
+  PalCallStatic (NULL, 1, 2, 0, 0);\r
+}\r
+\r
+/**\r
+  Writes Back a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Writes Back the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is written back. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is written back. This function may choose to write back the entire\r
+  data cache if that is more efficient than writing back the specified range.\r
+  If Length is 0, the no data cache lines are written back. This function may\r
+  also invalidate all the data cache lines in the specified range of the cache\r
+  coherency domain of the calling CPU. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing\r
+                  mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+\r
+  return IpfFlushCacheRange (Address, Length);\r
+}\r
+\r
+/**\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU. This function must be used with care because dirty cache lines are not\r
+  written back to system memory. It is typically used for cache diagnostics. If\r
+  the CPU does not support invalidation of the entire data cache, then a write\r
+  back and invalidate operation should be performed on the entire data cache.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+  WriteBackInvalidateDataCache ();\r
+}\r
+\r
+/**\r
+  Invalidates a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is invalidated. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is invalidated. This function must never invalidate any cache lines\r
+  outside the specified range. If Length is 0, the no data cache lines are\r
+  invalidated. Address is returned. This function must be used with care\r
+  because dirty cache lines are not written back to system memory. It is\r
+  typically used for cache diagnostics. If the CPU does not support\r
+  invalidation of a data cache range, then a write back and invalidate\r
+  operation should be performed on the data cache range.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to invalidate. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+  @param  Length  The number of bytes to invalidate from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return IpfFlushCacheRange (Address, Length);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c
new file mode 100644 (file)
index 0000000..2e2cb76
--- /dev/null
@@ -0,0 +1,262 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86Cache.c\r
+  \r
+Abstract: \r
+\r
+  Cache Maintenance Functions.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+//\r
+// This size must be at or below the smallest cache size possible among all\r
+// supported processors\r
+//\r
+#define CACHE_LINE_SIZE             0x20\r
+\r
+/**\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the entire instruction cache in cache coherency domain of the\r
+  calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueInvalidateInstructionCache (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Writes Back and Invalidates the entire data cache in cache coherency domain\r
+  of the calling CPU. This function guarantees that all dirty cache lines are\r
+  written back to system memory, and also invalidates all the data cache lines\r
+  in the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackInvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+  AsmWbinvd ();\r
+}\r
+\r
+/**\r
+  Writes Back and Invalidates a range of data cache lines in the cache\r
+  coherency domain of the calling CPU.\r
+\r
+  Writes Back and Invalidate the data cache lines specified by Address and\r
+  Length. If Address is not aligned on a cache line boundary, then entire data\r
+  cache line containing Address is written back and invalidated. If Address +\r
+  Length is not aligned on a cache line boundary, then the entire data cache\r
+  line containing Address + Length -1 is written back and invalidated. This\r
+  function may choose to write back and invalidate the entire data cache if\r
+  that is more efficient than writing back and invalidating the specified\r
+  range. If Length is 0, the no data cache lines are written back and\r
+  invalidated. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back and\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back and invalidate from the\r
+                  data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackInvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  UINTN                             Start, End;\r
+\r
+  ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
+\r
+  if (Length == 0) {\r
+    return Address;\r
+  }\r
+\r
+  Start = (UINTN)Address;\r
+  End = (Start + Length + (CACHE_LINE_SIZE - 1)) & ~(CACHE_LINE_SIZE - 1);\r
+  Start &= ~(CACHE_LINE_SIZE - 1);\r
+\r
+  do {\r
+    Start = (UINTN)AsmFlushCacheLine ((VOID*)Start) + CACHE_LINE_SIZE;\r
+  } while (Start != End);\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Writes Back the entire data cache in cache coherency domain of the calling\r
+  CPU. This function guarantees that all dirty cache lines are written back to\r
+  system memory. This function may also invalidate all the data cache lines in\r
+  the cache coherency domain of the calling CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+WriteBackDataCache (\r
+  VOID\r
+  )\r
+{\r
+  WriteBackInvalidateDataCache ();\r
+}\r
+\r
+/**\r
+  Writes Back a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Writes Back the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is written back. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is written back. This function may choose to write back the entire\r
+  data cache if that is more efficient than writing back the specified range.\r
+  If Length is 0, the no data cache lines are written back. This function may\r
+  also invalidate all the data cache lines in the specified range of the cache\r
+  coherency domain of the calling CPU. Address is returned.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to write back. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing\r
+                  mode, then Address is a virtual address.\r
+  @param  Length  The number of bytes to write back from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+WriteBackDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return WriteBackInvalidateDataCacheRange (Address, Length);\r
+}\r
+\r
+/**\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU.\r
+\r
+  Invalidates the entire data cache in cache coherency domain of the calling\r
+  CPU. This function must be used with care because dirty cache lines are not\r
+  written back to system memory. It is typically used for cache diagnostics. If\r
+  the CPU does not support invalidation of the entire data cache, then a write\r
+  back and invalidate operation should be performed on the entire data cache.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InvalidateDataCache (\r
+  VOID\r
+  )\r
+{\r
+  AsmInvd ();\r
+}\r
+\r
+/**\r
+  Invalidates a range of data cache lines in the cache coherency domain of the\r
+  calling CPU.\r
+\r
+  Invalidates the data cache lines specified by Address and Length. If Address\r
+  is not aligned on a cache line boundary, then entire data cache line\r
+  containing Address is invalidated. If Address + Length is not aligned on a\r
+  cache line boundary, then the entire data cache line containing Address +\r
+  Length -1 is invalidated. This function must never invalidate any cache lines\r
+  outside the specified range. If Length is 0, the no data cache lines are\r
+  invalidated. Address is returned. This function must be used with care\r
+  because dirty cache lines are not written back to system memory. It is\r
+  typically used for cache diagnostics. If the CPU does not support\r
+  invalidation of a data cache range, then a write back and invalidate\r
+  operation should be performed on the data cache range.\r
+\r
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+  @param  Address The base address of the data cache lines to invalidate. If\r
+                  the CPU is in a physical addressing mode, then Address is a\r
+                  physical address. If the CPU is in a virtual addressing mode,\r
+                  then Address is a virtual address.\r
+  @param  Length  The number of bytes to invalidate from the data cache.\r
+\r
+  @return Address\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InvalidateDataCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return WriteBackInvalidateDataCacheRange (Address, Length);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf
new file mode 100644 (file)
index 0000000..4b33115
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseDebugLibNull.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseDebugLibNull.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseDebugLibNull\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  DebugLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\Include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueBasePrintLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c
new file mode 100644 (file)
index 0000000..6ce2f49
--- /dev/null
@@ -0,0 +1,193 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DebugLib.c\r
+  \r
+Abstract: \r
+\r
+  Base Debug Library that uses PrintLib to print messages to a memory buffer.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+\r
+  Prints a debug message to the debug output device if the specified error level is enabled.\r
+\r
+  If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r
+  the message specified by Format and the associated variable argument list to \r
+  the debug output device.\r
+\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  ErrorLevel  The error level of the debug message.\r
+  @param  Format      Format string for the debug message to print.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugPrint (\r
+  IN  UINTN        ErrorLevel,\r
+  IN  CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+{\r
+}\r
+\r
+\r
+/**\r
+\r
+  Prints an assert message containing a filename, line number, and description.  \r
+  This may be followed by a breakpoint or a dead loop.\r
+\r
+  Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" \r
+  to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of \r
+  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if \r
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then \r
+  CpuDeadLoop() is called.  If neither of these bits are set, then this function \r
+  returns immediately after the message is printed to the debug output device.\r
+  DebugAssert() must actively prevent recusrsion.  If DebugAssert() is called while\r
+  processing another DebugAssert(), then DebugAssert() must return immediately.\r
+\r
+  If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r
+\r
+  If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r
+\r
+  @param  FileName     Pointer to the name of the source file that generated the assert condition.\r
+  @param  LineNumber   The line number in the source file that generated the assert condition\r
+  @param  Description  Pointer to the description of the assert condition.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugAssert (\r
+  IN CONST CHAR8  *FileName,\r
+  IN UINTN        LineNumber,\r
+  IN CONST CHAR8  *Description\r
+  )\r
+{\r
+}\r
+\r
+\r
+/**\r
+\r
+  Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the value specified by \r
+  PcdDebugClearMemoryValue, and returns Buffer.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param   Buffer  Pointer to the target buffer to fill with PcdDebugClearMemoryValue.\r
+  @param   Length  Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r
+\r
+  @return  Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+DebugClearMemory (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  return Buffer;\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if ASSERT() macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugAssertEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugPrintEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CODE()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugClearMemoryEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
new file mode 100644 (file)
index 0000000..1feeb5c
--- /dev/null
@@ -0,0 +1,85 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseIoLibIntrinsic.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseIoLibIntrinsic.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseIoLibIntrinsic\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  \r
+[sources.ia32]\r
+  IoLib.c\r
+  IoLibMsc.c\r
+  IoHighLevel.c\r
+\r
+[sources.x64]\r
+  IoLib.c\r
+  IoLibMsc.c\r
+  IoHighLevel.c\r
+\r
+[sources.ipf]\r
+  IoLibIpf.c\r
+  IoHighLevel.c\r
+\r
+[sources.ebc]\r
+# doesn't support EBC\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c
new file mode 100644 (file)
index 0000000..c843be5
--- /dev/null
@@ -0,0 +1,2280 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoHighLevel.c\r
+  \r
+Abstract: \r
+\r
+  High-level Io/Mmio functions.\r
+\r
+  All assertions for bit field operations are handled bit field functions in the\r
+  Base Library.\r
+\r
+  The following IoLib instances share the same version of this file:\r
+\r
+    BaseIoLibIntrinsic\r
+    DxeIoLibCpuIo\r
+    PeiIoLibCpuIo\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 8-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in an 8-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldRead8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 8-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 16-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 16-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldRead16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 16-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (Port, IoRead32 (Port) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return IoWrite32 (Port, IoRead32 (Port) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 32-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 32-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldRead32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 32-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (Port, IoRead64 (Port) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return IoWrite64 (Port, IoRead64 (Port) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 64-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 64-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldRead64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 8-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in an 8-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 8-bit register is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 8-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 16-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 16-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 16-bit register is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 16-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, MmioRead32 (Address) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, MmioRead32 (Address) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 32-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 32-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 32-bit register is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 32-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, MmioRead64 (Address) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, MmioRead64 (Address) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 64-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 64-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldRead64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 64-bit register is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 64-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c
new file mode 100644 (file)
index 0000000..c24d0bc
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoLib.c\r
+  \r
+Abstract: \r
+\r
+  Common I/O Library routines.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Reads a 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoRead64 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Writes a 64-bit I/O port.\r
+\r
+  Writes the 64-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c
new file mode 100644 (file)
index 0000000..dc999c3
--- /dev/null
@@ -0,0 +1,490 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoLibIpf.c\r
+  \r
+Abstract: \r
+\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+#define  BIT63    0x8000000000000000UL\r
+\r
+#define MAP_PORT_BASE_TO_MEM(_Port) \\r
+    ((((_Port) & 0xfffc) << 10) | ((_Port) & 0x0fff))\r
+\r
+/**\r
+  Reads a 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoRead8 (\r
+  IN  UINT64                 Port\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioRead8 (Address);\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoRead16 (\r
+  IN  UINT64                 Port\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioRead16 (Address);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoRead32 (\r
+  IN  UINT64                 Port\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioRead32 (Address);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoRead64 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Writes a 8-bit I/O port.\r
+\r
+  Writes the 8-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoWrite8 (\r
+  IN  UINT64                 Port,\r
+  IN  UINT8                  Data\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioWrite8 (Address, Data);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit I/O port.\r
+\r
+  Writes the 16-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoWrite16 (\r
+  IN  UINT64                 Port,\r
+  IN  UINT16                 Data\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioWrite16 (Address, Data);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit I/O port.\r
+\r
+  Writes the 32-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoWrite32 (\r
+  IN  UINT64                 Port,\r
+  IN  UINT32                 Data\r
+  )\r
+{\r
+  UINT64           Address;\r
+\r
+  //\r
+  // Add the 64MB aligned IO Port space to the IO address\r
+  //\r
+  Address = MAP_PORT_BASE_TO_MEM (Port);\r
+  Address += PcdGet64(PcdIoBlockBaseAddressForIpf);\r
+\r
+  return MmioWrite32 (Address, Data);\r
+}\r
+\r
+/**\r
+  Writes a 64-bit I/O port.\r
+\r
+  Writes the 64-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Reads a 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioRead8 (\r
+  IN  UINT64                 Address\r
+  )\r
+{\r
+  UINT8            Data;\r
+\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  Data = *((volatile UINT8 *) Address);\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioRead16 (\r
+  IN  UINT64                 Address\r
+  )\r
+{\r
+  UINT16           Data;\r
+\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  Data = *((volatile UINT16 *) Address);\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioRead32 (\r
+  IN  UINT64                 Address\r
+  )\r
+{\r
+  UINT32           Data;\r
+\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  Data = *((volatile UINT32 *) Address);\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioRead64 (\r
+  IN  UINT64                 Address\r
+  )\r
+{\r
+  UINT64           Data;\r
+\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  Data = *((volatile UINT64 *) Address);\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+\r
+}\r
+\r
+/**\r
+  Writes a 8-bit MMIO register.\r
+\r
+  Writes the 8-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Data    The value to write to the MMIO register.\r
+\r
+  @return The value written the memory address.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioWrite8 (\r
+  IN  UINT64                 Address,\r
+  IN  UINT8                  Data\r
+  )\r
+{\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  *((volatile UINT8 *) Address) = Data;\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Writes a 16-bit MMIO register.\r
+\r
+  Writes the 16-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Data    The value to write to the MMIO register.\r
+\r
+  @return The value written the memory address.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioWrite16 (\r
+  IN  UINT64                 Address,\r
+  IN  UINT16                 Data\r
+  )\r
+{\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  *((volatile UINT16 *) Address) = Data;\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Writes a 32-bit MMIO register.\r
+\r
+  Writes the 32-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Data    The value to write to the MMIO register.\r
+\r
+  @return The value written the memory address.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioWrite32 (\r
+  IN  UINT64                 Address,\r
+  IN  UINT32                 Data\r
+  )\r
+{\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  *((volatile UINT32 *) Address) = Data;\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Writes a 64-bit MMIO register.\r
+\r
+  Writes the 64-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Data    The value to write to the MMIO register.\r
+\r
+  @return The value written the memory address.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWrite64 (\r
+  IN  UINT64                 Address,\r
+  IN  UINT64                 Data\r
+  )\r
+{\r
+  Address |= BIT63;\r
+\r
+  MemoryFence ();\r
+  *((volatile UINT64 *) Address) = Data;\r
+  MemoryFence ();\r
+\r
+  return Data;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c
new file mode 100644 (file)
index 0000000..7b78e27
--- /dev/null
@@ -0,0 +1,436 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoLibMsc.c\r
+  \r
+Abstract: \r
+\r
+  I/O Library. This file has compiler specifics for Microsft C as there is no\r
+  ANSI C standard for doing IO.\r
+\r
+  MSC - uses intrinsic functions and the optimize will remove the function call\r
+  overhead.\r
+\r
+  We don't advocate putting compiler specifics in libraries or drivers but there\r
+  is no other way to make this work.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+#if _MSC_EXTENSIONS\r
+\r
+//\r
+// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics\r
+//\r
+int            _inp (unsigned short port);\r
+unsigned short _inpw (unsigned short port);\r
+unsigned long  _inpd (unsigned short port);\r
+int            _outp (unsigned short port, int databyte );\r
+unsigned short _outpw (unsigned short port, unsigned short dataword );\r
+unsigned long  _outpd (unsigned short port, unsigned long dataword );\r
+void          _ReadWriteBarrier (void);\r
+\r
+#pragma intrinsic(_inp)\r
+#pragma intrinsic(_inpw)\r
+#pragma intrinsic(_inpd)\r
+#pragma intrinsic(_outp)\r
+#pragma intrinsic(_outpw)\r
+#pragma intrinsic(_outpd)\r
+#pragma intrinsic(_ReadWriteBarrier)\r
+\r
+//\r
+// _ReadWriteBarrier() forces memory reads and writes to complete at the point\r
+// in the call. This is only a hint to the compiler and does emit code.\r
+// In past versions of the compiler, _ReadWriteBarrier was enforced only\r
+// locally and did not affect functions up the call tree. In Visual C++\r
+// 2005, _ReadWriteBarrier is enforced all the way up the call tree.\r
+//\r
+\r
+/**\r
+  Reads an 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+GlueIoRead8 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  UINT8                             Value;\r
+\r
+  _ReadWriteBarrier ();\r
+  Value = (UINT8)_inp ((UINT16)Port);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes an 8-bit I/O port.\r
+\r
+  Writes the 8-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+GlueIoWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  _ReadWriteBarrier ();\r
+  (UINT8)_outp ((UINT16)Port, Value);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+GlueIoRead16 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  UINT16                            Value;\r
+\r
+  ASSERT ((Port & 1) == 0);\r
+  _ReadWriteBarrier ();\r
+  Value = _inpw ((UINT16)Port);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 16-bit I/O port.\r
+\r
+  Writes the 16-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+GlueIoWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT ((Port & 1) == 0);\r
+  _ReadWriteBarrier ();\r
+  _outpw ((UINT16)Port, Value);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GlueIoRead32 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  UINT32                            Value;\r
+\r
+  ASSERT ((Port & 3) == 0);\r
+  _ReadWriteBarrier ();\r
+  Value = _inpd ((UINT16)Port);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 32-bit I/O port.\r
+\r
+  Writes the 32-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GlueIoWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT ((Port & 3) == 0);\r
+  _ReadWriteBarrier ();\r
+  _outpd ((UINT16)Port, Value);\r
+  _ReadWriteBarrier ();\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Reads an 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT8                             Value;\r
+\r
+  Value = *(volatile UINT8*)Address;\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes an 8-bit MMIO register.\r
+\r
+  Writes the 8-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return *(volatile UINT8*)Address = Value;\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT16                            Value;\r
+\r
+  ASSERT ((Address & 1) == 0);\r
+  Value = *(volatile UINT16*)Address;\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 16-bit MMIO register.\r
+\r
+  Writes the 16-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 1) == 0);\r
+  return *(volatile UINT16*)Address = Value;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT32                            Value;\r
+\r
+  ASSERT ((Address & 3) == 0);\r
+  Value = *(volatile UINT32*)Address;\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 32-bit MMIO register.\r
+\r
+  Writes the 32-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 3) == 0);\r
+  return *(volatile UINT32*)Address = Value;\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioRead64 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT64                            Value;\r
+\r
+  ASSERT ((Address & 7) == 0);\r
+  Value = *(volatile UINT64*)Address;\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 64-bit MMIO register.\r
+\r
+  Writes the 64-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 7) == 0);\r
+  return *(volatile UINT64*)Address = Value;\r
+}\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c
new file mode 100644 (file)
index 0000000..2dbf61d
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  ARShiftU64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r
+  with original integer's bit 63. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to bit 63 of Operand.  The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand arithmetically shifted right by Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+ARShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return InternalMathARShiftU64 (Operand, Count);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf
new file mode 100644 (file)
index 0000000..40b2824
--- /dev/null
@@ -0,0 +1,361 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  String.c\r
+  LinkedList.c\r
+  Synchronization.c\r
+  Cpu.c\r
+  CpuDeadLoop.c\r
+  BitField.c\r
+  ARShiftU64.c\r
+  DivS64x64Remainder.c\r
+  DivU64x32.c\r
+  DivU64x32Remainder.c\r
+  DivU64x64Remainder.c\r
+  GetPowerOfTwo32.c\r
+  GetPowerOfTwo64.c\r
+  HighBitSet32.c\r
+  HighBitSet64.c\r
+  LowBitSet32.c\r
+  LowBitSet64.c\r
+  LRotU32.c\r
+  LRotU64.c\r
+  LShiftU64.c\r
+  ModU64x32.c\r
+  MultS64x64.c\r
+  MultU64x32.c\r
+  MultU64x64.c\r
+  RRotU32.c\r
+  RRotU64.c\r
+  RShiftU64.c\r
+  SetJump.c\r
+  LongJump.c\r
+  SwapBytes16.c\r
+  SwapBytes32.c\r
+  SwapBytes64.c\r
+  SwitchStack.c\r
+\r
+[sources.ia32]\r
+  x86DisablePaging32.c\r
+  x86DisablePaging64.c\r
+  x86EnablePaging32.c\r
+  x86EnablePaging64.c\r
+  x86FxRestore.c\r
+  x86FxSave.c\r
+  x86GetInterruptState.c\r
+  x86MemoryFence.c\r
+  x86Msr.c\r
+  x86ReadGdtr.c\r
+  x86ReadIdtr.c\r
+  x86Thunk.c\r
+  x86WriteGdtr.c\r
+  x86WriteIdtr.c\r
+  Unaligned.c\r
+  Ia32\Non-existing.c\r
+  Ia32\InternalSwitchStack.c\r
+  Ia32\DivS64x64Remainder.c\r
+  Ia32\ARShiftU64.asm\r
+  Ia32\CpuBreakpoint.asm\r
+  Ia32\CpuFlushTlb.asm\r
+  Ia32\CpuSleep.asm\r
+  Ia32\CpuId.asm\r
+  Ia32\CpuIdEx.asm\r
+  Ia32\CpuPause.asm\r
+  Ia32\DisableInterrupts.asm\r
+  Ia32\DisablePaging32.asm\r
+  Ia32\DivU64x32.asm\r
+  Ia32\DivU64x32Remainder.asm\r
+  Ia32\DivU64x64Remainder.asm\r
+  Ia32\EnableDisableInterrupts.asm\r
+  Ia32\EnableInterrupts.asm\r
+  Ia32\EnablePaging32.asm\r
+  Ia32\EnablePaging64.asm\r
+  Ia32\FlushCacheLine.asm\r
+  Ia32\FxSave.asm\r
+  Ia32\FxRestore.asm\r
+  Ia32\InterlockedIncrement.asm\r
+  Ia32\InterlockedDecrement.asm\r
+  Ia32\InterlockedCompareExchange32.asm\r
+  Ia32\InterlockedCompareExchange64.asm\r
+  Ia32\Invd.asm\r
+  Ia32\LongJump.asm\r
+  Ia32\LRotU64.asm\r
+  Ia32\LShiftU64.asm\r
+  Ia32\MultU64x32.asm\r
+  Ia32\MultU64x64.asm\r
+  Ia32\ModU64x32.asm\r
+  Ia32\Monitor.asm\r
+  Ia32\Mwait.asm\r
+  Ia32\ReadCr0.asm\r
+  Ia32\ReadCr2.asm\r
+  Ia32\ReadCr3.asm\r
+  Ia32\ReadCr4.asm\r
+  Ia32\ReadDr0.asm\r
+  Ia32\ReadDr1.asm\r
+  Ia32\ReadDr2.asm\r
+  Ia32\ReadDr3.asm\r
+  Ia32\ReadDr4.asm\r
+  Ia32\ReadDr5.asm\r
+  Ia32\ReadDr6.asm\r
+  Ia32\ReadDr7.asm\r
+  Ia32\ReadEflags.asm\r
+  Ia32\ReadMm0.asm\r
+  Ia32\ReadMm1.asm\r
+  Ia32\ReadMm2.asm\r
+  Ia32\ReadMm3.asm\r
+  Ia32\ReadMm4.asm\r
+  Ia32\ReadMm5.asm\r
+  Ia32\ReadMm6.asm\r
+  Ia32\ReadMm7.asm\r
+  Ia32\ReadMsr64.asm\r
+  Ia32\ReadCs.asm\r
+  Ia32\ReadDs.asm\r
+  Ia32\ReadEs.asm\r
+  Ia32\ReadFs.asm\r
+  Ia32\ReadGs.asm\r
+  Ia32\ReadSs.asm\r
+  Ia32\ReadTr.asm\r
+  Ia32\ReadGdtr.asm\r
+  Ia32\ReadIdtr.asm\r
+  Ia32\ReadLdtr.asm\r
+  Ia32\ReadTsc.asm\r
+  Ia32\ReadPmc.asm\r
+  Ia32\RShiftU64.asm\r
+  Ia32\RRotU64.asm\r
+  Ia32\SetJump.asm\r
+  Ia32\SwapBytes64.asm\r
+  Ia32\Thunk16.asm\r
+  Ia32\WriteMsr64.asm\r
+  Ia32\WriteCr0.asm\r
+  Ia32\WriteCr2.asm\r
+  Ia32\WriteCr3.asm\r
+  Ia32\WriteCr4.asm\r
+  Ia32\WriteDr0.asm\r
+  Ia32\WriteDr1.asm\r
+  Ia32\WriteDr2.asm\r
+  Ia32\WriteDr3.asm\r
+  Ia32\WriteDr4.asm\r
+  Ia32\WriteDr5.asm\r
+  Ia32\WriteDr6.asm\r
+  Ia32\WriteDr7.asm\r
+  Ia32\WriteGdtr.asm\r
+  Ia32\WriteIdtr.asm\r
+  Ia32\WriteLdtr.asm\r
+  Ia32\WriteMm0.asm\r
+  Ia32\WriteMm1.asm\r
+  Ia32\WriteMm2.asm\r
+  Ia32\WriteMm3.asm\r
+  Ia32\WriteMm4.asm\r
+  Ia32\WriteMm5.asm\r
+  Ia32\WriteMm6.asm\r
+  Ia32\WriteMm7.asm\r
+  Ia32\Wbinvd.asm\r
+  \r
+[sources.x64]\r
+  x86DisablePaging32.c\r
+  x86DisablePaging64.c\r
+  x86EnablePaging32.c\r
+  x86EnablePaging64.c\r
+  x86FxRestore.c\r
+  x86FxSave.c\r
+  x86GetInterruptState.c\r
+  x86MemoryFence.c\r
+  x86Msr.c\r
+  x86ReadGdtr.c\r
+  x86ReadIdtr.c\r
+  x86Thunk.c\r
+  x86WriteGdtr.c\r
+  x86WriteIdtr.c\r
+  Unaligned.c\r
+  Math64.c\r
+  X64\Non-existing.c\r
+  X64\SwitchStack.asm\r
+  X64\SetJump.asm\r
+  X64\LongJump.asm\r
+  X64\CpuId.asm\r
+  X64\CpuIdEx.asm\r
+  X64\ReadEflags.asm\r
+  X64\ReadMsr64.asm\r
+  X64\WriteMsr64.asm\r
+  X64\ReadCr0.asm\r
+  X64\ReadCr2.asm\r
+  X64\ReadCr3.asm\r
+  X64\ReadCr4.asm\r
+  X64\WriteCr0.asm\r
+  X64\WriteCr2.asm\r
+  X64\WriteCr3.asm\r
+  X64\WriteCr4.asm\r
+  X64\ReadDr0.asm\r
+  X64\ReadDr1.asm\r
+  X64\ReadDr2.asm\r
+  X64\ReadDr3.asm\r
+  X64\ReadDr4.asm\r
+  X64\ReadDr5.asm\r
+  X64\ReadDr6.asm\r
+  X64\ReadDr7.asm\r
+  X64\WriteDr0.asm\r
+  X64\WriteDr1.asm\r
+  X64\WriteDr2.asm\r
+  X64\WriteDr3.asm\r
+  X64\WriteDr4.asm\r
+  X64\WriteDr5.asm\r
+  X64\WriteDr6.asm\r
+  X64\WriteDr7.asm\r
+  X64\ReadCs.asm\r
+  X64\ReadDs.asm\r
+  X64\ReadEs.asm\r
+  X64\ReadFs.asm\r
+  X64\ReadGs.asm\r
+  X64\ReadSs.asm\r
+  X64\ReadTr.asm\r
+  X64\ReadGdtr.asm\r
+  X64\WriteGdtr.asm\r
+  X64\ReadIdtr.asm\r
+  X64\WriteIdtr.asm\r
+  X64\ReadLdtr.asm\r
+  X64\WriteLdtr.asm\r
+  X64\FxSave.asm\r
+  X64\FxRestore.asm\r
+  X64\ReadMm0.asm\r
+  X64\ReadMm1.asm\r
+  X64\ReadMm2.asm\r
+  X64\ReadMm3.asm\r
+  X64\ReadMm4.asm\r
+  X64\ReadMm5.asm\r
+  X64\ReadMm6.asm\r
+  X64\ReadMm7.asm\r
+  X64\WriteMm0.asm\r
+  X64\WriteMm1.asm\r
+  X64\WriteMm2.asm\r
+  X64\WriteMm3.asm\r
+  X64\WriteMm4.asm\r
+  X64\WriteMm5.asm\r
+  X64\WriteMm6.asm\r
+  X64\WriteMm7.asm\r
+  X64\ReadTsc.asm\r
+  X64\ReadPmc.asm\r
+  X64\Monitor.asm\r
+  X64\Mwait.asm\r
+  X64\EnablePaging64.asm\r
+  X64\DisablePaging64.asm\r
+  X64\Wbinvd.asm\r
+  X64\Invd.asm\r
+  X64\FlushCacheLine.asm\r
+  X64\InterlockedIncrement.asm\r
+  X64\InterlockedDecrement.asm\r
+  X64\InterlockedCompareExchange32.asm\r
+  X64\InterlockedCompareExchange64.asm\r
+  X64\EnableInterrupts.asm\r
+  X64\DisableInterrupts.asm\r
+  X64\EnableDisableInterrupts.asm\r
+  X64\CpuSleep.asm\r
+  X64\CpuPause.asm\r
+  X64\CpuBreakpoint.asm\r
+  X64\CpuFlushTlb.asm\r
+  X64\Thunk16.asm\r
+\r
+[sources.ipf]\r
+  Math64.c\r
+  Ipf\asm.h\r
+  Ipf\ia_64gen.h\r
+  Ipf\PalCallStatic.s\r
+  Ipf\setjmp.s\r
+  Ipf\longjmp.s\r
+  Ipf\SwitchStack.s\r
+  Ipf\Unaligned.c\r
+  Ipf\CpuBreakpoint.c\r
+  Ipf\InterlockedCompareExchange32.s\r
+  Ipf\InterlockedCompareExchange64.s\r
+  Ipf\Synchronization.c\r
+  Ipf\CpuPause.s\r
+  Ipf\CpuFlushTlb.s\r
+  Ipf\GetInterruptState.s\r
+  Ipf\Non-existing.c\r
+  Ipf\FlushCacheRange.s\r
+  Ipf\ReadItc.s\r
+    \r
+[sources.ebc]\r
+  Math64.c\r
+  Unaligned.c\r
+  Ebc\SwitchStack.c\r
+  Ebc\SetJumpLongJump.c\r
+  Ebc\CpuBreakpoint.c\r
+  Ebc\Synchronization.c\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\Include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[includes.IA32]\r
+  ..\..\Include\Ia32\r
+\r
+[includes.X64]\r
+  ..\..\Include\x64\r
+\r
+\r
+[libraries.common]\r
+#\r
+# Actually, BaesLib may refer\r
+#      BaseTimerLibLocalApic::GetPerformanceCounter()in AcquireSpinLock()\r
+#      BaseMemoryLib::ZeroMem() in StrnCpy()\r
+#\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
+  
\ 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 (file)
index 0000000..1ed7085
--- /dev/null
@@ -0,0 +1,813 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  BaseLibInternal.h\r
+    \r
+Abstract: \r
+\r
+  Declaration of internal functions in BaseLib.\r
+\r
+--*/\r
+\r
+#ifndef __BASE_LIB_INTERNAL_H__\r
+#define __BASE_LIB_INTERNAL_H__\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+#define QUIENT_MAX_UINTN_DIVIDED_BY_10      ((UINTN) -1 / 10)\r
+#define REMINDER_MAX_UINTN_DIVIDED_BY_10    ((UINTN) -1 % 10)\r
+\r
+#define QUIENT_MAX_UINTN_DIVIDED_BY_16      ((UINTN) -1 / 16)\r
+#define REMINDER_MAX_UINTN_DIVIDED_BY_16    ((UINTN) -1 % 16)\r
+\r
+#define QUIENT_MAX_UINT64_DIVIDED_BY_10      ((UINT64) -1 / 10)\r
+#define REMINDER_MAX_UINT64_DIVIDED_BY_10    ((UINT64) -1 % 10)\r
+\r
+#define QUIENT_MAX_UINT64_DIVIDED_BY_16      ((UINT64) -1 / 16)\r
+#define REMINDER_MAX_UINT64_DIVIDED_BY_16    ((UINT64) -1 % 16)\r
+\r
+//\r
+// Math functions\r
+//\r
+\r
+/**\r
+  Shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift left.\r
+  @param  Count   The number of bits to shift left.\r
+\r
+  @return Operand << Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathLShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathRShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
+  are filled with original integer's bit 63. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to bit 63 of Operand.  The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand arithmetically shifted right by Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathARShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 64-bit integer left between 0 and 63 bits, filling\r
+  the low bits with the high bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathLRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Rotates a 64-bit integer right between 0 and 63 bits, filling\r
+  the high bits with the high low bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathRRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  );\r
+\r
+/**\r
+  Switches the endianess of a 64-bit integer.\r
+\r
+  This function swaps the bytes in a 64-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 64-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathSwapBytes64 (\r
+  IN      UINT64                    Operand\r
+  );\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 32-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathMultU64x32 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT32                    Multiplier\r
+  );\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 64-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathMultU64x64 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT64                    Multiplier\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
+  function returns the 64-bit unsigned quotient.\r
+\r
+   @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 32-bit remainder. This function\r
+  returns the 32-bit unsigned remainder.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend % Divisor\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalMathModU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivRemU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor,\r
+  OUT     UINT32                    *Remainder\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 64-bit unsigned integer and\r
+  generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 64-bit unsigned value.\r
+  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivRemU64x64 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT64                    Divisor,\r
+  OUT     UINT64                    *Remainder\r
+  );\r
+\r
+/**\r
+  Divides a 64-bit signed integer by a 64-bit signed integer and\r
+  generates a  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+INT64\r
+InternalMathDivRemS64x64 (\r
+  IN      INT64                     Dividend,\r
+  IN      INT64                     Divisor,\r
+  OUT     INT64                     *Remainder  OPTIONAL\r
+ );\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,\r
+  IN      VOID                      *Context2,\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+//\r
+// Ia32 and x64 specific functions\r
+//\r
+\r
+/**\r
+  Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86ReadGdtr (\r
+  OUT     IA32_DESCRIPTOR           *Gdtr\r
+  );\r
+\r
+/**\r
+  Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
+\r
+  Writes and the current GDTR descriptor specified by Gdtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86WriteGdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Gdtr\r
+  );\r
+\r
+/**\r
+  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86ReadIdtr (\r
+  OUT     IA32_DESCRIPTOR           *Idtr\r
+  );\r
+\r
+/**\r
+  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Writes the current IDTR descriptor and returns it in Idtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86WriteIdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Idtr\r
+  );\r
+\r
+/**\r
+  Save the current floating point/SSE/SSE2 context to a buffer.\r
+\r
+  Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
+  Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86FxSave (\r
+  OUT     IA32_FX_BUFFER            *Buffer\r
+  );\r
+\r
+/**\r
+  Restores the current floating point/SSE/SSE2 context from a buffer.\r
+\r
+  Restores the current floating point/SSE/SSE2 state from the buffer specified\r
+  by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86FxRestore (\r
+  IN      CONST IA32_FX_BUFFER      *Buffer\r
+  );\r
+\r
+/**\r
+  Enables the 32-bit paging mode on the CPU.\r
+\r
+  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode. This function is\r
+  only available on IA-32. After the 32-bit paging mode is enabled, control is\r
+  transferred to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit protected mode with flat descriptors. This\r
+      means all descriptors must have a base of 0 and a limit of 4GB.\r
+  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
+      descriptors.\r
+  4)  CR3 must point to valid page tables that will be used once the transition\r
+      is complete, and those page tables must guarantee that the pages for this\r
+      function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is enabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is enabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is enabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86EnablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+/**\r
+  Disables the 32-bit paging mode on the CPU.\r
+\r
+  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 32-paged protected\r
+  mode. This function is only available on IA-32. After the 32-bit paging mode\r
+  is disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be NULL. The function EntryPoint must never return.\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit paged mode.\r
+  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
+  4)  CR3 must point to valid page tables that guarantee that the pages for\r
+      this function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is disabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is disabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is\r
+                      disabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86DisablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+/**\r
+  Enables the 64-bit paging mode on the CPU.\r
+\r
+  Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode with flat\r
+  descriptors. This function is only available on IA-32. After the 64-bit\r
+  paging mode is enabled, control is transferred to the function specified by\r
+  EntryPoint using the new stack specified by NewStack and passing in the\r
+  parameters specified by Context1 and Context2. Context1 and Context2 are\r
+  optional and may be 0. The function EntryPoint must never return.\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for long mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is enabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is enabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is enabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86EnablePaging64 (\r
+  IN      UINT16                    Cs,\r
+  IN      UINT64                    EntryPoint,\r
+  IN      UINT64                    Context1,  OPTIONAL\r
+  IN      UINT64                    Context2,  OPTIONAL\r
+  IN      UINT64                    NewStack\r
+  );\r
+\r
+/**\r
+  Disables the 64-bit paging mode on the CPU.\r
+\r
+  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 64-paging mode.\r
+  This function is only available on X64. After the 64-bit paging mode is\r
+  disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be 0. The function EntryPoint must never return.\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for 32-bit protected mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is disabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is disabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is disabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86DisablePaging64 (\r
+  IN      UINT16                    Cs,\r
+  IN      UINT32                    EntryPoint,\r
+  IN      UINT32                    Context1,  OPTIONAL\r
+  IN      UINT32                    Context2,  OPTIONAL\r
+  IN      UINT32                    NewStack\r
+  );\r
+\r
+/**\r
+  Worker function that locates the Node in the List\r
+\r
+  By searching the List, finds the location of the Node in List. At the same time,\r
+  verifies the validity of this list.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If List->ForwardLink is NULL, then ASSERT().\r
+  If List->backLink is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT();\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  List  A pointer to a node in a linked list.\r
+  @param  Node  A pointer to one nod.\r
+\r
+  @retval TRUE   Node is in List\r
+  @retval FALSE  Node isn't in List, or List is invalid\r
+\r
+**/\r
+BOOLEAN\r
+IsNodeInList (\r
+  IN      CONST LIST_ENTRY      *List,\r
+  IN      CONST LIST_ENTRY      *Node\r
+  );\r
+\r
+/**\r
+  Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic increment of the 32-bit unsigned integer specified by\r
+  Value and returns the incremented value. The increment operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to increment.\r
+\r
+  @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncIncrement (\r
+  IN      volatile UINT32           *Value\r
+  );\r
+\r
+/**\r
+  Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+  Value and returns the decrement value. The decrement operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to decrement.\r
+\r
+  @return The decrement value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncDecrement (\r
+  IN      volatile UINT32           *Value\r
+  );\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
+  specified by Value.  If Value is equal to CompareValue, then Value is set to \r
+  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,\r
+  then Value is returned.  The compare exchange operation must be performed using \r
+  MP safe mechanisms.\r
+\r
+  @param  Value         A pointer to the 32-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  32-bit value used in compare operation.\r
+  @param  ExchangeValue 32-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncCompareExchange32 (\r
+  IN      volatile UINT32           *Value,\r
+  IN      UINT32                    CompareValue,\r
+  IN      UINT32                    ExchangeValue\r
+  );\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned. \r
+  The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+  @param  Value         A pointer to the 64-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  64-bit value used in compare operation.\r
+  @param  ExchangeValue 64-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalSyncCompareExchange64 (\r
+  IN      volatile UINT64           *Value,\r
+  IN      UINT64                    CompareValue,\r
+  IN      UINT64                    ExchangeValue\r
+  );\r
+\r
+/**\r
+  Worker function that returns a bit field from Operand\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+unsigned int\r
+BitFieldReadUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  );\r
+\r
+/**\r
+  Worker function that reads a bit field from Operand, performs a bitwise OR, \r
+  and returns the result.\r
+\r
+  Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new value is returned.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldOrUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      unsigned int              OrData\r
+  );\r
+\r
+/**\r
+  Worker function that reads a bit field from Operand, performs a bitwise AND, \r
+  and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new value is returned.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+  @param  AndData    The value to And with the read value from the value\r
+\r
+  @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldAndUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      unsigned int              AndData\r
+  );\r
+\r
+/**\r
+  Worker function that checks ASSERT condition for JumpBuffer\r
+\r
+  Checks ASSERT condition for JumpBuffer.\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+\r
+**/\r
+VOID\r
+InternalAssertJumpBuffer (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+  );\r
+\r
+/**\r
+  Restores the CPU context that was saved with SetJump().\r
+\r
+  Restores the CPU context from the buffer specified by JumpBuffer.\r
+  This function never returns to the caller.\r
+  Instead is resumes execution based on the state of JumpBuffer.\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+  @param  Value         The value to return when the SetJump() context is restored.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalLongJump (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+  IN      UINTN                     Value\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c
new file mode 100644 (file)
index 0000000..6b332e5
--- /dev/null
@@ -0,0 +1,873 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  BitField.c\r
+  \r
+Abstract: \r
+\r
+  Bit field functions of BaseLib.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Worker function that returns a bit field from Operand\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+unsigned int\r
+BitFieldReadUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  //\r
+  // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]\r
+  // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.\r
+  //\r
+  return (Operand & ~((unsigned int)-2 << EndBit)) >> StartBit;\r
+}\r
+\r
+/**\r
+  Worker function that reads a bit field from Operand, performs a bitwise OR, \r
+  and returns the result.\r
+\r
+  Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new value is returned.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldOrUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      unsigned int              OrData\r
+  )\r
+{\r
+  //\r
+  // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]\r
+  // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.\r
+  //\r
+  return Operand | ((OrData << StartBit) & ~((unsigned int) -2 << EndBit));\r
+}\r
+\r
+/**\r
+  Worker function that reads a bit field from Operand, performs a bitwise AND, \r
+  and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new value is returned.\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+  @param  AndData    The value to And with the read value from the value\r
+\r
+  @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldAndUint (\r
+  IN      unsigned int              Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      unsigned int              AndData\r
+  )\r
+{\r
+  //\r
+  // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]\r
+  // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.\r
+  //\r
+  return Operand & ~((~AndData << StartBit) & ~((unsigned int) -2 << EndBit));\r
+}\r
+\r
+/**\r
+  Returns a bit field from an 8-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldRead8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT8)BitFieldReadUint (Operand, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an 8-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 8-bit value is\r
+  returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldWrite8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldOr8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT8)BitFieldOrUint (Operand, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldAnd8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT8)BitFieldAndUint (Operand, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 8-bit value is returned.\r
+\r
+  If 8-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 8-bit value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BitFieldAndThenOr8 (\r
+  IN      UINT8                     Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldOr8 (\r
+           BitFieldAnd8 (Operand, StartBit, EndBit, AndData),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Returns a bit field from a 16-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldRead16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT16)BitFieldReadUint (Operand, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a 16-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 16-bit value is\r
+  returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldWrite16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldOr16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT16)BitFieldOrUint (Operand, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldAnd16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT16)BitFieldAndUint (Operand, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 16-bit value is returned.\r
+\r
+  If 16-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 16-bit value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+BitFieldAndThenOr16 (\r
+  IN      UINT16                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldOr16 (\r
+           BitFieldAnd16 (Operand, StartBit, EndBit, AndData),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Returns a bit field from a 32-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldRead32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)BitFieldReadUint (Operand, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a 32-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 32-bit value is\r
+  returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldWrite32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldOr32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)BitFieldOrUint (Operand, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldAnd32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)BitFieldAndUint (Operand, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 32-bit value is returned.\r
+\r
+  If 32-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 32-bit value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+BitFieldAndThenOr32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldOr32 (\r
+           BitFieldAnd32 (Operand, StartBit, EndBit, AndData),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Returns a bit field from a 64-bit value.\r
+\r
+  Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The bit field read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldRead64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a 64-bit value, and returns the result.\r
+\r
+  Writes Value to the bit field specified by the StartBit and the EndBit in\r
+  Operand. All other bits in Operand are preserved. The new 64-bit value is\r
+  returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldWrite64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r
+  result.\r
+\r
+  Performs a bitwise inclusive OR between the bit field specified by StartBit\r
+  and EndBit in Operand and the value specified by OrData. All other bits in\r
+  Operand are preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the value\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldOr64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  UINT64  Value1;\r
+  UINT64  Value2;\r
+\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+\r
+  Value1 = LShiftU64 (OrData, StartBit);\r
+  Value2 = LShiftU64 ((UINT64) - 2, EndBit);\r
+\r
+  return Operand | (Value1 & ~Value2);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r
+  the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData. All other bits in Operand are\r
+  preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the value\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldAnd64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  UINT64  Value1;\r
+  UINT64  Value2;\r
+  \r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+\r
+  Value1 = LShiftU64 (~AndData, StartBit);\r
+  Value2 = LShiftU64 ((UINT64)-2, EndBit);\r
+\r
+  return Operand & ~(Value1 & ~Value2);\r
+}\r
+\r
+/**\r
+  Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r
+  bitwise OR, and returns the result.\r
+\r
+  Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+  in Operand and the value specified by AndData, followed by a bitwise\r
+  inclusive OR with value specified by OrData. All other bits in Operand are\r
+  preserved. The new 64-bit value is returned.\r
+\r
+  If 64-bit operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Operand   Operand on which to perform the bitfield operation.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the value.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The new 64-bit value.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+BitFieldAndThenOr64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Operand) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return BitFieldOr64 (\r
+           BitFieldAnd64 (Operand, StartBit, EndBit, AndData),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c
new file mode 100644 (file)
index 0000000..adabe61
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Cpu.c\r
+  \r
+Abstract: \r
+\r
+  Base Library CPU Functions for all architectures.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Disables CPU interrupts and returns the interrupt state prior to the disable\r
+  operation.\r
+\r
+  Disables CPU interrupts and returns the interrupt state prior to the disable\r
+  operation.\r
+\r
+  @retval TRUE  CPU interrupts were enabled on entry to this call.\r
+  @retval FALSE CPU interrupts were disabled on entry to this call.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SaveAndDisableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  BOOLEAN                           InterruptState;\r
+\r
+  InterruptState = GetInterruptState ();\r
+  DisableInterrupts ();\r
+  return InterruptState;\r
+}\r
+\r
+/**\r
+  Set the current CPU interrupt state.\r
+\r
+  Sets the current CPU interrupt state to the state specified by\r
+  InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r
+  InterruptState is FALSE, then interrupts are disabled. InterruptState is\r
+  returned.\r
+\r
+  @param  InterruptState  TRUE if interrupts should enabled. FALSE if\r
+                          interrupts should be disabled.\r
+\r
+  @return InterruptState\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SetInterruptState (\r
+  IN      BOOLEAN                   InterruptState\r
+  )\r
+{\r
+  if (InterruptState) {\r
+    EnableInterrupts ();\r
+  } else {\r
+    DisableInterrupts ();\r
+  }\r
+  return InterruptState;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c
new file mode 100644 (file)
index 0000000..6eef035
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  CpuDeadLoop.c\r
+  \r
+Abstract: \r
+\r
+  Base Library CPU Functions for all architectures.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Executes an infinite loop.\r
+\r
+  Forces the CPU to execute an infinite loop. A debugger may be used to skip\r
+  past the loop and the code that follows the loop must execute properly. This\r
+  implies that the infinite loop must not cause the code that follow it to be\r
+  optimized away.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuDeadLoop (\r
+  VOID\r
+  )\r
+{\r
+  volatile UINTN  Index;\r
+\r
+  for (Index = 0; Index == 0;);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c
new file mode 100644 (file)
index 0000000..58d99de
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DivS64x64Remainder.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r
+  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit signed value Dividend by the 64-bit signed\r
+  value Divisor and generates a 64-bit signed quotient. If Remainder is not\r
+  NULL, then the 64-bit signed remainder is returned in Remainder. This\r
+  function returns the 64-bit signed quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+INT64\r
+EFIAPI\r
+DivS64x64Remainder (\r
+  IN      INT64                     Dividend,\r
+  IN      INT64                     Divisor,\r
+  OUT     INT64                     *Remainder  OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Divisor != 0);\r
+  return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c
new file mode 100644 (file)
index 0000000..d45c4d4
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DivU64x32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 64-bit unsigned result.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
+  function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueDivU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  )\r
+{\r
+  ASSERT (Divisor != 0);\r
+  return InternalMathDivU64x32 (Dividend, Divisor);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c
new file mode 100644 (file)
index 0000000..fe065cd
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DivU64x32Remainder.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+DivU64x32Remainder (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor,\r
+  OUT     UINT32                    *Remainder  OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Divisor != 0);\r
+  return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c
new file mode 100644 (file)
index 0000000..6ea2f0a
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  DivU64x64Remainder.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r
+  a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 64-bit unsigned value.\r
+  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+DivU64x64Remainder (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT64                    Divisor,\r
+  OUT     UINT64                    *Remainder  OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Divisor != 0);\r
+  return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder);\r
+}\r
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 (file)
index 0000000..438df67
--- /dev/null
@@ -0,0 +1,173 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  CpuBreakpoint.c\r
+  \r
+Abstract: \r
+\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+extern\r
+UINT64\r
+_break (\r
+  CHAR8 BreakCode\r
+  );\r
+\r
+/**\r
+  Generates a breakpoint on the CPU.\r
+\r
+  Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
+  that code can resume normal execution after the breakpoint.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuBreakpoint (\r
+  VOID\r
+  )\r
+{\r
+  _break (3);\r
+}\r
+\r
+/**\r
+  Used to serialize load and store operations.\r
+\r
+  All loads and stores that proceed calls to this function are guaranteed to be\r
+  globally visible when this function returns.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MemoryFence (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Disables CPU interrupts.\r
+\r
+  Disables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Enables CPU interrupts.\r
+\r
+  Enables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieves the current CPU interrupt state.\r
+\r
+  Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r
+  currently enabled. Otherwise returns FALSE.\r
+\r
+  @retval TRUE  CPU interrupts are enabled.\r
+  @retval FALSE CPU interrupts are disabled.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueGetInterruptState (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableDisableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  EnableInterrupts ();\r
+  DisableInterrupts ();\r
+}\r
+\r
+/**\r
+  Requests CPU to pause for a short period of time.\r
+\r
+  Requests CPU to pause for a short period of time. Typically used in MP\r
+  systems to prevent memory starvation while waiting for a spin lock.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuPause (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+  Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFlushTlb (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Places the CPU in a sleep state until an interrupt is received.\r
+\r
+  Places the CPU in a sleep state until an interrupt is received. If interrupts\r
+  are disabled prior to calling this function, then the CPU will be placed in a\r
+  sleep state indefinitely.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuSleep (\r
+  VOID\r
+  )\r
+{\r
+}\r
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 (file)
index 0000000..c42fa5c
--- /dev/null
@@ -0,0 +1,85 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SetJumpLongJump.c\r
+  \r
+Abstract: \r
+\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Worker function that checks ASSERT condition for JumpBuffer\r
+\r
+  Checks ASSERT condition for JumpBuffer.\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+\r
+**/\r
+VOID\r
+InternalAssertJumpBuffer (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+  );\r
+\r
+/**\r
+  Saves the current CPU context that can be restored with a call to LongJump() and returns 0.\r
+\r
+  Saves the current CPU context in the buffer specified by JumpBuffer and returns 0.  The initial \r
+  call to SetJump() must always return 0.  Subsequent calls to LongJump() cause a non-zero \r
+  value to be returned by SetJump(). \r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
\r
+**/\r
+UINTN\r
+EFIAPI\r
+SetJump (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+  )\r
+{\r
+  InternalAssertJumpBuffer (JumpBuffer);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Restores the CPU context that was saved with SetJump().\r
+\r
+  Restores the CPU context from the buffer specified by JumpBuffer.\r
+  This function never returns to the caller.\r
+  Instead is resumes execution based on the state of JumpBuffer.\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+  @param  Value         The value to return when the SetJump() context is restored.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalLongJump (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+  IN      UINTN                     Value\r
+  )\r
+{\r
+  //\r
+  // This function cannot work on EBC\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
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 (file)
index 0000000..c94a086
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SwitchStack.c\r
+  \r
+Abstract: \r
+\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  //\r
+  // This version of this function does not actually change the stack pointer\r
+  // This is to support compilation of CPU types that do not support assemblers\r
+  // such as EBC\r
+  //\r
+  EntryPoint (Context1, Context2);\r
+}\r
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 (file)
index 0000000..2c08ffa
--- /dev/null
@@ -0,0 +1,106 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Synchronization.c\r
+  \r
+Abstract: \r
+\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+UINT32\r
+EFIAPI\r
+InternalSyncCompareExchange32 (\r
+  IN      volatile UINT32           *Value,\r
+  IN      UINT32                    CompareValue,\r
+  IN      UINT32                    ExchangeValue\r
+  )\r
+{\r
+  return *Value != CompareValue ? *Value :\r
+           ((*Value = ExchangeValue), CompareValue);\r
+}\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned. \r
+  The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+  @param  Value         A pointer to the 64-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  64-bit value used in compare operation.\r
+  @param  ExchangeValue 64-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalSyncCompareExchange64 (\r
+  IN      volatile UINT64           *Value,\r
+  IN      UINT64                    CompareValue,\r
+  IN      UINT64                    ExchangeValue\r
+  )\r
+{\r
+  return *Value != CompareValue ? *Value :\r
+           ((*Value = ExchangeValue), CompareValue);\r
+}\r
+\r
+/**\r
+  Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic increment of the 32-bit unsigned integer specified by\r
+  Value and returns the incremented value. The increment operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to increment.\r
+\r
+  @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncIncrement (\r
+  IN      volatile UINT32           *Value\r
+  )\r
+{\r
+  return ++*Value;\r
+}\r
+\r
+/**\r
+  Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+  Value and returns the decrement value. The decrement operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to decrement.\r
+\r
+  @return The decrement value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncDecrement (\r
+  IN      volatile UINT32           *Value\r
+  )\r
+{\r
+  return --*Value;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c
new file mode 100644 (file)
index 0000000..1199bfd
--- /dev/null
@@ -0,0 +1,48 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  GetPowerOfTwo32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the value of the highest bit set in a 32-bit value. Equivalent to\r
+  1 << HighBitSet32(x).\r
+\r
+  This function computes the value of the highest bit set in the 32-bit value\r
+  specified by Operand. If Operand is zero, then zero is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return 1 << HighBitSet32(Operand)\r
+  @retval 0 Operand is zero.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GetPowerOfTwo32 (\r
+  IN      UINT32                    Operand\r
+  )\r
+{\r
+  if (Operand == 0) {\r
+    return 0;\r
+  }\r
+\r
+  return 1ul << HighBitSet32 (Operand);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
new file mode 100644 (file)
index 0000000..bd702a2
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  GetPowerOfTwo64.c\r
+\r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the value of the highest bit set in a 64-bit value. Equivalent to\r
+  1 << HighBitSet64(x).\r
+\r
+  This function computes the value of the highest bit set in the 64-bit value\r
+  specified by Operand. If Operand is zero, then zero is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return 1 << HighBitSet64(Operand)\r
+  @retval 0 Operand is zero.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPowerOfTwo64 (\r
+  IN      UINT64                    Operand\r
+  )\r
+{\r
+  if (Operand == 0) {\r
+    return 0;\r
+  }\r
+\r
+  return LShiftU64 (1, HighBitSet64 (Operand));\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c
new file mode 100644 (file)
index 0000000..a7a1f56
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  HighBitSet32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r
+  to log2(x).\r
+\r
+  This function computes the bit position of the highest bit set in the 32-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 31 is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return Position of the highest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+HighBitSet32 (\r
+  IN      UINT32                    Operand\r
+  )\r
+{\r
+  INTN                              BitIndex;\r
+\r
+  if (Operand == 0) {\r
+    return - 1;\r
+  }\r
+  for (BitIndex = 31; (INT32)Operand > 0; BitIndex--, Operand <<= 1);\r
+  return BitIndex;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c
new file mode 100644 (file)
index 0000000..e19928f
--- /dev/null
@@ -0,0 +1,60 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  HighBitSet64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r
+  to log2(x).\r
+\r
+  This function computes the bit position of the highest bit set in the 64-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 63 is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return Position of the highest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+HighBitSet64 (\r
+  IN      UINT64                    Operand\r
+  )\r
+{\r
+  if (Operand == (UINT32)Operand) {\r
+    //\r
+    // Operand is just a 32-bit integer\r
+    //\r
+    return HighBitSet32 ((UINT32)Operand);\r
+  }\r
+\r
+  //\r
+  // Operand is really a 64-bit integer\r
+  //\r
+  if (sizeof (UINTN) == sizeof (UINT32)) {\r
+    return HighBitSet32 (((UINT32*)&Operand)[1]) + 32;\r
+  } else {\r
+    return HighBitSet32 ((UINT32)RShiftU64 (Operand, 32)) + 32;\r
+  }\r
+}\r
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 (file)
index 0000000..1e14e9e
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ARShiftU64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   64-bit arithmetic right shift function for IA-32\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathARShiftU64 (\r
+;   IN      UINT64                    Operand,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathARShiftU64  PROC\r
+    mov     cl, [esp + 12]\r
+    mov     eax, [esp + 8]\r
+    cdq\r
+    test    cl, 32\r
+    cmovz   edx, eax\r
+    cmovz   eax, [esp + 4]\r
+    shrd    eax, edx, cl\r
+    sar     edx, cl\r
+    ret\r
+InternalMathARShiftU64  ENDP\r
+\r
+    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 (file)
index 0000000..e1050af
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuBreakpoint.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuBreakpoint function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuBreakpoint (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+_CpuBreakpoint   PROC\r
+    int  3\r
+    ret\r
+_CpuBreakpoint   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ba4849f
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuFlushTlb.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuFlushTlb function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuFlushTlb (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuFlushTlb PROC\r
+    mov     eax, cr3\r
+    mov     cr3, eax                    ; moving to CR3 flushes TLB\r
+    ret\r
+CpuFlushTlb ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4b97570
--- /dev/null
@@ -0,0 +1,64 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuId.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmCpuid function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586P\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EFIAPI\r
+;  AsmCpuid (\r
+;    IN   UINT32  RegisterInEax,\r
+;    OUT  UINT32  *RegisterOutEax  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEbx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEcx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEdx  OPTIONAL\r
+;    );\r
+;------------------------------------------------------------------------------\r
+AsmCpuid    PROC    USES    ebx\r
+    push    ebp\r
+    mov     ebp, esp\r
+    mov     eax, [ebp + 12]\r
+    cpuid\r
+    push    ecx\r
+    mov     ecx, [ebp + 16]\r
+    jecxz   @F\r
+    mov     [ecx], eax\r
+@@:\r
+    mov     ecx, [ebp + 20]\r
+    jecxz   @F\r
+    mov     [ecx], ebx\r
+@@:\r
+    mov     ecx, [ebp + 24]\r
+    jecxz   @F\r
+    pop     [ecx]\r
+@@:\r
+    mov     ecx, [ebp + 28]\r
+    jecxz   @F\r
+    mov     [ecx], edx\r
+@@:\r
+    mov     eax, [ebp + 12]\r
+    leave\r
+    ret\r
+AsmCpuid    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ea57e60
--- /dev/null
@@ -0,0 +1,66 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuIdEx.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmCpuidEx function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  UINT32\r
+;  EFIAPI\r
+;  AsmCpuidEx (\r
+;    IN   UINT32  RegisterInEax,\r
+;    IN   UINT32  RegisterInEcx,\r
+;    OUT  UINT32  *RegisterOutEax  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEbx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEcx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEdx  OPTIONAL\r
+;    )\r
+;------------------------------------------------------------------------------\r
+AsmCpuidEx  PROC    USES    ebx\r
+    push    ebp\r
+    mov     ebp, esp\r
+    mov     eax, [ebp + 12]\r
+    mov     ecx, [ebp + 16]\r
+    cpuid\r
+    push    ecx\r
+    mov     ecx, [ebp + 20]\r
+    jecxz   @F\r
+    mov     [ecx], eax\r
+@@:\r
+    mov     ecx, [ebp + 24]\r
+    jecxz   @F\r
+    mov     [ecx], ebx\r
+@@:\r
+    mov     ecx, [ebp + 28]\r
+    jecxz   @F\r
+    pop     [ecx]\r
+@@:\r
+    mov     edx, [ebp + 32]\r
+    jecxz   @F\r
+    mov     [ecx], edx\r
+@@:\r
+    mov     eax, [ebp + 12]\r
+    leave\r
+    ret\r
+AsmCpuidEx  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..95e1307
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuPause.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuPause function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuPause (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuPause    PROC\r
+    pause\r
+    ret\r
+CpuPause    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4220834
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuSleep.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuSleep function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuSleep (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuSleep    PROC\r
+    hlt\r
+    ret\r
+CpuSleep    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..fabb3b8
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DisableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   DisableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; DisableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+DisableInterrupts   PROC\r
+    cli\r
+    ret\r
+DisableInterrupts   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..77eee7c
--- /dev/null
@@ -0,0 +1,55 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DisablePaging32.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmDisablePaging32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86DisablePaging32 (\r
+;   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+;   IN      VOID                      *Context1,    OPTIONAL\r
+;   IN      VOID                      *Context2,    OPTIONAL\r
+;   IN      VOID                      *NewStack\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86DisablePaging32    PROC\r
+    mov     ebx, [esp + 4]\r
+    mov     ecx, [esp + 8]\r
+    mov     edx, [esp + 12]\r
+    pushfd\r
+    pop     edi                         ; save EFLAGS to edi\r
+    cli\r
+    mov     eax, cr0\r
+    btr     eax, 31\r
+    mov     esp, [esp + 16]\r
+    mov     cr0, eax\r
+    push    edi\r
+    popfd                               ; restore EFLAGS from edi\r
+    push    edx\r
+    push    ecx\r
+    call    ebx\r
+    jmp     $                           ; EntryPoint() should not return\r
+InternalX86DisablePaging32    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c53b8a0
--- /dev/null
@@ -0,0 +1,60 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DivS64x64Remainder.c\r
+  \r
+Abstract: \r
+\r
+  Integer division worker functions for Ia32.\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and\r
+  generates a  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+INT64\r
+InternalMathDivRemS64x64 (\r
+  IN      INT64                     Dividend,\r
+  IN      INT64                     Divisor,\r
+  OUT     INT64                     *Remainder  OPTIONAL\r
+  )\r
+{\r
+  INT64                             Quot;\r
+\r
+  Quot = InternalMathDivRemU64x64 (\r
+           Dividend >= 0 ? Dividend : -Dividend,\r
+           Divisor >= 0 ? Divisor : -Divisor,\r
+           (UINT64 *) Remainder\r
+           );\r
+  if (Remainder != NULL && Dividend < 0) {\r
+    *Remainder = -*Remainder;\r
+  }\r
+  return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;\r
+}\r
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 (file)
index 0000000..28ae1f8
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DivU64x32.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Calculate the quotient of a 64-bit integer by a 32-bit integer\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathDivU64x32 (\r
+;   IN      UINT64                    Dividend,\r
+;   IN      UINT32                    Divisor\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathDivU64x32   PROC\r
+    mov     eax, [esp + 8]\r
+    mov     ecx, [esp + 12]\r
+    xor     edx, edx\r
+    div     ecx\r
+    push    eax                     ; save quotient on stack\r
+    mov     eax, [esp + 8]\r
+    div     ecx\r
+    pop     edx                     ; restore high-order dword of the quotient\r
+    ret\r
+InternalMathDivU64x32   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..6a1b0eb
--- /dev/null
@@ -0,0 +1,49 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DivError.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Set error flag for all division functions\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathDivRemU64x32 (\r
+;   IN      UINT64                    Dividend,\r
+;   IN      UINT32                    Divisor,\r
+;   OUT     UINT32                    *Remainder\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathDivRemU64x32    PROC\r
+    mov     ecx, [esp + 12]         ; ecx <- divisor\r
+    mov     eax, [esp + 8]          ; eax <- dividend[32..63]\r
+    xor     edx, edx\r
+    div     ecx                     ; eax <- quotient[32..63], edx <- remainder\r
+    push    eax\r
+    mov     eax, [esp + 8]          ; eax <- dividend[0..31]\r
+    div     ecx                     ; eax <- quotient[0..31]\r
+    mov     ecx, [esp + 20]         ; ecx <- Remainder\r
+    jecxz   @F                      ; abandon remainder if Remainder == NULL\r
+    mov     [ecx], edx\r
+@@:\r
+    pop     edx                     ; edx <- quotient[32..63]\r
+    ret\r
+InternalMathDivRemU64x32    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f0261c6
--- /dev/null
@@ -0,0 +1,90 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DivU64x64Remainder.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Calculate the quotient of a 64-bit integer by a 64-bit integer and returns\r
+;   both the quotient and the remainder\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+EXTERN  InternalMathDivRemU64x32:PROC\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathDivRemU64x64 (\r
+;   IN      UINT64                    Dividend,\r
+;   IN      UINT64                    Divisor,\r
+;   OUT     UINT64                    *Remainder    OPTIONAL\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathDivRemU64x64    PROC\r
+    mov     ecx, [esp + 16]             ; ecx <- divisor[32..63]\r
+    test    ecx, ecx\r
+    jnz     _@DivRemU64x64              ; call _@DivRemU64x64 if Divisor > 2^32\r
+    mov     ecx, [esp + 20]\r
+    jecxz   @F\r
+    and     dword ptr [ecx + 4], 0      ; zero high dword of remainder\r
+    mov     [esp + 16], ecx             ; set up stack frame to match DivRemU64x32\r
+@@:\r
+    jmp     InternalMathDivRemU64x32\r
+InternalMathDivRemU64x64    ENDP\r
+\r
+_@DivRemU64x64  PROC    USES    ebx esi edi\r
+    mov     edx, dword ptr [esp + 20]\r
+    mov     eax, dword ptr [esp + 16]   ; edx:eax <- dividend\r
+    mov     edi, edx\r
+    mov     esi, eax                    ; edi:esi <- dividend\r
+    mov     ebx, dword ptr [esp + 24]   ; ecx:ebx <- divisor\r
+@@:\r
+    shr     edx, 1\r
+    rcr     eax, 1\r
+    shrd    ebx, ecx, 1\r
+    shr     ecx, 1\r
+    jnz     @B\r
+    div     ebx\r
+    mov     ebx, eax                    ; ebx <- quotient\r
+    mov     ecx, [esp + 28]             ; ecx <- high dword of divisor\r
+    mul     dword ptr [esp + 24]        ; edx:eax <- quotient * divisor[0..31]\r
+    imul    ecx, ebx                    ; ecx <- quotient * divisor[32..63]\r
+    add     edx, ecx                    ; edx <- (quotient * divisor)[32..63]\r
+    mov     ecx, dword ptr [esp + 32]   ; ecx <- addr for Remainder\r
+    jc      @TooLarge                   ; product > 2^64\r
+    cmp     edi, edx                    ; compare high 32 bits\r
+    ja      @Correct\r
+    jb      @TooLarge                   ; product > dividend\r
+    cmp     esi, eax\r
+    jae     @Correct                    ; product <= dividend\r
+@TooLarge:\r
+    dec     ebx                         ; adjust quotient by -1\r
+    jecxz   @Return                     ; return if Remainder == NULL\r
+    sub     eax, dword ptr [esp + 24]\r
+    sbb     edx, dword ptr [esp + 28]   ; edx:eax <- (quotient - 1) * divisor\r
+@Correct:\r
+    jecxz   @Return\r
+    sub     esi, eax\r
+    sbb     edi, edx                    ; edi:esi <- remainder\r
+    mov     [ecx], esi\r
+    mov     [ecx + 4], edi\r
+@Return:\r
+    mov     eax, ebx                    ; eax <- quotient\r
+    xor     edx, edx                    ; quotient is 32 bits long\r
+    ret\r
+_@DivRemU64x64  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..7218d30
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnableDisableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   EnableDisableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; EnableDisableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+_EnableDisableInterrupts    PROC\r
+    sti\r
+    cli\r
+    ret\r
+_EnableDisableInterrupts    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..26cc379
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   EnableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; EnableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+_EnableInterrupts   PROC\r
+    sti\r
+    ret\r
+_EnableInterrupts   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..06188d7
--- /dev/null
@@ -0,0 +1,55 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnablePaging32.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmEnablePaging32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86EnablePaging32 (\r
+;   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+;   IN      VOID                      *Context1,    OPTIONAL\r
+;   IN      VOID                      *Context2,    OPTIONAL\r
+;   IN      VOID                      *NewStack\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86EnablePaging32 PROC\r
+    mov     ebx, [esp + 4]\r
+    mov     ecx, [esp + 8]\r
+    mov     edx, [esp + 12]\r
+    pushfd\r
+    pop     edi                         ; save flags in edi\r
+    cli\r
+    mov     eax, cr0\r
+    bts     eax, 31\r
+    mov     esp, [esp + 16]\r
+    mov     cr0, eax\r
+    push    edi\r
+    popfd                               ; restore flags\r
+    push    edx\r
+    push    ecx\r
+    call    ebx\r
+    jmp     $\r
+InternalX86EnablePaging32 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..bed4753
--- /dev/null
@@ -0,0 +1,66 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnablePaging64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmEnablePaging64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86EnablePaging64 (\r
+;   IN      UINT16                    Cs,\r
+;   IN      UINT64                    EntryPoint,\r
+;   IN      UINT64                    Context1,  OPTIONAL\r
+;   IN      UINT64                    Context2,  OPTIONAL\r
+;   IN      UINT64                    NewStack\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86EnablePaging64 PROC\r
+    cli\r
+    mov     [esp], @F                   ; offset for far retf, seg is the 1st arg\r
+    mov     eax, cr4\r
+    or      al, (1 SHL 5)\r
+    mov     cr4, eax                    ; enable PAE\r
+    mov     ecx, 0c0000080h\r
+    rdmsr\r
+    or      ah, 1                       ; set LME\r
+    wrmsr\r
+    mov     eax, cr0\r
+    bts     eax, 31                     ; set PG\r
+    mov     cr0, eax                    ; enable paging\r
+    retf                                ; topmost 2 dwords hold the address\r
+@@:                                     ; long mode starts here\r
+    DB      67h, 48h                    ; 32-bit address size, 64-bit operand size\r
+    mov     ebx, [esp]                  ; mov rbx, [esp]\r
+    DB      67h, 48h\r
+    mov     ecx, [esp + 8]              ; mov rcx, [esp + 8]\r
+    DB      67h, 48h\r
+    mov     edx, [esp + 10h]            ; mov rdx, [esp + 10h]\r
+    DB      67h, 48h\r
+    mov     esp, [esp + 18h]            ; mov rsp, [esp + 18h]\r
+    DB      48h\r
+    add     esp, -20h                   ; add rsp, -20h\r
+    call    ebx                         ; call rbx\r
+    hlt                                 ; no one should get here\r
+InternalX86EnablePaging64 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..e4d1880
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FlushCacheLine.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFlushCacheLine function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586P\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; AsmFlushCacheLine (\r
+;   IN      VOID                      *LinearAddress\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFlushCacheLine   PROC\r
+    mov     eax, [esp + 4]\r
+    clflush [eax]\r
+    ret\r
+AsmFlushCacheLine   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..520efe8
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FxRestore.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFxRestore function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86FxRestore (\r
+;   IN CONST IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86FxRestore  PROC\r
+    mov     eax, [esp + 4]              ; Buffer must be 16-byte aligned\r
+    fxrstor [eax]\r
+    ret\r
+InternalX86FxRestore  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cd8a801
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FxSave.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFxSave function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86FxSave (\r
+;   OUT IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86FxSave PROC\r
+    mov     eax, [esp + 4]              ; Buffer must be 16-byte aligned\r
+    fxsave  [eax]\r
+    ret\r
+InternalX86FxSave ENDP\r
+\r
+    END\r
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 (file)
index 0000000..1937c86
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedCompareExchange32.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedCompareExchange32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .486\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InternalSyncCompareExchange32 (\r
+;   IN      UINT32                    *Value,\r
+;   IN      UINT32                    CompareValue,\r
+;   IN      UINT32                    ExchangeValue\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncCompareExchange32   PROC\r
+    mov     ecx, [esp + 4]\r
+    mov     eax, [esp + 8]\r
+    mov     edx, [esp + 12]\r
+    lock    cmpxchg [ecx], edx\r
+    ret\r
+InternalSyncCompareExchange32   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..8cea7dc
--- /dev/null
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedCompareExchange64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedCompareExchange64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586P\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalSyncCompareExchange64 (\r
+;   IN      UINT64                    *Value,\r
+;   IN      UINT64                    CompareValue,\r
+;   IN      UINT64                    ExchangeValue\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncCompareExchange64   PROC    USES    esi ebx\r
+    mov     esi, [esp + 12]\r
+    mov     eax, [esp + 16]\r
+    mov     edx, [esp + 20]\r
+    mov     ebx, [esp + 24]\r
+    mov     ecx, [esp + 28]\r
+    lock    cmpxchg8b   qword ptr [esi]\r
+    ret\r
+InternalSyncCompareExchange64   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..269c5f2
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedDecrement.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedDecrement function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InternalSyncDecrement (\r
+;   IN      UINT32                    *Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncDecrement   PROC\r
+    mov     eax, [esp + 4]\r
+    lock    dec     dword ptr [eax]\r
+    mov     eax, [eax]\r
+    ret\r
+InternalSyncDecrement   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4d989b5
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedIncrement.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedIncrement function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InternalSyncIncrement (\r
+;   IN      UINT32                    *Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncIncrement   PROC\r
+    mov     eax, [esp + 4]\r
+    lock    inc     dword ptr [eax]\r
+    mov     eax, [eax]\r
+    ret\r
+InternalSyncIncrement   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9d6443a
--- /dev/null
@@ -0,0 +1,60 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  InternalSwitchStack.c\r
+  \r
+Abstract: \r
+\r
+  SwitchStack() function for IA-32.\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,\r
+  IN      VOID                      *Context2,\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;\r
+\r
+  JumpBuffer.Eip = (UINTN)EntryPoint;\r
+  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r
+  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);\r
+  ((VOID**)JumpBuffer.Esp)[1] = Context1;\r
+  ((VOID**)JumpBuffer.Esp)[2] = Context2;\r
+\r
+  LongJump (&JumpBuffer, (UINTN)-1);\r
+}\r
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 (file)
index 0000000..24a3869
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Invd.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmInvd function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .486p\r
+    .model  flat\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmInvd (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+_AsmInvd    PROC\r
+    invd\r
+    ret\r
+_AsmInvd    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f1bbd58
--- /dev/null
@@ -0,0 +1,47 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   LRotU64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   64-bit left rotation for Ia32\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathLRotU64 (\r
+;   IN      UINT64                    Operand,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathLRotU64 PROC    USES    ebx\r
+    mov     cl, [esp + 16]\r
+    mov     edx, [esp + 12]\r
+    mov     eax, [esp + 8]\r
+    shld    ebx, edx, cl\r
+    shld    edx, eax, cl\r
+    ror     ebx, cl\r
+    shld    eax, ebx, cl\r
+    test    cl, 32                      ; Count >= 32?\r
+    cmovnz  ecx, eax\r
+    cmovnz  eax, edx\r
+    cmovnz  edx, ecx\r
+    ret\r
+InternalMathLRotU64 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..06a521d
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   LShiftU64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   64-bit left shift function for IA-32\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathLShiftU64 (\r
+;   IN      UINT64                    Operand,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathLShiftU64   PROC\r
+    mov     cl, [esp + 12]\r
+    xor     eax, eax\r
+    mov     edx, [esp + 4]\r
+    test    cl, 32                      ; Count >= 32?\r
+    cmovz   eax, edx\r
+    cmovz   edx, [esp + 8]\r
+    shld    edx, eax, cl\r
+    shl     eax, cl\r
+    ret\r
+InternalMathLShiftU64   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..68e5b6b
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   LongJump.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   Implementation of _LongJump() on IA-32.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalLongJump (\r
+;   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+;   IN      UINTN                     Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalLongJump    PROC\r
+    pop     eax                         ; skip return address\r
+    pop     edx                         ; edx <- JumpBuffer\r
+    pop     eax                         ; eax <- Value\r
+    mov     ebx, [edx]\r
+    mov     esi, [edx + 4]\r
+    mov     edi, [edx + 8]\r
+    mov     ebp, [edx + 12]\r
+    mov     esp, [edx + 16]\r
+    jmp     dword ptr [edx + 20]        ; restore "eip"\r
+InternalLongJump    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..62e310a
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DivU64x32.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Calculate the remainder of a 64-bit integer by a 32-bit integer\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InternalMathModU64x32 (\r
+;   IN      UINT64                    Dividend,\r
+;   IN      UINT32                    Divisor\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathModU64x32   PROC\r
+    mov     eax, [esp + 8]\r
+    mov     ecx, [esp + 12]\r
+    xor     edx, edx\r
+    div     ecx\r
+    mov     eax, [esp + 4]\r
+    div     ecx\r
+    mov     eax, edx\r
+    ret\r
+InternalMathModU64x32   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cf298a9
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Monitor.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmMonitor function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmMonitor (\r
+;   IN      UINTN                     Eax,\r
+;   IN      UINTN                     Ecx,\r
+;   IN      UINTN                     Edx\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmMonitor  PROC\r
+    mov     eax, [esp + 4]\r
+    mov     ecx, [esp + 8]\r
+    mov     edx, [esp + 12]\r
+    DB      0fh, 1, 0c8h                ; monitor\r
+    ret\r
+AsmMonitor  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f10c4a7
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   MultU64x32.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Calculate the product of a 64-bit integer and a 32-bit integer\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathMultU64x32 (\r
+;   IN      UINT64                    Multiplicand,\r
+;   IN      UINT32                    Multiplier\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathMultU64x32  PROC\r
+    mov     ecx, [esp + 12]\r
+    mov     eax, ecx\r
+    imul    ecx, [esp + 8]              ; overflow not detectable\r
+    mul     dword ptr [esp + 4]\r
+    add     edx, ecx\r
+    ret\r
+InternalMathMultU64x32  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..39a66eb
--- /dev/null
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   MultU64x64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Calculate the product of a 64-bit integer and another 64-bit integer\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathMultU64x64 (\r
+;   IN      UINT64                    Multiplicand,\r
+;   IN      UINT64                    Multiplier\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathMultU64x64  PROC    USES    ebx\r
+    mov     ebx, [esp + 8]              ; ebx <- M1[0..31]\r
+    mov     edx, [esp + 16]             ; edx <- M2[0..31]\r
+    mov     ecx, ebx\r
+    mov     eax, edx\r
+    imul    ebx, [esp + 20]             ; ebx <- M1[0..31] * M2[32..63]\r
+    imul    edx, [esp + 12]             ; edx <- M1[32..63] * M2[0..31]\r
+    add     ebx, edx                    ; carries are abandoned\r
+    mul     ecx                         ; edx:eax <- M1[0..31] * M2[0..31]\r
+    add     edx, ebx                    ; carries are abandoned\r
+    ret\r
+InternalMathMultU64x64  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..bb2a07c
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Mwait.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmMwait function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmMwait (\r
+;   IN      UINTN                     Eax,\r
+;   IN      UINTN                     Ecx\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmMwait    PROC\r
+    mov     eax, [esp + 4]\r
+    mov     ecx, [esp + 8]\r
+    DB      0fh, 1, 0c9h                ; mwait\r
+    ret\r
+AsmMwait    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..6ac40c7
--- /dev/null
@@ -0,0 +1,66 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Non-existing.c\r
+  \r
+Abstract: \r
+\r
+  Non-existing BaseLib functions on Ia32\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+\r
+/**\r
+  Disables the 64-bit paging mode on the CPU.\r
+\r
+  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 64-paging mode.\r
+  This function is only available on X64. After the 64-bit paging mode is\r
+  disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be 0. The function EntryPoint must never return.\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for 32-bit protected mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is disabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is disabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is disabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86DisablePaging64 (\r
+  IN      UINT16                    CodeSelector,\r
+  IN      UINT32                    EntryPoint,\r
+  IN      UINT32                    Context1,  OPTIONAL\r
+  IN      UINT32                    Context2,  OPTIONAL\r
+  IN      UINT32                    NewStack\r
+  )\r
+{\r
+  //\r
+  // This function cannot work on IA32 platform\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
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 (file)
index 0000000..413ae0c
--- /dev/null
@@ -0,0 +1,47 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   RRotU64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   64-bit right rotation for Ia32\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathRRotU64 (\r
+;   IN      UINT64                    Operand,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathRRotU64 PROC    USES    ebx\r
+    mov     cl, [esp + 16]\r
+    mov     eax, [esp + 8]\r
+    mov     edx, [esp + 12]\r
+    shrd    ebx, eax, cl\r
+    shrd    eax, edx, cl\r
+    rol     ebx, cl\r
+    shrd    edx, ebx, cl\r
+    test    cl, 32                      ; Count >= 32?\r
+    cmovnz  ecx, eax                    ; switch eax & edx if Count >= 32\r
+    cmovnz  eax, edx\r
+    cmovnz  edx, ecx\r
+    ret\r
+InternalMathRRotU64 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..78b039f
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   RShiftU64.asm\r
+;\r
+; Abstract:\r
+;\r
+;   64-bit logical right shift function for IA-32\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathRShiftU64 (\r
+;   IN      UINT64                    Operand,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathRShiftU64   PROC\r
+    mov     cl, [esp + 12]              ; cl <- Count\r
+    xor     edx, edx\r
+    mov     eax, [esp + 8]\r
+    test    cl, 32                      ; Count >= 32?\r
+    cmovz   edx, eax\r
+    cmovz   eax, [esp + 4]\r
+    shrd    eax, edx, cl\r
+    shr     edx, cl\r
+    ret\r
+InternalMathRShiftU64   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..6d15ad5
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr0  PROC\r
+    mov     eax, cr0\r
+    ret\r
+AsmReadCr0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b7f75e4
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr2  PROC\r
+    mov     eax, cr2\r
+    ret\r
+AsmReadCr2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2f3b54b
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr3  PROC\r
+    mov     eax, cr3\r
+    ret\r
+AsmReadCr3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..bf2aaee
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr4  PROC\r
+    mov     eax, cr4\r
+    ret\r
+AsmReadCr4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..69e2d11
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadCs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCs   PROC\r
+    mov     eax, cs\r
+    ret\r
+AsmReadCs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..bf5d546
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr0  PROC\r
+    mov     eax, dr0\r
+    ret\r
+AsmReadDr0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9b143cd
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr1 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr1  PROC\r
+    mov     eax, dr1\r
+    ret\r
+AsmReadDr1  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ba24037
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr2  PROC\r
+    mov     eax, dr2\r
+    ret\r
+AsmReadDr2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..67a0f1c
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr3  PROC\r
+    mov     eax, dr3\r
+    ret\r
+AsmReadDr3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cfae3e8
--- /dev/null
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr4  PROC\r
+    ;\r
+    ; DR4 is alias to DR6 only if DE (in CR4) is cleared. Otherwise, reading\r
+    ; this register will cause a #UD exception.\r
+    ;\r
+    ; MS assembler doesn't support this instruction since no one would use it\r
+    ; under normal circustances. Here opcode is used.\r
+    ;\r
+    DB      0fh, 21h, 0e0h\r
+    ret\r
+AsmReadDr4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9f3fec1
--- /dev/null
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr5 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr5  PROC\r
+    ;\r
+    ; DR5 is alias to DR7 only if DE (in CR4) is cleared. Otherwise, reading\r
+    ; this register will cause a #UD exception.\r
+    ;\r
+    ; MS assembler doesn't support this instruction since no one would use it\r
+    ; under normal circustances. Here opcode is used.\r
+    ;\r
+    DB      0fh, 21h, 0e8h\r
+    ret\r
+AsmReadDr5  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..a773f12
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr6 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr6  PROC\r
+    mov     eax, dr6\r
+    ret\r
+AsmReadDr6  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..74b2927
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr7 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr7  PROC\r
+    mov     eax, dr7\r
+    ret\r
+AsmReadDr7  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b724a46
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadDs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDs   PROC\r
+    mov     eax, ds\r
+    ret\r
+AsmReadDs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..5cb241f
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadEflags.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadEflags function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadEflags (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadEflags   PROC\r
+    pushfd\r
+    pop     eax\r
+    ret\r
+AsmReadEflags   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..6706071
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadEs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadEs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadEs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadEs   PROC\r
+    mov     eax, es\r
+    ret\r
+AsmReadEs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..773da70
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadFs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadFs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadFs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadFs   PROC\r
+    mov     eax, fs\r
+    ret\r
+AsmReadFs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..19db886
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadGdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadGdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86ReadGdtr (\r
+;   OUT IA32_DESCRIPTOR  *Gdtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86ReadGdtr   PROC\r
+    mov     eax, [esp + 4]\r
+    sgdt    fword ptr [eax]\r
+    ret\r
+InternalX86ReadGdtr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..55ccca4
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadGs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadGs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadGs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadGs   PROC\r
+    mov     eax, gs\r
+    ret\r
+AsmReadGs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..6c10fca
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadIdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadIdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86ReadIdtr (\r
+;   OUT     IA32_DESCRIPTOR           *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86ReadIdtr PROC\r
+    mov     eax, [esp + 4]\r
+    sidt    fword ptr [eax]\r
+    ret\r
+InternalX86ReadIdtr ENDP\r
+\r
+    END\r
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 (file)
index 0000000..7b9696f
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadLdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadLdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadLdtr (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadLdtr PROC\r
+    sldt    ax\r
+    ret\r
+AsmReadLdtr ENDP\r
+\r
+    END\r
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 (file)
index 0000000..1ea5b21
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm0  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm0\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..36d14b0
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm1 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm1  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm1\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm1  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..652ae5e
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm2  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm2\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2cf4c67
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm3  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm3\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..37599ae
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm4  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm4\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..3722f9d
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm5 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm5  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm5\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm5  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..031889e
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm6 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm6  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm6\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm6  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c831950
--- /dev/null
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm7 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm7  PROC\r
+    push    eax\r
+    push    eax\r
+    movq    [esp], mm7\r
+    pop     eax\r
+    pop     edx\r
+    ret\r
+AsmReadMm7  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f0cf6a8
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMsr64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMsr64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMsr64 (\r
+;   IN UINT64  Index\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMsr64    PROC\r
+    mov     ecx, [esp + 4]\r
+    rdmsr\r
+    ret\r
+AsmReadMsr64    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..3b0d0e3
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadPmc.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadPmc function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadPmc (\r
+;   IN UINT32   PmcIndex\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadPmc  PROC\r
+    mov     ecx, [esp + 4]\r
+    rdpmc\r
+    ret\r
+AsmReadPmc  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..7788fc9
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadSs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadSs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadSs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadSs   PROC\r
+    mov     eax, ss\r
+    ret\r
+AsmReadSs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..8990e31
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadTr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadTr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadTr (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadTr   PROC\r
+    str     ax\r
+    ret\r
+AsmReadTr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..8ff0ea4
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadTsc.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadTsc function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadTsc (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadTsc  PROC\r
+    rdtsc\r
+    ret\r
+AsmReadTsc  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..e3d33e1
--- /dev/null
@@ -0,0 +1,49 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   SetJump.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   Implementation of SetJump() on IA-32.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386\r
+    .model  flat,C\r
+    .code\r
+\r
+InternalAssertJumpBuffer    PROTO   C\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; SetJump (\r
+;   OUT     BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+SetJump     PROC\r
+    push    [esp + 4]\r
+    call    InternalAssertJumpBuffer    ; To validate JumpBuffer\r
+    pop     ecx\r
+    pop     ecx                         ; ecx <- return address\r
+    mov     edx, [esp]\r
+    mov     [edx], ebx\r
+    mov     [edx + 4], esi\r
+    mov     [edx + 8], edi\r
+    mov     [edx + 12], ebp\r
+    mov     [edx + 16], esp\r
+    mov     [edx + 20], ecx             ; eip value to restore in LongJump\r
+    xor     eax, eax\r
+    jmp     ecx\r
+SetJump     ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9554c19
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuId.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmCpuid function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InternalMathSwapBytes64 (\r
+;   IN      UINT64                    Operand\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalMathSwapBytes64 PROC\r
+    mov     eax, [esp + 8]              ; eax <- upper 32 bits\r
+    mov     edx, [esp + 4]              ; edx <- lower 32 bits\r
+    bswap   eax\r
+    bswap   edx\r
+    ret\r
+InternalMathSwapBytes64 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..154008f
--- /dev/null
@@ -0,0 +1,250 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Thunk.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Real mode thunk\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .686p\r
+    .model  flat,C\r
+\r
+EXTERNDEF   C   m16Start:BYTE\r
+EXTERNDEF   C   m16Size:WORD\r
+EXTERNDEF   C   mThunk16Attr:WORD\r
+EXTERNDEF   C   m16Gdt:WORD\r
+EXTERNDEF   C   m16GdtrBase:WORD\r
+EXTERNDEF   C   mTransition:WORD\r
+\r
+THUNK_ATTRIBUTE_BIG_REAL_MODE               EQU 1\r
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15     EQU 2\r
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL   EQU 4\r
+\r
+;\r
+; Here is the layout of the real mode stack. _ToUserCode() is responsible for\r
+; loading all these registers from real mode stack.\r
+;\r
+IA32_REGS   STRUC   4t\r
+_EDI        DD      ?\r
+_ESI        DD      ?\r
+_EBP        DD      ?\r
+_ESP        DD      ?\r
+_EBX        DD      ?\r
+_EDX        DD      ?\r
+_ECX        DD      ?\r
+_EAX        DD      ?\r
+_DS         DW      ?\r
+_ES         DW      ?\r
+_FS         DW      ?\r
+_GS         DW      ?\r
+_EFLAGS     DD      ?\r
+_EIP        DD      ?\r
+_CS         DW      ?\r
+_SS         DW      ?\r
+IA32_REGS   ENDS\r
+\r
+    .const\r
+\r
+;\r
+; These are global constant to convey information to C code.\r
+;\r
+m16Size         DW      InternalAsmThunk16 - m16Start\r
+mThunk16Attr    DW      _ThunkAttr - m16Start\r
+m16Gdt          DW      _NullSegDesc - m16Start\r
+m16GdtrBase     DW      _16GdtrBase - m16Start\r
+mTransition     DW      _EntryPoint - m16Start\r
+\r
+    .code\r
+\r
+m16Start    LABEL   BYTE\r
+\r
+SavedGdt    LABEL   FWORD\r
+            DW      ?\r
+            DD      ?\r
+;------------------------------------------------------------------------------\r
+; _BackFromUserCode() takes control in real mode after 'retf' has been executed\r
+; by user code. It will be shadowed to somewhere in memory below 1MB.\r
+;------------------------------------------------------------------------------\r
+_BackFromUserCode   PROC\r
+    ;\r
+    ; The order of saved registers on the stack matches the order they appears\r
+    ; in IA32_REGS structure. This facilitates wrapper function to extract them\r
+    ; into that structure.\r
+    ;\r
+    push    ss\r
+    push    cs\r
+    DB      66h\r
+    call    @Base                       ; push eip\r
+@Base:\r
+    pushf                               ; pushfd actually\r
+    cli                                 ; disable interrupts\r
+    push    gs\r
+    push    fs\r
+    push    es\r
+    push    ds\r
+    pushaw                              ; pushad actually\r
+    DB      66h, 0bah                   ; mov edx, imm32\r
+_ThunkAttr  DD      ?\r
+    test    dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15\r
+    jz      @1\r
+    mov     eax, 15cd2401h              ; mov ax, 2401h & int 15h\r
+    cli                                 ; disable interrupts\r
+    jnc     @2\r
+@1:\r
+    test    dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL\r
+    jz      @2\r
+    in      al, 92h\r
+    or      al, 2\r
+    out     92h, al                     ; deactivate A20M#\r
+@2:\r
+    mov     eax, ss\r
+    DB      67h\r
+    lea     bp, [esp + sizeof (IA32_REGS)]\r
+    ;\r
+    ; esi's in the following 2 instructions are indeed bp in 16-bit code. Fact\r
+    ; is "esi" in 32-bit addressing mode has the same encoding of "bp" in 16-\r
+    ; bit addressing mode.\r
+    ;\r
+    mov     word ptr (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._ESP, bp\r
+    mov     ebx, (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._EIP\r
+    shl     ax, 4                       ; shl eax, 4\r
+    add     bp, ax                      ; add ebp, eax\r
+    DB      66h, 0b8h                   ; mov eax, imm32\r
+SavedCr4    DD      ?\r
+    mov     cr4, eax\r
+    DB      66h\r
+    lgdt    fword ptr cs:[edi + (SavedGdt - @Base)]\r
+    DB      66h, 0b8h                   ; mov eax, imm32\r
+SavedCr0    DD      ?\r
+    mov     cr0, eax\r
+    DB      0b8h                        ; mov ax, imm16\r
+SavedSs     DW      ?\r
+    mov     ss, eax\r
+    DB      66h, 0bch                   ; mov esp, imm32\r
+SavedEsp    DD      ?\r
+    DB      66h\r
+    retf                                ; return to protected mode\r
+_BackFromUserCode   ENDP\r
+\r
+_EntryPoint DD      _ToUserCode - m16Start\r
+            DW      8h\r
+_16Idtr     FWORD   (1 SHL 10) - 1\r
+_16Gdtr     LABEL   FWORD\r
+            DW      GdtEnd - _NullSegDesc - 1\r
+_16GdtrBase DD      _NullSegDesc\r
+\r
+;------------------------------------------------------------------------------\r
+; _ToUserCode() takes control in real mode before passing control to user code.\r
+; It will be shadowed to somewhere in memory below 1MB.\r
+;------------------------------------------------------------------------------\r
+_ToUserCode PROC\r
+    mov     edx, ss\r
+    mov     ss, ecx                     ; set new segment selectors\r
+    mov     ds, ecx\r
+    mov     es, ecx\r
+    mov     fs, ecx\r
+    mov     gs, ecx\r
+    mov     cr0, eax\r
+    mov     cr4, ebp                    ; real mode starts at next instruction\r
+    mov     ss, esi                     ; set up 16-bit stack segment\r
+    xchg    sp, bx                      ; set up 16-bit stack pointer\r
+    DB      66h\r
+    call    @Base                       ; push eip\r
+@Base:\r
+    pop     bp                          ; ebp <- address of @Base\r
+    DB      67h                         ; address size override\r
+    push    [esp + sizeof (IA32_REGS) + 2]\r
+    lea     eax, [esi + (@RealMode - @Base)]\r
+    push    eax\r
+    retf\r
+@RealMode:\r
+    mov     cs:[esi + (SavedSs - @Base)], edx\r
+    mov     cs:[esi + (SavedEsp - @Base)], bx\r
+    DB      66h\r
+    lidt    fword ptr cs:[esi + (_16Idtr - @Base)]\r
+    popaw                               ; popad actually\r
+    pop     ds\r
+    pop     es\r
+    pop     fs\r
+    pop     gs\r
+    popf                                ; popfd\r
+    DB      66h                         ; Use 32-bit addressing for "retf" below\r
+    retf                                ; transfer control to user code\r
+_ToUserCode ENDP\r
+\r
+_NullSegDesc    DQ      0\r
+_16CsDesc       LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      9bh\r
+                DB      8fh             ; 16-bit segment, 4GB limit\r
+                DB      0\r
+_16DsDesc       LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      93h\r
+                DB      8fh             ; 16-bit segment, 4GB limit\r
+                DB      0\r
+GdtEnd          LABEL   QWORD\r
+\r
+;------------------------------------------------------------------------------\r
+; IA32_REGISTER_SET *\r
+; EFIAPI\r
+; InternalAsmThunk16 (\r
+;   IN      IA32_REGISTER_SET         *RegisterSet,\r
+;   IN OUT  VOID                      *Transition\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalAsmThunk16  PROC    USES    ebp ebx esi edi ds  es  fs  gs\r
+    mov     esi, [esp + 36]             ; esi <- RegSet, the 1st parameter\r
+    movzx   edx, (IA32_REGS ptr [esi])._SS\r
+    mov     edi, (IA32_REGS ptr [esi])._ESP\r
+    add     edi, - (sizeof (IA32_REGS) + 4) ; reserve stack space\r
+    mov     ebx, edi                    ; ebx <- stack offset\r
+    imul    eax, edx, 16                ; eax <- edx * 16\r
+    push    sizeof (IA32_REGS) / 4\r
+    add     edi, eax                    ; edi <- linear address of 16-bit stack\r
+    pop     ecx\r
+    rep     movsd                       ; copy RegSet\r
+    mov     eax, [esp + 40]             ; eax <- address of transition code\r
+    mov     esi, edx                    ; esi <- 16-bit stack segment\r
+    lea     edx, [eax + (SavedCr0 - m16Start)]\r
+    mov     ecx, eax\r
+    and     ecx, 0fh\r
+    shl     eax, 12\r
+    lea     ecx, [ecx + (_BackFromUserCode - m16Start)]\r
+    mov     ax, cx\r
+    stosd                               ; [edi] <- return address of user code\r
+    sgdt    fword ptr [edx + (SavedGdt - SavedCr0)]\r
+    sidt    fword ptr [esp + 36]        ; save IDT stack in argument space\r
+    mov     eax, cr0\r
+    mov     [edx], eax                  ; save CR0 in SavedCr0\r
+    and     eax, 7ffffffeh              ; clear PE, PG bits\r
+    mov     ebp, cr4\r
+    mov     [edx + (SavedCr4 - SavedCr0)], ebp\r
+    and     ebp, 300h                   ; clear all but PCE and OSFXSR bits\r
+    push    10h\r
+    pop     ecx                         ; ecx <- selector for data segments\r
+    lgdt    fword ptr [edx + (_16Gdtr - SavedCr0)]\r
+    pushfd                              ; Save df/if indeed\r
+    call    fword ptr [edx + (_EntryPoint - SavedCr0)]\r
+    popfd\r
+    lidt    fword ptr [esp + 36]        ; restore protected mode IDTR\r
+    lea     eax, [ebp - sizeof (IA32_REGS)] ; eax <- the address of IA32_REGS\r
+    ret\r
+InternalAsmThunk16  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9ffdec9
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Wbinvd.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWbinvd function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .486p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWbinvd (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWbinvd   PROC\r
+    wbinvd\r
+    ret\r
+AsmWbinvd   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..d87c7e3
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr0 (\r
+;   UINTN  Cr0\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr0 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     cr0, eax\r
+    ret\r
+AsmWriteCr0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..412cb26
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr2 (\r
+;   UINTN  Cr2\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr2 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     cr2, eax\r
+    ret\r
+AsmWriteCr2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..47514ea
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr3 (\r
+;   UINTN  Cr3\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr3 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     cr3, eax\r
+    ret\r
+AsmWriteCr3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..dd8d37e
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr4 (\r
+;   UINTN  Cr4\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr4 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     cr4, eax\r
+    ret\r
+AsmWriteCr4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0154d0f
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr0 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr0 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr0, eax\r
+    ret\r
+AsmWriteDr0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4c7a2b3
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr1 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr1 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr1, eax\r
+    ret\r
+AsmWriteDr1 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f621f6d
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr2 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr2 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr2, eax\r
+    ret\r
+AsmWriteDr2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..99a5d56
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr3 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr3 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr3, eax\r
+    ret\r
+AsmWriteDr3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9ed8bb3
--- /dev/null
@@ -0,0 +1,46 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr4 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr4 PROC\r
+    mov     eax, [esp + 4]\r
+    ;\r
+    ; DR4 is alias to DR6 only if DE (in CR4) is cleared. Otherwise, writing to\r
+    ; this register will cause a #UD exception.\r
+    ;\r
+    ; MS assembler doesn't support this instruction since no one would use it\r
+    ; under normal circustances. Here opcode is used.\r
+    ;\r
+    DB      0fh, 23h, 0e0h\r
+    ret\r
+AsmWriteDr4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ba74eaa
--- /dev/null
@@ -0,0 +1,46 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr5 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr5 PROC\r
+    mov     eax, [esp + 4]\r
+    ;\r
+    ; DR5 is alias to DR7 only if DE (in CR4) is cleared. Otherwise, writing to\r
+    ; this register will cause a #UD exception.\r
+    ;\r
+    ; MS assembler doesn't support this instruction since no one would use it\r
+    ; under normal circustances. Here opcode is used.\r
+    ;\r
+    DB      0fh, 23h, 0e8h\r
+    ret\r
+AsmWriteDr5 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f36e95e
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr6 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr6 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr6, eax\r
+    ret\r
+AsmWriteDr6 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cba6459
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr7 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr7 PROC\r
+    mov     eax, [esp + 4]\r
+    mov     dr7, eax\r
+    ret\r
+AsmWriteDr7 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0d5b533
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteGdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteGdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86WriteGdtr (\r
+;   IN      CONST IA32_DESCRIPTOR     *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86WriteGdtr  PROC\r
+    mov     eax, [esp + 4]\r
+    lgdt    fword ptr [eax]\r
+    ret\r
+InternalX86WriteGdtr  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..427637a
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteIdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteIdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86WriteIdtr (\r
+;   IN      CONST IA32_DESCRIPTOR     *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86WriteIdtr  PROC\r
+    mov     eax, [esp + 4]\r
+    lidt    fword ptr [eax]\r
+    ret\r
+InternalX86WriteIdtr  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..fb24d05
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteLdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteLdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .386p\r
+    .model  flat\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteLdtr (\r
+;   IN UINT16 Ldtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+_AsmWriteLdtr   PROC\r
+    mov     eax, [esp + 4]\r
+    lldt    ax\r
+    ret\r
+_AsmWriteLdtr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..64090ce
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm0 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm0 PROC\r
+    movq    mm0, [esp + 4]\r
+    ret\r
+AsmWriteMm0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9f81608
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm1 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm1 PROC\r
+    movq    mm1, [esp + 4]\r
+    ret\r
+AsmWriteMm1 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..e882045
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm2 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm2 PROC\r
+    movq    mm2, [esp + 4]\r
+    ret\r
+AsmWriteMm2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c00c328
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm3 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm3 PROC\r
+    movq    mm3, [esp + 4]\r
+    ret\r
+AsmWriteMm3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f12f1e3
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm4 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm4 PROC\r
+    movq    mm4, [esp + 4]\r
+    ret\r
+AsmWriteMm4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..a6fe8fd
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm5 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm5 PROC\r
+    movq    mm5, [esp + 4]\r
+    ret\r
+AsmWriteMm5 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b8be7e5
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm6 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm6 PROC\r
+    movq    mm6, [esp + 4]\r
+    ret\r
+AsmWriteMm6 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..dfce9eb
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm7 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm7 PROC\r
+    movq    mm7, [esp + 4]\r
+    ret\r
+AsmWriteMm7 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..69eaae0
--- /dev/null
@@ -0,0 +1,42 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMsr64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMsr64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmWriteMsr64 (\r
+;   IN UINT32  Index,\r
+;   IN UINT64  Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMsr64   PROC\r
+    mov     edx, [esp + 12]\r
+    mov     eax, [esp + 8]\r
+    mov     ecx, [esp + 4]\r
+    wrmsr\r
+    ret\r
+AsmWriteMsr64   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..237ca21
--- /dev/null
@@ -0,0 +1,126 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  CpuBreakpint.c\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+//void __mfa (void);\r
+\r
+#pragma intrinsic (_enable)\r
+#pragma intrinsic (_disable)\r
+#pragma intrinsic (__break)\r
+#pragma intrinsic (__mfa)\r
+\r
+\r
+/**\r
+  Generates a breakpoint on the CPU.\r
+\r
+  Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
+  that code can resume normal execution after the breakpoint.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuBreakpoint (\r
+  VOID\r
+  )\r
+{\r
+  __break (0);\r
+}\r
+\r
+/**\r
+  Used to serialize load and store operations.\r
+\r
+  All loads and stores that proceed calls to this function are guaranteed to be\r
+  globally visible when this function returns.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MemoryFence (\r
+  VOID\r
+  )\r
+{\r
+  __mfa ();\r
+}\r
+\r
+/**\r
+  Disables CPU interrupts.\r
+\r
+  Disables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DisableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  _disable ();\r
+}\r
+\r
+/**\r
+  Enables CPU interrupts.\r
+\r
+  Enables CPU interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  _enable ();\r
+}\r
+\r
+/**\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+  Enables CPU interrupts for the smallest window required to capture any\r
+  pending interrupts.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnableDisableInterrupts (\r
+  VOID\r
+  )\r
+{\r
+  EnableInterrupts ();\r
+  DisableInterrupts ();\r
+}\r
+\r
+/**\r
+  Places the CPU in a sleep state until an interrupt is received.\r
+\r
+  Places the CPU in a sleep state until an interrupt is received. If interrupts\r
+  are disabled prior to calling this function, then the CPU will be placed in a\r
+  sleep state indefinitely.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuSleep (\r
+  VOID\r
+  )\r
+{\r
+  PalCallStatic (NULL, 29, 0, 0, 0);\r
+}\r
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 (file)
index 0000000..02b67fd
--- /dev/null
@@ -0,0 +1,59 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   CpuFlushTlb.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.globl PalCallStatic\r
+.type   PalCallStatic, @function\r
+\r
+.proc   CpuFlushTlb\r
+.type   CpuFlushTlb, @function\r
+CpuFlushTlb::\r
+        alloc               loc0 = ar.pfs, 0, 3, 5, 0\r
+        mov                 out0 = 0\r
+        mov                 out1 = 6\r
+        mov                 out2 = 0\r
+        mov                 out3 = 0\r
+        mov                 loc1 = b0\r
+        mov                 out4 = 0\r
+        brl.call.sptk       b0  = PalCallStatic\r
+        mov                 loc2 = psr              // save PSR\r
+        mov                 ar.pfs = loc0\r
+        extr.u              r14 = r10, 32, 32       // r14 <- count1\r
+        rsm                 1 << 14                 // Disable interrupts\r
+        extr.u              r15 = r11, 32, 32       // r15 <- stride1\r
+        extr.u              r10 = r10, 0, 32        // r10 <- count2\r
+        add                 r10 = -1, r10\r
+        extr.u              r11 = r11, 0, 32        // r11 <- stride2\r
+        br.cond.sptk        LoopPredicate\r
+LoopOuter:\r
+        mov                 ar.lc = r10             // LC <- count2\r
+        mov                 ar.ec = r0              // EC <- 0\r
+Loop:\r
+        ptc.e               r9\r
+        add                 r9 = r11, r9            // r9 += stride2\r
+        br.ctop.sptk        Loop\r
+        add                 r9 = r15, r9            // r9 += stride1\r
+LoopPredicate:\r
+        cmp.ne              p6 = r0, r14            // count1 == 0?\r
+        add                 r14 = -1, r14\r
+(p6)    br.cond.sptk        LoopOuter\r
+        mov                 psr.l = loc2\r
+        mov                 b0  = loc1\r
+        br.ret.sptk.many    b0\r
+.endp\r
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 (file)
index 0000000..8b33642
--- /dev/null
@@ -0,0 +1,26 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   CpuPause.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   CpuPause\r
+.type   CpuPause, @function\r
+CpuPause::\r
+        hint                0 //@pause\r
+        br.ret.sptk.many    b0\r
+.endp\r
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 (file)
index 0000000..8c88f90
--- /dev/null
@@ -0,0 +1,94 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   FlushCacheRange.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.file  "IpfCpuCache.s"\r
+\r
+#include  "IpfMacro.i"\r
+#include  "IpfDefines.h"\r
+\r
+//\r
+//  Invalidates a range of instruction cache lines in the cache coherency domain\r
+//  of the calling CPU.\r
+//\r
+//  Invalidates the instruction cache lines specified by Address and Length. If\r
+//  Address is not aligned on a cache line boundary, then entire instruction\r
+//  cache line containing Address is invalidated. If Address + Length is not\r
+//  aligned on a cache line boundary, then the entire instruction cache line\r
+//  containing Address + Length -1 is invalidated. This function may choose to\r
+//  invalidate the entire instruction cache if that is more efficient than\r
+//  invalidating the specified range. If Length is 0, the no instruction cache\r
+//  lines are invalidated. Address is returned.\r
+//\r
+//  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
+//\r
+//  @param  Address The base address of the instruction cache lines to\r
+//                  invalidate. If the CPU is in a physical addressing mode, then\r
+//                  Address is a physical address. If the CPU is in a virtual\r
+//                  addressing mode, then Address is a virtual address.\r
+//\r
+//  @param  Length  The number of bytes to invalidate from the instruction cache.\r
+//\r
+//  @return Address\r
+//  \r
+//  VOID *\r
+//  EFIAPI\r
+//  IpfFlushCacheRange (\r
+//    IN      VOID                      *Address,\r
+//    IN      UINTN                     Length\r
+//    );\r
+//\r
+PROCEDURE_ENTRY (IpfFlushCacheRange)\r
+\r
+      NESTED_SETUP (5,8,0,0)\r
+            \r
+      mov         loc2 = ar.lc\r
+      \r
+      mov         loc3 = in0                  // Start address.\r
+      mov         loc4 = in1;;                // Length in bytes.\r
+      \r
+      cmp.eq  p6,p7 = loc4, r0;;               // If Length is zero then don't flush any cache\r
+      (p6)  br.spnt.many DoneFlushingC;;         \r
+      \r
+      add         loc4 = loc4,loc3 \r
+      mov         loc5 = 1;;\r
+      sub         loc4 = loc4, loc5 ;; // the End address to flush\r
+                                         \r
+      dep         loc3 = r0,loc3,0,5          \r
+      dep         loc4 = r0,loc4,0,5;;         \r
+      shr         loc3 = loc3,5             \r
+      shr         loc4 = loc4,5;;    // 32 byte cache line\r
+      \r
+      sub         loc4 = loc4,loc3;; // total flush count, It should be add 1 but \r
+                                     // the br.cloop will first execute one time \r
+      mov         loc3 = in0                  \r
+      mov         loc5 = 32      \r
+      mov         ar.lc = loc4;;\r
+\r
+StillFlushingC:\r
+      fc          loc3;; \r
+      sync.i;;\r
+      srlz.i;;\r
+      add         loc3 = loc5,loc3;;\r
+      br.cloop.sptk.few StillFlushingC;;\r
+\r
+DoneFlushingC:      \r
+      mov         ar.lc = loc2     \r
+      mov          r8   = in0       // return *Address\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (IpfFlushCacheRange)\r
+\r
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 (file)
index 0000000..873676f
--- /dev/null
@@ -0,0 +1,27 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   GetInterruptState.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   GlueGetInterruptState\r
+.type   GlueGetInterruptState, @function\r
+GlueGetInterruptState::\r
+        mov                 r8  = psr\r
+        extr.u              r8  = r8, 14, 1\r
+        br.ret.sptk.many    b0\r
+.endp   GlueGetInterruptState\r
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 (file)
index 0000000..4b5d7cb
--- /dev/null
@@ -0,0 +1,29 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   InterlockedCompareExchange32.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   InternalSyncCompareExchange32\r
+.type   InternalSyncCompareExchange32, @function\r
+InternalSyncCompareExchange32::\r
+        zxt4                r33 = r33\r
+        mov                 ar.ccv = r33\r
+        cmpxchg4.rel        r8  = [r32], r34\r
+        mf\r
+        br.ret.sptk.many    b0\r
+.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 (file)
index 0000000..b3d7b84
--- /dev/null
@@ -0,0 +1,28 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   InterlockedCompareExchange64.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   InternalSyncCompareExchange64\r
+.type   InternalSyncCompareExchange64, @function\r
+InternalSyncCompareExchange64::\r
+        mov                 ar.ccv = r33\r
+        cmpxchg8.rel        r8  = [r32], r34\r
+        mf\r
+        br.ret.sptk.many    b0\r
+.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 (file)
index 0000000..47f2f5a
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Non-existing.c\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  //\r
+  // This version of this function does not actually change the stack pointer\r
+  // This is to support compilation of CPU types that do not support assemblers\r
+  // such as EBC\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
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 (file)
index 0000000..d6b883e
--- /dev/null
@@ -0,0 +1,48 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   PalCallStatic.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   PalCallStatic\r
+.type   PalCallStatic, @function\r
+.regstk 5, 0, 0, 0\r
+PalCallStatic::\r
+        cmp.eq              p15 = in0, r0\r
+        mov                 r31 = in4\r
+        mov                 r8  = ip\r
+\r
+(p15)   mov                 in0 = ar.k5\r
+        add                 r8  = (_PalProcReturn - PalCallStatic), r8\r
+        mov                 r30 = in3\r
+\r
+        mov                 in4 = psr\r
+        mov                 in3 = b0\r
+        mov                 b7  = in0\r
+\r
+        rsm                 1 << 14                 // Disable interrupts\r
+        mov                 r29 = in2\r
+        mov                 r28 = in1\r
+\r
+        mov                 b0  = r8\r
+        br.cond.sptk.many   b7\r
+\r
+_PalProcReturn:\r
+        mov                 psr.l = in4\r
+        mov                 b0  = in3\r
+        br.ret.sptk.many    b0\r
+.endp   PalCallStatic\r
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 (file)
index 0000000..473c82e
--- /dev/null
@@ -0,0 +1,26 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   ReadItc.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   IpfReadItc\r
+.type   IpfReadItc, @function\r
+IpfReadItc::\r
+        mov                 r8  = ar.itc\r
+        br.ret.sptk.many    b0\r
+.endp   IpfReadItc\r
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 (file)
index 0000000..5ec5aba
--- /dev/null
@@ -0,0 +1,51 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   SwitchStack.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   AsmSwitchStackAndBackingStore\r
+.type   AsmSwitchStackAndBackingStore, @function\r
+.regstk 5, 0, 0, 0\r
+AsmSwitchStackAndBackingStore::\r
+        mov                 r14 = ar.rsc\r
+        movl                r2  = ~((((1 << 14) - 1) << 16) | 3)\r
+\r
+        mov                 r17 = in1\r
+        mov                 r18 = in2\r
+        and                 r2  = r14, r2\r
+\r
+        mov                 ar.rsc = r2\r
+        mov                 sp  = in3\r
+        mov                 r19 = in4\r
+\r
+        ld8.nt1             r16 = [in0], 8\r
+        ld8.nta             gp  = [in0]\r
+        mov                 r3  = -1\r
+\r
+        loadrs\r
+        mov                 ar.bspstore = r19\r
+        mov                 b7  = r16\r
+\r
+        alloc               r2  = ar.pfs, 0, 0, 2, 0\r
+        mov                 out0 = r17\r
+        mov                 out1 = r18\r
+\r
+        mov                 ar.rnat = r3\r
+        mov                 ar.rsc = r14\r
+        br.call.sptk.many   b0  = b7\r
+.endp   AsmSwitchStackAndBackingStore\r
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 (file)
index 0000000..e1bc578
--- /dev/null
@@ -0,0 +1,83 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Synchronization.c\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic increment of the 32-bit unsigned integer specified by\r
+  Value and returns the incremented value. The increment operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to increment.\r
+\r
+  @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncIncrement (\r
+  IN      volatile UINT32           *Value\r
+  )\r
+{\r
+  UINT32                            OriginalValue;\r
+\r
+  do {\r
+    OriginalValue = *Value;\r
+  } while (OriginalValue != InternalSyncCompareExchange32 (\r
+                              Value,\r
+                              OriginalValue,\r
+                              OriginalValue + 1\r
+                              ));\r
+  return OriginalValue + 1;\r
+}\r
+\r
+/**\r
+  Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+  Value and returns the decrement value. The decrement operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  @param  Value A pointer to the 32-bit value to decrement.\r
+\r
+  @return The decrement value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncDecrement (\r
+  IN      volatile UINT32           *Value\r
+  )\r
+{\r
+  UINT32                            OriginalValue;\r
+\r
+  do {\r
+    OriginalValue = *Value;\r
+  } while (OriginalValue != InternalSyncCompareExchange32 (\r
+                              Value,\r
+                              OriginalValue,\r
+                              OriginalValue - 1\r
+                              ));\r
+  return OriginalValue - 1;\r
+}\r
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 (file)
index 0000000..bcb3bb8
--- /dev/null
@@ -0,0 +1,249 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Unaligned.c\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Reads a 16-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 16-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+\r
+  @return *Uint16\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+ReadUnaligned16 (\r
+  IN      CONST UINT16              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return (UINT16)(((UINT8*)Buffer)[0] | (((UINT8*)Buffer)[1] << 8));\r
+}\r
+\r
+/**\r
+  Writes a 16-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 16-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+  @param  Value   16-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+WriteUnaligned16 (\r
+  OUT     UINT16                    *Buffer,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  ((UINT8*)Buffer)[0] = (UINT8)Value;\r
+  ((UINT8*)Buffer)[1] = (UINT8)(Value >> 8);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 24-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 24-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned24 (\r
+  IN      CONST UINT32              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return (UINT32)(\r
+            ReadUnaligned16 ((UINT16*)Buffer) |\r
+            (((UINT8*)Buffer)[2] << 16)\r
+            );\r
+}\r
+\r
+/**\r
+  Writes a 24-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 24-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+  @param  Value   24-bit value to write to Buffer.\r
+\r
+  @return The value written.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned24 (\r
+  OUT     UINT32                    *Buffer,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value);\r
+  *(UINT8*)((UINT16*)Buffer + 1) = (UINT8)(Value >> 16);\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 32-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+\r
+  @return *Uint32\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned32 (\r
+  IN      CONST UINT32              *Buffer\r
+  )\r
+{\r
+  UINT16  LowerBytes;\r
+  UINT16  HigherBytes;\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  LowerBytes  = ReadUnaligned16 ((UINT16*) Buffer);\r
+  HigherBytes = ReadUnaligned16 ((UINT16*) Buffer + 1);\r
+\r
+  return (UINT32) (LowerBytes | (HigherBytes << 16));\r
+}\r
+\r
+/**\r
+  Writes a 32-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 32-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+  @param  Value   32-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned32 (\r
+  OUT     UINT32                    *Buffer,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value);\r
+  WriteUnaligned16 ((UINT16*)Buffer + 1, (UINT16)(Value >> 16));\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 64-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 64-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+\r
+  @return *Uint64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+ReadUnaligned64 (\r
+  IN      CONST UINT64              *Buffer\r
+  )\r
+{\r
+  UINT32  LowerBytes;\r
+  UINT32  HigherBytes;\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  LowerBytes  = ReadUnaligned32 ((UINT32*) Buffer);\r
+  HigherBytes = ReadUnaligned32 ((UINT32*) Buffer + 1);\r
+\r
+  return (UINT64) (LowerBytes | LShiftU64 (HigherBytes, 32));\r
+}\r
+\r
+/**\r
+  Writes a 64-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 64-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+  @param  Value   64-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+WriteUnaligned64 (\r
+  OUT     UINT64                    *Buffer,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  WriteUnaligned32 ((UINT32*)Buffer, (UINT32)Value);\r
+  WriteUnaligned32 ((UINT32*)Buffer + 1, (UINT32)RShiftU64 (Value, 32));\r
+  return Value;\r
+}\r
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 (file)
index 0000000..1b3c84e
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  asm.h\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#ifndef _ASM_H\r
+#define _ASM_H\r
+\r
+#define TRUE  1\r
+#define FALSE 0\r
+#define PROCEDURE_ENTRY(name)   .##text;            \\r
+  .##type name, @function; \\r
+  .##proc name; \\r
+  name::\r
+\r
+#define PROCEDURE_EXIT(name)  .##endp name\r
+\r
+#endif // _ASM_H\r
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 (file)
index 0000000..a2a284e
--- /dev/null
@@ -0,0 +1,211 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  asm.h\r
+  \r
+Abstract: \r
+\r
+--*/\r
+\r
+#ifndef _IA64GEN_H\r
+#define _IA64GEN_H\r
+\r
+#define TT_UNAT           0\r
+#define C_PSR             0\r
+#define J_UNAT            0\r
+#define T_TYPE            0\r
+#define T_IPSR            0x8\r
+#define T_ISR             0x10\r
+#define T_IIP             0x18\r
+#define T_IFA             0x20\r
+#define T_IIPA            0x28\r
+#define T_IFS             0x30\r
+#define T_IIM             0x38\r
+#define T_RSC             0x40\r
+#define T_BSP             0x48\r
+#define T_BSPSTORE        0x50\r
+#define T_RNAT            0x58\r
+#define T_PFS             0x60\r
+#define T_KBSPSTORE       0x68\r
+#define T_UNAT            0x70\r
+#define T_CCV             0x78\r
+#define T_DCR             0x80\r
+#define T_PREDS           0x88\r
+#define T_NATS            0x90\r
+#define T_R1              0x98\r
+#define T_GP              0x98\r
+#define T_R2              0xa0\r
+#define T_R3              0xa8\r
+#define T_R4              0xb0\r
+#define T_R5              0xb8\r
+#define T_R6              0xc0\r
+#define T_R7              0xc8\r
+#define T_R8              0xd0\r
+#define T_R9              0xd8\r
+#define T_R10             0xe0\r
+#define T_R11             0xe8\r
+#define T_R12             0xf0\r
+#define T_SP              0xf0\r
+#define T_R13             0xf8\r
+#define T_R14             0x100\r
+#define T_R15             0x108\r
+#define T_R16             0x110\r
+#define T_R17             0x118\r
+#define T_R18             0x120\r
+#define T_R19             0x128\r
+#define T_R20             0x130\r
+#define T_R21             0x138\r
+#define T_R22             0x140\r
+#define T_R23             0x148\r
+#define T_R24             0x150\r
+#define T_R25             0x158\r
+#define T_R26             0x160\r
+#define T_R27             0x168\r
+#define T_R28             0x170\r
+#define T_R29             0x178\r
+#define T_R30             0x180\r
+#define T_R31             0x188\r
+#define T_F2              0x1f0\r
+#define T_F3              0x200\r
+#define T_F4              0x210\r
+#define T_F5              0x220\r
+#define T_F6              0x230\r
+#define T_F7              0x240\r
+#define T_F8              0x250\r
+#define T_F9              0x260\r
+#define T_F10             0x270\r
+#define T_F11             0x280\r
+#define T_F12             0x290\r
+#define T_F13             0x2a0\r
+#define T_F14             0x2b0\r
+#define T_F15             0x2c0\r
+#define T_F16             0x2d0\r
+#define T_F17             0x2e0\r
+#define T_F18             0x2f0\r
+#define T_F19             0x300\r
+#define T_F20             0x310\r
+#define T_F21             0x320\r
+#define T_F22             0x330\r
+#define T_F23             0x340\r
+#define T_F24             0x350\r
+#define T_F25             0x360\r
+#define T_F26             0x370\r
+#define T_F27             0x380\r
+#define T_F28             0x390\r
+#define T_F29             0x3a0\r
+#define T_F30             0x3b0\r
+#define T_F31             0x3c0\r
+#define T_FPSR            0x1e0\r
+#define T_B0              0x190\r
+#define T_B1              0x198\r
+#define T_B2              0x1a0\r
+#define T_B3              0x1a8\r
+#define T_B4              0x1b0\r
+#define T_B5              0x1b8\r
+#define T_B6              0x1c0\r
+#define T_B7              0x1c8\r
+#define T_EC              0x1d0\r
+#define T_LC              0x1d8\r
+#define J_NATS            0x8\r
+#define J_PFS             0x10\r
+#define J_BSP             0x18\r
+#define J_RNAT            0x20\r
+#define J_PREDS           0x28\r
+#define J_LC              0x30\r
+#define J_R4              0x38\r
+#define J_R5              0x40\r
+#define J_R6              0x48\r
+#define J_R7              0x50\r
+#define J_SP              0x58\r
+#define J_F2              0x60\r
+#define J_F3              0x70\r
+#define J_F4              0x80\r
+#define J_F5              0x90\r
+#define J_F16             0xa0\r
+#define J_F17             0xb0\r
+#define J_F18             0xc0\r
+#define J_F19             0xd0\r
+#define J_F20             0xe0\r
+#define J_F21             0xf0\r
+#define J_F22             0x100\r
+#define J_F23             0x110\r
+#define J_F24             0x120\r
+#define J_F25             0x130\r
+#define J_F26             0x140\r
+#define J_F27             0x150\r
+#define J_F28             0x160\r
+#define J_F29             0x170\r
+#define J_F30             0x180\r
+#define J_F31             0x190\r
+#define J_FPSR            0x1a0\r
+#define J_B0              0x1a8\r
+#define J_B1              0x1b0\r
+#define J_B2              0x1b8\r
+#define J_B3              0x1c0\r
+#define J_B4              0x1c8\r
+#define J_B5              0x1d0\r
+#define TRAP_FRAME_LENGTH 0x3d0\r
+#define C_UNAT            0x28\r
+#define C_NATS            0x30\r
+#define C_PFS             0x8\r
+#define C_BSPSTORE        0x10\r
+#define C_RNAT            0x18\r
+#define C_RSC             0x20\r
+#define C_PREDS           0x38\r
+#define C_LC              0x40\r
+#define C_DCR             0x48\r
+#define C_R1              0x50\r
+#define C_GP              0x50\r
+#define C_R4              0x58\r
+#define C_R5              0x60\r
+#define C_R6              0x68\r
+#define C_R7              0x70\r
+#define C_SP              0x78\r
+#define C_R13             0x80\r
+#define C_F2              0x90\r
+#define C_F3              0xa0\r
+#define C_F4              0xb0\r
+#define C_F5              0xc0\r
+#define C_F16             0xd0\r
+#define C_F17             0xe0\r
+#define C_F18             0xf0\r
+#define C_F19             0x100\r
+#define C_F20             0x110\r
+#define C_F21             0x120\r
+#define C_F22             0x130\r
+#define C_F23             0x140\r
+#define C_F24             0x150\r
+#define C_F25             0x160\r
+#define C_F26             0x170\r
+#define C_F27             0x180\r
+#define C_F28             0x190\r
+#define C_F29             0x1a0\r
+#define C_F30             0x1b0\r
+#define C_F31             0x1c0\r
+#define C_FPSR            0x1d0\r
+#define C_B0              0x1d8\r
+#define C_B1              0x1e0\r
+#define C_B2              0x1e8\r
+#define C_B3              0x1f0\r
+#define C_B4              0x1f8\r
+#define C_B5              0x200\r
+#define TT_R2             0x8\r
+#define TT_R3             0x10\r
+#define TT_R8             0x18\r
+#define TT_R9             0x20\r
+#define TT_R10            0x28\r
+#define TT_R11            0x30\r
+#define TT_R14            0x38\r
+\r
+#endif _IA64GEN_H\r
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 (file)
index 0000000..c0cea0b
--- /dev/null
@@ -0,0 +1,122 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   longjmp.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   InternalLongJump\r
+.type   InternalLongJump, @function\r
+.regstk 2, 0, 0, 0\r
+InternalLongJump::\r
+        add                 r10 = 0x10*20 + 8*14, in0\r
+        movl                r2  = ~((((1 << 14) - 1) << 16) | 3)\r
+\r
+        ld8.nt1             r14 = [r10], -8*2       // BSP, skip PFS\r
+        mov                 r15 = ar.bspstore       // BSPSTORE\r
+\r
+        ld8.nt1             r17 = [r10], -8         // UNAT after spill\r
+        mov                 r16 = ar.rsc            // RSC\r
+        cmp.leu             p6  = r14, r15\r
+\r
+        ld8.nt1             r18 = [r10], -8         // UNAT\r
+        ld8.nt1             r25 = [r10], -8         // b5\r
+        and                 r2  = r16, r2\r
+\r
+        ldf.fill.nt1        f2  = [in0], 0x10\r
+        ld8.nt1             r24 = [r10], -8         // b4\r
+        mov                 b5  = r25\r
+\r
+        mov                 ar.rsc = r2\r
+        ld8.nt1             r23 = [r10], -8         // b3\r
+        mov                 b4  = r24\r
+\r
+        ldf.fill.nt1        f3  = [in0], 0x10\r
+        mov                 ar.unat = r17\r
+(p6)    br.spnt.many        _skip_flushrs\r
+\r
+        flushrs\r
+        mov                 r15 = ar.bsp            // New BSPSTORE\r
+\r
+_skip_flushrs:\r
+        mov                 r31 = ar.rnat           // RNAT\r
+        loadrs\r
+\r
+        ldf.fill.nt1        f4  = [in0], 0x10\r
+        ld8.nt1             r22 = [r10], -8\r
+        dep                 r2  = -1, r14, 3, 6\r
+\r
+        ldf.fill.nt1        f5  = [in0], 0x10\r
+        ld8.nt1             r21 = [r10], -8\r
+        cmp.ltu             p6  = r2, r15\r
+\r
+        ld8.nt1             r20 = [r10], -0x10      // skip sp\r
+(p6)    ld8.nta             r31 = [r2]\r
+        mov                 b3  = r23\r
+\r
+        ldf.fill.nt1        f16 = [in0], 0x10\r
+        ld8.fill.nt1        r7  = [r10], -8\r
+        mov                 b2  = r22\r
+\r
+        ldf.fill.nt1        f17 = [in0], 0x10\r
+        ld8.fill.nt1        r6  = [r10], -8\r
+        mov                 b1  = r21\r
+\r
+        ldf.fill.nt1        f18 = [in0], 0x10\r
+        ld8.fill.nt1        r5  = [r10], -8\r
+        mov                 b0  = r20\r
+\r
+        ldf.fill.nt1        f19 = [in0], 0x10\r
+        ld8.fill.nt1        r4  = [r10], 8*13\r
+\r
+        ldf.fill.nt1        f20 = [in0], 0x10\r
+        ld8.nt1             r19 = [r10], 0x10       // PFS\r
+\r
+        ldf.fill.nt1        f21 = [in0], 0x10\r
+        ld8.nt1             r26 = [r10], 8          // Predicate\r
+        mov                 ar.pfs = r19\r
+\r
+        ldf.fill.nt1        f22 = [in0], 0x10\r
+        ld8.nt1             r27 = [r10], 8          // LC\r
+        mov                 pr  = r26, -1\r
+\r
+        ldf.fill.nt1        f23 = [in0], 0x10\r
+        ld8.nt1             r28 = [r10], -17*8 - 0x10\r
+        mov                 ar.lc = r27\r
+\r
+        ldf.fill.nt1        f24 = [in0], 0x10\r
+        ldf.fill.nt1        f25 = [in0], 0x10\r
+        mov                 r8  = in1\r
+\r
+        ldf.fill.nt1        f26 = [in0], 0x10\r
+        ldf.fill.nt1        f31 = [r10], -0x10\r
+\r
+        ldf.fill.nt1        f27 = [in0], 0x10\r
+        ldf.fill.nt1        f30 = [r10], -0x10\r
+\r
+        ldf.fill.nt1        f28 = [in0]\r
+        ldf.fill.nt1        f29 = [r10], 0x10*3 + 8*4\r
+\r
+        ld8.fill.nt1        sp  = [r10]\r
+        mov                 ar.unat = r18\r
+\r
+        mov                 ar.bspstore = r14\r
+        mov                 ar.rnat = r31\r
+\r
+        invala\r
+        mov                 ar.rsc = r16\r
+        br.ret.sptk         b0\r
+.endp\r
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 (file)
index 0000000..9032bce
--- /dev/null
@@ -0,0 +1,109 @@
+/// Copyright (c) 2004, Intel Corporation                                                         \r
+/// All rights reserved. This program and the accompanying materials                          \r
+/// are licensed and made available under the terms and conditions of the BSD License         \r
+/// which accompanies this distribution.  The full text of the license may be found at        \r
+/// http://opensource.org/licenses/bsd-license.php                                            \r
+///                                                                                           \r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+///\r
+/// Module Name:\r
+///\r
+///   setjmp.s\r
+///\r
+/// Abstract:\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.globl InternalAssertJumpBuffer\r
+.type   InternalAssertJumpBuffer, @function\r
+\r
+.proc   SetJump\r
+.type   SetJump, @function\r
+SetJump::\r
+        alloc               loc0 = ar.pfs, 1, 2, 1, 0\r
+        mov                 loc1 = b0\r
+        mov                 out0 = in0\r
+\r
+        brl.call.sptk.many  b0  = InternalAssertJumpBuffer\r
+\r
+        mov                 r14 = ar.unat\r
+        mov                 r15 = ar.bsp\r
+        add                 r10 = 0x10*20, in0\r
+\r
+        stf.spill.nta       [in0] = f2, 0x10\r
+        st8.spill.nta       [r10] = r4, 8\r
+        mov                 r21 = b1\r
+\r
+        stf.spill.nta       [in0] = f3, 0x10\r
+        st8.spill.nta       [r10] = r5, 8\r
+        mov                 r22 = b2\r
+\r
+        stf.spill.nta       [in0] = f4, 0x10\r
+        st8.spill.nta       [r10] = r6, 8\r
+        mov                 r23 = b3\r
+\r
+        stf.spill.nta       [in0] = f5, 0x10\r
+        st8.spill.nta       [r10] = r7, 8\r
+        mov                 r24 = b4\r
+\r
+        stf.spill.nta       [in0] = f16, 0x10\r
+        st8.spill.nta       [r10] = sp, 8\r
+        mov                 r25 = b5\r
+\r
+        stf.spill.nta       [in0] = f17, 0x10\r
+        st8.nta             [r10] = loc1, 8\r
+        mov                 r16 = pr\r
+\r
+        stf.spill.nta       [in0] = f18, 0x10\r
+        st8.nta             [r10] = r21, 8\r
+        mov                 r17 = ar.lc\r
+\r
+        stf.spill.nta       [in0] = f19, 0x10\r
+        st8.nta             [r10] = r22, 8\r
+\r
+        stf.spill.nta       [in0] = f20, 0x10\r
+        st8.nta             [r10] = r23, 8\r
+\r
+        stf.spill.nta       [in0] = f21, 0x10\r
+        st8.nta             [r10] = r24, 8\r
+\r
+        stf.spill.nta       [in0] = f22, 0x10\r
+        st8.nta             [r10] = r25, 8\r
+\r
+        stf.spill.nta       [in0] = f23, 0x10\r
+        mov                 r18 = ar.unat\r
+\r
+        stf.spill.nta       [in0] = f24, 0x10\r
+        st8.nta             [r10] = r14, 8          // UNAT\r
+\r
+        stf.spill.nta       [in0] = f25, 0x10\r
+        st8.nta             [r10] = r18, 8          // UNAT after spill\r
+\r
+        stf.spill.nta       [in0] = f26, 0x10\r
+        st8.nta             [r10] = loc0, 8         // PFS\r
+\r
+        stf.spill.nta       [in0] = f27, 0x10\r
+        st8.nta             [r10] = r15, 8          // BSP\r
+        mov                 r8  = 0\r
+\r
+        stf.spill.nta       [in0] = f28, 0x10\r
+        mov                 r19 = ar.fpsr\r
+\r
+        stf.spill.nta       [in0] = f29, 0x10\r
+        st8.nta             [r10] = r16, 8          // PR\r
+        mov                 ar.pfs = loc0\r
+\r
+        stf.spill.nta       [in0] = f30, 0x10\r
+        st8.nta             [r10] = r17, 8          // LC\r
+        mov                 b0  = loc1\r
+\r
+        stf.spill.nta       [in0] = f31, 0x10\r
+        st8.nta             [r10] = r19             // FPSR\r
+\r
+        mov                 ar.unat = r14\r
+        br.ret.sptk         b0\r
+.endp   SetJump\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c
new file mode 100644 (file)
index 0000000..81ba6e0
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LRotU32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r
+  with the high bits that were rotated.\r
+\r
+  This function rotates the 32-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 31, then ASSERT().\r
+\r
+  @param  Operand The 32-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+LRotU32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return (Operand << Count) | (Operand >> (32 - Count));\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c
new file mode 100644 (file)
index 0000000..ba919b2
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LRotU64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r
+  with the high bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+LRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return InternalMathLRotU64 (Operand, Count);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c
new file mode 100644 (file)
index 0000000..163fb30
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LShiftU64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r
+  with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are set to zero. The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift left.\r
+  @param  Count   The number of bits to shift left.\r
+\r
+  @return Operand << Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueLShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return InternalMathLShiftU64 (Operand, Count);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c
new file mode 100644 (file)
index 0000000..6c680d6
--- /dev/null
@@ -0,0 +1,471 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LinkedList.c\r
+  \r
+Abstract: \r
+\r
+  Linked List Library Functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Worker function that locates the Node in the List\r
+\r
+  By searching the List, finds the location of the Node in List. At the same time,\r
+  verifies the validity of this list.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If List->ForwardLink is NULL, then ASSERT().\r
+  If List->backLink is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT();\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  List  A pointer to a node in a linked list.\r
+  @param  Node  A pointer to one nod.\r
+\r
+  @retval TRUE   Node is in List\r
+  @retval FALSE  Node isn't in List, or List is invalid\r
+\r
+**/\r
+BOOLEAN\r
+IsNodeInList (\r
+  IN      CONST LIST_ENTRY      *List,\r
+  IN      CONST LIST_ENTRY      *Node\r
+  )\r
+{\r
+  UINTN                         Count;\r
+  CONST LIST_ENTRY              *Ptr;\r
+  BOOLEAN                       Found;\r
+\r
+  //\r
+  // Test the validity of List and Node\r
+  //\r
+  ASSERT (List != NULL);\r
+  ASSERT (List->ForwardLink != NULL);\r
+  ASSERT (List->BackLink != NULL);\r
+  ASSERT (Node != NULL);\r
+\r
+  Count = PcdGet32 (PcdMaximumLinkedListLength);\r
+\r
+  Ptr = List;\r
+  do {\r
+    Ptr = Ptr->ForwardLink;\r
+    Count--;\r
+  } while ((Ptr != List) && (Ptr != Node) && (Count > 0));\r
+  Found = (BOOLEAN)(Ptr == Node);\r
+\r
+  if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {\r
+    while ((Count > 0) && (Ptr != List)) {\r
+      Ptr = Ptr->ForwardLink;\r
+      Count--;\r
+    }\r
+    ASSERT (Count > 0);\r
+  }\r
+\r
+  return Found;\r
+}\r
+\r
+/**\r
+  Initializes the head node of a doubly linked list, and returns the pointer to\r
+  the head node of the doubly linked list.\r
+\r
+  Initializes the forward and backward links of a new linked list. After\r
+  initializing a linked list with this function, the other linked list\r
+  functions may be used to add and remove nodes from the linked list. It is up\r
+  to the caller of this function to allocate the memory for ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a new doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInitializeListHead (\r
+  IN OUT  LIST_ENTRY            *List\r
+  )\r
+\r
+{\r
+  ASSERT (List != NULL);\r
+\r
+  List->ForwardLink = List;\r
+  List->BackLink = List;\r
+  return List;\r
+}\r
+\r
+/**\r
+  Adds a node to the beginning of a doubly linked list, and returns the pointer\r
+  to the head node of the doubly linked list.\r
+\r
+  Adds the node Entry at the beginning of the doubly linked list denoted by\r
+  ListHead, and returns ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If Entry is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+  @param  Entry     A pointer to a node that is to be inserted at the beginning\r
+                    of a doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInsertHeadList (\r
+  IN OUT  LIST_ENTRY            *List,\r
+  IN OUT  LIST_ENTRY            *Entry\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Entry is not one of the nodes of List\r
+  //\r
+  ASSERT (!IsNodeInList (List, Entry));\r
+\r
+  Entry->ForwardLink = List->ForwardLink;\r
+  Entry->BackLink = List;\r
+  Entry->ForwardLink->BackLink = Entry;\r
+  List->ForwardLink = Entry;\r
+  return List;\r
+}\r
+\r
+/**\r
+  Adds a node to the end of a doubly linked list, and returns the pointer to\r
+  the head node of the doubly linked list.\r
+\r
+  Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r
+  and returns ListHead.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If Entry is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  of nodes in ListHead, including the ListHead node, is greater than or\r
+  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+  @param  Entry     A pointer to a node that is to be added at the end of the\r
+                    doubly linked list.\r
+\r
+  @return ListHead\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueInsertTailList (\r
+  IN OUT  LIST_ENTRY            *List,\r
+  IN OUT  LIST_ENTRY            *Entry\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Entry is not one of the nodes of List\r
+  //\r
+  ASSERT (!IsNodeInList (List, Entry));\r
+\r
+  Entry->ForwardLink = List;\r
+  Entry->BackLink = List->BackLink;\r
+  Entry->BackLink->ForwardLink = Entry;\r
+  List->BackLink = Entry;\r
+  return List;\r
+}\r
+\r
+/**\r
+  Retrieves the first node of a doubly linked list.\r
+\r
+  Returns the first node of a doubly linked list. List must have been\r
+  initialized with InitializeListHead(). If List is empty, then NULL is\r
+  returned.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+\r
+  @return The first node of a doubly linked list.\r
+  @retval NULL  The list is empty.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueGetFirstNode (\r
+  IN CONST LIST_ENTRY  *List\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long\r
+  //\r
+  ASSERT (IsNodeInList (List, List));\r
+\r
+  return List->ForwardLink;\r
+}\r
+\r
+/**\r
+  Retrieves the next node of a doubly linked list.\r
+\r
+  Returns the node of a doubly linked list that follows Node. List must have\r
+  been initialized with InitializeListHead(). If List is empty, then List is\r
+  returned.\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
+  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If Node is not a node in List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @return Pointer to the next node if one exists. Otherwise a null value which\r
+          is actually List is returned.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueGetNextNode (\r
+  IN CONST LIST_ENTRY  *List,\r
+  IN CONST LIST_ENTRY  *Node\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Node is one of the nodes of List\r
+  //\r
+  ASSERT (IsNodeInList (List, Node));\r
+\r
+  return Node->ForwardLink;\r
+}\r
+\r
+/**\r
+  Checks to see if a doubly linked list is empty or not.\r
+\r
+  Checks to see if the doubly linked list is empty. If the linked list contains\r
+  zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r
+\r
+  If ListHead is NULL, then ASSERT().\r
+  If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  ListHead  A pointer to the head node of a doubly linked list.\r
+\r
+  @retval TRUE  The linked list is empty.\r
+  @retval FALSE The linked list is not empty.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsListEmpty (\r
+  IN      CONST LIST_ENTRY      *List\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long\r
+  //\r
+  ASSERT (IsNodeInList (List, List));\r
+\r
+  return (BOOLEAN)(List->ForwardLink == List);\r
+}\r
+\r
+/**\r
+  Determines if a node in a doubly linked list is null.\r
+\r
+  Returns FALSE if Node is one of the nodes in the doubly linked list specified\r
+  by List. Otherwise, TRUE is returned. List must have been initialized with\r
+  InitializeListHead().\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+  If Node is not a node in List and Node is not equal to List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @retval TRUE  Node is one of the nodes in the doubly linked list.\r
+  @retval FALSE Node is not one of the nodes in the doubly linked list.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsNull (\r
+  IN      CONST LIST_ENTRY      *List,\r
+  IN      CONST LIST_ENTRY      *Node\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Node is one of the nodes of List\r
+  //\r
+  ASSERT (IsNodeInList (List, Node));\r
+\r
+  return (BOOLEAN)(Node == List);\r
+}\r
+\r
+/**\r
+  Determines if a node the last node in a doubly linked list.\r
+\r
+  Returns TRUE if Node is the last node in the doubly linked list specified by\r
+  List. Otherwise, FALSE is returned. List must have been initialized with\r
+  InitializeListHead().\r
+\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  in List, including the List node, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+  If Node is not a node in List, then ASSERT().\r
+\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
+\r
+  @retval TRUE  Node is the last node in the linked list.\r
+  @retval FALSE Node is not the last node in the linked list.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsNodeAtEnd (\r
+  IN      CONST LIST_ENTRY      *List,\r
+  IN      CONST LIST_ENTRY      *Node\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Node is one of the nodes of List\r
+  //\r
+  ASSERT (IsNodeInList (List, Node));\r
+\r
+  return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node);\r
+}\r
+\r
+/**\r
+  Swaps the location of two nodes in a doubly linked list, and returns the\r
+  first node after the swap.\r
+\r
+  If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r
+  Otherwise, the location of the FirstEntry node is swapped with the location\r
+  of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r
+  same double linked list as FirstEntry and that double linked list must have\r
+  been initialized with InitializeListHead(). SecondEntry is returned after the\r
+  nodes are swapped.\r
+\r
+  If FirstEntry is NULL, then ASSERT().\r
+  If SecondEntry is NULL, then ASSERT().\r
+  If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing the FirstEntry and SecondEntry nodes, including\r
+  the FirstEntry and SecondEntry nodes, is greater than or equal to\r
+  PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  FirstEntry  A pointer to a node in a linked list.\r
+  @param  SecondEntry A pointer to another node in the same linked list.\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueSwapListEntries (\r
+  IN OUT  LIST_ENTRY            *FirstEntry,\r
+  IN OUT  LIST_ENTRY            *SecondEntry\r
+  )\r
+{\r
+  LIST_ENTRY                    *Ptr;\r
+\r
+  if (FirstEntry == SecondEntry) {\r
+    return SecondEntry;\r
+  }\r
+\r
+  //\r
+  // ASSERT Entry1 and Entry2 are in the same linked list\r
+  //\r
+  ASSERT (IsNodeInList (FirstEntry, SecondEntry));\r
+\r
+  //\r
+  // Ptr is the node pointed to by FirstEntry->ForwardLink\r
+  //\r
+  Ptr = RemoveEntryList (FirstEntry);\r
+\r
+  //\r
+  // If FirstEntry immediately follows SecondEntry, FirstEntry willl be placed\r
+  // immediately in front of SecondEntry\r
+  //\r
+  if (Ptr->BackLink == SecondEntry) {\r
+    return InsertTailList (SecondEntry, FirstEntry);\r
+  }\r
+\r
+  //\r
+  // Ptr == SecondEntry means SecondEntry immediately follows FirstEntry,\r
+  // then there are no further steps necessary\r
+  //\r
+  if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) {\r
+    return Ptr;\r
+  }\r
+\r
+  //\r
+  // Move SecondEntry to the front of Ptr\r
+  //\r
+  RemoveEntryList (SecondEntry);\r
+  InsertTailList (Ptr, SecondEntry);\r
+  return SecondEntry;\r
+}\r
+\r
+/**\r
+  Removes a node from a doubly linked list, and returns the node that follows\r
+  the removed node.\r
+\r
+  Removes the node Entry from a doubly linked list. It is up to the caller of\r
+  this function to release the memory used by this node if that is required. On\r
+  exit, the node following Entry in the doubly linked list is returned. If\r
+  Entry is the only node in the linked list, then the head node of the linked\r
+  list is returned.\r
+\r
+  If Entry is NULL, then ASSERT().\r
+  If Entry is the head node of an empty list, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
+  linked list containing Entry, including the Entry node, is greater than\r
+  or equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+  @param  Entry A pointer to a node in a linked list\r
+\r
+  @return Entry\r
+\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GlueRemoveEntryList (\r
+  IN      CONST LIST_ENTRY      *Entry\r
+  )\r
+{\r
+  ASSERT (!IsListEmpty (Entry));\r
+\r
+  Entry->ForwardLink->BackLink = Entry->BackLink;\r
+  Entry->BackLink->ForwardLink = Entry->ForwardLink;\r
+  return Entry->ForwardLink;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c
new file mode 100644 (file)
index 0000000..7ca6ab9
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LongJump.c\r
+  \r
+Abstract: \r
+\r
+  Long Jump functions\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Restores the CPU context that was saved with SetJump().\r
+\r
+  Restores the CPU context from the buffer specified by JumpBuffer.\r
+  This function never returns to the caller.\r
+  Instead is resumes execution based on the state of JumpBuffer.\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+  If Value is 0, then ASSERT().\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+  @param  Value         The value to return when the SetJump() context is restored.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LongJump (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+  IN      UINTN                     Value\r
+  )\r
+{\r
+  InternalAssertJumpBuffer (JumpBuffer);\r
+  ASSERT (Value != 0);\r
+\r
+  InternalLongJump (JumpBuffer, Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c
new file mode 100644 (file)
index 0000000..eb03215
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LowBitSet32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the bit position of the lowest bit set in a 32-bit value.\r
+\r
+  This function computes the bit position of the lowest bit set in the 32-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 31 is returned.\r
+\r
+  @param  Operand The 32-bit operand to evaluate.\r
+\r
+  @return Position of the lowest bit set in Operand if found.\r
+  @retval -1 Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+LowBitSet32 (\r
+  IN      UINT32                    Operand\r
+  )\r
+{\r
+  INTN                              BitIndex;\r
+\r
+  if (Operand == 0) {\r
+    return -1;\r
+  }\r
+\r
+  for (BitIndex = 0; (Operand & 1) == 0; BitIndex++, Operand >>= 1);\r
+  return BitIndex;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c
new file mode 100644 (file)
index 0000000..1330c73
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  LowBitSet64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the bit position of the lowest bit set in a 64-bit value.\r
+\r
+  This function computes the bit position of the lowest bit set in the 64-bit\r
+  value specified by Operand. If Operand is zero, then -1 is returned.\r
+  Otherwise, a value between 0 and 63 is returned.\r
+\r
+  @param  Operand The 64-bit operand to evaluate.\r
+\r
+  @return Position of the lowest bit set in Operand if found.\r
+  @retval -1  Operand is zero.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+LowBitSet64 (\r
+  IN      UINT64                    Operand\r
+  )\r
+{\r
+  INTN                              BitIndex;\r
+\r
+  if (Operand == 0) {\r
+    return -1;\r
+  }\r
+\r
+  for (BitIndex = 0;\r
+       (Operand & 1) == 0;\r
+       BitIndex++, Operand = RShiftU64 (Operand, 1));\r
+  return BitIndex;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c
new file mode 100644 (file)
index 0000000..9ca5e0f
--- /dev/null
@@ -0,0 +1,377 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Match64.c\r
+  \r
+Abstract: \r
+\r
+  Leaf math worker functions that require 64-bit arithmetic support from the\r
+  compiler.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift left.\r
+  @param  Count   The number of bits to shift left.\r
+\r
+  @return Operand << Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathLShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  return Operand << Count;\r
+}\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
+  are filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to zero. The shifted value is returned.\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathRShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  return Operand >> Count;\r
+}\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
+  are filled with original integer's bit 63. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to bit 63 of Operand.  The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand arithmetically shifted right by Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathARShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  INTN  TestValue;\r
+\r
+  //\r
+  // Test if this compiler supports arithmetic shift\r
+  //\r
+  TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));\r
+  if (TestValue == -1) {\r
+    //\r
+    // Arithmetic shift is supported\r
+    //\r
+    return (UINT64)((INT64)Operand >> Count);\r
+  }\r
+\r
+  //\r
+  // Arithmetic is not supported\r
+  //\r
+  return (Operand >> Count) |\r
+         ((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0);\r
+}\r
+\r
+\r
+/**\r
+  Rotates a 64-bit integer left between 0 and 63 bits, filling\r
+  the low bits with the high bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the left by Count bits. The\r
+  low Count bits are fill with the high Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate left.\r
+  @param  Count   The number of bits to rotate left.\r
+\r
+  @return Operand <<< Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathLRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  return (Operand << Count) | (Operand >> (64 - Count));\r
+}\r
+\r
+/**\r
+  Rotates a 64-bit integer right between 0 and 63 bits, filling\r
+  the high bits with the high low bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  @param  Operand The 64-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathRRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  return (Operand >> Count) | (Operand << (64 - Count));\r
+}\r
+\r
+/**\r
+  Switches the endianess of a 64-bit integer.\r
+\r
+  This function swaps the bytes in a 64-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 64-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathSwapBytes64 (\r
+  IN      UINT64                    Operand\r
+  )\r
+{\r
+  UINT64  LowerBytes;\r
+  UINT64  HigherBytes;\r
+\r
+  LowerBytes  = (UINT64) SwapBytes32 ((UINT32) Operand);\r
+  HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32));\r
+\r
+  return (LowerBytes << 32 | HigherBytes);\r
+}\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 32-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathMultU64x32 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT32                    Multiplier\r
+  )\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
+  and generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 64-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathMultU64x64 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT64                    Multiplier\r
+  )\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
+  function returns the 64-bit unsigned quotient.\r
+\r
+   @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  )\r
+{\r
+  return Dividend / Divisor;\r
+}\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer\r
+  and generates a 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 32-bit remainder. This function\r
+  returns the 32-bit unsigned remainder.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend % Divisor\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalMathModU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  )\r
+{\r
+  return (UINT32)(Dividend % Divisor);\r
+}\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+  @param  Remainder A pointer to a 32-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivRemU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor,\r
+  OUT     UINT32                    *Remainder  OPTIONAL\r
+  )\r
+{\r
+  if (Remainder != NULL) {\r
+    *Remainder = (UINT32)(Dividend % Divisor);\r
+  }\r
+  return Dividend / Divisor;\r
+}\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 64-bit unsigned integer and\r
+  generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 64-bit unsigned value.\r
+  @param  Remainder A pointer to a 64-bit unsigned value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalMathDivRemU64x64 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT64                    Divisor,\r
+  OUT     UINT64                    *Remainder  OPTIONAL\r
+  )\r
+{\r
+  if (Remainder != NULL) {\r
+    *Remainder = Dividend % Divisor;\r
+  }\r
+  return Dividend / Divisor;\r
+}\r
+\r
+/**\r
+  Divides a 64-bit signed integer by a 64-bit signed integer and\r
+  generates a  64-bit signed result and a optional 64-bit signed remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 64-bit\r
+  unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
+  is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
+  This function returns the 64-bit unsigned quotient.\r
+\r
+  @param  Dividend  A 64-bit signed value.\r
+  @param  Divisor   A 64-bit signed value.\r
+  @param  Remainder A pointer to a 64-bit signed value. This parameter is\r
+                    optional and may be NULL.\r
+\r
+  @return Dividend / Divisor\r
+\r
+**/\r
+INT64\r
+InternalMathDivRemS64x64 (\r
+  IN      INT64                     Dividend,\r
+  IN      INT64                     Divisor,\r
+  OUT     INT64                     *Remainder  OPTIONAL\r
+  )\r
+{\r
+  if (Remainder != NULL) {\r
+    *Remainder = Dividend % Divisor;\r
+  }\r
+  return Dividend / Divisor;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c
new file mode 100644 (file)
index 0000000..22824f2
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  ModU64x32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
+  a 32-bit unsigned remainder.\r
+\r
+  This function divides the 64-bit unsigned value Dividend by the 32-bit\r
+  unsigned value Divisor and generates a 32-bit remainder. This function\r
+  returns the 32-bit unsigned remainder.\r
+\r
+  If Divisor is 0, then ASSERT().\r
+\r
+  @param  Dividend  A 64-bit unsigned value.\r
+  @param  Divisor   A 32-bit unsigned value.\r
+\r
+  @return Dividend % Divisor\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ModU64x32 (\r
+  IN      UINT64                    Dividend,\r
+  IN      UINT32                    Divisor\r
+  )\r
+{\r
+  ASSERT (Divisor != 0);\r
+  return InternalMathModU64x32 (Dividend, Divisor);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
new file mode 100644 (file)
index 0000000..780bfe5
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  MultS64x64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r
+  64-bit signed result.\r
+\r
+  This function multiples the 64-bit signed value Multiplicand by the 64-bit\r
+  signed value Multiplier and generates a 64-bit signed result. This 64-bit\r
+  signed result is returned.\r
+\r
+  If the result overflows, then ASSERT().\r
+\r
+  @param  Multiplicand  A 64-bit signed value.\r
+  @param  Multiplier    A 64-bit signed value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+INT64\r
+EFIAPI\r
+MultS64x64 (\r
+  IN      INT64                     Multiplicand,\r
+  IN      INT64                     Multiplier\r
+  )\r
+{\r
+  return (INT64)MultU64x64 (Multiplicand, Multiplier);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c
new file mode 100644 (file)
index 0000000..f9f3a28
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  MultU64x32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 32-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueMultU64x32 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT32                    Multiplier\r
+  )\r
+{\r
+  UINT64                            Result;\r
+\r
+  Result = InternalMathMultU64x32 (Multiplicand, Multiplier);\r
+\r
+  return Result;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c
new file mode 100644 (file)
index 0000000..c8888bc
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  MultU64x64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r
+  generates a 64-bit unsigned result.\r
+\r
+  This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
+  unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
+  bit unsigned result is returned.\r
+\r
+  @param  Multiplicand  A 64-bit unsigned value.\r
+  @param  Multiplier    A 64-bit unsigned value.\r
+\r
+  @return Multiplicand * Multiplier\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MultU64x64 (\r
+  IN      UINT64                    Multiplicand,\r
+  IN      UINT64                    Multiplier\r
+  )\r
+{\r
+  UINT64                            Result;\r
+\r
+  Result = InternalMathMultU64x64 (Multiplicand, Multiplier);\r
+\r
+  return Result;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c
new file mode 100644 (file)
index 0000000..a68df78
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  RRotU32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r
+  with the low bits that were rotated.\r
+\r
+  This function rotates the 32-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 31, then ASSERT().\r
+\r
+  @param  Operand The 32-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+RRotU32 (\r
+  IN      UINT32                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return (Operand >> Count) | (Operand << (32 - Count));\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c
new file mode 100644 (file)
index 0000000..18b2482
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  RRotU64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r
+  with the high low bits that were rotated.\r
+\r
+  This function rotates the 64-bit value Operand to the right by Count bits.\r
+  The high Count bits are fill with the low Count bits of Operand. The rotated\r
+  value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to rotate right.\r
+  @param  Count   The number of bits to rotate right.\r
+\r
+  @return Operand >>> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+RRotU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return InternalMathRRotU64 (Operand, Count);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c
new file mode 100644 (file)
index 0000000..ee29680
--- /dev/null
@@ -0,0 +1,49 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  RShiftU64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r
+  filled with zeros. The shifted value is returned.\r
+\r
+  This function shifts the 64-bit value Operand to the right by Count bits. The\r
+  high Count bits are set to zero. The shifted value is returned.\r
+\r
+  If Count is greater than 63, then ASSERT().\r
+\r
+  @param  Operand The 64-bit operand to shift right.\r
+  @param  Count   The number of bits to shift right.\r
+\r
+  @return Operand >> Count\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GlueRShiftU64 (\r
+  IN      UINT64                    Operand,\r
+  IN      UINTN                     Count\r
+  )\r
+{\r
+  ASSERT (Count < sizeof (Operand) * 8);\r
+  return InternalMathRShiftU64 (Operand, Count);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c
new file mode 100644 (file)
index 0000000..b1bf185
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SetJump.c\r
+  \r
+Abstract: \r
+\r
+  Internal ASSERT () functions for SetJump.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Worker function that checks ASSERT condition for JumpBuffer\r
+\r
+  Checks ASSERT condition for JumpBuffer.\r
+\r
+  If JumpBuffer is NULL, then ASSERT().\r
+  If JumpBuffer is not aligned on a BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT\r
+  boundary, then ASSERT().\r
+\r
+  @param  JumpBuffer    A pointer to CPU context buffer.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalAssertJumpBuffer (\r
+  IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+  )\r
+{\r
+  ASSERT (JumpBuffer != NULL);\r
+\r
+  ASSERT (((UINTN)JumpBuffer & ((BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT - 1) >> 8)) == 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c
new file mode 100644 (file)
index 0000000..0330923
--- /dev/null
@@ -0,0 +1,2077 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  String.c\r
+  \r
+Abstract: \r
+\r
+  Unicode string primatives.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
+  string and returns the new Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destiantion\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  )\r
+{\r
+  CHAR16                            *ReturnValue;\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+  ASSERT (((UINTN) Destination & 0x01) == 0);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r
+\r
+  ReturnValue = Destination;\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated Unicode string with a maximum length to another\r
+  Null-terminated Unicode string with a maximum length and returns the new\r
+  Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. At most, Length Unicode\r
+  characters are copied from Source to Destination. If Length is 0, then\r
+  Destination is returned unmodified. If Length is greater that the number of\r
+  Unicode characters in Source, then Destination is padded with Null Unicode\r
+  characters. If Source and Destination overlap, then the results are\r
+  undefined.\r
+\r
+  If Length > 0 and Destination is NULL, then ASSERT().\r
+  If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrnCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  CHAR16                            *ReturnValue;\r
+\r
+  if (Length == 0) {\r
+    return Destination;\r
+  }\r
+\r
+  //\r
+  // Destination cannot be NULL if Length is not zero\r
+  //\r
+  ASSERT (Destination != NULL);\r
+  ASSERT (((UINTN) Destination & 0x01) == 0);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  // Q: Does Source have to be NULL-terminated?\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) >= Length);\r
+\r
+  ReturnValue = Destination;\r
+\r
+  while ((*Source != L'\0') && (Length > 0)) {\r
+    *(Destination++) = *(Source++);\r
+    Length--;\r
+  }\r
+\r
+  ZeroMem (Destination, Length * sizeof (*Destination));\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Returns the length of a Null-terminated Unicode string.\r
+\r
+  This function returns the number of Unicode characters in the Null-terminated\r
+  Unicode string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueStrLen (\r
+  IN      CONST CHAR16              *String\r
+  )\r
+{\r
+  UINTN                             Length;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+\r
+  for (Length = 0; *String != L'\0'; String++, Length++) {\r
+    //\r
+    // If PcdMaximumUnicodeStringLength is not zero,\r
+    // length should not more than PcdMaximumUnicodeStringLength\r
+    //\r
+    if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+      ASSERT (Length < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+    }\r
+  }\r
+  return Length;\r
+}\r
+\r
+/**\r
+  Returns the size of a Null-terminated Unicode string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated Unicode\r
+  string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueStrSize (\r
+  IN      CONST CHAR16              *String\r
+  )\r
+{\r
+  return (StrLen (String) + 1) * sizeof (*String);\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated Unicode strings, and returns the difference\r
+  between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched Unicode character in SecondString subtracted from the first\r
+  mismatched Unicode character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueStrCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings are less long than PcdMaximumUnicodeStringLength\r
+  //\r
+  ASSERT (StrSize (FirstString) != 0);\r
+  ASSERT (StrSize (SecondString) != 0);\r
+\r
+  while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {\r
+    FirstString++;\r
+    SecondString++;\r
+  }\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated Unicode strings with maximum lengths, and\r
+  returns the difference between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. At most, Length Unicode\r
+  characters will be compared. If Length is 0, then 0 is returned. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched Unicode character in SecondString\r
+  subtracted from the first mismatched Unicode character in FirstString.\r
+\r
+  If Length > 0 and FirstString is NULL, then ASSERT().\r
+  If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If Length > 0 and SecondString is NULL, then ASSERT().\r
+  If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+  @param  Length        Maximum number of Unicode characters to compare.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueStrnCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // ASSERT both strings are less long than PcdMaximumUnicodeStringLength.\r
+  // Length tests are performed inside StrLen().\r
+  //\r
+  ASSERT (StrSize (FirstString) != 0);\r
+  ASSERT (StrSize (SecondString) != 0);\r
+\r
+  while ((*FirstString != L'\0') &&\r
+         (*FirstString == *SecondString) &&\r
+         (Length > 1)) {\r
+    FirstString++;\r
+    SecondString++;\r
+    Length--;\r
+  }\r
+\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated Unicode string to another Null-terminated\r
+  Unicode string, and returns the concatenated Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination. The Null-terminated concatenated\r
+  Unicode String is returned. If Source and Destination overlap, then the\r
+  results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
+  and Source results in a Unicode string with more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  )\r
+{\r
+  StrCpy (Destination + StrLen (Destination), Source);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  // PcdMaximumUnicodeStringLength is tested inside StrLen().\r
+  //\r
+  ASSERT (StrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated Unicode string with a maximum length to the\r
+  end of another Null-terminated Unicode string, and returns the concatenated\r
+  Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination, and Destination is returned. At\r
+  most, Length Unicode characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length > 0 and Source is NULL, then ASSERT().\r
+  If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
+  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
+  and Source results in a Unicode string with more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+GlueStrnCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  StrnCpy (Destination + StrLen (Destination), Source, Length);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  // PcdMaximumUnicodeStringLength is tested inside StrLen().\r
+  //\r
+  ASSERT (StrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Returns the first occurance of a Null-terminated Unicode sub-string \r
+  in a Null-terminated Unicode string.\r
+\r
+  This function scans the contents of the Null-terminated Unicode string \r
+  specified by String and returns the first occurrence of SearchString.  \r
+  If SearchString is not found in String, then NULL is returned.  If \r
+  the length of SearchString is zero, then String is \r
+  returned.\r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+  If SearchString is NULL, then ASSERT().\r
+  If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and SearchString \r
+  or String contains more than PcdMaximumUnicodeStringLength Unicode \r
+  characters not including the Null-terminator, then ASSERT().\r
+\r
+  @param  String                                 Pointer to a Null-terminated Unicode string.\r
+  @param  SearchString Pointer to a Null-terminated Unicode string to search for.\r
+\r
+  @retval NULL            If the SearchString does not appear in String.\r
+  @retval !NULL           If there is a match.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrStr (\r
+  IN      CONST CHAR16               *String,\r
+  IN      CONST CHAR16               *SearchString\r
+  )\r
+{\r
+  CONST CHAR16 *FirstMatch;\r
+  CONST CHAR16 *SearchStringTmp;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (SearchString != NULL);\r
+  ASSERT (((UINTN) SearchString & 0x01) == 0);\r
+\r
+  //\r
+  // If PcdMaximumUnicodeStringLength is not zero,\r
+  // length of String should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+    ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  }\r
+\r
+  //\r
+  // If PcdMaximumUnicodeStringLength is not zero,\r
+  // length of SearchString should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+    ASSERT (StrLen (SearchString) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
+  while (*String != '\0') {\r
+    SearchStringTmp = SearchString;\r
+    FirstMatch = String;\r
+    \r
+    while ((*String == *SearchStringTmp) \r
+            && (*SearchStringTmp != '\0') \r
+            && (*String != '\0')) {\r
+      String++;\r
+      SearchStringTmp++;\r
+    } \r
+    \r
+    if (*SearchStringTmp == '\0') {\r
+      return (CHAR16 *) FirstMatch;\r
+    }\r
+\r
+    if (SearchStringTmp == SearchString) {\r
+      //\r
+      // If no character from SearchString match,\r
+      // move the pointer to the String under search\r
+      // by one character.\r
+      //\r
+      String++;\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Check if a Unicode character is a decimal character.\r
+\r
+  This internal function checks if a Unicode character is a \r
+  decimal character. The valid decimal character is from\r
+  L'0' to L'9'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a decmial character.\r
+  @retval FALSE Otherwise.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+InternalIsDecimalDigitCharacter (\r
+  IN      CHAR16                    Char\r
+  )\r
+{\r
+  return (BOOLEAN) (Char >= L'0' && Char <= L'9');\r
+}\r
+\r
+/**\r
+  Convert a Unicode character to upper case only if \r
+  it maps to a valid small-case ASCII character.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid small-case ASII character, i.e.\r
+  L'a' to L'z'. For other Unicode character, the input character\r
+  is returned directly.\r
+\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @retval LowerCharacter   If the Char is with range L'a' to L'z'.\r
+  @retval Unchanged        Otherwise.\r
+\r
+**/\r
+STATIC\r
+CHAR16\r
+InternalCharToUpper (\r
+  IN      CHAR16                    Char\r
+  )\r
+{\r
+  if (Char >= L'a' && Char <= L'z') {\r
+    return (CHAR16) (Char - (L'a' - L'A'));\r
+  }\r
+\r
+  return Char;\r
+}\r
+\r
+/**\r
+  Convert a Unicode character to numerical value.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid hexadecimal ASII character, i.e.\r
+  L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other \r
+  Unicode character, the value returned does not make sense.\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @retval UINTN   The numerical value converted.\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+InternalHexCharToUintn (\r
+  IN      CHAR16                    Char\r
+  )\r
+{\r
+  if (InternalIsDecimalDigitCharacter (Char)) {\r
+    return Char - L'0';\r
+  }\r
+\r
+  return (UINTN) (10 + InternalCharToUpper (Char) - L'A');\r
+}\r
+\r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This internal function checks if a Unicode character is a \r
+  decimal character.  The valid hexadecimal character is \r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a hexadecmial character.\r
+  @retval FALSE Otherwise.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+InternalIsHexaDecimalDigitCharacter (\r
+  IN      CHAR16                    Char\r
+  )\r
+{\r
+\r
+  return (BOOLEAN) (InternalIsDecimalDigitCharacter (Char) ||\r
+    (Char >= L'A' && Char <= L'F') ||\r
+    (Char >= L'a' && Char <= L'f'));\r
+}\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of \r
+  type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the Unicode string specified by String as a decimal number. The format \r
+  of the input Unicode string String is:\r
+  \r
+                  [spaces] [decimal digits].\r
+                  \r
+  The valid decimal digit character is in the range [0-9]. The \r
+  function will ignore the pad space, which includes spaces or \r
+  tab characters, before [decimal digits]. The running zero in the \r
+  beginning of [decimal digits] will be ignored. Then, the function \r
+  stops at the first character that is a not a valid decimal character \r
+  or a Null-terminator, whichever one comes first. \r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, \r
+  then 0 is returned.\r
+  If the number represented by String overflows according \r
+  to the range defined by UINTN, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINTN           \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrDecimalToUintn (\r
+  IN      CONST CHAR16               *String\r
+  )\r
+{\r
+  UINTN     Result;\r
+  \r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+\r
+  //\r
+  // Ignore the pad spaces (space or tab)\r
+  //\r
+  while ((*String == L' ') || (*String == L'\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == L'0') {\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+\r
+  while (InternalIsDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
+      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) &&\r
+      (*String - L'0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)\r
+      );\r
+\r
+    Result = Result * 10 + (*String - L'0');\r
+    String++;\r
+  }\r
+  \r
+  return Result;\r
+}\r
+\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of \r
+  type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the Unicode string specified by String as a decimal number. The format \r
+  of the input Unicode string String is:\r
+  \r
+                  [spaces] [decimal digits].\r
+                  \r
+  The valid decimal digit character is in the range [0-9]. The \r
+  function will ignore the pad space, which includes spaces or \r
+  tab characters, before [decimal digits]. The running zero in the \r
+  beginning of [decimal digits] will be ignored. Then, the function \r
+  stops at the first character that is a not a valid decimal character \r
+  or a Null-terminator, whichever one comes first. \r
+  \r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, \r
+  then 0 is returned.\r
+  If the number represented by String overflows according \r
+  to the range defined by UINT64, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINT64           \r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+StrDecimalToUint64 (\r
+  IN      CONST CHAR16               *String\r
+  )\r
+{\r
+  UINT64     Result;\r
+  \r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+\r
+  //\r
+  // Ignore the pad spaces (space or tab)\r
+  //\r
+  while ((*String == L' ') || (*String == L'\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == L'0') {\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+\r
+  while (InternalIsDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || \r
+      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && \r
+      (*String - L'0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)\r
+      );\r
+\r
+    Result = MultU64x32 (Result, 10) + (*String - L'0');\r
+    String++;\r
+  }\r
+  \r
+  return Result;\r
+}\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the Unicode string specified by String as a hexadecimal number. \r
+  The format of the input Unicode string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits]. \r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. \r
+  If "x" appears in the input string, it must be prefixed with at least one 0. \r
+  The function will ignore the pad space, which includes spaces or tab characters, \r
+  before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or \r
+  [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the \r
+  first valid hexadecimal digit. Then, the function stops at the first character that is \r
+  a not a valid hexadecimal character or NULL, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If String has only pad spaces, then zero is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, \r
+  then zero is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINTN, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINTN\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrHexToUintn (\r
+  IN      CONST CHAR16               *String\r
+  )\r
+{\r
+  UINTN     Result;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  \r
+  //\r
+  // Ignore the pad spaces (space or tab) \r
+  //\r
+  while ((*String == L' ') || (*String == L'\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == L'0') {\r
+    String++;\r
+  }\r
+\r
+  if (InternalCharToUpper (*String) == L'X') {\r
+    ASSERT (*(String - 1)  == L'0');\r
+    if (*(String - 1)  != L'0') {\r
+      return 0;\r
+    }\r
+    //\r
+    // Skip the 'X'\r
+    //\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+  \r
+  while (InternalIsHexaDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the Hex Number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
+      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && \r
+      (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))\r
+      );\r
+\r
+    Result = (Result << 4) + InternalHexCharToUintn (*String);\r
+    String++;\r
+  }\r
+\r
+  return Result;\r
+}\r
+\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the Unicode string specified by String as a hexadecimal number. \r
+  The format of the input Unicode string String is \r
+  \r
+                  [spaces][zeros][x][hexadecimal digits]. \r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. \r
+  If "x" appears in the input string, it must be prefixed with at least one 0. \r
+  The function will ignore the pad space, which includes spaces or tab characters, \r
+  before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or \r
+  [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the \r
+  first valid hexadecimal digit. Then, the function stops at the first character that is \r
+  a not a valid hexadecimal character or NULL, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If String has only pad spaces, then zero is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, \r
+  then zero is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINT64, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval UINT64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+StrHexToUint64 (\r
+  IN      CONST CHAR16               *String\r
+  )\r
+{\r
+  UINT64    Result;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (((UINTN) String & 0x01) == 0);\r
+  ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  \r
+  //\r
+  // Ignore the pad spaces (space or tab) \r
+  //\r
+  while ((*String == L' ') || (*String == L'\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == L'0') {\r
+    String++;\r
+  }\r
+\r
+  if (InternalCharToUpper (*String) == L'X') {\r
+    ASSERT (*(String - 1)  == L'0');\r
+    if (*(String - 1)  != L'0') {\r
+      return 0;\r
+    }\r
+    //\r
+    // Skip the 'X'\r
+    //\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+  \r
+  while (InternalIsHexaDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the Hex Number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16)|| \r
+      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && \r
+      (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))\r
+      );\r
+\r
+    Result = LShiftU64 (Result, 4);\r
+    Result = Result + InternalHexCharToUintn (*String);\r
+    String++;\r
+  }\r
+\r
+  return Result;\r
+}\r
+\r
+/**\r
+  Check if a ASCII character is a decimal character.\r
+\r
+  This internal function checks if a Unicode character is a \r
+  decimal character. The valid decimal character is from\r
+  '0' to '9'.\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a decmial character.\r
+  @retval FALSE Otherwise.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+InternalAsciiIsDecimalDigitCharacter (\r
+  IN      CHAR8                     Char\r
+  )\r
+{\r
+  return (BOOLEAN) (Char >= '0' && Char <= '9');\r
+}\r
+\r
+/**\r
+  Check if a ASCII character is a hexadecimal character.\r
+\r
+  This internal function checks if a ASCII character is a \r
+  decimal character.  The valid hexadecimal character is \r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  If the Char is a hexadecmial character.\r
+  @retval FALSE Otherwise.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+InternalAsciiIsHexaDecimalDigitCharacter (\r
+  IN      CHAR8                    Char\r
+  )\r
+{\r
+\r
+  return (BOOLEAN) (InternalAsciiIsDecimalDigitCharacter (Char) ||\r
+    (Char >= 'A' && Char <= 'F') ||\r
+    (Char >= 'a' && Char <= 'f'));\r
+}\r
+\r
+/**\r
+  Convert a Null-terminated Unicode string to a Null-terminated \r
+  ASCII string and returns the ASCII string.\r
+  \r
+  This function converts the content of the Unicode string Source \r
+  to the ASCII string Destination by copying the lower 8 bits of \r
+  each Unicode character. It returns Destination. The function terminates \r
+  the ASCII string Destination  by appending a Null-terminator character \r
+  at the end. The caller is responsible to make sure Destination points \r
+  to a buffer with size equal or greater than (StrLen (Source) + 1) in bytes.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  If any Unicode characters in Source contain non-zero value in \r
+  the upper 8 bits, then ASSERT().\r
+  \r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains \r
+  more than PcdMaximumUnicodeStringLength Unicode characters not including \r
+  the Null-terminator, then ASSERT().\r
+  \r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more \r
+  than PcdMaximumAsciiStringLength Unicode characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Source        Pointer to a Null-terminated Unicode string.\r
+  @param  Destination   Pointer to a Null-terminated ASCII string.\r
+\r
+  @reture Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+UnicodeStrToAsciiStr (\r
+  IN      CONST CHAR16               *Source,\r
+  OUT    CHAR8                           *Destination\r
+  )\r
+{\r
+  ASSERT (Destination != NULL);\r
+  ASSERT (Source != NULL);\r
+  ASSERT (((UINTN) Source & 0x01) == 0);\r
+\r
+  //\r
+  // Source and Destination should not overlap\r
+  //\r
+  ASSERT ((UINTN) ((CHAR16 *) Destination -  Source) > StrLen (Source));\r
+  ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));\r
+\r
+  //\r
+  // If PcdMaximumUnicodeStringLength is not zero,\r
+  // length of Source should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+    ASSERT (StrLen (Source) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  }\r
+\r
+  while (*Source != '\0') {\r
+    //\r
+    // If any Unicode characters in Source contain \r
+    // non-zero value in the upper 8 bits, then ASSERT().\r
+    //\r
+    ASSERT (*Source < 0x100);\r
+    *(Destination++) = (CHAR8) *(Source++);\r
+  }\r
+\r
+  *Destination = '\0';\r
+  \r
+  return Destination;\r
+}\r
+\r
+\r
+/**\r
+  Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
+  string and returns the new ASCII string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source\r
+  )\r
+{\r
+  CHAR8                             *ReturnValue;\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r
+\r
+  ReturnValue = Destination;\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated ASCII string with a maximum length to another\r
+  Null-terminated ASCII string with a maximum length and returns the new ASCII\r
+  string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. At most, Length ASCII characters\r
+  are copied from Source to Destination. If Length is 0, then Destination is\r
+  returned unmodified. If Length is greater that the number of ASCII characters\r
+  in Source, then Destination is padded with Null ASCII characters. If Source\r
+  and Destination overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  CHAR8                             *ReturnValue;\r
+\r
+  if (Length == 0) {\r
+    return Destination;\r
+  }\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) >= Length);\r
+\r
+  ReturnValue = Destination;\r
+\r
+  while (*Source && Length > 0) {\r
+    *(Destination++) = *(Source++);\r
+    Length--;\r
+  }\r
+\r
+  ZeroMem (Destination, Length * sizeof (*Destination));\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Returns the length of a Null-terminated ASCII string.\r
+\r
+  This function returns the number of ASCII characters in the Null-terminated\r
+  ASCII string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and String contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrLen (\r
+  IN      CONST CHAR8               *String\r
+  )\r
+{\r
+  UINTN                             Length;\r
+\r
+  ASSERT (String != NULL);\r
+\r
+  for (Length = 0; *String != '\0'; String++, Length++) {\r
+    //\r
+    // If PcdMaximumUnicodeStringLength is not zero,\r
+    // length should not more than PcdMaximumUnicodeStringLength\r
+    //\r
+    if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+      ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength));\r
+    }\r
+  }\r
+  return Length;\r
+}\r
+\r
+/**\r
+  Returns the size of a Null-terminated ASCII string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated ASCII string\r
+  specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and String contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrSize (\r
+  IN      CONST CHAR8               *String\r
+  )\r
+{\r
+  return (AsciiStrLen (String) + 1) * sizeof (*String);\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated ASCII strings, and returns the difference\r
+  between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched ASCII character in SecondString subtracted from the first\r
+  mismatched ASCII character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  while ((*FirstString != '\0') && (*FirstString == *SecondString)) {\r
+    FirstString++;\r
+    SecondString++;\r
+  }\r
+\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Converts a lowercase Ascii character to upper one\r
+\r
+  If Chr is lowercase Ascii character, then converts it to upper one.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  chr   one Ascii character\r
+\r
+  @return The uppercase value of Ascii character \r
+\r
+**/\r
+STATIC\r
+CHAR8\r
+AsciiToUpper (\r
+  IN      CHAR8                     Chr\r
+  )\r
+{\r
+  return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);\r
+}\r
+\r
+/**\r
+  Convert a ASCII character to numerical value.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid hexadecimal ASII character, i.e.\r
+  '0' to '9', 'a' to 'f' or 'A' to 'F'. For other \r
+  ASCII character, the value returned does not make sense.\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @retval UINTN   The numerical value converted.\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+InternalAsciiHexCharToUintn (\r
+  IN      CHAR8                    Char\r
+  )\r
+{\r
+  if (InternalIsDecimalDigitCharacter (Char)) {\r
+    return Char - '0';\r
+  }\r
+\r
+  return (UINTN) (10 + AsciiToUpper (Char) - 'A');\r
+}\r
+\r
+\r
+/**\r
+  Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
+  and returns the difference between the first mismatched ASCII characters.\r
+\r
+  This function performs a case insensitive comparison of the Null-terminated\r
+  ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched lower case ASCII character in\r
+  SecondString subtracted from the first mismatched lower case ASCII character\r
+  in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
+  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString using case insensitive\r
+              comparisons.\r
+  @retval !=0 FirstString is not identical to SecondString using case\r
+              insensitive comparisons.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStriCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  )\r
+{\r
+  CHAR8  UpperFirstString;\r
+  CHAR8  UpperSecondString;\r
+\r
+  //\r
+  // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  UpperFirstString  = AsciiToUpper (*FirstString);\r
+  UpperSecondString = AsciiToUpper (*SecondString);\r
+  while ((*FirstString != '\0') && (UpperFirstString == UpperSecondString)) {\r
+    FirstString++;\r
+    SecondString++;\r
+    UpperFirstString  = AsciiToUpper (*FirstString);\r
+    UpperSecondString = AsciiToUpper (*SecondString);\r
+  }\r
+\r
+  return UpperFirstString - UpperSecondString;\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
+  the difference between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII  string SecondString. At most, Length ASCII characters\r
+  will be compared. If Length is 0, then 0 is returned. If FirstString is\r
+  identical to SecondString, then 0 is returned. Otherwise, the value returned\r
+  is the first mismatched ASCII character in SecondString subtracted from the\r
+  first mismatched ASCII character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and SecondString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrnCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  while ((*FirstString != '\0') &&\r
+         (*FirstString == *SecondString) &&\r
+         (Length > 1)) {\r
+    FirstString++;\r
+    SecondString++;\r
+    Length--;\r
+  }\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated ASCII string to another Null-terminated\r
+  ASCII string, and returns the concatenated ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents of\r
+  Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
+  String is returned.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
+  Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
+  ASCII characters, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCat (\r
+  IN OUT CHAR8    *Destination,\r
+  IN CONST CHAR8  *Source\r
+  )\r
+{\r
+  AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  // PcdMaximumUnicodeStringLength is tested inside StrLen().\r
+  //\r
+  ASSERT (AsciiStrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated ASCII string with a maximum length to the\r
+  end of another Null-terminated ASCII string, and returns the concatenated\r
+  ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents\r
+  of Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination, and Destination is returned. At most,\r
+  Length ASCII characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
+  Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
+  ASCII characters not including the Null-terminator, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCat (\r
+  IN OUT  CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  // PcdMaximumUnicodeStringLength is tested inside StrLen().\r
+  //\r
+  ASSERT (AsciiStrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Returns the first occurance of a Null-terminated ASCII sub-string \r
+  in a Null-terminated ASCII string.\r
+\r
+  This function scans the contents of the ASCII string specified by String \r
+  and returns the first occurrence of SearchString. If SearchString is not \r
+  found in String, then NULL is returned. If the length of SearchString is zero, \r
+  then String is returned.\r
+  \r
+  If String is NULL, then ASSERT().\r
+  If SearchString is NULL, then ASSERT().\r
+\r
+  If PcdMaximumAsciiStringLength is not zero, and SearchString or \r
+  String contains more than PcdMaximumAsciiStringLength Unicode characters \r
+  not including the Null-terminator, then ASSERT().\r
+\r
+  @param  String                                 Pointer to a Null-terminated ASCII string.\r
+  @param  SearchString   Pointer to a Null-terminated ASCII string to search for.\r
+\r
+  @retval NULL            If the SearchString does not appear in String.\r
+  @retval !NULL           If there is a match.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrStr (\r
+  IN      CONST CHAR8                *String,\r
+  IN      CONST CHAR8             *SearchString\r
+  )\r
+{\r
+  CONST CHAR8 *FirstMatch;\r
+  CONST CHAR8 *SearchStringTmp;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (SearchString != NULL);\r
+\r
+  //\r
+  // If PcdMaximumUnicodeStringLength is not zero,\r
+  // length of String should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+    ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
+  //\r
+  // If PcdMaximumUnicodeStringLength is not zero,\r
+  // length of SearchString should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+    ASSERT (AsciiStrLen (SearchString) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
+  while (*String != '\0') {\r
+    SearchStringTmp = SearchString;\r
+    FirstMatch = String;\r
+    \r
+    while ((*String == *SearchStringTmp) \r
+            && (*SearchStringTmp != '\0') \r
+            && (*String != '\0')) {\r
+      String++;\r
+      SearchStringTmp++;\r
+    } \r
+    \r
+    if (*SearchStringTmp == '\0') {\r
+      return (CHAR8 *) FirstMatch;\r
+    }\r
+\r
+    if (SearchStringTmp == SearchString) {\r
+      //\r
+      // If no character from SearchString match,\r
+      // move the pointer to the String under search\r
+      // by one character.\r
+      //\r
+      String++;\r
+    }\r
+\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Convert a Null-terminated ASCII decimal string to a value of type \r
+  UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents \r
+  of the ASCII string String as a decimal number. The format of the input \r
+  ASCII string String is:\r
+  \r
+                    [spaces] [decimal digits].\r
+  \r
+  The valid decimal digit character is in the range [0-9]. The function will \r
+  ignore the pad space, which includes spaces or tab characters, before the digits. \r
+  The running zero in the beginning of [decimal digits] will be ignored. Then, the \r
+  function stops at the first character that is a not a valid decimal character or \r
+  Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, then 0 is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINTN, then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINTN           \r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrDecimalToUintn (\r
+  IN      CONST CHAR8                  *String\r
+  )\r
+{\r
+  UINTN     Result;\r
+  \r
+  ASSERT (String != NULL);\r
+  ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+\r
+  //\r
+  // Ignore the pad spaces (space or tab)\r
+  //\r
+  while ((*String == ' ') || (*String == '\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == '0') {\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+\r
+  while (InternalAsciiIsDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
+      ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) && \r
+      (*String - '0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10)\r
+      );\r
+\r
+    Result = Result * 10 + (*String - '0');\r
+    String++;\r
+  }\r
+  \r
+  return Result;\r
+}\r
+\r
+\r
+/**\r
+  Convert a Null-terminated ASCII decimal string to a value of type \r
+  UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents \r
+  of the ASCII string String as a decimal number. The format of the input \r
+  ASCII string String is:\r
+  \r
+                    [spaces] [decimal digits].\r
+  \r
+  The valid decimal digit character is in the range [0-9]. The function will \r
+  ignore the pad space, which includes spaces or tab characters, before the digits. \r
+  The running zero in the beginning of [decimal digits] will be ignored. Then, the \r
+  function stops at the first character that is a not a valid decimal character or \r
+  Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no pad spaces or valid decimal digits, then 0 is returned.\r
+  If the number represented by String overflows according to the range defined by \r
+  UINT64, then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINT64           \r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsciiStrDecimalToUint64 (\r
+  IN      CONST CHAR8                *String\r
+  )\r
+{\r
+  UINT64     Result;\r
+  \r
+  ASSERT (String != NULL);\r
+  ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+\r
+  //\r
+  // Ignore the pad spaces (space or tab)\r
+  //\r
+  while ((*String == ' ') || (*String == '\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == '0') {\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+\r
+  while (InternalAsciiIsDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || \r
+      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && \r
+      (*String - '0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10)\r
+      );\r
+\r
+    Result = MultU64x32 (Result, 10) + (*String - '0');\r
+    String++;\r
+  }\r
+  \r
+  return Result;\r
+}\r
+\r
+/**\r
+  Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r
+\r
+  This function returns a value of type UINTN by interpreting the contents of \r
+  the ASCII string String as a hexadecimal number. The format of the input ASCII \r
+  string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits].\r
+                  \r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" \r
+  appears in the input string, it must be prefixed with at least one 0. The function \r
+  will ignore the pad space, which includes spaces or tab characters, before [zeros], \r
+  [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] \r
+  will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal \r
+  digit. Then, the function stops at the first character that is a not a valid \r
+  hexadecimal character or Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
+  0 is returned.\r
+\r
+  If the number represented by String overflows according to the range defined by UINTN, \r
+  then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, \r
+  and String contains more than PcdMaximumAsciiStringLength ASCII characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINTN\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrHexToUintn (\r
+  IN      CONST CHAR8                *String\r
+  )\r
+{\r
+  UINTN     Result;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+  \r
+  //\r
+  // Ignore the pad spaces (space or tab) \r
+  //\r
+  while ((*String == ' ') || (*String == '\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == '0') {\r
+    String++;\r
+  }\r
+\r
+  if (AsciiToUpper (*String) == 'X') {\r
+    ASSERT (*(String - 1)  == '0');\r
+    if (*(String - 1)  != '0') {\r
+      return 0;\r
+    }\r
+    //\r
+    // Skip the 'X'\r
+    //\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+  \r
+  while (InternalAsciiIsHexaDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the Hex Number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+     ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
+       ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && \r
+       (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16))\r
+       );\r
+\r
+    Result = (Result << 4) + InternalAsciiHexCharToUintn (*String);\r
+    String++;\r
+  }\r
+\r
+  return Result;\r
+}\r
+\r
+\r
+/**\r
+  Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r
+\r
+  This function returns a value of type UINT64 by interpreting the contents of \r
+  the ASCII string String as a hexadecimal number. The format of the input ASCII \r
+  string String is:\r
+  \r
+                  [spaces][zeros][x][hexadecimal digits].\r
+                  \r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. \r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" \r
+  appears in the input string, it must be prefixed with at least one 0. The function \r
+  will ignore the pad space, which includes spaces or tab characters, before [zeros], \r
+  [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] \r
+  will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal \r
+  digit. Then, the function stops at the first character that is a not a valid \r
+  hexadecimal character or Null-terminator, whichever on comes first.\r
+  \r
+  If String has only pad spaces, then 0 is returned.\r
+  If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
+  0 is returned.\r
+\r
+  If the number represented by String overflows according to the range defined by UINT64, \r
+  then ASSERT().\r
+  If String is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, \r
+  and String contains more than PcdMaximumAsciiStringLength ASCII characters not including \r
+  the Null-terminator, then ASSERT().\r
+\r
+  @param  String                           Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval UINT64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsciiStrHexToUint64 (\r
+  IN      CONST CHAR8                *String\r
+  )\r
+{\r
+  UINT64    Result;\r
+\r
+  ASSERT (String != NULL);\r
+  ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  \r
+  //\r
+  // Ignore the pad spaces (space or tab) and leading Zeros\r
+  //\r
+  //\r
+  // Ignore the pad spaces (space or tab) \r
+  //\r
+  while ((*String == ' ') || (*String == '\t')) {\r
+    String++;\r
+  }\r
+\r
+  //\r
+  // Ignore leading Zeros after the spaces\r
+  //\r
+  while (*String == '0') {\r
+    String++;\r
+  }\r
+\r
+  if (AsciiToUpper (*String) == 'X') {\r
+    ASSERT (*(String - 1)  == '0');\r
+    if (*(String - 1)  != '0') {\r
+      return 0;\r
+    }\r
+    //\r
+    // Skip the 'X'\r
+    //\r
+    String++;\r
+  }\r
+\r
+  Result = 0;\r
+  \r
+  while (InternalAsciiIsHexaDecimalDigitCharacter (*String)) {\r
+    //\r
+    // If the Hex Number represented by String overflows according \r
+    // to the range defined by UINTN, then ASSERT().\r
+    //\r
+    ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16) ||\r
+      ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && \r
+      (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16))\r
+      );\r
+\r
+    Result = LShiftU64 (Result, 4);\r
+    Result = Result + InternalAsciiHexCharToUintn (*String);\r
+    String++;\r
+  }\r
+\r
+  return Result;\r
+}\r
+\r
+\r
+/**\r
+  Convert one Null-terminated ASCII string to a Null-terminated \r
+  Unicode string and returns the Unicode string.\r
+\r
+  This function converts the contents of the ASCII string Source to the Unicode \r
+  string Destination, and returns Destination.  The function terminates the \r
+  Unicode string Destination by appending a Null-terminator character at the end. \r
+  The caller is responsible to make sure Destination points to a buffer with size \r
+  equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
+  \r
+  If Destination is NULL, then ASSERT().\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and Source contains more than \r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, \r
+  then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters not including the \r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  Source        Pointer to a Null-terminated ASCII string.\r
+  @param  Destination   Pointer to a Null-terminated Unicode string.\r
+\r
+  @reture Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+AsciiStrToUnicodeStr (\r
+  IN      CONST CHAR8                *Source,\r
+  OUT    CHAR16                        *Destination\r
+  )\r
+{\r
+  ASSERT (Destination != NULL);\r
+  ASSERT (Source != NULL);\r
+\r
+  //\r
+  // Source and Destination should not overlap\r
+  //\r
+  ASSERT ((UINTN) ((CHAR8 *) Destination - Source) > AsciiStrLen (Source));\r
+  ASSERT ((UINTN) (Source - (CHAR8 *) Destination) > (AsciiStrLen (Source) * sizeof (CHAR16)));\r
+\r
+  //\r
+  // If PcdMaximumAsciiStringLength is not zero,\r
+  // length of Source should not more than PcdMaximumUnicodeStringLength\r
+  //\r
+  if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+    ASSERT (AsciiStrLen (Source) < PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
+  while (*Source != '\0') {\r
+    *(Destination++) = (CHAR16) *(Source++);\r
+  }\r
+  //\r
+  // End the Destination with a NULL.\r
+  //\r
+  *Destination = '\0';\r
+\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Converts an 8-bit value to an 8-bit BCD value.\r
+\r
+  Converts the 8-bit value specified by Value to BCD. The BCD value is\r
+  returned.\r
+\r
+  If Value >= 100, then ASSERT().\r
+\r
+  @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
+\r
+  @return The BCD value\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DecimalToBcd8 (\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT (Value < 100);\r
+  return (UINT8) (((Value / 10) << 4) | (Value % 10));\r
+}\r
+\r
+/**\r
+  Converts an 8-bit BCD value to an 8-bit value.\r
+\r
+  Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
+  value is returned.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
+\r
+  @return The 8-bit value is returned.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BcdToDecimal8 (\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT (Value < 0xa0);\r
+  ASSERT ((Value & 0xf) < 0xa);\r
+  return (UINT8) ((Value >> 4) * 10 + (Value & 0xf));\r
+}\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c
new file mode 100644 (file)
index 0000000..890369e
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SwapBytes16.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Switches the endianess of a 16-bit integer.\r
+\r
+  This function swaps the bytes in a 16-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 16-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SwapBytes16 (\r
+  IN      UINT16                    Operand\r
+  )\r
+{\r
+  return (UINT16) ((Operand << 8) | (Operand >> 8));\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c
new file mode 100644 (file)
index 0000000..59b4659
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SwapBytes32.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Switches the endianess of a 32-bit integer.\r
+\r
+  This function swaps the bytes in a 32-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 32-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+SwapBytes32 (\r
+  IN      UINT32                    Operand\r
+  )\r
+{\r
+  UINT32  LowerBytes;\r
+  UINT32  HigherBytes;\r
+\r
+  LowerBytes  = (UINT32) SwapBytes16 ((UINT16) Operand);\r
+  HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16));\r
+\r
+  return (LowerBytes << 16 | HigherBytes);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c
new file mode 100644 (file)
index 0000000..bd402d3
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SwapBytes64.c\r
+  \r
+Abstract: \r
+\r
+  Math worker functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Switches the endianess of a 64-bit integer.\r
+\r
+  This function swaps the bytes in a 64-bit unsigned value to switch the value\r
+  from little endian to big endian or vice versa. The byte swapped value is\r
+  returned.\r
+\r
+  @param  Operand A 64-bit unsigned value.\r
+\r
+  @return The byte swaped Operand.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+SwapBytes64 (\r
+  IN      UINT64                    Operand\r
+  )\r
+{\r
+  return InternalMathSwapBytes64 (Operand);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c
new file mode 100644 (file)
index 0000000..82a19eb
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SwitchStack.c\r
+  \r
+Abstract: \r
+\r
+  Switch Stack functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+  For IPF CPUs, if NewStack is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,\r
+  IN      VOID                      *Context2,\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  ASSERT (EntryPoint != NULL && NewStack != NULL);\r
+\r
+#ifdef MDE_CPU_IPF\r
+  ASSERT (((UINTN)NewStack & 0xf) == 0);\r
+#endif\r
+\r
+  InternalSwitchStack (EntryPoint, Context1, Context2, NewStack);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c
new file mode 100644 (file)
index 0000000..9165b86
--- /dev/null
@@ -0,0 +1,364 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Synchronization.c\r
+  \r
+Abstract: \r
+\r
+  Implementation of synchronization functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+#define SPIN_LOCK_RELEASED          ((SPIN_LOCK)1)\r
+#define SPIN_LOCK_ACQUIRED          ((SPIN_LOCK)2)\r
+\r
+/**\r
+  Retrieves the architecture specific spin lock alignment requirements for\r
+  optimal spin lock performance.\r
+\r
+  This function retrieves the spin lock alignment requirements for optimal\r
+  performance on a given CPU architecture. The spin lock alignment must be a\r
+  power of two and is returned by this function. If there are no alignment\r
+  requirements, then 1 must be returned. The spin lock synchronization\r
+  functions must function correctly if the spin lock size and alignment values\r
+  returned by this function are not used at all. These values are hints to the\r
+  consumers of the spin lock synchronization functions to obtain optimal spin\r
+  lock performance.\r
+\r
+  @return The architecture specific spin lock alignment.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetSpinLockProperties (\r
+  VOID\r
+  )\r
+{\r
+  // @bug May use a PCD entry to determine this alignment.\r
+  return 32;\r
+}\r
+\r
+/**\r
+  Initializes a spin lock to the released state and returns the spin lock.\r
+\r
+  This function initializes the spin lock specified by SpinLock to the released\r
+  state, and returns SpinLock. Optimal performance can be achieved by calling\r
+  GetSpinLockProperties() to determine the size and alignment requirements for\r
+  SpinLock.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to initialize to the released\r
+                    state.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+InitializeSpinLock (\r
+  OUT     SPIN_LOCK                 *SpinLock\r
+  )\r
+{\r
+  ASSERT (SpinLock != NULL);\r
+  *SpinLock = SPIN_LOCK_RELEASED;\r
+  return SpinLock;\r
+}\r
+\r
+/**\r
+  Waits until a spin lock can be placed in the acquired state.\r
+\r
+  This function checks the state of the spin lock specified by SpinLock. If\r
+  SpinLock is in the released state, then this function places SpinLock in the\r
+  acquired state and returns SpinLock. Otherwise, this function waits\r
+  indefinitely for the spin lock to be released, and then places it in the\r
+  acquired state and returns SpinLock. All state transitions of SpinLock must\r
+  be performed using MP safe mechanisms.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+  If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r
+  PcdSpinLockTimeout microseconds, then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to place in the acquired state.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+AcquireSpinLock (\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
+  )\r
+{\r
+  UINT64                            Tick;\r
+  UINT64                            Start, End;\r
+  UINT64                            Timeout;\r
+\r
+  Tick = 0;\r
+  Start = 0;\r
+  End = 0;\r
+  if (PcdGet32 (PcdSpinLockTimeout) > 0) {\r
+    Tick = GetPerformanceCounter ();\r
+    Timeout = DivU64x32 (\r
+                MultU64x32 (\r
+                  GetPerformanceCounterProperties (&Start, &End),\r
+                  PcdGet32 (PcdSpinLockTimeout)\r
+                  ),\r
+                1000000\r
+                );\r
+    if (Start < End) {\r
+      Tick += Timeout;\r
+    } else {\r
+      Tick -= Timeout;\r
+    }\r
+  }\r
+\r
+  while (!AcquireSpinLockOrFail (SpinLock)) {\r
+    CpuPause ();\r
+    ASSERT ((Start < End) ^ (Tick <= GetPerformanceCounter ()));\r
+  }\r
+  return SpinLock;\r
+}\r
+\r
+/**\r
+  Attempts to place a spin lock in the acquired state.\r
+\r
+  This function checks the state of the spin lock specified by SpinLock. If\r
+  SpinLock is in the released state, then this function places SpinLock in the\r
+  acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r
+  transitions of SpinLock must be performed using MP safe mechanisms.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to place in the acquired state.\r
+\r
+  @retval TRUE  SpinLock was placed in the acquired state.\r
+  @retval FALSE SpinLock could not be acquired.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AcquireSpinLockOrFail (\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
+  )\r
+{\r
+  volatile SPIN_LOCK    LockValue;\r
+\r
+  ASSERT (SpinLock != NULL);\r
+\r
+  LockValue = *SpinLock;\r
+  ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
+\r
+  return (BOOLEAN)(\r
+           InterlockedCompareExchangePointer (\r
+             (VOID**)SpinLock,\r
+             (VOID*)SPIN_LOCK_RELEASED,\r
+             (VOID*)SPIN_LOCK_ACQUIRED\r
+             ) == (VOID*)SPIN_LOCK_RELEASED\r
+           );\r
+}\r
+\r
+/**\r
+  Releases a spin lock.\r
+\r
+  This function places the spin lock specified by SpinLock in the release state\r
+  and returns SpinLock.\r
+\r
+  If SpinLock is NULL, then ASSERT().\r
+  If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
+\r
+  @param  SpinLock  A pointer to the spin lock to release.\r
+\r
+  @return SpinLock\r
+\r
+**/\r
+SPIN_LOCK *\r
+EFIAPI\r
+ReleaseSpinLock (\r
+  IN OUT  SPIN_LOCK                 *SpinLock\r
+  )\r
+{\r
+  volatile SPIN_LOCK    LockValue;\r
+\r
+  ASSERT (SpinLock != NULL);\r
+\r
+  LockValue = *SpinLock;\r
+  ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
+\r
+  *SpinLock = SPIN_LOCK_RELEASED;\r
+  return SpinLock;\r
+}\r
+\r
+/**\r
+  Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic increment of the 32-bit unsigned integer specified by\r
+  Value and returns the incremented value. The increment operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value A pointer to the 32-bit value to increment.\r
+\r
+  @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedIncrement (\r
+  IN      UINT32                    *Value\r
+  )\r
+{\r
+  ASSERT (Value != NULL);\r
+  return InternalSyncIncrement (Value);\r
+}\r
+\r
+/**\r
+  Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+  Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+  Value and returns the decremented value. The decrement operation must be\r
+  performed using MP safe mechanisms. The state of the return value is not\r
+  guaranteed to be MP safe.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value A pointer to the 32-bit value to decrement.\r
+\r
+  @return The decremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedDecrement (\r
+  IN      UINT32                    *Value\r
+  )\r
+{\r
+  ASSERT (Value != NULL);\r
+  return InternalSyncDecrement (Value);\r
+}\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
+  specified by Value.  If Value is equal to CompareValue, then Value is set to \r
+  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,\r
+  then Value is returned.  The compare exchange operation must be performed using \r
+  MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the 32-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  32-bit value used in compare operation.\r
+  @param  ExchangeValue 32-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InterlockedCompareExchange32 (\r
+  IN OUT  UINT32                    *Value,\r
+  IN      UINT32                    CompareValue,\r
+  IN      UINT32                    ExchangeValue\r
+  )\r
+{\r
+  ASSERT (Value != NULL);\r
+  return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);\r
+}\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
+\r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned. \r
+  The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the 64-bit value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  64-bit value used in compare operation.\r
+  @param  ExchangeValue 64-bit value used in exchange operation.\r
+\r
+  @return The original *Value before exchange.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InterlockedCompareExchange64 (\r
+  IN OUT  UINT64                    *Value,\r
+  IN      UINT64                    CompareValue,\r
+  IN      UINT64                    ExchangeValue\r
+  )\r
+{\r
+  ASSERT (Value != NULL);\r
+  return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);\r
+}\r
+\r
+/**\r
+  Performs an atomic compare exchange operation on a pointer value.\r
+\r
+  Performs an atomic compare exchange operation on the pointer value specified\r
+  by Value. If Value is equal to CompareValue, then Value is set to\r
+  ExchangeValue and CompareValue is returned. If Value is not equal to\r
+  CompareValue, then Value is returned. The compare exchange operation must be\r
+  performed using MP safe mechanisms.\r
+\r
+  If Value is NULL, then ASSERT().\r
+\r
+  @param  Value         A pointer to the pointer value for the compare exchange\r
+                        operation.\r
+  @param  CompareValue  Pointer value used in compare operation.\r
+  @param  ExchangeValue Pointer value used in exchange operation.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InterlockedCompareExchangePointer (\r
+  IN OUT  VOID                      **Value,\r
+  IN      VOID                      *CompareValue,\r
+  IN      VOID                      *ExchangeValue\r
+  )\r
+{\r
+  UINT8  SizeOfValue;\r
+\r
+  SizeOfValue = sizeof (*Value);\r
+\r
+  switch (SizeOfValue) {\r
+    case sizeof (UINT32):\r
+      return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
+                             (UINT32*)Value,\r
+                             (UINT32)(UINTN)CompareValue,\r
+                             (UINT32)(UINTN)ExchangeValue\r
+                             );\r
+    case sizeof (UINT64):\r
+      return (VOID*)(UINTN)InterlockedCompareExchange64 (\r
+                             (UINT64*)Value,\r
+                             (UINT64)(UINTN)CompareValue,\r
+                             (UINT64)(UINTN)ExchangeValue\r
+                             );\r
+    default:\r
+      ASSERT (FALSE);\r
+      return NULL;\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c
new file mode 100644 (file)
index 0000000..37c9e71
--- /dev/null
@@ -0,0 +1,228 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Unaligned.c\r
+  \r
+Abstract: \r
+\r
+  Unaligned access functions of BaseLib.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Reads a 16-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 16-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+\r
+  @return *Uint16\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+ReadUnaligned16 (\r
+  IN      CONST UINT16              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer;\r
+}\r
+\r
+/**\r
+  Writes a 16-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 16-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 16-bit value that may be unaligned.\r
+  @param  Value   16-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+WriteUnaligned16 (\r
+  OUT     UINT16                    *Buffer,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer = Value;\r
+}\r
+\r
+/**\r
+  Reads a 24-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 24-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned24 (\r
+  IN      CONST UINT32              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer & 0xffffff;\r
+}\r
+\r
+/**\r
+  Writes a 24-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 24-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 24-bit value that may be unaligned.\r
+  @param  Value   24-bit value to write to Buffer.\r
+\r
+  @return The value written.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned24 (\r
+  OUT     UINT32                    *Buffer,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value);\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 32-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+\r
+  @return *Uint32\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+ReadUnaligned32 (\r
+  IN      CONST UINT32              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer;\r
+}\r
+\r
+/**\r
+  Writes a 32-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 32-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 32-bit value that may be unaligned.\r
+  @param  Value   32-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+WriteUnaligned32 (\r
+  OUT     UINT32                    *Buffer,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer = Value;\r
+}\r
+\r
+/**\r
+  Reads a 64-bit value from memory that may be unaligned.\r
+\r
+  This function returns the 64-bit value pointed to by Buffer. The function\r
+  guarantees that the read operation does not produce an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+\r
+  @return *Uint64\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+ReadUnaligned64 (\r
+  IN      CONST UINT64              *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer;\r
+}\r
+\r
+/**\r
+  Writes a 64-bit value to memory that may be unaligned.\r
+\r
+  This function writes the 64-bit value specified by Value to Buffer. Value is\r
+  returned. The function guarantees that the write operation does not produce\r
+  an alignment fault.\r
+\r
+  If the Buffer is NULL, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a 64-bit value that may be unaligned.\r
+  @param  Value   64-bit value to write to Buffer.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+WriteUnaligned64 (\r
+  OUT     UINT64                    *Buffer,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+\r
+  return *Buffer = Value;\r
+}\r
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 (file)
index 0000000..75d081e
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuBreakpoint.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuBreakpoint function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuBreakpoint (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuBreakpoint   PROC\r
+    int  3\r
+    ret\r
+CpuBreakpoint   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2da3b42
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuFlushTlb.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuFlushTlb function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuFlushTlb (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuFlushTlb PROC\r
+    mov     rax, cr3\r
+    mov     cr3, rax\r
+    ret\r
+CpuFlushTlb ENDP\r
+\r
+    END\r
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 (file)
index 0000000..5680014
--- /dev/null
@@ -0,0 +1,60 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuId.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmCpuid function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EFIAPI\r
+;  AsmCpuid (\r
+;    IN   UINT32  RegisterInEax,\r
+;    OUT  UINT32  *RegisterOutEax  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEbx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEcx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEdx  OPTIONAL\r
+;    )\r
+;------------------------------------------------------------------------------\r
+AsmCpuid    PROC    USES    rbx\r
+    mov     eax, ecx\r
+    push    rax                         ; save Index on stack\r
+    push    rdx\r
+    cpuid\r
+    test    r9, r9\r
+    jz      @F\r
+    mov     [r9], ecx\r
+@@:\r
+    pop     rcx\r
+    jrcxz   @F\r
+    mov     [rcx], eax\r
+@@:\r
+    mov     rcx, r8\r
+    jrcxz   @F\r
+    mov     [rcx], ebx\r
+@@:\r
+    mov     rcx, [rsp + 38h]\r
+    jrcxz   @F\r
+    mov     [rcx], edx\r
+@@:\r
+    pop     rax                         ; restore Index to rax as return value\r
+    ret\r
+AsmCpuid    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2f531f7
--- /dev/null
@@ -0,0 +1,62 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuIdEx.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmCpuidEx function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  UINT32\r
+;  EFIAPI\r
+;  AsmCpuidEx (\r
+;    IN   UINT32  RegisterInEax,\r
+;    IN   UINT32  RegisterInEcx,\r
+;    OUT  UINT32  *RegisterOutEax  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEbx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEcx  OPTIONAL,\r
+;    OUT  UINT32  *RegisterOutEdx  OPTIONAL\r
+;    )\r
+;------------------------------------------------------------------------------\r
+AsmCpuidEx  PROC    USES    rbx\r
+    mov     eax, ecx\r
+    mov     ecx, edx\r
+    push    rax                         ; save Index on stack\r
+    cpuid\r
+    mov     r10, [rsp + 38h]\r
+    test    r10, r10\r
+    jz      @F\r
+    mov     [r10], ecx\r
+@@:\r
+    mov     rcx, r8\r
+    jrcxz   @F\r
+    mov     [rcx], eax\r
+@@:\r
+    mov     rcx, r9\r
+    jrcxz   @F\r
+    mov     [rcx], ebx\r
+@@:\r
+    mov     rcx, [rsp + 40h]\r
+    jrcxz   @F\r
+    mov     [rcx], edx\r
+@@:\r
+    pop     rax                         ; restore Index to rax as return value\r
+    ret\r
+AsmCpuidEx  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4e9697d
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuPause.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuPause function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuPause (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuPause    PROC\r
+    pause\r
+    ret\r
+CpuPause    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f0ba417
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   CpuSleep.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CpuSleep function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; CpuSleep (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+CpuSleep    PROC\r
+    hlt\r
+    ret\r
+CpuSleep    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b332a2e
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DisableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   DisableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; DisableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+DisableInterrupts   PROC\r
+    cli\r
+    ret\r
+DisableInterrupts   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0359baf
--- /dev/null
@@ -0,0 +1,63 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   DisablePaging64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmDisablePaging64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86DisablePaging64 (\r
+;   IN      UINT16                    Cs,\r
+;   IN      UINT32                    EntryPoint,\r
+;   IN      UINT32                    Context1,  OPTIONAL\r
+;   IN      UINT32                    Context2,  OPTIONAL\r
+;   IN      UINT32                    NewStack\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86DisablePaging64    PROC\r
+    cli\r
+    shl     rcx, 32                     ; rcx[32..47] <- Cs\r
+    lea     eax, @F\r
+    mov     esi, r8d\r
+    or      rcx, rax                    ; rcx[0..47] <- Cs:@F\r
+    mov     edi, r9d\r
+    mov     eax, [rsp + 28h]            ; eax <- New Stack\r
+    push    rcx\r
+    retf                                ; switch to compatibility mode\r
+@@:\r
+    mov     esp, eax                    ; set up new stack\r
+    mov     rax, cr0\r
+    btr     eax, 31\r
+    mov     cr0, rax                    ; disable paging\r
+    mov     ecx, 0c0000080h\r
+    rdmsr\r
+    and     ah, NOT 1                   ; clear LME\r
+    wrmsr\r
+    mov     rax, cr4\r
+    and     al, NOT (1 SHL 5)           ; clear PAE\r
+    mov     cr4, rax\r
+    push    rdi                         ; push Context2\r
+    push    rsi                         ; push Context1\r
+    call    rdx                         ; transfer control to EntryPoint\r
+    hlt                                 ; no one should get here\r
+InternalX86DisablePaging64    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..bc0d748
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnableDisableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   EnableDisableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; EnableDisableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EnableDisableInterrupts PROC\r
+    sti\r
+    cli\r
+    ret\r
+EnableDisableInterrupts ENDP\r
+\r
+    END\r
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 (file)
index 0000000..d94bb42
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnableInterrupts.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   EnableInterrupts function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; EnableInterrupts (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EnableInterrupts    PROC\r
+    sti\r
+    ret\r
+EnableInterrupts    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b4f50b2
--- /dev/null
@@ -0,0 +1,62 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   EnablePaging64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmEnablePaging64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86EnablePaging64 (\r
+;   IN      UINT16                    Cs,\r
+;   IN      UINT64                    EntryPoint,\r
+;   IN      UINT64                    Context1,  OPTIONAL\r
+;   IN      UINT64                    Context2,  OPTIONAL\r
+;   IN      UINT64                    NewStack\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86EnablePaging64 PROC\r
+    cli\r
+    pop     rax                         ; skip the return address\r
+    call    @Base\r
+@Base:\r
+    add     dword ptr [rsp], @F - @Base ; offset for far retf, seg is the 1st arg\r
+    mov     rax, cr4                    ; mov eax, cr4\r
+    or      al, (1 SHL 5)\r
+    mov     cr4, rax                    ; enable PAE\r
+    mov     ecx, 0c0000080h\r
+    rdmsr\r
+    or      ah, 1                       ; set LME\r
+    wrmsr\r
+    mov     rax, cr0                    ; mov eax, cr0\r
+    bts     eax, 31\r
+    mov     cr0, rax                    ; enable paging\r
+    retf\r
+@@:                                     ; long mode starts here\r
+    mov     rbx, [esp]\r
+    mov     rcx, [esp + 8]\r
+    mov     rdx, [esp + 10h]\r
+    mov     rsp, [esp + 18h]\r
+    add     rsp, -20h\r
+    call    rbx\r
+    hlt                                 ; halt processor if EntryPoint() returned\r
+InternalX86EnablePaging64 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f2c17c4
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FlushCacheLine.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFlushCacheLine function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI \r
+; AsmFlushCacheLine (\r
+;   IN      VOID                      *LinearAddress\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFlushCacheLine   PROC\r
+    clflush [rcx]\r
+    mov     rax, rcx\r
+    ret\r
+AsmFlushCacheLine   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..962827e
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FxRestore.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFxRestore function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86FxRestore (\r
+;   IN CONST IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86FxRestore  PROC\r
+    fxrstor [rcx]\r
+    ret\r
+InternalX86FxRestore  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..072d275
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   FxSave.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmFxSave function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86FxSave (\r
+;   OUT IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86FxSave PROC\r
+    fxsave  [rcx]\r
+    ret\r
+InternalX86FxSave ENDP\r
+\r
+    END\r
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 (file)
index 0000000..947822a
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedCompareExchange32.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedCompareExchange32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InterlockedCompareExchange32 (\r
+;   IN      UINT32                    *Value,\r
+;   IN      UINT32                    CompareValue,\r
+;   IN      UINT32                    ExchangeValue\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncCompareExchange32   PROC\r
+    mov     eax, edx\r
+    lock    cmpxchg [rcx], r8d\r
+    ret\r
+InternalSyncCompareExchange32   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..769b313
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedCompareExchange64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedCompareExchange64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; InterlockedCompareExchange64 (\r
+;   IN      UINT64                    *Value,\r
+;   IN      UINT64                    CompareValue,\r
+;   IN      UINT64                    ExchangeValue\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncCompareExchange64   PROC\r
+    mov     rax, rdx\r
+    lock    cmpxchg [rcx], r8\r
+    ret\r
+InternalSyncCompareExchange64   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..be0807b
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedDecrement.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedDecrement function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InterlockedDecrement (\r
+;   IN      UINT32                    *Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncDecrement   PROC\r
+    lock    dec     dword ptr [rcx]\r
+    mov     eax, [rcx]\r
+    ret\r
+InternalSyncDecrement   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..3b24752
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   InterlockedIncrement.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   InterlockedIncrement function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT32\r
+; EFIAPI\r
+; InterlockedIncrement (\r
+;   IN      UINT32                    *Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalSyncIncrement   PROC\r
+    lock    inc     dword ptr [rcx]\r
+    mov     eax, [rcx]\r
+    ret\r
+InternalSyncIncrement   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b69fc7b
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Invd.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmInvd function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmInvd (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmInvd PROC\r
+    invd\r
+    ret\r
+AsmInvd ENDP\r
+\r
+    END\r
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 (file)
index 0000000..3e0d540
--- /dev/null
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   LongJump.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   Implementation of _LongJump() on x64.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalLongJump (\r
+;   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+;   IN      UINTN                     Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalLongJump    PROC\r
+    mov     rbx, [rcx]\r
+    mov     rsp, [rcx + 8]\r
+    mov     rbp, [rcx + 10h]\r
+    mov     rdi, [rcx + 18h]\r
+    mov     rsi, [rcx + 20h]\r
+    mov     r12, [rcx + 28h]\r
+    mov     r13, [rcx + 30h]\r
+    mov     r14, [rcx + 38h]\r
+    mov     r15, [rcx + 40h]\r
+    mov     rax, rdx                    ; set return value\r
+    jmp     qword ptr [rcx + 48h]\r
+InternalLongJump    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..d830775
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Monitor.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmMonitor function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmMonitor (\r
+;   IN      UINTN                     Eax,\r
+;   IN      UINTN                     Ecx,\r
+;   IN      UINTN                     Edx\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmMonitor  PROC\r
+    mov     eax, ecx\r
+    mov     ecx, edx\r
+    mov     edx, r8d\r
+    DB      0fh, 1, 0c8h                ; monitor\r
+    ret\r
+AsmMonitor  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4dcdb7b
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Mwait.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmMwait function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmMwait (\r
+;   IN      UINTN                     Eax,\r
+;   IN      UINTN                     Ecx\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmMwait    PROC\r
+    mov     eax, ecx\r
+    mov     ecx, edx\r
+    DB      0fh, 1, 0c9h                ; mwait\r
+    ret\r
+AsmMwait    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..023af1c
--- /dev/null
@@ -0,0 +1,116 @@
+/*++\r
+       \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  Non-existing.c\r
+  \r
+Abstract: \r
+\r
+  Non-existing BaseLib functions on x64\r
+\r
+--*/\r
+\r
+#include "..\BaseLibInternal.h"\r
+\r
+/**\r
+  Enables the 32-bit paging mode on the CPU.\r
+\r
+  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode. This function is\r
+  only available on IA-32. After the 32-bit paging mode is enabled, control is\r
+  transferred to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit protected mode with flat descriptors. This\r
+      means all descriptors must have a base of 0 and a limit of 4GB.\r
+  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
+      descriptors.\r
+  4)  CR3 must point to valid page tables that will be used once the transition\r
+      is complete, and those page tables must guarantee that the pages for this\r
+      function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is enabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is enabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is enabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86EnablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  //\r
+  // This function cannot work on X64 platform\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Disables the 32-bit paging mode on the CPU.\r
+\r
+  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 32-paged protected\r
+  mode. This function is only available on IA-32. After the 32-bit paging mode\r
+  is disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be NULL. The function EntryPoint must never return.\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit paged mode.\r
+  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
+  4)  CR3 must point to valid page tables that guarantee that the pages for\r
+      this function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is disabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is disabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is\r
+                      disabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalX86DisablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  //\r
+  // This function cannot work on X64 platform\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
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 (file)
index 0000000..d9a1459
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr0  PROC\r
+    mov     rax, cr0\r
+    ret\r
+AsmReadCr0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..8a62a36
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr2  PROC\r
+    mov     rax, cr2\r
+    ret\r
+AsmReadCr2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c87fabf
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr3  PROC\r
+    mov     rax, cr3\r
+    ret\r
+AsmReadCr3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b53d063
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadCr4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCr4  PROC\r
+    mov     rax, cr4\r
+    ret\r
+AsmReadCr4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c537764
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadCs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadCs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadCs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadCs   PROC\r
+    mov     eax, cs\r
+    ret\r
+AsmReadCs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f501659
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr0  PROC\r
+    mov     rax, dr0\r
+    ret\r
+AsmReadDr0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..fb3f1f9
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr1 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr1  PROC\r
+    mov     rax, dr1\r
+    ret\r
+AsmReadDr1  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..1a95578
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr2  PROC\r
+    mov     rax, dr2\r
+    ret\r
+AsmReadDr2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..1828fae
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr3  PROC\r
+    mov     rax, dr3\r
+    ret\r
+AsmReadDr3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0708718
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr4  PROC\r
+    ;\r
+    ; There's no obvious reason to access this register, since it's aliased to\r
+    ; DR7 when DE=0 or an exception generated when DE=1\r
+    ;\r
+    DB      0fh, 21h, 0e0h\r
+    ret\r
+AsmReadDr4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..5c74080
--- /dev/null
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr5 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr5  PROC\r
+    ;\r
+    ; There's no obvious reason to access this register, since it's aliased to\r
+    ; DR7 when DE=0 or an exception generated when DE=1\r
+    ;\r
+    DB      0fh, 21h, 0e8h\r
+    ret\r
+AsmReadDr5  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cdf034d
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr6 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr6  PROC\r
+    mov     rax, dr6\r
+    ret\r
+AsmReadDr6  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ee570dd
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDr7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDr7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadDr7 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDr7  PROC\r
+    mov     rax, dr7\r
+    ret\r
+AsmReadDr7  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..525b219
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadDs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadDs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadDs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadDs   PROC\r
+    mov     eax, ds\r
+    ret\r
+AsmReadDs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..83dc8de
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadEflags.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadEflags function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmReadEflags (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadEflags   PROC\r
+    pushfq\r
+    pop     rax\r
+    ret\r
+AsmReadEflags   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..8d94c8b
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadEs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadEs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadEs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadEs   PROC\r
+    mov     eax, es\r
+    ret\r
+AsmReadEs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ea49b68
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadFs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadFs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadFs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadFs   PROC\r
+    mov     eax, fs\r
+    ret\r
+AsmReadFs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4e4cb8b
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadGdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadGdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86ReadGdtr (\r
+;   OUT IA32_DESCRIPTOR  *Gdtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86ReadGdtr   PROC\r
+    sgdt    fword ptr [rcx]\r
+    ret\r
+InternalX86ReadGdtr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..18beba0
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadGs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadGs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadGs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadGs   PROC\r
+    mov     eax, gs\r
+    ret\r
+AsmReadGs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b4d21a0
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadIdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadIdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86ReadIdtr (\r
+;   OUT     IA32_DESCRIPTOR           *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86ReadIdtr   PROC\r
+    sidt    fword ptr [rcx]\r
+    ret\r
+InternalX86ReadIdtr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cc43bfd
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadLdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadLdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadLdtr (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadLdtr PROC\r
+    sldt    eax\r
+    ret\r
+AsmReadLdtr ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c21458e
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm0 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm0  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0c0h\r
+    ret\r
+AsmReadMm0  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..aff4795
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm1 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm1  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0c8h\r
+    ret\r
+AsmReadMm1  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..872e72a
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm2 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm2  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0d0h\r
+    ret\r
+AsmReadMm2  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0178d51
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm3 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm3  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0d8h\r
+    ret\r
+AsmReadMm3  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..07d2291
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm4 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm4  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0e0h\r
+    ret\r
+AsmReadMm4  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..1feb517
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm5 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm5  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0e8h\r
+    ret\r
+AsmReadMm5  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..09f420d
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm6 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm6  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0f0h\r
+    ret\r
+AsmReadMm6  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..b51de17
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMm7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMm7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMm7 (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMm7  PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 7eh, 0f8h\r
+    ret\r
+AsmReadMm7  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..5b376bd
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadMsr64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadMsr64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadMsr64 (\r
+;   IN UINT32  Index\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadMsr64    PROC\r
+    rdmsr                               ; edx & eax are zero extended\r
+    shl     rdx, 20h\r
+    or      rax, rdx\r
+    ret\r
+AsmReadMsr64    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..9c3f69a
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadPmc.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadPmc function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadPmc (\r
+;   IN UINT32   PmcIndex\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadPmc  PROC\r
+    rdpmc\r
+    shl     rdx, 20h\r
+    or      rax, rdx\r
+    ret\r
+AsmReadPmc  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..7f80964
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadSs.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadSs function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadSs (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadSs   PROC\r
+    mov     eax, ss\r
+    ret\r
+AsmReadSs   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..3e29b4f
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadTr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadTr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; EFIAPI\r
+; AsmReadTr (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadTr   PROC\r
+    str     eax\r
+    ret\r
+AsmReadTr   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ffbb5f4
--- /dev/null
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   ReadTsc.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmReadTsc function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmReadTsc (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmReadTsc  PROC\r
+    rdtsc\r
+    shl     rdx, 20h\r
+    or      rax, rdx\r
+    ret\r
+AsmReadTsc  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..cd0293e
--- /dev/null
@@ -0,0 +1,52 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   SetJump.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   Implementation of SetJump() on x64.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+EXTERNDEF   InternalAssertJumpBuffer:PROC\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; SetJump (\r
+;   OUT     BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+SetJump     PROC\r
+    push    rcx\r
+    add     rsp, -20h\r
+    call    InternalAssertJumpBuffer\r
+    add     rsp, 20h\r
+    pop     rcx\r
+    pop     rdx\r
+    mov     [rcx], rbx\r
+    mov     [rcx + 8], rsp\r
+    mov     [rcx + 10h], rbp\r
+    mov     [rcx + 18h], rdi\r
+    mov     [rcx + 20h], rsi\r
+    mov     [rcx + 28h], r12\r
+    mov     [rcx + 30h], r13\r
+    mov     [rcx + 38h], r14\r
+    mov     [rcx + 40h], r15\r
+    mov     [rcx + 48h], rdx\r
+    xor     rax, rax\r
+    jmp     rdx\r
+SetJump     ENDP\r
+\r
+    END\r
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 (file)
index 0000000..db93c13
--- /dev/null
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   SwitchStack.Asm\r
+;\r
+; Abstract:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; Routine Description:\r
+;\r
+;   Routine for switching stacks with 1 parameter\r
+;\r
+; Arguments:\r
+;\r
+;   (rcx) EntryPoint    - Entry point with new stack.\r
+;   (rdx) Context       - Parameter for entry point.\r
+;   (r8)  Context2      - Parameter2 for entry point.\r
+;   (r9)  NewStack      - Pointer to new stack.\r
+;\r
+; Returns:\r
+;\r
+;   None\r
+;\r
+;------------------------------------------------------------------------------\r
+InternalSwitchStack PROC\r
+    mov     rax, rcx\r
+    mov     rcx, rdx\r
+    mov     rdx, r8\r
+    lea     rsp, [r9 - 20h]\r
+    call    rax\r
+InternalSwitchStack ENDP\r
+\r
+    END\r
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 (file)
index 0000000..0c3bb7d
--- /dev/null
@@ -0,0 +1,285 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Thunk.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Real mode thunk\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+EXTERNDEF   m16Start:BYTE\r
+EXTERNDEF   m16Size:WORD\r
+EXTERNDEF   mThunk16Attr:WORD\r
+EXTERNDEF   m16Gdt:WORD\r
+EXTERNDEF   m16GdtrBase:WORD\r
+EXTERNDEF   mTransition:WORD\r
+\r
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15     EQU 2\r
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL   EQU 4\r
+\r
+IA32_REGS   STRUC   4t\r
+_EDI        DD      ?\r
+_ESI        DD      ?\r
+_EBP        DD      ?\r
+_ESP        DD      ?\r
+_EBX        DD      ?\r
+_EDX        DD      ?\r
+_ECX        DD      ?\r
+_EAX        DD      ?\r
+_DS         DW      ?\r
+_ES         DW      ?\r
+_FS         DW      ?\r
+_GS         DW      ?\r
+_EFLAGS     DQ      ?\r
+_EIP        DD      ?\r
+_CS         DW      ?\r
+_SS         DW      ?\r
+IA32_REGS   ENDS\r
+\r
+    .const\r
+\r
+m16Size         DW      InternalAsmThunk16 - m16Start\r
+mThunk16Attr    DW      _ThunkAttr - m16Start\r
+m16Gdt          DW      _NullSeg - m16Start\r
+m16GdtrBase     DW      _16GdtrBase - m16Start\r
+mTransition     DW      _EntryPoint - m16Start\r
+\r
+    .code\r
+\r
+m16Start    LABEL   BYTE\r
+\r
+SavedGdt    LABEL   FWORD\r
+            DW      ?\r
+            DQ      ?\r
+\r
+;------------------------------------------------------------------------------\r
+; _BackFromUserCode() takes control in real mode after 'retf' has been executed\r
+; by user code. It will be shadowed to somewhere in memory below 1MB.\r
+;------------------------------------------------------------------------------\r
+_BackFromUserCode   PROC\r
+    ;\r
+    ; The order of saved registers on the stack matches the order they appears\r
+    ; in IA32_REGS structure. This facilitates wrapper function to extract them\r
+    ; into that structure.\r
+    ;\r
+    ; Some instructions for manipulation of segment registers have to be written\r
+    ; in opcode since 64-bit MASM prevents accesses to those registers.\r
+    ;\r
+    DB      16h                         ; push ss\r
+    DB      0eh                         ; push cs\r
+    DB      66h\r
+    call    @Base                       ; push eip\r
+@Base:\r
+    DB      66h\r
+    push    0                           ; reserved high order 32 bits of EFlags\r
+    pushf                               ; pushfd actually\r
+    cli                                 ; disable interrupts\r
+    push    gs\r
+    push    fs\r
+    DB      6                           ; push es\r
+    DB      1eh                         ; push ds\r
+    DB      66h, 60h                    ; pushad\r
+    DB      66h, 0bah                   ; mov edx, imm32\r
+_ThunkAttr  DD      ?\r
+    test    dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15\r
+    jz      @1\r
+    mov     eax, 15cd2401h              ; mov ax, 2401h & int 15h\r
+    cli                                 ; disable interrupts\r
+    jnc     @2\r
+@1:\r
+    test    dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL\r
+    jz      @2\r
+    in      al, 92h\r
+    or      al, 2\r
+    out     92h, al                     ; deactivate A20M#\r
+@2:\r
+    mov     eax, ss\r
+    lea     bp, [esp + sizeof (IA32_REGS)]\r
+    ;\r
+    ; rsi in the following 2 instructions is indeed bp in 16-bit code\r
+    ;\r
+    mov     word ptr (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._ESP, bp\r
+    DB      66h\r
+    mov     ebx, (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._EIP\r
+    shl     ax, 4                       ; shl eax, 4\r
+    add     bp, ax                      ; add ebp, eax\r
+    mov     ax, cs\r
+    shl     ax, 4\r
+    lea     ax, [eax + ebx + (@64BitCode - @Base)]\r
+    DB      66h, 2eh, 89h, 87h          ; mov cs:[bx + (@64Eip - @Base)], eax\r
+    DW      @64Eip - @Base\r
+    DB      66h, 0b8h                   ; mov eax, imm32\r
+SavedCr4    DD      ?\r
+    mov     cr4, rax\r
+    ;\r
+    ; rdi in the instruction below is indeed bx in 16-bit code\r
+    ;\r
+    DB      66h, 2eh                    ; 2eh is "cs:" segment override\r
+    lgdt    fword ptr [rdi + (SavedGdt - @Base)]\r
+    DB      66h\r
+    mov     ecx, 0c0000080h\r
+    rdmsr\r
+    or      ah, 1\r
+    wrmsr\r
+    DB      66h, 0b8h                   ; mov eax, imm32\r
+SavedCr0    DD      ?\r
+    mov     cr0, rax\r
+    DB      66h, 0eah                   ; jmp far cs:@64Bit\r
+@64Eip      DD      ?\r
+SavedCs     DW      ?\r
+@64BitCode:\r
+    mov     rsp, r8                     ; restore stack\r
+    ret\r
+_BackFromUserCode   ENDP\r
+\r
+_EntryPoint DD      _ToUserCode - m16Start\r
+            DW      CODE16\r
+_16Gdtr     LABEL   FWORD\r
+            DW      GDT_SIZE - 1\r
+_16GdtrBase DQ      _NullSeg\r
+_16Idtr     FWORD   (1 SHL 10) - 1\r
+\r
+;------------------------------------------------------------------------------\r
+; _ToUserCode() takes control in real mode before passing control to user code.\r
+; It will be shadowed to somewhere in memory below 1MB.\r
+;------------------------------------------------------------------------------\r
+_ToUserCode PROC\r
+    mov     ss, edx                     ; set new segment selectors\r
+    mov     ds, edx\r
+    mov     es, edx\r
+    mov     fs, edx\r
+    mov     gs, edx\r
+    DB      66h\r
+    mov     ecx, 0c0000080h\r
+    mov     cr0, rax                    ; real mode starts at next instruction\r
+    rdmsr\r
+    and     ah, NOT 1\r
+    wrmsr\r
+    mov     cr4, rbp\r
+    mov     ss, esi                     ; set up 16-bit stack segment\r
+    mov     sp, bx                      ; set up 16-bit stack pointer\r
+    DB      66h                         ; make the following call 32-bit\r
+    call    @Base                       ; push eip\r
+@Base:\r
+    pop     bp                          ; ebp <- address of @Base\r
+    push    [esp + sizeof (IA32_REGS) + 2]\r
+    lea     eax, [rsi + (@RealMode - @Base)]    ; rsi is "bp" in 16-bit code\r
+    push    rax\r
+    retf                                ; execution begins at next instruction\r
+@RealMode:\r
+    DB      66h, 2eh                    ; CS and operand size override\r
+    lidt    fword ptr [rsi + (_16Idtr - @Base)]\r
+    DB      66h, 61h                    ; popad\r
+    DB      1fh                         ; pop ds\r
+    DB      07h                         ; pop es\r
+    pop     fs\r
+    pop     gs\r
+    popf                                ; popfd\r
+    lea     sp, [esp + 4]               ; skip high order 32 bits of EFlags\r
+    DB      66h                         ; make the following retf 32-bit\r
+    retf                                ; transfer control to user code\r
+_ToUserCode ENDP\r
+\r
+CODE16  = _16Code - $\r
+DATA16  = _16Data - $\r
+DATA32  = _32Data - $\r
+\r
+_NullSeg    DQ      0\r
+_16Code     LABEL   QWORD\r
+            DW      -1\r
+            DW      0\r
+            DB      0\r
+            DB      9bh\r
+            DB      8fh                 ; 16-bit segment, 4GB limit\r
+            DB      0\r
+_16Data     LABEL   QWORD\r
+            DW      -1\r
+            DW      0\r
+            DB      0\r
+            DB      93h\r
+            DB      8fh                 ; 16-bit segment, 4GB limit\r
+            DB      0\r
+_32Data     LABEL   QWORD\r
+            DW      -1\r
+            DW      0\r
+            DB      0\r
+            DB      93h\r
+            DB      0cfh                ; 16-bit segment, 4GB limit\r
+            DB      0\r
+\r
+GDT_SIZE = $ - _NullSeg\r
+\r
+;------------------------------------------------------------------------------\r
+; IA32_REGISTER_SET *\r
+; EFIAPI\r
+; InternalAsmThunk16 (\r
+;   IN      IA32_REGISTER_SET         *RegisterSet,\r
+;   IN OUT  VOID                      *Transition\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalAsmThunk16  PROC    USES    rbp rbx rsi rdi\r
+    mov     r10d, ds                    ; r9 ~ r11 are not accessible in 16-bit\r
+    mov     r11d, es                    ; so use them for saving seg registers\r
+    mov     r9d, ss\r
+    push    fs\r
+    push    gs\r
+    mov     rsi, rcx\r
+    movzx   r8d, (IA32_REGS ptr [rsi])._SS\r
+    mov     edi, (IA32_REGS ptr [rsi])._ESP\r
+    lea     rdi, [edi - (sizeof (IA32_REGS) + 4)]\r
+    imul    eax, r8d, 16                ; eax <- r8d(stack segment) * 16\r
+    mov     ebx, edi                    ; ebx <- stack for 16-bit code\r
+    push    sizeof (IA32_REGS) / 4\r
+    add     edi, eax                    ; edi <- linear address of 16-bit stack\r
+    pop     rcx\r
+    rep     movsd                       ; copy RegSet\r
+    lea     ecx, [rdx + (SavedCr4 - m16Start)]\r
+    mov     eax, edx                    ; eax <- transition code address\r
+    and     edx, 0fh\r
+    shl     eax, 12                     ; segment address in high order 16 bits\r
+    lea     ax, [rdx + (_BackFromUserCode - m16Start)]  ; offset address\r
+    stosd                               ; [edi] <- return address of user code\r
+    sgdt    fword ptr [rcx + (SavedGdt - SavedCr4)]\r
+    sidt    fword ptr [rsp + 38h]       ; save IDT stack in argument space\r
+    mov     rax, cr0\r
+    mov     [rcx + (SavedCr0 - SavedCr4)], eax\r
+    and     eax, 7ffffffeh              ; clear PE, PG bits\r
+    mov     rbp, cr4\r
+    mov     [rcx], ebp                  ; save CR4 in SavedCr4\r
+    and     ebp, 300h                   ; clear all but PCE and OSFXSR bits\r
+    mov     esi, r8d                    ; esi <- 16-bit stack segment\r
+    DB      6ah, DATA32                 ; push DATA32\r
+    pop     rdx                         ; rdx <- 32-bit data segment selector\r
+    lgdt    fword ptr [rcx + (_16Gdtr - SavedCr4)]\r
+    mov     ss, edx\r
+    pushfq\r
+    lea     edx, [rdx + DATA16 - DATA32]\r
+    lea     r8, @RetFromRealMode\r
+    push    r8\r
+    mov     r8d, cs\r
+    mov     [rcx + (SavedCs - SavedCr4)], r8w\r
+    mov     r8, rsp\r
+    jmp     fword ptr [rcx + (_EntryPoint - SavedCr4)]\r
+@RetFromRealMode:\r
+    popfq\r
+    lidt    fword ptr [rsp + 38h]       ; restore protected mode IDTR\r
+    lea     eax, [rbp - sizeof (IA32_REGS)]\r
+    pop     gs\r
+    pop     fs\r
+    mov     ss, r9d\r
+    mov     es, r11d\r
+    mov     ds, r10d\r
+    ret\r
+InternalAsmThunk16  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..722e1f8
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   Wbinvd.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWbinvd function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWbinvd (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWbinvd   PROC\r
+    wbinvd\r
+    ret\r
+AsmWbinvd   ENDP\r
+\r
+    END\r
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 (file)
index 0000000..aab3525
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr0 (\r
+;   UINTN  Cr0\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr0 PROC\r
+    mov     cr0, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteCr0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..30194c4
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr2 (\r
+;   UINTN  Cr2\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr2 PROC\r
+    mov     cr2, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteCr2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..a32b5df
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr3 (\r
+;   UINTN  Cr3\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr3 PROC\r
+    mov     cr3, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteCr3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..c20d1ef
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteCr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteCr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteCr4 (\r
+;   UINTN  Cr4\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteCr4 PROC\r
+    mov     cr4, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteCr4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..ad4f36a
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr0 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr0 PROC\r
+    mov     dr0, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..a298285
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr1 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr1 PROC\r
+    mov     dr1, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr1 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2ee275c
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr2 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr2 PROC\r
+    mov     dr2, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..42512c1
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr3 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr3 PROC\r
+    mov     dr3, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..487a8a6
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr4 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr4 PROC\r
+    ;\r
+    ; There's no obvious reason to access this register, since it's aliased to\r
+    ; DR6 when DE=0 or an exception generated when DE=1\r
+    ;\r
+    DB      0fh, 23h, 0e1h\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..4417c58
--- /dev/null
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr6 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr5 PROC\r
+    ;\r
+    ; There's no obvious reason to access this register, since it's aliased to\r
+    ; DR7 when DE=0 or an exception generated when DE=1\r
+    ;\r
+    DB      0fh, 23h, 0e9h\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr5 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..28fd589
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr6 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr6 PROC\r
+    mov     dr6, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr6 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..07a25ee
--- /dev/null
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteDr7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteDr7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; EFIAPI\r
+; AsmWriteDr7 (\r
+;   IN UINTN Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteDr7 PROC\r
+    mov     dr7, rcx\r
+    mov     rax, rcx\r
+    ret\r
+AsmWriteDr7 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..e401a67
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteGdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteGdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86WriteGdtr (\r
+;   IN      CONST IA32_DESCRIPTOR     *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86WriteGdtr  PROC\r
+    lgdt    fword ptr [rcx]\r
+    ret\r
+InternalX86WriteGdtr  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..aa8c70d
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteIdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteIdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; InternalX86WriteIdtr (\r
+;   IN      CONST IA32_DESCRIPTOR     *Idtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+InternalX86WriteIdtr  PROC\r
+    lidt    fword ptr [rcx]\r
+    ret\r
+InternalX86WriteIdtr  ENDP\r
+\r
+    END\r
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 (file)
index 0000000..92ca864
--- /dev/null
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteLdtr.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteLdtr function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteLdtr (\r
+;   IN UINT16 Ldtr\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteLdtr    PROC\r
+    lldt    cx\r
+    ret\r
+AsmWriteLdtr    ENDP\r
+\r
+    END\r
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 (file)
index 0000000..e906440
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm0.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm0 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm0 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm0 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0c1h\r
+    ret\r
+AsmWriteMm0 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..49b7b18
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm1.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm1 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm1 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm1 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0c9h\r
+    ret\r
+AsmWriteMm1 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..358194e
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm2.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm2 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm2 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm2 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0d1h\r
+    ret\r
+AsmWriteMm2 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..48e1c32
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm3.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm3 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm3 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm3 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0d9h\r
+    ret\r
+AsmWriteMm3 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..f90f9d3
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm4.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm4 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm4 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm4 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0e1h\r
+    ret\r
+AsmWriteMm4 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..2d06be2
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm5.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm5 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm5 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm5 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0e9h\r
+    ret\r
+AsmWriteMm5 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..42e17f9
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm6.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm6 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm6 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm6 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0f1h\r
+    ret\r
+AsmWriteMm6 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..17e8f98
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMm7.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMm7 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmWriteMm7 (\r
+;   IN UINT64   Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMm7 PROC\r
+    ;\r
+    ; 64-bit MASM doesn't support MMX instructions, so use opcode here\r
+    ;\r
+    DB      48h, 0fh, 6eh, 0f9h\r
+    ret\r
+AsmWriteMm7 ENDP\r
+\r
+    END\r
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 (file)
index 0000000..95c48f4
--- /dev/null
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+;\r
+; Module Name:\r
+;\r
+;   WriteMsr64.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   AsmWriteMsr64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT64\r
+; EFIAPI\r
+; AsmWriteMsr64 (\r
+;   IN UINT32  Index,\r
+;   IN UINT64  Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmWriteMsr64   PROC\r
+    mov     rax, rdx                    ; meanwhile, rax <- return value\r
+    shr     rdx, 20h                    ; edx:eax contains the value to write\r
+    wrmsr\r
+    ret\r
+AsmWriteMsr64   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c
new file mode 100644 (file)
index 0000000..8af5534
--- /dev/null
@@ -0,0 +1,71 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86DisablePaging32.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Disables the 32-bit paging mode on the CPU.\r
+\r
+  Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 32-paged protected\r
+  mode. This function is only available on IA-32. After the 32-bit paging mode\r
+  is disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be NULL. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit paged mode, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit paged mode.\r
+  3)  CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
+  4)  CR3 must point to valid page tables that guarantee that the pages for\r
+      this function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is disabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is disabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is\r
+                      disabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmDisablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  ASSERT (EntryPoint != NULL);\r
+  ASSERT (NewStack != NULL);\r
+  InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c
new file mode 100644 (file)
index 0000000..5c4737b
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86DisablePaging64.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Disables the 64-bit paging mode on the CPU.\r
+\r
+  Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
+  mode. This function assumes the current execution mode is 64-paging mode.\r
+  This function is only available on X64. After the 64-bit paging mode is\r
+  disabled, control is transferred to the function specified by EntryPoint\r
+  using the new stack specified by NewStack and passing in the parameters\r
+  specified by Context1 and Context2. Context1 and Context2 are optional and\r
+  may be 0. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 64-bit paged mode, then ASSERT().\r
+  If EntryPoint is 0, then ASSERT().\r
+  If NewStack is 0, then ASSERT().\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for 32-bit protected mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is disabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is disabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is disabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is disabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmDisablePaging64 (\r
+  IN      UINT16                    Cs,\r
+  IN      UINT32                    EntryPoint,\r
+  IN      UINT32                    Context1,  OPTIONAL\r
+  IN      UINT32                    Context2,  OPTIONAL\r
+  IN      UINT32                    NewStack\r
+  )\r
+{\r
+  ASSERT (EntryPoint != 0);\r
+  ASSERT (NewStack != 0);\r
+  InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c
new file mode 100644 (file)
index 0000000..33622a5
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86EnablePaging32.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Enables the 32-bit paging mode on the CPU.\r
+\r
+  Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode. This function is\r
+  only available on IA-32. After the 32-bit paging mode is enabled, control is\r
+  transferred to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit protected mode, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  There are a number of constraints that must be followed before calling this\r
+  function:\r
+  1)  Interrupts must be disabled.\r
+  2)  The caller must be in 32-bit protected mode with flat descriptors. This\r
+      means all descriptors must have a base of 0 and a limit of 4GB.\r
+  3)  CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
+      descriptors.\r
+  4)  CR3 must point to valid page tables that will be used once the transition\r
+      is complete, and those page tables must guarantee that the pages for this\r
+      function and the stack are identity mapped.\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack after\r
+                      paging is enabled.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function as the first parameter after paging is enabled.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function as the second parameter after paging is enabled.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmEnablePaging32 (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  ASSERT (EntryPoint != NULL);\r
+  ASSERT (NewStack != NULL);\r
+  InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c
new file mode 100644 (file)
index 0000000..790c80c
--- /dev/null
@@ -0,0 +1,70 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86EnablePaging64.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Enables the 64-bit paging mode on the CPU.\r
+\r
+  Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
+  must be properly initialized prior to calling this service. This function\r
+  assumes the current execution mode is 32-bit protected mode with flat\r
+  descriptors. This function is only available on IA-32. After the 64-bit\r
+  paging mode is enabled, control is transferred to the function specified by\r
+  EntryPoint using the new stack specified by NewStack and passing in the\r
+  parameters specified by Context1 and Context2. Context1 and Context2 are\r
+  optional and may be 0. The function EntryPoint must never return.\r
+\r
+  If the current execution mode is not 32-bit protected mode with flat\r
+  descriptors, then ASSERT().\r
+  If EntryPoint is 0, then ASSERT().\r
+  If NewStack is 0, then ASSERT().\r
+\r
+  @param  Cs          The 16-bit selector to load in the CS before EntryPoint\r
+                      is called. The descriptor in the GDT that this selector\r
+                      references must be setup for long mode.\r
+  @param  EntryPoint  The 64-bit virtual address of the function to call with\r
+                      the new stack after paging is enabled.\r
+  @param  Context1    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the first parameter after\r
+                      paging is enabled.\r
+  @param  Context2    The 64-bit virtual address of the context to pass into\r
+                      the EntryPoint function as the second parameter after\r
+                      paging is enabled.\r
+  @param  NewStack    The 64-bit virtual address of the new stack to use for\r
+                      the EntryPoint function after paging is enabled.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmEnablePaging64 (\r
+  IN      UINT16                    Cs,\r
+  IN      UINT64                    EntryPoint,\r
+  IN      UINT64                    Context1,  OPTIONAL\r
+  IN      UINT64                    Context2,  OPTIONAL\r
+  IN      UINT64                    NewStack\r
+  )\r
+{\r
+  ASSERT (EntryPoint != 0);\r
+  ASSERT (NewStack != 0);\r
+  InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c
new file mode 100644 (file)
index 0000000..46a3eef
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86FxRestore.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Restores the current floating point/SSE/SSE2 context from a buffer.\r
+\r
+  Restores the current floating point/SSE/SSE2 state from the buffer specified\r
+  by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
+  If Buffer was not saved with AsmFxSave(), then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmFxRestore (\r
+  IN CONST IA32_FX_BUFFER  *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & 0xf) == 0);\r
+\r
+  //\r
+  // Check the flag recorded by AsmFxSave()\r
+  //\r
+  ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA);\r
+\r
+  InternalX86FxRestore (Buffer);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c
new file mode 100644 (file)
index 0000000..de59619
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86FxSave.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Save the current floating point/SSE/SSE2 context to a buffer.\r
+\r
+  Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
+  Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmFxSave (\r
+  OUT     IA32_FX_BUFFER            *Buffer\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & 0xf) == 0);\r
+\r
+  InternalX86FxSave (Buffer);\r
+\r
+  //\r
+  // Mark one flag at end of Buffer, it will be check by AsmFxRestor()\r
+  //\r
+  *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c
new file mode 100644 (file)
index 0000000..d3fd368
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86GetInterruptState.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Retrieves the current CPU interrupt state.\r
+\r
+  Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r
+  currently enabled. Otherwise returns FALSE.\r
+\r
+  @retval TRUE  CPU interrupts are enabled.\r
+  @retval FALSE CPU interrupts are disabled.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueGetInterruptState (\r
+  VOID\r
+  )\r
+{\r
+  IA32_EFLAGS32                     EFlags;\r
+\r
+  EFlags.UintN = AsmReadEflags ();\r
+  return (BOOLEAN)(EFlags.Bits.IF == 1);\r
+}\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c
new file mode 100644 (file)
index 0000000..4a9c2ad
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86MemoryFence.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Used to serialize load and store operations.\r
+\r
+  All loads and stores that proceed calls to this function are guaranteed to be\r
+  globally visible when this function returns.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MemoryFence (\r
+  VOID\r
+  )\r
+{\r
+  return;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c
new file mode 100644 (file)
index 0000000..ce7d58d
--- /dev/null
@@ -0,0 +1,657 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86Msr.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Returns the lower 32-bits of a Machine Specific Register(MSR).\r
+\r
+  Reads and returns the lower 32-bits of the MSR specified by Index.\r
+  No parameter checking is performed on Index, and some Index values may cause\r
+  CPU exceptions. The caller must either guarantee that Index is valid, or the\r
+  caller must set up exception handlers to catch the exceptions. This function\r
+  is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to read.\r
+\r
+  @return The lower 32 bits of the MSR identified by Index.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmReadMsr32 (\r
+  IN      UINT32                    Index\r
+  )\r
+{\r
+  return (UINT32)AsmReadMsr64 (Index);\r
+}\r
+\r
+/**\r
+  Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
+\r
+  Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
+  upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
+  the MSR is returned. No parameter checking is performed on Index or Value,\r
+  and some of these may cause CPU exceptions. The caller must either guarantee\r
+  that Index and Value are valid, or the caller must establish proper exception\r
+  handlers. This function is only available on IA-32 and X64.\r
+\r
+  @param  Index The 32-bit MSR index to write.\r
+  @param  Value The 32-bit value to write to the MSR.\r
+\r
+  @return Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmWriteMsr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return (UINT32)AsmWriteMsr64 (Index, Value);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
+  writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the lower 32-bits of the read result and the value specified by\r
+  OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
+  32-bits of the value written to the MSR is returned. No parameter checking is\r
+  performed on Index or OrData, and some of these may cause CPU exceptions. The\r
+  caller must either guarantee that Index and OrData are valid, or the caller\r
+  must establish proper exception handlers. This function is only available on\r
+  IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  OrData  The value to OR with the read value from the MSR.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return (UINT32)AsmMsrOr64 (Index, OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
+  the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  lower 32-bits of the read result and the value specified by AndData, and\r
+  writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
+  the value written to the MSR is returned. No parameter checking is performed\r
+  on Index or AndData, and some of these may cause CPU exceptions. The caller\r
+  must either guarantee that Index and AndData are valid, or the caller must\r
+  establish proper exception handlers. This function is only available on IA-32\r
+  and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAnd32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return (UINT32)AsmMsrAnd64 (Index, AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
+  on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  lower 32-bits of the read result and the value specified by AndData\r
+  preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
+  result of the AND operation and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
+  written to the MSR is returned. No parameter checking is performed on Index,\r
+  AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
+  must either guarantee that Index, AndData, and OrData are valid, or the\r
+  caller must establish proper exception handlers. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The lower 32-bit value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrAndThenOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an MSR.\r
+\r
+  Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned. The caller must either guarantee that Index is valid, or the caller\r
+  must set up exception handlers to catch the exceptions. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The bit field read from the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldRead32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an MSR.\r
+\r
+  Writes Value to a bit field in the lower 32-bits of a  64-bit MSR. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination MSR are preserved. The lower 32-bits of the MSR written is\r
+  returned. Extra left bits in Value are stripped. The caller must either\r
+  guarantee that Index and the data written is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldWrite32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (Value) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
+  written to the MSR are returned. Extra left bits in OrData are stripped. The\r
+  caller must either guarantee that Index and the data written is valid, or\r
+  the caller must set up exception handlers to catch the exceptions. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the MSR.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (OrData) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by AndData, and writes the result to the\r
+  64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
+  MSR are returned. Extra left bits in AndData are stripped. The caller must\r
+  either guarantee that Index and the data written is valid, or the caller must\r
+  set up exception handlers to catch the exceptions. This function is only\r
+  available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the MSR.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldAnd32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (AndData) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+  lower 32-bits of the value written to the MSR are returned. Extra left bits\r
+  in both AndData and OrData are stripped. The caller must either guarantee\r
+  that Index and the data written is valid, or the caller must set up exception\r
+  handlers to catch the exceptions. This function is only available on IA-32\r
+  and X64.\r
+\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the MSR.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The lower 32-bit of the value written to the MSR.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmMsrBitFieldAndThenOr32 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT (EndBit < sizeof (AndData) * 8);\r
+  ASSERT (StartBit <= EndBit);\r
+  return (UINT32)AsmMsrBitFieldAndThenOr64 (\r
+                   Index,\r
+                   StartBit,\r
+                   EndBit,\r
+                   AndData,\r
+                   OrData\r
+                   );\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
+  back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+  returned. No parameter checking is performed on Index or OrData, and some of\r
+  these may cause CPU exceptions. The caller must either guarantee that Index\r
+  and OrData are valid, or the caller must establish proper exception handlers.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  OrData  The value to OR with the read value from the MSR.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by OrData, and writes the result to the\r
+  64-bit MSR specified by Index. The value written to the MSR is returned. No\r
+  parameter checking is performed on Index or OrData, and some of these may\r
+  cause CPU exceptions. The caller must either guarantee that Index and OrData\r
+  are valid, or the caller must establish proper exception handlers. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAnd64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r
+  OR, and writes the result back to the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
+  result and the value specified by AndData, performs a bitwise inclusive OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 64-bit MSR specified by Index. The value written\r
+  to the MSR is returned. No parameter checking is performed on Index, AndData,\r
+  or OrData, and some of these may cause CPU exceptions. The caller must either\r
+  guarantee that Index, AndData, and OrData are valid, or the caller must\r
+  establish proper exception handlers. This function is only available on IA-32\r
+  and X64.\r
+\r
+  @param  Index   The 32-bit MSR index to write.\r
+  @param  AndData The value to AND with the read value from the MSR.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrAndThenOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an MSR.\r
+\r
+  Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
+  StartBit and the EndBit. The value of the bit field is returned. The caller\r
+  must either guarantee that Index is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldRead64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an MSR.\r
+\r
+  Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
+  the StartBit and the EndBit. All other bits in the destination MSR are\r
+  preserved. The MSR written is returned. Extra left bits in Value are\r
+  stripped. The caller must either guarantee that Index and the data written is\r
+  valid, or the caller must set up exception handlers to catch the exceptions.\r
+  This function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldWrite64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  return AsmWriteMsr64 (\r
+           Index,\r
+           BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
+  writes the result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit MSR specified by Index. The value written to the MSR is\r
+  returned. Extra left bits in OrData are stripped. The caller must either\r
+  guarantee that Index and the data written is valid, or the caller must set up\r
+  exception handlers to catch the exceptions. This function is only available\r
+  on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (\r
+           Index,\r
+           BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
+  read result and the value specified by AndData, and writes the result to the\r
+  64-bit MSR specified by Index. The value written to the MSR is returned.\r
+  Extra left bits in AndData are stripped. The caller must either guarantee\r
+  that Index and the data written is valid, or the caller must set up exception\r
+  handlers to catch the exceptions. This function is only available on IA-32\r
+  and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the bit field.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldAnd64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (\r
+           Index,\r
+           BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MSR.\r
+\r
+  Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
+  a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit MSR specified by Index. The\r
+  value written to the MSR is returned. Extra left bits in both AndData and\r
+  OrData are stripped. The caller must either guarantee that Index and the data\r
+  written is valid, or the caller must set up exception handlers to catch the\r
+  exceptions. This function is only available on IA-32 and X64.\r
+\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Index     The 32-bit MSR index to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the bit field.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MSR.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmMsrBitFieldAndThenOr64 (\r
+  IN      UINT32                    Index,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return AsmWriteMsr64 (\r
+           Index,\r
+           BitFieldAndThenOr64 (\r
+             AsmReadMsr64 (Index),\r
+             StartBit,\r
+             EndBit,\r
+             AndData,\r
+             OrData\r
+             )\r
+           );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c
new file mode 100644 (file)
index 0000000..b271f7e
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86ReadGdtr.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If Gdtr is NULL, then ASSERT().\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmReadGdtr (\r
+  OUT     IA32_DESCRIPTOR           *Gdtr\r
+  )\r
+{\r
+  ASSERT (Gdtr != NULL);\r
+  InternalX86ReadGdtr (Gdtr);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c
new file mode 100644 (file)
index 0000000..579b738
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86ReadIdtr.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
+  function is only available on IA-32 and X64.\r
+\r
+  If Idtr is NULL, then ASSERT().\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmReadIdtr (\r
+  OUT     IA32_DESCRIPTOR           *Idtr\r
+  )\r
+{\r
+  ASSERT (Idtr != NULL);\r
+  InternalX86ReadIdtr (Idtr);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c
new file mode 100644 (file)
index 0000000..aafc18d
--- /dev/null
@@ -0,0 +1,250 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86Thunk.c\r
+  \r
+Abstract: \r
+\r
+  Real Mode Thunk Functions for IA32 and X64.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+//\r
+// Byte packed structure for a segment descriptor in a GDT/LDT\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  LimitLow:16;\r
+    UINT32  BaseLow:16;\r
+    UINT32  BaseMid:8;\r
+    UINT32  Type:4;\r
+    UINT32  S:1;\r
+    UINT32  DPL:2;\r
+    UINT32  P:1;\r
+    UINT32  LimitHigh:4;\r
+    UINT32  AVL:1;\r
+    UINT32  L:1;\r
+    UINT32  DB:1;\r
+    UINT32  G:1;\r
+    UINT32  BaseHigh:8;\r
+  } Bits;\r
+  UINT64  Uint64;\r
+} IA32_SEGMENT_DESCRIPTOR;\r
+\r
+extern CONST UINT8                  m16Start;\r
+extern CONST UINT16                 m16Size;\r
+extern CONST UINT16                 mThunk16Attr;\r
+extern CONST UINT16                 m16Gdt;\r
+extern CONST UINT16                 m16GdtrBase;\r
+extern CONST UINT16                 mTransition;\r
+\r
+/**\r
+  Invokes 16-bit code in big real mode and returns the updated register set.\r
+\r
+  This function transfers control to the 16-bit code specified by CS:EIP using\r
+  the stack specified by SS:ESP in RegisterSet. The updated registers are saved\r
+  on the real mode stack and the starting address of the save area is returned.\r
+\r
+  @param  RegisterSet Values of registers before invocation of 16-bit code.\r
+  @param  Transition  Pointer to the transition code under 1MB.\r
+\r
+  @return The pointer to a IA32_REGISTER_SET structure containing the updated\r
+          register values.\r
+\r
+**/\r
+IA32_REGISTER_SET *\r
+EFIAPI\r
+InternalAsmThunk16 (\r
+  IN      IA32_REGISTER_SET         *RegisterSet,\r
+  IN OUT  VOID                      *Transition\r
+  );\r
+\r
+/**\r
+  Retrieves the properties for 16-bit thunk functions.\r
+\r
+  Computes the size of the buffer and stack below 1MB required to use the\r
+  AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
+  buffer size is returned in RealModeBufferSize, and the stack size is returned\r
+  in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
+  then the actual minimum stack size is ExtraStackSize plus the maximum number\r
+  of bytes that need to be passed to the 16-bit real mode code.\r
+\r
+  If RealModeBufferSize is NULL, then ASSERT().\r
+  If ExtraStackSize is NULL, then ASSERT().\r
+\r
+  @param  RealModeBufferSize  A pointer to the size of the buffer below 1MB\r
+                              required to use the 16-bit thunk functions.\r
+  @param  ExtraStackSize      A pointer to the extra size of stack below 1MB\r
+                              that the 16-bit thunk functions require for\r
+                              temporary storage in the transition to and from\r
+                              16-bit real mode.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmGetThunk16Properties (\r
+  OUT     UINT32                    *RealModeBufferSize,\r
+  OUT     UINT32                    *ExtraStackSize\r
+  )\r
+{\r
+  ASSERT (RealModeBufferSize != NULL);\r
+  ASSERT (ExtraStackSize != NULL);\r
+\r
+  *RealModeBufferSize = m16Size;\r
+\r
+  //\r
+  // Extra 4 bytes for return address, and another 4 bytes for mode transition\r
+  //\r
+  *ExtraStackSize = sizeof (IA32_DWORD_REGS) + 8;\r
+}\r
+\r
+/**\r
+  Prepares all structures a code required to use AsmThunk16().\r
+\r
+  Prepares all structures and code required to use AsmThunk16().\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmPrepareThunk16 (\r
+  OUT     THUNK_CONTEXT             *ThunkContext\r
+  )\r
+{\r
+  IA32_SEGMENT_DESCRIPTOR           *RealModeGdt;\r
+\r
+  ASSERT (ThunkContext != NULL);\r
+  ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000);\r
+  ASSERT (ThunkContext->RealModeBufferSize >= m16Size);\r
+  ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000);\r
+\r
+  CopyMem (ThunkContext->RealModeBuffer, &m16Start, m16Size);\r
+\r
+  //\r
+  // Point RealModeGdt to the GDT to be used in transition\r
+  //\r
+  // RealModeGdt[0]: Reserved as NULL descriptor\r
+  // RealModeGdt[1]: Code Segment\r
+  // RealModeGdt[2]: Data Segment\r
+  // RealModeGdt[3]: Call Gate\r
+  //\r
+  RealModeGdt = (IA32_SEGMENT_DESCRIPTOR*)(\r
+                  (UINTN)ThunkContext->RealModeBuffer + m16Gdt);\r
+\r
+  //\r
+  // Update Code & Data Segment Descriptor\r
+  //\r
+  RealModeGdt[1].Bits.BaseLow =\r
+    (UINT32)(UINTN)ThunkContext->RealModeBuffer & ~0xf;\r
+  RealModeGdt[1].Bits.BaseMid =\r
+    (UINT32)(UINTN)ThunkContext->RealModeBuffer >> 16;\r
+\r
+  //\r
+  // Update transition code entry point offset\r
+  //\r
+  *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mTransition) +=\r
+    (UINT32)(UINTN)ThunkContext->RealModeBuffer & 0xf;\r
+\r
+  //\r
+  // Update Segment Limits for both Code and Data Segment Descriptors\r
+  //\r
+  if ((ThunkContext->ThunkAttributes & THUNK_ATTRIBUTE_BIG_REAL_MODE) == 0) {\r
+    //\r
+    // Set segment limits to 64KB\r
+    //\r
+    RealModeGdt[1].Bits.LimitHigh = 0;\r
+    RealModeGdt[1].Bits.G = 0;\r
+    RealModeGdt[2].Bits.LimitHigh = 0;\r
+    RealModeGdt[2].Bits.G = 0;\r
+  }\r
+\r
+  //\r
+  // Update GDTBASE for this thunk context\r
+  //\r
+  *(VOID**)((UINTN)ThunkContext->RealModeBuffer + m16GdtrBase) = RealModeGdt;\r
+\r
+  //\r
+  // Update Thunk Attributes\r
+  //\r
+  *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mThunk16Attr) =\r
+    ThunkContext->ThunkAttributes;\r
+}\r
+\r
+/**\r
+  Transfers control to a 16-bit real mode entry point and returns the results.\r
+\r
+  Transfers control to a 16-bit real mode entry point and returns the results.\r
+  AsmPrepareThunk16() must be called with ThunkContext before this function is\r
+  used. This function must be called with interrupts disabled.\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+  If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmThunk16 (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  )\r
+{\r
+  IA32_REGISTER_SET                 *UpdatedRegs;\r
+\r
+  ASSERT (ThunkContext != NULL);\r
+  ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000);\r
+  ASSERT (ThunkContext->RealModeBufferSize >= m16Size);\r
+  ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000);\r
+\r
+  UpdatedRegs = InternalAsmThunk16 (\r
+                  ThunkContext->RealModeState,\r
+                  ThunkContext->RealModeBuffer\r
+                  );\r
+\r
+  CopyMem (ThunkContext->RealModeState, UpdatedRegs, sizeof (*UpdatedRegs));\r
+}\r
+\r
+/**\r
+  Prepares all structures and code for a 16-bit real mode thunk, transfers\r
+  control to a 16-bit real mode entry point, and returns the results.\r
+\r
+  Prepares all structures and code for a 16-bit real mode thunk, transfers\r
+  control to a 16-bit real mode entry point, and returns the results. If the\r
+  caller only need to perform a single 16-bit real mode thunk, then this\r
+  service should be used. If the caller intends to make more than one 16-bit\r
+  real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
+  once and AsmThunk16() can be called for each 16-bit real mode thunk. This\r
+  function must be called with interrupts disabled.\r
+\r
+  If ThunkContext is NULL, then ASSERT().\r
+\r
+  @param  ThunkContext  A pointer to the context structure that describes the\r
+                        16-bit real mode code to call.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmPrepareAndThunk16 (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  )\r
+{\r
+  AsmPrepareThunk16 (ThunkContext);\r
+  AsmThunk16 (ThunkContext);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c
new file mode 100644 (file)
index 0000000..9dfa789
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86WriteGdtr.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
+\r
+  Writes and the current GDTR descriptor specified by Gdtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Gdtr is NULL, then ASSERT().\r
+\r
+  @param  Gdtr  Pointer to a GDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteGdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Gdtr\r
+  )\r
+{\r
+  ASSERT (Gdtr != NULL);\r
+  InternalX86WriteGdtr (Gdtr);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c
new file mode 100644 (file)
index 0000000..fed0ef8
--- /dev/null
@@ -0,0 +1,44 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86WriteIdtr.c\r
+  \r
+Abstract: \r
+\r
+  IA-32/x64 specific functions.\r
+\r
+--*/\r
+\r
+#include "BaseLibInternal.h"\r
+\r
+/**\r
+  Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+\r
+  Writes the current IDTR descriptor and returns it in Idtr. This function is\r
+  only available on IA-32 and X64.\r
+\r
+  If Idtr is NULL, then ASSERT().\r
+\r
+  @param  Idtr  Pointer to a IDTR descriptor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteIdtr (\r
+  IN      CONST IA32_DESCRIPTOR     *Idtr\r
+  )\r
+{\r
+  ASSERT (Idtr != NULL);\r
+  InternalX86WriteIdtr (Idtr);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf
new file mode 100644 (file)
index 0000000..2ea4399
--- /dev/null
@@ -0,0 +1,91 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseMemoryLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseMemoryLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseMemoryLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  CopyMem.c\r
+  MemLibGuid.c\r
+  MemLibGeneric.c\r
+  CopyMemWrapper.c\r
+  SetMemWrapper.c\r
+  SetMem16Wrapper.c\r
+  SetMem32Wrapper.c\r
+  SetMem64Wrapper.c\r
+  CompareMemWrapper.c\r
+  ZeroMemWrapper.c\r
+  ScanMem8Wrapper.c\r
+  ScanMem16Wrapper.c\r
+  ScanMem32Wrapper.c\r
+  ScanMem64Wrapper.c\r
+  SetMem.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h
new file mode 100644 (file)
index 0000000..6a62104
--- /dev/null
@@ -0,0 +1,227 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  BaseMemoryLibInternals.h\r
+  \r
+Abstract: \r
+\r
+  Header file for Base Memory Library.\r
+  \r
+--*/\r
+\r
+#ifndef __BASEMEMORY_LIB_INTERNALS_H__\r
+#define __BASEMEMORY_LIB_INTERNALS_H__\r
+\r
+#include "EdkIIGlueBase.h"\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  Destination Target of copy\r
+  @param  Source Place to copy from\r
+  @param  Length Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Size Number of bytes to set\r
+  @param  Value Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Size Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @retval 0     if MemOne == MemTwo\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  );\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
new file mode 100644 (file)
index 0000000..fe07382
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  CompareMemWrapper.c\r
+  \r
+Abstract: \r
+  \r
+  CompareMem() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Compares the contents of two buffers.\r
+\r
+  This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
+  If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the\r
+  value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
+  mismatched byte in DestinationBuffer.\r
+  If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().\r
+  If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
+\r
+\r
+  @param  DestinationBuffer Pointer to the destination buffer to compare.\r
+  @param  SourceBuffer      Pointer to the source buffer to compare.\r
+  @param  Length            Number of bytes to compare.\r
+\r
+  @return 0                 All Length bytes of the two buffers are identical.\r
+  @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first\r
+                            mismatched byte in DestinationBuffer.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+GlueCompareMem (\r
+  IN CONST VOID  *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return 0;\r
+  }\r
+  ASSERT (DestinationBuffer != NULL);\r
+  ASSERT (SourceBuffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c
new file mode 100644 (file)
index 0000000..bd39f1f
--- /dev/null
@@ -0,0 +1,65 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  CopyMem.c\r
+  \r
+Abstract: \r
+\r
+  Internal CopyMem\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Copy Length bytes from Source to Destination.\r
+\r
+  @param  Destination Target of copy\r
+  @param  Source Place to copy from\r
+  @param  Length Number of bytes to copy\r
+\r
+  @return Destination\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemCopyMem (\r
+  OUT     VOID                      *Destination,\r
+  IN      CONST VOID                *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memcpy()\r
+  //\r
+  volatile UINT8                    *Destination8;\r
+  CONST UINT8                       *Source8;\r
+\r
+  if (Source > Destination) {\r
+    Destination8 = (UINT8*)Destination;\r
+    Source8 = (CONST UINT8*)Source;\r
+    while (Length-- != 0) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  } else if (Source < Destination) {\r
+    Destination8 = (UINT8*)Destination + Length;\r
+    Source8 = (CONST UINT8*)Source + Length;\r
+    while (Length-- != 0) {\r
+      *(--Destination8) = *(--Source8);\r
+    }\r
+  }\r
+  return Destination;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c
new file mode 100644 (file)
index 0000000..4a62962
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  CopyMemWrapper.c\r
+  \r
+Abstract: \r
+\r
+  CopyMem() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Copies a source buffer to a destination buffer, and returns the destination buffer.\r
+\r
+  This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r
+  DestinationBuffer.  The implementation must be reentrant, and it must handle the case\r
+  where SourceBuffer overlaps DestinationBuffer.\r
+  If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
+  If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
+\r
+  @param  DestinationBuffer   Pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        Pointer to the source buffer of the memory copy.\r
+  @param  Length              Number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @return DestinationBuffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueCopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return DestinationBuffer;\r
+  }\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
+\r
+  if (DestinationBuffer == SourceBuffer) {\r
+    return DestinationBuffer;\r
+  }\r
+  return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c
new file mode 100644 (file)
index 0000000..a7fc82f
--- /dev/null
@@ -0,0 +1,261 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  MemLibGeneric.c\r
+  \r
+Abstract: \r
+\r
+  Architecture Independent Base Memory Library Implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem16 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT16*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem32 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT32*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem64 (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  do {\r
+    ((UINT64*)Buffer)[--Length] = Value;\r
+  } while (Length != 0);\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Size Number of bytes to set\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemZeroMem (\r
+  OUT     VOID                      *Buffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  return InternalMemSetMem (Buffer, Length, 0);\r
+}\r
+\r
+/**\r
+  Compares two memory buffers of a given length.\r
+\r
+  @param  DestinationBuffer First memory buffer\r
+  @param  SourceBuffer      Second memory buffer\r
+  @param  Length            Length of DestinationBuffer and SourceBuffer memory\r
+                            regions to compare. Must be non-zero.\r
+\r
+  @retval 0     if MemOne == MemTwo\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+InternalMemCompareMem (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  while ((--Length != 0) &&\r
+         (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {\r
+    DestinationBuffer = (INT8*)DestinationBuffer + 1;\r
+    SourceBuffer = (INT8*)SourceBuffer + 1;\r
+  }\r
+  return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the\r
+  matching 8-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem8 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  CONST UINT8                       *Pointer;\r
+\r
+  Pointer = (CONST UINT8*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the\r
+  matching 16-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem16 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  CONST UINT16                      *Pointer;\r
+\r
+  Pointer = (CONST UINT16*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the\r
+  matching 32-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem32 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  CONST UINT32                      *Pointer;\r
+\r
+  Pointer = (CONST UINT32*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the\r
+  matching 64-bit value in the target buffer.\r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan. Must be non-zero.\r
+  @param  Value   Value to search for in the target buffer.\r
+\r
+  @return Pointer to the first occurrence or NULL if not found.\r
+\r
+**/\r
+CONST VOID *\r
+EFIAPI\r
+InternalMemScanMem64 (\r
+  IN      CONST VOID                *Buffer,\r
+  IN      UINTN                     Length,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  CONST UINT64                      *Pointer;\r
+\r
+  Pointer = (CONST UINT64*)Buffer;\r
+  do {\r
+    if (*(Pointer++) == Value) {\r
+      return Pointer;\r
+    }\r
+  } while (--Length != 0);\r
+  return NULL;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c
new file mode 100644 (file)
index 0000000..6a3654c
--- /dev/null
@@ -0,0 +1,135 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  MemLibGuid.c\r
+  \r
+Abstract: \r
+\r
+  Implementation of GUID functions.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Copies a source GUID to a destination GUID.\r
+\r
+  This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
+  DestinationGuid, and returns DestinationGuid.\r
+  If DestinationGuid is NULL, then ASSERT().\r
+  If SourceGuid is NULL, then ASSERT().\r
+\r
+  @param  DestinationGuid   Pointer to the destination GUID.\r
+  @param  SourceGuid        Pointer to the source GUID.\r
+\r
+  @return DestinationGuid.\r
+\r
+**/\r
+GUID *\r
+EFIAPI\r
+CopyGuid (\r
+  OUT GUID       *DestinationGuid,\r
+  IN CONST GUID  *SourceGuid\r
+  )\r
+{\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid)\r
+    );\r
+  WriteUnaligned64 (\r
+    (UINT64*)DestinationGuid + 1,\r
+    ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1)\r
+    );\r
+  return DestinationGuid;\r
+}\r
+\r
+/**\r
+  Compares two GUIDs.\r
+\r
+  This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.\r
+  If there are any bit differences in the two GUIDs, then FALSE is returned.\r
+  If Guid1 is NULL, then ASSERT().\r
+  If Guid2 is NULL, then ASSERT().\r
+\r
+  @param  Guid1       A pointer to a 128 bit GUID.\r
+  @param  Guid2       A pointer to a 128 bit GUID.\r
+\r
+  @retval TRUE        Guid1 and Guid2 are identical.\r
+  @retval FALSE       Guid1 and Guid2 are not identical.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueCompareGuid (\r
+  IN CONST GUID  *Guid1,\r
+  IN CONST GUID  *Guid2\r
+  )\r
+{\r
+  UINT64  LowPartOfGuid1;\r
+  UINT64  LowPartOfGuid2;\r
+  UINT64  HighPartOfGuid1;\r
+  UINT64  HighPartOfGuid2;\r
+\r
+  LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+  LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+  HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+  HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+  return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
+}\r
+\r
+/**\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer  Pointer to the target buffer to scan.\r
+  @param  Length  Number of bytes in Buffer to scan.\r
+  @param  Guid    Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN CONST GUID  *Guid\r
+  )\r
+{\r
+  CONST GUID                        *GuidPtr;\r
+\r
+  ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
+\r
+  GuidPtr = (GUID*)Buffer;\r
+  Buffer  = GuidPtr + Length / sizeof (*GuidPtr);\r
+  while (GuidPtr < (CONST GUID*)Buffer) {\r
+    if (CompareGuid (GuidPtr, Guid)) {\r
+      return (VOID*)GuidPtr;\r
+    }\r
+    GuidPtr++;\r
+  }\r
+  return NULL;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c
new file mode 100644 (file)
index 0000000..e1fc8f1
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  ScanMem16Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  ScanMem16() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 16-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem16 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT16      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c
new file mode 100644 (file)
index 0000000..f9ae443
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  ScanMem32Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  ScanMem32() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 32-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem32 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT32      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c
new file mode 100644 (file)
index 0000000..fb22270
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  ScanMem64Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  ScanMem64() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for a 64-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem64 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT64      Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c
new file mode 100644 (file)
index 0000000..90f7df8
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  ScanMem8Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  ScanMem8() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from the lowest\r
+  address to the highest address for an 8-bit value that matches Value.  If a match is found,\r
+  then a pointer to the matching byte in the target buffer is returned.  If no match is found,\r
+  then NULL is returned.  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer      Pointer to the target buffer to scan.\r
+  @param  Length      Number of bytes in Buffer to scan.\r
+  @param  Value       Value to search for in the target buffer.\r
+\r
+  @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ScanMem8 (\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Length,\r
+  IN UINT8       Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return NULL;\r
+  }\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
\r
+  return (VOID*)InternalMemScanMem8 (Buffer, Length, Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c
new file mode 100644 (file)
index 0000000..3646233
--- /dev/null
@@ -0,0 +1,55 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SetMem.c\r
+  \r
+Abstract: \r
+\r
+  Internal SetMem\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer Memory to set.\r
+  @param  Size Number of bytes to set\r
+  @param  Value Value of the set operation.\r
+\r
+  @return Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalMemSetMem (\r
+  IN      VOID                      *Buffer,\r
+  IN      UINTN                     Size,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  //\r
+  // Declare the local variables that actually move the data elements as\r
+  // volatile to prevent the optimizer from replacing this function with\r
+  // the intrinsic memset()\r
+  //\r
+  volatile UINT8                    *Pointer;\r
+\r
+  Pointer = (UINT8*)Buffer;\r
+  while (Size-- != 0) {\r
+    *(Pointer++) = Value;\r
+  }\r
+  return Buffer;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c
new file mode 100644 (file)
index 0000000..2fa5c6e
--- /dev/null
@@ -0,0 +1,61 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  SetMem16Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  SetMem16() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with a 16-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 16-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 16-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem16 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT16  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c
new file mode 100644 (file)
index 0000000..198f221
--- /dev/null
@@ -0,0 +1,61 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  SetMem32Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  SetMem32() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with a 32-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 32-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 32-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem32 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c
new file mode 100644 (file)
index 0000000..5643665
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  SetMem64Wrapper.c\r
+  \r
+Abstract: \r
+\r
+  SetMem64() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with a 64-bit value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the 64-bit value specified by\r
+  Value, and returns Buffer. Value is repeated every 64-bits in for Length\r
+  bytes of Buffer.\r
+\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+  If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Buffer  Pointer to the target buffer to fill.\r
+  @param  Length  Number of bytes in Buffer to fill.\r
+  @param  Value   Value with which to fill Length bytes of Buffer.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+SetMem64 (\r
+  OUT VOID   *Buffer,\r
+  IN UINTN   Length,\r
+  IN UINT64  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+  ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);\r
+  ASSERT ((Length & (sizeof (Value) - 1)) == 0);\r
+\r
+  return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c
new file mode 100644 (file)
index 0000000..79481d8
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  SetMemWrapper.c\r
+  \r
+Abstract: \r
+\r
+  SetMem() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with a byte value, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with Value, and returns Buffer.\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  Buffer    Memory to set.\r
+  @param  Length    Number of bytes to set.\r
+  @param  Value     Value of the set operation.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueSetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return Buffer;\r
+  }\r
+\r
+  ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
+\r
+  return InternalMemSetMem (Buffer, Length, Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c
new file mode 100644 (file)
index 0000000..6adda51
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  ZeroMemWrapper.c\r
+  \r
+Abstract: \r
+\r
+  ZeroMem() implementation.\r
+\r
+--*/\r
+\r
+#include "BaseMemoryLibInternal.h"\r
+\r
+/**\r
+  Fills a target buffer with zeros, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with zeros, and returns Buffer.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
+\r
+  @param  Buffer      Pointer to the target buffer to fill with zeros.\r
+  @param  Length      Number of bytes in Buffer to fill with zeros.\r
+\r
+  @return Buffer.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueZeroMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  ASSERT (!(Buffer == NULL && Length > 0));\r
+  ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  return InternalMemZeroMem (Buffer, Length);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf
new file mode 100644 (file)
index 0000000..94af773
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePciCf8Lib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePciCf8Lib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePciCf8Lib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PciLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+\r
+\r
+[libraries.ia32]\r
+  EdkIIGlueBaseIoLibIntrinsic  \r
+\r
+[libraries.x64]\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+\r
+[libraries.ebc]\r
+  EdkIIGlueDxeIoLibCpuIo\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c
new file mode 100644 (file)
index 0000000..0bd1471
--- /dev/null
@@ -0,0 +1,1468 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  PciLib.c\r
+  \r
+Abstract: \r
+\r
+  PCI Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+//\r
+// Declare I/O Ports used to perform PCI Confguration Cycles\r
+//\r
+#define PCI_CONFIGURATION_ADDRESS_PORT  0xCF8\r
+#define PCI_CONFIGURATION_DATA_PORT     0xCFC\r
+\r
+//\r
+// Declare macro to convert PCI Library formatted address to CF8 formatted address\r
+//\r
+// PCI Library formatted address    CF8 Formatted Address\r
+// =============================    ======================\r
+//    Bits 00..11  Register           Bits 00..07  Register\r
+//    Bits 12..14  Function           Bits 08..10  Function\r
+//    Bits 15..19  Device             Bits 11..15  Device\r
+//    Bits 20..27  Bus                Bits 16..23  Bus\r
+//    Bits 28..31  Reserved(MBZ)      Bits 24..30  Reserved(MBZ)\r
+//                                    Bits 31..31  Must be 1\r
+//\r
+\r
+/**\r
+  Assert the validity of a PCI address. A valid PCI address should contain 1's\r
+  only in the low 28 bits.\r
+\r
+  @param  A The address to validate.\r
+  @param  M Additional bits to assert to be zero.\r
+\r
+**/\r
+#define ASSERT_INVALID_PCI_ADDRESS(A,M) \\r
+  ASSERT (((A) & (~0xffff0ff | (M))) == 0)\r
+\r
+/**\r
+  Convert a PCI Express address to PCI CF8 address.\r
+\r
+  @param  A The address to convert.\r
+\r
+  @retval The coverted address.\r
+\r
+**/\r
+#define PCI_TO_CF8_ADDRESS(A) \\r
+  ((UINT32) ((((A) >> 4) & 0x00ffff00) | ((A) & 0xfc) | 0x80000000))\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Read8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoRead8 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3));\r
+}\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Write8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoWrite8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8Or8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoOr8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8And8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAnd8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8AndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAndThenOr8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldRead8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldWrite8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldOr8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAnd8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr8(\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAndThenOr8 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Read16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoRead16 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2));\r
+}\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Write16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoWrite16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8Or16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoOr16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8And16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAnd16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8AndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAndThenOr16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldRead16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldWrite16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldOr16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAnd16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr16(\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAndThenOr16 (\r
+           PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Read32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoRead32 (PCI_CONFIGURATION_DATA_PORT);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Write32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoWrite32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8Or32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoOr32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8And32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAnd32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8AndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoAndThenOr32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldRead32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldWrite32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldOr32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAnd32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If the register specified by Address >= 0x100, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciCf8BitFieldAndThenOr32(\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
+  IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));\r
+  return IoBitFieldAndThenOr32 (\r
+           PCI_CONFIGURATION_DATA_PORT,\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by StartAddress >= 0x100, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciCf8ReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  )\r
+{\r
+  UINTN                             ReturnValue;\r
+\r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
+\r
+  if (Size == 0) {\r
+    return Size;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Save Size for return\r
+  //\r
+  ReturnValue = Size;\r
+\r
+  if ((StartAddress & 1) != 0) {\r
+    //\r
+    // Read a byte if StartAddress is byte aligned\r
+    //\r
+    *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress);\r
+    StartAddress += sizeof (UINT8);\r
+    Size -= sizeof (UINT8);\r
+    Buffer = (UINT8*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {\r
+    //\r
+    // Read a word if StartAddress is word aligned\r
+    //\r
+    *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  while (Size >= sizeof (UINT32)) {\r
+    //\r
+    // Read as many double words as possible\r
+    //\r
+    *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress);\r
+    StartAddress += sizeof (UINT32);\r
+    Size -= sizeof (UINT32);\r
+    Buffer = (UINT32*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16)) {\r
+    //\r
+    // Read the last remaining word if exist\r
+    //\r
+    *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT8)) {\r
+    //\r
+    // Read the last remaining byte if exist\r
+    //\r
+    *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If the register specified by StartAddress >= 0x100, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciCf8WriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  )\r
+{\r
+  UINTN                             ReturnValue;\r
+\r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);\r
+\r
+  if (Size == 0) {\r
+    return 0;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Save Size for return\r
+  //\r
+  ReturnValue = Size;\r
+\r
+  if ((StartAddress & 1) != 0) {\r
+    //\r
+    // Write a byte if StartAddress is byte aligned\r
+    //\r
+    PciCf8Write8 (StartAddress, *(UINT8*)Buffer);\r
+    StartAddress += sizeof (UINT8);\r
+    Size -= sizeof (UINT8);\r
+    Buffer = (UINT8*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {\r
+    //\r
+    // Write a word if StartAddress is word aligned\r
+    //\r
+    PciCf8Write16 (StartAddress, *(UINT16*)Buffer);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  while (Size >= sizeof (UINT32)) {\r
+    //\r
+    // Write as many double words as possible\r
+    //\r
+    PciCf8Write32 (StartAddress, *(UINT32*)Buffer);\r
+    StartAddress += sizeof (UINT32);\r
+    Size -= sizeof (UINT32);\r
+    Buffer = (UINT32*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16)) {\r
+    //\r
+    // Write the last remaining word if exist\r
+    //\r
+    PciCf8Write16 (StartAddress, *(UINT16*)Buffer);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT8)) {\r
+    //\r
+    // Write the last remaining byte if exist\r
+    //\r
+    PciCf8Write8 (StartAddress, *(UINT8*)Buffer);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf
new file mode 100644 (file)
index 0000000..b408dc3
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePciExpressLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePciExpressLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePciExpressLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PciLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\Include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+\r
+[libraries.ia32]\r
+  EdkIIGlueBaseIoLibIntrinsic  \r
+\r
+[libraries.x64]\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+\r
+[libraries.ebc]\r
+  EdkIIGlueDxeIoLibCpuIo\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c
new file mode 100644 (file)
index 0000000..8404f71
--- /dev/null
@@ -0,0 +1,1373 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  PciLib.c\r
+  \r
+Abstract: \r
+\r
+  PCI Library.\r
+\r
+  Functions in this library instance make use of MMIO functions in IoLib to\r
+  access memory mapped PCI configuration space.\r
+\r
+  All assertions for I/O operations are handled in MMIO functions in the IoLib\r
+  Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Assert the validity of a PCI address. A valid PCI address should contain 1's\r
+  only in the low 28 bits.\r
+\r
+  @param  A The address to validate.\r
+\r
+**/\r
+#define ASSERT_INVALID_PCI_ADDRESS(A) \\r
+  ASSERT (((A) & ~0xfffffff) == 0)\r
+\r
+\r
+/**\r
+  Gets the base address of PCI Express.\r
+  \r
+  This internal functions retrieves PCI Express Base Address via a PCD entry\r
+  PcdPciExpressBaseAddress.\r
+  \r
+  @return The base address of PCI Express.\r
+\r
+**/\r
+STATIC\r
+volatile VOID*\r
+GetPciExpressBaseAddress (\r
+  VOID\r
+  )\r
+{\r
+  return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress);\r
+}\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address);\r
+}\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAndThenOr8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldRead8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldWrite8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldOr8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAnd8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAndThenOr8 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAndThenOr16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldRead16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldWrite16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldOr16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAnd16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAndThenOr16 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioAndThenOr32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldRead32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit\r
+           );\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldWrite32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           Value\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldOr32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAnd32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciExpressBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  ASSERT_INVALID_PCI_ADDRESS (Address);\r
+  return MmioBitFieldAndThenOr32 (\r
+           (UINTN) GetPciExpressBaseAddress () + Address,\r
+           StartBit,\r
+           EndBit,\r
+           AndData,\r
+           OrData\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciExpressReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  )\r
+{\r
+  UINTN                             ReturnValue;\r
+\r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+\r
+  if (Size == 0) {\r
+    return Size;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Save Size for return\r
+  //\r
+  ReturnValue = Size;\r
+\r
+  if ((StartAddress & 1) != 0) {\r
+    //\r
+    // Read a byte if StartAddress is byte aligned\r
+    //\r
+    *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);\r
+    StartAddress += sizeof (UINT8);\r
+    Size -= sizeof (UINT8);\r
+    Buffer = (UINT8*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {\r
+    //\r
+    // Read a word if StartAddress is word aligned\r
+    //\r
+    *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  while (Size >= sizeof (UINT32)) {\r
+    //\r
+    // Read as many double words as possible\r
+    //\r
+    *(volatile UINT32 *)Buffer = PciExpressRead32 (StartAddress);\r
+    StartAddress += sizeof (UINT32);\r
+    Size -= sizeof (UINT32);\r
+    Buffer = (UINT32*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16)) {\r
+    //\r
+    // Read the last remaining word if exist\r
+    //\r
+    *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT8)) {\r
+    //\r
+    // Read the last remaining byte if exist\r
+    //\r
+    *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciExpressWriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  )\r
+{\r
+  UINTN                             ReturnValue;\r
+\r
+  ASSERT_INVALID_PCI_ADDRESS (StartAddress);\r
+  ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
+\r
+  if (Size == 0) {\r
+    return 0;\r
+  }\r
+\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Save Size for return\r
+  //\r
+  ReturnValue = Size;\r
+\r
+  if ((StartAddress & 1) != 0) {\r
+    //\r
+    // Write a byte if StartAddress is byte aligned\r
+    //\r
+    PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);\r
+    StartAddress += sizeof (UINT8);\r
+    Size -= sizeof (UINT8);\r
+    Buffer = (UINT8*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {\r
+    //\r
+    // Write a word if StartAddress is word aligned\r
+    //\r
+    PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  while (Size >= sizeof (UINT32)) {\r
+    //\r
+    // Write as many double words as possible\r
+    //\r
+    PciExpressWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    StartAddress += sizeof (UINT32);\r
+    Size -= sizeof (UINT32);\r
+    Buffer = (UINT32*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT16)) {\r
+    //\r
+    // Write the last remaining word if exist\r
+    //\r
+    PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    StartAddress += sizeof (UINT16);\r
+    Size -= sizeof (UINT16);\r
+    Buffer = (UINT16*)Buffer + 1;\r
+  }\r
+\r
+  if (Size >= sizeof (UINT8)) {\r
+    //\r
+    // Write the last remaining byte if exist\r
+    //\r
+    PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf
new file mode 100644 (file)
index 0000000..2196639
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePciLibCf8.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePciLibCf8.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePciLibCf8\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PciLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBasePciCf8Lib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c
new file mode 100644 (file)
index 0000000..cc818a7
--- /dev/null
@@ -0,0 +1,1076 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PciLib.c\r
+  \r
+Abstract: \r
+\r
+  PCI Library using Port CF8/CFC access.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciCf8Read8 (Address);\r
+}\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Data\r
+  )\r
+{\r
+  return PciCf8Write8 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciCf8Or8 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return PciCf8And8 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciCf8AndThenOr8 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciCf8BitFieldRead8 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciCf8Read16 (Address);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Data\r
+  )\r
+{\r
+  return PciCf8Write16 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciCf8Or16 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return PciCf8And16 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciCf8AndThenOr16 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciCf8BitFieldRead16 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciCf8Read32 (Address);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Data\r
+  )\r
+{\r
+  return PciCf8Write32 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciCf8Or32 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return PciCf8And32 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciCf8AndThenOr32 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciCf8BitFieldRead32 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  )\r
+{\r
+  return PciCf8ReadBuffer (StartAddress, Size, Buffer);\r
+}\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciWriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  )\r
+{\r
+  return PciCf8WriteBuffer (StartAddress, Size, Buffer);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
new file mode 100644 (file)
index 0000000..84af9d6
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePciLibPciExpress.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePciLibPciExpress.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePciLibPciExpress\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PciLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBasePciExpressLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c
new file mode 100644 (file)
index 0000000..652bfd9
--- /dev/null
@@ -0,0 +1,1076 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PciLib.c\r
+  \r
+Abstract: \r
+\r
+  PCI Library using PC Express access.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Reads an 8-bit PCI configuration register.\r
+\r
+  Reads and returns the 8-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciExpressRead8 (Address);\r
+}\r
+\r
+/**\r
+  Writes an 8-bit PCI configuration register.\r
+\r
+  Writes the 8-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Data\r
+  )\r
+{\r
+  return PciExpressWrite8 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
+  an 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciExpressOr8 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return PciExpressAnd8 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
+  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciExpressAndThenOr8 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciExpressBitFieldRead8 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  8-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return PciExpressBitFieldWrite8 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 8-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldOr8 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 8-bit register.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 8-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return PciExpressBitFieldAnd8 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 8-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PciBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a 16-bit PCI configuration register.\r
+\r
+  Reads and returns the 16-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciExpressRead16 (Address);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit PCI configuration register.\r
+\r
+  Writes the 16-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Data\r
+  )\r
+{\r
+  return PciExpressWrite16 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  a 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciExpressOr16 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return PciExpressAnd16 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
+  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciExpressAndThenOr16 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciExpressBitFieldRead16 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  16-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 16-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldOr16 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 16-bit register.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 16-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return PciExpressBitFieldAnd16 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 16-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PciBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit PCI configuration register.\r
+\r
+  Reads and returns the 32-bit PCI configuration register specified by Address.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @return The read value from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return PciExpressRead32 (Address);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit PCI configuration register.\r
+\r
+  Writes the 32-bit PCI configuration register specified by Address with the\r
+  value specified by Value. Value is returned. This function must guarantee\r
+  that all PCI read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  Value   The value to write.\r
+\r
+  @return The value written to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Data\r
+  )\r
+{\r
+  return PciExpressWrite32 (Address, Data);\r
+}\r
+\r
+/**\r
+  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
+  a 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  OrData  The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciExpressOr32 (Address, OrData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return PciExpressAnd32 (Address, AndData);\r
+}\r
+\r
+/**\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
+  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise inclusive OR between the result of the AND operation and\r
+  the value specified by OrData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+\r
+  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciExpressAndThenOr32 (Address, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a PCI configuration register.\r
+\r
+  Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
+  specified by the StartBit and the EndBit. The value of the bit field is\r
+  returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value of the bit field read from the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return PciExpressBitFieldRead32 (Address, StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a PCI configuration register.\r
+\r
+  Writes Value to the bit field of the PCI configuration register. The bit\r
+  field is specified by the StartBit and the EndBit. All other bits in the\r
+  destination PCI configuration register are preserved. The new value of the\r
+  32-bit register is returned.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise inclusive OR between the read result and the value specified by\r
+  OrData, and writes the result to the 32-bit PCI configuration register\r
+  specified by Address. The value written to the PCI configuration register is\r
+  returned. This function must guarantee that all PCI read and write operations\r
+  are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
+  AND, and writes the result back to the bit field in the 32-bit register.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND between the read result and the value specified by AndData, and\r
+  writes the result to the 32-bit PCI configuration register specified by\r
+  Address. The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are\r
+  serialized. Extra left bits in AndData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return PciExpressBitFieldAnd32 (Address, StartBit, EndBit, AndData);\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit PCI configuration register specified by Address, performs a\r
+  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  the value specified by AndData, and writes the result to the 32-bit PCI\r
+  configuration register specified by Address. The value written to the PCI\r
+  configuration register is returned. This function must guarantee that all PCI\r
+  read and write operations are serialized. Extra left bits in both AndData and\r
+  OrData are stripped.\r
+\r
+  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   PCI configuration register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the PCI configuration register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PciBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return PciExpressBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);\r
+}\r
+\r
+/**\r
+  Reads a range of PCI configuration registers into a caller supplied buffer.\r
+\r
+  Reads the range of PCI configuration registers specified by StartAddress and\r
+  Size into the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be read. Size is\r
+  returned. When possible 32-bit PCI configuration read cycles are used to read\r
+  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  and 16-bit PCI configuration read cycles may be used at the beginning and the\r
+  end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer receiving the data read.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciReadBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      *Buffer\r
+  )\r
+{\r
+  return PciExpressReadBuffer (StartAddress, Size, Buffer);\r
+}\r
+\r
+/**\r
+  Copies the data in a caller supplied buffer to a specified range of PCI\r
+  configuration space.\r
+\r
+  Writes the range of PCI configuration registers specified by StartAddress and\r
+  Size from the buffer specified by Buffer. This function only allows the PCI\r
+  configuration registers from a single PCI function to be written. Size is\r
+  returned. When possible 32-bit PCI configuration write cycles are used to\r
+  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
+  and the end of the range.\r
+\r
+  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
+  If Size > 0 and Buffer is NULL, then ASSERT().\r
+\r
+  @param  StartAddress  Starting address that encodes the PCI Bus, Device,\r
+                        Function and Register.\r
+  @param  Size          Size in bytes of the transfer.\r
+  @param  Buffer        Pointer to a buffer containing the data to write.\r
+\r
+  @return Size\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PciWriteBuffer (\r
+  IN      UINTN                     StartAddress,\r
+  IN      UINTN                     Size,\r
+  IN      VOID                      *Buffer\r
+  )\r
+{\r
+  return PciExpressWriteBuffer (StartAddress, Size, Buffer);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
new file mode 100644 (file)
index 0000000..7b272bf
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePeCoffGetEntryPointLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePeCoffGetEntryPointLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePeCoffGetEntryPointLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeCoffGetEntryPoint.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r \r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  \r
+\r
+[libraries.common]\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
new file mode 100644 (file)
index 0000000..87818b7
--- /dev/null
@@ -0,0 +1,222 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffGetEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  Pe/Coff loader\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded\r
+  into system memory with the PE/COFF Loader Library functions.\r
+\r
+  Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry\r
+  point in EntryPoint.  If the entry point could not be retrieved from the PE/COFF image, then\r
+  return RETURN_INVALID_PARAMETER.  Otherwise return RETURN_SUCCESS.\r
+  If Pe32Data is NULL, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data                  Pointer to the PE/COFF image that is loaded in system memory.\r
+  @param  EntryPoint                Pointer to entry point to the PE/COFF image to return.\r
+\r
+  @retval RETURN_SUCCESS            EntryPoint was returned.\r
+  @retval RETURN_INVALID_PARAMETER  The entry point could not be found in the PE/COFF image.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetEntryPoint (\r
+  IN  VOID  *Pe32Data,\r
+  OUT VOID  **EntryPoint\r
+  )\r
+{\r
+  EFI_IMAGE_DOS_HEADER                  *DosHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Header;\r
+\r
+  ASSERT (Pe32Data   != NULL);\r
+  ASSERT (EntryPoint != NULL);\r
+\r
+  DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+  if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header.\r
+    //\r
+    Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));\r
+  } else {\r
+    //\r
+    // DOS image header is not present, so PE header is at the image base.\r
+    //\r
+    Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+  }\r
+\r
+  //\r
+  // Calculate the entry point relative to the start of the image. \r
+  // AddressOfEntryPoint is common for PE32 & PE32+\r
+  //\r
+  *EntryPoint = (VOID *)((UINTN)Pe32Data + (UINTN)(Header.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Returns the machine type of a PE/COFF image.\r
+\r
+  Returns the machine type from the PE/COFF image specified by Pe32Data.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return Machine type or zero if not a valid iamge.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PeCoffLoaderGetMachineType (\r
+  IN VOID  *Pe32Data\r
+  )\r
+{\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;\r
+  EFI_IMAGE_DOS_HEADER                 *DosHdr;\r
+\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER  *)Pe32Data;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + DosHdr->e_lfanew);\r
+  } else {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data);\r
+  }\r
+\r
+  if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {\r
+    return Hdr.Pe32->FileHeader.Machine;\r
+  }\r
+\r
+  return 0x0000;\r
+}\r
+\r
+/**\r
+  Returns a pointer to the PDB file name for a PE/COFF image that has been\r
+  loaded into system memory with the PE/COFF Loader Library functions. \r
+\r
+  Returns the PDB file name for the PE/COFF image specified by Pe32Data.  If\r
+  the PE/COFF image specified by Pe32Data is not a valid, then NULL is\r
+  returned.  If the PE/COFF image specified by Pe32Data does not contain a\r
+  debug directory entry, then NULL is returned.  If the debug directory entry\r
+  in the PE/COFF image specified by Pe32Data does not contain a PDB file name,\r
+  then NULL is returned.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL\r
+          if it cannot be retrieved.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+PeCoffLoaderGetPdbPointer (\r
+  IN VOID  *Pe32Data\r
+  )\r
+{\r
+  EFI_IMAGE_DOS_HEADER                  *DosHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
+  UINTN                                 DirCount;\r
+  VOID                                  *CodeViewEntryPointer;\r
+  INTN                                  TEImageAdjust;\r
+  UINT32                                NumberOfRvaAndSizes;\r
\r
+  ASSERT (Pe32Data   != NULL);\r
+\r
+  TEImageAdjust       = 0;\r
+  DirectoryEntry      = NULL;\r
+  DebugEntry          = NULL;\r
+  NumberOfRvaAndSizes = 0;\r
+\r
+  DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+  if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));\r
+  } else {\r
+    //\r
+    // DOS image header is not present, so PE header is at the image base.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+  }\r
+\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {\r
+      DirectoryEntry  = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];\r
+      TEImageAdjust   = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;\r
+      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +\r
+                    Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +\r
+                    TEImageAdjust);\r
+    }\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+    if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //     \r
+      // Use PE32 offset get Debug Directory Entry\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+    } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+      //     \r
+      // Use PE32+ offset get Debug Directory Entry\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+    }\r
+\r
+    if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+      DirectoryEntry = NULL;\r
+      DebugEntry = NULL;\r
+    }\r
+  } else {\r
+    return NULL;\r
+  }\r
+\r
+  if (DebugEntry == NULL || DirectoryEntry == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {\r
+    if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+      if (DebugEntry->SizeOfData > 0) {\r
+        CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);\r
+        switch (* (UINT32 *) CodeViewEntryPointer) {\r
+        case CODEVIEW_SIGNATURE_NB10:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r
+        case CODEVIEW_SIGNATURE_RSDS:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
new file mode 100644 (file)
index 0000000..489667c
--- /dev/null
@@ -0,0 +1,1336 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EdkIIGlueDxeDriverEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  Pe/Coff loader\r
+\r
+--*/\r
+\r
+#include "BasePeCoffLibInternals.h"\r
+\r
+/**\r
+  Retrieves the magic value from the PE/COFF header.\r
+\r
+  @param  Hdr             The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+  @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32\r
+  @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+\r
+\r
+**/\r
+UINT16\r
+PeCoffLoaderGetPeHeaderMagicValue (\r
+  IN  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr\r
+  )\r
+{\r
+  //\r
+  // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value \r
+  //       in the PE/COFF Header.  If the MachineType is Itanium(IA64) and the \r
+  //       Magic value in the OptionalHeader is  EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+  //       then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+  //\r
+  if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+  }\r
+  //\r
+  // Return the magic value from the PC/COFF Optional Header\r
+  //\r
+  return Hdr.Pe32->OptionalHeader.Magic;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves the PE or TE Header from a PE/COFF or TE image.\r
+\r
+  @param  ImageContext    The context of the image being loaded.\r
+  @param  Hdr             The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+  @retval RETURN_SUCCESS  The PE or TE Header is read.\r
+  @retval Other           The error status from reading the PE/COFF or TE image using the ImageRead function.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderGetPeHeader (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,\r
+  OUT    EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr\r
+  )\r
+{\r
+  RETURN_STATUS         Status;\r
+  EFI_IMAGE_DOS_HEADER  DosHdr;\r
+  UINTN                 Size;\r
+  UINT16                Magic;\r
+\r
+  //\r
+  // Read the DOS image header to check for it's existance\r
+  //\r
+  Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
+  Status = ImageContext->ImageRead (\r
+                           ImageContext->Handle,\r
+                           0,\r
+                           &Size,\r
+                           &DosHdr\r
+                           );\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+\r
+  ImageContext->PeCoffHeaderOffset = 0;\r
+  if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image\r
+    // header\r
+    //\r
+    ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;\r
+  }\r
+\r
+  //\r
+  // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much\r
+  // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic\r
+  // determins if this is a PE32 or PE32+ image. The magic is in the same\r
+  // location in both images.\r
+  //\r
+  Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);\r
+  Status = ImageContext->ImageRead (\r
+                           ImageContext->Handle,\r
+                           ImageContext->PeCoffHeaderOffset,\r
+                           &Size,\r
+                           Hdr.Pe32\r
+                           );\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Use Signature to figure out if we understand the image format\r
+  //\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    ImageContext->IsTeImage         = TRUE;\r
+    ImageContext->Machine           = Hdr.Te->Machine;\r
+    ImageContext->ImageType         = (UINT16)(Hdr.Te->Subsystem);\r
+    ImageContext->ImageSize         = 0;\r
+    ImageContext->SectionAlignment  = 4096;\r
+    ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;\r
+\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {\r
+    ImageContext->IsTeImage = FALSE;\r
+    ImageContext->Machine = Hdr.Pe32->FileHeader.Machine;\r
+\r
+    Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      ImageContext->ImageType         = Hdr.Pe32->OptionalHeader.Subsystem;\r
+      ImageContext->ImageSize         = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;\r
+      ImageContext->SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;\r
+      ImageContext->SizeOfHeaders     = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
+\r
+    } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      ImageContext->ImageType         = Hdr.Pe32Plus->OptionalHeader.Subsystem;\r
+      ImageContext->ImageSize         = (UINT64) Hdr.Pe32Plus->OptionalHeader.SizeOfImage;\r
+      ImageContext->SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;\r
+      ImageContext->SizeOfHeaders     = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;\r
+    } else {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
+      return RETURN_UNSUPPORTED;\r
+    }\r
+  } else {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) {\r
+    //\r
+    // If the PE/COFF loader does not support the image type return\r
+    // unsupported. This library can suport lots of types of images\r
+    // this does not mean the user of this library can call the entry\r
+    // point of the image.\r
+    //\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves information about a PE/COFF image.\r
+\r
+  Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,\r
+  PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva\r
+  fields of the ImageContext structure.  If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.\r
+  If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not\r
+  a supported PE/COFF image type, then return RETURN_UNSUPPORTED.  If any errors occur while\r
+  computing the fields of ImageContext, then the error status is returned in the ImageError field of\r
+  ImageContext.\r
+\r
+  @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
+                                    image that needs to be examined by this function.\r
+\r
+  @retval RETURN_SUCCESS            The information on the PE/COFF image was collected.\r
+  @retval RETURN_INVALID_PARAMETER  ImageContext is NULL.\r
+  @retval RETURN_UNSUPPORTED        The PE/COFF image is not supported.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderGetImageInfo (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT           *ImageContext\r
+  )\r
+{\r
+  RETURN_STATUS                         Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_UNION       HdrData;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DebugDirectoryEntry;\r
+  UINTN                                 Size;\r
+  UINTN                                 Index;\r
+  UINTN                                 DebugDirectoryEntryRva;\r
+  UINTN                                 DebugDirectoryEntryFileOffset;\r
+  UINTN                                 SectionHeaderOffset;\r
+  EFI_IMAGE_SECTION_HEADER              SectionHeader;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       DebugEntry;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  if (NULL == ImageContext) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError  = IMAGE_ERROR_SUCCESS;\r
+\r
+  Hdr.Union = &HdrData;\r
+  Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);\r
+\r
+  //\r
+  // Retrieve the base address of the image\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase;\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase;\r
+    }\r
+  } else {\r
+    ImageContext->ImageAddress = (PHYSICAL_ADDRESS)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
+  }\r
+\r
+  //\r
+  // Initialize the alternate destination address to 0 indicating that it\r
+  // should not be used.\r
+  //\r
+  ImageContext->DestinationAddress = 0;\r
+\r
+  //\r
+  // Initialize the codeview pointer.\r
+  //\r
+  ImageContext->CodeView    = NULL;\r
+  ImageContext->PdbPointer  = NULL;\r
+\r
+  //\r
+  // Three cases with regards to relocations:\r
+  // - Image has base relocs, RELOCS_STRIPPED==0    => image is relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but\r
+  //   has no base relocs to apply\r
+  // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.\r
+  //\r
+  // Look at the file header to determine if relocations have been stripped, and\r
+  // save this info in the image context for later use.\r
+  //\r
+  if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {\r
+    ImageContext->RelocationsStripped = TRUE;\r
+  } else {\r
+    ImageContext->RelocationsStripped = FALSE;\r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    }\r
+\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+\r
+      DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;\r
+\r
+      //\r
+      // Determine the file offset of the debug directory...  This means we walk\r
+      // the sections to find which section contains the RVA of the debug\r
+      // directory\r
+      //\r
+      DebugDirectoryEntryFileOffset = 0;\r
+\r
+      SectionHeaderOffset = (UINTN)(\r
+                               ImageContext->PeCoffHeaderOffset +\r
+                               sizeof (UINT32) +\r
+                               sizeof (EFI_IMAGE_FILE_HEADER) +\r
+                               Hdr.Pe32->FileHeader.SizeOfOptionalHeader\r
+                               );\r
+\r
+      for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {\r
+        //\r
+        // Read section header from file\r
+        //\r
+        Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 SectionHeaderOffset,\r
+                                 &Size,\r
+                                 &SectionHeader\r
+                                 );\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+            DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+\r
+          DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;\r
+          break;\r
+        }\r
+\r
+        SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      }\r
+\r
+      if (DebugDirectoryEntryFileOffset != 0) {\r
+        for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {\r
+          //\r
+          // Read next debug directory entry\r
+          //\r
+          Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+          Status = ImageContext->ImageRead (\r
+                                   ImageContext->Handle,\r
+                                   DebugDirectoryEntryFileOffset,\r
+                                   &Size,\r
+                                   &DebugEntry\r
+                                   );\r
+          if (RETURN_ERROR (Status)) {\r
+            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+            return Status;\r
+          }\r
+          if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+            ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);\r
+            if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {\r
+              ImageContext->ImageSize += DebugEntry.SizeOfData;\r
+            }\r
+\r
+            return RETURN_SUCCESS;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+\r
+    DebugDirectoryEntry             = &Hdr.Te->DataDirectory[1];\r
+    DebugDirectoryEntryRva          = DebugDirectoryEntry->VirtualAddress;\r
+    SectionHeaderOffset             = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER));\r
+\r
+    DebugDirectoryEntryFileOffset   = 0;\r
+\r
+    for (Index = 0; Index < Hdr.Te->NumberOfSections;) {\r
+      //\r
+      // Read section header from file\r
+      //\r
+      Size   = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      Status = ImageContext->ImageRead (\r
+                               ImageContext->Handle,\r
+                               SectionHeaderOffset,\r
+                               &Size,\r
+                               &SectionHeader\r
+                               );\r
+      if (RETURN_ERROR (Status)) {\r
+        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+\r
+      if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+          DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+        DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -\r
+                                        SectionHeader.VirtualAddress +\r
+                                        SectionHeader.PointerToRawData +\r
+                                        sizeof (EFI_TE_IMAGE_HEADER) -\r
+                                        Hdr.Te->StrippedSize;\r
+\r
+        //\r
+        // File offset of the debug directory was found, if this is not the last\r
+        // section, then skip to the last section for calculating the image size.\r
+        //\r
+        if (Index < (UINTN) Hdr.Te->NumberOfSections - 1) {\r
+          SectionHeaderOffset += (Hdr.Te->NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER);\r
+          Index = Hdr.Te->NumberOfSections - 1;\r
+          continue;\r
+        }\r
+      }\r
+\r
+      //\r
+      // In Te image header there is not a field to describe the ImageSize.\r
+      // Actually, the ImageSize equals the RVA plus the VirtualSize of\r
+      // the last section mapped into memory (Must be rounded up to\r
+      // a mulitple of Section Alignment). Per the PE/COFF specification, the\r
+      // section headers in the Section Table must appear in order of the RVA\r
+      // values for the corresponding sections. So the ImageSize can be determined\r
+      // by the RVA and the VirtualSize of the last section header in the\r
+      // Section Table.\r
+      //\r
+      if ((++Index) == (UINTN)Hdr.Te->NumberOfSections) {\r
+        ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize +\r
+                                   ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1);\r
+      }\r
+\r
+      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+    }\r
+\r
+    if (DebugDirectoryEntryFileOffset != 0) {\r
+      for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {\r
+        //\r
+        // Read next debug directory entry\r
+        //\r
+        Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 DebugDirectoryEntryFileOffset,\r
+                                 &Size,\r
+                                 &DebugEntry\r
+                                 );\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+          ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);\r
+          return RETURN_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Converts an image address to the loaded address.\r
+\r
+  @param  ImageContext  The context of the image being loaded.\r
+  @param  Address       The address to be converted to the loaded address.\r
+\r
+  @return The converted address or NULL if the address can not be converted.\r
+\r
+**/\r
+VOID *\r
+GluePeCoffLoaderImageAddress (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN     UINTN                                 Address\r
+  )\r
+{\r
+  //\r
+  // @bug Check to make sure ImageSize is correct for the relocated image.\r
+  //      it may only work for the file we start with and not the relocated image\r
+  //\r
+  if (Address >= ImageContext->ImageSize) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return NULL;\r
+  }\r
+\r
+  return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address);\r
+}\r
+\r
+/**\r
+  Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().\r
+\r
+  If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of\r
+  ImageContext as the relocation base address.  Otherwise, use the DestinationAddress field\r
+  of ImageContext as the relocation base address.  The caller must allocate the relocation\r
+  fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext        Pointer to the image context structure that describes the PE/COFF\r
+                              image that is being relocated.\r
+\r
+  @retval RETURN_SUCCESS      The PE/COFF image was relocated.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_LOAD_ERROR   The image in not a valid PE/COFF image.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_UNSUPPORTED  A relocation record type is not supported.\r
+                              Extended status information is in the ImageError field of ImageContext.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderRelocateImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  RETURN_STATUS                         Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *RelocDir;\r
+  UINT64                                Adjust;\r
+  EFI_IMAGE_BASE_RELOCATION             *RelocBase;\r
+  EFI_IMAGE_BASE_RELOCATION             *RelocBaseEnd;\r
+  UINT16                                *Reloc;\r
+  UINT16                                *RelocEnd;\r
+  CHAR8                                 *Fixup;\r
+  CHAR8                                 *FixupBase;\r
+  UINT16                                *F16;\r
+  UINT32                                *F32;\r
+  UINT64                                *F64;\r
+  CHAR8                                 *FixupData;\r
+  PHYSICAL_ADDRESS                      BaseAddress;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  ASSERT (ImageContext != NULL);\r
+\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // If there are no relocation entries, then we are done\r
+  //\r
+  if (ImageContext->RelocationsStripped) {\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // If the destination address is not 0, use that rather than the\r
+  // image address as the relocation target.\r
+  //\r
+  if (ImageContext->DestinationAddress != 0) {\r
+    BaseAddress = ImageContext->DestinationAddress;\r
+  } else if (!(ImageContext->IsTeImage)) {\r
+    BaseAddress = ImageContext->ImageAddress;\r
+  } else {\r
+    Hdr.Te      = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
+    BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; \r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+\r
+    Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;\r
+      Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;\r
+\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      RelocDir  = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase;\r
+      Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;\r
+\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      RelocDir  = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    }\r
+\r
+    //\r
+    // Find the relocation block\r
+    // Per the PE/COFF spec, you can't assume that a given data directory\r
+    // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+    // the optional header to verify a desired directory entry is there.\r
+    //\r
+\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
+      RelocBaseEnd = PeCoffLoaderImageAddress (\r
+                      ImageContext,\r
+                      RelocDir->VirtualAddress + RelocDir->Size - 1\r
+                      );\r
+    } else {\r
+      //\r
+      // Set base and end to bypass processing below.\r
+      //\r
+      RelocBase = RelocBaseEnd = 0;\r
+    }\r
+  } else {\r
+    Hdr.Te             = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
+    Adjust             = (UINT64) (BaseAddress - Hdr.Te->ImageBase);\r
+    Hdr.Te->ImageBase  = (UINT64) (BaseAddress);\r
+\r
+    //\r
+    // Find the relocation block\r
+    //\r
+    RelocDir = &Hdr.Te->DataDirectory[0];\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
+                                    ImageContext->ImageAddress +\r
+                                    RelocDir->VirtualAddress +\r
+                                    sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                    Hdr.Te->StrippedSize\r
+                                    );\r
+    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+  }\r
+\r
+  //\r
+  // Run the relocation information and apply the fixups\r
+  //\r
+  FixupData = ImageContext->FixupData;\r
+  while (RelocBase < RelocBaseEnd) {\r
+\r
+    Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\r
+    RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
+    if (!(ImageContext->IsTeImage)) {\r
+      FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
+    } else {\r
+      FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
+                    RelocBase->VirtualAddress +\r
+                    sizeof(EFI_TE_IMAGE_HEADER) -\r
+                    Hdr.Te->StrippedSize\r
+                    );\r
+    }\r
+\r
+    if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||\r
+        (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +\r
+          (UINTN)ImageContext->ImageSize)) {\r
+      ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Run this relocation record\r
+    //\r
+    while (Reloc < RelocEnd) {\r
+\r
+      Fixup = FixupBase + (*Reloc & 0xFFF);\r
+      switch ((*Reloc) >> 12) {\r
+      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGH:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_LOW:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16  = (UINT16) (*F16 + (UINT16) Adjust);\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
+        F32   = (UINT32 *) Fixup;\r
+        *F32  = *F32 + (UINT32) Adjust;\r
+        if (FixupData != NULL) {\r
+          FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));\r
+          *(UINT32 *)FixupData  = *F32;\r
+          FixupData             = FixupData + sizeof (UINT32);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_DIR64:\r
+        F64 = (UINT64 *) Fixup;\r
+        *F64 = *F64 + (UINT64) Adjust;\r
+        if (FixupData != NULL) {\r
+          FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));\r
+          *(UINT64 *)(FixupData) = *F64;\r
+          FixupData = FixupData + sizeof(UINT64);\r
+        }\r
+        break;\r
+\r
+      default:\r
+        //\r
+        // The common code does not handle some of the stranger IPF relocations\r
+        // PeCoffLoaderRelocateImageEx () addes support for these complex fixups\r
+        // on IPF and is a No-Op on other archtiectures.\r
+        //\r
+        Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
+          return Status;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Next relocation record\r
+      //\r
+      Reloc += 1;\r
+    }\r
+\r
+    //\r
+    // Next reloc block\r
+    //\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Loads a PE/COFF image into memory.\r
+\r
+  Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer\r
+  specified by the ImageAddress and ImageSize fields of ImageContext.  The caller must allocate\r
+  the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.\r
+  The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
+                                    image that is being loaded.\r
+\r
+  @retval RETURN_SUCCESS            The PE/COFF image was loaded into the buffer specified by\r
+                                    the ImageAddress and ImageSize fields of ImageContext.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The caller did not provide a large enough buffer.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_LOAD_ERROR         The PE/COFF image is an EFI Runtime image with no relocations.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+  @retval RETURN_INVALID_PARAMETER  The image address is invalid.\r
+                                    Extended status information is in the ImageError field of ImageContext.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+GluePeCoffLoaderLoadImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  RETURN_STATUS                         Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT          CheckContext;\r
+  EFI_IMAGE_SECTION_HEADER              *FirstSection;\r
+  EFI_IMAGE_SECTION_HEADER              *Section;\r
+  UINTN                                 NumberOfSections;\r
+  UINTN                                 Index;\r
+  CHAR8                                 *Base;\r
+  CHAR8                                 *End;\r
+  CHAR8                                 *MaxEnd;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
+  UINTN                                 Size;\r
+  UINT32                                TempDebugEntryRva;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  ASSERT (ImageContext != NULL);\r
+\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // Copy the provided context info into our local version, get what we\r
+  // can from the original image, and then use that to make sure everything\r
+  // is legit.\r
+  //\r
+  CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
+\r
+  Status = PeCoffLoaderGetImageInfo (&CheckContext);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure there is enough allocated space for the image being loaded\r
+  //\r
+  if (ImageContext->ImageSize < CheckContext.ImageSize) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;\r
+    return RETURN_BUFFER_TOO_SMALL;\r
+  }\r
+  if (ImageContext->ImageAddress == 0) {\r
+    //\r
+    // Image cannot be loaded into 0 address.\r
+    //\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // If there's no relocations, then make sure it's not a runtime driver,\r
+  // and that it's being loaded at the linked address.\r
+  //\r
+  if (CheckContext.RelocationsStripped) {\r
+    //\r
+    // If the image does not contain relocations and it is a runtime driver\r
+    // then return an error.\r
+    //\r
+    if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+    //\r
+    // If the image does not contain relocations, and the requested load address\r
+    // is not the linked address, then return an error.\r
+    //\r
+    if (CheckContext.ImageAddress != ImageContext->ImageAddress) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Make sure the allocated space has the proper section alignment\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Read the entire PE/COFF or TE header into memory\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (VOID *) (UINTN) ImageContext->ImageAddress\r
+                            );\r
+\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      ImageContext->PeCoffHeaderOffset +\r
+                      sizeof(UINT32) +\r
+                      sizeof(EFI_IMAGE_FILE_HEADER) +\r
+                      Hdr.Pe32->FileHeader.SizeOfOptionalHeader\r
+      );\r
+    NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);\r
+  } else {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (void *)(UINTN)ImageContext->ImageAddress\r
+                            );\r
+\r
+    Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      sizeof(EFI_TE_IMAGE_HEADER)\r
+                      );\r
+    NumberOfSections  = (UINTN) (Hdr.Te->NumberOfSections);\r
+\r
+  }\r
+\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return RETURN_LOAD_ERROR;\r
+  }\r
+\r
+  //\r
+  // Load each section of the image\r
+  //\r
+  Section = FirstSection;\r
+  for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {\r
+\r
+    //\r
+    // Compute sections address\r
+    //\r
+    Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);\r
+    End = PeCoffLoaderImageAddress (\r
+            ImageContext,\r
+            Section->VirtualAddress + Section->Misc.VirtualSize - 1\r
+            );\r
+    if (ImageContext->IsTeImage) {\r
+      Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);\r
+      End  = (CHAR8 *)((UINTN) End +  sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);\r
+    }\r
+\r
+    if (End > MaxEnd) {\r
+      MaxEnd = End;\r
+    }\r
+    //\r
+    // If the base start or end address resolved to 0, then fail.\r
+    //\r
+    if ((Base == NULL) || (End == NULL)) {\r
+      ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Read the section\r
+    //\r
+    Size = (UINTN) Section->Misc.VirtualSize;\r
+    if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
+      Size = (UINTN) Section->SizeOfRawData;\r
+    }\r
+\r
+    if (Section->SizeOfRawData) {\r
+      if (!(ImageContext->IsTeImage)) {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      } else {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      }\r
+\r
+      if (RETURN_ERROR (Status)) {\r
+        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+    }\r
+\r
+    //\r
+    // If raw size is less then virt size, zero fill the remaining\r
+    //\r
+\r
+    if (Size < Section->Misc.VirtualSize) {\r
+      ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);\r
+    }\r
+\r
+    //\r
+    // Next Section\r
+    //\r
+    Section += 1;\r
+  }\r
+\r
+  //\r
+  // Get image's entry point\r
+  //\r
+  Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);\r
+  if (!(ImageContext->IsTeImage)) {\r
+    //\r
+    // Sizes of AddressOfEntryPoint are different so we need to do this safely\r
+    //\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (\r
+                                                            ImageContext,\r
+                                                            (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint\r
+                                                            );\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (\r
+                                                            ImageContext,\r
+                                                            (UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPoint\r
+                                                            );\r
+    }\r
+  } else {\r
+    ImageContext->EntryPoint =  (PHYSICAL_ADDRESS) (\r
+                                (UINTN)ImageContext->ImageAddress  +\r
+                                (UINTN)Hdr.Te->AddressOfEntryPoint +\r
+                                (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                (UINTN)Hdr.Te->StrippedSize\r
+                                );\r
+  }\r
+\r
+  //\r
+  // Determine the size of the fixup data\r
+  //\r
+  // Per the PE/COFF spec, you can't assume that a given data directory\r
+  // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+  // the optional header to verify a desired directory entry is there.\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    }\r
+\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+    } else {\r
+      ImageContext->FixupDataSize = 0;\r
+    }\r
+  } else {\r
+    DirectoryEntry              = &Hdr.Te->DataDirectory[0];\r
+    ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+  }\r
+  //\r
+  // Consumer must allocate a buffer for the relocation fixup log.\r
+  // Only used for runtime drivers.\r
+  //\r
+  ImageContext->FixupData = NULL;\r
+\r
+  //\r
+  // Load the Codeview info if present\r
+  //\r
+  if (ImageContext->DebugDirectoryEntryRva != 0) {\r
+    if (!(ImageContext->IsTeImage)) {\r
+      DebugEntry = PeCoffLoaderImageAddress (\r
+                    ImageContext,\r
+                    ImageContext->DebugDirectoryEntryRva\r
+                    );\r
+    } else {\r
+      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(\r
+                      ImageContext->ImageAddress +\r
+                      ImageContext->DebugDirectoryEntryRva +\r
+                      sizeof(EFI_TE_IMAGE_HEADER) -\r
+                      Hdr.Te->StrippedSize\r
+                      );\r
+    }\r
+\r
+    if (DebugEntry != NULL) {\r
+      TempDebugEntryRva = DebugEntry->RVA;\r
+      if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {\r
+        Section--;\r
+        if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;\r
+        } else {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;\r
+        }\r
+      }\r
+\r
+      if (TempDebugEntryRva != 0) {\r
+        if (!(ImageContext->IsTeImage)) {\r
+          ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);\r
+        } else {\r
+          ImageContext->CodeView = (VOID *)(\r
+                                    (UINTN)ImageContext->ImageAddress +\r
+                                    (UINTN)TempDebugEntryRva +\r
+                                    (UINTN)sizeof (EFI_TE_IMAGE_HEADER) -\r
+                                    (UINTN) Hdr.Te->StrippedSize\r
+                                    );\r
+        }\r
+\r
+        if (ImageContext->CodeView == NULL) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return RETURN_LOAD_ERROR;\r
+        }\r
+\r
+        if (DebugEntry->RVA == 0) {\r
+          Size = DebugEntry->SizeOfData;\r
+          if (!(ImageContext->IsTeImage)) {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+          } else {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+            //\r
+            // Should we apply fix up to this field according to the size difference between PE and TE?\r
+            // Because now we maintain TE header fields unfixed, this field will also remain as they are\r
+            // in original PE image.\r
+            //\r
+          }\r
+\r
+          if (RETURN_ERROR (Status)) {\r
+            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+            return RETURN_LOAD_ERROR;\r
+          }\r
+\r
+          DebugEntry->RVA = TempDebugEntryRva;\r
+        }\r
+\r
+        switch (*(UINT32 *) ImageContext->CodeView) {\r
+        case CODEVIEW_SIGNATURE_NB10:\r
+          ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+          break;\r
+\r
+        case CODEVIEW_SIGNATURE_RSDS:\r
+          ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+          break;\r
+\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI\r
+  runtime.\r
+\r
+  PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply\r
+  the fixups with a virtual mapping.\r
+\r
+\r
+  @param  ImageBase          Base address of relocated image\r
+  @param  VirtImageBase      Virtual mapping for ImageBase\r
+  @param  ImageSize          Size of the image to relocate\r
+  @param  RelocationData     Location to place results of read\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderRelocateImageForRuntime (\r
+  IN  PHYSICAL_ADDRESS        ImageBase,\r
+  IN  PHYSICAL_ADDRESS        VirtImageBase,\r
+  IN  UINTN                   ImageSize,\r
+  IN  VOID                    *RelocationData\r
+  )\r
+{\r
+  CHAR8                               *OldBase;\r
+  CHAR8                               *NewBase;\r
+  EFI_IMAGE_DOS_HEADER                *DosHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
+  UINT32                              NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY            *DataDirectory;\r
+  EFI_IMAGE_DATA_DIRECTORY            *RelocDir;\r
+  EFI_IMAGE_BASE_RELOCATION           *RelocBase;\r
+  EFI_IMAGE_BASE_RELOCATION           *RelocBaseEnd;\r
+  UINT16                              *Reloc;\r
+  UINT16                              *RelocEnd;\r
+  CHAR8                               *Fixup;\r
+  CHAR8                               *FixupBase;\r
+  UINT16                              *F16;\r
+  UINT32                              *F32;\r
+  UINT64                              *F64;\r
+  CHAR8                               *FixupData;\r
+  UINTN                               Adjust;\r
+  RETURN_STATUS                       Status;\r
+  UINT16                              Magic;\r
+\r
+  OldBase = (CHAR8 *)((UINTN)ImageBase);\r
+  NewBase = (CHAR8 *)((UINTN)VirtImageBase);\r
+  Adjust = (UINTN) NewBase - (UINTN) OldBase;\r
+\r
+  //\r
+  // Find the image's relocate dir info\r
+  //\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // Valid DOS header so get address of PE header\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(((CHAR8 *)DosHdr) + DosHdr->e_lfanew);\r
+  } else {\r
+    //\r
+    // No Dos header so assume image starts with PE header.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)OldBase;\r
+  }\r
+\r
+  if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+    //\r
+    // Not a valid PE image so Exit\r
+    //\r
+    return ;\r
+  }\r
+\r
+  Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);\r
+\r
+  if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    //\r
+    // Use PE32 offset\r
+    //\r
+    NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);\r
+  } else {\r
+    //\r
+    // Use PE32+ offset\r
+    //\r
+    NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+    DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);\r
+  }\r
+\r
+  //\r
+  // Find the relocation block\r
+  //\r
+  // Per the PE/COFF spec, you can't assume that a given data directory\r
+  // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+  // the optional header to verify a desired directory entry is there.\r
+  //\r
+  if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+    RelocDir      = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;\r
+    RelocBase     = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress);\r
+    RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress + RelocDir->Size);\r
+  } else {\r
+    //\r
+    // Cannot find relocations, cannot continue\r
+    //\r
+    ASSERT (FALSE);\r
+    return ;\r
+  }\r
+\r
+  ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);\r
+\r
+  //\r
+  // Run the whole relocation block. And re-fixup data that has not been\r
+  // modified. The FixupData is used to see if the image has been modified\r
+  // since it was relocated. This is so data sections that have been updated\r
+  // by code will not be fixed up, since that would set them back to\r
+  // defaults.\r
+  //\r
+  FixupData = RelocationData;\r
+  while (RelocBase < RelocBaseEnd) {\r
+\r
+    Reloc     = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\r
+    RelocEnd  = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock);\r
+    FixupBase = (CHAR8 *) ((UINTN)ImageBase) + RelocBase->VirtualAddress;\r
+\r
+    //\r
+    // Run this relocation record\r
+    //\r
+    while (Reloc < RelocEnd) {\r
+\r
+      Fixup = FixupBase + (*Reloc & 0xFFF);\r
+      switch ((*Reloc) >> 12) {\r
+\r
+      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGH:\r
+        F16 = (UINT16 *) Fixup;\r
+        if (*(UINT16 *) FixupData == *F16) {\r
+          *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));\r
+        }\r
+\r
+        FixupData = FixupData + sizeof (UINT16);\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_LOW:\r
+        F16 = (UINT16 *) Fixup;\r
+        if (*(UINT16 *) FixupData == *F16) {\r
+          *F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff));\r
+        }\r
+\r
+        FixupData = FixupData + sizeof (UINT16);\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
+        F32       = (UINT32 *) Fixup;\r
+        FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));\r
+        if (*(UINT32 *) FixupData == *F32) {\r
+          *F32 = *F32 + (UINT32) Adjust;\r
+        }\r
+\r
+        FixupData = FixupData + sizeof (UINT32);\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_DIR64:\r
+        F64       = (UINT64 *)Fixup;\r
+        FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));\r
+        if (*(UINT64 *) FixupData == *F64) {\r
+          *F64 = *F64 + (UINT64)Adjust;\r
+        }\r
+\r
+        FixupData = FixupData + sizeof (UINT64);\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHADJ:\r
+        //\r
+        // Not implemented, but not used in EFI 1.0\r
+        //\r
+        ASSERT (FALSE);\r
+        break;\r
+\r
+      default:\r
+        //\r
+        // Only Itanium requires ConvertPeImage_Ex\r
+        //\r
+        Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);\r
+        if (RETURN_ERROR (Status)) {\r
+          return ;\r
+        }\r
+      }\r
+      //\r
+      // Next relocation record\r
+      //\r
+      Reloc += 1;\r
+    }\r
+    //\r
+    // next reloc block\r
+    //\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  ImageRead function that operates on a memory buffer whos base is passed into\r
+  FileHandle.\r
+\r
+  @param  FileHandle        Ponter to baes of the input stream\r
+  @param  FileOffset        Offset to the start of the buffer\r
+  @param  ReadSize          Number of bytes to copy into the buffer\r
+  @param  Buffer            Location to place results of read\r
+\r
+  @retval RETURN_SUCCESS    Data is read from FileOffset from the Handle into\r
+                            the buffer.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderImageReadFromMemory (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+{\r
+  CopyMem (Buffer, ((UINT8 *)FileHandle) + FileOffset, *ReadSize);\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf
new file mode 100644 (file)
index 0000000..8c9f6bc
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePeCoffLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePeCoffLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePeCoffLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  BasePeCoff.c\r
+\r
+[sources.ia32]\r
+  Ia32\PeCoffLoaderEx.c\r
+\r
+[sources.x64]\r
+  X64\PeCoffLoaderEx.c\r
+\r
+[sources.ipf]\r
+  Ipf\PeCoffLoaderEx.c\r
+\r
+[sources.ebc]\r
+  Ebc\PeCoffLoaderEx.c\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader\r
+\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h
new file mode 100644 (file)
index 0000000..c72f182
--- /dev/null
@@ -0,0 +1,131 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  BasePeCoffLibInternals.h\r
+  \r
+Abstract: \r
+\r
+  Header file for Base PeCoff Library\r
+  \r
+--*/\r
+\r
+#ifndef __BASE_PECOFF_LIB_INTERNALS__\r
+#define __BASE_PECOFF_LIB_INTERNALS__\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Performs an Itanium-based specific relocation fixup and is a no-op on other\r
+  instruction sets.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  );\r
+\r
+\r
+/**\r
+  Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
+  instruction sets. This is used to re-relocated the image into the EFI virtual\r
+  space for runtime calls.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeHotRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  );\r
+\r
+\r
+/**\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported\r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point.\r
+\r
+  @param  Machine   Machine type from the PE Header.\r
+\r
+  @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  );\r
+\r
+/**\r
+  Retrieves the magic value from the PE/COFF header.\r
+\r
+  @param  Hdr             The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+  @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32\r
+  @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+\r
+\r
+**/\r
+UINT16\r
+PeCoffLoaderGetPeHeaderMagicValue (\r
+  IN  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr\r
+  );\r
+\r
+/**\r
+  Retrieves the PE or TE Header from a PE/COFF or TE image.\r
+\r
+  @param  ImageContext    The context of the image being loaded.\r
+  @param  Hdr             The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+  @retval RETURN_SUCCESS  The PE or TE Header is read.\r
+  @retval Other           The error status from reading the PE/COFF or TE image using the ImageRead function.\r
+\r
+**/\r
+RETURN_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,\r
+  OUT    EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr\r
+  );\r
+\r
+/**\r
+  Converts an image address to the loaded address.\r
+\r
+  @param  ImageContext  The context of the image being loaded.\r
+  @param  Address       The address to be converted to the loaded address.\r
+\r
+  @return The converted address or NULL if the address can not be converted.\r
+\r
+**/\r
+VOID *\r
+PeCoffLoaderImageAddress (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN     UINTN                                 Address\r
+  );\r
+\r
+#endif\r
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 (file)
index 0000000..b6df433
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+  \r
+Abstract: \r
+\r
+  EBC Specific relocation fixups.\r
+\r
+--*/\r
+\r
+#include "BasePeCoffLibInternals.h"\r
+\r
+/**\r
+  Performs an EBC specific relocation fixup.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @retval EFI_UNSUPPORTED Unsupported now.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+  @param  Machine   Machine type from the PE Header.\r
+\r
+  @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
+  instruction sets. This is used to re-relocated the image into the EFI virtual\r
+  space for runtime calls.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeHotRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
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 (file)
index 0000000..713ad7b
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+  \r
+Abstract: \r
+\r
+  IA-32 Specific relocation fixups.\r
+\r
+--*/\r
+\r
+#include "BasePeCoffLibInternals.h"\r
+\r
+/**\r
+  Performs an IA-32 specific relocation fixup.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @retval EFI_UNSUPPORTED Unsupported now.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+  @param  Machine   Machine type from the PE Header.\r
+\r
+  @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
+  instruction sets. This is used to re-relocated the image into the EFI virtual\r
+  space for runtime calls.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeHotRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
+\r
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 (file)
index 0000000..d722175
--- /dev/null
@@ -0,0 +1,430 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+  \r
+Abstract: \r
+\r
+  IA-32 Specific relocation fixups.\r
+\r
+--*/\r
+\r
+#include "BasePeCoffLibInternals.h"\r
+\r
+#define EFI_IMAGE_MACHINE_IPF EFI_IMAGE_MACHINE_IA64\r
+\r
+#define EXT_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)\r
+\r
+#define INS_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \\r
+          ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)\r
+\r
+#define IMM64_IMM7B_INST_WORD_X         3\r
+#define IMM64_IMM7B_SIZE_X              7\r
+#define IMM64_IMM7B_INST_WORD_POS_X     4\r
+#define IMM64_IMM7B_VAL_POS_X           0\r
+\r
+#define IMM64_IMM9D_INST_WORD_X         3\r
+#define IMM64_IMM9D_SIZE_X              9\r
+#define IMM64_IMM9D_INST_WORD_POS_X     18\r
+#define IMM64_IMM9D_VAL_POS_X           7\r
+\r
+#define IMM64_IMM5C_INST_WORD_X         3\r
+#define IMM64_IMM5C_SIZE_X              5\r
+#define IMM64_IMM5C_INST_WORD_POS_X     13\r
+#define IMM64_IMM5C_VAL_POS_X           16\r
+\r
+#define IMM64_IC_INST_WORD_X            3\r
+#define IMM64_IC_SIZE_X                 1\r
+#define IMM64_IC_INST_WORD_POS_X        12\r
+#define IMM64_IC_VAL_POS_X              21\r
+\r
+#define IMM64_IMM41a_INST_WORD_X        1\r
+#define IMM64_IMM41a_SIZE_X             10\r
+#define IMM64_IMM41a_INST_WORD_POS_X    14\r
+#define IMM64_IMM41a_VAL_POS_X          22\r
+\r
+#define IMM64_IMM41b_INST_WORD_X        1\r
+#define IMM64_IMM41b_SIZE_X             8\r
+#define IMM64_IMM41b_INST_WORD_POS_X    24\r
+#define IMM64_IMM41b_VAL_POS_X          32\r
+\r
+#define IMM64_IMM41c_INST_WORD_X        2\r
+#define IMM64_IMM41c_SIZE_X             23\r
+#define IMM64_IMM41c_INST_WORD_POS_X    0\r
+#define IMM64_IMM41c_VAL_POS_X          40\r
+\r
+#define IMM64_SIGN_INST_WORD_X          3\r
+#define IMM64_SIGN_SIZE_X               1\r
+#define IMM64_SIGN_INST_WORD_POS_X      27\r
+#define IMM64_SIGN_VAL_POS_X            63\r
+\r
+/**\r
+  Performs an Itanium-based specific relocation fixup.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  UINT64      *F64;\r
+  UINT64      FixupVal;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+    case EFI_IMAGE_REL_BASED_IA64_IMM64:\r
+\r
+      //\r
+      // Align it to bundle address before fixing up the\r
+      // 64-bit immediate value of the movl instruction.\r
+      //\r
+\r
+      Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));\r
+      FixupVal = (UINT64)0;\r
+\r
+      //\r
+      // Extract the lower 32 bits of IMM64 from bundle\r
+      //\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+\r
+      //\r
+      // Update 64-bit address\r
+      //\r
+      FixupVal += Adjust;\r
+\r
+      //\r
+      // Insert IMM64 into bundle\r
+      //\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),\r
+                IMM64_IMM41b_SIZE_X,\r
+                IMM64_IMM41b_INST_WORD_POS_X,\r
+                IMM64_IMM41b_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),\r
+                IMM64_IMM41c_SIZE_X,\r
+                IMM64_IMM41c_INST_WORD_POS_X,\r
+                IMM64_IMM41c_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),\r
+                IMM64_SIGN_SIZE_X,\r
+                IMM64_SIGN_INST_WORD_POS_X,\r
+                IMM64_SIGN_VAL_POS_X\r
+                );\r
+\r
+      F64 = (UINT64 *) Fixup;\r
+      if (*FixupData != NULL) {\r
+        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+        *(UINT64 *)(*FixupData) = *F64;\r
+        *FixupData = *FixupData + sizeof(UINT64);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported\r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point.\r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the\r
+  consumer of this library. This version also supports the special relocations\r
+  for Itanium.\r
+\r
+  @param  Machine   Machine type from the PE Header.\r
+\r
+  @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IPF) || (Machine == EFI_IMAGE_MACHINE_IA32) ||\r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC) || (Machine == EFI_IMAGE_MACHINE_X64)) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  ImageRead function that operates on a memory buffer whos base is passed into\r
+  FileHandle.\r
+\r
+  @param  Reloc             Ponter to baes of the input stream\r
+  @param  Fixup             Offset to the start of the buffer\r
+  @param  FixupData         Number of bytes to copy into the buffer\r
+  @param  Adjust            Location to place results of read\r
+\r
+  @retval RETURN_SUCCESS    Data is read from FileOffset from the Handle into\r
+                            the buffer.\r
+**/\r
+RETURN_STATUS\r
+GluePeHotRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  UINT64  *F64;\r
+  UINT64  FixupVal;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+  case EFI_IMAGE_REL_BASED_DIR64:\r
+    F64         = (UINT64 *) Fixup;\r
+    *FixupData  = ALIGN_POINTER (*FixupData, sizeof (UINT64));\r
+    if (*(UINT64 *) (*FixupData) == *F64) {\r
+      *F64 = *F64 + (UINT64) Adjust;\r
+    }\r
+\r
+    *FixupData = *FixupData + sizeof (UINT64);\r
+    break;\r
+\r
+  case EFI_IMAGE_REL_BASED_IA64_IMM64:\r
+    F64         = (UINT64 *) Fixup;\r
+    *FixupData  = ALIGN_POINTER (*FixupData, sizeof (UINT64));\r
+    if (*(UINT64 *) (*FixupData) == *F64) {\r
+      //\r
+      // Align it to bundle address before fixing up the\r
+      // 64-bit immediate value of the movl instruction.\r
+      //\r
+      //\r
+      Fixup     = (CHAR8 *) ((UINT64) Fixup & (UINT64)~(15));\r
+      FixupVal  = (UINT64) 0;\r
+\r
+      //\r
+      // Extract the lower 32 bits of IMM64 from bundle\r
+      //\r
+      EXT_IMM64 (\r
+        FixupVal,\r
+        (UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X,\r
+        IMM64_IMM7B_SIZE_X,\r
+        IMM64_IMM7B_INST_WORD_POS_X,\r
+        IMM64_IMM7B_VAL_POS_X\r
+        );\r
+\r
+      EXT_IMM64 (\r
+        FixupVal,\r
+        (UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X,\r
+        IMM64_IMM9D_SIZE_X,\r
+        IMM64_IMM9D_INST_WORD_POS_X,\r
+        IMM64_IMM9D_VAL_POS_X\r
+        );\r
+\r
+      EXT_IMM64 (\r
+        FixupVal,\r
+        (UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X,\r
+        IMM64_IMM5C_SIZE_X,\r
+        IMM64_IMM5C_INST_WORD_POS_X,\r
+        IMM64_IMM5C_VAL_POS_X\r
+        );\r
+\r
+      EXT_IMM64 (\r
+        FixupVal,\r
+        (UINT32 *) Fixup + IMM64_IC_INST_WORD_X,\r
+        IMM64_IC_SIZE_X,\r
+        IMM64_IC_INST_WORD_POS_X,\r
+        IMM64_IC_VAL_POS_X\r
+        );\r
+\r
+      EXT_IMM64 (\r
+        FixupVal,\r
+        (UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X,\r
+        IMM64_IMM41a_SIZE_X,\r
+        IMM64_IMM41a_INST_WORD_POS_X,\r
+        IMM64_IMM41a_VAL_POS_X\r
+        );\r
+\r
+      //\r
+      // Update 64-bit address\r
+      //\r
+      FixupVal += Adjust;\r
+\r
+      //\r
+      // Insert IMM64 into bundle\r
+      //\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X),\r
+        IMM64_IMM7B_SIZE_X,\r
+        IMM64_IMM7B_INST_WORD_POS_X,\r
+        IMM64_IMM7B_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X),\r
+        IMM64_IMM9D_SIZE_X,\r
+        IMM64_IMM9D_INST_WORD_POS_X,\r
+        IMM64_IMM9D_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X),\r
+        IMM64_IMM5C_SIZE_X,\r
+        IMM64_IMM5C_INST_WORD_POS_X,\r
+        IMM64_IMM5C_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IC_INST_WORD_X),\r
+        IMM64_IC_SIZE_X,\r
+        IMM64_IC_INST_WORD_POS_X,\r
+        IMM64_IC_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X),\r
+        IMM64_IMM41a_SIZE_X,\r
+        IMM64_IMM41a_INST_WORD_POS_X,\r
+        IMM64_IMM41a_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM41b_INST_WORD_X),\r
+        IMM64_IMM41b_SIZE_X,\r
+        IMM64_IMM41b_INST_WORD_POS_X,\r
+        IMM64_IMM41b_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_IMM41c_INST_WORD_X),\r
+        IMM64_IMM41c_SIZE_X,\r
+        IMM64_IMM41c_INST_WORD_POS_X,\r
+        IMM64_IMM41c_VAL_POS_X\r
+        );\r
+\r
+      INS_IMM64 (\r
+        FixupVal,\r
+        ((UINT32 *) Fixup + IMM64_SIGN_INST_WORD_X),\r
+        IMM64_SIGN_SIZE_X,\r
+        IMM64_SIGN_INST_WORD_POS_X,\r
+        IMM64_SIGN_VAL_POS_X\r
+        );\r
+\r
+      *(UINT64 *) (*FixupData) = *F64;\r
+    }\r
+\r
+    *FixupData = *FixupData + sizeof (UINT64);\r
+    break;\r
+\r
+  default:\r
+    DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n"));\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+\r
+\r
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 (file)
index 0000000..6d1fb39
--- /dev/null
@@ -0,0 +1,99 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+  \r
+Abstract: \r
+\r
+  x64 Specific relocation fixups.\r
+\r
+--*/\r
+\r
+#include "BasePeCoffLibInternals.h"\r
+\r
+\r
+/**\r
+  Performs an x64 specific relocation fixup.\r
+\r
+  @param  Reloc       Pointer to the relocation record\r
+  @param  Fixup       Pointer to the address to fix up\r
+  @param  FixupData   Pointer to a buffer to log the fixups\r
+  @param  Adjust      The offset to adjust the fixup\r
+\r
+  @retval RETURN_SUCCESS      Success to perform relocation\r
+  @retval RETURN_UNSUPPORTED  Unsupported.\r
+**/\r
+RETURN_STATUS\r
+GluePeCoffLoaderRelocateImageEx (\r
+  IN     UINT16       *Reloc,\r
+  IN OUT CHAR8        *Fixup, \r
+  IN OUT CHAR8        **FixupData,\r
+  IN     UINT64       Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+  @param  Machine   Machine type from the PE Header.\r
+\r
+  @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Performs an X64 specific re-relocation fixup and is a no-op on other\r
+  instruction sets. This is used to re-relocated the image into the EFI virtual\r
+  space for runtime calls.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+GluePeHotRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf
new file mode 100644 (file)
index 0000000..4911096
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePostCodeLibDebug.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePostCodeLibDebug\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePostCodeLibDebug\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PostCode.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader\r
+\r
+\r
+[libraries.common]\r
+# A DebugLib instance\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c
new file mode 100644 (file)
index 0000000..d16b592
--- /dev/null
@@ -0,0 +1,131 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PostCode.c\r
+  \r
+Abstract: \r
+\r
+  Post Code functions\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Sends an 32-bit value to a POST card.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.  \r
+  Some implementations of this library function may perform I/O operations \r
+  directly to a POST card device.  Other implementations may send Value to \r
+  ReportStatusCode(), and the status code reporting mechanism will eventually \r
+  display the 32-bit value on the status reporting device.\r
+  \r
+  PostCode() must actively prevent recursion.  If PostCode() is called while \r
+  processing another any other Report Status Code Library function, then \r
+  PostCode() must return Value immediately.\r
+\r
+  @param  Value  The 32-bit value to write to the POST card.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCode (\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  DEBUG((EFI_D_INFO, "POST %08x\n", Value));\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Sends an 32-bit value to a POST and associated ASCII string.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.\r
+  If Description is not NULL, then the ASCII string specified by Description is \r
+  also passed to the handler that displays the POST card value.  Some \r
+  implementations of this library function may perform I/O operations directly \r
+  to a POST card device.  Other implementations may send Value to ReportStatusCode(), \r
+  and the status code reporting mechanism will eventually display the 32-bit \r
+  value on the status reporting device.  \r
+\r
+  PostCodeWithDescription()must actively prevent recursion.  If \r
+  PostCodeWithDescription() is called while processing another any other Report \r
+  Status Code Library function, then PostCodeWithDescription() must return Value \r
+  immediately.\r
+\r
+  @param  Value        The 32-bit value to write to the POST card.\r
+  @param  Description  Pointer to an ASCII string that is a description of the \r
+                       POST code value.  This is an optional parameter that may \r
+                       be NULL.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCodeWithDescription (\r
+  IN UINT32       Value,\r
+  IN CONST CHAR8  *Description  OPTIONAL\r
+  )\r
+{\r
+  DEBUG((EFI_D_INFO, "POST %08x - %s\n", Value, Description));\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST Codes are enabled.\r
+\r
+  This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+  bit of PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST code descriptions are enabled.\r
+\r
+  This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED\r
+  bit of PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
+                  PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of\r
+                  PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeDescriptionEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
new file mode 100644 (file)
index 0000000..f7376ca
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePostCodeLibPort80.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePostCodeLibPort80\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePostCodeLibPort80\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PostCode.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader\r
+\r
+\r
+[libraries.common]\r
+\r
+[libraries.ia32]\r
+  EdkIIGlueBaseIoLibIntrinsic  \r
+\r
+[libraries.x64]\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+\r
+[libraries.ebc]\r
+  EdkIIGlueDxeIoLibCpuIo\r
+\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c
new file mode 100644 (file)
index 0000000..ff14011
--- /dev/null
@@ -0,0 +1,131 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+Module Name:\r
+\r
+  PostCode.c\r
+  \r
+Abstract: \r
+\r
+  Post Code functions\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Sends an 32-bit value to a POST card.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.  \r
+  Some implementations of this library function may perform I/O operations \r
+  directly to a POST card device.  Other implementations may send Value to \r
+  ReportStatusCode(), and the status code reporting mechanism will eventually \r
+  display the 32-bit value on the status reporting device.\r
+  \r
+  PostCode() must actively prevent recursion.  If PostCode() is called while \r
+  processing another any other Report Status Code Library function, then \r
+  PostCode() must return Value immediately.\r
+\r
+  @param  Value  The 32-bit value to write to the POST card.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCode (\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  IoWrite8 (0x80, (UINT8)(Value));\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Sends an 32-bit value to a POST and associated ASCII string.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.\r
+  If Description is not NULL, then the ASCII string specified by Description is \r
+  also passed to the handler that displays the POST card value.  Some \r
+  implementations of this library function may perform I/O operations directly \r
+  to a POST card device.  Other implementations may send Value to ReportStatusCode(), \r
+  and the status code reporting mechanism will eventually display the 32-bit \r
+  value on the status reporting device.  \r
+\r
+  PostCodeWithDescription()must actively prevent recursion.  If \r
+  PostCodeWithDescription() is called while processing another any other Report \r
+  Status Code Library function, then PostCodeWithDescription() must return Value \r
+  immediately.\r
+\r
+  @param  Value        The 32-bit value to write to the POST card.\r
+  @param  Description  Pointer to an ASCII string that is a description of the \r
+                       POST code value.  This is an optional parameter that may \r
+                       be NULL.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCodeWithDescription (\r
+  IN UINT32       Value,\r
+  IN CONST CHAR8  *Description  OPTIONAL\r
+  )\r
+{\r
+  IoWrite8 (0x80, (UINT8)(Value));\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST Codes are enabled.\r
+\r
+  This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+  bit of PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST code descriptions are enabled.\r
+\r
+  This function returns TRUE if the \r
+  POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+  PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeDescriptionEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf
new file mode 100644 (file)
index 0000000..4e10309
--- /dev/null
@@ -0,0 +1,82 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BasePrintLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BasePrintLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBasePrintLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PrintLib.c\r
+  PrintLibInternal.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader\r
+\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
new file mode 100644 (file)
index 0000000..e90b73f
--- /dev/null
@@ -0,0 +1,1086 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PrintLib.c\r
+  \r
+Abstract: \r
+\r
+  Print Library.\r
+\r
+--*/\r
+\r
+#include "PrintLibInternal.h"\r
+\r
+#define WARNING_STATUS_NUMBER         4\r
+#define ERROR_STATUS_NUMBER           24\r
+#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = {\r
+  "Success",                      //  RETURN_SUCCESS                = 0\r
+  "Warning Unknown Glyph",        //  RETURN_WARN_UNKNOWN_GLYPH     = 1\r
+  "Warning Delete Failure",       //  RETURN_WARN_DELETE_FAILURE    = 2\r
+  "Warning Write Failure",        //  RETURN_WARN_WRITE_FAILURE     = 3\r
+  "Warning Buffer Too Small",     //  RETURN_WARN_BUFFER_TOO_SMALL  = 4\r
+  "Load Error",                   //  RETURN_LOAD_ERROR             = 1  | MAX_BIT\r
+  "Invalid Parameter",            //  RETURN_INVALID_PARAMETER      = 2  | MAX_BIT\r
+  "Unsupported",                  //  RETURN_UNSUPPORTED            = 3  | MAX_BIT\r
+  "Bad Buffer Size",              //  RETURN_BAD_BUFFER_SIZE        = 4  | MAX_BIT\r
+  "Buffer Too Small",             //  RETURN_BUFFER_TOO_SMALL,      = 5  | MAX_BIT\r
+  "Not Ready",                    //  RETURN_NOT_READY              = 6  | MAX_BIT\r
+  "Device Error",                 //  RETURN_DEVICE_ERROR           = 7  | MAX_BIT\r
+  "Write Protected",              //  RETURN_WRITE_PROTECTED        = 8  | MAX_BIT\r
+  "Out of Resources",             //  RETURN_OUT_OF_RESOURCES       = 9  | MAX_BIT\r
+  "Volume Corrupt",               //  RETURN_VOLUME_CORRUPTED       = 10 | MAX_BIT\r
+  "Volume Full",                  //  RETURN_VOLUME_FULL            = 11 | MAX_BIT\r
+  "No Media",                     //  RETURN_NO_MEDIA               = 12 | MAX_BIT\r
+  "Media changed",                //  RETURN_MEDIA_CHANGED          = 13 | MAX_BIT\r
+  "Not Found",                    //  RETURN_NOT_FOUND              = 14 | MAX_BIT\r
+  "Access Denied",                //  RETURN_ACCESS_DENIED          = 15 | MAX_BIT\r
+  "No Response",                  //  RETURN_NO_RESPONSE            = 16 | MAX_BIT\r
+  "No mapping",                   //  RETURN_NO_MAPPING             = 17 | MAX_BIT\r
+  "Time out",                     //  RETURN_TIMEOUT                = 18 | MAX_BIT\r
+  "Not started",                  //  RETURN_NOT_STARTED            = 19 | MAX_BIT\r
+  "Already started",              //  RETURN_ALREADY_STARTED        = 20 | MAX_BIT\r
+  "Aborted",                      //  RETURN_ABORTED                = 21 | MAX_BIT\r
+  "ICMP Error",                   //  RETURN_ICMP_ERROR             = 22 | MAX_BIT\r
+  "TFTP Error",                   //  RETURN_TFTP_ERROR             = 23 | MAX_BIT\r
+  "Protocol Error"                //  RETURN_PROTOCOL_ERROR         = 24 | MAX_BIT\r
+};\r
+\r
+/**\r
+  Worker function that produces a Null-terminated string in an output buffer \r
+  based on a Null-terminated format string and a VA_LIST argument list.\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine.\r
+\r
+  @param  Buffer      Character buffer to print the results of the parsing\r
+                      of Format into.\r
+  @param  BufferSize  Maximum number of characters to put into buffer.\r
+  @param  Flags       Intial flags value.\r
+                      Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.\r
+  @param  Format      Null-terminated format string.\r
+  @param  Marker      Vararg list consumed by processing Format.\r
+\r
+  @return Number of characters printed not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibVSPrint (\r
+  OUT CHAR8        *Buffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *Format,\r
+  IN  VA_LIST      Marker\r
+  )\r
+{\r
+  CHAR8           *OriginalBuffer;\r
+  CHAR8           *EndBuffer;\r
+  CHAR8           ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
+  UINTN           BytesPerOutputCharacter;\r
+  UINTN           BytesPerFormatCharacter;\r
+  UINTN           FormatMask;\r
+  UINTN           FormatCharacter;\r
+  UINTN           Width;\r
+  UINTN           Precision;\r
+  INT64           Value;\r
+  CONST CHAR8     *ArgumentString;\r
+  UINTN           Character;\r
+  GUID            *TmpGuid;\r
+  TIME            *TmpTime;\r
+  UINTN           Count;\r
+  UINTN           ArgumentMask;\r
+  INTN            BytesPerArgumentCharacter;\r
+  UINTN           ArgumentCharacter;\r
+  BOOLEAN         Done;\r
+  UINTN           Index;\r
+  CHAR8           Prefix;\r
+  BOOLEAN         ZeroPad;\r
+  BOOLEAN         Comma;\r
+  UINTN           Digits;\r
+  UINTN           Radix;\r
+  RETURN_STATUS   Status;\r
+\r
+  if (BufferSize == 0) {\r
+    return 0;\r
+  }\r
+  ASSERT (Buffer != NULL);\r
+\r
+  if ((Flags & OUTPUT_UNICODE) != 0) {\r
+    BytesPerOutputCharacter = 2;\r
+  } else {\r
+    BytesPerOutputCharacter = 1;\r
+  }\r
+\r
+  //\r
+  // Reserve space for the Null terminator.\r
+  //\r
+  BufferSize--;\r
+  OriginalBuffer = Buffer;\r
+  //\r
+  // Set the tag for the end of the input Buffer.\r
+  //\r
+  EndBuffer      = Buffer + BufferSize * BytesPerOutputCharacter;\r
+\r
+  if ((Flags & FORMAT_UNICODE) != 0) {\r
+    //\r
+    // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength\r
+    // Unicode characters if PcdMaximumUnicodeStringLength is not zero. \r
+    //\r
+    ASSERT (StrSize ((CHAR16 *) Format) != 0);\r
+    BytesPerFormatCharacter = 2;\r
+    FormatMask = 0xffff;\r
+  } else {\r
+    //\r
+    // Make sure format string cannot contain more than PcdMaximumAsciiStringLength\r
+    // Ascii characters if PcdMaximumAsciiStringLength is not zero. \r
+    //\r
+    ASSERT (AsciiStrSize (Format) != 0);\r
+    BytesPerFormatCharacter = 1;\r
+    FormatMask = 0xff;\r
+  }\r
+\r
+\r
+\r
+  //\r
+  // Get the first character from the format string\r
+  //\r
+  FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+\r
+  //\r
+  // Loop until the end of the format string is reached or the output buffer is full\r
+  //\r
+  while (FormatCharacter != 0 && Buffer < EndBuffer) {\r
+    //\r
+    // Clear all the flag bits except those that may have been passed in\r
+    //\r
+    Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE);\r
+\r
+    //\r
+    // Set the default width to zero, and the default precision to 1\r
+    //\r
+    Width     = 0;\r
+    Precision = 1;\r
+    Prefix    = 0;\r
+    Comma     = FALSE;\r
+    ZeroPad   = FALSE;\r
+    Count     = 0;\r
+    Digits    = 0;\r
+\r
+    switch (FormatCharacter) {\r
+    case '%':\r
+      //\r
+      // Parse Flags and Width\r
+      //\r
+      for (Done = FALSE; !Done; ) {\r
+        Format += BytesPerFormatCharacter;\r
+        FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+        switch (FormatCharacter) {\r
+        case '.': \r
+          Flags |= PRECISION; \r
+          break;\r
+        case '-': \r
+          Flags |= LEFT_JUSTIFY; \r
+          break;\r
+        case '+': \r
+          Flags |= PREFIX_SIGN;  \r
+          break;\r
+        case ' ': \r
+          Flags |= PREFIX_BLANK; \r
+          break;\r
+        case ',': \r
+          Flags |= COMMA_TYPE; \r
+          break;\r
+        case 'L':\r
+        case 'l': \r
+          Flags |= LONG_TYPE;    \r
+          break;\r
+        case '*':\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PAD_TO_WIDTH;\r
+            Width = VA_ARG (Marker, UINTN);\r
+          } else {\r
+            Precision = VA_ARG (Marker, UINTN);\r
+          }\r
+          break;\r
+        case '0':\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PREFIX_ZERO;\r
+          }\r
+        case '1':\r
+        case '2':\r
+        case '3':\r
+        case '4':\r
+        case '5':\r
+        case '6':\r
+        case '7':\r
+        case '8':\r
+        case '9':\r
+          for (Count = 0; ((FormatCharacter >= '0') &&  (FormatCharacter <= '9')); ){\r
+            Count = (Count * 10) + FormatCharacter - '0';\r
+            Format += BytesPerFormatCharacter;\r
+            FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+          }\r
+          Format -= BytesPerFormatCharacter;\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PAD_TO_WIDTH;\r
+            Width = Count;\r
+          } else {\r
+            Precision = Count;\r
+          }\r
+          break;\r
+       \r
+        case '\0':\r
+          //\r
+          // Make no output if Format string terminates unexpectedly when\r
+          // looking up for flag, width, precision and type. \r
+          //\r
+          Format   -= BytesPerFormatCharacter;\r
+          Precision = 0;\r
+          //\r
+          // break skipped on purpose.\r
+          //\r
+        default:\r
+          Done = TRUE;\r
+          break;\r
+        }\r
+      } \r
+\r
+      //\r
+      // Handle each argument type\r
+      //\r
+      switch (FormatCharacter) {\r
+      case 'p':\r
+        //\r
+        // Flag space, +, 0, L & l are invalid for type p.\r
+        //\r
+        Flags &= ~(PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE);\r
+        if (sizeof (VOID *) > 4) {\r
+          Flags |= LONG_TYPE;\r
+        }\r
+      case 'X':\r
+        Flags |= PREFIX_ZERO;\r
+        //\r
+        // break skipped on purpose\r
+        //\r
+      case 'x':\r
+        Flags |= RADIX_HEX;\r
+        //\r
+        // break skipped on purpose\r
+        //\r
+      case 'd':\r
+        if ((Flags & LONG_TYPE) == 0) {\r
+          Value = (VA_ARG (Marker, int));\r
+        } else {\r
+          Value = VA_ARG (Marker, INT64);\r
+        }\r
+        if ((Flags & PREFIX_BLANK) != 0) {\r
+          Prefix = ' ';\r
+        }\r
+        if ((Flags & PREFIX_SIGN) != 0) {\r
+          Prefix = '+';\r
+        }\r
+        if ((Flags & COMMA_TYPE) != 0) {\r
+          Comma = TRUE;\r
+        }\r
+        if ((Flags & RADIX_HEX) == 0) {\r
+          Radix = 10;\r
+          if (Comma) {\r
+            Flags &= (~PREFIX_ZERO);\r
+            Precision = 1;\r
+          }\r
+          if (Value < 0) {\r
+            Flags |= PREFIX_SIGN;\r
+            Prefix = '-';\r
+            Value = -Value;\r
+          }\r
+        } else {\r
+          Radix = 16;\r
+          Comma = FALSE;\r
+          if ((Flags & LONG_TYPE) == 0 && Value < 0) {\r
+            Value = (unsigned int)Value;\r
+          }\r
+        }\r
+        //\r
+        // Convert Value to a reversed string\r
+        //\r
+        Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);\r
+        if (Value == 0 && Precision == 0) {\r
+          Count = 0;\r
+        }\r
+        ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
+        \r
+        Digits = Count % 3;\r
+        if (Digits != 0) {\r
+          Digits = 3 - Digits;\r
+        }\r
+        if (Comma && Count != 0) {\r
+          Count += ((Count - 1) / 3);\r
+        }\r
+        if (Prefix != 0) {\r
+          Count++;\r
+          Precision++;\r
+        }\r
+        Flags |= ARGUMENT_REVERSED;\r
+        ZeroPad = TRUE;\r
+        if ((Flags & PREFIX_ZERO) != 0) {\r
+          if ((Flags & LEFT_JUSTIFY) == 0) {\r
+            if ((Flags & PAD_TO_WIDTH) != 0) {\r
+              if ((Flags & PRECISION) == 0) {\r
+                Precision = Width;\r
+              }\r
+            }\r
+          }\r
+        }\r
+        break;\r
+\r
+      case 's':\r
+      case 'S':\r
+        Flags |= ARGUMENT_UNICODE;\r
+        //\r
+        // break skipped on purpose\r
+        //\r
+      case 'a':\r
+        ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);\r
+        if (ArgumentString == NULL) {\r
+          Flags &= (~ARGUMENT_UNICODE);\r
+          ArgumentString = "<null string>";\r
+        }\r
+        break;\r
+\r
+      case 'c':\r
+        Character = VA_ARG (Marker, UINTN) & 0xffff;\r
+        ArgumentString = (CHAR8 *)&Character;\r
+        Flags |= ARGUMENT_UNICODE;\r
+        break;\r
+\r
+      case 'g':\r
+        TmpGuid = VA_ARG (Marker, GUID *);\r
+        if (TmpGuid == NULL) {\r
+          ArgumentString = "<null guid>";\r
+        } else {\r
+          BasePrintLibSPrint (\r
+            ValueBuffer,\r
+            MAXIMUM_VALUE_CHARACTERS, \r
+            0,\r
+            "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
+            TmpGuid->Data1,\r
+            TmpGuid->Data2,\r
+            TmpGuid->Data3,\r
+            TmpGuid->Data4[0],\r
+            TmpGuid->Data4[1],\r
+            TmpGuid->Data4[2],\r
+            TmpGuid->Data4[3],\r
+            TmpGuid->Data4[4],\r
+            TmpGuid->Data4[5],\r
+            TmpGuid->Data4[6],\r
+            TmpGuid->Data4[7]\r
+            );\r
+          ArgumentString = ValueBuffer;\r
+        }\r
+        break;\r
+\r
+      case 't':\r
+        TmpTime = VA_ARG (Marker, TIME *); \r
+        if (TmpTime == NULL) {\r
+          ArgumentString = "<null time>";\r
+        } else {\r
+          BasePrintLibSPrint (\r
+            ValueBuffer,\r
+            MAXIMUM_VALUE_CHARACTERS,\r
+            0,\r
+            "%02d/%02d/%04d  %02d:%02d",\r
+            TmpTime->Month,\r
+            TmpTime->Day,\r
+            TmpTime->Year,\r
+            TmpTime->Hour,\r
+            TmpTime->Minute\r
+            );\r
+          ArgumentString = ValueBuffer;\r
+        }\r
+        break;\r
+\r
+      case 'r':\r
+        Status = VA_ARG (Marker, RETURN_STATUS);\r
+        ArgumentString = ValueBuffer;\r
+        if (RETURN_ERROR (Status)) {\r
+          //\r
+          // Clear error bit\r
+          //\r
+          Index = Status & ~MAX_BIT;\r
+          if (Index > 0 && Index <= ERROR_STATUS_NUMBER) {\r
+            ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER];\r
+          }\r
+        } else {\r
+          Index = Status;\r
+          if (Index <= WARNING_STATUS_NUMBER) {\r
+            ArgumentString = StatusString [Index];\r
+          }\r
+        }\r
+        if (ArgumentString == ValueBuffer) {\r
+          BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);\r
+        }\r
+        break;\r
+\r
+      case '\n':\r
+        ArgumentString = "\n\r";\r
+        break;\r
+\r
+      case '%':\r
+      default:\r
+        //\r
+        // if the type is '%' or unknown, then print it to the screen\r
+        //\r
+        ArgumentString = (CHAR8 *)&FormatCharacter;\r
+        Flags |= ARGUMENT_UNICODE;\r
+        break;\r
+      }\r
+      break;\r
\r
+    case '\n':\r
+      ArgumentString = "\n\r";\r
+      break;\r
+\r
+    default:\r
+      ArgumentString = (CHAR8 *)&FormatCharacter;\r
+      Flags |= ARGUMENT_UNICODE;\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Retrieve the ArgumentString attriubutes\r
+    //\r
+    if ((Flags & ARGUMENT_UNICODE) != 0) {\r
+      ArgumentMask = 0xffff;\r
+      BytesPerArgumentCharacter = 2;\r
+    } else {\r
+      ArgumentMask = 0xff;\r
+      BytesPerArgumentCharacter = 1;\r
+    }\r
+    if ((Flags & ARGUMENT_REVERSED) != 0) {\r
+      BytesPerArgumentCharacter = -BytesPerArgumentCharacter;\r
+    } else {\r
+      //\r
+      // Compute the number of characters in ArgumentString and store it in Count\r
+      // ArgumentString is either null-terminated, or it contains Precision characters\r
+      //\r
+      for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {\r
+        ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;\r
+        if (ArgumentCharacter == 0) {\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    if (Precision < Count) {\r
+      Precision = Count;\r
+    }\r
+\r
+    //\r
+    // Pad before the string\r
+    //\r
+    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
+    }\r
+\r
+    if (ZeroPad) {\r
+      if (Prefix != 0) {\r
+        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
+      }\r
+      Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);\r
+    } else {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);\r
+      if (Prefix != 0) {\r
+        Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);\r
+      }\r
+    }\r
+\r
+    //\r
+    // Output the Prefix character if it is present\r
+    //\r
+    Index = 0;\r
+    if (Prefix != 0) {\r
+      Index++;\r
+    }\r
+\r
+    //\r
+    // Copy the string into the output buffer performing the required type conversions\r
+    //\r
+    while (Index < Count) {\r
+      ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r
+\r
+      Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r
+      ArgumentString    += BytesPerArgumentCharacter;\r
+      Index++;\r
+      if (Comma) {\r
+        Digits++;\r
+        if (Digits == 3) {\r
+          Digits = 0;\r
+          Index++;\r
+          if (Index < Count) {\r
+            Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // Pad after the string\r
+    //\r
+    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
+    }\r
+\r
+    //\r
+    // Get the next character from the format string\r
+    //\r
+    Format += BytesPerFormatCharacter;\r
+\r
+    //\r
+    // Get the next character from the format string\r
+    //\r
+    FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+  }\r
+\r
+  //\r
+  // Null terminate the Unicode or ASCII string\r
+  //\r
+  BasePrintLibFillBuffer (Buffer, EndBuffer + BytesPerOutputCharacter, 1, 0, BytesPerOutputCharacter);\r
+  //\r
+  // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength\r
+  // Unicode characters if PcdMaximumUnicodeStringLength is not zero. \r
+  //\r
+  ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0));\r
+  //\r
+  // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength\r
+  // ASCII characters if PcdMaximumAsciiStringLength is not zero. \r
+  //\r
+  ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));\r
+\r
+  return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r
+}\r
+\r
+/**\r
+  Worker function that produces a Null-terminated string in an output buffer \r
+  based on a Null-terminated format string and variable argument list.\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine.\r
+\r
+  @param  Buffer        Character buffer to print the results of the parsing\r
+                        of Format into.\r
+  @param  BufferSize    Maximum number of characters to put into buffer.\r
+                        Zero means no limit.\r
+  @param  Flags         Intial flags value.\r
+                        Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
+  @param  FormatString  Null-terminated format string.\r
+\r
+  @return Number of characters printed not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST  Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on \r
+  a Null-terminated Unicode format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.  \r
+  The Unicode string is produced by parsing the format string specified by FormatString.  \r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.  \r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  ASSERT_UNICODE_BUFFER(StartOfBuffer);\r
+  ASSERT_UNICODE_BUFFER(FormatString);\r
+  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  Unicode format string and variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  IN  VA_LIST      Marker\r
+  )\r
+{\r
+  ASSERT_UNICODE_BUFFER(StartOfBuffer);\r
+  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of Unicode characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of Unicode characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated Unicode string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated Unicode \r
+  string specified by Buffer containing at most Width characters. No padding of spaces \r
+  is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
+  If the conversion contains more than Width characters, then only the first\r
+  Width characters are returned, and the total number of characters \r
+  required to perform the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If HEX_RADIX is set in Flags, then the output buffer will be \r
+  formatted in hexadecimal format.\r
+  If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  Unicode string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of Unicode characters to place in Buffer, not including\r
+                  the Null-terminator.\r
+  \r
+  @return The number of Unicode characters in Buffer not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeValueToString (\r
+  IN OUT CHAR16  *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width\r
+  )\r
+{\r
+  ASSERT_UNICODE_BUFFER(Buffer);\r
+  return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  ASSERT_UNICODE_BUFFER (FormatString);\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);\r
+}\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The number of ASCII characters in the produced output buffer is returned not including\r
+  the Null-terminator.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
+  If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
+  ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
+  contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  @param  StartOfBuffer   A pointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return The number of ASCII characters in the produced output buffer not including the\r
+          Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated ASCII string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated ASCII string \r
+  specified by Buffer containing at most Width characters. No padding of spaces \r
+  is ever performed.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
+  If the conversion contains more than Width characters, then only the first Width\r
+  characters are returned, and the total number of characters required to perform\r
+  the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If HEX_RADIX is set in Flags, then the output buffer will be \r
+  formatted in hexadecimal format.\r
+  If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  ASCII string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width   The maximum number of ASCII characters to place in Buffer, not including\r
+                  the Null-terminator.\r
+  \r
+  @return The number of ASCII characters in Buffer not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN UINTN      Flags,\r
+  IN INT64      Value,\r
+  IN UINTN      Width\r
+  )\r
+{\r
+  return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c
new file mode 100644 (file)
index 0000000..2319469
--- /dev/null
@@ -0,0 +1,215 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PrintLibInternal.c\r
+  \r
+Abstract: \r
+\r
+  Print Library worker functions.\r
+\r
+--*/\r
+\r
+#include "PrintLibInternal.h"\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};\r
+\r
+\r
+/**\r
+  Internal function that places the character into the Buffer.\r
+\r
+  Internal function that places ASCII or Unicode character into the Buffer.\r
+\r
+  @param  Buffer      Buffer to place the Unicode or ASCII string.\r
+  @param  EndBuffer   The end of the input Buffer. No characters will be\r
+                      placed after that. \r
+  @param  Length      Count of character to be placed into Buffer.\r
+  @param  Character   Character to be placed into Buffer.\r
+  @param  Increment   Character increment in Buffer.\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+CHAR8 *\r
+BasePrintLibFillBuffer (\r
+  CHAR8   *Buffer,\r
+  CHAR8   *EndBuffer,\r
+  INTN    Length,\r
+  UINTN   Character,\r
+  INTN    Increment\r
+  )\r
+{\r
+  INTN  Index;\r
+\r
+  for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {\r
+    *Buffer       =  (CHAR8) Character;\r
+    *(Buffer + 1) =  (CHAR8) (Character >> 8);\r
+    Buffer        += Increment;\r
+  }\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Internal function that convert a decimal number to a string in Buffer.\r
+\r
+  Print worker function that convert a decimal number to a string in Buffer.\r
+\r
+  @param  Buffer    Location to place the Unicode or ASCII string of Value.\r
+  @param  Value     Value to convert to a Decimal or Hexidecimal string in Buffer.\r
+  @param  Radix     Radix of the value\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BasePrintLibValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN INT64      Value,\r
+  IN UINTN      Radix\r
+  )\r
+{\r
+  UINTN   Digits;\r
+  UINT32  Remainder;\r
+\r
+  //\r
+  // Loop to convert one digit at a time in reverse order\r
+  //\r
+  *(Buffer++) = 0;\r
+  Digits = 0;\r
+  do {\r
+    Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);\r
+    *(Buffer++) = mHexStr[Remainder];\r
+    Digits++;\r
+  } while (Value != 0);\r
+  return Digits;\r
+}\r
+\r
+/**\r
+  Internal function that converts a decimal value to a Null-terminated string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated  \r
+  string specified by Buffer containing at most Width characters.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The number of characters in Buffer is returned not including the Null-terminator.\r
+  If the conversion contains more than Width characters, then only the first\r
+  Width characters are returned, and the total number of characters \r
+  required to perform the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If HEX_RADIX is set in Flags, then the output buffer will be formatted in hexadecimal format.\r
+  If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+  If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer    Pointer to the output buffer for the produced Null-terminated\r
+                    string.\r
+  @param  Flags     The bitmask of flags that specify left justification, zero pad,\r
+                    and commas.\r
+  @param  Value     The 64-bit signed value to convert to a string.\r
+  @param  Width     The maximum number of characters to place in Buffer, not including\r
+                    the Null-terminator.\r
+  @param  Increment Character increment in Buffer.\r
+  \r
+  @return The number of characters in Buffer not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibConvertValueToString (\r
+  IN OUT CHAR8   *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width,\r
+  IN UINTN       Increment\r
+  )\r
+{\r
+  CHAR8  *OriginalBuffer;\r
+  CHAR8  *EndBuffer;\r
+  CHAR8  ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
+  UINTN  Count;\r
+  UINTN  Digits;\r
+  UINTN  Index;\r
+  UINTN  Radix;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (Width < MAXIMUM_VALUE_CHARACTERS);\r
+  //\r
+  // Make sure Flags can only contain supported bits.\r
+  //\r
+  ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO | RADIX_HEX)) == 0);\r
+\r
+  //\r
+  // If both COMMA_TYPE and HEX_RADIX are set, then ASSERT ()\r
+  //\r
+  ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE);\r
+\r
+  OriginalBuffer = Buffer;\r
+\r
+  if (Width == 0 || (Flags & COMMA_TYPE) != 0) {\r
+    Flags &= (~PREFIX_ZERO);\r
+  }\r
+\r
+  if (Width == 0) {\r
+    Width = MAXIMUM_VALUE_CHARACTERS - 1;\r
+  }\r
+  //\r
+  // Set the tag for the end of the input Buffer.\r
+  //\r
+  EndBuffer = Buffer + Width * Increment;\r
+\r
+  if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) {\r
+    Value = -Value;\r
+    Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment);\r
+    Width--;\r
+  }\r
+\r
+  Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16;\r
+  Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);\r
+\r
+  if ((Flags & PREFIX_ZERO) != 0) {\r
+    Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment);\r
+  }\r
+\r
+  Digits = Count % 3;\r
+  if (Digits != 0) {\r
+    Digits = 3 - Digits;\r
+  }\r
+  for (Index = 0; Index < Count; Index++) {\r
+    Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ValueBuffer[Count - Index], Increment);\r
+    if ((Flags & COMMA_TYPE) != 0) {\r
+      Digits++;\r
+      if (Digits == 3) {\r
+        Digits = 0;\r
+        if ((Index + 1) < Count) {\r
+          Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', Increment);\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment);\r
+\r
+  return ((Buffer - OriginalBuffer) / Increment);\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h
new file mode 100644 (file)
index 0000000..8442416
--- /dev/null
@@ -0,0 +1,209 @@
+/*++\r
+  \r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PrintLibInternal.h\r
+  \r
+Abstract: \r
+\r
+  Print Library.\r
+\r
+--*/\r
+\r
+#ifndef __PRINT_LIB_INTERNAL_H__\r
+#define __PRINT_LIB_INTERNAL_H__\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+//\r
+// Print primitives\r
+//\r
+//#define LEFT_JUSTIFY      0x01\r
+#define PREFIX_SIGN       0x02\r
+#define PREFIX_BLANK      0x04\r
+//#define COMMA_TYPE        0x08\r
+#define LONG_TYPE         0x10\r
+//#define PREFIX_ZERO       0x20\r
+#define OUTPUT_UNICODE    0x40\r
+//#define RADIX_HEX         0x80\r
+#define FORMAT_UNICODE    0x100\r
+#define PAD_TO_WIDTH      0x200\r
+#define ARGUMENT_UNICODE  0x400\r
+#define PRECISION         0x800\r
+#define ARGUMENT_REVERSED 0x1000\r
+\r
+//\r
+// Record date and time information\r
+//\r
+typedef struct {\r
+  UINT16  Year;\r
+  UINT8   Month;\r
+  UINT8   Day;\r
+  UINT8   Hour;\r
+  UINT8   Minute;\r
+  UINT8   Second;\r
+  UINT8   Pad1;\r
+  UINT32  Nanosecond;\r
+  INT16   TimeZone;\r
+  UINT8   Daylight;\r
+  UINT8   Pad2;\r
+} TIME;\r
+\r
+/**\r
+  Worker function that produces a Null-terminated string in an output buffer \r
+  based on a Null-terminated format string and a VA_LIST argument list.\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine.\r
+\r
+  @param  Buffer      Character buffer to print the results of the parsing\r
+                      of Format into.\r
+  @param  BufferSize  Maximum number of characters to put into buffer.\r
+  @param  Flags       Intial flags value.\r
+                      Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.\r
+  @param  Format      Null-terminated format string.\r
+  @param  Marker      Vararg list consumed by processing Format.\r
+\r
+  @return Number of characters printed not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibVSPrint (\r
+  OUT CHAR8        *Buffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *Format,\r
+  IN  VA_LIST      Marker\r
+  );\r
+\r
+/**\r
+  Worker function that produces a Null-terminated string in an output buffer \r
+  based on a Null-terminated format string and variable argument list.\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+  @param  Buffer        Character buffer to print the results of the parsing\r
+                        of Format into.\r
+  @param  BufferSize    Maximum number of characters to put into buffer.\r
+                        Zero means no limit.\r
+  @param  Flags         Intial flags value.\r
+                        Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
+  @param  FormatString  Null-terminated format string.\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibSPrint (\r
+  OUT CHAR8        *Buffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Internal function that places the character into the Buffer.\r
+\r
+  Internal function that places ASCII or Unicode character into the Buffer.\r
+\r
+  @param  Buffer      Buffer to place the Unicode or ASCII string.\r
+  @param  EndBuffer   The end of the input Buffer. No characters will be\r
+                      placed after that. \r
+  @param  Length      Count of character to be placed into Buffer.\r
+  @param  Character   Character to be placed into Buffer.\r
+  @param  Increment   Character increment in Buffer.\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+CHAR8 *\r
+BasePrintLibFillBuffer (\r
+  CHAR8   *Buffer,\r
+  CHAR8   *EndBuffer,\r
+  INTN    Length,\r
+  UINTN   Character,\r
+  INTN    Increment\r
+  );\r
+\r
+/**\r
+  Internal function that convert a decimal number to a string in Buffer.\r
+\r
+  Print worker function that convert a decimal number to a string in Buffer.\r
+\r
+  @param  Buffer    Location to place the Unicode or ASCII string of Value.\r
+  @param  Value     Value to convert to a Decimal or Hexidecimal string in Buffer.\r
+  @param  Radix     Radix of the value\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BasePrintLibValueToString (\r
+  IN OUT CHAR8  *Buffer, \r
+  IN INT64      Value, \r
+  IN UINTN      Radix\r
+  );\r
+\r
+/**\r
+  Internal function that converts a decimal value to a Null-terminated string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated  \r
+  string specified by Buffer containing at most Width characters.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The total number of characters placed in Buffer is returned.\r
+  If the conversion contains more than Width characters, then only the first\r
+  Width characters are returned, and the total number of characters \r
+  required to perform the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If Value is < 0, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer    Pointer to the output buffer for the produced Null-terminated\r
+                    string.\r
+  @param  Flags     The bitmask of flags that specify left justification, zero pad,\r
+                    and commas.\r
+  @param  Value     The 64-bit signed value to convert to a string.\r
+  @param  Width     The maximum number of characters to place in Buffer, not including\r
+                    the Null-terminator.\r
+  @param  Increment Character increment in Buffer.\r
+  \r
+  @return Total number of characters required to perform the conversion.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibConvertValueToString (\r
+  IN OUT CHAR8   *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width,\r
+  IN UINTN       Increment\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf
new file mode 100644 (file)
index 0000000..d84842b
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseTimerLibLocalApic.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseTimerLibLocalApic.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseTimerLibLocalApic\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ia32]\r
+  x86TimerLib.c\r
+\r
+[sources.x64]\r
+  x86TimerLib.c\r
+\r
+[sources.ipf]\r
+  Ipf/IpfTimerLib.c\r
+\r
+[sources.ebc]\r
+  Ebc/EbcTimerLib.c\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  EdkIIGlueBaseIoLibIntrinsic  \r
+\r
+[libraries.x64]\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+\r
+[libraries.ebc]\r
+  EdkIIGlueDxeIoLibCpuIo\r
+\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
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 (file)
index 0000000..2257f11
--- /dev/null
@@ -0,0 +1,135 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  EbcTimerLib.c\r
+  \r
+Abstract: \r
+\r
+  Timer Library functions built upon local APIC on IA32/x64.\r
+\r
+  @bug Should use PCD to retrieve all the constants including index of\r
+  the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount\r
+  and DivideConfiguration.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return MicroSeconds;\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return NanoSeconds;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+  //\r
+  // EBC architecture does not support local APIC timer.\r
+  //\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
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 (file)
index 0000000..524d973
--- /dev/null
@@ -0,0 +1,178 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IpfTimerLib.c\r
+  \r
+Abstract: \r
+\r
+  Timer Library functions built upon local APIC on IA32/x64.\r
+\r
+  @bug Should use PCD to retrieve all the constants including index of\r
+  the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount\r
+  and DivideConfiguration.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+\r
+/**\r
+  Performs a delay measured as number of ticks.\r
+\r
+  An internal function to perform a delay measured as number of ticks. It's\r
+  invoked by MicroSecondDelay() and NanoSecondDelay().\r
+\r
+  @param  Delay Number of ticks to delay.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+InternalIpfDelay (\r
+  IN      INT64                     Delay\r
+  )\r
+{\r
+  INT64                             Ticks;\r
+\r
+  //\r
+  // The target timer count is calculated here\r
+  //\r
+  Ticks = IpfReadItc () + Delay;\r
+\r
+  //\r
+  // Wait until time out\r
+  // Delay > 2^63 could not be handled by this function\r
+  // Timer wrap-arounds are handled correctly by this function\r
+  //\r
+  while (Ticks - IpfReadItc () >= 0);\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  InternalIpfDelay (\r
+    GetPerformanceCounterProperties (NULL, NULL) *\r
+    MicroSeconds /\r
+    1000000\r
+    );\r
+  return MicroSeconds;\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  InternalIpfDelay (\r
+    GetPerformanceCounterProperties (NULL, NULL) *\r
+    NanoSeconds /\r
+    1000000000\r
+    );\r
+  return NanoSeconds;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  return IpfReadItc ();\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+  PAL_PROC_RETURN                   PalRet;\r
+  UINT64                            BaseFrequence;\r
+\r
+  PalRet = PalCallStatic (NULL, 13, 0, 0, 0);\r
+  ASSERT (PalRet.Status == 0);\r
+  BaseFrequence = PalRet.r9;\r
+\r
+  PalRet = PalCallStatic (NULL, 14, 0, 0, 0);\r
+  ASSERT (PalRet.Status == 0);\r
+\r
+  if (StartValue != NULL) {\r
+    *StartValue = 0;\r
+  }\r
+\r
+  if (EndValue != NULL) {\r
+    *EndValue = (UINT64)(-1);\r
+  }\r
+\r
+  return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c
new file mode 100644 (file)
index 0000000..be4d8c1
--- /dev/null
@@ -0,0 +1,258 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  x86TimerLib.c\r
+  \r
+Abstract: \r
+\r
+  Timer Library functions built upon local APIC on IA32/x64.\r
+\r
+  @bug Should use PCD to retrieve all the constants including index of\r
+  the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount\r
+  and DivideConfiguration.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+//\r
+// The following array is used in calculating the frequency of local APIC\r
+// timer. Refer to IA-32 developers' manual for more details.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED\r
+CONST UINT8                           mTimerLibLocalApicDivisor[] = {\r
+  0x02, 0x04, 0x08, 0x10,\r
+  0x02, 0x04, 0x08, 0x10,\r
+  0x20, 0x40, 0x80, 0x01,\r
+  0x20, 0x40, 0x80, 0x01\r
+};\r
+\r
+/**\r
+  Internal function to retrieve the base address of local APIC.\r
+\r
+  Internal function to retrieve the base address of local APIC.\r
+\r
+  @return The base address of local APIC\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+InternalX86GetApicBase (\r
+  VOID\r
+  )\r
+{\r
+  return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12;\r
+}\r
+\r
+/**\r
+  Internal function to return the frequency of the local APIC timer.\r
+\r
+  Internal function to return the frequency of the local APIC timer.\r
+\r
+  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
+\r
+  @return The frequency of the timer in Hz.\r
+\r
+**/\r
+STATIC\r
+UINT32\r
+InternalX86GetTimerFrequency (\r
+  IN      UINTN                     ApicBase\r
+  )\r
+{\r
+  return\r
+    PcdGet32(PcdFSBClock) /\r
+    mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)];\r
+}\r
+\r
+/**\r
+  Internal function to read the current tick counter of local APIC.\r
+\r
+  Internal function to read the current tick counter of local APIC.\r
+\r
+  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
+\r
+  @return The tick counter read.\r
+\r
+**/\r
+STATIC\r
+INT32\r
+InternalX86GetTimerTick (\r
+  IN      UINTN                     ApicBase\r
+  )\r
+{\r
+  return MmioRead32 (ApicBase + 0x390);\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of ticks.\r
+\r
+  Stalls the CPU for at least the given number of ticks. It's invoked by\r
+  MicroSecondDelay() and NanoSecondDelay().\r
+\r
+  @param  ApicBase  The base address of memory mapped registers of local APIC.\r
+  @param  Delay     A period of time to delay in ticks.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+InternalX86Delay (\r
+  IN      UINTN                     ApicBase,\r
+  IN      UINT32                    Delay\r
+  )\r
+{\r
+  INT32                             Ticks;\r
+\r
+  //\r
+  // The target timer count is calculated here\r
+  //\r
+  Ticks = InternalX86GetTimerTick (ApicBase) - Delay;\r
+\r
+  //\r
+  // Wait until time out\r
+  // Delay > 2^31 could not be handled by this function\r
+  // Timer wrap-arounds are handled correctly by this function\r
+  //\r
+  while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  UINTN                             ApicBase;\r
+\r
+  ApicBase = InternalX86GetApicBase ();\r
+  InternalX86Delay (\r
+    ApicBase,\r
+    (UINT32)DivU64x32 (\r
+              MultU64x64 (\r
+                InternalX86GetTimerFrequency (ApicBase),\r
+                MicroSeconds\r
+                ),\r
+              1000000u\r
+              )\r
+    );\r
+  return MicroSeconds;\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  UINTN                             ApicBase;\r
+\r
+  ApicBase = InternalX86GetApicBase ();\r
+  InternalX86Delay (\r
+    ApicBase,\r
+    (UINT32)DivU64x32 (\r
+              MultU64x64 (\r
+                InternalX86GetTimerFrequency (ApicBase),\r
+                NanoSeconds\r
+                ),\r
+              1000000000u\r
+              )\r
+    );\r
+  return NanoSeconds;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  return (UINT64)(UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ());\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+  UINTN                             ApicBase;\r
+\r
+  ApicBase = InternalX86GetApicBase ();\r
+\r
+  if (StartValue != NULL) {\r
+    *StartValue = MmioRead32 (ApicBase + 0x380);\r
+  }\r
+\r
+  if (EndValue != NULL) {\r
+    *EndValue = 0;\r
+  }\r
+\r
+  return (UINT64) InternalX86GetTimerFrequency (ApicBase);;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
new file mode 100644 (file)
index 0000000..caa8917
--- /dev/null
@@ -0,0 +1,801 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  BaseUefiDecompressLib.c\r
+  \r
+Abstract: \r
+\r
+  UEFI Decompress Library.\r
+\r
+--*/\r
+\r
+#include "BaseUefiDecompressLibInternals.h"\r
+\r
+/**\r
+  Read NumOfBit of bits from source into mBitBuf\r
+\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+  @param  Sd        The global scratch data\r
+  @param  NumOfBits The number of bits to shift and read.\r
+\r
+**/\r
+VOID\r
+GlueFillBuf (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+{\r
+  //\r
+  // Left shift NumOfBits of bits in advance\r
+  //\r
+  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
+\r
+  //\r
+  // Copy data needed in bytes into mSbuBitBuf\r
+  //\r
+  while (NumOfBits > Sd->mBitCount) {\r
+\r
+    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
+\r
+    if (Sd->mCompSize > 0) {\r
+      //\r
+      // Get 1 byte into SubBitBuf\r
+      //\r
+      Sd->mCompSize--;\r
+      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
+      Sd->mBitCount   = 8;\r
+\r
+    } else {\r
+      //\r
+      // No more bits from the source, just pad zero bit.\r
+      //\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mBitCount   = 8;\r
+\r
+    }\r
+  }\r
+\r
+  //\r
+  // Caculate additional bit count read to update mBitCount\r
+  //\r
+  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
+  \r
+  //\r
+  // Copy NumOfBits of bits from mSubBitBuf into mBitBuf\r
+  //\r
+  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
+}\r
+\r
+/**\r
+  Get NumOfBits of bits out from mBitBuf\r
+\r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  popped out.\r
+\r
+  @param  Sd        The global scratch data.\r
+  @param  NumOfBits The number of bits to pop and read.\r
+\r
+  @return The bits that are popped out.\r
+\r
+**/\r
+UINT32\r
+GlueGetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+{\r
+  UINT32  OutBits;\r
+\r
+  //\r
+  // Pop NumOfBits of Bits from Left\r
+  //  \r
+  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
+\r
+  //\r
+  // Fill up mBitBuf from source\r
+  //\r
+  FillBuf (Sd, NumOfBits);\r
+\r
+  return OutBits;\r
+}\r
+\r
+/**\r
+  Creates Huffman Code mapping table according to code length array.\r
+\r
+  Creates Huffman Code mapping table for Extra Set, Char&Len Set \r
+  and Position Set according to code length array.\r
+\r
+  @param  Sd        The global scratch data\r
+  @param  NumOfChar Number of symbols in the symbol set\r
+  @param  BitLen    Code length array\r
+  @param  TableBits The width of the mapping table\r
+  @param  Table     The table\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE The table is corrupted.\r
+\r
+**/\r
+UINT16\r
+GlueMakeTable (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfChar,\r
+  IN  UINT8         *BitLen,\r
+  IN  UINT16        TableBits,\r
+  OUT UINT16        *Table\r
+  )\r
+{\r
+  UINT16  Count[17];\r
+  UINT16  Weight[17];\r
+  UINT16  Start[18];\r
+  UINT16  *Pointer;\r
+  UINT16  Index3;\r
+  volatile UINT16  Index;\r
+  UINT16  Len;\r
+  UINT16  Char;\r
+  UINT16  JuBits;\r
+  UINT16  Avail;\r
+  UINT16  NextCode;\r
+  UINT16  Mask;\r
+  UINT16  WordOfStart;\r
+  UINT16  WordOfCount;\r
+\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Count[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NumOfChar; Index++) {\r
+    Count[BitLen[Index]]++;\r
+  }\r
+\r
+  Start[1] = 0;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    WordOfStart = Start[Index];\r
+    WordOfCount = Count[Index];\r
+    Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));\r
+  }\r
+\r
+  if (Start[17] != 0) {\r
+    /*(1U << 16)*/\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
+  JuBits = (UINT16) (16 - TableBits);\r
+\r
+  for (Index = 1; Index <= TableBits; Index++) {\r
+    Start[Index] >>= JuBits;\r
+    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
+  }\r
+\r
+  while (Index <= 16) {\r
+    Weight[Index] = (UINT16) (1U << (16 - Index));\r
+    Index++;    \r
+  }\r
+\r
+  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
+\r
+  if (Index != 0) {\r
+    Index3 = (UINT16) (1U << TableBits);\r
+    while (Index != Index3) {\r
+      Table[Index++] = 0;\r
+    }\r
+  }\r
+\r
+  Avail = NumOfChar;\r
+  Mask  = (UINT16) (1U << (15 - TableBits));\r
+\r
+  for (Char = 0; Char < NumOfChar; Char++) {\r
+\r
+    Len = BitLen[Char];\r
+    if (Len == 0) {\r
+      continue;\r
+    }\r
+\r
+    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
+\r
+    if (Len <= TableBits) {\r
+\r
+      for (Index = Start[Len]; Index < NextCode; Index++) {\r
+        Table[Index] = Char;\r
+      }\r
+\r
+    } else {\r
+\r
+      Index3  = Start[Len];\r
+      Pointer = &Table[Index3 >> JuBits];\r
+      Index   = (UINT16) (Len - TableBits);\r
+\r
+      while (Index != 0) {\r
+        if (*Pointer == 0) {\r
+          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
+          *Pointer = Avail++;\r
+        }\r
+\r
+        if (Index3 & Mask) {\r
+          Pointer = &Sd->mRight[*Pointer];\r
+        } else {\r
+          Pointer = &Sd->mLeft[*Pointer];\r
+        }\r
+\r
+        Index3 <<= 1;\r
+        Index--;\r
+      }\r
+\r
+      *Pointer = Char;\r
+\r
+    }\r
+\r
+    Start[Len] = NextCode;\r
+  }\r
+  //\r
+  // Succeeds\r
+  //\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Decodes a position value.\r
+\r
+  Get a position value according to Position Huffman Table.\r
+  \r
+  @param  Sd the global scratch data\r
+\r
+  @return The position value decoded.\r
+\r
+**/\r
+UINT32\r
+GlueDecodeP (\r
+  IN  SCRATCH_DATA  *Sd\r
+  )\r
+{\r
+  UINT16  Val;\r
+  UINT32  Mask;\r
+  UINT32  Pos;\r
+\r
+  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+\r
+  if (Val >= MAXNP) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+    do {\r
+\r
+      if (Sd->mBitBuf & Mask) {\r
+        Val = Sd->mRight[Val];\r
+      } else {\r
+        Val = Sd->mLeft[Val];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Val >= MAXNP);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mPTLen[Val]);\r
+\r
+  Pos = Val;\r
+  if (Val > 1) {\r
+    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
+  }\r
+\r
+  return Pos;\r
+}\r
+\r
+/**\r
+  Reads code lengths for the Extra Set or the Position Set.\r
+\r
+  Read in the Extra Set or Pointion Set Length Arrary, then\r
+  generate the Huffman code mapping for them.\r
+\r
+  @param  Sd      The global scratch data.\r
+  @param  nn      Number of symbols.\r
+  @param  nbit    Number of bits needed to represent nn.\r
+  @param  Special The special symbol that needs to be taken care of.\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE Table is corrupted.\r
+\r
+**/\r
+UINT16\r
+GlueReadPTLen (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        nn,\r
+  IN  UINT16        nbit,\r
+  IN  UINT16        Special\r
+  )\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  volatile UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  //\r
+  // Read Extra Set Code Length Array size \r
+  //\r
+  Number = (UINT16) GetBits (Sd, nbit);\r
+\r
+  if (Number == 0) {\r
+    //\r
+    // This represents only Huffman code used\r
+    //\r
+    CharC = (UINT16) GetBits (Sd, nbit);\r
+\r
+    for (Index = 0; Index < 256; Index++) {\r
+      Sd->mPTTable[Index] = CharC;\r
+    }\r
+\r
+    for (Index = 0; Index < nn; Index++) {\r
+      Sd->mPTLen[Index] = 0;\r
+    }\r
+\r
+    return 0;\r
+  }\r
+\r
+  Index = 0;\r
+\r
+  while (Index < Number) {\r
+\r
+    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
+\r
+    //\r
+    // If a code length is less than 7, then it is encoded as a 3-bit\r
+    // value. Or it is encoded as a series of "1"s followed by a \r
+    // terminating "0". The number of "1"s = Code length - 4.\r
+    //\r
+    if (CharC == 7) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
+      while (Mask & Sd->mBitBuf) {\r
+        Mask >>= 1;\r
+        CharC += 1;\r
+      }\r
+    }\r
+    \r
+    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
+\r
+    Sd->mPTLen[Index++] = (UINT8) CharC;\r
\r
+    //\r
+    // For Code&Len Set, \r
+    // After the third length of the code length concatenation,\r
+    // a 2-bit value is used to indicated the number of consecutive \r
+    // zero lengths after the third length.\r
+    //\r
+    if (Index == Special) {\r
+      CharC = (UINT16) GetBits (Sd, 2);\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mPTLen[Index++] = 0;\r
+      }\r
+    }\r
+  }\r
+\r
+  while (Index < nn) {\r
+    Sd->mPTLen[Index++] = 0;\r
+  }\r
+  \r
+  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
+}\r
+\r
+/**\r
+  Reads code lengths for Char&Len Set.\r
+  \r
+  Read in and decode the Char&Len Set Code Length Array, then\r
+  generate the Huffman Code mapping table for the Char&Len Set.\r
+\r
+  @param  Sd the global scratch data\r
+\r
+**/\r
+VOID\r
+GlueReadCLen (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+{\r
+  UINT16           Number;\r
+  UINT16           CharC;\r
+  volatile UINT16  Index;\r
+  UINT32           Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, CBIT);\r
+\r
+  if (Number == 0) {\r
+    //\r
+    // This represents only Huffman code used\r
+    //\r
+    CharC = (UINT16) GetBits (Sd, CBIT);\r
+\r
+    for (Index = 0; Index < NC; Index++) {\r
+      Sd->mCLen[Index] = 0;\r
+    }\r
+\r
+    for (Index = 0; Index < 4096; Index++) {\r
+      Sd->mCTable[Index] = CharC;\r
+    }\r
+\r
+    return ;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+    if (CharC >= NT) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+      do {\r
+\r
+        if (Mask & Sd->mBitBuf) {\r
+          CharC = Sd->mRight[CharC];\r
+        } else {\r
+          CharC = Sd->mLeft[CharC];\r
+        }\r
+\r
+        Mask >>= 1;\r
+\r
+      } while (CharC >= NT);\r
+    }\r
+    //\r
+    // Advance what we have read\r
+    //\r
+    FillBuf (Sd, Sd->mPTLen[CharC]);\r
+\r
+    if (CharC <= 2) {\r
+\r
+      if (CharC == 0) {\r
+        CharC = 1;\r
+      } else if (CharC == 1) {\r
+        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
+      } else if (CharC == 2) {\r
+        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
+      }\r
+\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mCLen[Index++] = 0;\r
+      }\r
+\r
+    } else {\r
+\r
+      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
+\r
+    }\r
+  }\r
+\r
+  while (Index < NC) {\r
+    Sd->mCLen[Index++] = 0;\r
+  }\r
+\r
+  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
+\r
+  return ;\r
+}\r
+\r
+/**\r
+  Decode a character/length value.\r
+  \r
+  Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates\r
+  Huffman code mapping table for Extra Set, Code&Len Set and\r
+  Position Set.\r
+\r
+  @param  Sd The global scratch data.\r
+\r
+  @return The value decoded.\r
+\r
+**/\r
+UINT16\r
+GlueDecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+{\r
+  UINT16  Index2;\r
+  UINT32  Mask;\r
+\r
+  if (Sd->mBlockSize == 0) {\r
+    //\r
+    // Starting a new block\r
+    // Read BlockSize from block header\r
+    // \r
+    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
+\r
+    //\r
+    // Read in the Extra Set Code Length Arrary,\r
+    // Generate the Huffman code mapping table for Extra Set.\r
+    //\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+\r
+    //\r
+    // Read in and decode the Char&Len Set Code Length Arrary,\r
+    // Generate the Huffman code mapping table for Char&Len Set.\r
+    //\r
+    ReadCLen (Sd);\r
+\r
+    //\r
+    // Read in the Position Set Code Length Arrary, \r
+    // Generate the Huffman code mapping table for the Position Set.\r
+    //\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Get one code according to Code&Set Huffman Table\r
+  //\r
+  Sd->mBlockSize--;\r
+  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
+\r
+  if (Index2 >= NC) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
+\r
+    do {\r
+      if (Sd->mBitBuf & Mask) {\r
+        Index2 = Sd->mRight[Index2];\r
+      } else {\r
+        Index2 = Sd->mLeft[Index2];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Index2 >= NC);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mCLen[Index2]);\r
+\r
+  return Index2;\r
+}\r
+\r
+/**\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+  \r
+  @param  Sd The global scratch data\r
+\r
+**/\r
+VOID\r
+GlueDecode (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+{\r
+  UINT16  BytesRemain;\r
+  UINT32  DataIdx;\r
+  UINT16  CharC;\r
+\r
+  BytesRemain = (UINT16) (-1);\r
+\r
+  DataIdx     = 0;\r
+\r
+  for (;;) {\r
+    //\r
+    // Get one code from mBitBuf\r
+    // \r
+    CharC = DecodeC (Sd);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      goto Done;\r
+    }\r
+\r
+    if (CharC < 256) {\r
+      //\r
+      // Process an Original character\r
+      //\r
+      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+        goto Done;\r
+      } else {\r
+        //\r
+        // Write orignal character into mDstBase\r
+        //\r
+        Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
+      }\r
+\r
+    } else {\r
+      //\r
+      // Process a Pointer\r
+      //\r
+      CharC       = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
\r
+      //\r
+      // Get string length\r
+      //\r
+      BytesRemain = CharC;\r
+\r
+      //\r
+      // Locate string position\r
+      //\r
+      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
+\r
+      //\r
+      // Write BytesRemain of bytes into mDstBase\r
+      //\r
+      BytesRemain--;\r
+      while ((INT16) (BytesRemain) >= 0) {\r
+        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
+        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+          goto Done;\r
+        }\r
+\r
+        BytesRemain--;\r
+      }\r
+    }\r
+  }\r
+\r
+Done:\r
+  return ;\r
+}\r
+\r
+/**\r
+  Retrieves the size of the uncompressed buffer and the size of the scratch buffer.\r
+\r
+  Retrieves the size of the uncompressed buffer and the temporary scratch buffer \r
+  required to decompress the buffer specified by Source and SourceSize.\r
+  If the size of the uncompressed buffer or the size of the scratch buffer cannot\r
+  be determined from the compressed data specified by Source and SourceData, \r
+  then RETURN_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
+  buffer is returned in DestinationSize, the size of the scratch buffer is returned\r
+  in ScratchSize, and RETURN_SUCCESS is returned.\r
+  This function does not have scratch buffer available to perform a thorough \r
+  checking of the validity of the source data.  It just retrieves the "Original Size"\r
+  field from the beginning bytes of the source data and output it as DestinationSize.\r
+  And ScratchSize is specific to the decompression implementation.\r
+\r
+  If Source is NULL, then ASSERT().\r
+  If DestinationSize is NULL, then ASSERT().\r
+  If ScratchSize is NULL, then ASSERT().\r
+\r
+  @param  Source          The source buffer containing the compressed data.\r
+  @param  SourceSize      The size, in bytes, of the source buffer.\r
+  @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer\r
+                          that will be generated when the compressed buffer specified\r
+                          by Source and SourceSize is decompressed..\r
+  @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
+                          is required to decompress the compressed buffer specified \r
+                          by Source and SourceSize.\r
+\r
+  @retval  RETURN_SUCCESS The size of destination buffer and the size of scratch \r
+                          buffer are successull retrieved.\r
+  @retval  RETURN_INVALID_PARAMETER The source data is corrupted\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UefiDecompressGetInfo (\r
+  IN  CONST VOID  *Source,\r
+  IN  UINT32      SourceSize,\r
+  OUT UINT32      *DestinationSize,\r
+  OUT UINT32      *ScratchSize\r
+  )\r
+{\r
+  UINT32  CompressedSize;\r
+\r
+  ASSERT (Source != NULL);\r
+  ASSERT (DestinationSize != NULL);\r
+  ASSERT (ScratchSize != NULL);\r
+\r
+  *ScratchSize  = sizeof (SCRATCH_DATA);\r
+\r
+  if (SourceSize < 8) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  CopyMem (&CompressedSize, Source, sizeof (UINT32));\r
+  CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32));\r
+\r
+  if (SourceSize < (CompressedSize + 8)) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Decompresses a compressed source buffer.\r
+\r
+  This function is designed so that the decompression algorithm can be implemented\r
+  without using any memory services.  As a result, this function is not allowed to\r
+  call any memory allocation services in its implementation.  It is the caller's r\r
+  esponsibility to allocate and free the Destination and Scratch buffers.\r
+  If the compressed source data specified by Source is sucessfully decompressed \r
+  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data \r
+  specified by Source is not in a valid compressed data format,\r
+  then RETURN_INVALID_PARAMETER is returned.\r
+\r
+  If Source is NULL, then ASSERT().\r
+  If Destination is NULL, then ASSERT().\r
+  If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().\r
+\r
+  @param  Source      The source buffer containing the compressed data.\r
+  @param  Destination The destination buffer to store the decompressed data\r
+  @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
+                      This is an optional parameter that may be NULL if the \r
+                      required scratch buffer size is 0.\r
+                     \r
+  @retval  RETURN_SUCCESS Decompression is successfull\r
+  @retval  RETURN_INVALID_PARAMETER The source data is corrupted\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UefiDecompress (\r
+  IN CONST VOID  *Source,\r
+  IN OUT VOID    *Destination,\r
+  IN OUT VOID    *Scratch\r
+  )\r
+{\r
+  volatile UINT32  Index;\r
+  UINT32           CompSize;\r
+  UINT32           OrigSize;\r
+  SCRATCH_DATA     *Sd;\r
+  CONST UINT8      *Src;\r
+  UINT8            *Dst;\r
+\r
+  ASSERT (Source != NULL);\r
+  ASSERT (Destination != NULL);\r
+  ASSERT (Scratch != NULL);\r
+\r
+  Src     = Source;\r
+  Dst     = Destination;\r
+\r
+  Sd = (SCRATCH_DATA *) Scratch;\r
+\r
+  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
+  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+\r
+  //\r
+  // If compressed file size is 0, return\r
+  //\r
+  if (OrigSize == 0) {\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
+  Src = Src + 8;\r
+\r
+  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
+    ((UINT8 *) Sd)[Index] = 0;\r
+  }\r
+  //\r
+  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4\r
+  // For Tiano de/compression algorithm(Version 2), mPBit = 5\r
+  //\r
+  Sd->mPBit     = 4;\r
+  Sd->mSrcBase  = (UINT8 *)Src;\r
+  Sd->mDstBase  = Dst;\r
+  //\r
+  // CompSize and OrigSize are caculated in bytes\r
+  //\r
+  Sd->mCompSize = CompSize;\r
+  Sd->mOrigSize = OrigSize;\r
+\r
+  //\r
+  // Fill the first BITBUFSIZ bits\r
+  //\r
+  FillBuf (Sd, BITBUFSIZ);\r
+\r
+  //\r
+  // Decompress it\r
+  //\r
+  Decode (Sd);\r
+\r
+  if (Sd->mBadTableFlag != 0) {\r
+    //\r
+    // Something wrong with the source\r
+    //\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
new file mode 100644 (file)
index 0000000..bc1c6dc
--- /dev/null
@@ -0,0 +1,78 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   BaseUefiDecompressLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for BaseUefiDecompressLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueBaseUefiDecompressLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  BaseUefiDecompressLib.c\r
+  \r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h
new file mode 100644 (file)
index 0000000..09ec44e
--- /dev/null
@@ -0,0 +1,222 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  BaseUefiDecompressLibInternals.h\r
+  \r
+Abstract: \r
+\r
+  Header file for Base Uefi Decompress Library.\r
+  \r
+--*/\r
+\r
+#ifndef __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\r
+#define __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\r
+\r
+#include "EdkIIGlueBase.h"\r
+\r
+//\r
+// Decompression algorithm begins here\r
+//\r
+#define BITBUFSIZ 32\r
+#define MAXMATCH  256\r
+#define THRESHOLD 3\r
+#define CODE_BIT  16\r
+#define BAD_TABLE - 1\r
+\r
+//\r
+// C: Char&Len Set; P: Position Set; T: exTra Set\r
+//\r
+#define NC      (0xff + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT    9\r
+#define MAXPBIT 5\r
+#define TBIT    5\r
+#define MAXNP   ((1U << MAXPBIT) - 1)\r
+#define NT      (CODE_BIT + 3)\r
+#if NT > MAXNP\r
+#define NPT NT\r
+#else\r
+#define NPT MAXNP\r
+#endif\r
+\r
+typedef struct {\r
+  UINT8   *mSrcBase;  ///< Starting address of compressed data\r
+  UINT8   *mDstBase;  ///< Starting address of decompressed data\r
+  UINT32  mOutBuf;\r
+  UINT32  mInBuf;\r
+\r
+  UINT16  mBitCount;\r
+  UINT32  mBitBuf;\r
+  UINT32  mSubBitBuf;\r
+  UINT16  mBlockSize;\r
+  UINT32  mCompSize;\r
+  UINT32  mOrigSize;\r
+\r
+  UINT16  mBadTableFlag;\r
+\r
+  UINT16  mLeft[2 * NC - 1];\r
+  UINT16  mRight[2 * NC - 1];\r
+  UINT8   mCLen[NC];\r
+  UINT8   mPTLen[NPT];\r
+  UINT16  mCTable[4096];\r
+  UINT16  mPTTable[256];\r
+\r
+  ///\r
+  /// The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  /// For EFI 1.1 de/compression algorithm, mPBit = 4\r
+  /// For Tiano de/compression algorithm, mPBit = 5\r
+  ///\r
+  UINT8   mPBit;\r
+} SCRATCH_DATA;\r
+\r
+/**\r
+  Read NumOfBit of bits from source into mBitBuf\r
+\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+  @param  Sd        The global scratch data\r
+  @param  NumOfBits The number of bits to shift and read.\r
+\r
+**/\r
+VOID\r
+GlueFillBuf (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  );\r
+\r
+/**\r
+  Get NumOfBits of bits out from mBitBuf\r
+\r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  popped out.\r
+\r
+  @param  Sd        The global scratch data.\r
+  @param  NumOfBits The number of bits to pop and read.\r
+\r
+  @return The bits that are popped out.\r
+\r
+**/\r
+UINT32\r
+GlueGetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  );\r
+\r
+/**\r
+  Creates Huffman Code mapping table according to code length array.\r
+\r
+  Creates Huffman Code mapping table for Extra Set, Char&Len Set \r
+  and Position Set according to code length array.\r
+\r
+  @param  Sd        The global scratch data\r
+  @param  NumOfChar Number of symbols in the symbol set\r
+  @param  BitLen    Code length array\r
+  @param  TableBits The width of the mapping table\r
+  @param  Table     The table\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE The table is corrupted.\r
+\r
+**/\r
+UINT16\r
+GlueMakeTable (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfChar,\r
+  IN  UINT8         *BitLen,\r
+  IN  UINT16        TableBits,\r
+  OUT UINT16        *Table\r
+  );\r
+\r
+/**\r
+  Decodes a position value.\r
+\r
+  Get a position value according to Position Huffman Table.\r
+  \r
+  @param  Sd the global scratch data\r
+\r
+  @return The position value decoded.\r
+\r
+**/\r
+UINT32\r
+GlueDecodeP (\r
+  IN  SCRATCH_DATA  *Sd\r
+  );\r
+\r
+/**\r
+  Reads code lengths for the Extra Set or the Position Set.\r
+\r
+  Read in the Extra Set or Pointion Set Length Arrary, then\r
+  generate the Huffman code mapping for them.\r
+\r
+  @param  Sd      The global scratch data.\r
+  @param  nn      Number of symbols.\r
+  @param  nbit    Number of bits needed to represent nn.\r
+  @param  Special The special symbol that needs to be taken care of.\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE Table is corrupted.\r
+\r
+**/\r
+UINT16\r
+GlueReadPTLen (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        nn,\r
+  IN  UINT16        nbit,\r
+  IN  UINT16        Special\r
+  );\r
+\r
+/**\r
+  Reads code lengths for Char&Len Set.\r
+  \r
+  Read in and decode the Char&Len Set Code Length Array, then\r
+  generate the Huffman Code mapping table for the Char&Len Set.\r
+\r
+  @param  Sd the global scratch data\r
+\r
+**/\r
+VOID\r
+GlueReadCLen (\r
+  SCRATCH_DATA  *Sd\r
+  );\r
+\r
+/**\r
+  Decode a character/length value.\r
+  \r
+  Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates\r
+  Huffman code mapping table for Extra Set, Code&Len Set and\r
+  Position Set.\r
+\r
+  @param  Sd The global scratch data.\r
+\r
+  @return The value decoded.\r
+\r
+**/\r
+UINT16\r
+GlueDecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  );\r
+\r
+/**\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+  \r
+  @param  Sd The global scratch data\r
+\r
+**/\r
+VOID\r
+GlueDecode (\r
+  SCRATCH_DATA  *Sd\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf
new file mode 100644 (file)
index 0000000..64cdfec
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeHobLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeHobLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeHobLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  HobLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiLib\r
+#\r
+# R8.x Library, GUID needed: gEfiHobListGuid\r
+#  \r
+  EdkFrameworkGuidLib\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c
new file mode 100644 (file)
index 0000000..9dc50a2
--- /dev/null
@@ -0,0 +1,501 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  HobLib.c\r
+  \r
+Abstract: \r
+\r
+  HOB Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+\r
+STATIC VOID  *mHobList = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer to HOB list.\r
+  \r
+  The constructor function gets the start address of HOB list from system configuration table.\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HobLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (mHobList != NULL);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Returns the pointer to the HOB list.\r
+\r
+  This function returns the pointer to first HOB in the list.\r
+\r
+  @return The pointer to the HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetHobList (\r
+  VOID\r
+  )\r
+{\r
+  return mHobList;\r
+}\r
+\r
+/**\r
+  Returns the next instance of a HOB type from the starting HOB.\r
+\r
+  This function searches the first instance of a HOB type from the starting HOB pointer. \r
+  If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Type          The HOB type to return.\r
+  @param  HobStart      The starting HOB pointer to search from.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetNextHob (\r
+  IN UINT16                 Type,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  ASSERT (HobStart != NULL);\r
+   \r
+  Hob.Raw = (UINT8 *) HobStart;\r
+  //\r
+  // Parse the HOB list until end of list or matching type is found.\r
+  //\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+    if (Hob.Header->HobType == Type) {\r
+      return Hob.Raw;\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Returns the first instance of a HOB type among the whole HOB list.\r
+\r
+  This function searches the first instance of a HOB type among the whole HOB list. \r
+  If there does not exist such HOB type in the HOB list, it will return NULL. \r
+\r
+  @param  Type          The HOB type to return.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFirstHob (\r
+  IN UINT16                 Type\r
+  )\r
+{\r
+  VOID      *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  return GetNextHob (Type, HobList);\r
+}\r
+\r
+/**\r
+  This function searches the first instance of a HOB from the starting HOB pointer. \r
+  Such HOB should satisfy two conditions: \r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If Guid is NULL, then ASSERT().\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+  @param  HobStart      A pointer to a Guid.\r
+\r
+  @return The next instance of the matched GUID HOB from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetNextGuidHob (\r
+  IN CONST EFI_GUID         *Guid,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  GuidHob.Raw = (UINT8 *) HobStart;\r
+  while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
+    if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
+      break;\r
+    }\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+  return GuidHob.Raw;\r
+}\r
+\r
+/**\r
+  This function searches the first instance of a HOB among the whole HOB list. \r
+  Such HOB should satisfy two conditions:\r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+\r
+  @return The first instance of the matched GUID HOB among the whole HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetFirstGuidHob (\r
+  IN CONST EFI_GUID         *Guid\r
+  )\r
+{\r
+  VOID      *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  return GetNextGuidHob (Guid, HobList);\r
+}\r
+\r
+/**\r
+  Get the Boot Mode from the HOB list.\r
+\r
+  This function returns the system boot mode information from the \r
+  PHIT HOB in HOB list.\r
+\r
+  @param  VOID\r
+\r
+  @return The Boot Mode.\r
+\r
+**/\r
+EFI_BOOT_MODE\r
+EFIAPI\r
+GetBootModeHob (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_HANDOFF_INFO_TABLE    *HandOffHob;\r
+\r
+  HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();\r
+\r
+  return  HandOffHob->BootMode;\r
+}\r
+\r
+/**\r
+  Builds a HOB for a loaded PE32 module.\r
+\r
+  This function builds a HOB for a loaded PE32 module.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If ModuleName is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ModuleName              The GUID File Name of the module.\r
+  @param  MemoryAllocationModule  The 64 bit physical address of the module.\r
+  @param  ModuleLength            The length of the module in bytes.\r
+  @param  EntryPoint              The 64 bit physical address of the module's entry point.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildModuleHob (\r
+  IN CONST EFI_GUID         *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a HOB that describes a chunk of system memory.\r
+\r
+  This function builds a HOB that describes a chunk of system memory.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ResourceType        The type of resource described by this HOB.\r
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.\r
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.\r
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildResourceDescriptorHob (\r
+  IN EFI_RESOURCE_TYPE            ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
+  IN UINT64                       NumberOfBytes\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a GUID HOB with a certain data length.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification \r
+  and returns the start address of GUID HOB data so that caller can fill the customized data. \r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN UINTN                       DataLength\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Copies a data buffer to a newly-built HOB.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification,\r
+  copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If Data is NULL and DataLength > 0, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  Data          The data to be copied into the data field of the GUID HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidDataHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Builds a Firmware Volume HOB.\r
+\r
+  This function builds a Firmware Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Firmware Volume.\r
+  @param  Length        The size of the Firmware Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildFvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a Capsule Volume HOB.\r
+\r
+  This function builds a Capsule Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Capsule Volume.\r
+  @param  Length        The size of the Capsule Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a HOB for the CPU.\r
+\r
+  This function builds a HOB for the CPU.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.\r
+  @param  SizeOfIoSpace       The maximum physical I/O addressability of the processor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCpuHob (\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a HOB for the Stack.\r
+\r
+  This function builds a HOB for the stack.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the Stack.\r
+  @param  Length        The length of the stack in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildStackHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a HOB for the BSP store.\r
+\r
+  This function builds a HOB for BSP store.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the BSP.\r
+  @param  Length        The length of the BSP store in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildBspStoreHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Builds a HOB for the memory allocation.\r
+\r
+  This function builds a HOB for the memory allocation.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the memory.\r
+  @param  Length        The length of the memory allocation in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildMemoryAllocationHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+{\r
+  //\r
+  // PEI HOB is read only for DXE phase\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h
new file mode 100644 (file)
index 0000000..b82557c
--- /dev/null
@@ -0,0 +1,115 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DxeCpuIoLibInternal.h\r
+  \r
+Abstract: \r
+\r
+  Internal header file for DxeIoLibCpuIo\r
+\r
+--*/\r
+\r
+#ifndef __DXE_CPUIO_LIB_INTERNAL_H__\r
+#define __DXE_CPUIO_LIB_INTERNAL_H__\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+/**\r
+  Reads registers in the EFI CPU I/O space.\r
+\r
+  Reads the I/O port specified by Port with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI CPU I/O space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoReadWorker (\r
+  IN      UINTN                     Port,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+  );\r
+\r
+/**\r
+  Writes registers in the EFI CPU I/O space.\r
+\r
+  Writes the I/O port specified by Port with registers width and value specified by Width\r
+  and Data respectively.  Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+  @param  Data          The value to write to the I/O port.\r
+\r
+  @return The paramter of Data.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWriteWorker (\r
+  IN      UINTN                     Port,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+  IN      UINT64                    Data\r
+  );\r
+\r
+/**\r
+  Reads memory-mapped registers in the EFI system memory space.\r
+\r
+  Reads the MMIO registers specified by Address with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioReadWorker (\r
+  IN      UINTN                     Address,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+  );\r
+\r
+/**\r
+  Writes memory-mapped registers in the EFI system memory space.\r
+\r
+  Writes the MMIO registers specified by Address with registers width and value specified by Width\r
+  and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWriteWorker (\r
+  IN      UINTN                     Address,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+  IN      UINT64                    Data\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf
new file mode 100644 (file)
index 0000000..a721a14
--- /dev/null
@@ -0,0 +1,80 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeIoLibCpuIo.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeIoLibCpuIo.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeIoLibCpuIo\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  IoLib.c\r
+  IoHighLevel.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c
new file mode 100644 (file)
index 0000000..3e6b588
--- /dev/null
@@ -0,0 +1,2271 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoHighLevel.c\r
+  \r
+Abstract: \r
+\r
+  High-level Io/Mmio functions.\r
+\r
+--*/\r
+\r
+#include "DxeCpuIoLibInternal.h"\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 8-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in an 8-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldRead8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 8-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 8-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAnd8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit port.\r
+\r
+  Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 8-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoBitFieldAndThenOr8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return IoWrite8 (\r
+           Port,\r
+           BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 16-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 16-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldRead16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 16-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 16-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAnd16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit port.\r
+\r
+  Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 16-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoBitFieldAndThenOr16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return IoWrite16 (\r
+           Port,\r
+           BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (Port, IoRead32 (Port) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return IoWrite32 (Port, IoRead32 (Port) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 32-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 32-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldRead32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 32-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 32-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAnd32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit port.\r
+\r
+  Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 32-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoBitFieldAndThenOr32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return IoWrite32 (\r
+           Port,\r
+           BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  OrData  The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (Port, IoRead64 (Port) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back\r
+  to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return IoWrite64 (Port, IoRead64 (Port) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, performs a bitwise OR\r
+  between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 64-bit I/O port specified by Port. The value\r
+  written to the I/O port is returned. This function must guarantee that all\r
+  I/O read and write operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to write.\r
+  @param  AndData The value to AND with the read value from the I/O port.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of an I/O register.\r
+\r
+  Reads the bit field in a 64-bit I/O register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldRead64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to an I/O register.\r
+\r
+  Writes Value to the bit field of the I/O register. The bit field is specified\r
+  by the StartBit and the EndBit. All other bits in the destination I/O\r
+  register are preserved. The value written to the I/O port is returned. Extra\r
+  left bits in Value are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR\r
+  between the read result and the value specified by OrData, and writes the\r
+  result to the 64-bit I/O port specified by Port. The value written to the I/O\r
+  port is returned. This function must guarantee that all I/O read and write\r
+  operations are serialized. Extra left bits in OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the\r
+  result back to the bit field in the 64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r
+  the read result and the value specified by AndData, and writes the result to\r
+  the 64-bit I/O port specified by Port. The value written to the I/O port is\r
+  returned. This function must guarantee that all I/O read and write operations\r
+  are serialized. Extra left bits in AndData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAnd64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit port, performs a bitwise AND followed by a\r
+  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit port.\r
+\r
+  Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed\r
+  by a bitwise inclusive OR between the read result and the value specified by\r
+  AndData, and writes the result to the 64-bit I/O port specified by Port. The\r
+  value written to the I/O port is returned. This function must guarantee that\r
+  all I/O read and write operations are serialized. Extra left bits in both\r
+  AndData and OrData are stripped.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Port      The I/O port to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with the read value from the I/O port.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoBitFieldAndThenOr64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return IoWrite64 (\r
+           Port,\r
+           BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 8-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in an 8-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldRead8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 8-bit register is returned.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 8-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 8-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAnd8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 8-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 7, then ASSERT().\r
+  If EndBit is greater than 7, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..7.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioBitFieldAndThenOr8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT8                     AndData,\r
+  IN      UINT8                     OrData\r
+  )\r
+{\r
+  return MmioWrite8 (\r
+           Address,\r
+           BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 16-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 16-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldRead16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 16-bit register is returned.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 16-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAnd16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 16-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 15, then ASSERT().\r
+  If EndBit is greater than 15, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..15.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioBitFieldAndThenOr16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT16                    AndData,\r
+  IN      UINT16                    OrData\r
+  )\r
+{\r
+  return MmioWrite16 (\r
+           Address,\r
+           BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, MmioRead32 (Address) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, MmioRead32 (Address) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 32-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 32-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldRead32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 32-bit register is returned.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 32-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 32-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAnd32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 32-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 31, then ASSERT().\r
+  If EndBit is greater than 31, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..31.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioBitFieldAndThenOr32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT32                    AndData,\r
+  IN      UINT32                    OrData\r
+  )\r
+{\r
+  return MmioWrite32 (\r
+           Address,\r
+           BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the\r
+  result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  OrData  The value to OR with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, MmioRead64 (Address) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result\r
+  back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, MmioRead64 (Address) & AndData);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r
+  inclusive OR, and writes the result back to the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, performs a\r
+  bitwise OR between the result of the AND operation and the value specified by\r
+  OrData, and writes the result to the 64-bit MMIO register specified by\r
+  Address. The value written to the MMIO register is returned. This function\r
+  must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  AndData The value to AND with the read value from the MMIO register.\r
+  @param  OrData  The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData);\r
+}\r
+\r
+/**\r
+  Reads a bit field of a MMIO register.\r
+\r
+  Reads the bit field in a 64-bit MMIO register. The bit field is specified by\r
+  the StartBit and the EndBit. The value of the bit field is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to read.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldRead64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit\r
+  )\r
+{\r
+  return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);\r
+}\r
+\r
+/**\r
+  Writes a bit field to a MMIO register.\r
+\r
+  Writes Value to the bit field of the MMIO register. The bit field is\r
+  specified by the StartBit and the EndBit. All other bits in the destination\r
+  MMIO register are preserved. The new value of the 64-bit register is returned.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  Value     New value of the bit field.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise\r
+  inclusive OR between the read result and the value specified by OrData, and\r
+  writes the result to the 64-bit MMIO register specified by Address. The value\r
+  written to the MMIO register is returned. This function must guarantee that\r
+  all MMIO read and write operations are serialized. Extra left bits in OrData\r
+  are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  OrData    The value to OR with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and\r
+  writes the result back to the bit field in the 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  between the read result and the value specified by AndData, and writes the\r
+  result to the 64-bit MMIO register specified by Address. The value written to\r
+  the MMIO register is returned. This function must guarantee that all MMIO\r
+  read and write operations are serialized. Extra left bits in AndData are\r
+  stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAnd64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)\r
+           );\r
+}\r
+\r
+/**\r
+  Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed\r
+  by a bitwise inclusive OR, and writes the result back to the bit field in the\r
+  64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r
+  followed by a bitwise inclusive OR between the read result and the value\r
+  specified by AndData, and writes the result to the 64-bit MMIO register\r
+  specified by Address. The value written to the MMIO register is returned.\r
+  This function must guarantee that all MMIO read and write operations are\r
+  serialized. Extra left bits in both AndData and OrData are stripped.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If StartBit is greater than 63, then ASSERT().\r
+  If EndBit is greater than 63, then ASSERT().\r
+  If EndBit is less than StartBit, then ASSERT().\r
+\r
+  @param  Address   MMIO register to write.\r
+  @param  StartBit  The ordinal of the least significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  EndBit    The ordinal of the most significant bit in the bit field.\r
+                    Range 0..63.\r
+  @param  AndData   The value to AND with read value from the MMIO register.\r
+  @param  OrData    The value to OR with the result of the AND operation.\r
+\r
+  @return The value written back to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioBitFieldAndThenOr64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINTN                     StartBit,\r
+  IN      UINTN                     EndBit,\r
+  IN      UINT64                    AndData,\r
+  IN      UINT64                    OrData\r
+  )\r
+{\r
+  return MmioWrite64 (\r
+           Address,\r
+           BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)\r
+           );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c
new file mode 100644 (file)
index 0000000..6105c7a
--- /dev/null
@@ -0,0 +1,600 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  IoHighLevel.c\r
+  \r
+Abstract: \r
+\r
+  High-level Io/Mmio functions.\r
+\r
+--*/\r
+\r
+#include "DxeCpuIoLibInternal.h"\r
+\r
+//\r
+// Globle varible to cache pointer to CpuIo protocol.\r
+//\r
+STATIC EFI_CPU_IO_PROTOCOL          *mCpuIo = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer to CpuIo protocol.\r
+\r
+  The constructor function locates CpuIo protocol from protocol database.\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IoLibConstructor (\r
+  IN      EFI_HANDLE                ImageHandle,\r
+  IN      EFI_SYSTEM_TABLE          *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID**) &mCpuIo);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Reads registers in the EFI CPU I/O space.\r
+\r
+  Reads the I/O port specified by Port with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI CPU I/O space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoReadWorker (\r
+  IN      UINTN                     Port,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  UINT64                            Data;\r
+\r
+  Status = mCpuIo->Io.Read (mCpuIo, Width, Port, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Writes registers in the EFI CPU I/O space.\r
+\r
+  Writes the I/O port specified by Port with registers width and value specified by Width\r
+  and Data respectively.  Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+  @param  Port          The base address of the I/O operation.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+  @param  Data          The value to write to the I/O port.\r
+\r
+  @return The paramter of Data.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWriteWorker (\r
+  IN      UINTN                     Port,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+  IN      UINT64                    Data\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Reads memory-mapped registers in the EFI system memory space.\r
+\r
+  Reads the MMIO registers specified by Address with registers width specified by Width.\r
+  The read value is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioReadWorker (\r
+  IN      UINTN                     Address,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  UINT64                            Data;\r
+\r
+  Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Writes memory-mapped registers in the EFI system memory space.\r
+\r
+  Writes the MMIO registers specified by Address with registers width and value specified by Width\r
+  and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r
+  This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+  @param  Address       The MMIO register to read.\r
+                        The caller is responsible for aligning the Address if required.\r
+  @param  Width         The width of the I/O operation.\r
+\r
+  @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWriteWorker (\r
+  IN      UINTN                     Address,\r
+  IN      EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+  IN      UINT64                    Data\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = mCpuIo->Mem.Write (mCpuIo, Width, Address, 1, &Data);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Data;\r
+}\r
+\r
+/**\r
+  Reads an 8-bit I/O port.\r
+\r
+  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoRead8 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  return (UINT8)IoReadWorker (Port, EfiCpuIoWidthUint8);\r
+}\r
+\r
+/**\r
+  Writes an 8-bit I/O port.\r
+\r
+  Writes the 8-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+IoWrite8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return (UINT8)IoWriteWorker (Port, EfiCpuIoWidthUint8, Value);\r
+}\r
+\r
+/**\r
+  Reads a 16-bit I/O port.\r
+\r
+  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoRead16 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
+  return (UINT16)IoReadWorker (Port, EfiCpuIoWidthUint16);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit I/O port.\r
+\r
+  Writes the 16-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+IoWrite16 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Port & 1) == 0);\r
+  return (UINT16)IoWriteWorker (Port, EfiCpuIoWidthUint16, Value);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit I/O port.\r
+\r
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoRead32 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
+  return (UINT32)IoReadWorker (Port, EfiCpuIoWidthUint32);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit I/O port.\r
+\r
+  Writes the 32-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+IoWrite32 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Port & 3) == 0);\r
+  return (UINT32)IoWriteWorker (Port, EfiCpuIoWidthUint32, Value);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit I/O port.\r
+\r
+  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoRead64 (\r
+  IN      UINTN                     Port\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
+  return IoReadWorker (Port, EfiCpuIoWidthUint64);\r
+}\r
+\r
+/**\r
+  Writes a 64-bit I/O port.\r
+\r
+  Writes the 64-bit I/O port specified by Port with the value specified by Value\r
+  and returns Value. This function must guarantee that all I/O read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port  The I/O port to write.\r
+  @param  Value The value to write to the I/O port.\r
+\r
+  @return The value written the I/O port.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWrite64 (\r
+  IN      UINTN                     Port,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Port is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Port & 7) == 0);\r
+  return IoWriteWorker (Port, EfiCpuIoWidthUint64, Value);\r
+}\r
+\r
+/**\r
+  Reads an 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  return (UINT8)MmioReadWorker (Address, EfiCpuIoWidthUint8);\r
+}\r
+\r
+/**\r
+  Writes an 8-bit MMIO register.\r
+\r
+  Writes the 8-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  return (UINT8)MmioWriteWorker (Address, EfiCpuIoWidthUint8, Value);\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
+  return (UINT16)MmioReadWorker (Address, EfiCpuIoWidthUint16);\r
+}\r
+\r
+/**\r
+  Writes a 16-bit MMIO register.\r
+\r
+  Writes the 16-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 16-bit boundary.\r
+  //\r
+  ASSERT ((Address & 1) == 0);\r
+  return (UINT16)MmioWriteWorker (Address, EfiCpuIoWidthUint16, Value);\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
+  return (UINT32)MmioReadWorker (Address, EfiCpuIoWidthUint32);\r
+}\r
+\r
+/**\r
+  Writes a 32-bit MMIO register.\r
+\r
+  Writes the 32-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 32-bit boundary.\r
+  //\r
+  ASSERT ((Address & 3) == 0);\r
+  return (UINT32)MmioWriteWorker (Address, EfiCpuIoWidthUint32, Value);\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioRead64 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
+  return (UINT64)MmioReadWorker (Address, EfiCpuIoWidthUint64);\r
+}\r
+\r
+/**\r
+  Writes a 64-bit MMIO register.\r
+\r
+  Writes the 64-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  //\r
+  // Make sure Address is aligned on a 64-bit boundary.\r
+  //\r
+  ASSERT ((Address & 7) == 0);\r
+  return (UINT64)MmioWriteWorker (Address, EfiCpuIoWidthUint64, Value);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf
new file mode 100644 (file)
index 0000000..ad90935
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeMemoryAllocationLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeMemoryAllocationLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeMemoryAllocationLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  MemoryAllocationLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+  EfiProtocolLib\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
new file mode 100644 (file)
index 0000000..482faa3
--- /dev/null
@@ -0,0 +1,1079 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  MemoryAllocationLib.c\r
+  \r
+Abstract: \r
+\r
+  Support routines for memory allocation routines for use with drivers.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type.\r
+\r
+  Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+  buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Memory; \r
+\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory);\r
+  if (EFI_ERROR (Status)) {\r
+    Memory = 0;\r
+  }\r
+  return (VOID *) (UINTN) Memory;\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiBootServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+  functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
\r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (Pages != 0);\r
+  Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+  NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Memory;\r
+  UINTN                 AlignedMemory;\r
+  UINTN                 AlignmentMask;\r
+  UINTN                 UnalignedPages;\r
+  UINTN                 RealPages;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+  if (Alignment > EFI_PAGE_SIZE) {\r
+    //\r
+    // Caculate the total number of pages since alignment is larger than page size.\r
+    //\r
+    AlignmentMask  = Alignment - 1;\r
+    RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+    //\r
+    // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+    //\r
+    ASSERT (RealPages > Pages);\r
\r
+    Status         = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
+    if (EFI_ERROR (Status)) {\r
+      return NULL;\r
+    }\r
+    AlignedMemory  = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
+    UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory);\r
+    if (UnalignedPages > 0) {\r
+      //\r
+      // Free first unaligned page(s).\r
+      //\r
+      Status = (gBS->FreePages) (Memory, UnalignedPages);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+    Memory         = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    UnalignedPages = RealPages - Pages - UnalignedPages;\r
+    if (UnalignedPages > 0) {\r
+      //\r
+      // Free last unaligned page(s).\r
+      //\r
+      Status = (gBS->FreePages) (Memory, UnalignedPages);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  } else {\r
+    //\r
+    // Do not over-allocate pages in this case.\r
+    //\r
+    Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory);\r
+    if (EFI_ERROR (Status)) {\r
+      return NULL;\r
+    }\r
+    AlignedMemory  = (UINTN) Memory;\r
+  }\r
+  return (VOID *) AlignedMemory;\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+  allocation functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
+  \r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (Pages != 0);\r
+  Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of a certain pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            AllocationSize\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  VOID        *Memory;\r
+\r
+  Status = (gBS->AllocatePool) (MemoryType, AllocationSize, &Memory);\r
+  if (EFI_ERROR (Status)) {\r
+    Memory = NULL;\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of a certian pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+  with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the request,\r
+  then NULL is returned.\r
+\r
+  @param  PoolType              The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize,\r
+  IN CONST VOID       *Buffer\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+} \r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+  Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePool (\r
+  IN VOID   *Buffer\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  Status = (gBS->FreePool) (Buffer);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining\r
+  to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.                            If Alignment is zero, then byte alignment is used.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID        *RawAddress;\r
+  UINTN       AlignedAddress;\r
+  UINTN       AlignmentMask;\r
+  UINTN       OverAllocationSize;\r
+  UINTN       RealAllocationSize;\r
+  VOID        **FreePointer;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+  \r
+  if (Alignment == 0) {\r
+    AlignmentMask = Alignment;\r
+  } else {\r
+    AlignmentMask = Alignment - 1;\r
+  }\r
+  //\r
+  // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. \r
+  //\r
+  OverAllocationSize  = sizeof (RawAddress) + AlignmentMask;\r
+  RealAllocationSize  = AllocationSize + OverAllocationSize;\r
+  //\r
+  // Make sure that AllocationSize plus OverAllocationSize does not overflow. \r
+  //\r
+  ASSERT (RealAllocationSize > AllocationSize); \r
+\r
+  RawAddress = InternalAllocatePool (PoolType, RealAllocationSize);\r
+  if (RawAddress == NULL) {\r
+    return NULL;\r
+  }\r
+  AlignedAddress      = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;\r
+  //\r
+  // Save the original memory address just before the aligned address.\r
+  //\r
+  FreePointer         = (VOID **)(AlignedAddress - sizeof (RawAddress));\r
+  *FreePointer        = RawAddress;\r
+\r
+  return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+  buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there is not\r
+  enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID    *Memory;\r
+  Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining\r
+  to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN CONST VOID       *Buffer,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID  *Memory;\r
+  \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
+  in the Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  aligned pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPool (\r
+  IN VOID   *Buffer\r
+  )\r
+{\r
+  VOID        *RawAddress;\r
+  VOID        **FreePointer;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Get the pre-saved original address in the over-allocate pool.\r
+  //\r
+  FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress));\r
+  RawAddress  = *FreePointer;\r
+\r
+  Status = (gBS->FreePool) (RawAddress);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
new file mode 100644 (file)
index 0000000..766559c
--- /dev/null
@@ -0,0 +1,97 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeReportStatusCodeLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeReportStatusCodeLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeReportStatusCodeLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  ReportStatusCodeLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+#\r
+# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used\r
+# \r
+  EdkIIGlueUefiRuntimeServicesTableLib\r
+# R8.x lib\r
+  EfiProtocolLib\r
+# Possibly, gEfiCallerIdGuid might be used.\r
+  EdkGuidLib\r
+  ArchProtocolLib\r
+\r
+\r
+[libraries.ia32]\r
+  EdkIIGlueBaseIoLibIntrinsic  \r
+\r
+[libraries.x64]\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+\r
+[libraries.ebc]\r
+  EdkIIGlueDxeIoLibCpuIo\r
+\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
new file mode 100644 (file)
index 0000000..2178d74
--- /dev/null
@@ -0,0 +1,605 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  ReportStatusCodeLib.c\r
+  \r
+Abstract: \r
+\r
+  Report Status Code Library for DXE Phase.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+//\r
+// Global pointer to the Status Code Protocol\r
+//\r
+static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+\r
+#endif\r
+\r
+/**\r
+  Internal worker function that reports a status code through the Status Code Protocol\r
+\r
+  This function checks to see if a Status Code Protocol is present in the handle \r
+  database.  If a Status Code Protocol is not present, then EFI_UNSUPPORTED is \r
+  returned.  If a Status Code Protocol is present, then it is cached in gStatusCode,\r
+  and the ReportStatusCode() service of the Status Code Protocol is called passing in\r
+  Type, Value, Instance, CallerId, and Data.  The result of this call is returned.\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  This is an optional parameter that may be \r
+                            NULL.\r
+  @param  Data              Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to report the status code.\r
+  @retval  EFI_UNSUPPORTED       Status Code Protocol is not available.\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+InternalReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
+  )\r
+{\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // If gStatusCode is NULL, then see if a Status Code Protocol instance is present \r
+  // in the handle database.\r
+  //\r
+  if (gStatusCode == NULL) {\r
+    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+    if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  //\r
+  // A Status Code Protocol is present in the handle database, so pass in all the  \r
+  // parameters to the ReportStatusCode() service of the Status Code Protocol\r
+  //\r
+  return (gStatusCode->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
+\r
+#else\r
+\r
+  return (gRT->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
+\r
+#endif\r
+\r
+}\r
+\r
+\r
+/**\r
+  Computes and returns the size, in bytes, of a device path.\r
+\r
+  @param  DevicePath  A pointer to a device path.\r
+\r
+  @return  The size, in bytes, of DevicePath.\r
+\r
+**/\r
+STATIC\r
+UINTN\r
+InternalReportStatusCodeDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!EfiIsDevicePathEnd (DevicePath)) {\r
+    DevicePath = EfiNextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Subtract the start node from the end node and add in the size of the end node\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
+}\r
+\r
+\r
+/**\r
+  Converts a status code to an 8-bit POST code value.\r
+\r
+  Converts the status code specified by CodeType and Value to an 8-bit POST code \r
+  and returns the 8-bit POST code in PostCode.  If CodeType is an \r
+  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode \r
+  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits \r
+  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.  \r
+\r
+  If PostCode is NULL, then ASSERT().\r
+\r
+  @param  CodeType  The type of status code being converted.\r
+  @param  Value     The status code value being converted.\r
+  @param  PostCode  A pointer to the 8-bit POST code value to return. \r
+\r
+  @retval  TRUE   The status code specified by CodeType and Value was converted \r
+                  to an 8-bit POST code and returned in  PostCode.\r
+  @retval  FALSE  The status code specified by CodeType and Value could not be \r
+                  converted to an 8-bit POST code value.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueCodeTypeToPostCode (\r
+  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
+  IN  EFI_STATUS_CODE_VALUE  Value,\r
+  OUT UINT8                  *PostCode\r
+  )\r
+{\r
+  //\r
+  // If PostCode is NULL, then ASSERT()\r
+  //\r
+  ASSERT (PostCode != NULL);\r
+\r
+  //\r
+  // Convert Value to an 8 bit post code\r
+  //\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
+      ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {\r
+    *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
+                          (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Extracts ASSERT() information from a status code structure.\r
+\r
+  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
+  arguments specified by Filename, Description, and LineNumber.  If CodeType is \r
+  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r
+  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r
+  Filename, Description, and LineNumber from the optional data area of the \r
+  status code buffer specified by Data.  The optional data area of Data contains \r
+  a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r
+  ASCII string for the Description, followed by a 32-bit LineNumber.  If the \r
+  ASSERT() information could be extracted from Data, then return TRUE.  \r
+  Otherwise, FALSE is returned.  \r
+\r
+  If Data is NULL, then ASSERT().\r
+  If Filename is NULL, then ASSERT().\r
+  If Description is NULL, then ASSERT().\r
+  If LineNumber is NULL, then ASSERT().\r
+\r
+  @param  CodeType     The type of status code being converted.\r
+  @param  Value        The status code value being converted.\r
+  @param  Data         Pointer to status code data buffer. \r
+  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
+  @param  Description  Pointer to the description of the ASSERT().\r
+  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
+\r
+  @retval  TRUE   The status code specified by CodeType, Value, and Data was \r
+                  converted ASSERT() arguments specified by Filename, Description, \r
+                  and LineNumber.\r
+  @retval  FALSE  The status code specified by CodeType, Value, and Data could \r
+                  not be converted to ASSERT() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE        CodeType,\r
+  IN EFI_STATUS_CODE_VALUE       Value,  \r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT CHAR8                      **Filename,\r
+  OUT CHAR8                      **Description,\r
+  OUT UINT32                     *LineNumber\r
+  )\r
+{\r
+  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
+\r
+  ASSERT (Data        != NULL);\r
+  ASSERT (Filename    != NULL);\r
+  ASSERT (Description != NULL);\r
+  ASSERT (LineNumber  != NULL);\r
+\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) && \r
+      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&\r
+      ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
+    AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
+    *Filename    = (CHAR8 *)(AssertData + 1);\r
+    *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
+    *LineNumber  = AssertData->LineNumber;\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Extracts DEBUG() information from a status code structure.\r
+\r
+  Converts the status code specified by Data to the DEBUG() arguments specified \r
+  by ErrorLevel, Marker, and Format.  If type GUID in Data is \r
+  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and \r
+  Format from the optional data area of the status code buffer specified by Data.  \r
+  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker \r
+  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for \r
+  the Format.  If the DEBUG() information could be extracted from Data, then \r
+  return TRUE.  Otherwise, FALSE is returned.\r
+\r
+  If Data is NULL, then ASSERT().\r
+  If ErrorLevel is NULL, then ASSERT().\r
+  If Marker is NULL, then ASSERT().\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  Data        Pointer to status code data buffer. \r
+  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
+  @param  Marker      Pointer to the variable argument list associated with Format.\r
+  @param  Format      Pointer to a Null-terminated ASCII format string of a \r
+                      debug message.\r
+\r
+  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments \r
+                  specified by ErrorLevel, Marker, and Format.\r
+  @retval  FALSE  The status code specified by Data could not be converted to \r
+                  DEBUG() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractDebugInfo (\r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT UINT32                     *ErrorLevel,\r
+  OUT VA_LIST                    *Marker,\r
+  OUT CHAR8                      **Format\r
+  )\r
+{\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  ASSERT (Data       != NULL);\r
+  ASSERT (ErrorLevel != NULL);\r
+  ASSERT (Marker     != NULL);\r
+  ASSERT (Format     != NULL);\r
+\r
+  //\r
+  // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
+  //\r
+  if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Retrieve the debug information from the status code record\r
+  //\r
+  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
+\r
+  *ErrorLevel = DebugInfo->ErrorLevel;\r
+\r
+  //\r
+  // The first 12 * UINTN bytes of the string are really an \r
+  // argument stack to support varargs on the Format string.\r
+  //\r
+  *Marker = (VA_LIST) (DebugInfo + 1);\r
+  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
+\r
+  return TRUE;\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code.\r
+\r
+  Reports the status code specified by the parameters Type and Value.  Status \r
+  code also require an instance, caller ID, and extended data.  This function \r
+  passed in a zero instance, NULL extended data, and a caller ID of \r
+  gEfiCallerIdGuid, which is the GUID for the module.  \r
+  \r
+  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode() \r
+  is called while processing another any other Report Status Code Library function,\r
+  then ReportStatusCode() must return immediately.\r
+\r
+  @param  Type   Status code type. \r
+  @param  Value  Status code value.\r
+\r
+  @retval  EFI_SUCCESS       The status code was reported.\r
+  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a \r
+                             device error.\r
+  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value\r
+  )\r
+{\r
+  return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with a Device Path Protocol as the extended data.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  Device Path Protocol specified by DevicePath.  This function is responsible \r
+  for allocating a buffer large enough for the standard header and the device \r
+  path.  The standard header is filled in with a GUID of \r
+  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero \r
+  instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If \r
+  ReportStatusCodeWithDevicePath() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithDevicePath() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If DevicePath is NULL, then ASSERT().\r
+\r
+  @param  Type        Status code type. \r
+  @param  Value       Status code value.\r
+  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by DevicePath.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithDevicePath (\r
+  IN EFI_STATUS_CODE_TYPE            Type,\r
+  IN EFI_STATUS_CODE_VALUE           Value,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  ASSERT (DevicePath != NULL);\r
+  return ReportStatusCodeWithExtendedData (\r
+           Type, \r
+           Value, \r
+           (VOID *)DevicePath, \r
+           InternalReportStatusCodeDevicePathSize (DevicePath)\r
+           );\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with an extended data buffer.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData \r
+  is assumed to be one of the data structures specified in Related Definitions.  \r
+  These data structure do not have the standard header, so this function is \r
+  responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled \r
+  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported \r
+  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If \r
+  ReportStatusCodeWithExtendedData() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithExtendedData() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL, then ASSERT().\r
+  If ExtendedDataSize is 0, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to \r
+                            be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by ExtendedData and ExtendedDataSize.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithExtendedData (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN CONST VOID             *ExtendedData,\r
+  IN UINTN                  ExtendedDataSize\r
+  )\r
+{\r
+  ASSERT (ExtendedData     != NULL);\r
+  ASSERT (ExtendedDataSize != 0);\r
+  return ReportStatusCodeEx (\r
+           Type,\r
+           Value,\r
+           0,\r
+           NULL,\r
+           NULL,\r
+           ExtendedData,\r
+           ExtendedDataSize\r
+           );\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with full parameters.\r
+\r
+  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize \r
+  is 0, then an extended data buffer is not reported.  If ExtendedData is not \r
+  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.  \r
+  ExtendedData is assumed not have the standard status code header, so this function \r
+  is responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled in \r
+  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a \r
+  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with \r
+  an instance specified by Instance and a caller ID specified by CallerId.  If \r
+  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
+\r
+  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx() \r
+  is called while processing another any other Report Status Code Library function, \r
+  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
+  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  If this parameter is NULL, then a caller \r
+                            ID of gEfiCallerIdGuid is used.\r
+  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.  \r
+                            If this parameter is NULL, then a the status code \r
+                            standard header is filled in with \r
+                            gEfiStatusCodeSpecificDataGuid.\r
+  @param  ExtendedData      Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate \r
+                                 the extended data section if it was specified.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeEx (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN UINT32                 Instance,\r
+  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
+  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
+  IN CONST VOID             *ExtendedData      OPTIONAL,\r
+  IN UINTN                  ExtendedDataSize\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_STATUS_CODE_DATA  *StatusCodeData;\r
+\r
+  ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
+  ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
+\r
+  //\r
+  // Allocate space for the Status Code Header and its buffer\r
+  //\r
+  StatusCodeData = NULL;\r
+  (gBS->AllocatePool) (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
+  if (StatusCodeData == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // Fill in the extended data header\r
+  //\r
+  StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
+  StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
+  if (ExtendedDataGuid == NULL) {\r
+    ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
+  }\r
+  CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
+\r
+  //\r
+  // Fill in the extended data buffer\r
+  //\r
+  CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
+\r
+  //\r
+  // Report the status code\r
+  //\r
+  if (CallerId == NULL) {\r
+    CallerId = &gEfiCallerIdGuid;\r
+  }\r
+  Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
+\r
+  //\r
+  // Free the allocated buffer\r
+  //\r
+  (gBS->FreePool) (StatusCodeData);\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportProgressCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportErrorCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportDebugCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c
new file mode 100644 (file)
index 0000000..31591be
--- /dev/null
@@ -0,0 +1,61 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  DxeServicesTableLib.c\r
+  \r
+Abstract: \r
+\r
+  Dxe Services Table Lib\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+//\r
+// Cache copy of the DXE Services Table\r
+//\r
+EFI_DXE_SERVICES  *gDS      = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer of DXE Services Table.\r
+\r
+  The constructor function caches the pointer of DXE Services Table.\r
+  It will ASSERT() if that operation fails.\r
+  It will ASSERT() if the pointer of DXE Services Table is NULL.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Cache copy of the DXE Services Table\r
+  //\r
+  Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (gDS != NULL);\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf
new file mode 100644 (file)
index 0000000..f3be24f
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeServicesTableLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeServicesTableLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeServicesTableLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  DxeServicesTableLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+\r
+[libraries.common]\r
+  EdkIIGlueUefiLib\r
+  EfiProtocolLib\r
+\r
+[libraries.ia32]\r
+\r
+[libraries.x64]\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c
new file mode 100644 (file)
index 0000000..c078f41
--- /dev/null
@@ -0,0 +1,107 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  DxeSmbusLib.c\r
+  \r
+Abstract: \r
+\r
+  Dxe Smbus Lib internal functions\r
+\r
+--*/\r
+\r
+#include "DxeSmbusLibInternal.h"\r
+\r
+//\r
+// Globle varible to cache pointer to Smbus protocol.\r
+//\r
+STATIC EFI_SMBUS_HC_PROTOCOL      *mSmbus = NULL; \r
+\r
+/**\r
+  The constructor function caches the pointer to Smbus protocol.\r
+  \r
+  The constructor function locates Smbus protocol from protocol database.\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmbusLibConstructor (\r
+  IN EFI_HANDLE                ImageHandle,\r
+  IN EFI_SYSTEM_TABLE          *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  \r
+  Status = gBS->LocateProtocol (&gEfiSmbusProtocolGuid, NULL, (VOID**) &mSmbus);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (mSmbus != NULL);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation..\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+     OUT RETURN_STATUS              *Status        OPTIONAL\r
+  )\r
+{\r
+  RETURN_STATUS             ReturnStatus;\r
+  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
+\r
+  SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
+\r
+  ReturnStatus = mSmbus->Execute (\r
+                           mSmbus,\r
+                           SmbusDeviceAddress,\r
+                           SMBUS_LIB_COMMAND (SmBusAddress),\r
+                           SmbusOperation,\r
+                           SMBUS_LIB_PEC (SmBusAddress),  \r
+                           &Length,\r
+                           Buffer\r
+                           );\r
+  if (Status != NULL) {\r
+    *Status = ReturnStatus;\r
+  }\r
+\r
+  return Length;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf
new file mode 100644 (file)
index 0000000..a3819b2
--- /dev/null
@@ -0,0 +1,82 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   DxeSmbusLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for DxeSmbusLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueDxeSmbusLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  DxeSmbusLib.c\r
+  SmbusLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+  EfiProtocolLib\r
+  EdkFrameworkProtocolLib\r
+\r
+[libraries.ia32]\r
+\r
+[libraries.x64]\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h
new file mode 100644 (file)
index 0000000..0b141bd
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DxeSmbusLibInternal.h\r
+    \r
+Abstract: \r
+\r
+  Declarations of internal functions in DxeSmbusLib.\r
+\r
+--*/\r
+\r
+#ifndef __DXE_SMBUS_LIB_INTERNAL_H__\r
+#define __DXE_SMBUS_LIB_INTERNAL_H__\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress)      (((SmBusAddress) >> 1)  & 0x7f)\r
+#define SMBUS_LIB_COMMAND(SmBusAddress)            (((SmBusAddress) >> 8)  & 0xff)\r
+#define SMBUS_LIB_LENGTH(SmBusAddress)             (((SmBusAddress) >> 16) & 0x3f)\r
+#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))\r
+#define SMBUS_LIB_RESEARVED(SmBusAddress)          ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))\r
+\r
+//\r
+// Declaration for internal functions\r
+//\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation.\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+     OUT RETURN_STATUS              *Status        OPTIONAL\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c
new file mode 100644 (file)
index 0000000..503d167
--- /dev/null
@@ -0,0 +1,475 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  DxeSmbus.c\r
+  \r
+Abstract: \r
+\r
+  Dxe Smbus Lib Interfaces\r
+\r
+--*/\r
+\r
+#include "DxeSmbusLibInternal.h"\r
+\r
+/**\r
+  Executes an SMBUS quick read command.\r
+\r
+  Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickRead (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS quick write command.\r
+\r
+  Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickWrite (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS receive byte command.\r
+\r
+  Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  The byte received from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte received from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReceiveByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)  == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS send byte command.\r
+\r
+  Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
+  The byte specified by Value is sent.\r
+  Only the SMBUS slave address field of SmBusAddress is required.  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to send.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusSendByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte   = Value;\r
+  InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data byte command.\r
+\r
+  Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 8-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReadDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data byte command.\r
+\r
+  Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
+  The 8-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusWriteDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte = Value;\r
+  InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data word command.\r
+\r
+  Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+  \r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusReadDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);\r
+  \r
+  return Word;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data word command.\r
+\r
+  Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusWriteDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Word = Value;\r
+  InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS process call command.\r
+\r
+  Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value returned by the process call command is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The 16-bit value returned by the process call command.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read block command.\r
+\r
+  Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Bytes are read from the SMBUS and stored in Buffer.\r
+  The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusReadBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write block command.\r
+\r
+  Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from Buffer.\r
+  The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.  \r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusWriteBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN  Length;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS block process call command.\r
+\r
+  Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  WriteBuffer     Pointer to the buffer of bytes to write to the SMBUS.\r
+  @param  ReadBuffer      Pointer to the buffer of bytes to read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusBlockProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN   Length;\r
+\r
+  ASSERT (WriteBuffer != NULL);\r
+  ASSERT (ReadBuffer  != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  //\r
+  // Assuming that ReadBuffer is large enough to save another memory copy.\r
+  //\r
+  ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);\r
+}\r
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 (file)
index 0000000..73ed44f
--- /dev/null
@@ -0,0 +1,181 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Runtime lib\r
+\r
+--*/\r
+\r
+#include "..\RuntimeLibInternal.h"\r
+\r
+//\r
+// Driver Lib Module Globals\r
+//\r
+\r
+STATIC EFI_EVENT              mEfiVirtualNotifyEvent;\r
+STATIC BOOLEAN                mEfiGoneVirtual         = FALSE;\r
+STATIC BOOLEAN                mEfiAtRuntime           = FALSE;\r
+EFI_RUNTIME_SERVICES          *mRT;\r
+\r
+/**\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+  \r
+  @param[in]  Event   The Event that is being processed\r
+  @param[in]  Context Event Context\r
+**/\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  //\r
+  // Clear out BootService globals\r
+  //\r
+  gBS             = NULL;\r
+\r
+  mEfiAtRuntime = TRUE;\r
+}\r
+\r
+/**\r
+  Fixup internal data so that EFI can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in \r
+  lib to virtual mode.\r
+  \r
+  @param[in]    Event   The Event that is being processed\r
+  @param[in]    Context Event Context\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+RuntimeLibVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  UINTN Index;\r
+  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;\r
+\r
+  for (Index = 0; \r
+       _gDriverSetVirtualAddressMapEvent[Index] != NULL;\r
+       Index++) {\r
+    ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
+    ChildNotifyEventHandler (Event, NULL);\r
+  }\r
+\r
+  //\r
+  // Update global for Runtime Services Table and IO\r
+  //\r
+  EfiConvertPointer (0, (VOID **) &mRT);\r
+\r
+  mEfiGoneVirtual = TRUE;\r
+}\r
+\r
+/**\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+  \r
+  @param[in]  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param[in]  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @return     EFI_STATUS    always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeDriverLibConstruct (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  ASSERT (SystemTable != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+  \r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  // \r
+  ASSERT (gBS != NULL);\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+                  EFI_TPL_NOTIFY,\r
+                  RuntimeLibVirtualNotifyEvent,\r
+                  NULL,\r
+                  &mEfiVirtualNotifyEvent\r
+                  );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+  @retval     EFI_SUCCESS       Shutdown the Runtime Driver Lib successfully\r
+  @retval     EFI_UNSUPPORTED   Runtime Driver lib was not initialized at all\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeDriverLibDeconstruct (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Close SetVirtualAddressMap () notify function\r
+  //\r
+  ASSERT (gBS != NULL);\r
+  Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Return TRUE if ExitBootServices () has been called\r
+  \r
+  @retval TRUE If ExitBootServices () has been called\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+{\r
+  return mEfiAtRuntime;\r
+}\r
+\r
+/**\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+  \r
+  @retval TRUE  If SetVirtualAddressMap () has been called\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+{\r
+  return mEfiGoneVirtual;\r
+}\r
+\r
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 (file)
index 0000000..5528f84
--- /dev/null
@@ -0,0 +1,471 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  RuntimeService.c\r
+\r
+Abstract:\r
+\r
+  Runtime Lib\r
+\r
+--*/\r
+\r
+#include "..\RuntimeLibInternal.h"\r
+\r
+VOID\r
+EFIAPI\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+}\r
+\r
+//\r
+// The following functions hide the mRT local global from the call to\r
+// runtime service in the EFI system table.\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device's\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetTime (Time, Capabilities);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetTime (Time);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetWakeupTime (Enabled, Pending, Time);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetWakeupTime (Enable, Time);\r
+}\r
+\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor's variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor's variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform's monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextHighMonotonicCount (HighCount);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertPointer (\r
+  IN UINTN                  DebugDisposition,\r
+  IN OUT VOID               **Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT LIST_ENTRY       *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Conver the standard Lib double linked list to a virtual mapping.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)\r
+\r
+  ListHead         - Head of linked list to convert\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  LIST_ENTRY  *Link;\r
+  LIST_ENTRY  *NextLink;\r
+\r
+  //\r
+  // Convert all the ForwardLink & BackLink pointers in the list\r
+  //\r
+  Link = ListHead;\r
+  do {\r
+    NextLink = Link->ForwardLink;\r
+\r
+    EfiConvertPointer (\r
+      Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->ForwardLink\r
+      );\r
+\r
+    EfiConvertPointer (\r
+      Link->BackLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->BackLink\r
+      );\r
+\r
+    Link = NextLink;\r
+  } while (Link != ListHead);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Change the runtime addressing mode of EFI firmware from physical to virtual.\r
+\r
+  @param  MemoryMapSize         The size in bytes of VirtualMap.\r
+  @param  DescriptorSize        The size in bytes of an entry in the VirtualMap.\r
+  @param  DescriptorVersion     The version of the structure entries in VirtualMap.\r
+  @param  VirtualMap            An array of memory descriptors which contain new virtual\r
+                                address mapping information for all runtime ranges. Type\r
+                                EFI_MEMORY_DESCRIPTOR is defined in the\r
+                                GetMemoryMap() function description.\r
+\r
+  @retval EFI_SUCCESS           The virtual address map has been applied.\r
+  @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in\r
+                                virtual address mapped mode.\r
+  @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r
+                                invalid.\r
+  @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory\r
+                                map that requires a mapping.\r
+  @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found\r
+                                in the memory map.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVirtualAddressMap (\r
+  IN UINTN                          MemoryMapSize,\r
+  IN UINTN                          DescriptorSize,\r
+  IN UINT32                         DescriptorVersion,\r
+  IN CONST EFI_MEMORY_DESCRIPTOR    *VirtualMap\r
+  )\r
+{\r
+  return mRT->SetVirtualAddressMap (\r
+                MemoryMapSize,\r
+                DescriptorSize,\r
+                DescriptorVersion,\r
+                (EFI_MEMORY_DESCRIPTOR *) VirtualMap\r
+                );\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiUpdateCapsule (\r
+  IN UEFI_CAPSULE_HEADER       **CapsuleHeaderArray,\r
+  IN UINTN                                 CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS      ScatterGatherList       OPTIONAL\r
+  )\r
+{\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  return mRT->UpdateCapsule (\r
+                CapsuleHeaderArray,\r
+                CapsuleCount,\r
+                ScatterGatherList\r
+                );\r
+#else\r
+  return EFI_UNSUPPORTED;\r
+#endif\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryCapsuleCapabilities (\r
+  IN UEFI_CAPSULE_HEADER       **CapsuleHeaderArray,\r
+  IN UINTN                                 CapsuleCount,\r
+  OUT  UINT64                      *MaximumCapsuleSize,\r
+  OUT EFI_RESET_TYPE           *ResetType\r
+  )\r
+{\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  return mRT->QueryCapsuleCapabilities (\r
+          CapsuleHeaderArray,\r
+          CapsuleCount,\r
+          MaximumCapsuleSize,\r
+          ResetType\r
+          );\r
+#else\r
+  return EFI_UNSUPPORTED;\r
+#endif\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryVariableInfo (\r
+  IN UINT32                      Attributes,\r
+  OUT UINT64                   *MaximumVariableStorageSize,\r
+  OUT   UINT64                 *RemainingVariableStorageSize,\r
+  OUT UINT64                   *MaximumVariableSize\r
+  )\r
+{\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  return mRT->QueryVariableInfo (\r
+          Attributes,\r
+          MaximumVariableStorageSize,\r
+          RemainingVariableStorageSize,\r
+          MaximumVariableSize\r
+          );\r
+#else \r
+  return EFI_UNSUPPORTED;\r
+#endif\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf
new file mode 100644 (file)
index 0000000..aa4f6ac
--- /dev/null
@@ -0,0 +1,96 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   EdkDxeRuntimeDriverLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for EdkDxeRuntimeDriverLib.\r
+#    This is the one whose name is EdkUefiRuntimeLib in EdkModulePkg in EdkII.\r
+#    For backward compatibility, we don't change the library name.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueEdkDxeRuntimeDriverLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ia32]\r
+  Common\RuntimeLib.c\r
+  Common\RuntimeService.c\r
+\r
+[sources.x64]\r
+  Common\RuntimeLib.c\r
+  Common\RuntimeService.c\r
+\r
+[sources.ipf]\r
+  Ipf\RuntimeLib.c\r
+  Ipf\RuntimeService.c\r
+\r
+[sources.ebc]\r
+  Common\RuntimeLib.c\r
+  Common\RuntimeService.c\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+\r
+[libraries.common]\r
+  EdkIIGlueUefiLib\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+#\r
+# R8.x Library\r
+#  \r
+  EfiProtocolLib\r
+\r
+[libraries.ia32]\r
+              \r
+[libraries.x64]\r
+\r
+[libraries.ipf]\r
+  EdkIIGlueEdkDxeSalLib\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
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 (file)
index 0000000..9f26230
--- /dev/null
@@ -0,0 +1,235 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Runtime lib\r
+\r
+--*/\r
+\r
+#include "..\RuntimeLibInternal.h"\r
+\r
+//\r
+// Driver Lib Module Globals\r
+//\r
+static EFI_EVENT      mEfiVirtualNotifyEvent;\r
+EFI_RUNTIME_SERVICES  *mRT;\r
+\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  if (EfiAtRuntime()) {\r
+    return;\r
+  }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+RuntimeLibVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in \r
+  lib to virtual mode.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN             Index;\r
+  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;\r
+\r
+  for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {\r
+    ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
+    ChildNotifyEventHandler (Event, NULL);\r
+  }\r
+\r
+  //\r
+  // Update global for Runtime Services Table\r
+  //\r
+  EfiConvertPointer (0, (VOID **) &mRT);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeDriverLibConstruct (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  mRT = SystemTable->RuntimeServices;\r
+\r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  //\r
+  if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
+    Status = gBS->CreateEvent (\r
+                    EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+                    EFI_TPL_NOTIFY,\r
+                    RuntimeLibVirtualNotifyEvent,\r
+                    NULL,\r
+                    &mEfiVirtualNotifyEvent\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeDriverLibDeconstruct (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Close SetVirtualAddressMap () notify function\r
+  //\r
+  if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
+    Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+EFIAPI\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if ExitBootService () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If ExitBootService () has been called\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r
+\r
+  return (BOOLEAN) (ReturnReg.r9 == 1);\r
+}\r
+\r
+BOOLEAN\r
+EFIAPI\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r
+\r
+  return (BOOLEAN) (ReturnReg.r9 == 1);\r
+}\r
+\r
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 (file)
index 0000000..d4010b2
--- /dev/null
@@ -0,0 +1,527 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  RuntimeService.c\r
+\r
+Abstract:\r
+\r
+  Runtime Lib\r
+\r
+--*/\r
+\r
+#include "..\RuntimeLibInternal.h"\r
+\r
+VOID\r
+EFIAPI\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;\r
+\r
+  EfiCallEsalService (\r
+    &Guid,\r
+    ResetSystem,\r
+    (UINT64) ResetType,\r
+    (UINT64) ResetStatus,\r
+    (UINT64) DataSize,\r
+    (UINT64) ResetData,\r
+    0,\r
+    0,\r
+    0\r
+    );\r
+}\r
+\r
+\r
+//\r
+// The following functions hide the mRT local global from the call to\r
+// runtime service in the EFI system table.\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device's\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor's variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalGetVariable,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                (UINT64) Attributes,\r
+                (UINT64) DataSize,\r
+                (UINT64) Data,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalGetNextVariableName,\r
+                (UINT64) VariableNameSize,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                0,\r
+                0,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor's variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalSetVariable,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                (UINT64) Attributes,\r
+                (UINT64) DataSize,\r
+                (UINT64) Data,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform's monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0);\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertPointer (\r
+  IN UINTN                  DebugDisposition,\r
+  IN OUT VOID               **Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT LIST_ENTRY       *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Conver the standard Lib double linked list to a virtual mapping.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)\r
+\r
+  ListHead         - Head of linked list to convert\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  LIST_ENTRY  *Link;\r
+  LIST_ENTRY  *NextLink;\r
+\r
+  //\r
+  // Convert all the ForwardLink & BackLink pointers in the list\r
+  //\r
+  Link = ListHead;\r
+  do {\r
+    NextLink = Link->ForwardLink;\r
+\r
+    EfiConvertPointer (\r
+      Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->ForwardLink\r
+      );\r
+\r
+    EfiConvertPointer (\r
+      Link->BackLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->BackLink\r
+      );\r
+\r
+    Link = NextLink;\r
+  } while (Link != ListHead);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Change the runtime addressing mode of EFI firmware from physical to virtual.\r
+\r
+  @param  MemoryMapSize         The size in bytes of VirtualMap.\r
+  @param  DescriptorSize        The size in bytes of an entry in the VirtualMap.\r
+  @param  DescriptorVersion     The version of the structure entries in VirtualMap.\r
+  @param  VirtualMap            An array of memory descriptors which contain new virtual\r
+                                address mapping information for all runtime ranges. Type\r
+                                EFI_MEMORY_DESCRIPTOR is defined in the\r
+                                GetMemoryMap() function description.\r
+\r
+  @retval EFI_SUCCESS           The virtual address map has been applied.\r
+  @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in\r
+                                virtual address mapped mode.\r
+  @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r
+                                invalid.\r
+  @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory\r
+                                map that requires a mapping.\r
+  @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found\r
+                                in the memory map.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiSetVirtualAddressMap (\r
+  IN UINTN                          MemoryMapSize,\r
+  IN UINTN                          DescriptorSize,\r
+  IN UINT32                         DescriptorVersion,\r
+  IN CONST EFI_MEMORY_DESCRIPTOR    *VirtualMap\r
+  )\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                SetVirtualAddress,\r
+                (UINT64) MemoryMapSize,\r
+                (UINT64) DescriptorSize,\r
+                (UINT64) DescriptorVersion,\r
+                (UINT64) VirtualMap,\r
+                0,\r
+                0,\r
+                0\r
+                );\r
+\r
+  return ReturnReg.Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiUpdateCapsule (\r
+  IN UEFI_CAPSULE_HEADER  **CapsuleHeaderArray,\r
+  IN UINTN                CapsuleCount,\r
+  IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryCapsuleCapabilities (\r
+  IN UEFI_CAPSULE_HEADER  **CapsuleHeaderArray,\r
+  IN UINTN                CapsuleCount,\r
+  OUT UINT64              *MaximumCapsuleSize,\r
+  OUT EFI_RESET_TYPE    *ResetType\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiQueryVariableInfo (\r
+  IN UINT32       Attributes,\r
+  OUT UINT64      *MaximumVariableStorageSize,\r
+  OUT  UINT64     *RemainingVariableStorageSize,\r
+  OUT UINT64      *MaximumVariableSize\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
new file mode 100644 (file)
index 0000000..925fc7b
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  RuntimeLibInternal.h\r
+\r
+Abstract:\r
+\r
+  Runtime Lib internal header file\r
+\r
+--*/\r
+\r
+#ifndef __RUNTIMELIBINTERNAL_H__\r
+#define __RUNTIMELIBINTERNAL_H__\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+extern EFI_RUNTIME_SERVICES   *mRT;\r
+\r
+#endif //__RUNTIMELIBINTERNAL_H__\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf
new file mode 100644 (file)
index 0000000..fabb4ed
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   EdkDxeSalLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    SAL library for BS/RT drivers\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueEdkDxeSalLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+  Ipf/EsalServiceLib.c\r
+  Ipf/AsmEsalServiceLib.s\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+\r
+[libraries.common]\r
+\r
+[libraries.ia32]\r
+              \r
+[libraries.x64]\r
+\r
+[libraries.ipf]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+  EdkProtocolLib\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
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 (file)
index 0000000..c5cb881
--- /dev/null
@@ -0,0 +1,149 @@
+//++\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    EsalLib.s\r
+//\r
+//  Abstract:\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+.file  "EsalLib.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//\r
+// Exports\r
+//\r
+.globl GetEsalEntryPoint\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// GetEsalEntryPoint\r
+//\r
+// Return Esal global and PSR register.\r
+//\r
+// On Entry :\r
+//\r
+//\r
+// Return Value:\r
+//        r8  = EFI_SAL_SUCCESS\r
+//        r9  = Physical Plabel\r
+//        r10 = Virtual Plabel\r
+//        r11 = psr\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (GetEsalEntryPoint)\r
+\r
+      NESTED_SETUP (0,8,0,0)\r
+\r
+EsalCalcStart:\r
+      mov   r8  = ip;;\r
+      add   r8  = (EsalEntryPoint - EsalCalcStart), r8;;\r
+      mov   r9  = r8;;\r
+      add   r10 = 0x10, r8;;\r
+      mov   r11 = psr;;\r
+      mov   r8  = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (GetEsalEntryPoint)\r
+\r
+\r
+\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// SetEsalPhysicalEntryPoint\r
+//\r
+// Set the dispatcher entry point\r
+//\r
+// On Entry:\r
+//  in0 = Physical address of Esal Dispatcher\r
+//  in1 = Physical GP\r
+//\r
+// Return Value: \r
+//   r8 = EFI_SAL_SUCCESS\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (SetEsalPhysicalEntryPoint)\r
+\r
+      NESTED_SETUP (2,8,0,0)\r
+\r
+EsalCalcStart1:\r
+      mov   r8   = ip;;\r
+      add   r8   = (EsalEntryPoint - EsalCalcStart1), r8;;\r
+      st8   [r8] = in0;;\r
+      add   r8   = 0x08, r8;;\r
+      st8   [r8] = in1;;\r
+      mov   r8   = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (SetEsalPhysicalEntryPoint)\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// SetEsalVirtualEntryPoint\r
+//\r
+// Register physical address of Esal globals.\r
+//\r
+// On Entry :\r
+//  in0 = Virtual address of Esal Dispatcher\r
+//  in1 = Virtual GP\r
+//\r
+// Return Value: \r
+//  r8 = EFI_SAL_ERROR\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (SetEsalVirtualEntryPoint)\r
+\r
+      NESTED_SETUP (2,8,0,0)\r
+\r
+EsalCalcStart2:\r
+      mov   r8   = ip;;\r
+      add   r8   = (EsalEntryPoint - EsalCalcStart2), r8;;\r
+      add   r8   = 0x10, r8;;\r
+      st8   [r8] = in0;;\r
+      add   r8   = 0x08, r8;;\r
+      st8   [r8] = in1;;\r
+      mov   r8   = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (SetEsalVirtualEntryPoint)\r
+\r
+\r
+\r
+\r
+.align 32\r
+EsalEntryPoint: \r
+    data8 0   // Physical Entry\r
+    data8 0   //         GP\r
+    data8 0   // Virtual Entry\r
+    data8 0   //         GP\r
+\r
+\r
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 (file)
index 0000000..377ac79
--- /dev/null
@@ -0,0 +1,288 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.           \r
+\r
+\r
+Module Name:\r
+\r
+  EsalServiceLib.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include <Ipf/IpfDefines.h>\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+EXTENDED_SAL_BOOT_SERVICE_PROTOCOL  *mEsalBootService = NULL;\r
+EFI_PLABEL                          mPlabel;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeSalLibInitialize (\r
+  VOID\r
+  )\r
+{\r
+  EFI_PLABEL  *Plabel;\r
+  EFI_STATUS  Status;\r
+\r
+  if (mEsalBootService != NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // The protocol contains a function pointer, which is an indirect procedure call.\r
+  // An indirect procedure call goes through a plabel, and pointer to a function is\r
+  // a pointer to a plabel. To implement indirect procedure calls that can work in\r
+  // both physical and virtual mode, two plabels are required (one physical and one\r
+  // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r
+  // away. We cache it in a module global, so we can register the vitrual version.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);\r
+  if (EFI_ERROR (Status)) {\r
+    mEsalBootService = NULL;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Plabel              = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r
+\r
+  mPlabel.EntryPoint  = Plabel->EntryPoint;\r
+  mPlabel.GP          = Plabel->GP;\r
+  SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DxeSalLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  return DxeSalLibInitialize ();\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+DxeSalVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup virtual address pointer of label.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EfiConvertPointer (0x0, (VOID **) &mPlabel.EntryPoint);\r
+  EfiConvertPointer (EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);\r
+\r
+  SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class Function and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  FunctionId    - ID of function to register\r
+  ClassGuid     - GUID of function class \r
+  Function      - Function to register under ClassGuid/FunctionId pair\r
+  ModuleGlobal  - Module global for Function.\r
+\r
+Returns: \r
+  EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r
+\r
+--*/\r
+{\r
+  DxeSalLibInitialize ();\r
+  return mEsalBootService->AddExtendedSalProc (\r
+                            mEsalBootService,\r
+                            ClassGuid,\r
+                            FunctionId,\r
+                            Function,\r
+                            ModuleGlobal\r
+                            );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterEsalClass (\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  VOID                                      *ModuleGlobal,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  ClassGuid     - GUID of function class \r
+  ModuleGlobal  - Module global for Function.\r
+  ...           - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r
+                  indicates the end of the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS - All members of ClassGuid registered\r
+\r
+--*/\r
+{\r
+  VA_LIST                         Args;\r
+  EFI_STATUS                      Status;\r
+  SAL_INTERNAL_EXTENDED_SAL_PROC  Function;\r
+  UINT64                          FunctionId;\r
+  EFI_HANDLE                      NewHandle;\r
+\r
+  VA_START (Args, ModuleGlobal);\r
+\r
+  Status = EFI_SUCCESS;\r
+  while (!EFI_ERROR (Status)) {\r
+    Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);\r
+    if (Function == NULL) {\r
+      break;\r
+    }\r
+\r
+    FunctionId  = VA_ARG (Args, UINT64);\r
+\r
+    Status      = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  NewHandle = NULL;\r
+  return gBS->InstallProtocolInterface (\r
+                &NewHandle,\r
+                ClassGuid,\r
+                EFI_NATIVE_INTERFACE,\r
+                NULL\r
+                );\r
+}\r
+\r
+SAL_RETURN_REGS\r
+EFIAPI\r
+EfiCallEsalService (\r
+  IN  EFI_GUID                                      *ClassGuid,\r
+  IN  UINT64                                        FunctionId,\r
+  IN  UINT64                                        Arg2,\r
+  IN  UINT64                                        Arg3,\r
+  IN  UINT64                                        Arg4,\r
+  IN  UINT64                                        Arg5,\r
+  IN  UINT64                                        Arg6,\r
+  IN  UINT64                                        Arg7,\r
+  IN  UINT64                                        Arg8\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call module that is not linked direclty to this module. This code is IP \r
+  relative and hides the binding issues of virtual or physical calling. The\r
+  function that gets dispatched has extra arguments that include the registered\r
+  module global and a boolean flag to indicate if the system is in virutal mode.\r
+\r
+Arguments:\r
+  ClassGuid   - GUID of function\r
+  FunctionId  - Function in ClassGuid to call\r
+  Arg2        - Argument 2 ClassGuid/FunctionId defined\r
+  Arg3        - Argument 3 ClassGuid/FunctionId defined\r
+  Arg4        - Argument 4 ClassGuid/FunctionId defined\r
+  Arg5        - Argument 5 ClassGuid/FunctionId defined\r
+  Arg6        - Argument 6 ClassGuid/FunctionId defined\r
+  Arg7        - Argument 7 ClassGuid/FunctionId defined\r
+  Arg8        - Argument 8 ClassGuid/FunctionId defined\r
+\r
+Returns: \r
+  Status of ClassGuid/FuncitonId\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS       ReturnReg;\r
+  SAL_EXTENDED_SAL_PROC EsalProc;\r
+\r
+  ReturnReg = GetEsalEntryPoint ();\r
+  if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r
+    return ReturnReg;\r
+  }\r
+\r
+  //\r
+  // Look at the physical mode ESAL entry point to determine of the ESAL entry point has been initialized\r
+  //\r
+  if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
+    //\r
+    // Both the function ponter and the GP value are zero, so attempt to initialize the ESAL Entry Point\r
+    //\r
+    DxeSalLibInitialize ();\r
+    ReturnReg = GetEsalEntryPoint ();\r
+    if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r
+      return ReturnReg;\r
+    }\r
+    if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) {\r
+      //\r
+      // The ESAL Entry Point could not be initialized\r
+      //\r
+      ReturnReg.Status = EFI_SAL_ERROR;\r
+      return ReturnReg;\r
+    }\r
+  }\r
+\r
+  if (ReturnReg.r11 & PSR_IT_MASK) {\r
+    //\r
+    // Virtual mode plabel to entry point\r
+    //\r
+    EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10;\r
+  } else {\r
+    //\r
+    // Physical mode plabel to entry point\r
+    //\r
+    EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9;\r
+  }\r
+\r
+  return EsalProc (\r
+          ClassGuid,\r
+          FunctionId,\r
+          Arg2,\r
+          Arg3,\r
+          Arg4,\r
+          Arg5,\r
+          Arg6,\r
+          Arg7,\r
+          Arg8\r
+          );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
new file mode 100644 (file)
index 0000000..e0f7be0
--- /dev/null
@@ -0,0 +1,70 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  HiiLib.c\r
+  \r
+Abstract: \r
+\r
+  HII Library implementation that uses DXE protocols and services.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+/**\r
+  This function allocates pool for an EFI_HII_PACKAGES structure\r
+  with enough space for the variable argument list of package pointers.\r
+  The allocated structure is initialized using NumberOfPackages, Guid, \r
+  and the variable length argument list of package pointers.\r
+\r
+  @param  NumberOfPackages The number of HII packages to prepare.\r
+  @param  Guid Package GUID.\r
+\r
+  @return The allocated and initialized packages.\r
+\r
+**/\r
+EFI_HII_PACKAGES *\r
+EFIAPI\r
+GluePreparePackages (\r
+  IN UINTN           NumberOfPackages,\r
+  IN CONST EFI_GUID  *Guid OPTIONAL,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST           Args;\r
+  EFI_HII_PACKAGES  *HiiPackages;\r
+  VOID              **Package;\r
+  UINTN             Index;\r
+\r
+  ASSERT (NumberOfPackages > 0);\r
+\r
+  HiiPackages                   = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));\r
+  ASSERT (HiiPackages != NULL);\r
+\r
+  HiiPackages->GuidId           = (EFI_GUID *) Guid;\r
+  HiiPackages->NumberOfPackages = NumberOfPackages;\r
+  Package                       = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));\r
+\r
+  VA_START (Args, Guid);\r
+\r
+  for (Index = 0; Index < NumberOfPackages; Index++) {\r
+    *Package = VA_ARG (Args, VOID *);\r
+    Package++;\r
+  }\r
+\r
+  VA_END (Args);\r
+\r
+  return HiiPackages;\r
+\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf
new file mode 100644 (file)
index 0000000..102cd86
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   HiiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for HiiLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueHiiLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  HiiLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueDxeMemoryAllocationLib\r
+  EfiProtocolLib\r
+\r
+[libraries.ia32]\r
+\r
+[libraries.x64]\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
new file mode 100644 (file)
index 0000000..d21e517
--- /dev/null
@@ -0,0 +1,296 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.   \r
+\r
+\r
+Module Name:\r
+\r
+  DebugLib.c\r
+  \r
+Abstract: \r
+\r
+  Debug Library that fowards all messages to ReportStatusCode()\r
+  \r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+/**\r
+\r
+  Prints a debug message to the debug output device if the specified error level is enabled.\r
+\r
+  If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r
+  the message specified by Format and the associated variable argument list to \r
+  the debug output device.\r
+\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  ErrorLevel  The error level of the debug message.\r
+  @param  Format      Format string for the debug message to print.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugPrint (\r
+  IN  UINTN        ErrorLevel,\r
+  IN  CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+{\r
+  UINT64          Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+  UINTN           TotalSize;\r
+  UINTN           Index;\r
+  VA_LIST         Marker;\r
+  UINT64          *ArgumentPointer;\r
+\r
+  //\r
+  // If Format is NULL, then ASSERT().\r
+  //\r
+  ASSERT (Format != NULL);\r
+\r
+  //\r
+  // Check driver Debug Level value and global debug level\r
+  //\r
+  if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {\r
+    return;\r
+  }\r
+\r
+  TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1;\r
+  if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Then EFI_DEBUG_INFO\r
+  //\r
+  DebugInfo = (EFI_DEBUG_INFO *)Buffer;\r
+  DebugInfo->ErrorLevel = (UINT32)ErrorLevel;\r
+\r
+  //\r
+  // 256 byte mini Var Arg stack. That is followed by the format string.\r
+  //\r
+  VA_START (Marker, Format);\r
+  for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) {\r
+    WriteUnaligned64(ArgumentPointer, VA_ARG (Marker, UINT64));\r
+  }\r
+  VA_END (Marker);\r
+  AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format);\r
+\r
+  REPORT_STATUS_CODE_EX (\r
+    EFI_DEBUG_CODE,\r
+    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r
+    0,\r
+    NULL,\r
+    &gEfiStatusCodeDataTypeDebugGuid,\r
+    DebugInfo,\r
+    TotalSize\r
+    );\r
+}\r
+\r
+\r
+/**\r
+\r
+  Prints an assert message containing a filename, line number, and description.  \r
+  This may be followed by a breakpoint or a dead loop.\r
+\r
+  Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" \r
+  to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of \r
+  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if \r
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then \r
+  CpuDeadLoop() is called.  If neither of these bits are set, then this function \r
+  returns immediately after the message is printed to the debug output device.\r
+  DebugAssert() must actively prevent recusrsion.  If DebugAssert() is called while\r
+  processing another DebugAssert(), then DebugAssert() must return immediately.\r
+\r
+  If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r
+\r
+  If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r
+\r
+  @param  FileName     Pointer to the name of the source file that generated the assert condition.\r
+  @param  LineNumber   The line number in the source file that generated the assert condition\r
+  @param  Description  Pointer to the description of the assert condition.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DebugAssert (\r
+  IN CONST CHAR8  *FileName,\r
+  IN UINTN        LineNumber,\r
+  IN CONST CHAR8  *Description\r
+  )\r
+{\r
+  UINT64                 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];\r
+  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
+  UINTN                  TotalSize;\r
+  CHAR8                  *Temp;\r
+  UINTN                  FileNameLength;\r
+  UINTN                  DescriptionLength;\r
+\r
+  //\r
+  // Make sure it will all fit in the passed in buffer\r
+  //\r
+  FileNameLength    = AsciiStrLen (FileName);\r
+  DescriptionLength = AsciiStrLen (Description);\r
+  TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1;\r
+  if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+    //\r
+    // Fill in EFI_DEBUG_ASSERT_DATA\r
+    //\r
+    AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;\r
+    AssertData->LineNumber = (UINT32)LineNumber;\r
+\r
+    //\r
+    // Copy Ascii FileName including NULL.\r
+    //\r
+    Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName);\r
+\r
+    //\r
+    // Copy Ascii Description \r
+    //\r
+    AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description);\r
+\r
+    REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
+      (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
+      (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
+      AssertData,\r
+      TotalSize\r
+      );\r
+  }\r
+\r
+  //\r
+  // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
+  //\r
+  if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r
+    CpuBreakpoint ();\r
+  } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r
+    CpuDeadLoop ();\r
+  }\r
+}\r
+\r
+\r
+/**\r
+\r
+  Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
+\r
+  This function fills Length bytes of Buffer with the value specified by \r
+  PcdDebugClearMemoryValue, and returns Buffer.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param   Buffer  Pointer to the target buffer to fill with PcdDebugClearMemoryValue.\r
+  @param   Length  Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r
+\r
+  @return  Buffer\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+DebugClearMemory (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  //\r
+  // If Buffer is NULL, then ASSERT().\r
+  //\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // SetMem() checks for the the ASSERT() condition on Length and returns Buffer\r
+  //\r
+  return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if ASSERT() macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugAssertEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugPrintEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CODE()macros are enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  \r
+  Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.\r
+\r
+  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of \r
+  PcdDebugProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DebugClearMemoryEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
new file mode 100644 (file)
index 0000000..270f7f6
--- /dev/null
@@ -0,0 +1,89 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiDxeDebugLibReportStatusCode.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiDxeDebugLibReportStatusCode.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiDxeDebugLibReportStatusCode\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  DebugLib.c\r
\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueBaseMemoryLib\r
+#\r
+# R8.x\r
+#\r
+  EdkFrameworkGuidLib\r
+#\r
+#\r
+# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf\r
+#\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf
new file mode 100644 (file)
index 0000000..9b346dd
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiDxePostCodeLibReportStatusCode.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiDxePostCodeLibReportStatusCode.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiDxePostCodeLibReportStatusCode\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PostCode.c\r
\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+#\r
+# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf\r
+#\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
new file mode 100644 (file)
index 0000000..62fde35
--- /dev/null
@@ -0,0 +1,160 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.   \r
+  \r
+  \r
+Module Name:\r
+\r
+  PostCode.c\r
+  \r
+Abstract: \r
+\r
+  Post Code Lib\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueDxe.h"\r
+\r
+/**\r
+  Converts POST code value to status code value.\r
+\r
+  This macro converts the post code to status code value. Bits 0..4 of PostCode \r
+  are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits \r
+  24..26 of status code value.  \r
+\r
+  @param  PostCode  POST code value. \r
+\r
+  @return The converted status code value.\r
+\r
+**/\r
+#define POST_CODE_TO_STATUS_CODE_VALUE(PostCode)  \\r
+  ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19)))\r
+\r
+/**\r
+  Sends an 32-bit value to a POST card.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.  \r
+  Some implementations of this library function may perform I/O operations \r
+  directly to a POST card device.  Other implementations may send Value to \r
+  ReportStatusCode(), and the status code reporting mechanism will eventually \r
+  display the 32-bit value on the status reporting device.\r
+  \r
+  PostCode() must actively prevent recursion.  If PostCode() is called while \r
+  processing another any other Report Status Code Library function, then \r
+  PostCode() must return Value immediately.\r
+\r
+  @param  Value  The 32-bit value to write to the POST card.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCode (\r
+  IN UINT32  Value\r
+  )\r
+{\r
+  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value));\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Sends an 32-bit value to a POST and associated ASCII string.\r
+\r
+  Sends the 32-bit value specified by Value to a POST card, and returns Value.\r
+  If Description is not NULL, then the ASCII string specified by Description is \r
+  also passed to the handler that displays the POST card value.  Some \r
+  implementations of this library function may perform I/O operations directly \r
+  to a POST card device.  Other implementations may send Value to ReportStatusCode(), \r
+  and the status code reporting mechanism will eventually display the 32-bit \r
+  value on the status reporting device.  \r
+\r
+  PostCodeWithDescription()must actively prevent recursion.  If \r
+  PostCodeWithDescription() is called while processing another any other Report \r
+  Status Code Library function, then PostCodeWithDescription() must return Value \r
+  immediately.\r
+\r
+  @param  Value        The 32-bit value to write to the POST card.\r
+  @param  Description  Pointer to an ASCII string that is a description of the \r
+                       POST code value.  This is an optional parameter that may \r
+                       be NULL.\r
+\r
+  @return  Value\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+GluePostCodeWithDescription (\r
+  IN UINT32       Value,\r
+  IN CONST CHAR8  *Description  OPTIONAL\r
+  )\r
+{\r
+  if (Description == NULL) { \r
+    REPORT_STATUS_CODE (\r
+      EFI_PROGRESS_CODE,\r
+      POST_CODE_TO_STATUS_CODE_VALUE (Value)\r
+      );\r
+  } else {\r
+    REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
+      EFI_PROGRESS_CODE,\r
+      POST_CODE_TO_STATUS_CODE_VALUE (Value),\r
+      Description,\r
+      AsciiStrSize (Description)\r
+      );\r
+  }\r
+\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST Codes are enabled.\r
+\r
+  This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+  bit of PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+                  PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if POST code descriptions are enabled.\r
+\r
+  This function returns TRUE if the \r
+  POST_CODE_PROPERTY_POST_CODE_ENABLED bit of \r
+  PcdPostCodePropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is set.\r
+  @retval  FALSE  The POST_CODE_PROPERTY_POST_CODE_ENABLED \r
+                  bit of PcdPostCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GluePostCodeDescriptionEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
new file mode 100644 (file)
index 0000000..55b7242
--- /dev/null
@@ -0,0 +1,573 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  HobLib.c\r
+  \r
+Abstract: \r
+\r
+  HOB Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  Returns the pointer to the HOB list.\r
+\r
+  This function returns the pointer to first HOB in the list.\r
+\r
+  @return The pointer to the HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetHobList (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  VOID                  *HobList;\r
+\r
+  Status = PeiServicesGetHobList (&HobList);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (HobList != NULL);\r
+\r
+  return HobList;\r
+}\r
+\r
+/**\r
+  Returns the next instance of a HOB type from the starting HOB.\r
+\r
+  This function searches the first instance of a HOB type from the starting HOB pointer. \r
+  If there does not exist such HOB type from the starting HOB pointer, it will return NULL.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Type          The HOB type to return.\r
+  @param  HobStart      The starting HOB pointer to search from.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetNextHob (\r
+  IN UINT16                 Type,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  ASSERT (HobStart != NULL);\r
+   \r
+  Hob.Raw = (UINT8 *) HobStart;\r
+  //\r
+  // Parse the HOB list until end of list or matching type is found.\r
+  //\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+    if (Hob.Header->HobType == Type) {\r
+      return Hob.Raw;\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Returns the first instance of a HOB type among the whole HOB list.\r
+\r
+  This function searches the first instance of a HOB type among the whole HOB list. \r
+  If there does not exist such HOB type in the HOB list, it will return NULL. \r
+\r
+  @param  Type          The HOB type to return.\r
+\r
+  @return The next instance of a HOB type from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GetFirstHob (\r
+  IN UINT16                 Type\r
+  )\r
+{\r
+  VOID      *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  return GetNextHob (Type, HobList);\r
+}\r
+\r
+/**\r
+  This function searches the first instance of a HOB from the starting HOB pointer. \r
+  Such HOB should satisfy two conditions: \r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
+  If Guid is NULL, then ASSERT().\r
+  If HobStart is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+  @param  HobStart      A pointer to a Guid.\r
+\r
+  @return The next instance of the matched GUID HOB from the starting HOB.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetNextGuidHob (\r
+  IN CONST EFI_GUID         *Guid,\r
+  IN CONST VOID             *HobStart\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  GuidHob.Raw = (UINT8 *) HobStart;\r
+  while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {\r
+    if (CompareGuid (Guid, &GuidHob.Guid->Name)) {\r
+      break;\r
+    }\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+  return GuidHob.Raw;\r
+}\r
+\r
+/**\r
+  This function searches the first instance of a HOB among the whole HOB list. \r
+  Such HOB should satisfy two conditions:\r
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
+  to extract the data section and its size info respectively.\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  Guid          The GUID to match with in the HOB list.\r
+\r
+  @return The first instance of the matched GUID HOB among the whole HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueGetFirstGuidHob (\r
+  IN CONST EFI_GUID         *Guid\r
+  )\r
+{\r
+  VOID      *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  return GetNextGuidHob (Guid, HobList);\r
+}\r
+\r
+/**\r
+  Get the Boot Mode from the HOB list.\r
+\r
+  This function returns the system boot mode information from the \r
+  PHIT HOB in HOB list.\r
+\r
+  @param  VOID\r
+\r
+  @return The Boot Mode.\r
+\r
+**/\r
+EFI_BOOT_MODE\r
+EFIAPI\r
+GetBootModeHob (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS             Status;\r
+  EFI_BOOT_MODE          BootMode;\r
+\r
+  Status = PeiServicesGetBootMode (&BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return BootMode;\r
+}\r
+\r
+/**\r
+  Adds a new HOB to the HOB List.\r
+\r
+  This internal function enables PEIMs to create various types of HOBs.\r
+\r
+  @param  Type          Type of the new HOB.\r
+  @param  Length        Length of the new HOB to allocate.\r
+\r
+  @return The address of new HOB.\r
+\r
+**/\r
+STATIC\r
+VOID *\r
+InternalPeiCreateHob (\r
+  IN UINT16                      Type,\r
+  IN UINT16                      Length\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  VOID              *Hob;\r
+\r
+  Status = PeiServicesCreateHob (Type, Length, &Hob);\r
+  //\r
+  // Assume the process of HOB building is always successful.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Hob;\r
+}\r
+\r
+/**\r
+  Builds a HOB for a loaded PE32 module.\r
+\r
+  This function builds a HOB for a loaded PE32 module.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If ModuleName is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ModuleName              The GUID File Name of the module.\r
+  @param  MemoryAllocationModule  The 64 bit physical address of the module.\r
+  @param  ModuleLength            The length of the module in bytes.\r
+  @param  EntryPoint              The 64 bit physical address of the module's entry point.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildModuleHob (\r
+  IN CONST EFI_GUID         *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+{\r
+  EFI_HOB_MEMORY_ALLOCATION_MODULE  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
+\r
+  CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r
+  Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
+  Hob->MemoryAllocationHeader.MemoryLength      = ModuleLength;\r
+  Hob->MemoryAllocationHeader.MemoryType        = EfiBootServicesCode;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));\r
+  \r
+  CopyGuid (&Hob->ModuleName, ModuleName);\r
+  Hob->EntryPoint = EntryPoint;\r
+}\r
+\r
+/**\r
+  Builds a HOB that describes a chunk of system memory.\r
+\r
+  This function builds a HOB that describes a chunk of system memory.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  ResourceType        The type of resource described by this HOB.\r
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.\r
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.\r
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildResourceDescriptorHob (\r
+  IN EFI_RESOURCE_TYPE            ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
+  IN UINT64                       NumberOfBytes\r
+  )\r
+{\r
+  EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
+\r
+  Hob->ResourceType      = ResourceType;\r
+  Hob->ResourceAttribute = ResourceAttribute;\r
+  Hob->PhysicalStart     = PhysicalStart;\r
+  Hob->ResourceLength    = NumberOfBytes;\r
+}\r
+\r
+/**\r
+  Builds a GUID HOB with a certain data length.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification \r
+  and returns the start address of GUID HOB data so that caller can fill the customized data. \r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN UINTN                       DataLength\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE *Hob;\r
+\r
+  //\r
+  // Make sure that data length is not too long.\r
+  //\r
+  ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));\r
+  CopyGuid (&Hob->Name, Guid);\r
+  return Hob + 1;\r
+}\r
+\r
+/**\r
+  Copies a data buffer to a newly-built HOB.\r
+\r
+  This function builds a customized HOB tagged with a GUID for identification,\r
+  copies the input data to the HOB data field and returns the start address of the GUID HOB data.\r
+  The HOB Header and Name field is already stripped.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If Guid is NULL, then ASSERT().\r
+  If Data is NULL and DataLength > 0, then ASSERT().\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
+\r
+  @param  Guid          The GUID to tag the customized HOB.\r
+  @param  Data          The data to be copied into the data field of the GUID HOB.\r
+  @param  DataLength    The size of the data payload for the GUID HOB.\r
+\r
+  @return The start address of GUID HOB data.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+BuildGuidDataHob (\r
+  IN CONST EFI_GUID              *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+{\r
+  VOID  *HobData;\r
+\r
+  ASSERT (Data != NULL || DataLength == 0);\r
+\r
+  HobData = BuildGuidHob (Guid, DataLength);\r
+\r
+  return CopyMem (HobData, Data, DataLength);\r
+}\r
+\r
+/**\r
+  Builds a Firmware Volume HOB.\r
+\r
+  This function builds a Firmware Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Firmware Volume.\r
+  @param  Length        The size of the Firmware Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildFvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  EFI_HOB_FIRMWARE_VOLUME  *Hob;\r
+\r
+  //\r
+  // Check FV Signature\r
+  //\r
+  ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
+\r
+  Hob->BaseAddress = BaseAddress;\r
+  Hob->Length      = Length;\r
+}\r
+\r
+/**\r
+  Builds a Capsule Volume HOB.\r
+\r
+  This function builds a Capsule Volume HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Capsule Volume.\r
+  @param  Length        The size of the Capsule Volume in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  EFI_HOB_CAPSULE_VOLUME  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME));\r
+\r
+  Hob->BaseAddress  = BaseAddress;\r
+  Hob->Length       = Length;\r
+}\r
+\r
+/**\r
+  Builds a HOB for the CPU.\r
+\r
+  This function builds a HOB for the CPU.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.\r
+  @param  SizeOfIoSpace       The maximum physical I/O addressability of the processor.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildCpuHob (\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+{\r
+  EFI_HOB_CPU  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r
+\r
+  Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
+  Hob->SizeOfIoSpace     = SizeOfIoSpace;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); \r
+}\r
+\r
+/**\r
+  Builds a HOB for the Stack.\r
+\r
+  This function builds a HOB for the stack.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the Stack.\r
+  @param  Length        The length of the stack in bytes.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildStackHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+{\r
+  EFI_HOB_MEMORY_ALLOCATION_STACK  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
+\r
+  CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength      = Length;\r
+  Hob->AllocDescriptor.MemoryType        = EfiConventionalMemory;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
+}\r
+\r
+/**\r
+  Builds a HOB for the BSP store.\r
+\r
+  This function builds a HOB for BSP store.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the BSP.\r
+  @param  Length        The length of the BSP store in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BuildBspStoreHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+{\r
+  EFI_HOB_MEMORY_ALLOCATION_BSP_STORE  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
+\r
+  CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength      = Length;\r
+  Hob->AllocDescriptor.MemoryType        = MemoryType;\r
+\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
+}\r
+\r
+/**\r
+  Builds a HOB for the memory allocation.\r
+\r
+  This function builds a HOB for the memory allocation.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The 64 bit physical address of the memory.\r
+  @param  Length        The length of the memory allocation in bytes.\r
+  @param  MemoryType    Type of memory allocated by this HOB.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueBuildMemoryAllocationHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+{\r
+  EFI_HOB_MEMORY_ALLOCATION  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
+\r
+  ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength      = Length;\r
+  Hob->AllocDescriptor.MemoryType        = MemoryType;\r
+  //\r
+  // Zero the reserved space to match HOB spec\r
+  //\r
+  ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf
new file mode 100644 (file)
index 0000000..0ec70a3
--- /dev/null
@@ -0,0 +1,83 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiHobLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiHobLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiHobLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  HobLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGluePeiServicesLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
new file mode 100644 (file)
index 0000000..b85575b
--- /dev/null
@@ -0,0 +1,1080 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  MemoryAllocationLib.c\r
+  \r
+Abstract: \r
+\r
+  Support routines for memory allocation routines for use with drivers.\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type.\r
+\r
+  Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+  buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Memory; \r
+  EFI_PEI_SERVICES      **PeiServices;\r
+\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  Status = ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, &Memory);\r
+  if (EFI_ERROR (Status)) {\r
+    Memory = 0;\r
+  }\r
+  return (VOID *) (UINTN) Memory;\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiBootServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+  functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
\r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  //\r
+  // PEI phase does not support to free pages, so leave it as NOP.\r
+  //\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+  NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID    *Memory;\r
+  UINTN   AlignmentMask;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+  //\r
+  ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));\r
+  //\r
+  // We would rather waste some memory to save PEI code size.\r
+  //\r
+  Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment));\r
+  if (Alignment == 0) {\r
+    AlignmentMask = Alignment;\r
+  } else {\r
+    AlignmentMask = Alignment - 1;  \r
+  }\r
+  return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+  allocation functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+  Allocation Library.\r
+  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
+  \r
+  @param  Buffer                Pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  //\r
+  // PEI phase does not support to free pages, so leave it as NOP.\r
+  //\r
+}\r
+\r
+/**\r
+  Allocates a buffer of a certain pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            AllocationSize\r
+  )\r
+{\r
+  //\r
+  // If we need lots of small runtime/reserved memory type from PEI in the future, \r
+  // we can consider providing a more complex algorithm that allocates runtime pages and \r
+  // provide pool allocations from those pages. \r
+  //\r
+  return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize));\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocatePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  VOID              *Buffer;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+\r
+  Status = ((*PeiServices)->AllocatePool) (PeiServices, AllocationSize, &Buffer);\r
+  if (EFI_ERROR (Status)) {\r
+    Buffer = NULL;\r
+  }\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of a certian pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+  with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the request,\r
+  then NULL is returned.\r
+\r
+  @param  PoolType              The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = AllocatePool (AllocationSize);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize,\r
+  IN CONST VOID       *Buffer\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+} \r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+GlueAllocateCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  VOID  *Memory;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = AllocatePool (AllocationSize);\r
+  if (Memory != NULL) {\r
+     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+  Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueFreePool (\r
+  IN VOID   *Buffer\r
+  )\r
+{\r
+  //\r
+  // PEI phase does not support to free pool, so leave it as NOP.\r
+  //\r
+}\r
+\r
+/**\r
+  Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining\r
+  to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.                            If Alignment is zero, then byte alignment is used.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID    *RawAddress;\r
+  UINTN   AlignedAddress;\r
+  UINTN   AlignmentMask;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+  \r
+  if (Alignment == 0) {\r
+    AlignmentMask = Alignment;\r
+  } else {\r
+    AlignmentMask = Alignment - 1;\r
+  }\r
+  //\r
+  // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+  //\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
+\r
+  RawAddress      = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);\r
+  \r
+  AlignedAddress  = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
+    \r
+  return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  VOID    *RawAddress;\r
+  UINTN   AlignedAddress;\r
+  UINTN   AlignmentMask;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
+\r
+  if (Alignment == 0) {\r
+    AlignmentMask = Alignment;\r
+  } else {\r
+    AlignmentMask = Alignment - 1;\r
+  }\r
+\r
+  //\r
+  // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+  //\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
+\r
+  RawAddress      = AllocatePool (AllocationSize + AlignmentMask);\r
+  \r
+  AlignedAddress  = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
+    \r
+  return (VOID *) AlignedAddress;\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+  buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there is not\r
+  enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID    *Memory;\r
+\r
+  Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  VOID    *Memory;\r
+\r
+  Memory = AllocateAlignedPool (AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an\r
+  alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory at the specified alignment remaining to satisfy the request, then NULL is\r
+  returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedZeroPool (\r
+  IN UINTN  AllocationSize,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining\r
+  to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,\r
+  IN UINTN            AllocationSize,\r
+  IN CONST VOID       *Buffer,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  VOID  *Memory;\r
+  \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  VOID  *Memory;\r
+  \r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = AllocateAlignedPool (AllocationSize, Alignment);\r
+  if (Memory != NULL) {\r
+    Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0,\r
+  then a valid buffer of 0 size is returned.  If there is not enough memory at the specified\r
+  alignment remaining to satisfy the request, then NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer,\r
+  IN UINTN       Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);\r
+}\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the aligned pool allocation functions \r
+  in the Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  aligned pool allocation services of the Memory Allocation Library.\r
+  If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+\r
+  @param  Buffer                Pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPool (\r
+  IN VOID   *Buffer\r
+  )\r
+{\r
+  //\r
+  // PEI phase does not support to free pool, so leave it as NOP.\r
+  //\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
new file mode 100644 (file)
index 0000000..8cfa7f1
--- /dev/null
@@ -0,0 +1,87 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiMemoryAllocationLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiMemoryAllocationLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiMemoryAllocationLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  MemoryAllocationLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+# If necessary, EdkIIGluePeiSerivcesTablePointerLib can be used to \r
+# replaced EdkIIGluePeiServicesTablePointerLibMm7\r
+#  \r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
new file mode 100644 (file)
index 0000000..a60f1b2
--- /dev/null
@@ -0,0 +1,108 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiReportStatusCodeLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiReportStatusCodeLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiReportStatusCodeLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  ReportStatusCodeLib.c\r
+\r
+[sources.ia32]\r
+  \r
+\r
+[sources.x64]\r
+  \r
+\r
+[sources.ipf]\r
+  \r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueBaseIoLibIntrinsic\r
+  EdkFrameworkGuidLib\r
+# Possibly, gEfiCallerIdGuid might be used.\r
+  EdkGuidLib\r
+\r
+[libraries.ia32]\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be used\r
+# to replace EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+  \r
+\r
+[libraries.x64]\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be used\r
+# to replace EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+\r
+[libraries.ipf]\r
+  EdkIIGluePeiServicesTablePointerLibKr1\r
+#\r
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be used\r
+# to replace EdkIIGluePeiServicesTablePointerLibKr1\r
+#\r
+\r
+[libraries.ebc]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
new file mode 100644 (file)
index 0000000..5b62746
--- /dev/null
@@ -0,0 +1,527 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  ReportStatusCodeLib.c\r
+  \r
+Abstract: \r
+\r
+  Report Status Code Lib\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+//\r
+// Define the maximum extended data size that is supported in the PEI phase\r
+//\r
+#define MAX_EXTENDED_DATA_SIZE  0x200\r
+\r
+/**\r
+  Internal worker function that reports a status code through the Status Code Protocol\r
+\r
+  This function checks to see if a Status Code Protocol is present in the handle \r
+  database.  If a Status Code Protocol is not present, then EFI_UNSUPPORTED is \r
+  returned.  If a Status Code Protocol is present, then it is cached in gStatusCode,\r
+  and the ReportStatusCode() service of the Status Code Protocol is called passing in\r
+  Type, Value, Instance, CallerId, and Data.  The result of this call is returned.\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  This is an optional parameter that may be \r
+                            NULL.\r
+  @param  Data              Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to report the status code.\r
+  @retval  EFI_UNSUPPORTED       Status Code Protocol is not available.\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+InternalReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->PeiReportStatusCode (\r
+                           PeiServices,\r
+                           Type,\r
+                           Value,\r
+                           Instance,\r
+                           (EFI_GUID *)CallerId,\r
+                           Data\r
+                           );\r
+}\r
+\r
+\r
+/**\r
+  Converts a status code to an 8-bit POST code value.\r
+\r
+  Converts the status code specified by CodeType and Value to an 8-bit POST code \r
+  and returns the 8-bit POST code in PostCode.  If CodeType is an \r
+  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode \r
+  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits \r
+  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.  \r
+\r
+  If PostCode is NULL, then ASSERT().\r
+\r
+  @param  CodeType  The type of status code being converted.\r
+  @param  Value     The status code value being converted.\r
+  @param  PostCode  A pointer to the 8-bit POST code value to return. \r
+\r
+  @retval  TRUE   The status code specified by CodeType and Value was converted \r
+                  to an 8-bit POST code and returned in  PostCode.\r
+  @retval  FALSE  The status code specified by CodeType and Value could not be \r
+                  converted to an 8-bit POST code value.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueCodeTypeToPostCode (\r
+  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
+  IN  EFI_STATUS_CODE_VALUE  Value,\r
+  OUT UINT8                  *PostCode\r
+  )\r
+{\r
+  //\r
+  // If PostCode is NULL, then ASSERT()\r
+  //\r
+  ASSERT (PostCode != NULL);\r
+\r
+  //\r
+  // Convert Value to an 8 bit post code\r
+  //\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
+      ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {\r
+    *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
+                          (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Extracts ASSERT() information from a status code structure.\r
+\r
+  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
+  arguments specified by Filename, Description, and LineNumber.  If CodeType is \r
+  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r
+  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r
+  Filename, Description, and LineNumber from the optional data area of the \r
+  status code buffer specified by Data.  The optional data area of Data contains \r
+  a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r
+  ASCII string for the Description, followed by a 32-bit LineNumber.  If the \r
+  ASSERT() information could be extracted from Data, then return TRUE.  \r
+  Otherwise, FALSE is returned.  \r
+\r
+  If Data is NULL, then ASSERT().\r
+  If Filename is NULL, then ASSERT().\r
+  If Description is NULL, then ASSERT().\r
+  If LineNumber is NULL, then ASSERT().\r
+\r
+  @param  CodeType     The type of status code being converted.\r
+  @param  Value        The status code value being converted.\r
+  @param  Data         Pointer to status code data buffer. \r
+  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
+  @param  Description  Pointer to the description of the ASSERT().\r
+  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
+\r
+  @retval  TRUE   The status code specified by CodeType, Value, and Data was \r
+                  converted ASSERT() arguments specified by Filename, Description, \r
+                  and LineNumber.\r
+  @retval  FALSE  The status code specified by CodeType, Value, and Data could \r
+                  not be converted to ASSERT() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE        CodeType,\r
+  IN EFI_STATUS_CODE_VALUE       Value,  \r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT CHAR8                      **Filename,\r
+  OUT CHAR8                      **Description,\r
+  OUT UINT32                     *LineNumber\r
+  )\r
+{\r
+  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
+\r
+  ASSERT (Data        != NULL);\r
+  ASSERT (Filename    != NULL);\r
+  ASSERT (Description != NULL);\r
+  ASSERT (LineNumber  != NULL);\r
+\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) && \r
+      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&\r
+      ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
+    AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
+    *Filename    = (CHAR8 *)(AssertData + 1);\r
+    *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
+    *LineNumber  = AssertData->LineNumber;\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Extracts DEBUG() information from a status code structure.\r
+\r
+  Converts the status code specified by Data to the DEBUG() arguments specified \r
+  by ErrorLevel, Marker, and Format.  If type GUID in Data is \r
+  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and \r
+  Format from the optional data area of the status code buffer specified by Data.  \r
+  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker \r
+  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for \r
+  the Format.  If the DEBUG() information could be extracted from Data, then \r
+  return TRUE.  Otherwise, FALSE is returned.\r
+\r
+  If Data is NULL, then ASSERT().\r
+  If ErrorLevel is NULL, then ASSERT().\r
+  If Marker is NULL, then ASSERT().\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param  Data        Pointer to status code data buffer. \r
+  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
+  @param  Marker      Pointer to the variable argument list associated with Format.\r
+  @param  Format      Pointer to a Null-terminated ASCII format string of a \r
+                      debug message.\r
+\r
+  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments \r
+                  specified by ErrorLevel, Marker, and Format.\r
+  @retval  FALSE  The status code specified by Data could not be converted to \r
+                  DEBUG() arguments.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportStatusCodeExtractDebugInfo (\r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT UINT32                     *ErrorLevel,\r
+  OUT VA_LIST                    *Marker,\r
+  OUT CHAR8                      **Format\r
+  )\r
+{\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  ASSERT (Data       != NULL);\r
+  ASSERT (ErrorLevel != NULL);\r
+  ASSERT (Marker     != NULL);\r
+  ASSERT (Format     != NULL);\r
+\r
+  //\r
+  // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
+  //\r
+  if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Retrieve the debug information from the status code record\r
+  //\r
+  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
+\r
+  *ErrorLevel = DebugInfo->ErrorLevel;\r
+\r
+  //\r
+  // The first 12 * UINTN bytes of the string are really an \r
+  // argument stack to support varargs on the Format string.\r
+  //\r
+  *Marker = (VA_LIST) (DebugInfo + 1);\r
+  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
+\r
+  return TRUE;\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code.\r
+\r
+  Reports the status code specified by the parameters Type and Value.  Status \r
+  code also require an instance, caller ID, and extended data.  This function \r
+  passed in a zero instance, NULL extended data, and a caller ID of \r
+  gEfiCallerIdGuid, which is the GUID for the module.  \r
+  \r
+  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode() \r
+  is called while processing another any other Report Status Code Library function,\r
+  then ReportStatusCode() must return immediately.\r
+\r
+  @param  Type   Status code type. \r
+  @param  Value  Status code value.\r
+\r
+  @retval  EFI_SUCCESS       The status code was reported.\r
+  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a \r
+                             device error.\r
+  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value\r
+  )\r
+{\r
+  return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with a Device Path Protocol as the extended data.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  Device Path Protocol specified by DevicePath.  This function is responsible \r
+  for allocating a buffer large enough for the standard header and the device \r
+  path.  The standard header is filled in with a GUID of \r
+  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero \r
+  instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If \r
+  ReportStatusCodeWithDevicePath() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithDevicePath() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If DevicePath is NULL, then ASSERT().\r
+\r
+  @param  Type        Status code type. \r
+  @param  Value       Status code value.\r
+  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by DevicePath.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithDevicePath (\r
+  IN EFI_STATUS_CODE_TYPE            Type,\r
+  IN EFI_STATUS_CODE_VALUE           Value,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  ASSERT (DevicePath != NULL);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with an extended data buffer.\r
+\r
+  Allocates and fills in the extended data section of a status code with the \r
+  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData \r
+  is assumed to be one of the data structures specified in Related Definitions.  \r
+  These data structure do not have the standard header, so this function is \r
+  responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled \r
+  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported \r
+  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
+\r
+  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If \r
+  ReportStatusCodeWithExtendedData() is called while processing another any other \r
+  Report Status Code Library function, then ReportStatusCodeWithExtendedData() \r
+  must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL, then ASSERT().\r
+  If ExtendedDataSize is 0, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to \r
+                            be reported.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported with the extended \r
+                                 data specified by ExtendedData and ExtendedDataSize.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the \r
+                                 extended data section.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeWithExtendedData (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN CONST VOID             *ExtendedData,\r
+  IN UINTN                  ExtendedDataSize\r
+  )\r
+{\r
+  ASSERT (ExtendedData     != NULL);\r
+  ASSERT (ExtendedDataSize != 0);\r
+  return ReportStatusCodeEx (\r
+           Type,\r
+           Value,\r
+           0,\r
+           NULL,\r
+           NULL,\r
+           ExtendedData,\r
+           ExtendedDataSize\r
+           );\r
+}\r
+\r
+\r
+/**\r
+  Reports a status code with full parameters.\r
+\r
+  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize \r
+  is 0, then an extended data buffer is not reported.  If ExtendedData is not \r
+  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.  \r
+  ExtendedData is assumed not have the standard status code header, so this function \r
+  is responsible for allocating a buffer large enough for the standard header and \r
+  the extended data passed into this function.  The standard header is filled in \r
+  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a \r
+  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with \r
+  an instance specified by Instance and a caller ID specified by CallerId.  If \r
+  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
+\r
+  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx() \r
+  is called while processing another any other Report Status Code Library function, \r
+  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
+\r
+  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
+  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
+\r
+  @param  Type              Status code type. \r
+  @param  Value             Status code value.\r
+  @param  Instance          Status code instance number.\r
+  @param  CallerId          Pointer to a GUID that identifies the caller of this \r
+                            function.  If this parameter is NULL, then a caller \r
+                            ID of gEfiCallerIdGuid is used.\r
+  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.  \r
+                            If this parameter is NULL, then a the status code \r
+                            standard header is filled in with \r
+                            gEfiStatusCodeSpecificDataGuid.\r
+  @param  ExtendedData      Pointer to the extended data buffer.  This is an \r
+                            optional parameter that may be NULL.\r
+  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
+\r
+  @retval  EFI_SUCCESS           The status code was reported.\r
+  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate \r
+                                 the extended data section if it was specified.\r
+  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueReportStatusCodeEx (\r
+  IN EFI_STATUS_CODE_TYPE   Type,\r
+  IN EFI_STATUS_CODE_VALUE  Value,\r
+  IN UINT32                 Instance,\r
+  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
+  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
+  IN CONST VOID             *ExtendedData      OPTIONAL,\r
+  IN UINTN                  ExtendedDataSize\r
+  )\r
+{\r
+  EFI_STATUS_CODE_DATA  *StatusCodeData;\r
+  UINT64                Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)];\r
+\r
+  ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
+  ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
+\r
+  if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;\r
+  StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
+  StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
+  if (ExtendedDataGuid == NULL) {\r
+    ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
+  }\r
+  CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
+  CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
+  if (CallerId == NULL) {\r
+    CallerId = &gEfiCallerIdGuid;\r
+  }\r
+  return InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportProgressCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportErrorCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
+}\r
+\r
+\r
+/**\r
+  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
+\r
+  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \r
+  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is set.\r
+  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r
+                  PcdReportStatusCodeProperyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueReportDebugCodeEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c
new file mode 100644 (file)
index 0000000..58535b5
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiResourcePublicationLib.c\r
+  \r
+Abstract: \r
+\r
+  Resource Publication Library that uses PEI Core Services to publish system memory.\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  \r
+  Declares the presence of permanent system memory in the platform.\r
+\r
+  Declares that the system memory buffer specified by MemoryBegin and MemoryLength\r
+  as permanent memory that may be used for general purpose use by software.\r
+  The amount of memory available to software may be less than MemoryLength\r
+  if published memory has alignment restrictions.  \r
+\r
+  @param  MemoryBegin               The start address of the memory being declared.\r
+  @param  MemoryLength              The number of bytes of memory being declared.\r
+\r
+  @retval  RETURN_SUCCESS           The memory buffer was published.\r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to publish the memory buffer\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PublishSystemMemory (\r
+  IN PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                 MemoryLength\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+\r
+  ASSERT (MemoryLength > 0);\r
+  ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1));\r
+\r
+  Status      = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength);\r
+     \r
+  return (RETURN_STATUS) Status;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
new file mode 100644 (file)
index 0000000..53de36a
--- /dev/null
@@ -0,0 +1,81 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiResourcePublication.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiResourcePublication.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiResourcePublicationLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeiResourcePublicationLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGluePeiServicesLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c
new file mode 100644 (file)
index 0000000..6014351
--- /dev/null
@@ -0,0 +1,393 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiServicesLib.c\r
+  \r
+Abstract: \r
+\r
+  PEI Services Lib\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  This service enables a given PEIM to register an interface into the PEI Foundation. \r
+\r
+  @param  PpiList               A pointer to the list of interfaces that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPpi (\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *PpiList\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
+\r
+  @param  OldPpi                Pointer to the old PEI PPI Descriptors.\r
+  @param  NewPpi                Pointer to the new PEI PPI Descriptors.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+  @retval EFI_NOT_FOUND         The PPI for which the reinstallation was requested has not been\r
+                                installed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesReInstallPpi (\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *OldPpi,\r
+  IN EFI_PEI_PPI_DESCRIPTOR     *NewPpi\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover a given instance of an interface.\r
+\r
+  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be\r
+                                found.\r
+  @param  Instance              The N-th instance of the interface that is required.\r
+  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
+  @param  Ppi                   A pointer to the instance of the interface.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully returned.\r
+  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN EFI_GUID                   *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to register a given service to be invoked when another service is\r
+  installed or reinstalled.\r
+\r
+  @param  NotifyList            A pointer to the list of notification interfaces that the caller\r
+                                shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesNotifyPpi (\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to ascertain the present value of the boot mode.  \r
+\r
+  @param  BootMode              A pointer to contain the value of the boot mode.\r
+\r
+  @retval EFI_SUCCESS           The boot mode was returned successfully.\r
+  @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetBootMode (\r
+  IN OUT EFI_BOOT_MODE          *BootMode\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to update the boot mode variable.    \r
+\r
+  @param  BootMode              The value of the boot mode to set.\r
+\r
+  @retval EFI_SUCCESS           The value was successfully updated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesSetBootMode (\r
+  IN EFI_BOOT_MODE              BootMode\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r
+}\r
+\r
+/**\r
+  This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
+\r
+  @param  HobList               A pointer to the list of HOBs that the PEI Foundation will initialize.\r
+\r
+  @retval EFI_SUCCESS           The list was successfully returned.\r
+  @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetHobList (\r
+  IN OUT VOID                   **HobList\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->GetHobList (PeiServices, HobList);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to create various types of HOBs.\r
+\r
+  @param  Type                  The type of HOB to be installed.\r
+  @param  Length                The length of the HOB to be added.\r
+  @param  Hob                   The address of a pointer that will contain the HOB header.\r
+\r
+  @retval EFI_SUCCESS           The HOB was successfully created.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesCreateHob (\r
+  IN UINT16                     Type,\r
+  IN UINT16                     Length,\r
+  IN OUT VOID                   **Hob\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r
+}\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+/**\r
+  This service enables PEIMs to discover additional firmware volumes.\r
+\r
+  @param  Instance              This instance of the firmware volume to find.  The value 0 is the\r
+                                Boot Firmware Volume (BFV).\r
+  @param  FwVolHeader           Pointer to the firmware volume header of the volume to return.\r
+\r
+  @retval EFI_SUCCESS           The volume was found.\r
+  @retval EFI_NOT_FOUND         The volume was not found.\r
+  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware files.\r
+\r
+  @param  SearchType            A filter to find files only of this type.\r
+  @param  FwVolHeader           Pointer to the firmware volume header of the volume to search.\r
+                                This parameter must point to a valid FFS volume.\r
+  @param  FileHeader            Pointer to the current file from which to begin searching.\r
+\r
+  @retval EFI_SUCCESS           The file was found.\r
+  @retval EFI_NOT_FOUND         The file was not found.\r
+  @retval EFI_NOT_FOUND         The header checksum was not zero.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER    **FileHeader\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
+\r
+  @param  SearchType            The value of the section type to find.\r
+  @param  FfsFileHeader         A pointer to the file header that contains the set of sections to\r
+                                be searched.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+\r
+  @retval EFI_SUCCESS           The section was found.\r
+  @retval EFI_NOT_FOUND         The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_FFS_FILE_HEADER        *FfsFileHeader,\r
+  IN OUT VOID                   **SectionData\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData);\r
+}\r
+\r
+#endif\r
+\r
+/**\r
+  This service enables PEIMs to register the permanent memory configuration\r
+  that has been initialized with the PEI Foundation.\r
+\r
+  @param  MemoryBegin           The value of a region of installed memory.\r
+  @param  MemoryLength          The corresponding length of a region of installed memory.\r
+\r
+  @retval EFI_SUCCESS           The region was successfully installed in a HOB.\r
+  @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPeiMemory (\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to allocate memory after the permanent memory has been installed by a\r
+  PEIM.\r
+\r
+  @param  MemoryType            Type of memory to allocate.\r
+  @param  Pages                 Number of pages to allocate.\r
+  @param  Memory                Pointer of memory allocated.\r
+\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
+  @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePages (\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *Memory\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, Memory);\r
+}\r
+\r
+/**\r
+  This service allocates memory from the Hand-Off Block (HOB) heap.\r
+\r
+  @param  Size                  The number of bytes to allocate from the pool.\r
+  @param  Buffer                If the call succeeds, a pointer to a pointer to the allocate\r
+                                buffer; undefined otherwise.\r
+\r
+  @retval EFI_SUCCESS           The allocation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough heap to allocate the requested size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePool (\r
+  IN UINTN                      Size,\r
+  OUT VOID                      **Buffer\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return ((*PeiServices)->AllocatePool) (PeiServices, Size, Buffer);\r
+}\r
+\r
+/**\r
+  This service resets the entire platform, including all processors and devices, and reboots the\r
+  system. \r
+\r
+  @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesResetSystem (\r
+  VOID\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  return (*PeiServices)->PeiResetSystem (PeiServices);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf
new file mode 100644 (file)
index 0000000..efe0622
--- /dev/null
@@ -0,0 +1,86 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiServicesLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiServicesLib\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiServicesLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeiServicesLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+#\r
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be\r
+# used to replace EdkIIGluePeiServicesTablePointerLibMm7 or\r
+# EdkIIGluePeiServicesTablePointerLibKr1\r
+#\r
+\r
+[libraries.ia32]\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+\r
+[libraries.x64]\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+    \r
+[libraries.ipf]\r
+  EdkIIGluePeiServicesTablePointerLibKr1\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..d3c0c98
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiServicesTablePointer.c\r
+  \r
+Abstract: \r
+\r
+  PEI Services Table Pointer Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+static EFI_PEI_SERVICES  **gPeiServices;\r
+\r
+/**\r
+  The function returns the pointer to PEI services.\r
+\r
+  The function returns the pointer to PEI services.\r
+  It will ASSERT() if the pointer to PEI services is NULL.\r
+\r
+  @retval  The pointer to PeiServices.\r
+\r
+**/\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (gPeiServices != NULL);\r
+  return gPeiServices;\r
+}\r
+\r
+\r
+/**\r
+  The constructor function caches the pointer to PEI services.\r
+  \r
+  The constructor function caches the pointer to PEI services.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  gPeiServices = PeiServices;\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644 (file)
index 0000000..180bee6
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiServiceTablePointerLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiServicesTablePointerLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiServicesTablePointerLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeiServicesTablePointer.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
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 (file)
index 0000000..cc48f09
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+//\r
+// Module Name:\r
+//\r
+//   ReadKr1.s\r
+//\r
+// Abstract:\r
+//\r
+//   Contains assembly code for read Kr1.\r
+//\r
+//--\r
+\r
+  .file  "ReadKr1.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmReadKr1\r
+//\r
+// This routine is used to get KR1. KR1 is used to store Pei Service Table\r
+// Pointer in archeture.\r
+//\r
+// Arguments : \r
+//\r
+// On Entry :  None.\r
+//\r
+// Return Value: Pei Services Table.\r
+// \r
+//--\r
+//----------------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (AsmReadKr1)\r
+        \r
+        mov             r8 = ar.k1;;  // Pei Services Table Pointer\r
+        br.ret.dpnt     b0;;\r
+\r
+PROCEDURE_EXIT (AsmReadKr1)\r
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 (file)
index 0000000..e86f50a
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+//\r
+// Module Name:\r
+//\r
+//   WriteKr1.s\r
+//\r
+// Abstract:\r
+//\r
+//   Contains assembly code for write Kr1.\r
+//\r
+//--\r
+\r
+  .file  "WriteKr1.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmWriteKr1\r
+//\r
+// This routine is used to Write KR1. KR1 is used to store Pei Service Table\r
+// Pointer in archeture.\r
+//\r
+// Arguments : r32  Pei Services Table Pointer\r
+//\r
+// On Entry :  None.\r
+//\r
+// Return Value: None.\r
+// \r
+//--\r
+//----------------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (AsmWriteKr1)\r
+        \r
+        mov             ar.k1 = r32;;  // Pei Services Table Pointer\r
+        br.ret.dpnt     b0;;\r
+\r
+PROCEDURE_EXIT (AsmWriteKr1)\r
\ 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 (file)
index 0000000..a122ce8
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiServicesTablePointer.c\r
+  \r
+Abstract: \r
+\r
+  PEI Services Table Pointer Library.\r
+\r
+--*/\r
+\r
+#include "PeiServicesTablePointerLibInternals.h"\r
+\r
+/**\r
+  The function returns the pointer to PeiServices.\r
+\r
+  The function returns the pointer to PeiServices.\r
+  It will ASSERT() if the pointer to PeiServices is NULL.\r
+\r
+  @retval  The pointer to PeiServices.\r
+\r
+**/\r
+EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+  PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadKr1 ();\r
+  ASSERT (PeiServices != NULL);\r
+  return PeiServices;\r
+}\r
+\r
+/**\r
+  The constructor function caches the pointer to PEI services.\r
+\r
+  The constructor function caches the pointer to PEI services.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  AsmWriteKr1 ((UINT64)(UINTN)PeiServices);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h
new file mode 100644 (file)
index 0000000..ee0f2a5
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeiServicesTablePointerLibInternals.h\r
+    \r
+Abstract: \r
+\r
+  Declarations of internal functions in PeiServicesTableLibKr1.\r
+\r
+--*/\r
+\r
+#ifndef __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__\r
+#define __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  Reads the current value of Kr1.\r
+\r
+  @return The current value of Kr1.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadKr1 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Writes the current value of Kr1.\r
+\r
+  @param  Value The 64-bit value to write to Kr1.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteKr1 (\r
+  IN      UINT64                    Value\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf
new file mode 100644 (file)
index 0000000..24b5d6b
--- /dev/null
@@ -0,0 +1,74 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiServiceTablePointerLibKr1.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiServicesTablePointerLibKr1.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiServicesTablePointerLibKr1\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+\r
+[sources.ipf]\r
+  PeiServicesTablePointer.c\r
+  Ipf/ReadKr1.s\r
+  Ipf/WriteKr1.s\r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..f91a2f5
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiServicesTablePointer.c\r
+  \r
+Abstract: \r
+\r
+  PEI Services Table Pointer Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+/**\r
+  The function returns the pointer to PeiServices.\r
+\r
+  The function returns the pointer to PeiServices.\r
+  It will ASSERT() if the pointer to PeiServices is NULL.\r
+\r
+  @retval  The pointer to PeiServices.\r
+\r
+**/\r
+EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+  PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 ();\r
+  ASSERT (PeiServices != NULL);\r
+  return PeiServices;\r
+}\r
+\r
+/**\r
+  The constructor function caches the pointer to PEI services.\r
+\r
+  The constructor function caches the pointer to PEI services.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  FfsHeader   Pointer to FFS header the loaded driver.\r
+  @param  PeiServices Pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader,\r
+  IN EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  AsmWriteMm7 ((UINT64)(UINTN)PeiServices);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
new file mode 100644 (file)
index 0000000..0bcc415
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiServiceTablePointerLibMm7.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiServicesTablePointerLibMm7.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiServicesTablePointerLibMm7 \r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeiServicesTablePointer.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c
new file mode 100644 (file)
index 0000000..4abf5f6
--- /dev/null
@@ -0,0 +1,104 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiSmbusLib.c\r
+  \r
+Abstract: \r
+\r
+  PEI Smbus Lib internal functions\r
+\r
+--*/\r
+\r
+#include "PeiSmbusLibInternal.h"\r
+\r
+/**\r
+  Gets Smbus PPIs.\r
+\r
+  This internal function retrieves Smbus PPI from PPI database.\r
+\r
+  @param  PeiServices   An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.\r
+\r
+  @return The pointer to Smbus PPI.\r
+\r
+**/\r
+EFI_PEI_SMBUS_PPI *\r
+InternalGetSmbusPpi (\r
+  EFI_PEI_SERVICES      **PeiServices\r
+  ) \r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_SMBUS_PPI     *SmbusPpi;\r
+\r
+  Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (SmbusPpi != NULL);\r
+\r
+  return SmbusPpi;\r
+}\r
+\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation..\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+     OUT RETURN_STATUS              *Status        OPTIONAL\r
+  )\r
+{\r
+  EFI_PEI_SMBUS_PPI         *SmbusPpi;\r
+  EFI_PEI_SERVICES          **PeiServices;\r
+  RETURN_STATUS             ReturnStatus;\r
+  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
+\r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  SmbusPpi    = InternalGetSmbusPpi (PeiServices);\r
+  SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
+\r
+  ReturnStatus = SmbusPpi->Execute (\r
+                             PeiServices,\r
+                             SmbusPpi,\r
+                             SmbusDeviceAddress,\r
+                             SMBUS_LIB_COMMAND (SmBusAddress),\r
+                             SmbusOperation,\r
+                             SMBUS_LIB_PEC (SmBusAddress),  \r
+                             &Length,\r
+                             Buffer\r
+                             );\r
+  if (Status != NULL) {\r
+    *Status = ReturnStatus;\r
+  }\r
+\r
+  return Length;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf
new file mode 100644 (file)
index 0000000..c3bfa95
--- /dev/null
@@ -0,0 +1,86 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   PeiSmbusLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for PeiSmbusLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGluePeiSmbusLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  PeiSmbusLib.c\r
+  SmbusLib.c\r
+\r
+[sources.ia32]\r
+  \r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords\r
+  $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be\r
+# used to replace EdkIIGluePeiServicesTablePointerLibMm7\r
+#\r
+\r
+\r
+[libraries.ia32]\r
+\r
+[libraries.x64]\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h
new file mode 100644 (file)
index 0000000..fa7251c
--- /dev/null
@@ -0,0 +1,84 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  PeiSmbusLibInternal.h\r
+    \r
+Abstract: \r
+\r
+  Declarations of internal functions in PeiSmbusLib.\r
+\r
+--*/\r
+\r
+#ifndef __PEI_SMBUS_LIB_INTERNAL_H__\r
+#define __PEI_SMBUS_LIB_INTERNAL_H__\r
+\r
+#include "EdkIIGluePeim.h"\r
+\r
+\r
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress)      (((SmBusAddress) >> 1)  & 0x7f)\r
+#define SMBUS_LIB_COMMAND(SmBusAddress)            (((SmBusAddress) >> 8)  & 0xff)\r
+#define SMBUS_LIB_LENGTH(SmBusAddress)             (((SmBusAddress) >> 16) & 0x3f)\r
+#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))\r
+#define SMBUS_LIB_RESEARVED(SmBusAddress)          ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))\r
+\r
+//\r
+// Declaration for internal functions\r
+//\r
+\r
+/**\r
+  Gets Smbus PPIs.\r
+\r
+  This internal function retrieves Smbus PPI from PPI database.\r
+\r
+  @param  PeiServices   An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.\r
+\r
+  @return The pointer to Smbus PPI.\r
+\r
+**/\r
+EFI_PEI_SMBUS_PPI *\r
+InternalGetSmbusPpi (\r
+  EFI_PEI_SERVICES      **PeiServices\r
+  );\r
+\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation.\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+  OUT    RETURN_STATUS              *Status        OPTIONAL\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c
new file mode 100644 (file)
index 0000000..359eb35
--- /dev/null
@@ -0,0 +1,475 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  PeiSmbus.c\r
+  \r
+Abstract: \r
+\r
+  Pei Smbus Lib Interfaces\r
+\r
+--*/\r
+\r
+#include "PeiSmbusLibInternal.h"\r
+\r
+/**\r
+  Executes an SMBUS quick read command.\r
+\r
+  Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickRead (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS quick write command.\r
+\r
+  Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickWrite (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS receive byte command.\r
+\r
+  Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  The byte received from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte received from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReceiveByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)  == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS send byte command.\r
+\r
+  Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
+  The byte specified by Value is sent.\r
+  Only the SMBUS slave address field of SmBusAddress is required.  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to send.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusSendByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte   = Value;\r
+  InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data byte command.\r
+\r
+  Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 8-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReadDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data byte command.\r
+\r
+  Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
+  The 8-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusWriteDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte = Value;\r
+  InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data word command.\r
+\r
+  Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+  \r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusReadDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);\r
+  \r
+  return Word;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data word command.\r
+\r
+  Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusWriteDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Word = Value;\r
+  InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS process call command.\r
+\r
+  Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value returned by the process call command is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The 16-bit value returned by the process call command.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read block command.\r
+\r
+  Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Bytes are read from the SMBUS and stored in Buffer.\r
+  The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusReadBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write block command.\r
+\r
+  Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from Buffer.\r
+  The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.  \r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusWriteBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN  Length;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS block process call command.\r
+\r
+  Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  WriteBuffer     Pointer to the buffer of bytes to write to the SMBUS.\r
+  @param  ReadBuffer      Pointer to the buffer of bytes to read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusBlockProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN   Length;\r
+\r
+  ASSERT (WriteBuffer != NULL);\r
+  ASSERT (ReadBuffer  != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  //\r
+  // Assuming that ReadBuffer is large enough to save another memory copy.\r
+  //\r
+  ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
new file mode 100644 (file)
index 0000000..1727759
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  UefiBootServicesTableLib.c\r
+  \r
+Abstract: \r
+\r
+  UEFI Boot Services Table Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+\r
+EFI_HANDLE         gImageHandle;\r
+EFI_SYSTEM_TABLE   *gST;\r
+EFI_BOOT_SERVICES  *gBS;\r
+\r
+/**\r
+  The constructor function caches the pointer of Boot Services Table.\r
+  \r
+  The constructor function caches the pointer of Boot Services Table through System Table.\r
+  It will ASSERT() if the pointer of System Table is NULL.\r
+  It will ASSERT() if the pointer of Boot Services Table is NULL.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiBootServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  //\r
+  // Cache the Image Handle\r
+  //\r
+  gImageHandle = ImageHandle;\r
+\r
+  //\r
+  // Cache pointer to the EFI System Table\r
+  //\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  //\r
+  // Cache pointer to the EFI Boot Services Table\r
+  //\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
new file mode 100644 (file)
index 0000000..9b14aaf
--- /dev/null
@@ -0,0 +1,77 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   UefiBootServicesTableLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for UefiBootServicesTableLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueUefiBootServicesTableLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  UefiBootServicesTableLib.c \r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
\r
+  $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath\r
+\r
+[libraries.common]\r
+\r
+[libraries.ia32]\r
+\r
+[libraries.x64]\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c
new file mode 100644 (file)
index 0000000..d4174f3
--- /dev/null
@@ -0,0 +1,533 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+\r
+Module Name:\r
+\r
+  UefiDevicePathLib.c\r
+  \r
+Abstract: \r
+\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+#include "Library\EdkIIGlueMemoryAllocationLib.h"\r
+\r
+/**\r
+  Returns the size of a device path in bytes.\r
+\r
+  This function returns the size, in bytes, of the device path data structure specified by\r
+  DevicePath including the end of device path node.  If DevicePath is NULL, then 0 is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @return The size of a device path in bytes.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueGetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  if (DevicePath == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!EfiIsDevicePathEnd (DevicePath)) {\r
+    DevicePath = EfiNextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Compute the size and add back in the size of the end device path structure\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  If\r
+  DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the\r
+  contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
+  is returned.  Otherwise, NULL is returned.  \r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @return A pointer to the duplicated device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueDuplicateDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // Compute the size\r
+  //\r
+  Size = GetDevicePathSize (DevicePath);\r
+  if (Size == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Allocate space for duplicate device path\r
+  //\r
+  NewDevicePath = AllocateCopyPool (Size, DevicePath);\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
+  FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from\r
+  SecondDevicePath is retained. The newly created device path is returned.  \r
+  If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.  \r
+  If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.  \r
+  If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.  \r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. It is the\r
+  responsibility of the caller to free the memory allocated.\r
+\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
+  )\r
+{\r
+  UINTN                     Size;\r
+  UINTN                     Size1;\r
+  UINTN                     Size2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
+\r
+  //\r
+  // If there's only 1 path, just duplicate it.\r
+  //\r
+  if (FirstDevicePath == NULL) {\r
+    return DuplicateDevicePath (SecondDevicePath);\r
+  }\r
+\r
+  if (SecondDevicePath == NULL) {\r
+    return DuplicateDevicePath (FirstDevicePath);\r
+  }\r
+\r
+  //\r
+  // Allocate space for the combined device path. It only has one end node of\r
+  // length EFI_DEVICE_PATH_PROTOCOL.\r
+  //\r
+  Size1         = GetDevicePathSize (FirstDevicePath);\r
+  Size2         = GetDevicePathSize (SecondDevicePath);\r
+  Size          = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+\r
+  NewDevicePath = AllocatePool (Size);\r
+\r
+  if (NewDevicePath != NULL) {\r
+    NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);\r
+    //\r
+    // Over write FirstDevicePath EndNode and do the copy\r
+    //\r
+    DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
+                  (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
+    CopyMem (DevicePath2, SecondDevicePath, Size2);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node specified by\r
+  DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device node.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If DevicePathNode is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePathNode (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     NodeLength;\r
+\r
+  if (DevicePath == NULL || DevicePathNode == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Build a Node that has a terminator on it\r
+  //\r
+  NodeLength = DevicePathNodeLength (DevicePathNode);\r
+\r
+  TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+  if (TempDevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+  TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);\r
+  //\r
+  // Add and end device path node to convert Node to device path\r
+  //\r
+  NextNode = NextDevicePathNode (TempDevicePath);\r
+  SetDevicePathEndNode (NextNode);\r
+  //\r
+  // Append device paths\r
+  //\r
+  NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);\r
+\r
+  FreePool (TempDevicePath);\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
\r
+  This function creates a new device path by appending a copy of the device path instance specified\r
+  by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device path instance\r
+  and a new end-of-device-path-instance node is inserted between. \r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueAppendDevicePathInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  UINTN                     SrcSize;\r
+  UINTN                     InstanceSize;\r
+\r
+  if (DevicePath == NULL) {\r
+    return DuplicateDevicePath (DevicePathInstance);\r
+  }\r
+\r
+  if (DevicePathInstance == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  SrcSize       = GetDevicePathSize (DevicePath);\r
+  InstanceSize  = GetDevicePathSize (DevicePathInstance);\r
+\r
+  NewDevicePath = AllocatePool (SrcSize + InstanceSize);\r
+  if (NewDevicePath != NULL) {\r
+    \r
+    TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);;\r
\r
+    while (!IsDevicePathEnd (TempDevicePath)) {\r
+      TempDevicePath = NextDevicePathNode (TempDevicePath);\r
+    }\r
+    \r
+    TempDevicePath->SubType  = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
+    TempDevicePath           = NextDevicePathNode (TempDevicePath);\r
+    CopyMem (TempDevicePath, DevicePathInstance, InstanceSize);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates DevicePath to\r
+  point to the next device path instance in the device path (or NULL if no more) and updates Size\r
+  to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
\r
+  @param  DevicePath                 On input, this holds the pointer to the current device path\r
+                                     instance. On output, this holds the pointer to the next device\r
+                                     path instance or NULL if there are no more device path\r
+                                     instances in the device path pointer to a device path data\r
+                                     structure.\r
+  @param  Size                       On output, this holds the size of the device path instance, in\r
+                                     bytes or zero, if DevicePath is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueGetNextDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,\r
+  OUT UINTN                          *Size\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ReturnValue;\r
+  UINT8                     Temp;\r
+\r
+  ASSERT (Size != NULL);\r
+\r
+  if (DevicePath == NULL || *DevicePath == NULL) {\r
+    *Size = 0;\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Find the end of the device path instance\r
+  //\r
+  DevPath = *DevicePath;\r
+  while (!IsDevicePathEndType (DevPath)) {\r
+    DevPath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  //\r
+  // Compute the size of the device path instance\r
+  //\r
+  *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
\r
+  //\r
+  // Make a copy and return the device path instance\r
+  //\r
+  Temp              = DevPath->SubType;\r
+  DevPath->SubType  = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
+  ReturnValue       = DuplicateDevicePath (*DevicePath);\r
+  DevPath->SubType  = Temp;\r
+\r
+  //\r
+  // If DevPath is the end of an entire device path, then another instance\r
+  // does not follow, so *DevicePath is set to NULL.\r
+  //\r
+  if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {\r
+    *DevicePath = NULL;\r
+  } else {\r
+    *DevicePath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a new device node in a newly allocated buffer of size NodeLength and\r
+  initializes the device path node header with NodeType and NodeSubType.  The new device path node\r
+  is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.  \r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
+\r
+  @return The new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+CreateDeviceNode (\r
+  IN UINT8                           NodeType,\r
+  IN UINT8                           NodeSubType,\r
+  IN UINT16                          NodeLength\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
+\r
+  if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
+    //\r
+    // NodeLength is less than the size of the header.\r
+    //\r
+    return NULL;\r
+  }\r
\r
+  DevicePath = AllocatePool (NodeLength);\r
+  if (DevicePath != NULL) {\r
+     DevicePath->Type    = NodeType;\r
+     DevicePath->SubType = NodeSubType;\r
+     SetDevicePathNodeLength (DevicePath, NodeLength);\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
+\r
+  This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
+  Otherwise, FALSE is returned.  If DevicePath is NULL, then FALSE is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance or DevicePath is NULL.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+GlueIsDevicePathMultiInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL     *Node;\r
+\r
+  if (DevicePath == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  Node = DevicePath;\r
+  while (!EfiIsDevicePathEnd (Node)) {\r
+    if (EfiIsDevicePathEndInstance (Node)) {\r
+      return TRUE;\r
+    }\r
+\r
+    Node = EfiNextDevicePathNode (Node);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves the device path protocol from a handle.\r
+\r
+  This function returns the device path protocol from the handle specified by Handle.  If Handle is\r
+  NULL or Handle does not contain a device path protocol, then NULL is returned.\r
\r
+  @param  Handle                     The handle from which to retrieve the device path protocol.\r
+\r
+  @return The device path protocol from the handle specified by Handle.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueDevicePathFromHandle (\r
+  IN EFI_HANDLE                      Handle\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID *) &DevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    DevicePath = NULL;\r
+  }\r
+  return DevicePath;\r
+}\r
+\r
+/**\r
+  Allocates a device path for a file and appends it to an existing device path.\r
+\r
+  If Device is a valid device handle that contains a device path protocol, then a device path for\r
+  the file specified by FileName  is allocated and appended to the device path associated with the\r
+  handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle\r
+  that does not support the device path protocol, then a device path containing a single device\r
+  path node for the file specified by FileName is allocated and returned.\r
+  If FileName is NULL, then ASSERT().\r
+\r
+  @param  Device                     A pointer to a device handle.  This parameter is optional and\r
+                                     may be NULL.\r
+  @param  FileName                   A pointer to a Null-terminated Unicode string.\r
+\r
+  @return The allocated device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GlueFileDevicePath (\r
+  IN EFI_HANDLE                      Device,     OPTIONAL\r
+  IN CONST CHAR16                    *FileName\r
+  )\r
+{\r
+  UINTN                     Size;\r
+  FILEPATH_DEVICE_PATH      *FilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FileDevicePath;\r
+\r
+  DevicePath = NULL;\r
+\r
+  Size = StrSize (FileName);\r
+  FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);\r
+  if (FileDevicePath != NULL) {\r
+    FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
+    FilePath->Header.Type    = MEDIA_DEVICE_PATH;\r
+    FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
+    CopyMem (&FilePath->PathName, FileName, Size);\r
+    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
+    SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));\r
+\r
+    if (Device != NULL) {\r
+      DevicePath = DevicePathFromHandle (Device);\r
+    }\r
+\r
+    DevicePath = AppendDevicePath (DevicePath, FileDevicePath);\r
+    FreePool (FileDevicePath);\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf
new file mode 100644 (file)
index 0000000..6c4bc04
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   UefiDevicePathLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for UefiDevicePathLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueUefiDevicePathLib \r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  UefiDevicePathLib.c \r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r \r
+  $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+#\r
+# MemoryAllocationLib instance\r
+#\r
+  EdkIIGlueDxeMemoryAllocationLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
new file mode 100644 (file)
index 0000000..60ab441
--- /dev/null
@@ -0,0 +1,355 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  UefiDriverModelLib.c\r
+  \r
+Abstract: \r
+\r
+  UEFI Driver Model Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+\r
+/**\r
+  The constructor function installs the standard EFI Driver Model Protocols.\r
+\r
+  @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiDriverModelLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_HANDLE                   DriverBindingHandle;\r
+  EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;\r
+\r
+  //\r
+  // Install the first Driver Bindng Protocol onto ImageHandle\r
+  //\r
+  DriverBindingHandle = ImageHandle;\r
+\r
+  //\r
+  // See if onle one Driver Binding Protocol is advertised by the driver\r
+  // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1\r
+  //\r
+\r
+    //\r
+    // The Driver Binding Protocol must never be NULL\r
+    //\r
+    ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
+\r
+    //\r
+    // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
+    // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
+    // calls to InstallMultipleProtocolInterfaces()\r
+    //\r
+    if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,      (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      }\r
+    } else {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,    (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,     (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,      (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
+    //\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    //\r
+    // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
+    //\r
+    DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;\r
+    DriverBinding->ImageHandle         = ImageHandle;\r
+    DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
+\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  The destructor function uninstalls the standard EFI Driver Model Protocols.\r
+\r
+  @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS The destructor always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiDriverModelLibDestructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  DriverBindingHandle;\r
+\r
+  //\r
+  // See if onle one Driver Binding Protocol is advertised by the driver\r
+  // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1\r
+  //\r
+\r
+    //\r
+    // The Driver Binding Protocol must never be NULL\r
+    //\r
+    ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
+\r
+    //\r
+    // Retrieve the DriverBindingHandle from the Driver Binding Protocol\r
+    //\r
+    DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;\r
+\r
+    //\r
+    // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
+    // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
+    // calls to InstallMultipleProtocolInterfaces()\r
+    //\r
+    if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          NULL\r
+                          );\r
+\r
+#endif\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,      (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      }\r
+    } else {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,    (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,     (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+        } else {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,      (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#else\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
+                          &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
+                          NULL\r
+                          );\r
+#endif\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed\r
+    //\r
+    ASSERT_EFI_ERROR (Status);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf
new file mode 100644 (file)
index 0000000..6618c6a
--- /dev/null
@@ -0,0 +1,67 @@
+#/*++\r
+#\r
+#  Copyright (c) 2006, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.      \r
+#\r
+#  Module Name:\r
+#\r
+#    UefiDriverModelLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for UefiDriverModelLib.inf\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueUefiDriverModelLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  UefiDriverModelLib.c\r
+  \r
+[sources.ia32]\r
+\r
+[sources.ipf,sources.x64]\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include\r
+  $(EDK_SOURCE)\Foundation\Core\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+\r
+[libraries.common]\r
+  EdkIIGlueUefiBootServicesTableLib\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c
new file mode 100644 (file)
index 0000000..97bc801
--- /dev/null
@@ -0,0 +1,288 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  Console.c\r
+  \r
+Abstract: \r
+\r
+  UEFI library functions.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+\r
+typedef struct {\r
+  CHAR16  WChar;\r
+  UINT32  Width;\r
+} UNICODE_WIDTH_ENTRY;\r
+\r
+UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {\r
+  //\r
+  // General script area\r
+  //\r
+  {(CHAR16)0x1FFF,  1},\r
+  /*\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
+   * the same category and they are all narrow glyph. This will reduce search\r
+   * time and table size. The merge will omit the reserved code.\r
+   *\r
+   * Remove the above item if below is un-commented.\r
+   *\r
+  {(CHAR16)0x007F,  1},       // C0 controls and basic Latin. 0x0000-0x007F\r
+  {(CHAR16)0x00FF,  1},       // C1 controls and Latin-1 support. 0x0080-0x00FF\r
+  {(CHAR16)0x017F,  1},       // Latin extended-A. 0x0100-0x017F\r
+  {(CHAR16)0x024F,  1},       // Latin extended-B. 0x0180-0x024F\r
+  {(CHAR16)0x02AF,  1},       // IPA extensions. 0x0250-0x02AF\r
+  {(CHAR16)0x02FF,  1},       // Spacing modifier letters. 0x02B0-0x02FF\r
+  {(CHAR16)0x036F,  1},       // Combining diacritical marks. 0x0300-0x036F\r
+  {(CHAR16)0x03FF,  1},       // Greek. 0x0370-0x03FF\r
+  {(CHAR16)0x04FF,  1},       // Cyrillic. 0x0400-0x04FF\r
+  {(CHAR16)0x052F,  0},       // Unassigned. As Armenian in ver3.0. 0x0500-0x052F\r
+  {(CHAR16)0x058F,  1},       // Armenian. 0x0530-0x058F\r
+  {(CHAR16)0x05FF,  1},       // Hebrew. 0x0590-0x05FF\r
+  {(CHAR16)0x06FF,  1},       // Arabic. 0x0600-0x06FF\r
+  {(CHAR16)0x08FF,  0},       // Unassigned. 0x0700-0x08FF\r
+  {(CHAR16)0x097F,  1},       // Devanagari. 0x0900-0x097F\r
+  {(CHAR16)0x09FF,  1},       // Bengali. 0x0980-0x09FF\r
+  {(CHAR16)0x0A7F,  1},       // Gurmukhi. 0x0A00-0x0A7F\r
+  {(CHAR16)0x0AFF,  1},       // Gujarati. 0x0A80-0x0AFF\r
+  {(CHAR16)0x0B7F,  1},       // Oriya. 0x0B00-0x0B7F\r
+  {(CHAR16)0x0BFF,  1},       // Tamil. (See page 7-92). 0x0B80-0x0BFF\r
+  {(CHAR16)0x0C7F,  1},       // Telugu. 0x0C00-0x0C7F\r
+  {(CHAR16)0x0CFF,  1},       // Kannada. (See page 7-100). 0x0C80-0x0CFF\r
+  {(CHAR16)0x0D7F,  1},       // Malayalam (See page 7-104). 0x0D00-0x0D7F\r
+  {(CHAR16)0x0DFF,  0},       // Unassigned. 0x0D80-0x0DFF\r
+  {(CHAR16)0x0E7F,  1},       // Thai. 0x0E00-0x0E7F\r
+  {(CHAR16)0x0EFF,  1},       // Lao. 0x0E80-0x0EFF\r
+  {(CHAR16)0x0FBF,  1},       // Tibetan. 0x0F00-0x0FBF\r
+  {(CHAR16)0x109F,  0},       // Unassigned. 0x0FC0-0x109F\r
+  {(CHAR16)0x10FF,  1},       // Georgian. 0x10A0-0x10FF\r
+  {(CHAR16)0x11FF,  1},       // Hangul Jamo. 0x1100-0x11FF\r
+  {(CHAR16)0x1DFF,  0},       // Unassigned. 0x1200-0x1DFF\r
+  {(CHAR16)0x1EFF,  1},       // Latin extended additional. 0x1E00-0x1EFF\r
+  {(CHAR16)0x1FFF,  1},       // Greek extended. 0x1F00-0x1FFF\r
+  *\r
+  */\r
+\r
+  //\r
+  // Symbol area\r
+  //\r
+  {(CHAR16)0x2FFF,  1},\r
+  /*\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
+   * the same category and they are all narrow glyph. This will reduce search\r
+   * time and table size. The merge will omit the reserved code.\r
+   *\r
+   * Remove the above item if below is un-commented.\r
+   *\r
+  {(CHAR16)0x206F,  1},       // General punctuation. (See page7-154). 0x200-0x206F\r
+  {(CHAR16)0x209F,  1},       // Superscripts and subscripts. 0x2070-0x209F\r
+  {(CHAR16)0x20CF,  1},       // Currency symbols. 0x20A0-0x20CF\r
+  {(CHAR16)0x20FF,  1},       // Combining diacritical marks for symbols. 0x20D0-0x20FF\r
+  {(CHAR16)0x214F,  1},       // Letterlike sympbols. 0x2100-0x214F\r
+  {(CHAR16)0x218F,  1},       // Number forms. 0x2150-0x218F\r
+  {(CHAR16)0x21FF,  1},       // Arrows. 0x2190-0x21FF\r
+  {(CHAR16)0x22FF,  1},       // Mathematical operators. 0x2200-0x22FF\r
+  {(CHAR16)0x23FF,  1},       // Miscellaneous technical. 0x2300-0x23FF\r
+  {(CHAR16)0x243F,  1},       // Control pictures. 0x2400-0x243F\r
+  {(CHAR16)0x245F,  1},       // Optical character recognition. 0x2440-0x245F\r
+  {(CHAR16)0x24FF,  1},       // Enclosed alphanumerics. 0x2460-0x24FF\r
+  {(CHAR16)0x257F,  1},       // Box drawing. 0x2500-0x257F\r
+  {(CHAR16)0x259F,  1},       // Block elements. 0x2580-0x259F\r
+  {(CHAR16)0x25FF,  1},       // Geometric shapes. 0x25A0-0x25FF\r
+  {(CHAR16)0x26FF,  1},       // Miscellaneous symbols. 0x2600-0x26FF\r
+  {(CHAR16)0x27BF,  1},       // Dingbats. 0x2700-0x27BF\r
+  {(CHAR16)0x2FFF,  0},       // Reserved. 0x27C0-0x2FFF\r
+  *\r
+  */\r
+\r
+  //\r
+  // CJK phonetics and symbol area\r
+  //\r
+  {(CHAR16)0x33FF,  2},\r
+  /*\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
+   * the same category and they are all wide glyph. This will reduce search\r
+   * time and table size. The merge will omit the reserved code.\r
+   *\r
+   * Remove the above item if below is un-commented.\r
+   *\r
+  {(CHAR16)0x303F,  2},       // CJK symbols and punctuation. 0x3000-0x303F\r
+  {(CHAR16)0x309F,  2},       // Hiragana. 0x3040-0x309F\r
+  {(CHAR16)0x30FF,  2},       // Katakana. 0x30A0-0x30FF\r
+  {(CHAR16)0x312F,  2},       // Bopomofo. 0x3100-0x312F\r
+  {(CHAR16)0x318F,  2},       // Hangul compatibility jamo. 0x3130-0x318F\r
+  {(CHAR16)0x319F,  2},       // Kanbun. 0x3190-0x319F\r
+  {(CHAR16)0x31FF,  0},       // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF\r
+  {(CHAR16)0x32FF,  2},       // Enclosed CJK letters and months. 0x3200-0x32FF\r
+  {(CHAR16)0x33FF,  2},       // CJK compatibility. 0x3300-0x33FF\r
+  *\r
+  */\r
+\r
+  //\r
+  // CJK ideograph area\r
+  //\r
+  {(CHAR16)0x9FFF,  2},\r
+  /*\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
+   * the same category and they are all wide glyph. This will reduce search\r
+   * time and table size. The merge will omit the reserved code.\r
+   *\r
+   * Remove the above item if below is un-commented.\r
+   *\r
+  {(CHAR16)0x4DFF,  0},       // Reserved. 0x3400-0x4DBF as CJK unified ideographs \r
+                      // extension A in ver3.0. 0x3400-0x4DFF\r
+  {(CHAR16)0x9FFF,  2},       // CJK unified ideographs. 0x4E00-0x9FFF\r
+  *\r
+  */\r
+\r
+  //\r
+  // Reserved\r
+  //\r
+  {(CHAR16)0xABFF,  0},       // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0\r
+  // as Yi radicals in ver3.0. 0xA000-0xABFF\r
+  //\r
+  // Hangul syllables\r
+  //\r
+  {(CHAR16)0xD7FF,  2},\r
+  /*\r
+   * Merge the blocks and replace them with the above entry as they fall to \r
+   * the same category and they are all wide glyph. This will reduce search\r
+   * time and table size. The merge will omit the reserved code.\r
+   *\r
+   * Remove the above item if below is un-commented.\r
+   *\r
+  {(CHAR16)0xD7A3,  2},       // Hangul syllables. 0xAC00-0xD7A3\r
+  {(CHAR16)0xD7FF,  0},       // Reserved. 0xD7A3-0xD7FF\r
+  *\r
+  */\r
+\r
+  //\r
+  // Surrogates area\r
+  //\r
+  {(CHAR16)0xDFFF,  0},       // Surrogates, not used now. 0xD800-0xDFFF\r
+\r
+  //\r
+  // Private use area\r
+  //\r
+  {(CHAR16)0xF8FF,  0},       // Private use area. 0xE000-0xF8FF\r
+\r
+  //\r
+  // Compatibility area and specials\r
+  //\r
+  {(CHAR16)0xFAFF,  2},       // CJK compatibility ideographs. 0xF900-0xFAFF\r
+  {(CHAR16)0xFB4F,  1},       // Alphabetic presentation forms. 0xFB00-0xFB4F\r
+  {(CHAR16)0xFDFF,  1},       // Arabic presentation forms-A. 0xFB50-0xFDFF\r
+  {(CHAR16)0xFE1F,  0},       // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F\r
+  {(CHAR16)0xFE2F,  1},       // Combining half marks. 0xFE20-0xFE2F\r
+  {(CHAR16)0xFE4F,  2},       // CJK compatibility forms. 0xFE30-0xFE4F\r
+  {(CHAR16)0xFE6F,  1},       // Small Form Variants. 0xFE50-0xFE6F\r
+  {(CHAR16)0xFEFF,  1},       // Arabic presentation forms-B. 0xFE70-0xFEFF\r
+  {(CHAR16)0xFFEF,  1},       // Half width and full width forms. 0xFF00-0xFFEF\r
+  {(CHAR16)0xFFFF,  0},       // Speicials. 0xFFF0-0xFFFF\r
+};\r
+\r
+/**\r
+  This function computes and returns the width of the Unicode character \r
+  specified by UnicodeChar.\r
+\r
+  @param  UnicodeChar   A Unicode character.\r
+\r
+  @retval 0             The width if UnicodeChar could not be determined.\r
+  @retval 1             UnicodeChar is a narrow glyph.\r
+  @retval 2             UnicodeChar is a wide glyph.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GlueGetGlyphWidth (\r
+  IN CHAR16  UnicodeChar\r
+  )\r
+{\r
+  UINTN               Index;\r
+  UINTN               Low;\r
+  UINTN               High;\r
+  UNICODE_WIDTH_ENTRY *Item;\r
+\r
+  Item  = NULL;\r
+  Low   = 0;\r
+  High  = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1;\r
+  while (Low <= High) {\r
+    Index = (Low + High) >> 1;\r
+    Item  = &(mUnicodeWidthTable[Index]);\r
+    if (Index == 0) {\r
+      if (UnicodeChar <= Item->WChar) {\r
+        break;\r
+      }\r
+\r
+      return 0;\r
+    }\r
+\r
+    if (UnicodeChar > Item->WChar) {\r
+      Low = Index + 1;\r
+    } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) {\r
+      High = Index - 1;\r
+    } else {\r
+      //\r
+      // Index - 1 < UnicodeChar <= Index. Found\r
+      //\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (Low <= High) {\r
+    return Item->Width;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+/**\r
+  This function computes and returns the display length of\r
+  the Null-terminated Unicode string specified by String.\r
+  If String is NULL, then 0 is returned.\r
+  If any of the widths of the Unicode characters in String\r
+  can not be determined, then 0 is returned.\r
+\r
+  @param  String      A pointer to a Null-terminated Unicode string.\r
+\r
+  @return The display length of the Null-terminated Unicode string specified by String.\r
+  \r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeStringDisplayLength (\r
+  IN CONST CHAR16  *String\r
+  )\r
+{\r
+  UINTN      Length;\r
+  UINTN      Width;\r
+\r
+  if (String == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  Length = 0;\r
+  while (*String != 0) {\r
+    Width = GetGlyphWidth (*String);\r
+    if (Width == 0) {\r
+      return 0;\r
+    }\r
+\r
+    Length += Width;\r
+    String++;\r
+  }\r
+\r
+  return Length;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
new file mode 100644 (file)
index 0000000..0454dac
--- /dev/null
@@ -0,0 +1,813 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+**/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+#include "Library\EdkIIGlueMemoryAllocationLib.h"\r
+\r
+\r
+/**\r
+  Compare whether two names of languages are identical.\r
+\r
+  @param  Language1 Name of language 1.\r
+  @param  Language2 Name of language 2.\r
+\r
+  @retval TRUE      Language 1 and language 2 are the same.\r
+  @retval FALSE     Language 1 and language 2 are not the same.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+CompareIso639LanguageCode (\r
+  IN CONST CHAR8  *Language1,\r
+  IN CONST CHAR8  *Language2\r
+  )\r
+{\r
+  UINT32  Name1;\r
+  UINT32  Name2;\r
+\r
+  Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
+  Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
+\r
+  return (BOOLEAN) (Name1 == Name2);\r
+}\r
+\r
+/**\r
+  This function searches the list of configuration tables stored in the EFI System \r
+  Table for a table with a GUID that matches TableGuid.  If a match is found, \r
+  then a pointer to the configuration table is returned in Table, and EFI_SUCCESS \r
+  is returned.  If a matching GUID is not found, then EFI_NOT_FOUND is returned.\r
+\r
+  @param  TableGuid       Pointer to table's GUID type..\r
+  @param  Table           Pointer to the table associated with TableGuid in the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS     A configuration table matching TableGuid was found.\r
+  @retval EFI_NOT_FOUND   A configuration table matching TableGuid could not be found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetSystemConfigurationTable (  \r
+  IN  EFI_GUID  *TableGuid,\r
+  OUT VOID      **Table\r
+  )\r
+{\r
+  EFI_SYSTEM_TABLE  *SystemTable;\r
+  UINTN             Index;\r
+\r
+  ASSERT (TableGuid != NULL);\r
+  ASSERT (Table != NULL);\r
+\r
+  SystemTable = gST;\r
+  *Table = NULL;\r
+  for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {\r
+    if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {\r
+      *Table = SystemTable->ConfigurationTable[Index].VendorTable;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  This function causes the notification function to be executed for every protocol \r
+  of type ProtocolGuid instance that exists in the system when this function is \r
+  invoked.  In addition, every time a protocol of type ProtocolGuid instance is \r
+  installed or reinstalled, the notification function is also executed.\r
+\r
+  @param  ProtocolGuid    Supplies GUID of the protocol upon whose installation the event is fired.\r
+  @param  NotifyTpl       Supplies the task priority level of the event notifications.\r
+  @param  NotifyFunction  Supplies the function to notify when the event is signaled.\r
+  @param  NotifyContext   The context parameter to pass to NotifyFunction.\r
+  @param  Registration    A pointer to a memory location to receive the registration value.\r
+\r
+  @return The notification event that was created. \r
+\r
+**/\r
+EFI_EVENT\r
+EFIAPI\r
+EfiCreateProtocolNotifyEvent(\r
+  IN  EFI_GUID          *ProtocolGuid,\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT VOID              **Registration\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;\r
+\r
+  //\r
+  // Create the event\r
+  //\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &Event\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Register for protocol notifactions on this event\r
+  //\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  ProtocolGuid,\r
+                  Event,\r
+                  Registration\r
+                  );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Kick the event so we will perform an initial pass of\r
+  // current installed drivers\r
+  //\r
+\r
+  gBS->SignalEvent (Event);\r
+  return Event;\r
+}\r
+\r
+/**\r
+  This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
+  This event is signaled with EfiNamedEventSignal().  This provide the ability for \r
+  one or more listeners on the same event named by the GUID specified by Name.\r
+\r
+  @param  Name                  Supplies GUID name of the event.\r
+  @param  NotifyTpl             Supplies the task priority level of the event notifications.\r
+  @param  NotifyFunction        Supplies the function to notify when the event is signaled.\r
+  @param  NotifyContext         The context parameter to pass to NotifyFunction. \r
+  @param  Registration          A pointer to a memory location to receive the registration value.\r
+\r
+  @retval EFI_SUCCESS           A named event was created.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resource to create the named event.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNamedEventListen (\r
+  IN CONST EFI_GUID    *Name,\r
+  IN EFI_TPL           NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY  NotifyFunction,\r
+  IN CONST VOID        *NotifyContext,  OPTIONAL\r
+  OUT VOID             *Registration OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;\r
+  VOID        *RegistrationLocal;\r
+\r
+  //\r
+  // Create event\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  (VOID *) NotifyContext,\r
+                  &Event\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // The Registration is not optional to RegisterProtocolNotify().\r
+  // To make it optional to EfiNamedEventListen(), may need to substitute with a local.\r
+  //\r
+  if (Registration != NULL) {\r
+    RegistrationLocal = Registration;\r
+  } else {\r
+    RegistrationLocal = &RegistrationLocal;\r
+  }\r
+\r
+  //\r
+  // Register for an installation of protocol interface\r
+  //\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  (EFI_GUID *) Name,\r
+                  Event,\r
+                  RegistrationLocal\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function signals the named event specified by Name.  The named event must \r
+  have been created with EfiNamedEventListen().\r
+\r
+  @param  Name                  Supplies GUID name of the event.\r
+\r
+  @retval EFI_SUCCESS           A named event was signaled.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resource to signal the named event.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiNamedEventSignal (\r
+  IN CONST EFI_GUID  *Name\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  (EFI_GUID *) Name,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  Handle,\r
+                  (EFI_GUID *) Name,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/** \r
+  Returns the current TPL.\r
+\r
+  This function returns the current TPL.  There is no EFI service to directly \r
+  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level \r
+  can then immediately be restored back to the current TPL level with a call \r
+  to RestoreTPL().\r
+\r
+  @param  VOID\r
+\r
+  @retvale EFI_TPL              The current TPL.\r
+\r
+**/\r
+EFI_TPL\r
+EFIAPI\r
+EfiGetCurrentTpl (\r
+  VOID\r
+  )\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  Tpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); \r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return Tpl;\r
+}\r
+\r
+\r
+/**\r
+  This function initializes a basic mutual exclusion lock to the released state \r
+  and returns the lock.  Each lock provides mutual exclusion access at its task \r
+  priority level.  Since there is no preemption or multiprocessor support in EFI,\r
+  acquiring the lock only consists of raising to the locks TPL.\r
+\r
+  @param  Lock       A pointer to the lock data structure to initialize.\r
+  @param  Priority   EFI TPL associated with the lock.\r
+\r
+  @return The lock.\r
+\r
+**/\r
+EFI_LOCK *\r
+EFIAPI\r
+GlueEfiInitializeLock (\r
+  IN OUT EFI_LOCK  *Lock,\r
+  IN EFI_TPL        Priority\r
+  )\r
+{\r
+  ASSERT (Lock != NULL);\r
+  ASSERT (Priority <= EFI_TPL_HIGH_LEVEL);\r
+\r
+  Lock->Tpl       = Priority;\r
+  Lock->OwnerTpl  = EFI_TPL_APPLICATION;\r
+  Lock->Lock      = EfiLockReleased ;\r
+  return Lock;\r
+}\r
+\r
+/**\r
+  This function raises the system's current task priority level to the task \r
+  priority level of the mutual exclusion lock.  Then, it places the lock in the \r
+  acquired state.\r
+\r
+  @param  Priority  The task priority level of the lock.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  ASSERT (Lock != NULL);\r
+  ASSERT (Lock->Lock == EfiLockReleased);\r
+\r
+  Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+  Lock->Lock     = EfiLockAcquired;\r
+}\r
+\r
+/**\r
+  This function raises the system's current task priority level to the task \r
+  priority level of the mutual exclusion lock.  Then, it attempts to place the \r
+  lock in the acquired state.\r
+\r
+  @param  Lock              A pointer to the lock to acquire.\r
+\r
+  @retval EFI_SUCCESS       The lock was acquired.\r
+  @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+\r
+  ASSERT (Lock != NULL);\r
+  ASSERT (Lock->Lock != EfiLockUninitialized);\r
+\r
+  if (Lock->Lock == EfiLockAcquired) {\r
+    //\r
+    // Lock is already owned, so bail out\r
+    //\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+\r
+  Lock->Lock = EfiLockAcquired;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function transitions a mutual exclusion lock from the acquired state to \r
+  the released state, and restores the system's task priority level to its \r
+  previous level.\r
+\r
+  @param  Lock  A pointer to the lock to release.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  ASSERT (Lock != NULL);\r
+  ASSERT (Lock->Lock == EfiLockAcquired);\r
+\r
+  Tpl = Lock->OwnerTpl;\r
+  \r
+  Lock->Lock = EfiLockReleased;\r
+\r
+  gBS->RestoreTPL (Tpl);\r
+}\r
+\r
+/**\r
+  Tests whether a controller handle is being managed by a specific driver.\r
+\r
+  This function tests whether the driver specified by DriverBindingHandle is\r
+  currently managing the controller specified by ControllerHandle.  This test\r
+  is performed by evaluating if the the protocol specified by ProtocolGuid is\r
+  present on ControllerHandle and is was opened by DriverBindingHandle with an\r
+  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
+  If ProtocolGuid is NULL, then ASSERT().\r
+\r
+  @param  ControllerHandle     A handle for a controller to test.\r
+  @param  DriverBindingHandle  Specifies the driver binding handle for the\r
+                               driver.\r
+  @param  ProtocolGuid         Specifies the protocol that the driver specified\r
+                               by DriverBindingHandle opens in its Start()\r
+                               function.\r
+\r
+  @retval EFI_SUCCESS          ControllerHandle is managed by the driver\r
+                               specifed by DriverBindingHandle.\r
+  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver\r
+                               specifed by DriverBindingHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestManagedDevice (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       DriverBindingHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  )\r
+{\r
+  EFI_STATUS     Status;\r
+  VOID           *ManagedInterface;\r
+\r
+  ASSERT (ProtocolGuid != NULL);\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  (EFI_GUID *) ProtocolGuid,\r
+                  &ManagedInterface,\r
+                  DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+           ControllerHandle,\r
+           (EFI_GUID *) ProtocolGuid,\r
+           DriverBindingHandle,\r
+           ControllerHandle\r
+           );\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Tests whether a child handle is a child device of the controller.\r
+\r
+  This function tests whether ChildHandle is one of the children of\r
+  ControllerHandle.  This test is performed by checking to see if the protocol\r
+  specified by ProtocolGuid is present on ControllerHandle and opened by\r
+  ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  If ProtocolGuid is NULL, then ASSERT().\r
+\r
+  @param  ControllerHandle     A handle for a (parent) controller to test. \r
+  @param  ChildHandle          A child handle to test.\r
+  @param  ConsumsedGuid        Supplies the protocol that the child controller\r
+                               opens on its parent controller. \r
+\r
+  @retval EFI_SUCCESS          ChildHandle is a child of the ControllerHandle.\r
+  @retval EFI_UNSUPPORTED      ChildHandle is not a child of the\r
+                               ControllerHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestChildHandle (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       ChildHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  )\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY   *OpenInfoBuffer;\r
+  UINTN                                 EntryCount;\r
+  UINTN                                 Index;\r
+\r
+  ASSERT (ProtocolGuid != NULL);\r
+\r
+  //\r
+  // Retrieve the list of agents that are consuming the specific protocol\r
+  // on ControllerHandle.\r
+  //\r
+  Status = gBS->OpenProtocolInformation (\r
+                  ControllerHandle,\r
+                  (EFI_GUID *) ProtocolGuid,\r
+                  &OpenInfoBuffer,\r
+                  &EntryCount\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Inspect if ChildHandle is one of the agents.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  for (Index = 0; Index < EntryCount; Index++) {\r
+    if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) &&\r
+        (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+      Status = EFI_SUCCESS;\r
+      break;\r
+    }\r
+  }\r
+  \r
+  FreePool (OpenInfoBuffer);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  This function looks up a Unicode string in UnicodeStringTable.  If Language is \r
+  a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
+  that matches the language code specified by Language, then it is returned in \r
+  UnicodeString.\r
+\r
+  @param  Language                A pointer to the ISO 639-2 language code for the \r
+                                  Unicode string to look up and return.\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes \r
+                                  that the Unicode string table supports.  Language \r
+                                  must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string from UnicodeStringTable\r
+                                  that matches the language specified by Language.\r
+\r
+  @retval  EFI_SUCCESS            The Unicode string that matches the language \r
+                                  specified by Language was found\r
+                                  in the table of Unicoide strings UnicodeStringTable, \r
+                                  and it was returned in UnicodeString.\r
+  @retval  EFI_INVALID_PARAMETER  Language is NULL.\r
+  @retval  EFI_INVALID_PARAMETER  UnicodeString is NULL.\r
+  @retval  EFI_UNSUPPORTED        SupportedLanguages is NULL.\r
+  @retval  EFI_UNSUPPORTED        UnicodeStringTable is NULL.\r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
+  @retval  EFI_UNSUPPORTED        The language specified by Language is not \r
+                                  supported by UnicodeStringTable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LookupUnicodeString (\r
+  IN CONST CHAR8                     *Language,\r
+  IN CONST CHAR8                     *SupportedLanguages,\r
+  IN CONST EFI_UNICODE_STRING_TABLE  *UnicodeStringTable,\r
+  OUT CHAR16                         **UnicodeString\r
+  )\r
+{\r
+  //\r
+  // Make sure the parameters are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, or the Unicode String Table is empty, then the\r
+  // Unicode String specified by Language is not supported by this Unicode String Table\r
+  //\r
+  if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is in the set of Supported Languages\r
+  //\r
+  while (*SupportedLanguages != 0) {\r
+    if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+\r
+      //\r
+      // Search the Unicode String Table for the matching Language specifier\r
+      //\r
+      while (UnicodeStringTable->Language != NULL) {\r
+        if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {\r
+\r
+          //\r
+          // A matching string was found, so return it\r
+          //\r
+          *UnicodeString = UnicodeStringTable->UnicodeString;\r
+          return EFI_SUCCESS;\r
+        }\r
+\r
+        UnicodeStringTable++;\r
+      }\r
+\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    SupportedLanguages += 3;\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This function adds a Unicode string to UnicodeStringTable.\r
+  If Language is a member of SupportedLanguages then UnicodeString is added to \r
+  UnicodeStringTable.  New buffers are allocated for both Language and \r
+  UnicodeString.  The contents of Language and UnicodeString are copied into \r
+  these new buffers.  These buffers are automatically freed when \r
+  FreeUnicodeStringTable() is called.\r
+\r
+  @param  Language                A pointer to the ISO 639-2 language code for the Unicode \r
+                                  string to add.\r
+  @param  SupportedLanguages      A pointer to the set of ISO 639-2 language codes\r
+                                  that the Unicode string table supports.\r
+                                  Language must be a member of this set.\r
+  @param  UnicodeStringTable      A pointer to the table of Unicode strings.\r
+  @param  UnicodeString           A pointer to the Unicode string to add.\r
+\r
+  @retval EFI_SUCCESS             The Unicode string that matches the language \r
+                                  specified by Language was found in the table of \r
+                                  Unicode strings UnicodeStringTable, and it was \r
+                                  returned in UnicodeString.\r
+  @retval EFI_INVALID_PARAMETER   Language is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is NULL.\r
+  @retval EFI_INVALID_PARAMETER   UnicodeString is an empty string.\r
+  @retval EFI_UNSUPPORTED         SupportedLanguages is NULL.\r
+  @retval EFI_ALREADY_STARTED     A Unicode string with language Language is \r
+                                  already present in UnicodeStringTable.\r
+  @retval EFI_OUT_OF_RESOURCES    There is not enough memory to add another \r
+                                  Unicode string to UnicodeStringTable.\r
+  @retval EFI_UNSUPPORTED         The language specified by Language is not a \r
+                                  member of SupportedLanguages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddUnicodeString (\r
+  IN CONST CHAR8               *Language,\r
+  IN CONST CHAR8               *SupportedLanguages,\r
+  IN EFI_UNICODE_STRING_TABLE  **UnicodeStringTable,\r
+  IN CONST CHAR16              *UnicodeString\r
+  )\r
+{\r
+  UINTN                     NumberOfEntries;\r
+  EFI_UNICODE_STRING_TABLE  *OldUnicodeStringTable;\r
+  EFI_UNICODE_STRING_TABLE  *NewUnicodeStringTable;\r
+  UINTN                     UnicodeStringLength;\r
+\r
+  //\r
+  // Make sure the parameter are valid\r
+  //\r
+  if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If there are no supported languages, then a Unicode String can not be added\r
+  //\r
+  if (SupportedLanguages == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // If the Unicode String is empty, then a Unicode String can not be added\r
+  //\r
+  if (UnicodeString[0] == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Make sure Language is a member of SupportedLanguages\r
+  //\r
+  while (*SupportedLanguages != 0) {\r
+    if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+\r
+      //\r
+      // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
+      //\r
+      NumberOfEntries = 0;\r
+      if (*UnicodeStringTable != NULL) {\r
+        OldUnicodeStringTable = *UnicodeStringTable;\r
+        while (OldUnicodeStringTable->Language != NULL) {\r
+          if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {\r
+            return EFI_ALREADY_STARTED;\r
+          }\r
+\r
+          OldUnicodeStringTable++;\r
+          NumberOfEntries++;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Allocate space for a new Unicode String Table.  It must hold the current number of\r
+      // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
+      // marker\r
+      //\r
+      NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
+      if (NewUnicodeStringTable == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // If the current Unicode String Table contains any entries, then copy them to the\r
+      // newly allocated Unicode String Table.\r
+      //\r
+      if (*UnicodeStringTable != NULL) {\r
+        CopyMem (\r
+           NewUnicodeStringTable,\r
+           *UnicodeStringTable,\r
+           NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
+           );\r
+      }\r
+\r
+      //\r
+      // Allocate space for a copy of the Language specifier\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language);\r
+      if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
+        (gBS->FreePool) (NewUnicodeStringTable);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // Compute the length of the Unicode String\r
+      //\r
+      for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)\r
+        ;\r
+\r
+      //\r
+      // Allocate space for a copy of the Unicode String\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (\r
+                                                              (UnicodeStringLength + 1) * sizeof (CHAR16),\r
+                                                              UnicodeString\r
+                                                              );\r
+      if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
+        (gBS->FreePool) (NewUnicodeStringTable[NumberOfEntries].Language);\r
+        (gBS->FreePool) (NewUnicodeStringTable);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      //\r
+      // Mark the end of the Unicode String Table\r
+      //\r
+      NewUnicodeStringTable[NumberOfEntries + 1].Language       = NULL;\r
+      NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString  = NULL;\r
+\r
+      //\r
+      // Free the old Unicode String Table\r
+      //\r
+      if (*UnicodeStringTable != NULL) {\r
+        (gBS->FreePool) (*UnicodeStringTable);\r
+      }\r
+\r
+      //\r
+      // Point UnicodeStringTable at the newly allocated Unicode String Table\r
+      //\r
+      *UnicodeStringTable = NewUnicodeStringTable;\r
+\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    SupportedLanguages += 3;\r
+  }\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This function frees the table of Unicode strings in UnicodeStringTable.\r
+  If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
+  Otherwise, each language code, and each Unicode string in the Unicode string \r
+  table are freed, and EFI_SUCCESS is returned.\r
+\r
+  @param  UnicodeStringTable  A pointer to the table of Unicode strings.\r
+\r
+  @retval EFI_SUCCESS         The Unicode string table was freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FreeUnicodeStringTable (\r
+  IN EFI_UNICODE_STRING_TABLE  *UnicodeStringTable\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  //\r
+  // If the Unicode String Table is NULL, then it is already freed\r
+  //\r
+  if (UnicodeStringTable == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Loop through the Unicode String Table until we reach the end of table marker\r
+  //\r
+  for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {\r
+\r
+    //\r
+    // Free the Language string from the Unicode String Table\r
+    //\r
+    (gBS->FreePool) (UnicodeStringTable[Index].Language);\r
+\r
+    //\r
+    // Free the Unicode String from the Unicode String Table\r
+    //\r
+    if (UnicodeStringTable[Index].UnicodeString != NULL) {\r
+      (gBS->FreePool) (UnicodeStringTable[Index].UnicodeString);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Free the Unicode String Table itself\r
+  //\r
+  (gBS->FreePool) (UnicodeStringTable);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf
new file mode 100644 (file)
index 0000000..0d6b8ac
--- /dev/null
@@ -0,0 +1,89 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   UefiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for UefiLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueUefiLib \r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  UefiLib.c \r
+  Console.c\r
+  UefiNotTiano.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
\r
+  $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath\r
+\r
+[libraries.common]\r
+  EdkIIGlueBaseLib\r
+  EdkIIGlueBaseMemoryLib\r
+  EdkIIGlueUefiBootServicesTableLib\r
+#\r
+# MemoryAllocationLib instance\r
+#\r
+  EdkIIGlueDxeMemoryAllocationLib\r
+  EfiGuidLib\r
+\r
+[libraries.ia32]\r
+  \r
+\r
+[libraries.x64]\r
+  \r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
new file mode 100644 (file)
index 0000000..8fbfaa6
--- /dev/null
@@ -0,0 +1,382 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  \r
+\r
+Module Name:\r
+\r
+  UefiNotTiano.c\r
+  \r
+Abstract: \r
+\r
+  Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r
+\r
+  Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r
+  oldconflicts with library functions and supporting implementations of the old \r
+  (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+\r
+/**\r
+  An empty function to pass error checking of CreateEventEx (). \r
+  \r
+  This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r
+  checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
+  \r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+InternalEmptyFuntion (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  return;\r
+}\r
+\r
+/**\r
+  Create a Legacy Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiCreateEventLegacyBoot (\r
+  OUT EFI_EVENT  *LegacyBootEvent\r
+  )\r
+{\r
+  return EfiCreateEventLegacyBootEx (\r
+           EFI_TPL_CALLBACK,\r
+           InternalEmptyFuntion,\r
+           NULL,\r
+           LegacyBootEvent\r
+           );\r
+}\r
+\r
+/**\r
+  Create an EFI event in the Legacy Boot Event Group and allows\r
+  the caller to specify a notification function.  \r
+  \r
+  This function abstracts the creation of the Legacy Boot Event.\r
+  The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
+  This library abstracts the caller from how this event is created to prevent\r
+  to code form having to change with the version of the specification supported.\r
+  If LegacyBootEvent is NULL, then ASSERT().\r
+\r
+  @param  NotifyTpl         The task priority level of the event.\r
+  @param  NotifyFunction    The notification function to call when the event is signaled.\r
+  @param  NotifyContext     The content to pass to NotifyFunction when the event is signaled.\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventLegacyBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *LegacyBootEvent\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  ASSERT (LegacyBootEvent != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  LegacyBootEvent\r
+                  );\r
+#else\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventLegacyBootGuid,\r
+                  LegacyBootEvent\r
+                  );\r
+#endif\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GlueEfiCreateEventReadyToBoot (\r
+  OUT EFI_EVENT  *ReadyToBootEvent\r
+  )\r
+{\r
+  return EfiCreateEventReadyToBootEx (\r
+           EFI_TPL_CALLBACK,\r
+           InternalEmptyFuntion,\r
+           NULL,\r
+           ReadyToBootEvent\r
+           );\r
+}\r
+\r
+/**\r
+  Create an EFI event in the Ready To Boot Event Group and allows\r
+  the caller to specify a notification function.  \r
+  \r
+  This function abstracts the creation of the Ready to Boot Event.\r
+  The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
+  This library abstracts the caller from how this event is created to prevent\r
+  to code form having to change with the version of the specification supported.\r
+  If ReadyToBootEvent is NULL, then ASSERT().\r
+\r
+  @param  NotifyTpl         The task priority level of the event.\r
+  @param  NotifyFunction    The notification function to call when the event is signaled.\r
+  @param  NotifyContext     The content to pass to NotifyFunction when the event is signaled.\r
+  @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
+\r
+  @retval EFI_SUCCESS       Event was created.\r
+  @retval Other             Event was not created.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiCreateEventReadyToBootEx (\r
+  IN  EFI_TPL           NotifyTpl,\r
+  IN  EFI_EVENT_NOTIFY  NotifyFunction,  OPTIONAL\r
+  IN  VOID              *NotifyContext,  OPTIONAL\r
+  OUT EFI_EVENT         *ReadyToBootEvent\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  ASSERT (ReadyToBootEvent != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  ReadyToBootEvent\r
+                  );\r
+#else\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventReadyToBootGuid,\r
+                  ReadyToBootEvent\r
+                  );\r
+#endif\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Signal a Ready to Boot Event.  \r
+  \r
+  Create a Ready to Boot Event. Signal it and close it. This causes other \r
+  events of the same event group to be signaled in other modules. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiSignalEventReadyToBoot (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_EVENT     ReadyToBootEvent;\r
+\r
+  Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (ReadyToBootEvent);\r
+    gBS->CloseEvent (ReadyToBootEvent);\r
+  }\r
+}\r
+\r
+/**\r
+  Signal a Legacy Boot Event.  \r
+  \r
+  Create a legacy Boot Event. Signal it and close it. This causes other \r
+  events of the same event group to be signaled in other modules. \r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiSignalEventLegacyBoot (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_EVENT     LegacyBootEvent;\r
+\r
+  Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (LegacyBootEvent);\r
+    gBS->CloseEvent (LegacyBootEvent);\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid \r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability. The return value to this\r
+  function points to a location in FvDevicePathNode and it does not allocate\r
+  new memory for the GUID pointer that is returned.\r
+\r
+  @param  FvDevicePathNode  Pointer to FV device path to check.\r
+\r
+  @retval NULL              FvDevicePathNode is not valid.\r
+  @retval Other             FvDevicePathNode is valid and pointer to NameGuid was returned.\r
+\r
+**/\r
+EFI_GUID *\r
+EFIAPI\r
+GlueEfiGetNameGuidFromFwVolDevicePathNode (\r
+  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
+  )\r
+{\r
+  ASSERT (FvDevicePathNode != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000) \r
+  //\r
+  // Use old Device Path\r
+  //\r
+  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
+    return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
+  }\r
+\r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  // check here : piwg or tiano\r
+  if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) {        \r
+    if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
+      if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
+        return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
+      }\r
+    }\r
+  }\r
+#endif  \r
+  return NULL;\r
+}\r
+\r
+\r
+/**\r
+  Initialize a Firmware Volume (FV) Media Device Path node.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability.\r
+\r
+  @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
+  @param  NameGuid          FV file name to use in FvDevicePathNode\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GlueEfiInitializeFwVolDevicepathNode (\r
+  IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode,\r
+  IN CONST EFI_GUID                         *NameGuid\r
+  )\r
+{\r
+  ASSERT (FvDevicePathNode  != NULL);\r
+  ASSERT (NameGuid          != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000) \r
+  //\r
+  // Use old Device Path\r
+  //\r
+  FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+  \r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  FvDevicePathNode->Piwg.Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Piwg.Header.SubType  = MEDIA_VENDOR_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+\r
+  //\r
+  // Add the GUID for generic PIWG device paths\r
+  //\r
+  CopyGuid (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
+\r
+  //\r
+  // Add in the FW Vol File Path PIWG defined inforation\r
+  //\r
+  FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
+\r
+#endif\r
+\r
+  CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
+\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c
new file mode 100644 (file)
index 0000000..77ee80a
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+\r
+\r
+Module Name:\r
+\r
+  UefiRuntimeServicesTableLib.c\r
+  \r
+Abstract: \r
+\r
+  UEFI Runtime Services Table Library.\r
+\r
+--*/\r
+\r
+#include "EdkIIGlueUefi.h"\r
+\r
+EFI_RUNTIME_SERVICES  *gRT = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer of Runtime Services Table.\r
+\r
+  The constructor function caches the pointer of Runtime Services Table.\r
+  It will ASSERT() if the pointer of Runtime Services Table is NULL.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiRuntimeServicesTableLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  //\r
+  // Cache pointer to the EFI Runtime Services Table\r
+  //\r
+  gRT = SystemTable->RuntimeServices;\r
+  ASSERT (gRT != NULL);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
new file mode 100644 (file)
index 0000000..86c499c
--- /dev/null
@@ -0,0 +1,78 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.              \r
+# \r
+#  Module Name:\r
+#\r
+#   UefiRuntimeServicesTableLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for UefiRuntimeServicesTableLib.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EdkIIGlueUefiRuntimeServicesTableLib \r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  UefiRuntimeServicesTableLib.c \r
+\r
+[sources.ia32]\r
+\r
+[sources.x64]\r
+\r
+[sources.ipf]\r
+\r
+[sources.ebc]\r
+  \r
+\r
+[includes.common]\r
+  .\r
+  ..\..\Include\r
+  ..\..\include\Library\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath\r
+\r
+[libraries.common]\r
+\r
+[libraries.ia32]\r
+\r
+\r
+[libraries.x64]\r
+\r
+\r
+[nmake.common]\r
+  C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006\r
+\r
+[nmake.ia32]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32\r
+\r
+[nmake.x64]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64\r
+\r
+[nmake.ipf]\r
+  C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF\r
+\r
+[nmake.ebc]\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION\r
+  EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS)  /IGNORE:4006\r
+  EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
new file mode 100644 (file)
index 0000000..561345f
--- /dev/null
@@ -0,0 +1,84 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#   Module Name:\r
+#\r
+#     EfiCommonLib.inf\r
+#\r
+#   Abstract:\r
+#\r
+#     Component description file for the EFI common library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EfiCommonLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  EfiCompareGuid.c\r
+  EfiCompareMem.c\r
+  ReportStatusCode.c\r
+  PostCode.c\r
+  String.c\r
+  ValueToString.c\r
+  LinkedList.c\r
+\r
+[sources.ia32]\r
+  Ia32\EfiCopyMem.c\r
+  Ia32\EfiSetMem.c\r
+  Ia32\EfiZeroMem.c\r
+  Ia32\LShiftU64.c\r
+  Ia32\RShiftU64.c\r
+  Ia32\MultU64x32.c\r
+  Ia32\DivU64x32.c\r
+  Ia32\Power10U64.c\r
+  Ia32\Log2.c\r
+  Ia32\GetPowerOfTwo.c\r
+\r
+[sources.ipf]\r
+  EfiCopyMem.c\r
+  EfiSetMem.c\r
+  EfiZeroMem.c\r
+  Math.c\r
+\r
+[sources.ebc]\r
+  EfiCopyMem.c\r
+  EfiSetMem.c\r
+  EfiZeroMem.c\r
+  Math.c\r
+  \r
+[sources.x64]\r
+  x64\EfiCopyMem.asm\r
+  x64\EfiSetMem.asm\r
+  x64\EfiZeroMem.asm\r
+  Math.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  \r
+[libraries.common]\r
+  EdkFrameworkGuidLib\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c
new file mode 100644 (file)
index 0000000..ffaec95
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompareGuid.c\r
+\r
+Abstract:\r
+\r
+  Driver library routine to compare two GUIDs.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+BOOLEAN\r
+EfiCompareGuid (\r
+  IN EFI_GUID *Guid1,\r
+  IN EFI_GUID *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  TRUE     if Guid1 == Guid2\r
+  FALSE    if Guid1 != Guid2\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  //\r
+  // compare byte by byte\r
+  //\r
+  for (Index = 0; Index < 16; ++Index) {\r
+    if (*(((UINT8*) Guid1) + Index) != *(((UINT8*) Guid2) + Index)) {\r
+      return FALSE;\r
+    }\r
+  }\r
+  return TRUE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c
new file mode 100644 (file)
index 0000000..d640b9d
--- /dev/null
@@ -0,0 +1,76 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompareMem.c\r
+\r
+Abstract:\r
+\r
+  Generic compare-memory routine. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+\r
+INTN\r
+EfiCompareMem (\r
+  IN VOID     *MemOne,\r
+  IN VOID     *MemTwo,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two memory buffers of a given length.\r
+\r
+Arguments:\r
+\r
+  MemOne - First memory buffer\r
+\r
+  MemTwo - Second memory buffer\r
+\r
+  Len    - Length of Mem1 and Mem2 memory regions to compare\r
+\r
+Returns:\r
+\r
+  = 0     if MemOne == MemTwo\r
+\r
+--*/\r
+{\r
+  INTN ReturnValue;\r
+\r
+  if (!(EFI_UINTN_ALIGNED (MemOne) || EFI_UINTN_ALIGNED (MemTwo) || EFI_UINTN_ALIGNED (Length))) {\r
+    //\r
+    // If Destination/Source/Length are aligned do UINTN conpare\r
+    //\r
+    for (; Length > 0; Length -= sizeof (INTN), MemOne = (VOID *)((UINTN)MemOne + sizeof (INTN)), MemTwo = (VOID *)((UINTN)MemTwo + sizeof (INTN))) {\r
+      if (*(INTN *)MemOne != *(INTN *)MemTwo) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // If Destination/Source/Length not aligned do byte compare\r
+  //\r
+  for (; Length > 0; Length--, MemOne = (VOID *)((UINTN)MemOne + 1), MemTwo = (VOID *)((UINTN)MemTwo + 1)) {\r
+    ReturnValue = (INTN)(*(INT8 *)MemOne - *(INT8 *)MemTwo);\r
+    if (ReturnValue != 0) {\r
+      return ReturnValue;\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c
new file mode 100644 (file)
index 0000000..56c1dbd
--- /dev/null
@@ -0,0 +1,69 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCopyMem.c\r
+\r
+Abstract:\r
+\r
+  Implementation of the EfiCopyMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a\r
+  build for a particular platform easily if an optimized version \r
+  is desired.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+\r
+  if (Source < Destination) {\r
+    Destination8  = (CHAR8 *) Destination + Length - 1;\r
+    Source8       = (CHAR8 *) Source + Length - 1;\r
+    while (Length--) {\r
+      *(Destination8--) = *(Source8--);\r
+    }\r
+  } else {\r
+    Destination8  = (CHAR8 *) Destination;\r
+    Source8       = (CHAR8 *) Source;\r
+    while (Length--) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c
new file mode 100644 (file)
index 0000000..c677b6c
--- /dev/null
@@ -0,0 +1,65 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiSetMem.c\r
+\r
+Abstract:\r
+\r
+  Implementation of the EfiSetMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a\r
+  build for a particular platform easily if an optimized version \r
+  is desired.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiCommonLib.h"\r
+\r
+\r
+VOID\r
+EfiCommonLibSetMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size,\r
+  IN UINT8  Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to Value for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+  Value   - Value of the set operation.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT8  *Ptr;\r
+\r
+  if (Value == 0) {\r
+    EfiCommonLibZeroMem (Buffer, Size);\r
+  } else {\r
+    Ptr = Buffer;\r
+    while (Size--) {\r
+      *(Ptr++) = Value;\r
+    }\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c
new file mode 100644 (file)
index 0000000..5097be5
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiZeroMem.c\r
+\r
+Abstract:\r
+\r
+  Implementation of the EfiSetMem routine. This function is broken\r
+  out into its own source file so that it can be excluded from a\r
+  build for a particular platform easily if an optimized version \r
+  is desired.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+\r
+VOID\r
+EfiCommonLibZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to 0 for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT8  *Ptr;\r
+\r
+  Ptr = Buffer;\r
+  while (Size--) {\r
+    *(Ptr++) = 0;\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c
new file mode 100644 (file)
index 0000000..51aedf7
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DivU64x32.c\r
+\r
+Abstract:\r
+\r
+  64-bit division function for IA-32\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN UINT64   Dividend,\r
+  IN UINTN    Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
+  \r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+  \r
+N.B. only works for 31bit divisors!!\r
+\r
+--*/\r
+{\r
+  __asm {\r
+    xor edx, edx                    ; Clear EDX\r
+\r
+    mov eax, dword ptr Dividend[4]  ; Put high 32 bits of 64-bit dividend in EAX\r
+    mov ecx, Divisor                ; Put 32 bits divisor in ECX\r
+    div ecx                         ; Dividend   Divisor  Quoitent...Remainder\r
+                                    ;  0:EAX  /  ECX   =  EAX      EDX   \r
+\r
+    push eax                        ; Push quoitent in stack\r
+\r
+    mov eax, dword ptr Dividend[0]  ; Put low 32 bits of 64-bit dividend in EAX              \r
+    div ecx                         ; Leave the REMAINDER in EDX as High 32-bit of new dividend\r
+                                    ; Dividend   Divisor  Quoitent...Remainder              \r
+                                    ;  EDX:EAX  /  ECX   =  EAX      EDX               \r
+\r
+    mov ecx, Remainder              ; Put &REMAINDER to ecx\r
+\r
+    jecxz Label1                    ; If ecx == 0, no remainder exist, return with quoitent in EDX directly \r
+    mov dword ptr [ecx], edx        ; Put EDX through REMAINDER pointer in ECX \r
+\r
+Label1:\r
+    pop edx                         ; Pop High 32-bit QUOITENT to EDX\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
new file mode 100644 (file)
index 0000000..8ef8851
--- /dev/null
@@ -0,0 +1,184 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCopyMem.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized CopyMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64 MmxSave;\r
+  __asm {\r
+  \r
+  mov   ecx, Count\r
+  mov   esi, Source\r
+  mov   edi, Destination\r
+\r
+  ; First off, make sure we have no overlap. That is to say,\r
+  ;   if (Source == Destination)           => do nothing\r
+  ;   if (Source + Count <= Destination)   => regular copy\r
+  ;   if (Destination + Count <= Source)   => regular copy\r
+  ;   otherwise, do a reverse copy\r
+  mov   eax, esi\r
+  add   eax, ecx                      ; Source + Count\r
+  cmp   eax, edi\r
+  jle   _StartByteCopy\r
+\r
+  mov   eax, edi\r
+  add   eax, ecx                      ; Dest + Count\r
+  cmp   eax, esi\r
+  jle   _StartByteCopy\r
+\r
+  cmp   esi, edi\r
+  je    _CopyMemDone         \r
+  jl    _CopyOverlapped               ; too bad -- overlaps\r
+\r
+  ; Pick up misaligned start bytes to get destination pointer 4-byte aligned\r
+_StartByteCopy:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone                ; Count == 0, all done\r
+  mov   edx, edi\r
+  and   dl, 3                       ; check lower 2 bits of address\r
+  test  dl, dl          \r
+  je    SHORT _CopyBlocks           ; already aligned?\r
+\r
+  ; Copy a byte\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  inc   edi\r
+  inc   esi\r
+  jmp   _StartByteCopy               ; back to top of loop\r
+\r
+_CopyBlocks:\r
+  ; Compute how many 64-byte blocks we can clear \r
+  mov   eax, ecx                    ; get Count in eax\r
+  shr   eax, 6                      ; convert to 64-byte count\r
+  shl   eax, 6                      ; convert back to bytes\r
+  sub   ecx, eax                    ; subtract from the original count\r
+  shr   eax, 6                      ; and this is how many 64-byte blocks\r
+\r
+  ; If no 64-byte blocks, then skip \r
+  cmp   eax, 0\r
+  je    _CopyRemainingDWords\r
+\r
+  ; Save mm0\r
+  movq  MmxSave, mm0\r
+\r
+copymmx:\r
+  \r
+  movq  mm0, QWORD PTR ds:[esi]\r
+  movq  QWORD PTR ds:[edi], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+8]\r
+  movq  QWORD PTR ds:[edi+8], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+16]\r
+  movq  QWORD PTR ds:[edi+16], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+24]\r
+  movq  QWORD PTR ds:[edi+24], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+32]\r
+  movq  QWORD PTR ds:[edi+32], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+40]\r
+  movq  QWORD PTR ds:[edi+40], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+48]\r
+  movq  QWORD PTR ds:[edi+48], mm0\r
+  movq  mm0, QWORD PTR ds:[esi+56]\r
+  movq  QWORD PTR ds:[edi+56], mm0\r
+  \r
+  add   edi, 64\r
+  add   esi, 64\r
+  dec   eax\r
+  jnz   copymmx\r
+  \r
+; Restore mm0\r
+  movq  mm0, MmxSave\r
+  emms                                 ; Exit MMX Instruction\r
+\r
+  ; Copy as many DWORDS as possible\r
+_CopyRemainingDWords:\r
+  cmp   ecx, 4\r
+  jb    _CopyRemainingBytes\r
+\r
+  mov   eax, DWORD PTR [esi]        ; get data from Source\r
+  mov   DWORD PTR [edi], eax        ; write byte to Destination\r
+  sub   ecx, 4                      ; decrement Count\r
+  add   esi, 4                      ; advance Source pointer\r
+  add   edi, 4                      ; advance Destination pointer\r
+  jmp   _CopyRemainingDWords        ; back to top\r
+\r
+_CopyRemainingBytes:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  inc    esi\r
+  inc   edi                      ; advance Destination pointer\r
+  jmp   SHORT _CopyRemainingBytes   ; back to top of loop\r
+\r
+  ;\r
+  ; We do this block if the source and destination buffers overlap. To\r
+  ; handle it, copy starting at the end of the source buffer and work\r
+  ; your way back. Since this is the atypical case, this code has not\r
+  ; been optimized, and thus simply copies bytes.\r
+  ;\r
+_CopyOverlapped:\r
+   \r
+  ; Move the source and destination pointers to the end of the range\r
+  add   esi, ecx                      ; Source + Count\r
+  dec    esi\r
+  add   edi, ecx                      ; Dest + Count\r
+  dec    edi\r
+\r
+_CopyOverlappedLoop:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  dec    esi\r
+  dec   edi\r
+  jmp   _CopyOverlappedLoop         ; back to top of loop\r
+\r
+_CopyMemDone:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
new file mode 100644 (file)
index 0000000..e3b23f9
--- /dev/null
@@ -0,0 +1,169 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCopyMemSSE2.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized CopyMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  __asm {\r
+  mov   ecx, Count\r
+  mov   esi, Source\r
+  mov   edi, Destination\r
+\r
+  ; First off, make sure we have no overlap. That is to say,\r
+  ;   if (Source == Destination)           => do nothing\r
+  ;   if (Source + Count <= Destination)   => regular copy\r
+  ;   if (Destination + Count <= Source)   => regular copy\r
+  ;   otherwise, do a reverse copy\r
+  mov   eax, esi\r
+  add   eax, ecx                      ; Source + Count\r
+  cmp   eax, edi\r
+  jle   _StartByteCopy\r
+\r
+  mov   eax, edi\r
+  add   eax, ecx                      ; Dest + Count\r
+  cmp   eax, esi\r
+  jle   _StartByteCopy\r
+\r
+  cmp   esi, edi\r
+  je    _CopyMemDone         \r
+  jl    _CopyOverlapped               ; too bad -- overlaps\r
+\r
+  ; Pick up misaligned start bytes to get destination pointer 4-byte aligned\r
+_StartByteCopy:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone                ; Count == 0, all done\r
+  mov   edx, edi\r
+  and   dl, 3                       ; check lower 2 bits of address\r
+  test  dl, dl          \r
+  je    SHORT _CopyBlocks           ; already aligned?\r
+\r
+  ; Copy a byte\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  inc   edi\r
+  inc   esi\r
+  jmp   _StartByteCopy               ; back to top of loop\r
+\r
+_CopyBlocks:\r
+  ; Compute how many 64-byte blocks we can clear \r
+  mov   eax, ecx                    ; get Count in eax\r
+  shr   eax, 6                      ; convert to 64-byte count\r
+  shl   eax, 6                      ; convert back to bytes\r
+  sub   ecx, eax                    ; subtract from the original count\r
+  shr   eax, 6                      ; and this is how many 64-byte blocks\r
+\r
+  ; If no 64-byte blocks, then skip \r
+  cmp   eax, 0\r
+  je    _CopyRemainingDWords\r
+\r
+\r
+copyxmm:\r
+  \r
+  movdqu xmm0, OWORD PTR ds:[esi]\r
+  movdqu QWORD PTR ds:[edi], xmm0\r
+  movdqu xmm1, OWORD PTR ds:[esi+16]\r
+  movdqu QWORD PTR ds:[edi+16], xmm1\r
+  movdqu xmm2, OWORD PTR ds:[esi+32]\r
+  movdqu QWORD PTR ds:[edi+32], xmm2\r
+  movdqu xmm3, OWORD PTR ds:[esi+48]\r
+  movdqu QWORD PTR ds:[edi+48], xmm3\r
+  \r
+  add   edi, 64\r
+  add   esi, 64\r
+  dec   eax\r
+  jnz   copyxmm\r
+  \r
+\r
+  ; Copy as many DWORDS as possible\r
+_CopyRemainingDWords:\r
+  cmp   ecx, 4\r
+  jb    _CopyRemainingBytes\r
+\r
+  mov   eax, DWORD PTR [esi]        ; get data from Source\r
+  mov   DWORD PTR [edi], eax        ; write byte to Destination\r
+  sub   ecx, 4                      ; decrement Count\r
+  add   esi, 4                      ; advance Source pointer\r
+  add   edi, 4                      ; advance Destination pointer\r
+  jmp   _CopyRemainingDWords        ; back to top\r
+\r
+_CopyRemainingBytes:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  inc    esi\r
+  inc   edi                      ; advance Destination pointer\r
+  jmp   SHORT _CopyRemainingBytes   ; back to top of loop\r
+\r
+  ;\r
+  ; We do this block if the source and destination buffers overlap. To\r
+  ; handle it, copy starting at the end of the source buffer and work\r
+  ; your way back. Since this is the atypical case, this code has not\r
+  ; been optimized, and thus simply copies bytes.\r
+  ;\r
+_CopyOverlapped:\r
+   \r
+  ; Move the source and destination pointers to the end of the range\r
+  add   esi, ecx                      ; Source + Count\r
+  dec    esi\r
+  add   edi, ecx                      ; Dest + Count\r
+  dec    edi\r
+\r
+_CopyOverlappedLoop:\r
+  cmp   ecx, 0\r
+  je    _CopyMemDone\r
+  mov   al, BYTE PTR [esi]          ; get byte from Source\r
+  mov   BYTE PTR [edi], al          ; write byte to Destination\r
+  dec    ecx\r
+  dec    esi\r
+  dec   edi\r
+  jmp   _CopyOverlappedLoop         ; back to top of loop\r
+\r
+_CopyMemDone:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c
new file mode 100644 (file)
index 0000000..2543679
--- /dev/null
@@ -0,0 +1,139 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiSetMem.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized SetMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibSetMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Count,\r
+  IN UINT8  Value\r
+  )\r
+/*++\r
+\r
+Input:  VOID   *Buffer - Pointer to buffer to write\r
+        UINTN  Count   - Number of bytes to write\r
+        UINT8  Value   - Value to write\r
+\r
+Output: None.\r
+\r
+Saves:\r
+\r
+Modifies:\r
+\r
+Description:  This function is an optimized set-memory function.\r
+\r
+Notes:  This function tries to set memory 8 bytes at a time. As a result, \r
+        it first picks up any misaligned bytes, then words, before getting \r
+        in the main loop that does the 8-byte clears.\r
+\r
+--*/\r
+{\r
+  UINT64 QWordValue;\r
+  UINT64 MmxSave;\r
+  __asm {\r
+    mov edx, Count\r
+    test edx, edx\r
+    je _SetMemDone\r
+\r
+    push ebx\r
+  \r
+    mov eax, Buffer\r
+    mov bl, Value\r
+    mov edi, eax\r
+    mov bh, bl\r
+  \r
+    cmp edx, 256\r
+    jb _SetRemindingByte\r
+  \r
+    and al, 07h\r
+    test al, al\r
+    je _SetBlock\r
+  \r
+    mov eax, edi\r
+    shr eax, 3\r
+    inc eax\r
+    shl eax, 3\r
+    sub eax, edi\r
+    cmp eax, edx\r
+    jnb _SetRemindingByte\r
+  \r
+    sub edx, eax\r
+    mov ecx, eax\r
+\r
+    mov al, bl\r
+    rep stosb\r
+\r
+_SetBlock:\r
+    mov eax, edx\r
+    shr eax, 6\r
+    test eax, eax\r
+    je _SetRemindingByte\r
+\r
+    shl eax, 6\r
+    sub edx, eax\r
+    shr eax, 6\r
+\r
+    mov WORD PTR QWordValue[0], bx\r
+    mov WORD PTR QWordValue[2], bx\r
+    mov WORD PTR QWordValue[4], bx\r
+    mov WORD PTR QWordValue[6], bx\r
\r
+  \r
+    movq  MmxSave, mm0\r
+    movq  mm0, QWordValue\r
+\r
+_B:\r
+    movq  QWORD PTR ds:[edi], mm0\r
+    movq  QWORD PTR ds:[edi+8], mm0\r
+    movq  QWORD PTR ds:[edi+16], mm0\r
+    movq  QWORD PTR ds:[edi+24], mm0\r
+    movq  QWORD PTR ds:[edi+32], mm0\r
+    movq  QWORD PTR ds:[edi+40], mm0\r
+    movq  QWORD PTR ds:[edi+48], mm0\r
+    movq  QWORD PTR ds:[edi+56], mm0\r
+    add edi, 64\r
+    dec eax\r
+    jnz _B\r
+  \r
+; Restore mm0\r
+    movq  mm0, MmxSave\r
+    emms                                 ; Exit MMX Instruction\r
+  \r
+_SetRemindingByte:\r
+    mov ecx, edx\r
+\r
+    mov eax, ebx\r
+    shl eax, 16\r
+    mov ax, bx\r
+    shr ecx, 2\r
+    rep stosd\r
+  \r
+    mov ecx, edx\r
+    and ecx, 3\r
+    rep stosb\r
+  \r
+    pop ebx\r
+\r
+_SetMemDone:\r
+\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c
new file mode 100644 (file)
index 0000000..06cb5e2
--- /dev/null
@@ -0,0 +1,141 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiSetMemSSE2.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized SetMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibSetMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Count,\r
+  IN UINT8  Value\r
+  )\r
+/*++\r
+\r
+Input:  VOID   *Buffer - Pointer to buffer to write\r
+        UINTN  Count   - Number of bytes to write\r
+        UINT8  Value   - Value to write\r
+\r
+Output: None.\r
+\r
+Saves:\r
+\r
+Modifies:\r
+\r
+Description:  This function is an optimized set-memory function.\r
+\r
+Notes:  This function tries to set memory 8 bytes at a time. As a result, \r
+        it first picks up any misaligned bytes, then words, before getting \r
+        in the main loop that does the 8-byte clears.\r
+\r
+--*/\r
+{\r
+  UINT64 QWordValue;\r
+  UINT64 MmxSave;\r
+  __asm {\r
+    mov edx, Count\r
+    test edx, edx\r
+    je _SetMemDone\r
+\r
+    push ebx\r
+  \r
+    mov eax, Buffer\r
+    mov bl, Value\r
+    mov edi, eax\r
+    mov  bh, bl\r
+  \r
+    cmp edx, 256\r
+    jb _SetRemindingByte\r
+  \r
+    and al, 0fh\r
+    test al, al\r
+    je _SetBlock\r
+  \r
+    mov eax, edi\r
+    shr eax, 4\r
+    inc eax\r
+    shl eax, 4\r
+    sub eax, edi\r
+    cmp eax, edx\r
+    jnb _SetRemindingByte\r
+  \r
+    sub edx, eax\r
+    mov ecx, eax\r
+\r
+    mov al, bl\r
+    rep stosb\r
+\r
+_SetBlock:\r
+    mov eax, edx\r
+    shr eax, 7\r
+    test eax, eax\r
+    je _SetRemindingByte\r
+\r
+    shl eax, 7\r
+    sub edx, eax\r
+    shr eax, 7\r
+\r
+    mov  WORD PTR QWordValue[0], bx\r
+    mov  WORD PTR QWordValue[2], bx\r
+    mov  WORD PTR QWordValue[4], bx\r
+    mov  WORD PTR QWordValue[6], bx\r
\r
+  \r
+    movq  MmxSave, mm0\r
+    movq  mm0, QWordValue\r
+\r
+    movq2dq  xmm1, mm0\r
+    pshufd   xmm1, xmm1, 0\r
+\r
+_Loop:\r
+    movdqa  OWORD PTR ds:[edi], xmm1\r
+    movdqa  OWORD PTR ds:[edi+16], xmm1\r
+    movdqa  OWORD PTR ds:[edi+32], xmm1\r
+    movdqa  OWORD PTR ds:[edi+48], xmm1\r
+    movdqa  OWORD PTR ds:[edi+64], xmm1\r
+    movdqa  OWORD PTR ds:[edi+80], xmm1\r
+    movdqa  OWORD PTR ds:[edi+96], xmm1\r
+    movdqa  OWORD PTR ds:[edi+112], xmm1\r
+    add edi, 128\r
+    dec eax\r
+    jnz _Loop\r
+  \r
+; Restore mm0\r
+    movq  mm0, MmxSave\r
+    emms                                 ; Exit MMX Instruction\r
+  \r
+_SetRemindingByte:\r
+    mov ecx, edx\r
+\r
+    mov eax, ebx\r
+    shl eax, 16\r
+    mov ax, bx\r
+    shr ecx, 2\r
+    rep stosd\r
+  \r
+    mov ecx, edx\r
+    and ecx, 3\r
+    rep stosb\r
+  \r
+    pop ebx\r
+\r
+_SetMemDone:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c
new file mode 100644 (file)
index 0000000..fc9ed7b
--- /dev/null
@@ -0,0 +1,122 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiZeroMem.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized ZeroMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Count\r
+  )\r
+/*++\r
+\r
+Input:  VOID   *Buffer - Pointer to buffer to clear\r
+        UINTN  Count  - Number of bytes to clear\r
+\r
+Output: None.\r
+\r
+Saves:\r
+\r
+Modifies:\r
+\r
+Description:  This function is an optimized zero-memory function.\r
+\r
+Notes:  This function tries to zero memory 8 bytes at a time. As a result, \r
+        it first picks up any misaligned bytes, then words, before getting \r
+        in the main loop that does the 8-byte clears.\r
+\r
+--*/\r
+{\r
+  UINT64 MmxSave;\r
+  __asm {\r
+    mov   ecx, Count\r
+    mov   edi, Buffer\r
+\r
+    ; Pick up misaligned start bytes (get pointer 4-byte aligned)\r
+_StartByteZero:\r
+    mov   eax, edi    \r
+    and   al, 3                       ; check lower 2 bits of address\r
+    test  al, al\r
+    je    _ZeroBlocks                 ; already aligned?\r
+    cmp   ecx, 0\r
+    je    _ZeroMemDone\r
+\r
+    ; Clear the byte memory location\r
+    mov   BYTE PTR [edi], 0           \r
+    inc    edi\r
+\r
+    ; Decrement our count\r
+    dec    ecx\r
+    jmp   _StartByteZero        ; back to top of loop\r
+\r
+_ZeroBlocks:\r
+\r
+    ; Compute how many 64-byte blocks we can clear \r
+    mov   edx, ecx\r
+    shr   ecx, 6                      ; convert to 64-byte count\r
+    shl   ecx, 6                      ; convert back to bytes\r
+    sub   edx, ecx                    ; subtract from the original count\r
+    shr   ecx, 6                      ; and this is how many 64-byte blocks\r
+\r
+    ; If no 64-byte blocks, then skip \r
+    cmp    ecx, 0\r
+    je    _ZeroRemaining\r
+\r
+    ; Save mm0\r
+    movq  MmxSave, mm0\r
+\r
+    pxor  mm0, mm0          ; Clear mm0\r
+\r
+_B:\r
+    movq  QWORD PTR ds:[edi], mm0\r
+    movq  QWORD PTR ds:[edi+8], mm0\r
+    movq  QWORD PTR ds:[edi+16], mm0\r
+    movq  QWORD PTR ds:[edi+24], mm0\r
+    movq  QWORD PTR ds:[edi+32], mm0\r
+    movq  QWORD PTR ds:[edi+40], mm0\r
+    movq  QWORD PTR ds:[edi+48], mm0\r
+    movq  QWORD PTR ds:[edi+56], mm0\r
+   \r
+    add    edi, 64\r
+    dec    ecx\r
+    jnz    _B\r
+  \r
+; Restore mm0\r
+    movq  mm0, MmxSave\r
+    emms                                 ; Exit MMX Instruction\r
+\r
+_ZeroRemaining:\r
+    ; Zero out as many DWORDS as possible\r
+    mov   ecx, edx\r
+    shr   ecx, 2\r
+    xor   eax, eax\r
+\r
+    rep stosd\r
+\r
+    ; Zero out remaining as bytes\r
+    mov   ecx, edx\r
+    and   ecx, 03\r
+\r
+    rep   stosb\r
\r
+_ZeroMemDone:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c
new file mode 100644 (file)
index 0000000..316ff20
--- /dev/null
@@ -0,0 +1,111 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiZeroMemSSE2.c\r
+\r
+Abstract:\r
+\r
+  This is the code that supports IA32-optimized ZeroMem service\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+VOID\r
+EfiCommonLibZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Count\r
+  )\r
+/*++\r
+\r
+Input:  VOID   *Buffer - Pointer to buffer to clear\r
+        UINTN  Count  - Number of bytes to clear\r
+\r
+Output: None.\r
+\r
+Saves:\r
+\r
+Modifies:\r
+\r
+Description:  This function is an optimized zero-memory function.\r
+\r
+Notes:  This function tries to zero memory 8 bytes at a time. As a result, \r
+        it first picks up any misaligned bytes, then words, before getting \r
+        in the main loop that does the 8-byte clears.\r
+\r
+--*/\r
+{\r
+  __asm {\r
+  mov   ecx, Count\r
+  mov   edi, Buffer\r
+\r
+  ; Pick up misaligned start bytes (get pointer 4-byte aligned)\r
+_StartByteZero:\r
+  mov   eax, edi    \r
+  and   al, 3                       ; check lower 2 bits of address\r
+  test  al, al\r
+  je    _ZeroBlocks                 ; already aligned?\r
+  cmp   ecx, 0\r
+  je    _ZeroMemDone\r
+\r
+  ; Clear the byte memory location\r
+  mov   BYTE PTR [edi], 0           \r
+  inc    edi\r
+\r
+  ; Decrement our count\r
+  dec    ecx\r
+  jmp   _StartByteZero        ; back to top of loop\r
+\r
+_ZeroBlocks:\r
+\r
+  ; Compute how many 64-byte blocks we can clear \r
+  mov   edx, ecx\r
+  shr   ecx, 6                      ; convert to 64-byte count\r
+  shl   ecx, 6                      ; convert back to bytes\r
+  sub   edx, ecx                    ; subtract from the original count\r
+  shr   ecx, 6                      ; and this is how many 64-byte blocks\r
+\r
+  ; If no 64-byte blocks, then skip \r
+  cmp    ecx, 0\r
+  je    _ZeroRemaining\r
+\r
+  xorps  xmm1, xmm1\r
+\r
+_B:\r
+  movdqu OWORD PTR ds:[edi], xmm1\r
+  movdqu OWORD PTR ds:[edi+16], xmm1\r
+  movdqu OWORD PTR ds:[edi+32], xmm1\r
+  movdqu OWORD PTR ds:[edi+48], xmm1\r
+   \r
+  add    edi, 64\r
+  dec    ecx\r
+  jnz    _B\r
+  \r
+\r
+_ZeroRemaining:\r
+  ; Zero out as many DWORDS as possible\r
+  mov   ecx, edx\r
+  shr   ecx, 2\r
+  xor   eax, eax\r
+\r
+  rep stosd\r
+\r
+  ; Zero out remaining as bytes\r
+  mov   ecx, edx\r
+  and   ecx, 03\r
+\r
+  rep   stosb\r
\r
+_ZeroMemDone:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c
new file mode 100644 (file)
index 0000000..665fa02
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GetPowerOfTwo.c\r
+\r
+Abstract:\r
+\r
+  Calculates the largest integer that is both \r
+  a power of two and less than Input\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+GetPowerOfTwo (\r
+  IN UINT64   Input\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculates the largest integer that is both \r
+  a power of two and less than Input\r
+\r
+Arguments:\r
+\r
+  Input  - value to calculate power of two\r
+\r
+Returns:\r
+\r
+  the largest integer that is both  a power of \r
+  two and less than Input\r
+\r
+--*/\r
+{\r
+  __asm {\r
+    xor     eax, eax\r
+    mov     edx, eax\r
+    mov     ecx, dword ptr Input[4]\r
+    jecxz   _F\r
+    bsr     ecx, ecx\r
+    bts     edx, ecx\r
+    jmp     _Exit\r
+_F:\r
+    mov     ecx, dword ptr Input[0]\r
+    jecxz   _Exit\r
+    bsr     ecx, ecx\r
+    bts     eax, ecx\r
+_Exit:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c
new file mode 100644 (file)
index 0000000..0636b12
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LShiftU64.c\r
+\r
+Abstract:\r
+\r
+  64-bit left shift function for IA-32\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
+  \r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+{\r
+  __asm {\r
+  \r
+    mov    eax, dword ptr Operand[0]\r
+    mov    edx, dword ptr Operand[4]\r
+  \r
+    ;\r
+    ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EAX is not touched\r
+    ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move eax to edx later. \r
+    ;\r
+    mov    ecx, Count\r
+    and    ecx, 63\r
+    shld   edx, eax, cl\r
+    shl    eax, cl\r
+  \r
+    ;\r
+    ; Since Count is 32 - 63, eax will have been shifted  by 0 - 31                                                     \r
+    ; If shifted by 32 or more, set lower 32 bits to zero.\r
+    ;\r
+    cmp    ecx, 32\r
+    jc     short _LShiftU64_Done\r
+  \r
+    mov    edx, eax\r
+    xor    eax, eax\r
+\r
+_LShiftU64_Done:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c
new file mode 100644 (file)
index 0000000..7e6db88
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Log2.c\r
+\r
+Abstract:\r
+\r
+  64-bit integer logarithm function for IA-32\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT8\r
+Log2 (\r
+  IN UINT64   Operand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Calculates and floors logarithms based on 2\r
+\r
+Arguments:\r
+\r
+  Operand - value to calculate logarithm\r
+  \r
+Returns:\r
+\r
+  The largest integer that is less than or equal\r
+  to the logarithm of Operand based on 2 \r
+\r
+--*/\r
+{\r
+  __asm {\r
+  mov    ecx, 64\r
+  \r
+  cmp    dword ptr Operand[0], 0\r
+  jne    _Log2_Wend \r
+  cmp    dword ptr Operand[4], 0\r
+  jne    _Log2_Wend \r
+  mov    cl, 0FFH\r
+  jmp    _Log2_Done\r
+  \r
+_Log2_Wend:\r
+  dec    ecx\r
+  cmp    ecx, 32\r
+  jae    _Log2_Higher\r
+  bt     dword ptr Operand[0], ecx\r
+  jmp    _Log2_Bit\r
+  \r
+_Log2_Higher:\r
+  mov    eax, ecx\r
+  sub    eax, 32\r
+  bt     dword ptr Operand[4], eax\r
+  \r
+_Log2_Bit:\r
+  jc     _Log2_Done\r
+  jmp    _Log2_Wend\r
+      \r
+_Log2_Done:\r
+  mov    al, cl\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c
new file mode 100644 (file)
index 0000000..a102b0e
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+   MultU64x32.c\r
+\r
+Abstract:\r
+\r
+  64-bit Multiplication function for IA-32\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+\r
+--*/\r
+{\r
+  __asm {\r
+    mov    eax, dword ptr Multiplicand[0]\r
+    mul    Multiplier\r
+    push   eax\r
+    push   edx\r
+    mov    eax, dword ptr Multiplicand[4]\r
+    mul    Multiplier\r
+    ;\r
+    ; The value in edx stored by second multiplication overflows\r
+    ; the output and should be discarded. So here we overwrite it\r
+    ; with the edx value of first multiplication.\r
+    ;\r
+    pop    edx\r
+    add    edx, eax\r
+    pop    eax\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
new file mode 100644 (file)
index 0000000..e8e1652
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Power10U64.c\r
+\r
+Abstract:\r
+\r
+  Calculates Operand * 10 ^ Power\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  );\r
+\r
+UINT64\r
+Power10U64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Power\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raise 10 to the power of Power, and multiply the result with Operand\r
+\r
+Arguments:\r
+\r
+  Operand  - multiplicand\r
+  Power    - power\r
+\r
+Returns:\r
+\r
+  Operand * 10 ^ Power\r
+\r
+--*/\r
+{\r
+  __asm {\r
+  mov    ecx, Power\r
+  jcxz   _Power10U64_Done\r
+  \r
+_Power10U64_Wend:\r
+  push   10\r
+  push   dword ptr Operand[4]\r
+  push   dword ptr Operand[0]\r
+  call   MultU64x32\r
+  mov    dword ptr Operand[0], eax\r
+  mov    dword ptr Operand[4], edx\r
+  loop   _Power10U64_Wend\r
+\r
+_Power10U64_Done:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c
new file mode 100644 (file)
index 0000000..bc909eb
--- /dev/null
@@ -0,0 +1,71 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RShiftU64.c\r
+\r
+Abstract:\r
+\r
+  64-bit right shift function for IA-32\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+Arguments:\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+{\r
+  __asm {\r
+  \r
+    mov    eax, dword ptr Operand[0]\r
+    mov    edx, dword ptr Operand[4]\r
+  \r
+    ;\r
+    ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EDX is not touched\r
+    ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move edx to eax later. \r
+    ;\r
+    mov    ecx, Count\r
+    and    ecx, 63\r
+    shrd   eax, edx, cl\r
+    shr    edx, cl\r
+\r
+    cmp    ecx, 32\r
+    jc     short _RShiftU64_Done\r
+\r
+    ;\r
+    ; Since Count is 32 - 63, edx will have been shifted  by 0 - 31                                                     \r
+    ; If shifted by 32 or more, set upper 32 bits to zero.\r
+    ;\r
+    mov    eax, edx\r
+    xor    edx, edx\r
+\r
+_RShiftU64_Done:\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
new file mode 100644 (file)
index 0000000..64e683e
--- /dev/null
@@ -0,0 +1,216 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Math.c\r
+\r
+Abstract:\r
+\r
+  Math worker functions. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
\r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand << Count;\r
+}\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  )\r
+/*++  \r
+  \r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand >> Count;\r
+}\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN UINT64   Dividend,\r
+  IN UINTN    Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
\r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+\r
+--*/\r
+{\r
+  if (Remainder != NULL) {\r
+    *Remainder = Dividend % Divisor;\r
+  }\r
+\r
+  return Dividend / Divisor;\r
+}\r
+\r
+UINT8\r
+Log2 (\r
+  IN UINT64   Operand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function computes rounded down log2 of the Operand.  This is an equivalent\r
+  of the position of the highest bit set in the Operand treated as a mask.\r
+  E.g., Log2 (0x0001) == 0, Log2 (0x0002) == 1, Log2 (0x0003) == 1, Log2 (0x0005) == 2\r
+  Log2 (0x4000) == 14, Log2 (0x8000) == 15, Log2 (0xC000) == 15, Log2 (0xFFFF) == 15, etc.\r
+\r
+Arguments:\r
+  Operand - value of which the Log2 is to be computed.\r
+\r
+Returns:\r
+  Rounded down log2 of the Operand or 0xFF if zero passed in.\r
+\r
+--*/\r
+{\r
+  UINT8 Bitpos;\r
+  Bitpos = 0;\r
+\r
+  if (Operand == 0) {\r
+    return (0xff);\r
+  }\r
+\r
+  while (Operand != 0) {\r
+    Operand >>= 1;\r
+    Bitpos++;\r
+  }\r
+  return (Bitpos - 1);\r
+\r
+}\r
+\r
+UINT64\r
+GetPowerOfTwo (\r
+  IN UINT64 Operand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculates the largest integer that is both \r
+  a power of two and less than Input\r
+\r
+Arguments:\r
+\r
+  Operand  - value to calculate power of two\r
+\r
+Returns:\r
+\r
+  the largest integer that is both  a power of \r
+  two and less than Input\r
+\r
+--*/\r
+{\r
+  UINT8 Bitpos;\r
+  Bitpos = 0;\r
+\r
+  if (Operand == 0) {\r
+    return 0;\r
+  }\r
+\r
+  while (Operand != 0) {\r
+    Operand >>= 1;\r
+    Bitpos++;\r
+  }\r
+\r
+  Operand = 1;\r
+  Bitpos--;\r
+  while (Bitpos != 0) {\r
+    Operand <<= 1;\r
+    Bitpos--;\r
+  }\r
+\r
+  return Operand;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
new file mode 100644 (file)
index 0000000..b64ccae
--- /dev/null
@@ -0,0 +1,384 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  misc.c\r
+\r
+Abstract:\r
+  \r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "pei.h"\r
+#include "cpuio.h"\r
+#include "pcicfg.h"\r
+#include "pcicfg2.h"\r
+#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)\r
+\r
+//\r
+// Modular variable used by common libiary in PEI phase\r
+//\r
+EFI_GUID              mPeiCpuIoPpiGuid  = PEI_CPU_IO_PPI_GUID;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+EFI_GUID              mPeiPciCfgPpiGuid = PEI_PCI_CFG_PPI_GUID;\r
+PEI_PCI_CFG_PPI       *PciCfgPpi        = NULL;\r
+#else\r
+EFI_GUID              mPeiPciCfgPpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID;\r
+EFI_PEI_PCI_CFG2_PPI  *PciCfgPpi        = NULL;\r
+#endif\r
+EFI_PEI_SERVICES      **mPeiServices    = NULL;\r
+PEI_CPU_IO_PPI        *CpuIoPpi         = NULL;\r
+\r
+//\r
+// Modular variable used by common libiary in DXE phase\r
+//\r
+EFI_SYSTEM_TABLE      *mST  = NULL;\r
+EFI_BOOT_SERVICES     *mBS  = NULL;\r
+EFI_RUNTIME_SERVICES  *mRT  = NULL;\r
+\r
+EFI_STATUS\r
+EfiInitializeCommonDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN VOID                 *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize lib function calling phase: PEI or DXE\r
+  \r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  mPeiServices  = NULL;\r
+  CpuIoPpi      = NULL;\r
+  PciCfgPpi     = NULL;\r
+\r
+  if (ImageHandle == NULL) {\r
+    //\r
+    // The function is called in PEI phase, use PEI interfaces\r
+    //\r
+    mPeiServices = (EFI_PEI_SERVICES **) SystemTable;\r
+    ASSERT (mPeiServices == NULL);\r
+\r
+    CpuIoPpi  = (**mPeiServices).CpuIo;\r
+    PciCfgPpi = (**mPeiServices).PciCfg;\r
+\r
+  } else {\r
+    //\r
+    // ImageHandle is not NULL. The function is called in DXE phase\r
+    //\r
+    mST = SystemTable;\r
+    ASSERT (mST != NULL);\r
+\r
+    mBS = mST->BootServices;\r
+    mRT = mST->RuntimeServices;\r
+    ASSERT (mBS != NULL);\r
+    ASSERT (mRT != NULL);\r
+\r
+    //\r
+    // Should be at EFI_D_INFO, but lets us know things are running\r
+    //\r
+    DEBUG ((EFI_D_INFO, "EfiInitializeCommonDriverLib: Started in DXE\n"));\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiCommonIoWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io write operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of write operation\r
+  Address - Start IO address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
+\r
+  if (mPeiServices == NULL) {\r
+    //\r
+    // The function is called in PEI phase, use PEI interfaces\r
+    //\r
+    Status = CpuIoPpi->Io.Write (\r
+                            mPeiServices,\r
+                            CpuIoPpi,\r
+                            Width,\r
+                            Address,\r
+                            Count,\r
+                            Buffer\r
+                            );\r
+  } else {\r
+    //\r
+    // The function is called in DXE phase\r
+    //\r
+    Status = mBS->LocateProtocol (\r
+                    &gEfiPciRootBridgeIoProtocolGuid,\r
+                    NULL,\r
+                    (VOID **) &RootBridgeIo\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    Status = RootBridgeIo->Io.Write (RootBridgeIo, Width, Address, Count, Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiCommonIoRead (\r
+  IN  UINT8       Width,\r
+  IN  UINTN       Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Io read operation.\r
+\r
+Arguments:\r
+\r
+  Width   - Width of read operation\r
+  Address - Start IO address to read\r
+  Count   - Read count\r
+  Buffer  - Buffer to store result\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
+\r
+  if (mPeiServices == NULL) {\r
+    //\r
+    // The function is called in PEI phase, use PEI interfaces\r
+    //\r
+    Status = CpuIoPpi->Io.Read (\r
+                            mPeiServices,\r
+                            CpuIoPpi,\r
+                            Width,\r
+                            Address,\r
+                            Count,\r
+                            Buffer\r
+                            );\r
+  } else {\r
+    //\r
+    // The function is called in DXE phase\r
+    //\r
+    Status = mBS->LocateProtocol (\r
+                    &gEfiPciRootBridgeIoProtocolGuid,\r
+                    NULL,\r
+                    (VOID **) &RootBridgeIo\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    Status = RootBridgeIo->Io.Read (RootBridgeIo, Width, Address, Count, Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EfiCommonPciWrite (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci write operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI write\r
+  Address - PCI address to write\r
+  Count   - Write count\r
+  Buffer  - Buffer to write to the address\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINTN                           Index;\r
+  UINT8                           *Buffer8;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
+\r
+  if (mPeiServices == NULL) {\r
+    //\r
+    // The function is called in PEI phase, use PEI interfaces\r
+    //\r
+    Buffer8 = Buffer;\r
+    for (Index = 0; Index < Count; Index++) {\r
+      Status = PciCfgPpi->Write (\r
+                            mPeiServices,\r
+                            PciCfgPpi,\r
+                            Width,\r
+                            Address,\r
+                            Buffer8\r
+                            );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      Buffer8 += Width;\r
+    }\r
+\r
+  } else {\r
+    //\r
+    // The function is called in DXE phase\r
+    //\r
+    Status = mBS->LocateProtocol (\r
+                    &gEfiPciRootBridgeIoProtocolGuid,\r
+                    NULL,\r
+                    (VOID **) &RootBridgeIo\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    Status = RootBridgeIo->Pci.Write (\r
+                                RootBridgeIo,\r
+                                Width,\r
+                                Address,\r
+                                Count,\r
+                                Buffer\r
+                                );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiCommonPciRead (\r
+  IN  UINT8       Width,\r
+  IN  UINT64      Address,\r
+  IN  UINTN       Count,\r
+  IN  OUT VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pci read operation\r
+\r
+Arguments:\r
+\r
+  Width   - Width of PCI read\r
+  Address - PCI address to read\r
+  Count   - Read count\r
+  Buffer  - Output buffer for the read\r
+\r
+Returns: \r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINTN                           Index;\r
+  UINT8                           *Buffer8;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
+\r
+  if (mPeiServices == NULL) {\r
+    //\r
+    // The function is called in PEI phase, use PEI interfaces\r
+    //\r
+    Buffer8 = Buffer;\r
+    for (Index = 0; Index < Count; Index++) {\r
+      Status = PciCfgPpi->Read (\r
+                            mPeiServices,\r
+                            PciCfgPpi,\r
+                            Width,\r
+                            Address,\r
+                            Buffer8\r
+                            );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      Buffer8 += Width;\r
+    }\r
+\r
+  } else {\r
+    //\r
+    // The function is called in DXE phase\r
+    //\r
+    Status = mBS->LocateProtocol (\r
+                    &gEfiPciRootBridgeIoProtocolGuid,\r
+                    NULL,\r
+                    (VOID **) &RootBridgeIo\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    Status = RootBridgeIo->Pci.Read (\r
+                                RootBridgeIo,\r
+                                Width,\r
+                                Address,\r
+                                Count,\r
+                                Buffer\r
+                                );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c
new file mode 100644 (file)
index 0000000..31232be
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PostCode.c\r
+\r
+Abstract:\r
+\r
+  Worker functions for PostCode\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+\r
+BOOLEAN\r
+CodeTypeToPostCode (\r
+  IN  EFI_STATUS_CODE_TYPE    CodeType,\r
+  IN  EFI_STATUS_CODE_VALUE   Value,\r
+  OUT UINT8                   *PostCode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert code value to an 8 bit post code\r
+\r
+Arguments:\r
+\r
+  CodeType  - Code type\r
+  Value     - Code value\r
+  PostCode  - Post code as output\r
+\r
+Returns:\r
+\r
+  TRUE    - Successfully converted\r
+  \r
+  FALSE   - Convertion failed\r
+\r
+--*/\r
+{\r
+  //\r
+  // Convert Value to an 8 bit post code\r
+  //\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
+      ((CodeType & EFI_STATUS_CODE_TYPE_MASK)== EFI_ERROR_CODE)) {\r
+    *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);\r
+    *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c
new file mode 100644 (file)
index 0000000..4a9fca8
--- /dev/null
@@ -0,0 +1,338 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ReportStatusCode.c\r
+\r
+Abstract:\r
+\r
+  Worker functions for ReportStatusCode\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiCommonLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+\r
+VOID *\r
+EfiConstructStatusCodeData (\r
+  IN  UINT16                    DataSize,\r
+  IN  EFI_GUID                  *TypeGuid,\r
+  IN OUT  EFI_STATUS_CODE_DATA  *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Construct stanader header for optional data passed into ReportStatusCode\r
+\r
+Arguments:\r
+\r
+  DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header\r
+  TypeGuid - GUID to place in EFI_STATUS_CODE_DATA\r
+  Data     - Buffer to use.\r
+\r
+Returns:\r
+\r
+  Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA\r
+\r
+--*/\r
+{\r
+  Data->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
+  Data->Size = (UINT16)(DataSize - sizeof (EFI_STATUS_CODE_DATA));\r
+  EfiCommonLibCopyMem (&Data->Type, TypeGuid, sizeof (EFI_GUID));\r
+  \r
+  return (VOID *)(Data + 1); \r
+}\r
+\r
+EFI_STATUS\r
+EfiDebugVPrintWorker (\r
+  IN  UINTN                   ErrorLevel,\r
+  IN  CHAR8                   *Format,\r
+  IN  VA_LIST                 Marker,\r
+  IN  UINTN                   BufferSize,\r
+  IN OUT VOID                 *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+\r
+  The Format string might be truncated to fit into the status code struture\r
+  which has the max size of EFI_STATUS_CODE_DATA_MAX_SIZE.\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  Marker     - VarArgs\r
+\r
+  BufferSize - Size of Buffer.\r
+\r
+  Buffer     - Caller allocated buffer, contains ReportStatusCode extended data\r
+  \r
+Returns:\r
+  \r
+  Status code\r
+  \r
+  EFI_SUCCESS             - Successfully printed\r
+\r
+--*/\r
+{\r
+  UINTN                   Index;\r
+  UINTN                   FormatStrLen;\r
+  UINTN                   RemainingStrLen;\r
+  UINT64                  *Ptr;\r
+  EFI_DEBUG_INFO          *EfiDebug;\r
+\r
+  \r
+  //\r
+  // Build the type specific EFI_STATUS_CODE_DATA in order\r
+  //\r
+\r
+  //\r
+  // Fill in EFI_STATUS_CODE_DATA to Buffer.\r
+  //\r
+  EfiDebug = (EFI_DEBUG_INFO *)EfiConstructStatusCodeData (\r
+                                (UINT16)BufferSize, \r
+                                &gEfiStatusCodeDataTypeDebugGuid, \r
+                                Buffer\r
+                                );\r
+\r
+  //\r
+  // Then EFI_DEBUG_INFO\r
+  //\r
+  EfiDebug->ErrorLevel = (UINT32)ErrorLevel;\r
+\r
+  //\r
+  // 12 * sizeof (UINT64) byte mini Var Arg stack.\r
+  // That is followed by the format string.\r
+  //\r
+  for (Index = 0, Ptr = (UINT64 *)(EfiDebug + 1); Index < 12; Index++, Ptr++) {\r
+    *Ptr = VA_ARG (Marker, UINT64);\r
+  }\r
+\r
+  //\r
+  // Place Ascii Format string at the end\r
+  // Truncate it to fit into the status code structure\r
+  //\r
+  FormatStrLen    = EfiAsciiStrLen (Format);\r
+  RemainingStrLen = EFI_STATUS_CODE_DATA_MAX_SIZE\r
+    - sizeof (EFI_STATUS_CODE_DATA)\r
+    - sizeof (EFI_DEBUG_INFO)\r
+    - 12 * sizeof (UINT64) - 1;\r
+  if (FormatStrLen > RemainingStrLen) {\r
+    FormatStrLen = RemainingStrLen;\r
+  }\r
+  EfiCommonLibCopyMem (Ptr, Format, FormatStrLen);\r
+  *((CHAR8 *) Ptr + FormatStrLen) = '\0';\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EfiDebugAssertWorker (\r
+  IN CHAR8                    *Filename,\r
+  IN INTN                     LineNumber,\r
+  IN CHAR8                    *Description,\r
+  IN UINTN                    BufferSize,\r
+  IN OUT VOID                 *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded DEADLOOP ().\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  Filename    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT().\r
+\r
+  Description - Description, usually the assertion,\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+  Buffer     - Caller allocated buffer, contains ReportStatusCode extendecd data\r
+\r
+Returns:\r
+  \r
+  Status code\r
+  \r
+  EFI_BUFFER_TOO_SMALL      - Buffer not large enough\r
+  \r
+  EFI_SUCCESS               - Function successfully done.\r
+\r
+--*/\r
+{\r
+  EFI_DEBUG_ASSERT_DATA   *AssertData;\r
+  UINTN                   TotalSize;\r
+  CHAR8                   *EndOfStr;\r
+\r
+  //\r
+  // Make sure it will all fit in the passed in buffer\r
+  //\r
+  TotalSize = sizeof (EFI_STATUS_CODE_DATA) + sizeof (EFI_DEBUG_ASSERT_DATA);\r
+  TotalSize += EfiAsciiStrLen (Filename) + EfiAsciiStrLen (Description);\r
+  if (TotalSize > BufferSize) {\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  //\r
+  // Fill in EFI_STATUS_CODE_DATA\r
+  //\r
+  AssertData =  (EFI_DEBUG_ASSERT_DATA *)\r
+                EfiConstructStatusCodeData (\r
+                  (UINT16)(TotalSize - sizeof (EFI_STATUS_CODE_DATA)),\r
+                  &gEfiStatusCodeDataTypeAssertGuid, \r
+                  Buffer\r
+                  );\r
+\r
+  //\r
+  // Fill in EFI_DEBUG_ASSERT_DATA\r
+  //\r
+  AssertData->LineNumber = (UINT32)LineNumber;\r
+\r
+  //\r
+  // Copy Ascii FileName including NULL.\r
+  //\r
+  EndOfStr = EfiAsciiStrCpy ((CHAR8 *)(AssertData + 1), Filename);\r
+\r
+  //\r
+  // Copy Ascii Description \r
+  //\r
+  EfiAsciiStrCpy (EndOfStr, Description);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+BOOLEAN\r
+ReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,  \r
+  IN EFI_STATUS_CODE_DATA     *Data, \r
+  OUT CHAR8                   **Filename,\r
+  OUT CHAR8                   **Description,\r
+  OUT UINT32                  *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract assert information from status code data.\r
+\r
+Arguments:\r
+\r
+  CodeType    - Code type\r
+  Value       - Code value\r
+  Data        - Optional data associated with this status code.\r
+  Filename    - Filename extracted from Data\r
+  Description - Description extracted from Data\r
+  LineNumber  - Line number extracted from Data\r
+\r
+Returns:\r
+\r
+  TRUE      - Successfully extracted\r
+  \r
+  FALSE     - Extraction failed\r
+\r
+--*/\r
+{\r
+  EFI_DEBUG_ASSERT_DATA   *AssertData;\r
+\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && \r
+        ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED)) {\r
+    //\r
+    // Assume if we have an uncontained unrecoverable error that the data hub\r
+    // may not work. So we will print out data here. If we had an IPMI controller,\r
+    // or error log we could wack the hardware here.\r
+    //\r
+    if ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE && (Data != NULL)) {\r
+      //\r
+      // ASSERT (Expresion) - \r
+      // ExtendedData == FileName\r
+      // Instance     == Line Nuber\r
+      // NULL         == String of Expresion\r
+      //\r
+      AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
+      *Filename = (CHAR8 *)(AssertData + 1);\r
+      *Description = *Filename + EfiAsciiStrLen (*Filename) + 1;\r
+      *LineNumber = AssertData->LineNumber;\r
+      return TRUE;\r
+    } \r
+  }\r
+  return FALSE;\r
+}\r
+\r
+\r
+BOOLEAN\r
+ReportStatusCodeExtractDebugInfo (\r
+  IN EFI_STATUS_CODE_DATA     *Data,\r
+  OUT UINT32                  *ErrorLevel,\r
+  OUT VA_LIST                 *Marker,\r
+  OUT CHAR8                   **Format\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Extract debug information from status code data.\r
+\r
+Arguments:\r
+\r
+  Data        - Optional data associated with status code.\r
+  ErrorLevel  - Error level extracted from Data\r
+  Marker      - VA_LIST extracted from Data\r
+  Format      - Format string extracted from Data\r
+\r
+Returns:\r
+\r
+  TRUE      - Successfully extracted\r
+  \r
+  FALSE     - Extraction failed\r
+\r
+--*/\r
+{\r
+  EFI_DEBUG_INFO      *DebugInfo;\r
+\r
+  if ((Data == NULL) || (!EfiCompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid))) {\r
+    return FALSE;\r
+  }\r
+  \r
+  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
+\r
+  *ErrorLevel = DebugInfo->ErrorLevel;\r
+\r
+  //\r
+  // The first 12 * UINTN bytes of the string are really an \r
+  // arguement stack to support varargs on the Format string.\r
+  //\r
+  *Marker = (VA_LIST) (DebugInfo + 1);\r
+  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
+\r
+  return TRUE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c
new file mode 100644 (file)
index 0000000..150f650
--- /dev/null
@@ -0,0 +1,802 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  String.c\r
+\r
+Abstract:\r
+\r
+  Unicode string primatives\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiCommonLib.h"\r
+\r
+VOID\r
+EfiStrCpy (\r
+  IN CHAR16   *Destination,\r
+  IN CHAR16   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Unicode string Source to Destination.\r
+\r
+Arguments:\r
+  Destination - Location to copy string\r
+  Source      - String to copy\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+}\r
+\r
+VOID\r
+EfiStrnCpy (\r
+  OUT CHAR16  *Dst,\r
+  IN  CHAR16  *Src,\r
+  IN  UINTN   Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy a string from source to destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN SrcLen;\r
+\r
+  SrcLen = EfiStrLen (Src);\r
+\r
+  Index = 0;\r
+  while (Index < Length && Index < SrcLen) {\r
+    Dst[Index] = Src[Index];\r
+    Index++;\r
+  }\r
+  for (Index = SrcLen; Index < Length; Index++) {\r
+    Dst[Index] = 0;\r
+  }\r
+}\r
+\r
+UINTN\r
+EfiStrLen (\r
+  IN CHAR16   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number of Unicode characters in String. This is not the same as\r
+  the length of the string in bytes.\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of Unicode characters in String\r
+\r
+--*/\r
+{\r
+  UINTN Length;\r
+  \r
+  for (Length=0; *String; String++, Length++);\r
+  return Length;\r
+}\r
+\r
+\r
+UINTN\r
+EfiStrSize (\r
+  IN CHAR16   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number bytes in the Unicode String. This is not the same as\r
+  the length of the string in characters. The string size includes the NULL\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of bytes in String\r
+\r
+--*/\r
+{\r
+  return ((EfiStrLen (String) + 1) * sizeof (CHAR16));\r
+}\r
+\r
+\r
+INTN\r
+EfiStrCmp (\r
+  IN CHAR16   *String,\r
+  IN CHAR16   *String2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare the Unicode string pointed by String to the string pointed by String2.\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+  String2 - The other string to process\r
+\r
+Returns:\r
+  Return a positive integer if String is lexicall greater than String2; Zero if \r
+  the two strings are identical; and a negative interger if String is lexically \r
+  less than String2.\r
+\r
+--*/\r
+{\r
+  while (*String) {\r
+    if (*String != *String2) {\r
+      break;\r
+    }\r
+\r
+    String += 1;\r
+    String2 += 1;\r
+  }\r
+\r
+  return *String - *String2;\r
+}\r
+\r
+INTN\r
+EfiStrnCmp (\r
+  IN CHAR16   *String,\r
+  IN CHAR16   *String2,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function compares the Unicode string String to the Unicode\r
+  string String2 for len characters.  If the first len characters\r
+  of String is identical to the first len characters of String2,\r
+  then 0 is returned.  If substring of String sorts lexicographically\r
+  after String2, the function returns a number greater than 0. If\r
+  substring of String sorts lexicographically before String2, the\r
+  function returns a number less than 0.\r
+\r
+Arguments:\r
+  String  - Compare to String2\r
+  String2 - Compare to String\r
+  Length  - Number of Unicode characters to compare\r
+\r
+Returns:\r
+  0     - The substring of String and String2 is identical.\r
+  > 0   - The substring of String sorts lexicographically after String2\r
+  < 0   - The substring of String sorts lexicographically before String2\r
+\r
+--*/\r
+{\r
+  while (*String && Length != 0) {\r
+    if (*String != *String2) {\r
+      break;\r
+    }\r
+    String  += 1;\r
+    String2 += 1;\r
+    Length  -= 1;\r
+  }\r
+  return Length > 0 ? *String - *String2 : 0;\r
+}\r
+\r
+VOID\r
+EfiStrCat (\r
+  IN CHAR16   *Destination,\r
+  IN CHAR16   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{   \r
+  EfiStrCpy (Destination + EfiStrLen (Destination), Source);\r
+}\r
+\r
+VOID\r
+EfiStrnCat (\r
+  IN CHAR16   *Dest,\r
+  IN CHAR16   *Src,\r
+  IN UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EfiStrnCpy (Dest + EfiStrLen (Dest), Src, Length);\r
+}\r
+\r
+UINTN\r
+EfiAsciiStrLen (\r
+  IN CHAR8   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number of Ascii characters in String. This is not the same as\r
+  the length of the string in bytes.\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of Ascii characters in String\r
+\r
+--*/\r
+{\r
+  UINTN Length;\r
+  \r
+  for (Length=0; *String; String++, Length++);\r
+  return Length;\r
+}\r
+\r
+\r
+CHAR8 *\r
+EfiAsciiStrCpy (\r
+  IN CHAR8    *Destination,\r
+  IN CHAR8    *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Ascii string Source to Destination.\r
+\r
+Arguments:\r
+  Destination - Location to copy string\r
+  Source      - String to copy\r
+\r
+Returns:\r
+  Pointer just pass the end of Destination\r
+\r
+--*/\r
+{\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return Destination + 1;\r
+}\r
+\r
+VOID\r
+EfiAsciiStrnCpy (\r
+  OUT CHAR8    *Dst,\r
+  IN  CHAR8    *Src,\r
+  IN  UINTN    Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Copy the Ascii string from source to destination\r
+\r
+Arguments:\r
+  Dst              Destination string\r
+  Src              Source string\r
+  Length           Length of destination string\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN SrcLen;\r
+\r
+  SrcLen = EfiAsciiStrLen (Src);\r
+\r
+  Index = 0;\r
+  while (Index < Length && Index < SrcLen) {\r
+    Dst[Index] = Src[Index];\r
+    Index++;\r
+  }\r
+  for (Index = SrcLen; Index < Length; Index++) {\r
+    Dst[Index] = 0;\r
+  }\r
+}\r
+\r
+UINTN\r
+EfiAsciiStrSize (\r
+  IN CHAR8   *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the number bytes in the Ascii String. This is not the same as\r
+  the length of the string in characters. The string size includes the NULL\r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+Returns:\r
+  Number of bytes in String\r
+\r
+--*/\r
+{\r
+  return (EfiAsciiStrLen (String) + 1);\r
+}\r
+\r
+\r
+INTN\r
+EfiAsciiStrCmp (\r
+  IN CHAR8   *String,\r
+  IN CHAR8   *String2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare the Ascii string pointed by String to the string pointed by String2. \r
+\r
+Arguments:\r
+  String - String to process\r
+\r
+  String2 - The other string to process\r
+\r
+Returns:\r
+  Return a positive integer if String is lexicall greater than String2; Zero if \r
+  the two strings are identical; and a negative interger if String is lexically \r
+  less than String2.\r
+--*/\r
+{\r
+  while (*String) {\r
+    if (*String != *String2) {\r
+      break;\r
+    }\r
+\r
+    String += 1;\r
+    String2 += 1;\r
+  }\r
+\r
+  return *String - *String2;\r
+}\r
+\r
+INTN\r
+EfiAsciiStrnCmp (\r
+  IN CHAR8    *String,\r
+  IN CHAR8    *String2,\r
+  IN UINTN    Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return 0;\r
+  }\r
+\r
+  while ((*String != '\0') &&\r
+         (*String == *String2) &&\r
+         (Length > 1)) {\r
+    String++;\r
+    String2++;\r
+    Length--;\r
+  }\r
+  return *String - *String2;\r
+}\r
+\r
+VOID\r
+EfiAsciiStrCat (\r
+  IN CHAR8   *Destination,\r
+  IN CHAR8   *Source\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{   \r
+  EfiAsciiStrCpy (Destination + EfiAsciiStrLen (Destination), Source);\r
+}\r
+\r
+VOID\r
+EfiAsciiStrnCat (\r
+  IN CHAR8   *Destination,\r
+  IN CHAR8   *Source,\r
+  IN UINTN   Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Concatinate Source on the end of Destination\r
+\r
+Arguments:\r
+  Destination - String to added to the end of.\r
+  Source      - String to concatinate.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiAsciiStrnCpy (Destination + EfiAsciiStrLen (Destination), Source, Length);\r
+}\r
+\r
+BOOLEAN\r
+IsHexDigit (\r
+  OUT UINT8      *Digit,\r
+  IN  CHAR16      Char\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Determines if a Unicode character is a hexadecimal digit.\r
+    The test is case insensitive.\r
+\r
+  Arguments:\r
+    Digit - Pointer to byte that receives the value of the hex character.\r
+    Char  - Unicode character to test.\r
+\r
+  Returns:\r
+    TRUE  - If the character is a hexadecimal digit.\r
+    FALSE - Otherwise.\r
+\r
+--*/\r
+{\r
+  if ((Char >= L'0') && (Char <= L'9')) {\r
+    *Digit = (UINT8) (Char - L'0');\r
+    return TRUE;\r
+  }\r
+\r
+  if ((Char >= L'A') && (Char <= L'F')) {\r
+    *Digit = (UINT8) (Char - L'A' + 0x0A);\r
+    return TRUE;\r
+  }\r
+\r
+  if ((Char >= L'a') && (Char <= L'f')) {\r
+    *Digit = (UINT8) (Char - L'a' + 0x0A);\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+CHAR16\r
+NibbleToHexChar (\r
+  IN UINT8      Nibble\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts the low nibble of a byte  to hex unicode character.\r
+\r
+  Arguments:\r
+    Nibble - lower nibble of a byte.\r
+\r
+  Returns:\r
+    Hex unicode character.\r
+\r
+--*/\r
+{\r
+  Nibble &= 0x0F;\r
+  if (Nibble <= 0x9) {\r
+    return (CHAR16)(Nibble + L'0');\r
+  }\r
+\r
+  return (CHAR16)(Nibble - 0xA + L'A');\r
+}\r
+\r
+EFI_STATUS\r
+HexStringToBuf (\r
+  IN OUT UINT8                     *Buf,   \r
+  IN OUT UINTN                    *Len,\r
+  IN     CHAR16                    *Str,\r
+  OUT    UINTN                     *ConvertedStrLen  OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts Unicode string to binary buffer.\r
+    The conversion may be partial.\r
+    The first character in the string that is not hex digit stops the conversion.\r
+    At a minimum, any blob of data could be represented as a hex string.\r
+\r
+  Arguments:\r
+    Buf    - Pointer to buffer that receives the data.\r
+    Len    - Length in bytes of the buffer to hold converted data.\r
+                If routine return with EFI_SUCCESS, containing length of converted data.\r
+                If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.\r
+    Str    - String to be converted from.\r
+    ConvertedStrLen - Length of the Hex String consumed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS: Routine Success.\r
+    EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.\r
+    EFI_\r
+\r
+--*/\r
+{\r
+  UINTN       HexCnt;\r
+  UINTN       Idx;\r
+  UINTN       BufferLength;\r
+  UINT8       Digit;\r
+  UINT8       Byte;\r
+\r
+  //\r
+  // Find out how many hex characters the string has.\r
+  //\r
+  for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);\r
+\r
+  if (HexCnt == 0) {\r
+    *Len = 0;\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Two Unicode characters make up 1 buffer byte. Round up.\r
+  //\r
+  BufferLength = (HexCnt + 1) / 2; \r
+\r
+  //\r
+  // Test if  buffer is passed enough.\r
+  //\r
+  if (BufferLength > (*Len)) {\r
+    *Len = BufferLength;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *Len = BufferLength;\r
+\r
+  for (Idx = 0; Idx < HexCnt; Idx++) {\r
+\r
+    IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);\r
+\r
+    //\r
+    // For odd charaters, write the lower nibble for each buffer byte,\r
+    // and for even characters, the upper nibble.\r
+    //\r
+    if ((Idx & 1) == 0) {\r
+      Byte = Digit;\r
+    } else {\r
+      Byte = Buf[Idx / 2];\r
+      Byte &= 0x0F;\r
+      Byte |= Digit << 4;\r
+    }\r
+\r
+    Buf[Idx / 2] = Byte;\r
+  }\r
+\r
+  if (ConvertedStrLen != NULL) {\r
+    *ConvertedStrLen = HexCnt;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BufToHexString (\r
+  IN OUT CHAR16                    *Str,\r
+  IN OUT UINTN                     *HexStringBufferLength,\r
+  IN     UINT8                     *Buf,\r
+  IN     UINTN                      Len\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Converts binary buffer to Unicode string.\r
+    At a minimum, any blob of data could be represented as a hex string.\r
+\r
+  Arguments:\r
+    Str - Pointer to the string.\r
+    HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.\r
+                                        If routine return with EFI_SUCCESS, containing length of hex string buffer.\r
+                                        If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.\r
+    Buf - Buffer to be converted from.\r
+    Len - Length in bytes of the buffer to be converted.\r
+\r
+  Returns:\r
+    EFI_SUCCESS: Routine success.\r
+    EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.\r
+\r
+--*/\r
+{\r
+  UINTN       Idx;\r
+  UINT8       Byte;\r
+  UINTN       StrLen;\r
+\r
+  //\r
+  // Make sure string is either passed or allocate enough.\r
+  // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.\r
+  // Plus the Unicode termination character.\r
+  //\r
+  StrLen = Len * 2;\r
+  if (StrLen > ((*HexStringBufferLength) - 1)) {\r
+    *HexStringBufferLength = StrLen + 1;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *HexStringBufferLength = StrLen + 1;\r
+  //\r
+  // Ends the string.\r
+  //\r
+  Str[StrLen] = L'\0'; \r
+\r
+  for (Idx = 0; Idx < Len; Idx++) {\r
+\r
+    Byte = Buf[Idx];\r
+    Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);\r
+    Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EfiStrTrim (\r
+  IN OUT CHAR16   *str,\r
+  IN     CHAR16   CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Removes (trims) specified leading and trailing characters from a string.\r
+  \r
+Arguments: \r
+  \r
+  str     - Pointer to the null-terminated string to be trimmed. On return, \r
+            str will hold the trimmed string. \r
+  CharC       - Character will be trimmed from str.\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  CHAR16  *p1;\r
+  CHAR16  *p2;\r
+  \r
+  if (*str == 0) {\r
+    return;\r
+  }\r
+  \r
+  //\r
+  // Trim off the leading and trailing characters c\r
+  //\r
+  for (p1 = str; *p1 && *p1 == CharC; p1++) {\r
+    ;\r
+  }\r
+  \r
+  p2 = str;\r
+  if (p2 == p1) {\r
+    while (*p1) {\r
+      p2++;\r
+      p1++;\r
+    }\r
+  } else {\r
+    while (*p1) {    \r
+    *p2 = *p1;    \r
+    p1++;\r
+    p2++;\r
+    }\r
+    *p2 = 0;\r
+  }\r
+  \r
+  \r
+  for (p1 = str + EfiStrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {\r
+    ;\r
+  }\r
+  if  (p1 !=  str + EfiStrLen(str) - 1) { \r
+    *(p1 + 1) = 0;\r
+  }\r
+}\r
+CHAR16*\r
+EfiStrStr (\r
+   IN  CHAR16  *String,\r
+   IN  CHAR16  *StrCharSet\r
+   )\r
+/*++\r
\r
+Routine Description:\r
+   \r
+  Find a substring.\r
+   \r
+Arguments: \r
+   \r
+  String      - Null-terminated string to search.\r
+  StrCharSet  - Null-terminated string to search for.\r
+   \r
+Returns:\r
+  The address of the first occurrence of the matching substring if successful, or NULL otherwise.\r
+--*/\r
+{\r
+  CHAR16 *Src;\r
+  CHAR16 *Sub;\r
+  \r
+  Src = String;\r
+  Sub = StrCharSet;\r
+  \r
+  while ((*String != L'\0') && (*StrCharSet != L'\0')) {\r
+    if (*String++ != *StrCharSet++) {\r
+      String = ++Src;\r
+      StrCharSet = Sub;\r
+    }\r
+  }\r
+  if (*StrCharSet == L'\0') {\r
+    return Src;\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
\r
+CHAR8*\r
+EfiAsciiStrStr (\r
+  IN  CHAR8  *String,\r
+  IN  CHAR8  *StrCharSet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Find a Ascii substring.\r
+  \r
+Arguments: \r
+  \r
+  String      - Null-terminated Ascii string to search.\r
+  StrCharSet  - Null-terminated Ascii string to search for.\r
+  \r
+Returns:\r
+  The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise.\r
+--*/\r
+{\r
+  CHAR8 *Src;\r
+  CHAR8 *Sub;\r
+   \r
+  Src = String;\r
+  Sub = StrCharSet;\r
+  \r
+  while ((*String != '\0') && (*StrCharSet != '\0')) {\r
+    if (*String++ != *StrCharSet++) {\r
+      String = ++Src;\r
+      StrCharSet = Sub;\r
+    }\r
+  }\r
+  if (*StrCharSet == '\0') {\r
+    return Src;\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c
new file mode 100644 (file)
index 0000000..1d4c77e
--- /dev/null
@@ -0,0 +1,213 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ValueToString.c\r
+\r
+Abstract:\r
+\r
+  Routines changing value to Hex or Dec string\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+static CHAR16 mHexStr[] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',\r
+                            L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F' };\r
+\r
+UINTN\r
+EfiValueToHexStr (\r
+  IN  OUT CHAR16  *Buffer, \r
+  IN  UINT64      Value, \r
+  IN  UINTN       Flags, \r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints a Value as a hex number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii hex string of Value.\r
+\r
+  Value  - Hex value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing Hex string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  CHAR16  TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR16  *TempStr;\r
+  CHAR16  Prefix;\r
+  CHAR16  *BufferPtr;\r
+  UINTN   Count;\r
+  UINTN   Index;\r
+\r
+  TempStr   = TempBuffer;\r
+  BufferPtr = Buffer;\r
+\r
+  //\r
+  // Count starts at one since we will null terminate. Each iteration of the\r
+  // loop picks off one nibble. Oh yea TempStr ends up backwards\r
+  //\r
+  Count = 0;\r
+  \r
+  if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) {\r
+    Width = CHARACTER_NUMBER_FOR_VALUE - 1;\r
+  }\r
+\r
+  do {\r
+    Index = ((UINTN)Value & 0xf);\r
+    *(TempStr++) = mHexStr[Index];\r
+    Value = RShiftU64 (Value, 4);\r
+    Count++;\r
+  } while (Value != 0);\r
+\r
+  if (Flags & PREFIX_ZERO) {\r
+    Prefix = '0';\r
+  } else { \r
+    Prefix = ' ';\r
+  }\r
+\r
+  Index = Count;\r
+  if (!(Flags & LEFT_JUSTIFY)) {\r
+    for (; Index < Width; Index++) {\r
+      *(TempStr++) = Prefix;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Reverse temp string into Buffer.\r
+  //\r
+  if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {\r
+    TempStr = TempBuffer + Width;\r
+  }\r
+  Index = 0;\r
+  while (TempStr != TempBuffer) {\r
+    *(BufferPtr++) = *(--TempStr);\r
+    Index++;\r
+  }\r
+    \r
+  *BufferPtr = 0;\r
+  return Index;\r
+}\r
+\r
+\r
+UINTN\r
+EfiValueToString (\r
+  IN  OUT CHAR16  *Buffer, \r
+  IN  INT64       Value, \r
+  IN  UINTN       Flags,\r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint worker function that prints a Value as a decimal number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii decimal number string of Value.\r
+\r
+  Value  - Decimal value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing decimal string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  CHAR16    TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR16    *TempStr;\r
+  CHAR16    *BufferPtr;\r
+  UINTN     Count;\r
+  UINTN     ValueCharNum;\r
+  UINTN     Remainder;\r
+  CHAR16    Prefix;\r
+  UINTN     Index;\r
+  BOOLEAN   ValueIsNegative;\r
+\r
+  TempStr         = TempBuffer;\r
+  BufferPtr       = Buffer;\r
+  Count           = 0;\r
+  ValueCharNum    = 0;\r
+  ValueIsNegative = FALSE;\r
+\r
+  if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) {\r
+    Width = CHARACTER_NUMBER_FOR_VALUE - 1;\r
+  }\r
+\r
+  if (Value < 0) {\r
+    Value           = -Value;\r
+    ValueIsNegative = TRUE;\r
+  }\r
+\r
+  do {\r
+    Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder);\r
+    *(TempStr++) = (CHAR16)(Remainder + '0');\r
+    ValueCharNum++;\r
+    Count++;\r
+    if ((Flags & COMMA_TYPE) == COMMA_TYPE) {\r
+      if (ValueCharNum % 3 == 0 && Value != 0) {\r
+        *(TempStr++) = ',';\r
+        Count++;\r
+      }\r
+    }\r
+  } while (Value != 0);\r
+\r
+  if (ValueIsNegative) {\r
+    *(TempStr++)    = '-';\r
+    Count++;\r
+  }\r
+\r
+  if ((Flags & PREFIX_ZERO) && !ValueIsNegative) {\r
+    Prefix = '0';\r
+  } else { \r
+    Prefix = ' ';\r
+  }                   \r
+\r
+  Index = Count;\r
+  if (!(Flags & LEFT_JUSTIFY)) {\r
+    for (; Index < Width; Index++) {\r
+      *(TempStr++) = Prefix;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Reverse temp string into Buffer.\r
+  //\r
+  if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {\r
+    TempStr = TempBuffer + Width;\r
+  }\r
+  Index = 0;\r
+  while (TempStr != TempBuffer) {\r
+    *(BufferPtr++) = *(--TempStr);\r
+    Index++;\r
+  }\r
+\r
+  *BufferPtr = 0;\r
+  return Index;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c
new file mode 100644 (file)
index 0000000..4278762
--- /dev/null
@@ -0,0 +1,356 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LinkedList.c\r
+\r
+Abstract:\r
+\r
+  Linked List Library Functions\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+\r
+VOID\r
+InitializeListHead (\r
+  EFI_LIST_ENTRY       *List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the head of the List.  The caller must allocate the memory \r
+  for the EFI_LIST. This function must be called before the other linked\r
+  list macros can be used.\r
+    \r
+Arguments:\r
+\r
+  List - Pointer to list head to initialize\r
+   \r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+\r
+{\r
+  List->ForwardLink = List;\r
+  List->BackLink    = List;\r
+}\r
+\r
+\r
+BOOLEAN\r
+IsListEmpty (\r
+  EFI_LIST_ENTRY  *List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
+  The list must have been initialized with InitializeListHead () before using \r
+  this function.\r
+    \r
+Arguments:\r
+\r
+  List - Pointer to list head to test\r
+\r
+   \r
+Returns:\r
+\r
+  Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
+\r
+--*/\r
+{\r
+  return (BOOLEAN)(List->ForwardLink == List);\r
+}\r
+\r
+\r
+VOID\r
+RemoveEntryList (\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Remove Node from the doubly linked list. It is the caller's responsibility\r
+  to free any memory used by the entry if needed. The list must have been \r
+  initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  Entry - Element to remove from the list.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_LIST_ENTRY  *_ForwardLink;\r
+  EFI_LIST_ENTRY  *_BackLink;\r
+\r
+  _ForwardLink           = Entry->ForwardLink;\r
+  _BackLink              = Entry->BackLink;      \r
+  _BackLink->ForwardLink = _ForwardLink;\r
+  _ForwardLink->BackLink = _BackLink;   \r
+\r
+  DEBUG_CODE (\r
+    Entry->ForwardLink = (EFI_LIST_ENTRY *) EFI_BAD_POINTER;\r
+    Entry->BackLink    = (EFI_LIST_ENTRY *) EFI_BAD_POINTER;\r
+  )\r
+}\r
+\r
+\r
+VOID\r
+InsertTailList (\r
+  EFI_LIST_ENTRY  *ListHead,\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert a Node into the end of a doubly linked list. The list must have \r
+  been initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  ListHead - Head of doubly linked list\r
+\r
+  Entry    - Element to insert at the end of the list.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_LIST_ENTRY *_ListHead;\r
+  EFI_LIST_ENTRY *_BackLink;\r
+\r
+  _ListHead              = ListHead;              \r
+  _BackLink              = _ListHead->BackLink;     \r
+  Entry->ForwardLink     = _ListHead;    \r
+  Entry->BackLink        = _BackLink;       \r
+  _BackLink->ForwardLink = Entry;    \r
+  _ListHead->BackLink    = Entry;       \r
+}\r
+\r
+\r
+\r
+VOID\r
+InsertHeadList (\r
+  EFI_LIST_ENTRY  *ListHead,\r
+  EFI_LIST_ENTRY  *Entry\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert a Node into the start of a doubly linked list. The list must have \r
+  been initialized with InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  ListHead - Head of doubly linked list\r
+\r
+  Entry    - Element to insert to beginning of list\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_LIST_ENTRY  *_ListHead;\r
+  EFI_LIST_ENTRY  *_ForwardLink;\r
+\r
+  _ListHead               = ListHead;                 \r
+  _ForwardLink            = _ListHead->ForwardLink;  \r
+  Entry->ForwardLink      = _ForwardLink;    \r
+  Entry->BackLink         = _ListHead;          \r
+  _ForwardLink->BackLink  = Entry;       \r
+  _ListHead->ForwardLink  = Entry;       \r
+}\r
+\r
+VOID\r
+SwapListEntries (\r
+  EFI_LIST_ENTRY  *Entry1,\r
+  EFI_LIST_ENTRY  *Entry2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Swap the location of the two elements of a doubly linked list. Node2 \r
+  is placed in front of Node1. The list must have been initialized with \r
+  InitializeListHead () before using this function.\r
+    \r
+Arguments:\r
+\r
+  Entry1 - Element in the doubly linked list in front of Node2. \r
+\r
+  Entry2 - Element in the doubly linked list behind Node1.\r
+   \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_LIST_ENTRY *Entry1ForwardLink;\r
+  EFI_LIST_ENTRY *Entry1BackLink;\r
+  EFI_LIST_ENTRY *Entry2ForwardLink;\r
+  EFI_LIST_ENTRY *Entry2BackLink;\r
+\r
+  Entry2ForwardLink           = Entry2->ForwardLink;          \r
+  Entry2BackLink              = Entry2->BackLink;                \r
+  Entry1ForwardLink           = Entry1->ForwardLink;          \r
+  Entry1BackLink              = Entry1->BackLink;                \r
+  Entry2BackLink->ForwardLink = Entry2ForwardLink;    \r
+  Entry2ForwardLink->BackLink = Entry2BackLink;       \r
+  Entry2->ForwardLink         = Entry1;                     \r
+  Entry2->BackLink            = Entry1BackLink;                \r
+  Entry1BackLink->ForwardLink = Entry2;             \r
+  Entry1->BackLink            = Entry2;                      \r
+}\r
+\r
+\r
+EFI_LIST_ENTRY *\r
+GetFirstNode (\r
+  EFI_LIST_ENTRY  *List \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the first node pointed to by the list head.  The list must \r
+  have been initialized with InitializeListHead () before using this \r
+  function and must contain data.\r
+    \r
+Arguments:\r
+\r
+  List - The head of the doubly linked list.\r
+   \r
+Returns:\r
+  \r
+  Pointer to the first node, if the list contains nodes.  The list will\r
+  return a null value--that is, the value of List--when the list is empty.\r
+    See the description of IsNull for more information.\r
+\r
+\r
+--*/\r
+{\r
+  return List->ForwardLink;\r
+}\r
+\r
+\r
+EFI_LIST_ENTRY *\r
+GetNextNode (\r
+  EFI_LIST_ENTRY  *List,\r
+  EFI_LIST_ENTRY  *Node\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the node following Node in the list. The list must \r
+  have been initialized with InitializeListHead () before using this \r
+  function and must contain data.\r
+    \r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node in the list.  This value MUST NOT be the literal value NULL.\r
+    See the description of IsNull for more information.\r
+   \r
+Returns:\r
+  \r
+  Pointer to the next node, if one exists.  Otherwise, returns a null value,\r
+  which is actually a pointer to List.\r
+    See the description of IsNull for more information.\r
+\r
+--*/\r
+{\r
+  if (Node == List) {\r
+    return List;\r
+  } \r
+  return Node->ForwardLink;\r
+}\r
+\r
+\r
+BOOLEAN \r
+IsNull ( \r
+  EFI_LIST_ENTRY  *List,\r
+  EFI_LIST_ENTRY  *Node \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines whether the given node is null.  Note that Node is null\r
+  when its value is equal to the value of List.  It is an error for\r
+  Node to be the literal value NULL [(VOID*)0x0].\r
+\r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node to test.  MUST NOT be the literal value NULL.  See\r
+    the description above.\r
+   \r
+Returns:\r
+  \r
+  Returns true if the node is null.\r
+\r
+--*/\r
+{\r
+  return (BOOLEAN)(Node == List);\r
+}\r
+\r
+\r
+BOOLEAN \r
+IsNodeAtEnd ( \r
+  EFI_LIST_ENTRY  *List, \r
+  EFI_LIST_ENTRY  *Node \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines whether the given node is at the end of the list.  Used\r
+  to walk the list.  The list must have been initialized with \r
+  InitializeListHead () before using this function and must contain \r
+  data.\r
+\r
+Arguments:\r
+\r
+  List - The head of the list.  MUST NOT be the literal value NULL.\r
+  Node - The node to test.  MUST NOT be the literal value NULL.\r
+    See the description of IsNull for more information.\r
+   \r
+Returns:\r
+  \r
+  Returns true if the list is the tail.\r
+\r
+--*/\r
+{\r
+  if (IsNull (List, Node)) {\r
+    return FALSE;\r
+  }\r
+  return (BOOLEAN)(List->BackLink == Node);\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm
new file mode 100644 (file)
index 0000000..9d1e04b
--- /dev/null
@@ -0,0 +1,74 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   CopyMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; EfiCommonLibCopyMem (\r
+;   OUT     VOID                      *Destination,\r
+;   IN      VOID                      *Source,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibCopyMem  PROC    USES    rsi rdi\r
+    cmp     rdx, rcx                    ; if Source == Destination, do nothing\r
+    je      @CopyMemDone\r
+    cmp     r8, 0                       ; if Count == 0, do nothing\r
+    je      @CopyMemDone\r
+    mov     rsi, rdx                    ; rsi <- Source\r
+    mov     rdi, rcx                    ; rdi <- Destination\r
+    lea     r9, [rsi + r8 - 1]          ; r9 <- End of Source\r
+    cmp     rsi, rdi\r
+    mov     rax, rdi                    ; rax <- Destination as return value\r
+    jae     @F\r
+    cmp     r9, rdi\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    mov     rcx, r8\r
+    and     r8, 7\r
+    shr     rcx, 3                      ; rcx <- # of Qwords to copy\r
+    jz      @CopyBytes\r
+    DB      49h, 0fh, 7eh, 0c2h         ; movd r10, mm0 (Save mm0 in r10)\r
+@@:\r
+    DB      0fh, 6fh, 06h               ; movd mm0, [rsi]\r
+    DB      48h, 0fh, 7eh, 07h          ; movd [rdi], mm0\r
+    add     rsi, 8\r
+    add     rdi, 8\r
+    loop    @B\r
+    DB      49h, 0fh, 6eh, 0c2h         ; movd mm0, r10 (Restore mm0)\r
+    jmp     @CopyBytes\r
+@CopyBackward:\r
+    mov     rsi, r9                     ; rsi <- End of Source\r
+    lea     rdi, [rdi + r8 - 1]         ; rdi <- End of Destination\r
+    std                                 ; set direction flag\r
+@CopyBytes:\r
+    mov     rcx, r8\r
+    rep     movsb                       ; Copy bytes backward\r
+    cld\r
+@CopyMemDone:   \r
+    ret\r
+EfiCommonLibCopyMem  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm
new file mode 100644 (file)
index 0000000..9e60e94
--- /dev/null
@@ -0,0 +1,80 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   CopyMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiCommonLibCopyMem (\r
+;   OUT     VOID                      *Destination,\r
+;   IN      VOID                      *Source,\r
+;   IN      UINTN                     Count\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibCopyMem  PROC    USES    rsi rdi\r
+    cmp     rdx, rcx                    ; if Source == Destination, do nothing\r
+    je      @CopyMemDone\r
+    cmp     r8, 0                       ; if Count == 0, do nothing\r
+    je      @CopyMemDone\r
+    mov     rsi, rdx                    ; rsi <- Source\r
+    mov     rdi, rcx                    ; rdi <- Destination\r
+    lea     r9, [rsi + r8 - 1]          ; r9 <- End of Source\r
+    cmp     rsi, rdi\r
+    mov     rax, rdi                    ; rax <- Destination as return value\r
+    jae     @F                          ; Copy forward if Source > Destination\r
+    cmp     r9, rdi                     ; Overlapped?\r
+    jae     @CopyBackward               ; Copy backward if overlapped\r
+@@:\r
+    xor     rcx, rcx\r
+    sub     rcx, rdi                    ; rcx <- -rdi\r
+    and     rcx, 15                     ; rcx + rsi should be 16 bytes aligned\r
+    jz      @F                          ; skip if rcx == 0\r
+    cmp     rcx, r8\r
+    cmova   rcx, r8\r
+    sub     r8, rcx\r
+    rep     movsb\r
+@@:\r
+    mov     rcx, r8\r
+    and     r8, 15\r
+    shr     rcx, 4                      ; rcx <- # of DQwords to copy\r
+    jz      @CopyBytes\r
+@@:\r
+    movdqu  xmm0, [rsi]                 ; rsi may not be 16-byte aligned\r
+    movdqa  [rdi], xmm0                 ; rdi should be 16-byte aligned\r
+    add     rsi, 16\r
+    add     rdi, 16\r
+    loop    @B\r
+    jmp     @CopyBytes                  ; copy remaining bytes\r
+@CopyBackward:\r
+    mov     rsi, r9                     ; rsi <- Last byte of Source\r
+    lea     rdi, [rdi + r8 - 1]         ; rdi <- Last byte of Destination\r
+    std\r
+@CopyBytes:\r
+    mov     rcx, r8\r
+    rep     movsb\r
+    cld\r
+@CopyMemDone:   \r
+    ret\r
+EfiCommonLibCopyMem  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm
new file mode 100644 (file)
index 0000000..7568a52
--- /dev/null
@@ -0,0 +1,60 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; EfiCommonLibSetMem (\r
+;   OUT     VOID                      *Buffer,\r
+;   IN      UINTN                     Size,\r
+;   IN      UINT8                     Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibSetMem   PROC    USES    rdi\r
+    cmp     rdx, 0                      ; if Size == 0, do nothing\r
+    je      @SetDone\r
+    mov     rax, r8\r
+    mov     ah, al\r
+    DB      48h, 0fh, 6eh, 0c0h         ; movd mm0, rax\r
+    mov     r8, rcx\r
+    mov     rdi, r8                     ; rdi <- Buffer\r
+    mov     rcx, rdx\r
+    and     edx, 7\r
+    shr     rcx, 3\r
+    jz      @SetBytes\r
+    DB      0fh, 70h, 0C0h, 00h         ; pshufw mm0, mm0, 0h\r
+@@:\r
+    DB      48h, 0fh, 7eh, 07h          ; movd [rdi], mm0\r
+    add     rdi, 8\r
+    loop    @B\r
+@SetBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+    mov     rax, r8\r
+@SetDone:\r
+    ret\r
+EfiCommonLibSetMem   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm
new file mode 100644 (file)
index 0000000..8667d7e
--- /dev/null
@@ -0,0 +1,67 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EfiCommonLibSetMem (\r
+;   OUT     VOID                      *Buffer,\r
+;   IN      UINTN                     Size,\r
+;   IN      UINT8                     Value\r
+;   );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibSetMem   PROC    USES    rdi\r
+    cmp     rdx, 0                      ; if Size == 0, do nothing\r
+    je      @SetDone\r
+    mov     rdi, rcx                    ; rdi <- Buffer\r
+    mov     al, r8b                     ; al <- Value\r
+    xor     rcx, rcx\r
+    sub     rcx, rdi\r
+    and     rcx, 15                     ; rcx + rdi aligns on 16-byte boundary\r
+    jz      @F\r
+    cmp     rcx, rdx\r
+    cmova   rcx, rdx\r
+    sub     rdx, rcx\r
+    rep     stosb\r
+@@:\r
+    mov     rcx, rdx\r
+    and     rdx, 15\r
+    shr     rcx, 4\r
+    jz      @SetBytes\r
+    mov     ah, al                      ; ax <- Value repeats twice\r
+    movd    xmm0, eax                   ; xmm0[0..16] <- Value repeats twice\r
+    pshuflw xmm0, xmm0, 0               ; xmm0[0..63] <- Value repeats 8 times\r
+    movlhps xmm0, xmm0                  ; xmm0 <- Value repeats 16 times\r
+@@:\r
+    movdqa  [rdi], xmm0                 ; rdi should be 16-byte aligned\r
+    add     rdi, 16\r
+    loop    @B\r
+@SetBytes:\r
+    mov     ecx, edx                    ; high 32 bits of rcx are always zero\r
+    rep     stosb\r
+@SetDone:\r
+    ret\r
+EfiCommonLibSetMem   ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm
new file mode 100644 (file)
index 0000000..5f2c077
--- /dev/null
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   ZeroMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   ZeroMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  EfiCommonLibZeroMem (\r
+;    IN VOID   *Buffer,\r
+;    IN UINTN  Size\r
+;    );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibZeroMem  PROC    USES    rdi\r
+    mov     rdi, rcx\r
+    mov     rcx, rdx\r
+    mov     r8, rdi\r
+    and     edx, 7\r
+    shr     rcx, 3\r
+    jz      @ZeroBytes\r
+    DB      0fh, 0efh, 0c0h             ; pxor mm0, mm0\r
+@@:\r
+    DB      48h, 0fh, 7eh, 07h          ; movd [rdi], mm0\r
+    add     rdi, 8\r
+    loop    @B\r
+@ZeroBytes:\r
+    xor     eax, eax\r
+    mov     ecx, edx\r
+    rep     stosb\r
+    mov     rax, r8\r
+    ret\r
+EfiCommonLibZeroMem  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm
new file mode 100644 (file)
index 0000000..58cf76e
--- /dev/null
@@ -0,0 +1,60 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   ZeroMem.asm\r
+;\r
+; Abstract:\r
+;\r
+;   ZeroMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EfiCommonLibZeroMem (\r
+;    IN VOID   *Buffer,\r
+;    IN UINTN  Size\r
+;    );\r
+;------------------------------------------------------------------------------\r
+EfiCommonLibZeroMem  PROC    USES    rdi\r
+    mov     rdi, rcx\r
+    xor     rcx, rcx\r
+    xor     eax, eax\r
+    sub     rcx, rdi\r
+    and     rcx, 15\r
+    jz      @F\r
+    cmp     rcx, rdx\r
+    cmova   rcx, rdx\r
+    sub     rdx, rcx\r
+    rep     stosb\r
+@@:\r
+    mov     rcx, rdx\r
+    and     edx, 15\r
+    shr     rcx, 4\r
+    jz      @ZeroBytes\r
+    pxor    xmm0, xmm0\r
+@@:\r
+    movdqa  [rdi], xmm0                 ; rdi should be 16-byte aligned\r
+    add     rdi, 16\r
+    loop    @B\r
+@ZeroBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+    ret\r
+EfiCommonLibZeroMem  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c
new file mode 100644 (file)
index 0000000..c28fd03
--- /dev/null
@@ -0,0 +1,603 @@
+\r
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+MemoryAllocationModule Name:\r
+\r
+  Peihoblib.c\r
+\r
+Abstract:\r
+\r
+  PEI Library Functions\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiHob.h"\r
+#include "peihoblib.h"\r
+#include "peilib.h"\r
+#include EFI_GUID_DEFINITION(MemoryAllocationHob)\r
+\r
+\r
+EFI_PEI_HOB_POINTERS\r
+BuildHobEndOfHobList (\r
+  IN  VOID  *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds an end of HOB list HOB\r
+\r
+Arguments:\r
+\r
+  HobStart    - The HOB to build\r
+\r
+Returns:\r
+\r
+  A pointer to the next HOB\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  \r
+  Hob.Header->HobType   = EFI_HOB_TYPE_END_OF_HOB_LIST;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);\r
+\r
+  Hob.Header++;\r
+  return Hob;\r
+}\r
+\r
+EFI_STATUS\r
+BuildHobHandoffInfoTable (\r
+  IN  VOID                    *HobStart,\r
+  IN  UINT16                  Version,\r
+  IN  EFI_BOOT_MODE           BootMode,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiMemoryTop,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiMemoryBottom,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryTop,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryBottom\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HandoffInformationTable Information Table HOB\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  Version       - The version number pertaining to the PHIT HOB definition.\r
+  BootMode      - The system boot mode as determined during the HOB producer phase.\r
+  EfiMemoryTop  - The highest address location of memory that is allocated for use by the HOB\r
+                  producer phase.\r
+  EfiMemoryBottom   - The lowest address location of memory that is allocated for use by the HOB\r
+                      producer phase.\r
+  EfiFreeMemoryTop  - The highest address location of free memory that is currently available for use\r
+                      by the HOB producer phase.\r
+  EfiFreeMemoryBottom   - The lowest address location of free memory that is available for \r
+                          use by the HOB producer phase.\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HobEnd;\r
+  \r
+\r
+  HandOffHob.Raw     = HobStart;\r
+  Hob.Raw            = HobStart;\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_HANDOFF;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);\r
+\r
+  Hob.HandoffInformationTable->Version        = Version;\r
+  Hob.HandoffInformationTable->BootMode       = BootMode;\r
+  \r
+  Hob.HandoffInformationTable->EfiMemoryTop     = EfiMemoryTop;\r
+  Hob.HandoffInformationTable->EfiMemoryBottom  = EfiMemoryBottom;\r
+  Hob.HandoffInformationTable->EfiFreeMemoryTop = EfiFreeMemoryTop;\r
+  Hob.HandoffInformationTable->EfiFreeMemoryBottom = EfiFreeMemoryBottom;\r
\r
+  HobEnd.Raw = (VOID*)(Hob.HandoffInformationTable + 1);\r
+  Hob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd.Raw;\r
+  Hob = BuildHobEndOfHobList (HobEnd.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+BuildHobModule (\r
+  IN VOID                   *HobStart,\r
+  IN EFI_GUID               *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for a loaded PE32 module\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  ModuleName                - The GUID File Name of the HON from the Firmware Volume\r
+\r
+  MemoryAllocationModule                    - The 64 bit physical address of the module\r
+\r
+  ModuleLength              - The length of the module in bytes\r
+\r
+  EntryPoint                - The 64 bit physical address of the entry point to the module\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
\r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);\r
+\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_MEMORY_ALLOCATION;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_MODULE);\r
+  \r
+  CopyMem(&(Hob.MemoryAllocationModule->ModuleName), ModuleName, sizeof(EFI_GUID));\r
+  CopyMem(&(Hob.MemoryAllocationModule->MemoryAllocationHeader.Name), &gEfiHobMemeryAllocModuleGuid, sizeof(EFI_GUID));\r
+  Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
+  Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength      = ModuleLength;\r
+  Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryType  = EfiConventionalMemory;\r
+\r
+  Hob.MemoryAllocationModule->EntryPoint        = EntryPoint;\r
+\r
+  Hob.MemoryAllocationModule++;\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BuildHobResourceDescriptor (\r
+  IN VOID *                       HobStart,\r
+  IN EFI_RESOURCE_TYPE             ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE   ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS        PhysicalStart,\r
+  IN UINT64                      NumberOfBytes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB that describes a chunck of system memory\r
+\r
+Arguments:\r
+\r
+  HobStart          - Start pointer of hob list\r
+\r
+  ResourceType      - The type of memory described by this HOB\r
+\r
+  ResourceAttribute - The memory attributes of the memory described by this HOB\r
+\r
+  PhysicalStart   - The 64 bit physical address of memory described by this HOB\r
+\r
+  NumberOfBytes   - The length of the memoty described by this HOB in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+  \r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID *)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);\r
+  \r
+  Hob.Header->HobType   = EFI_HOB_TYPE_RESOURCE_DESCRIPTOR;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_RESOURCE_DESCRIPTOR);\r
+\r
+  Hob.ResourceDescriptor->ResourceType          = ResourceType;\r
+  Hob.ResourceDescriptor->ResourceAttribute     = ResourceAttribute;\r
+  Hob.ResourceDescriptor->PhysicalStart = PhysicalStart;\r
+  Hob.ResourceDescriptor->ResourceLength = NumberOfBytes; \r
+\r
+  Hob.ResourceDescriptor++;\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BuildHobGuidType (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_GUID                    *Guid,\r
+  IN VOID                        *Buffer,\r
+  IN UINTN                       BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  HobStart    - Start pointer of hob list\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+\r
+  Buffer      - A pointer to the data for the custom HOB type\r
+\r
+  BufferSize  - The size in byte of BufferSize\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+  UINTN                   Length;\r
+     \r
+  \r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;  \r
+\r
+\r
+  Hob.Header->HobType = EFI_HOB_TYPE_GUID_EXTENSION;\r
+  Length              = sizeof(EFI_HOB_GUID_TYPE) + BufferSize;\r
+  Hob.Header->HobLength  = (UINT16)Length;\r
+  CopyMem(&Hob.Guid->Name, Guid, sizeof(EFI_GUID));\r
+  CopyMem(Hob.Raw + sizeof(EFI_HOB_GUID_TYPE), Buffer, BufferSize);\r
+  Hob.Raw += Length;\r
+\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BuildHobFvDescriptor (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a Firmware Volume HOB\r
+\r
+Arguments:\r
+\r
+  HobStart    - Start pointer of hob list\r
+\r
+  BaseAddress - The base address of the Firmware Volume\r
+\r
+  Length      - The size of the Firmware Volume in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+  \r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);  \r
+\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_FV;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_FIRMWARE_VOLUME);\r
+\r
+  Hob.FirmwareVolume->BaseAddress = BaseAddress;\r
+  Hob.FirmwareVolume->Length      = Length;\r
+\r
+  Hob.FirmwareVolume++;\r
+\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BuildHobCpu (\r
+  IN VOID                        *HobStart,\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the CPU\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  SizeOfMemorySpace         - Identifies the maximum \r
+                              physical memory addressibility of the processor.\r
+\r
+  SizeOfIoSpace             - Identifies the maximum physical I/O addressibility \r
+                              of the processor.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+\r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;\r
+\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_CPU;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_CPU);\r
+\r
+  Hob.Cpu->SizeOfMemorySpace = SizeOfMemorySpace;\r
+  Hob.Cpu->SizeOfIoSpace     = SizeOfIoSpace;\r
+\r
+  Hob.Cpu++;\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+BuildHobStack (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the Stack\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The 64 bit physical address of the Stack\r
+\r
+  Length                    - The length of the stack in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+    \r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;\r
+\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_MEMORY_ALLOCATION;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_STACK);\r
+\r
+  CopyMem(&(Hob.MemoryAllocationStack->AllocDescriptor.Name), &gEfiHobMemeryAllocStackGuid, sizeof(EFI_GUID));\r
+  (Hob.MemoryAllocationStack->AllocDescriptor).MemoryBaseAddress = BaseAddress;\r
+  (Hob.MemoryAllocationStack->AllocDescriptor).MemoryLength      = Length;\r
+  (Hob.MemoryAllocationStack->AllocDescriptor).MemoryType  = EfiConventionalMemory;\r
+\r
+  Hob.MemoryAllocationStack++;\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+BuildHobBspStore (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the bsp store\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The 64 bit physical address of bsp store\r
+\r
+  Length                    - The length of the bsp store in bytes\r
+  \r
+  MemoryType                - Memory type of the bsp store\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+\r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_MEMORY_ALLOCATION;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_BSP_STORE);\r
+\r
+  (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryBaseAddress = BaseAddress;\r
+  (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryLength = Length;\r
+  (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryType = MemoryType;\r
+  CopyMem(&(Hob.MemoryAllocationBspStore->AllocDescriptor).Name, &gEfiHobMemeryAllocBspStoreGuid, sizeof(EFI_GUID));\r
+  Hob.MemoryAllocationBspStore++;\r
+\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+BuildMemoryAllocationHob (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *Name,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for memory allocation\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The base address of memory allocated by this HOB.\r
+\r
+  Length                    - The length in bytes of memory allocated by this HOB.\r
+  \r
+  Name                      - A GUID that defines the memory allocation region¡¯s type and purpose, \r
+                              as well as other fields within the memory allocation HOB.\r
+                              \r
+  MemoryType                - Defines the type of memory allocated by this HOB.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS        Hob;\r
+  EFI_PEI_HOB_POINTERS        HandOffHob;\r
+  \r
+    \r
+  HandOffHob.Raw = HobStart;\r
+  Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;\r
+\r
+  Hob.Header->HobType   = EFI_HOB_TYPE_MEMORY_ALLOCATION;\r
+  Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION);\r
+\r
+  if (Name != NULL) {\r
+    CopyMem(&(Hob.MemoryAllocation->AllocDescriptor.Name), &Name, sizeof(EFI_GUID));\r
+  } else {\r
+    ZeroMem(&Hob.MemoryAllocation->AllocDescriptor.Name, sizeof(EFI_GUID));\r
+  }\r
+\r
+  (Hob.MemoryAllocation->AllocDescriptor).MemoryBaseAddress = BaseAddress;\r
+  (Hob.MemoryAllocation->AllocDescriptor).MemoryLength = Length;\r
+  (Hob.MemoryAllocation->AllocDescriptor).MemoryType = MemoryType;\r
+\r
+  Hob.MemoryAllocation++;\r
+  HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  Hob = BuildHobEndOfHobList(Hob.Raw);\r
+  HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFirstGuidHob (\r
+  IN     VOID      **HobStart,\r
+  IN     EFI_GUID  *Guid,\r
+  OUT    VOID      **Buffer,\r
+  OUT    UINTN     *BufferSize  OPTIONAL\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function searches the first instance of a HOB among the whole HOB list. \r
+\r
+Arguments:\r
+\r
+  HobStart                  - A pointer to the start pointer of hob list.\r
+\r
+  Guid                      - A pointer to the GUID to match with in the HOB list.\r
+\r
+  Buffer                    - A pointer to the pointer to the data for the custom HOB type.\r
+\r
+  BufferSize                - A Pointer to the size in byte of BufferSize.\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  The first instance of the matched GUID HOB among the whole HOB list\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+  \r
+  GuidHob.Raw = *HobStart;\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status); ) {\r
+    \r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+    \r
+    if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {            \r
+      if ( ((INT32 *)Guid)[0] == ((INT32 *)&GuidHob.Guid->Name)[0] &&\r
+           ((INT32 *)Guid)[1] == ((INT32 *)&GuidHob.Guid->Name)[1] &&\r
+           ((INT32 *)Guid)[2] == ((INT32 *)&GuidHob.Guid->Name)[2] &&\r
+           ((INT32 *)Guid)[3] == ((INT32 *)&GuidHob.Guid->Name)[3] ) {\r
+        Status  = EFI_SUCCESS;\r
+        *Buffer = (VOID *)((UINT8 *)(&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        if (BufferSize) {\r
+          *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);\r
+        }\r
+      }\r
+    }\r
+\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf
new file mode 100644 (file)
index 0000000..6efd3ec
--- /dev/null
@@ -0,0 +1,49 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    PeiHobLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the PEI library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME         = PeiHobLib\r
+COMPONENT_TYPE    = LIBRARY\r
+\r
+[sources.common]\r
+  PeiHobLib.c\r
+\r
+[sources.ia32]\r
+\r
+[sources.ipf]\r
+\r
+[libraries.common]\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
new file mode 100644 (file)
index 0000000..f2cfdb8
--- /dev/null
@@ -0,0 +1,1341 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiLib.h\r
+\r
+Abstract:\r
+\r
+  PEI Library Functions\r
\r
+--*/\r
+\r
+#ifndef _PEI_LIB_H_\r
+#define _PEI_LIB_H_\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "peiHobLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (Decompress)\r
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)\r
+#include EFI_GUID_DEFINITION (PeiPeCoffLoader)\r
+#include EFI_PPI_DEFINITION (FindFv)\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+typedef struct {\r
+  UINT32   PeiServiceTable;\r
+} PEI_IDT_TABLE;\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN VOID        *Buffer,\r
+  IN UINTN       Length,\r
+  IN EFI_GUID    *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). \r
+\r
+Arguments:\r
+\r
+  Buffer - Pointer to the target buffer to scan.\r
+  Length - Number of bytes in Buffer to scan.\r
+  Guid   - Value to search for in the target buffer.\r
+  \r
+Returns:\r
+  A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+Arguments:\r
+\r
+  Address   -     The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  Length    -      The number of bytes to invalidate from the instruction cache.\r
+\r
+ Returns:\r
+  Address\r
+\r
+**/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindNextVolume.\r
+\r
+Arguments:\r
+\r
+  Instance     - The Fv Volume Instance.\r
+  VolumeHandle - Pointer to the current Fv Volume to search.\r
+\r
+Returns:\r
+  EFI_STATUS\r
+  \r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          FwVolHeader,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindNextFile.\r
+\r
+Arguments:\r
+\r
+  SearchType   - Filter to find only file of this type.\r
+  FwVolHeader  - Pointer to the current FV to search.\r
+  FileHandle   - Pointer to the file matching SearchType in FwVolHeader.\r
+                - NULL if file not found\r
+\r
+Returns:\r
+  EFI_STATUS\r
+  \r
+--*/  \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindFileByName (\r
+  IN  EFI_GUID              *FileName,\r
+  IN  EFI_PEI_FV_HANDLE     VolumeHandle,\r
+  OUT EFI_PEI_FILE_HANDLE   *FileHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindFileByName.\r
+\r
+Arguments:\r
+\r
+  FileName      - File name to search.\r
+  VolumeHandle  - The current FV to search.\r
+  FileHandle    - Pointer to the file matching name in VolumeHandle.\r
+                - NULL if file not found\r
+\r
+Returns:\r
+   EFI_STATUS\r
+   \r
+--*/  \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_FFS_FILE_HEADER        *FfsFileHeader,\r
+  IN OUT VOID                   **SectionData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindSectionData.\r
+\r
+Arguments:\r
+\r
+  SearchType      - Filter to find only sections of this type.\r
+  FileHandle      - Pointer to the current file to search.\r
+  SectionData     - Pointer to the Section matching SectionType in FfsFileHeader.\r
+                  - NULL if section not found\r
+\r
+Returns:\r
+  EFI_STATUS\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsGetVolumeInfo (\r
+  IN EFI_PEI_FV_HANDLE  *VolumeHandle,\r
+  OUT EFI_FV_INFO       *VolumeInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsGetVolumeInfo.\r
+\r
+Arguments:\r
+\r
+  VolumeHandle    - The handle to Fv Volume.\r
+  VolumeInfo      - The pointer to volume information.\r
+  \r
+Returns:\r
+  EFI_STATUS\r
+--*/  \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN EFI_GUID                   *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function LocatePpi.\r
+\r
+Arguments:\r
+\r
+  Guid          - Pointer to GUID of the PPI.\r
+  Instance      - Instance Number to discover.\r
+  PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r
+                returns a pointer to the descriptor (includes flags, etc)\r
+  Ppi           - Pointer to reference the found PPI\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS   if the PPI is in the database           \r
+            EFI_NOT_FOUND if the PPI is not in the database\r
+--*/  \r
+;\r
+\r
+VOID\r
+EFIAPI\r
+BuildFvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build FvHob.\r
+\r
+Arguments:\r
+\r
+  BaseAddress    - Fv base address.\r
+  Length         - Fv Length.\r
+\r
+Returns:\r
+  NONE.\r
+  \r
+--*/  \r
+;\r
+\r
+VOID\r
+EFIAPI\r
+BuildFvHob2 (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *FvNameGuid,\r
+  IN EFI_GUID                    *FileNameGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build FvHob2.\r
+\r
+Arguments:\r
+\r
+  BaseAddress  - Fv base address.\r
+  Length       - Fv length.\r
+  FvNameGuid   - Fv name.\r
+  FileNameGuid - File name which contians encapsulated Fv.\r
+\r
+Returns:\r
+   NONE.\r
+--*/  \r
+;\r
+\r
+\r
+VOID \r
+EFIAPI\r
+BuildGuidDataHob (\r
+  IN EFI_GUID                   *Guid,\r
+  IN VOID                       *Data,\r
+  IN UINTN                      DataLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build Guid data Hob.\r
+\r
+Arguments:\r
+\r
+  Guid        - guid to build data hob.\r
+  Data        - data to build data hob.\r
+  DataLength  - the length of data.\r
+\r
+Returns:\r
+  NONE\r
+  \r
+--*/  \r
+;\r
+\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate Memory.\r
+\r
+Arguments:\r
+\r
+  Pages - Pages to allocate.\r
+\r
+Returns:\r
+  Address if successful to allocate memory. \r
+  NULL    if fail to allocate memory.\r
+\r
+--*/  \r
+;\r
+\r
+VOID\r
+SetPeiServicesTablePointer (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PeiService pointer so that it can be retrieved anywhere.\r
+\r
+Arguments:\r
+\r
+  PeiServices     - The direct pointer to PeiServiceTable.\r
+  \r
+Returns:\r
+  NONE\r
+  \r
+--*/      \r
+;\r
+\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer (\r
+  VOID \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  NONE.\r
+  \r
+Returns:\r
+  The direct pointer to PeiServiceTable.\r
+  \r
+--*/      \r
+;\r
+\r
+VOID\r
+MigrateIdtTable (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
+  storing PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  PeiServices   - The direct pointer to PeiServiceTable.\r
+  \r
+Returns:\r
+\r
+  NONE.\r
+  \r
+--*/   \r
+;\r
+\r
+\r
+UINTN\r
+ReadIdtBase (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read IDT Register BaseAddress.\r
+\r
+Arguments:\r
+\r
+  NONE\r
+  \r
+Returns:\r
+  IDT Register BaseAddress.\r
+\r
+--*/  \r
+;\r
+\r
+\r
+UINT16\r
+ReadIdtLimit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read IDT Register Limit.\r
+\r
+Arguments:\r
+\r
+  NONE\r
+  \r
+Returns:\r
+  IDT Register Limit.\r
+\r
+--*/  \r
+;\r
+\r
+\r
+VOID\r
+SetIdtBase (\r
+  UINT32  IdtBase,\r
+  UINT16  IdtLimit \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set IDT Register BaseAddress.\r
+\r
+Arguments:\r
+\r
+  IdtBase   - IDT.BaseAddress\r
+  IdtLimit  - IDT.Limit\r
+  \r
+Returns:\r
+  NONE\r
+--*/    \r
+;\r
+\r
+VOID\r
+AsmWriteKr7 (\r
+  UINT64 Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Write 64 bit into Kernel Register7 on IPF.\r
+\r
+Arguments:\r
+\r
+  Address   - Data to write into kr7.\r
+  \r
+Returns:\r
+  NONE\r
+  \r
+--*/    \r
+;\r
+\r
+\r
+UINT64\r
+AsmReadKr7 (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read 64 bit from Kernel Register7 on IPF.\r
+\r
+Arguments:\r
+\r
+  NONE  \r
+  \r
+Returns:\r
+  Data in kr7.\r
+  \r
+--*/    \r
+;\r
+\r
+#endif\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to zero for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  = TRUE  if Guid1 == Guid2\r
+  = FALSE if Guid1 != Guid2 \r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+InstallEfiPeiPeCoffLoader (\r
+  IN EFI_PEI_SERVICES                     **PeiServices,\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL      **This,\r
+  IN EFI_PEI_PPI_DESCRIPTOR               *ThisPpi\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install EFI Pei PE coff loader protocol.\r
+  \r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+  \r
+  This        - Pointer to get Pei PE coff loader protocol as output\r
+  \r
+  ThisPpi     - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+InstallEfiPeiPeCoffLoader64 (\r
+  IN EFI_PEI_SERVICES                          **PeiServices,\r
+  IN OUT  EFI_PEI_PE_COFF_LOADER_PROTOCOL      **This,\r
+  IN EFI_PEI_PPI_DESCRIPTOR                    *ThisPpi\r
+  );\r
+\r
+\r
+\r
+EFI_STATUS\r
+InstallEfiDecompress (\r
+  EFI_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install EFI decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to get decompress protocol as output\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - EFI decompress protocol successfully installed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+InstallTianoDecompress (\r
+  EFI_TIANO_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install Tiano decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to get decompress protocol as output\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Tiano decompress protocol successfully installed.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PeiPerfMeasure (\r
+  EFI_PEI_SERVICES              **PeiServices,\r
+  IN UINT16                     *Token,\r
+  IN EFI_FFS_FILE_HEADER        *FileHeader,\r
+  IN BOOLEAN                    EntryExit,\r
+  IN UINT64                     Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Log a timestamp count.\r
+\r
+Arguments:\r
+\r
+  PeiServices - Pointer to the PEI Core Services table\r
+  \r
+  Token       - Pointer to Token Name\r
+  \r
+  FileHeader  - Pointer to the file header\r
+\r
+  EntryExit   - Indicates start or stop measurement\r
+\r
+  Value       - The start time or the stop time\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get timer value.\r
+\r
+Arguments:\r
+\r
+  TimerValue  - Pointer to the returned timer value\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Successfully got timer value\r
+\r
+--*/\r
+;\r
+\r
+#ifdef EFI_PEI_PERFORMANCE\r
+#define PEI_PERF_START(Ps, Token, FileHeader, Value)  PeiPerfMeasure (Ps, Token, FileHeader, FALSE, Value)\r
+#define PEI_PERF_END(Ps, Token, FileHeader, Value)    PeiPerfMeasure (Ps, Token, FileHeader, TRUE, Value)\r
+#else\r
+#define PEI_PERF_START(Ps, Token, FileHeader, Value)\r
+#define PEI_PERF_END(Ps, Token, FileHeader, Value)\r
+#endif\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+EFI_STATUS\r
+PeCoffLoaderWinNtLoadAsDll (\r
+  IN  CHAR8  *PdbFileName,\r
+  IN  VOID   **ImageEntryPoint,\r
+  OUT VOID   **ModHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Loads the .DLL file is present when a PE/COFF file is loaded.  This provides source level\r
+  debugging for drivers that have cooresponding .DLL files on the local system.\r
+\r
+Arguments:\r
+\r
+  PdbFileName     - The name of the .PDB file.  This was found from the PE/COFF\r
+                    file's debug directory entry.\r
+\r
+  ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded.\r
+\r
+  ModHandle       - Pointer to loaded library.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint\r
+\r
+  EFI_NOT_FOUND   - The .DLL file could not be found\r
+\r
+  EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not\r
+                    determined.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
+//\r
+// hob.c\r
+//\r
+EFI_STATUS\r
+PeiBuildHobModule (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_GUID                    *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS        Module,\r
+  IN UINT64                      ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS        EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for a loaded PE32 module\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+  ModuleName                - The GUID File Name of the module\r
+  Memory                    - The 64 bit physical address of the module\r
+  ModuleLength              - The length of the module in bytes\r
+  EntryPoint                - The 64 bit physical address of the entry point\r
+                              to the module\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobResourceDescriptor (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_RESOURCE_TYPE           ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS        PhysicalStart,\r
+  IN UINT64                      NumberOfBytes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB that describes a chunck of system memory\r
+\r
+Arguments:\r
+\r
+  PeiServices        - The PEI core services table.\r
\r
+  ResourceType       - The type of resource described by this HOB\r
+\r
+  ResourceAttribute  - The resource attributes of the memory described by this HOB\r
+\r
+  PhysicalStart      - The 64 bit physical address of memory described by this HOB\r
+\r
+  NumberOfBytes      - The length of the memoty described by this HOB in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Hob is successfully built.\r
+  Others          - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobGuid (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_GUID                    *Guid,\r
+  IN UINTN                       DataLength,\r
+  IN OUT VOID                    **Hob\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+\r
+  DataLength  - The size of the data payload for the GUIDed HOB\r
+\r
+  Hob         - Pointer to the Hob\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Hob is successfully built.\r
+  Others        - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobGuidData (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_GUID                    *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+\r
+  Data        - The data to be copied into the GUIDed HOB data field.\r
+\r
+  DataLength  - The data field length.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Hob is successfully built.\r
+  Others        - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobFv (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a Firmware Volume HOB\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  BaseAddress - The base address of the Firmware Volume\r
+\r
+  Length      - The size of the Firmware Volume in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Hob is successfully built.\r
+  Others        - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobCpu (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the CPU\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  SizeOfMemorySpace         - Identifies the maximum \r
+                              physical memory addressibility of the processor.\r
+\r
+  SizeOfIoSpace             - Identifies the maximum physical I/O addressibility \r
+                              of the processor.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobStack (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the Stack\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the Stack\r
+\r
+  Length                    - The length of the stack in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobBspStore (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the bsp store\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the bsp store\r
+\r
+  Length                    - The length of the bsp store in bytes\r
+\r
+  MemoryType                - Memory type\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiBuildHobMemoryAllocation (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *Name,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the memory allocation\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the memory\r
+\r
+  Length                    - The length of the memory allocation in bytes\r
+\r
+  Name                      - Name for Hob\r
+\r
+  MemoryType                - Memory type\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// print.c\r
+//\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8       *StartOfBuffer,\r
+  IN  UINTN       StrSize,\r
+  IN  CONST CHAR8 *Format,\r
+  IN  VA_LIST     Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.\r
+\r
+  StrSize       - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Ascii format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8       *Buffer,\r
+  IN UINTN        BufferSize,\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  ASPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Ascii buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// math.c\r
+//\r
+UINT64\r
+MultU64x32 (\r
+  IN  UINT64  Multiplicand,\r
+  IN  UINTN   Multiplier\r
+  )\r
+/*++  \r
+  \r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+;\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN  UINT64  Dividend,\r
+  IN  UINTN   Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+  N.B. only works for 31bit divisors!!\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
\r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN  UINT64  Operand,\r
+  IN  UINTN   Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+;\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN  UINT64  Operand,\r
+  IN  UINTN   Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
+\r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+RegisterNativeCpuIo (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN VOID                     *CpuIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register a native Cpu IO\r
+\r
+Arguments:\r
+\r
+  PeiServices - Calling context\r
+  CpuIo       - CpuIo instance to register\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+GetNativeCpuIo (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  OUT VOID                    **CpuIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get registered Cpu IO.\r
+\r
+Arguments:\r
+\r
+  PeiServices - Calling context\r
+  CpuIo       - CpuIo instance registered before\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FindFv (\r
+  IN     EFI_FIND_FV_PPI             *This,\r
+  IN     EFI_PEI_SERVICES            **PeiServices,\r
+  IN OUT UINT8                       *FvNumber,\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER  **FVAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Search Fv in Hob.\r
+\r
+Arguments:\r
+  \r
+  This        - Interface pointer that implement the Find Fv PPI\r
+  \r
+  PeiServices - Pointer to the PEI Service Table\r
+  \r
+  FvNumber    - On input,  the number of the fireware volume which supports FFS to locate\r
+                On output, the next FV number which supports FFS.\r
+  \r
+  FVAddress   - The address of the volume which supports FFS to discover\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - An addtional FV which supports FFS found\r
+  EFI_OUT_OF_RESOURCES  - There are no fireware volume which supports FFS for given fvnumber\r
+  EFI_INVALID_PARAMETER - FvAddress is NULL\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h
new file mode 100644 (file)
index 0000000..2310175
--- /dev/null
@@ -0,0 +1,345 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiHobLib.h\r
+\r
+Abstract:\r
+\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PEI_HOB_LIB_H_\r
+#define _EFI_PEI_HOB_LIB_H_\r
+\r
+#include "PeiApi.h" // EFI_PEI_SERVICES definition\r
+#define EFI_STACK_SIZE      0x20000\r
+#define EFI_BSP_STORE_SIZE  0x4000\r
+\r
+EFI_STATUS\r
+BuildHobHandoffInfoTable (\r
+  IN  VOID                    *HobStart,\r
+  IN  UINT16                  Version,\r
+  IN  EFI_BOOT_MODE           BootMode,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiMemoryTop,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiMemoryBottom,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryTop,\r
+  IN  EFI_PHYSICAL_ADDRESS    EfiFreeMemoryBottom\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HandoffInformationTable Information Table HOB\r
+\r
+Arguments:\r
+\r
+  HobStart      - Start pointer of hob list\r
+  Version       - The version number pertaining to the PHIT HOB definition.\r
+  BootMode      - The system boot mode as determined during the HOB producer phase.\r
+  EfiMemoryTop  - The highest address location of memory that is allocated for use by the HOB\r
+                  producer phase.\r
+  EfiMemoryBottom   - The lowest address location of memory that is allocated for use by the HOB\r
+                      producer phase.\r
+  EfiFreeMemoryTop  - The highest address location of free memory that is currently available for use\r
+                      by the HOB producer phase.\r
+  EfiFreeMemoryBottom   - The lowest address location of free memory that is available for \r
+                          use by the HOB producer phase.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobModule (\r
+  IN VOID                   *HobStart,\r
+  IN EFI_GUID               *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   Module,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for a loaded PE32 module\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  ModuleName                - The GUID File Name of the HON from the Firmware Volume\r
+\r
+  Module                    - The 64 bit physical address of the module\r
+\r
+  ModuleLength              - The length of the module in bytes\r
+\r
+  EntryPoint                - The 64 bit physical address of the entry point to the module\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobResourceDescriptor (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_RESOURCE_TYPE           ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS        PhysicalStart,\r
+  IN UINT64                      NumberOfBytes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB that describes a chunck of system memory\r
+\r
+Arguments:\r
+\r
+  HobStart          - Start pointer of hob list\r
+\r
+  ResourceType      - The type of memory described by this HOB\r
+\r
+  ResourceAttribute - The memory attributes of the memory described by this HOB\r
+\r
+  PhysicalStart     - The 64 bit physical address of memory described by this HOB\r
+\r
+  NumberOfBytes     - The length of the memoty described by this HOB in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobGuidType (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_GUID                    *Guid,\r
+  IN VOID                        *Buffer,\r
+  IN UINTN                       BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  HobStart    - Start pointer of hob list\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+\r
+  Buffer      - A pointer to the data for the custom HOB type\r
+\r
+  BufferSize  - The size in byte of BufferSize\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobFvDescriptor (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a Firmware Volume HOB\r
+\r
+Arguments:\r
+\r
+  HobStart    - Start pointer of hob list\r
+\r
+  BaseAddress - The base address of the Firmware Volume\r
+\r
+  Length      - The size of the Firmware Volume in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobCpu (\r
+  IN VOID                        *HobStart,\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the CPU\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  SizeOfMemorySpace         - Identifies the maximum \r
+                              physical memory addressibility of the processor.\r
+\r
+  SizeOfIoSpace             - Identifies the maximum physical I/O addressibility \r
+                              of the processor.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobStack (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the Stack\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The 64 bit physical address of the Stack\r
+\r
+  Length                    - The length of the stack in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildHobBspStore (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the bsp store\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The 64 bit physical address of bsp store\r
+\r
+  Length                    - The length of the bsp store in bytes\r
+  \r
+  MemoryType                - Memory type of the bsp store\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BuildMemoryAllocationHob (\r
+  IN VOID                        *HobStart,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *Name,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for memory allocation\r
+\r
+Arguments:\r
+\r
+  HobStart                  - Start pointer of hob list\r
+\r
+  BaseAddress               - The base address of memory allocated by this HOB.\r
+\r
+  Length                    - The length in bytes of memory allocated by this HOB.\r
+\r
+  Name                      - A GUID that defines the memory allocation region¡¯s type and purpose, \r
+                              as well as other fields within the memory allocation HOB.\r
+\r
+  MemoryType                - Defines the type of memory allocated by this HOB.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+  EFI_NOT_AVAILABLE_YET\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetFirstGuidHob (\r
+  IN     VOID      **HobStart,\r
+  IN     EFI_GUID  *Guid,\r
+  OUT    VOID      **Buffer,\r
+  OUT    UINTN     *BufferSize  OPTIONAL\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function searches the first instance of a HOB among the whole HOB list. \r
+\r
+Arguments:\r
+\r
+  HobStart                  - A pointer to the start pointer of hob list.\r
+\r
+  Guid                      - A pointer to the GUID to match with in the HOB list.\r
+\r
+  Buffer                    - A pointer to the pointer to the data for the custom HOB type.\r
+\r
+  BufferSize                - A Pointer to the size in byte of BufferSize.\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  The first instance of the matched GUID HOB among the whole HOB list\r
+\r
+--*/\r
+;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c
new file mode 100644 (file)
index 0000000..c5a8b91
--- /dev/null
@@ -0,0 +1,131 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Debug.c\r
+\r
+Abstract:\r
+\r
+  Support for Debug primatives. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "EfiPrintLib.h"\r
+#include "EfiStatusCode.h"\r
+#include "EfiCommonLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+VOID\r
+PeiDebugAssert (\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices,\r
+  IN CHAR8              *FileName,\r
+  IN INTN               LineNumber,\r
+  IN CHAR8              *Description\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded DEADLOOP ().\r
+  \r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  FileName    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT().\r
+\r
+  Description - Description, usually the assertion,\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+\r
+  EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);\r
+\r
+  //\r
+  // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable,\r
+  // we want get enough information if assert.\r
+  //\r
+  (**PeiServices).PeiReportStatusCode (\r
+                    (EFI_PEI_SERVICES**)PeiServices,\r
+                    (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
+                    (EFI_SOFTWARE_PEI_MODULE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
+                    0,\r
+                    &gEfiCallerIdGuid,\r
+                    (EFI_STATUS_CODE_DATA *) Buffer\r
+                    );\r
+\r
+  EFI_DEADLOOP ();\r
+}\r
+\r
+\r
+VOID\r
+PeiDebugPrint (\r
+  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+  IN  UINTN             ErrorLevel,\r
+  IN  CHAR8             *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+  \r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  ...        - Print arguments\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  VA_LIST Marker;\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+\r
+  VA_START (Marker, Format);\r
+  EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);\r
+\r
+  //\r
+  // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable,\r
+  // we want get enough information if assert.\r
+  //\r
+  (**PeiServices).PeiReportStatusCode (\r
+                    (EFI_PEI_SERVICES**)PeiServices,\r
+                    EFI_DEBUG_CODE,\r
+                    (EFI_SOFTWARE_PEI_MODULE | EFI_DC_UNSPECIFIED),\r
+                    0,\r
+                    &gEfiCallerIdGuid,\r
+                    (EFI_STATUS_CODE_DATA *) Buffer\r
+                    );\r
+\r
+  return ;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
new file mode 100644 (file)
index 0000000..43446a3
--- /dev/null
@@ -0,0 +1,1104 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.c\r
+\r
+Abstract:\r
+\r
+  Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
+  \r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include EFI_PROTOCOL_DEFINITION (Decompress)\r
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetInfo (\r
+  IN      EFI_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  OUT     UINT32                  *DstSize,\r
+  OUT     UINT32                  *ScratchSize\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiDecompress (\r
+  IN      EFI_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  IN OUT  VOID                    *Destination,\r
+  IN      UINT32                  DstSize,\r
+  IN OUT  VOID                    *Scratch,\r
+  IN      UINT32                  ScratchSize\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoGetInfo (\r
+  IN      EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  OUT     UINT32                        *DstSize,\r
+  OUT     UINT32                        *ScratchSize\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoDecompress (\r
+  IN      EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  IN OUT  VOID                          *Destination,\r
+  IN      UINT32                        DstSize,\r
+  IN OUT  VOID                          *Scratch,\r
+  IN      UINT32                        ScratchSize\r
+  );\r
+\r
+//\r
+// The protocol instance\r
+//\r
+\r
+EFI_DECOMPRESS_PROTOCOL       mEfiDecompress = {\r
+  EfiGetInfo,\r
+  EfiDecompress\r
+};\r
+\r
+EFI_TIANO_DECOMPRESS_PROTOCOL mTianoDecompress = {\r
+  TianoGetInfo,\r
+  TianoDecompress\r
+};\r
+\r
+EFI_STATUS\r
+InstallEfiDecompress (\r
+  IN OUT  EFI_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install EFI decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to get decompress protocol as output\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - EFI decompress protocol successfully installed.\r
+\r
+--*/\r
+{\r
+  *This = &mEfiDecompress;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InstallTianoDecompress (\r
+  EFI_TIANO_DECOMPRESS_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install Tiano decompress protocol.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to get decompress protocol as output\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Tiano decompress protocol successfully installed.\r
+\r
+--*/\r
+{\r
+  *This = &mTianoDecompress;\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// Decompression algorithm begins here\r
+//\r
+#define BITBUFSIZ 32\r
+#define MAXMATCH  256\r
+#define THRESHOLD 3\r
+#define CODE_BIT  16\r
+#define UINT8_MAX 0xff\r
+#define BAD_TABLE - 1\r
+\r
+//\r
+// C: Char&Len Set; P: Position Set; T: exTra Set\r
+//\r
+#define NC      (0xff + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT    9\r
+#define MAXPBIT 5\r
+#define TBIT    5\r
+#define MAXNP   ((1U << MAXPBIT) - 1)\r
+#define NT      (CODE_BIT + 3)\r
+#if NT > MAXNP\r
+#define NPT NT\r
+#else\r
+#define NPT MAXNP\r
+#endif\r
+\r
+typedef struct {\r
+  UINT8   *mSrcBase;  // Starting address of compressed data\r
+  UINT8   *mDstBase;  // Starting address of decompressed data\r
+  UINT32  mOutBuf;\r
+  UINT32  mInBuf;\r
+\r
+  UINT16  mBitCount;\r
+  UINT32  mBitBuf;\r
+  UINT32  mSubBitBuf;\r
+  UINT16  mBlockSize;\r
+  UINT32  mCompSize;\r
+  UINT32  mOrigSize;\r
+\r
+  UINT16  mBadTableFlag;\r
+\r
+  UINT16  mLeft[2 * NC - 1];\r
+  UINT16  mRight[2 * NC - 1];\r
+  UINT8   mCLen[NC];\r
+  UINT8   mPTLen[NPT];\r
+  UINT16  mCTable[4096];\r
+  UINT16  mPTTable[256];\r
+\r
+  //\r
+  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  // For EFI 1.1 de/compression algorithm, mPBit = 4\r
+  // For Tiano de/compression algorithm, mPBit = 5\r
+  //\r
+  UINT8   mPBit;\r
+} SCRATCH_DATA;\r
+\r
+STATIC\r
+VOID\r
+FillBuf (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfBits  - The number of bits to shift and read.\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
+\r
+  while (NumOfBits > Sd->mBitCount) {\r
+\r
+    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
+\r
+    if (Sd->mCompSize > 0) {\r
+      //\r
+      // Get 1 byte into SubBitBuf\r
+      //\r
+      Sd->mCompSize--;\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
+      Sd->mBitCount   = 8;\r
+\r
+    } else {\r
+      //\r
+      // No more bits from the source, just pad zero bit.\r
+      //\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mBitCount   = 8;\r
+\r
+    }\r
+  }\r
+\r
+  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
+  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+GetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  popped out.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data.\r
+  NumOfBits     - The number of bits to pop and read.\r
+\r
+Returns:\r
+\r
+  The bits that are popped out.\r
+\r
+--*/\r
+{\r
+  UINT32  OutBits;\r
+\r
+  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
+\r
+  FillBuf (Sd, NumOfBits);\r
+\r
+  return OutBits;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+MakeTable (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfChar,\r
+  IN  UINT8         *BitLen,\r
+  IN  UINT16        TableBits,\r
+  OUT UINT16        *Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Creates Huffman Code mapping table according to code length array.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfChar - Number of symbols in the symbol set\r
+  BitLen    - Code length array\r
+  TableBits - The width of the mapping table\r
+  Table     - The table\r
+  \r
+Returns:\r
+  \r
+  0         - OK.\r
+  BAD_TABLE - The table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Count[17];\r
+  UINT16  Weight[17];\r
+  UINT16  Start[18];\r
+  UINT16  *Pointer;\r
+  UINT16  Index3;\r
+  UINT16  Index;\r
+  UINT16  Len;\r
+  UINT16  Char;\r
+  UINT16  JuBits;\r
+  UINT16  Avail;\r
+  UINT16  NextCode;\r
+  UINT16  Mask;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Count[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NumOfChar; Index++) {\r
+    Count[BitLen[Index]]++;\r
+  }\r
+\r
+  Start[1] = 0;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));\r
+  }\r
+\r
+  if (Start[17] != 0) {\r
+    /*(1U << 16)*/\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
+  JuBits = (UINT16) (16 - TableBits);\r
+\r
+  for (Index = 1; Index <= TableBits; Index++) {\r
+    Start[Index] >>= JuBits;\r
+    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
+  }\r
+\r
+  while (Index <= 16) {\r
+    Weight[Index++] = (UINT16) (1U << (16 - Index));\r
+  }\r
+\r
+  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
+\r
+  if (Index != 0) {\r
+    Index3 = (UINT16) (1U << TableBits);\r
+    while (Index != Index3) {\r
+      Table[Index++] = 0;\r
+    }\r
+  }\r
+\r
+  Avail = NumOfChar;\r
+  Mask  = (UINT16) (1U << (15 - TableBits));\r
+\r
+  for (Char = 0; Char < NumOfChar; Char++) {\r
+\r
+    Len = BitLen[Char];\r
+    if (Len == 0) {\r
+      continue;\r
+    }\r
+\r
+    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
+\r
+    if (Len <= TableBits) {\r
+\r
+      for (Index = Start[Len]; Index < NextCode; Index++) {\r
+        Table[Index] = Char;\r
+      }\r
+\r
+    } else {\r
+\r
+      Index3  = Start[Len];\r
+      Pointer = &Table[Index3 >> JuBits];\r
+      Index   = (UINT16) (Len - TableBits);\r
+\r
+      while (Index != 0) {\r
+        if (*Pointer == 0) {\r
+          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
+          *Pointer = Avail++;\r
+        }\r
+\r
+        if (Index3 & Mask) {\r
+          Pointer = &Sd->mRight[*Pointer];\r
+        } else {\r
+          Pointer = &Sd->mLeft[*Pointer];\r
+        }\r
+\r
+        Index3 <<= 1;\r
+        Index--;\r
+      }\r
+\r
+      *Pointer = Char;\r
+\r
+    }\r
+\r
+    Start[Len] = NextCode;\r
+  }\r
+  //\r
+  // Succeeds\r
+  //\r
+  return 0;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+DecodeP (\r
+  IN  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decodes a position value.\r
+\r
+Arguments:\r
+\r
+  Sd      - the global scratch data\r
+\r
+Returns:\r
+\r
+  The position value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Val;\r
+  UINT32  Mask;\r
+  UINT32  Pos;\r
+\r
+  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+\r
+  if (Val >= MAXNP) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+    do {\r
+\r
+      if (Sd->mBitBuf & Mask) {\r
+        Val = Sd->mRight[Val];\r
+      } else {\r
+        Val = Sd->mLeft[Val];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Val >= MAXNP);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mPTLen[Val]);\r
+\r
+  Pos = Val;\r
+  if (Val > 1) {\r
+    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
+  }\r
+\r
+  return Pos;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+ReadPTLen (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        nn,\r
+  IN  UINT16        nbit,\r
+  IN  UINT16        Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for the Extra Set or the Position Set\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  nn        - Number of symbols\r
+  nbit      - Number of bits needed to represent nn\r
+  Special   - The special symbol that needs to be taken care of \r
+\r
+Returns:\r
+\r
+  0         - OK.\r
+  BAD_TABLE - Table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, nbit);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, nbit);\r
+\r
+    for (Index = 0; Index < 256; Index++) {\r
+      Sd->mPTTable[Index] = CharC;\r
+    }\r
+\r
+    for (Index = 0; Index < nn; Index++) {\r
+      Sd->mPTLen[Index] = 0;\r
+    }\r
+\r
+    return 0;\r
+  }\r
+\r
+  Index = 0;\r
+\r
+  while (Index < Number) {\r
+\r
+    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
+\r
+    if (CharC == 7) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
+      while (Mask & Sd->mBitBuf) {\r
+        Mask >>= 1;\r
+        CharC += 1;\r
+      }\r
+    }\r
+\r
+    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
+\r
+    Sd->mPTLen[Index++] = (UINT8) CharC;\r
+\r
+    if (Index == Special) {\r
+      CharC = (UINT16) GetBits (Sd, 2);\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mPTLen[Index++] = 0;\r
+      }\r
+    }\r
+  }\r
+\r
+  while (Index < nn) {\r
+    Sd->mPTLen[Index++] = 0;\r
+  }\r
+\r
+  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
+}\r
+\r
+STATIC\r
+VOID\r
+ReadCLen (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for Char&Len Set.\r
+\r
+Arguments:\r
+\r
+  Sd    - the global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, CBIT);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, CBIT);\r
+\r
+    for (Index = 0; Index < NC; Index++) {\r
+      Sd->mCLen[Index] = 0;\r
+    }\r
+\r
+    for (Index = 0; Index < 4096; Index++) {\r
+      Sd->mCTable[Index] = CharC;\r
+    }\r
+\r
+    return ;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+\r
+    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+    if (CharC >= NT) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+      do {\r
+\r
+        if (Mask & Sd->mBitBuf) {\r
+          CharC = Sd->mRight[CharC];\r
+        } else {\r
+          CharC = Sd->mLeft[CharC];\r
+        }\r
+\r
+        Mask >>= 1;\r
+\r
+      } while (CharC >= NT);\r
+    }\r
+    //\r
+    // Advance what we have read\r
+    //\r
+    FillBuf (Sd, Sd->mPTLen[CharC]);\r
+\r
+    if (CharC <= 2) {\r
+\r
+      if (CharC == 0) {\r
+        CharC = 1;\r
+      } else if (CharC == 1) {\r
+        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
+      } else if (CharC == 2) {\r
+        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
+      }\r
+\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mCLen[Index++] = 0;\r
+      }\r
+\r
+    } else {\r
+\r
+      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
+\r
+    }\r
+  }\r
+\r
+  while (Index < NC) {\r
+    Sd->mCLen[Index++] = 0;\r
+  }\r
+\r
+  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+DecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode a character/length value.\r
+\r
+Arguments:\r
+\r
+  Sd    - The global scratch data.\r
+\r
+Returns:\r
+\r
+  The value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Index2;\r
+  UINT32  Mask;\r
+\r
+  if (Sd->mBlockSize == 0) {\r
+    //\r
+    // Starting a new block\r
+    //\r
+    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+\r
+    ReadCLen (Sd);\r
+\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  Sd->mBlockSize--;\r
+  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
+\r
+  if (Index2 >= NC) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
+\r
+    do {\r
+      if (Sd->mBitBuf & Mask) {\r
+        Index2 = Sd->mRight[Index2];\r
+      } else {\r
+        Index2 = Sd->mLeft[Index2];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Index2 >= NC);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mCLen[Index2]);\r
+\r
+  return Index2;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Decode (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+ --*/\r
+{\r
+  UINT16  BytesRemain;\r
+  UINT32  DataIdx;\r
+  UINT16  CharC;\r
+\r
+  BytesRemain = (UINT16) (-1);\r
+\r
+  DataIdx     = 0;\r
+\r
+  for (;;) {\r
+    CharC = DecodeC (Sd);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return ;\r
+    }\r
+\r
+    if (CharC < 256) {\r
+      //\r
+      // Process an Original character\r
+      //\r
+      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+        return ;\r
+      } else {\r
+        Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
+      }\r
+\r
+    } else {\r
+      //\r
+      // Process a Pointer\r
+      //\r
+      CharC       = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
+\r
+      BytesRemain = CharC;\r
+\r
+      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
+\r
+      BytesRemain--;\r
+      while ((INT16) (BytesRemain) >= 0) {\r
+        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
+        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+          return ;\r
+        }\r
+\r
+        BytesRemain--;\r
+      }\r
+    }\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+EFI_STATUS\r
+GetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT8 *Src;\r
+\r
+  *ScratchSize  = sizeof (SCRATCH_DATA);\r
+\r
+  Src           = Source;\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Decompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize,\r
+  IN      UINT8   Version\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+  Version     - The version of de/compression algorithm.\r
+                Version 1 for EFI 1.1 de/compression algorithm.\r
+                Version 2 for Tiano de/compression algorithm.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT32        Index;\r
+  UINT32        CompSize;\r
+  UINT32        OrigSize;\r
+  EFI_STATUS    Status;\r
+  SCRATCH_DATA  *Sd;\r
+  UINT8         *Src;\r
+  UINT8         *Dst;\r
+\r
+  Status  = EFI_SUCCESS;\r
+  Src     = Source;\r
+  Dst     = Destination;\r
+\r
+  if (ScratchSize < sizeof (SCRATCH_DATA)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sd = (SCRATCH_DATA *) Scratch;\r
+\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
+  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+\r
+  //\r
+  // If compressed file size is 0, return\r
+  //\r
+  if (OrigSize == 0) {\r
+    return Status;\r
+  }\r
+\r
+  if (SrcSize < CompSize + 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (DstSize != OrigSize) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Src = Src + 8;\r
+\r
+  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
+    ((UINT8 *) Sd)[Index] = 0;\r
+  }\r
+  //\r
+  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4\r
+  // For Tiano de/compression algorithm(Version 2), mPBit = 5\r
+  //\r
+  switch (Version) {\r
+  case 1:\r
+    Sd->mPBit = 4;\r
+    break;\r
+\r
+  case 2:\r
+    Sd->mPBit = 5;\r
+    break;\r
+\r
+  default:\r
+    //\r
+    // Currently, only have 2 versions\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sd->mSrcBase  = Src;\r
+  Sd->mDstBase  = Dst;\r
+  Sd->mCompSize = CompSize;\r
+  Sd->mOrigSize = OrigSize;\r
+\r
+  //\r
+  // Fill the first BITBUFSIZ bits\r
+  //\r
+  FillBuf (Sd, BITBUFSIZ);\r
+\r
+  //\r
+  // Decompress it\r
+  //\r
+  Decode (Sd);\r
+\r
+  if (Sd->mBadTableFlag != 0) {\r
+    //\r
+    // Something wrong with the source\r
+    //\r
+    Status = EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetInfo (\r
+  IN      EFI_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  OUT     UINT32                  *DstSize,\r
+  OUT     UINT32                  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  return GetInfo (\r
+          Source,\r
+          SrcSize,\r
+          DstSize,\r
+          ScratchSize\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiDecompress (\r
+  IN      EFI_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  IN OUT  VOID                    *Destination,\r
+  IN      UINT32                  DstSize,\r
+  IN OUT  VOID                    *Scratch,\r
+  IN      UINT32                  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  //\r
+  // For EFI 1.1 de/compression algorithm, the version is 1.\r
+  //\r
+  return Decompress (\r
+          Source,\r
+          SrcSize,\r
+          Destination,\r
+          DstSize,\r
+          Scratch,\r
+          ScratchSize,\r
+          1\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoGetInfo (\r
+  IN      EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  OUT     UINT32                        *DstSize,\r
+  OUT     UINT32                        *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  return GetInfo (\r
+          Source,\r
+          SrcSize,\r
+          DstSize,\r
+          ScratchSize\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoDecompress (\r
+  IN      EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  IN OUT  VOID                          *Destination,\r
+  IN      UINT32                        DstSize,\r
+  IN OUT  VOID                          *Scratch,\r
+  IN      UINT32                        ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  //\r
+  // For Tiano de/compression algorithm, the version is 2.\r
+  //\r
+  return Decompress (\r
+          Source,\r
+          SrcSize,\r
+          Destination,\r
+          DstSize,\r
+          Scratch,\r
+          ScratchSize,\r
+          2\r
+          );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c
new file mode 100644 (file)
index 0000000..fcff7a6
--- /dev/null
@@ -0,0 +1,179 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+  \r
+    FindFv.c\r
+   \r
+Abstract:\r
+\r
+  Library function to find fv by hob.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+#include "PeiHobLib.h"\r
+#include "EfiCommonLib.h"\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
+\r
+static\r
+VOID *\r
+GetHob (\r
+  IN UINT16  Type,\r
+  IN VOID    *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the first instance of a HOB type in a HOB list.\r
+  \r
+Arguments:\r
+\r
+  Type          The HOB type to return.\r
+  HobStart      The first HOB in the HOB list.\r
+    \r
+Returns:\r
+\r
+  HobStart      There were no HOBs found with the requested type.\r
+  else          Returns the first HOB with the matching type.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (HobStart == NULL) {\r
+    return HobStart;\r
+  }\r
+\r
+  //\r
+  // Parse the HOB list, stop if end of list or matching type found.\r
+  //\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+\r
+    if (Hob.Header->HobType == Type) {\r
+      break;\r
+    }\r
+\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+  \r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (END_OF_HOB_LIST (Hob)) {\r
+    return HobStart;\r
+  }\r
+\r
+  return (VOID *) (Hob.Raw);\r
+}\r
+\r
+EFI_STATUS\r
+FindFv (\r
+  IN     EFI_FIND_FV_PPI             *This,\r
+  IN     EFI_PEI_SERVICES            **PeiServices,\r
+  IN OUT UINT8                       *FvNumber,\r
+  IN OUT EFI_FIRMWARE_VOLUME_HEADER  **FvAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Search Fv which supports FFS.\r
+\r
+Arguments:\r
+  \r
+  This        - Interface pointer that implement the Find Fv PPI\r
+  \r
+  PeiServices - Pointer to the PEI Service Table\r
+  \r
+  FvNumber    - On input,  the number of the fireware volume which supports FFS to locate\r
+                On output, the next FV number which supports FFS.\r
+  \r
+  FVAddress   - The address of the volume which supports FFS to discover\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - An addtional FV which supports FFS found\r
+  EFI_OUT_OF_RESOURCES  - There are no fireware volume which supports FFS for given fvnumber\r
+  EFI_INVALID_PARAMETER - FvAddress is NULL\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PEI_HOB_POINTERS    HobStart;\r
+  EFI_PEI_HOB_POINTERS    Hob;\r
+  EFI_HOB_FIRMWARE_VOLUME *FvHob;\r
+  UINT8                   FvIndex;\r
+\r
+  if (FvAddress == NULL){\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Hob.Raw = NULL;\r
+  FvIndex = 0;\r
+\r
+  //\r
+  // Get the Hob table pointer\r
+  //\r
+  Status = (*PeiServices)->GetHobList (\r
+                            PeiServices,\r
+                            &HobStart.Raw\r
+                            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  //\r
+  // Loop to search the wanted FirmwareVolume which supports FFS\r
+  //\r
+  //\r
+  while (FvIndex <= *FvNumber) {\r
+    \r
+    Hob.Raw = GetHob (EFI_HOB_TYPE_FV, HobStart.Raw); \r
+    \r
+    //\r
+    //  If the Hob is not EFI_HOB_TYPE_FV, it indicates that\r
+    //  we have finished all FV volumes search, and there is no\r
+    //  the FFS FV specified by FvNumber.\r
+    //\r
+    if (Hob.Header->HobType != EFI_HOB_TYPE_FV) {\r
+      *FvNumber = 0;\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  \r
+    HobStart.Raw = Hob.Raw + Hob.Header->HobLength;\r
+    FvHob        = Hob.FirmwareVolume;\r
+    *FvAddress  = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvHob->BaseAddress);\r
+    //\r
+    // Check if the FV supports FFS\r
+    //\r
+    if (EfiCompareGuid (&((*FvAddress)->FileSystemGuid), &gEfiFirmwareFileSystemGuid)) {\r
+      FvIndex++;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Return the next FV number which supports FFS.\r
+  //\r
+  (*FvNumber)++;\r
+  \r
+  return EFI_SUCCESS;\r
+\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c
new file mode 100644 (file)
index 0000000..eb1ae2d
--- /dev/null
@@ -0,0 +1,521 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  hob.c\r
+\r
+Abstract:\r
+\r
+  PEI Library Functions\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "peilib.h"\r
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobModule (\r
+  IN EFI_PEI_SERVICES       **PeiServices,\r
+  IN EFI_GUID               *ModuleName,\r
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
+  IN UINT64                 ModuleLength,\r
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for a loaded PE32 module\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+  ModuleName                - The GUID File Name of the module\r
+  MemoryAllocationModule    - The 64 bit physical address of the module\r
+  ModuleLength              - The length of the module in bytes\r
+  EntryPoint                - The 64 bit physical address of the entry point\r
+                              to the module\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;  \r
+  EFI_HOB_MEMORY_ALLOCATION_MODULE  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_MEMORY_ALLOCATION,\r
+                             sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Hob->MemoryAllocationHeader.Name = gEfiHobMemeryAllocModuleGuid;\r
+  Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
+  Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;\r
+  Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;\r
+  (*PeiServices)->SetMem (\r
+                    Hob->MemoryAllocationHeader.Reserved, \r
+                    sizeof (Hob->MemoryAllocationHeader.Reserved),\r
+                    0\r
+                    );\r
+\r
+  Hob->ModuleName = *ModuleName;\r
+  Hob->EntryPoint = EntryPoint;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobResourceDescriptor (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_RESOURCE_TYPE            ResourceType,\r
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
+  IN UINT64                       NumberOfBytes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB that describes a chunck of system memory\r
+\r
+Arguments:\r
+\r
+  PeiServices        - The PEI core services table.\r
\r
+  ResourceType       - The type of resource described by this HOB\r
+\r
+  ResourceAttribute  - The resource attributes of the memory described by this HOB\r
+\r
+  PhysicalStart      - The 64 bit physical address of memory described by this HOB\r
+\r
+  NumberOfBytes      - The length of the memoty described by this HOB in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Hob is successfully built.\r
+  Others          - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                   Status; \r
+  EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,\r
+                             sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Hob->ResourceType      = ResourceType;\r
+  Hob->ResourceAttribute = ResourceAttribute;\r
+  Hob->PhysicalStart     = PhysicalStart;\r
+  Hob->ResourceLength    = NumberOfBytes;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobGuid (\r
+  IN  EFI_PEI_SERVICES  **PeiServices,\r
+  IN  EFI_GUID          *Guid,\r
+  IN  UINTN             DataLength,\r
+  OUT VOID              **Hob\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+  Guid        - The GUID of the custome HOB type\r
+  DataLength  - The size of the data payload for the GUIDed HOB\r
+  Hob         - Pointer to pointer to the created Hob\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Hob is successfully built.\r
+  Others      - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS         Status;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_GUID_EXTENSION,\r
+                             (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength),\r
+                             Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  ((EFI_HOB_GUID_TYPE *)(*Hob))->Name = *Guid;\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobGuidData (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_GUID                    *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a custom HOB that is tagged with a GUID for identification\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  Guid        - The GUID of the custome HOB type\r
+\r
+  Data        - The data to be copied into the GUIDed HOB data field.\r
+\r
+  DataLength  - The data field length.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Hob is successfully built.\r
+  Others        - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS         Status;\r
+  \r
+  EFI_HOB_GUID_TYPE  *Hob;\r
+\r
+  Status = PeiBuildHobGuid (\r
+             PeiServices,\r
+             Guid,\r
+             DataLength,\r
+             &Hob\r
+             );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  } \r
+\r
+  Hob++;\r
+  (*PeiServices)->CopyMem (Hob, Data, DataLength);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobFv (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a Firmware Volume HOB\r
+\r
+Arguments:\r
+\r
+  PeiServices - The PEI core services table.\r
+\r
+  BaseAddress - The base address of the Firmware Volume\r
+\r
+  Length      - The size of the Firmware Volume in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Hob is successfully built.\r
+  Others        - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS               Status;  \r
+  EFI_HOB_FIRMWARE_VOLUME  *Hob;\r
+  \r
+  //\r
+  // Check FV Signature\r
+  //\r
+  PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r
+  \r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_FV,\r
+                             sizeof (EFI_HOB_FIRMWARE_VOLUME),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Hob->BaseAddress = BaseAddress;\r
+  Hob->Length      = Length;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobCpu (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN UINT8                       SizeOfMemorySpace,\r
+  IN UINT8                       SizeOfIoSpace\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the CPU\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  SizeOfMemorySpace         - Identifies the maximum \r
+                              physical memory addressibility of the processor.\r
+\r
+  SizeOfIoSpace             - Identifies the maximum physical I/O addressibility \r
+                              of the processor.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS   Status;  \r
+  EFI_HOB_CPU  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_CPU,\r
+                             sizeof (EFI_HOB_CPU),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
+  Hob->SizeOfIoSpace     = SizeOfIoSpace;\r
+  (*PeiServices)->SetMem (\r
+                    Hob->Reserved, \r
+                    sizeof (Hob->Reserved), \r
+                    0\r
+                    );\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobStack (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the Stack\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the Stack\r
+\r
+  Length                    - The length of the stack in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                       Status;  \r
+  EFI_HOB_MEMORY_ALLOCATION_STACK  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_MEMORY_ALLOCATION,\r
+                             sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
\r
+  Hob->AllocDescriptor.Name = gEfiHobMemeryAllocStackGuid;\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength = Length;\r
+  Hob->AllocDescriptor.MemoryType = EfiConventionalMemory;\r
+  (*PeiServices)->SetMem (\r
+                    Hob->AllocDescriptor.Reserved, \r
+                    sizeof (Hob->AllocDescriptor.Reserved), \r
+                    0\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobBspStore (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the bsp store\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the bsp\r
+\r
+  Length                    - The length of the bsp store in bytes\r
+\r
+  MemoryType                - Memory type\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                           Status;  \r
+  EFI_HOB_MEMORY_ALLOCATION_BSP_STORE  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_MEMORY_ALLOCATION,\r
+                             sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
\r
+  Hob->AllocDescriptor.Name = gEfiHobMemeryAllocBspStoreGuid;\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength = Length;\r
+  Hob->AllocDescriptor.MemoryType = MemoryType;\r
+  (*PeiServices)->SetMem (\r
+                    Hob->AllocDescriptor.Reserved, \r
+                    sizeof (Hob->AllocDescriptor.Reserved), \r
+                    0\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PeiBuildHobMemoryAllocation (\r
+  IN EFI_PEI_SERVICES            **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *Name,\r
+  IN EFI_MEMORY_TYPE             MemoryType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Builds a HOB for the memory allocation.\r
+\r
+Arguments:\r
+\r
+  PeiServices               - The PEI core services table.\r
+\r
+  BaseAddress               - The 64 bit physical address of the memory\r
+\r
+  Length                    - The length of the memory allocation in bytes\r
+\r
+  Name                      - Name for Hob\r
+\r
+  MemoryType                - Memory type\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Hob is successfully built.\r
+  Others                    - Errors occur while creating new Hob\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                 Status; \r
+  EFI_HOB_MEMORY_ALLOCATION  *Hob;\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_MEMORY_ALLOCATION,\r
+                             sizeof (EFI_HOB_MEMORY_ALLOCATION),\r
+                             &Hob\r
+                             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (Name != NULL) {\r
+    Hob->AllocDescriptor.Name = *Name;\r
+  } else {\r
+    (*PeiServices)->SetMem(&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID), 0);\r
+  }\r
+\r
+  Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
+  Hob->AllocDescriptor.MemoryLength = Length;\r
+  Hob->AllocDescriptor.MemoryType = MemoryType;\r
+  (*PeiServices)->SetMem (\r
+                    Hob->AllocDescriptor.Reserved, \r
+                    sizeof (Hob->AllocDescriptor.Reserved), \r
+                    0\r
+                    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s
new file mode 100644 (file)
index 0000000..931f930
--- /dev/null
@@ -0,0 +1,77 @@
+//++\r
+// Copyright (c) 2007, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//  HWAccess.s\r
+//\r
+// Abstract:\r
+//\r
+//  Contains an implementation of Read/Write Kr7 for the Itanium-based architecture.\r
+//\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+  .file  "HWAccess.s"\r
+#include  "IpfMacro.i"\r
+\r
+\r
+//----------------------------------------------------------------------------------\r
+//++ \r
+//VOID\r
+//AsmWriteKr7 (\r
+//  UINT64\r
+//  );\r
+//\r
+// This routine saves the given input value into the kernel register 7\r
+//\r
+// Arguments :\r
+//\r
+// On Entry :  64 bit value to be saved.\r
+//\r
+// Return Value: None\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (AsmWriteKr7)\r
+        NESTED_SETUP (1,2,0,0)\r
+        mov ar.k7 = in0;;\r
+        NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (AsmWriteKr7)\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+//UINT64\r
+//AsmReadKr7 (\r
+//  VOID\r
+//  );\r
+//\r
+// This routine returns the value of the kernel register 7\r
+//\r
+// Arguments :\r
+//\r
+// On Entry :  None\r
+//\r
+// Return Value: 64bit Value of the register.\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (AsmReadKr7)\r
+        NESTED_SETUP (0,2,0,0)\r
+        mov r8 = ar.k7;;\r
+        NESTED_RETURN\r
+PROCEDURE_EXIT (AsmReadKr7)\r
+//----------------------------------------------------------------------------------\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..d56d949
--- /dev/null
@@ -0,0 +1,268 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+    Fixes Intel Itanium(TM) specific relocation types\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiImage.h"\r
+\r
+#define EXT_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)\r
+\r
+#define INS_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \\r
+          ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)\r
+\r
+#define IMM64_IMM7B_INST_WORD_X         3  \r
+#define IMM64_IMM7B_SIZE_X              7  \r
+#define IMM64_IMM7B_INST_WORD_POS_X     4  \r
+#define IMM64_IMM7B_VAL_POS_X           0  \r
+\r
+#define IMM64_IMM9D_INST_WORD_X         3  \r
+#define IMM64_IMM9D_SIZE_X              9  \r
+#define IMM64_IMM9D_INST_WORD_POS_X     18  \r
+#define IMM64_IMM9D_VAL_POS_X           7  \r
+\r
+#define IMM64_IMM5C_INST_WORD_X         3  \r
+#define IMM64_IMM5C_SIZE_X              5  \r
+#define IMM64_IMM5C_INST_WORD_POS_X     13  \r
+#define IMM64_IMM5C_VAL_POS_X           16  \r
+\r
+#define IMM64_IC_INST_WORD_X            3  \r
+#define IMM64_IC_SIZE_X                 1  \r
+#define IMM64_IC_INST_WORD_POS_X        12  \r
+#define IMM64_IC_VAL_POS_X              21  \r
+\r
+#define IMM64_IMM41a_INST_WORD_X        1  \r
+#define IMM64_IMM41a_SIZE_X             10  \r
+#define IMM64_IMM41a_INST_WORD_POS_X    14  \r
+#define IMM64_IMM41a_VAL_POS_X          22  \r
+\r
+#define IMM64_IMM41b_INST_WORD_X        1  \r
+#define IMM64_IMM41b_SIZE_X             8  \r
+#define IMM64_IMM41b_INST_WORD_POS_X    24  \r
+#define IMM64_IMM41b_VAL_POS_X          32  \r
+\r
+#define IMM64_IMM41c_INST_WORD_X        2  \r
+#define IMM64_IMM41c_SIZE_X             23  \r
+#define IMM64_IMM41c_INST_WORD_POS_X    0  \r
+#define IMM64_IMM41c_VAL_POS_X          40  \r
+\r
+#define IMM64_SIGN_INST_WORD_X          3  \r
+#define IMM64_SIGN_SIZE_X               1  \r
+#define IMM64_SIGN_INST_WORD_POS_X      27  \r
+#define IMM64_SIGN_VAL_POS_X            63  \r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup, \r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an Itanium-based specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  UINT64      *F64;\r
+  UINT64      FixupVal;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+\r
+    case EFI_IMAGE_REL_BASED_IA64_IMM64:\r
+\r
+      //\r
+      // Align it to bundle address before fixing up the\r
+      // 64-bit immediate value of the movl instruction.\r
+      //\r
+\r
+      Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));\r
+      FixupVal = (UINT64)0;\r
+                       \r
+      // \r
+      // Extract the lower 32 bits of IMM64 from bundle\r
+      //\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+                       \r
+      // \r
+      // Update 64-bit address\r
+      //\r
+      FixupVal += Adjust;\r
+\r
+      // \r
+      // Insert IMM64 into bundle\r
+      //\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),\r
+                IMM64_IMM41b_SIZE_X,\r
+                IMM64_IMM41b_INST_WORD_POS_X,\r
+                IMM64_IMM41b_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),\r
+                IMM64_IMM41c_SIZE_X,\r
+                IMM64_IMM41c_INST_WORD_POS_X,\r
+                IMM64_IMM41c_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),\r
+                IMM64_SIGN_SIZE_X,\r
+                IMM64_SIGN_INST_WORD_POS_X,\r
+                IMM64_SIGN_VAL_POS_X\r
+                );\r
+\r
+      F64 = (UINT64 *) Fixup;\r
+      if (*FixupData != NULL) {\r
+        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+        *(UINT64 *)(*FixupData) = *F64;\r
+        *FixupData = *FixupData + sizeof(UINT64);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IPF, EBC,\r
+  images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA64) || (Machine == EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h
new file mode 100644 (file)
index 0000000..8f18ff0
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    PeCoffLoaderEx.h\r
+\r
+Abstract:\r
+\r
+    Fixes Intel Itanium(TM) specific relocation types\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PE_COFF_LOADER_EX_H_\r
+#define _PE_COFF_LOADER_EX_H_\r
+\r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an Itanium-based specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IPF, EBC,\r
+  images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c
new file mode 100644 (file)
index 0000000..7c77dd1
--- /dev/null
@@ -0,0 +1,108 @@
+/*++\r
+\r
+Copyright 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+    PeiServicePointer.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiApi.h"\r
+#include "PeiLib.h"\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+VOID\r
+SetPeiServicesTablePointer (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PeiService pointer so that it can be retrieved anywhere.\r
+\r
+Arguments:\r
+\r
+  PeiServices     - The direct pointer to PeiServiceTable.\r
+  PhyscialAddress - The physcial address of variable PeiServices.\r
+  \r
+Returns:\r
+  NONE\r
+  \r
+--*/        \r
+  \r
+{\r
+  //\r
+  // For Itanium Processor Family processors, the EFI_PEI_SERVICES**\r
+  // is stored in kernel register7.\r
+  //\r
+  AsmWriteKr7((UINT64)(UINTN)PeiServices);\r
+}\r
+\r
+\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  NONE.\r
+  \r
+Returns:\r
+  The direct pointer to PeiServiceTable.\r
+  \r
+--*/          \r
+  \r
+{\r
+  //\r
+  // For Itanium Processor Family processors, the EFI_PEI_SERVICES**\r
+  // is stored in kernel register7.\r
+  //\r
+  return (EFI_PEI_SERVICES **)(UINTN)AsmReadKr7();\r
+}\r
+\r
+VOID\r
+MigrateIdtTable (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
+  storing PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  PeiServices   - The direct pointer to PeiServiceTable.\r
+  \r
+Returns:\r
+\r
+  NONE.\r
+  \r
+--*/  \r
+{\r
+  return;\r
+}\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s
new file mode 100644 (file)
index 0000000..5814bb7
--- /dev/null
@@ -0,0 +1,61 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    PerformancePrimitives.s\r
+//\r
+//  Abstract:\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+.file  "PerformancePrimitives.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// GetTimerValue\r
+//\r
+// Implementation of CPU-based time service\r
+//\r
+// On Entry :\r
+//    EFI_STATUS\r
+//    GetTimerValue (\r
+//      OUT UINT64    *TimerValue\r
+//    )\r
+//\r
+// Return Value: \r
+//        r8  = Status\r
+//        r9  = 0\r
+//        r10 = 0\r
+//        r11 = 0\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (GetTimerValue)\r
+\r
+      NESTED_SETUP (1,8,0,0)\r
+      mov               r8 = ar.itc;;\r
+      st8               [r32]= r8\r
+      mov               r8 = r0\r
+      mov               r9 = r0\r
+      mov               r10 = r0\r
+      mov               r11 = r0\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (GetTimerValue)\r
+//---------------------------------------------------------------------------\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s
new file mode 100644 (file)
index 0000000..08ff773
--- /dev/null
@@ -0,0 +1,122 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//  SwitchStack.s\r
+//\r
+// Abstract:\r
+//\r
+//  Contains an implementation of a stack switch for the Itanium-based architecture.\r
+//\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+  .file  "SwitchStack.s"\r
+\r
+#include  <asm.h>\r
+#include  <ia_64gen.h>\r
+\r
+// Define hardware RSE Configuration Register\r
+//\r
+// RS Configuration (RSC) bit field positions\r
+\r
+#define RSC_MODE       0\r
+#define RSC_PL         2\r
+#define RSC_BE         4\r
+// RSC bits 5-15 reserved\r
+#define RSC_MBZ0       5\r
+#define RSC_MBZ0_V     0x3ff\r
+#define RSC_LOADRS     16\r
+#define RSC_LOADRS_LEN 14\r
+// RSC bits 30-63 reserved\r
+#define RSC_MBZ1       30\r
+#define RSC_MBZ1_V     0x3ffffffffULL\r
+\r
+// RSC modes\r
+// Lazy\r
+#define RSC_MODE_LY (0x0)\r
+// Store intensive\r
+#define RSC_MODE_SI (0x1)\r
+// Load intensive\r
+#define RSC_MODE_LI (0x2)\r
+// Eager\r
+#define RSC_MODE_EA (0x3)\r
+\r
+// RSC Endian bit values\r
+#define RSC_BE_LITTLE 0\r
+#define RSC_BE_BIG    1\r
+\r
+// RSC while in kernel: enabled, little endian, pl = 0, eager mode\r
+#define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
+// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode\r
+#define RSC_KERNEL_LAZ ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
+// RSE disabled: disabled, pl = 0, little endian, eager mode\r
+#define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
+\r
+\r
+//VOID\r
+//SwitchStacks (\r
+//    VOID    *ContinuationFunction,\r
+//    UINTN   Parameter,\r
+//    UINTN   NewTopOfStack,\r
+//    UINTN   NewBSPStore OPTIONAL\r
+//)\r
+///*++\r
+//\r
+//Input Arguments\r
+//\r
+//  ContinuationFunction - This is a pointer to the PLABEL of the function that should  be called once the\r
+//        new stack has been created.  \r
+//  Parameter - The parameter to pass to the continuation function\r
+//  NewTopOfStack - This is the new top of the memory stack for ensuing code.  This is mandatory and\r
+//      should be non-zero\r
+//  NewBSPStore - This is the new BSP store for the ensuing code.  It is optional on IA-32 and mandatory on Itanium-based platform.\r
+//\r
+//--*/\r
+\r
+PROCEDURE_ENTRY(SwitchStacks)\r
+\r
+        mov        r16 = -0x10;;\r
+        and        r16 = r34, r16;;             // get new stack value in R16, 0 the last nibble.\r
+        mov        r15 = r35;;                  // Get new BspStore into R15\r
+        mov        r13 = r32;;                  // this is a pointer to the PLABEL of the continuation function.  \r
+        mov        r17 = r33;;                  // this is the parameter to pass to the continuation function\r
+\r
+        alloc       r11=0,0,0,0                 // Set 0-size frame\r
+        ;;\r
+        flushrs;;\r
+\r
+        mov         r21 = RSC_KERNEL_DISABLED   // for rse disable             \r
+        ;;\r
+        mov         ar.rsc = r21                // turn off RSE                \r
+\r
+        add         sp = r0, r16;;              // transfer to the EFI stack\r
+        mov         ar.bspstore = r15           // switch to EFI BSP        \r
+        invala                                  // change of ar.bspstore needs invala.     \r
+      \r
+        mov         r18 = RSC_KERNEL_LAZ        // RSC enabled, Lazy mode\r
+        ;;\r
+        mov         ar.rsc = r18                // turn rse on, in kernel mode     \r
+        ;;        \r
+        alloc       r11=0,0,1,0;;                 // alloc 0 outs going to ensuing DXE IPL service\r
+        mov         out0 = r17\r
+        ld8         r16 = [r13],8;;               // r16 = address of continuation function from the PLABEL\r
+        ld8         gp = [r13]                  // gp  = gp of continuation function from the PLABEL\r
+        mov         b6 = r16\r
+        ;;\r
+        br.call.sptk.few b0=b6;;                  // Call the continuation function\r
+        ;;\r
+PROCEDURE_EXIT(SwitchStacks)\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/asm.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/asm.h
new file mode 100644 (file)
index 0000000..52ff4c0
--- /dev/null
@@ -0,0 +1,35 @@
+//\r
+//\r
+// Copyright (c) 2004, Intel Corporation\r
+// All rights reserved. This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution.  The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// Module Name:\r
+//\r
+//   asm.h\r
+//\r
+// Abstract:\r
+//\r
+//   This module contains generic macros for an assembly writer.\r
+//\r
+//\r
+// Revision History\r
+//\r
+#ifndef _ASM_H\r
+#define _ASM_H\r
+\r
+#define TRUE  1\r
+#define FALSE 0\r
+#define PROCEDURE_ENTRY(name)   .##text;            \\r
+  .##type name, @function; \\r
+  .##proc name; \\r
+  name::\r
+\r
+#define PROCEDURE_EXIT(name)  .##endp name\r
+\r
+#endif // _ASM_H\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/efijump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/efijump.h
new file mode 100644 (file)
index 0000000..cec5364
--- /dev/null
@@ -0,0 +1,112 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiJump.h\r
+\r
+Abstract:\r
+\r
+  This is the Setjump/Longjump pair for an IA32 processor.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_JUMP_H_\r
+#define _EFI_JUMP_H_\r
+\r
+#include EFI_GUID_DEFINITION (PeiTransferControl)\r
+\r
+//\r
+//  NOTE:Set/LongJump needs to have this buffer start\r
+//  at 16 byte boundary. Either fix the structure\r
+//  which call this buffer or fix inside SetJump/LongJump\r
+//  Choosing 1K buffer storage for now\r
+//\r
+typedef struct {\r
+  CHAR8 Buffer[1024];\r
+} EFI_JUMP_BUFFER;\r
+\r
+EFI_STATUS\r
+SetJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  SetJump stores the current register set in the area pointed to\r
+by "save".  It returns zero.  Subsequent calls to "LongJump" will\r
+restore the registers and return non-zero to the same location.\r
+  On entry, r32 contains the pointer to the jmp_buffer\r
+  \r
+Arguments:\r
+  \r
+  This  - Calling context\r
+  Jump  - Jump buffer\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LongJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  LongJump initializes the register set to the values saved by a\r
+previous 'SetJump' and jumps to the return location saved by that\r
+'SetJump'.  This has the effect of unwinding the stack and returning\r
+for a second time to the 'SetJump'.\r
+\r
+Arguments:\r
+\r
+  This  - Calling context\r
+  Jump  - Jump buffer\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+RtPioICacheFlush (\r
+  IN  VOID    *StartAddress,\r
+  IN  UINTN   SizeInBytes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flushing the CPU instruction cache.\r
+\r
+Arguments:\r
+\r
+  StartAddress  - Start address to flush\r
+  SizeInBytes   - Length in bytes to flush\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h
new file mode 100644 (file)
index 0000000..5eca149
--- /dev/null
@@ -0,0 +1,214 @@
+// \r
+// \r
+// \r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//Module Name: ia_64gen.h\r
+//\r
+//\r
+//Abstract:\r
+//\r
+//\r
+//\r
+//\r
+//Revision History\r
+//\r
+//\r
+#ifndef _IA64GEN_H\r
+#define _IA64GEN_H\r
+\r
+#define TT_UNAT           0\r
+#define C_PSR             0\r
+#define J_UNAT            0\r
+#define T_TYPE            0\r
+#define T_IPSR            0x8\r
+#define T_ISR             0x10\r
+#define T_IIP             0x18\r
+#define T_IFA             0x20\r
+#define T_IIPA            0x28\r
+#define T_IFS             0x30\r
+#define T_IIM             0x38\r
+#define T_RSC             0x40\r
+#define T_BSP             0x48\r
+#define T_BSPSTORE        0x50\r
+#define T_RNAT            0x58\r
+#define T_PFS             0x60\r
+#define T_KBSPSTORE       0x68\r
+#define T_UNAT            0x70\r
+#define T_CCV             0x78\r
+#define T_DCR             0x80\r
+#define T_PREDS           0x88\r
+#define T_NATS            0x90\r
+#define T_R1              0x98\r
+#define T_GP              0x98\r
+#define T_R2              0xa0\r
+#define T_R3              0xa8\r
+#define T_R4              0xb0\r
+#define T_R5              0xb8\r
+#define T_R6              0xc0\r
+#define T_R7              0xc8\r
+#define T_R8              0xd0\r
+#define T_R9              0xd8\r
+#define T_R10             0xe0\r
+#define T_R11             0xe8\r
+#define T_R12             0xf0\r
+#define T_SP              0xf0\r
+#define T_R13             0xf8\r
+#define T_R14             0x100\r
+#define T_R15             0x108\r
+#define T_R16             0x110\r
+#define T_R17             0x118\r
+#define T_R18             0x120\r
+#define T_R19             0x128\r
+#define T_R20             0x130\r
+#define T_R21             0x138\r
+#define T_R22             0x140\r
+#define T_R23             0x148\r
+#define T_R24             0x150\r
+#define T_R25             0x158\r
+#define T_R26             0x160\r
+#define T_R27             0x168\r
+#define T_R28             0x170\r
+#define T_R29             0x178\r
+#define T_R30             0x180\r
+#define T_R31             0x188\r
+#define T_F2              0x1f0\r
+#define T_F3              0x200\r
+#define T_F4              0x210\r
+#define T_F5              0x220\r
+#define T_F6              0x230\r
+#define T_F7              0x240\r
+#define T_F8              0x250\r
+#define T_F9              0x260\r
+#define T_F10             0x270\r
+#define T_F11             0x280\r
+#define T_F12             0x290\r
+#define T_F13             0x2a0\r
+#define T_F14             0x2b0\r
+#define T_F15             0x2c0\r
+#define T_F16             0x2d0\r
+#define T_F17             0x2e0\r
+#define T_F18             0x2f0\r
+#define T_F19             0x300\r
+#define T_F20             0x310\r
+#define T_F21             0x320\r
+#define T_F22             0x330\r
+#define T_F23             0x340\r
+#define T_F24             0x350\r
+#define T_F25             0x360\r
+#define T_F26             0x370\r
+#define T_F27             0x380\r
+#define T_F28             0x390\r
+#define T_F29             0x3a0\r
+#define T_F30             0x3b0\r
+#define T_F31             0x3c0\r
+#define T_FPSR            0x1e0\r
+#define T_B0              0x190\r
+#define T_B1              0x198\r
+#define T_B2              0x1a0\r
+#define T_B3              0x1a8\r
+#define T_B4              0x1b0\r
+#define T_B5              0x1b8\r
+#define T_B6              0x1c0\r
+#define T_B7              0x1c8\r
+#define T_EC              0x1d0\r
+#define T_LC              0x1d8\r
+#define J_NATS            0x8\r
+#define J_PFS             0x10\r
+#define J_BSP             0x18\r
+#define J_RNAT            0x20\r
+#define J_PREDS           0x28\r
+#define J_LC              0x30\r
+#define J_R4              0x38\r
+#define J_R5              0x40\r
+#define J_R6              0x48\r
+#define J_R7              0x50\r
+#define J_SP              0x58\r
+#define J_F2              0x60\r
+#define J_F3              0x70\r
+#define J_F4              0x80\r
+#define J_F5              0x90\r
+#define J_F16             0xa0\r
+#define J_F17             0xb0\r
+#define J_F18             0xc0\r
+#define J_F19             0xd0\r
+#define J_F20             0xe0\r
+#define J_F21             0xf0\r
+#define J_F22             0x100\r
+#define J_F23             0x110\r
+#define J_F24             0x120\r
+#define J_F25             0x130\r
+#define J_F26             0x140\r
+#define J_F27             0x150\r
+#define J_F28             0x160\r
+#define J_F29             0x170\r
+#define J_F30             0x180\r
+#define J_F31             0x190\r
+#define J_FPSR            0x1a0\r
+#define J_B0              0x1a8\r
+#define J_B1              0x1b0\r
+#define J_B2              0x1b8\r
+#define J_B3              0x1c0\r
+#define J_B4              0x1c8\r
+#define J_B5              0x1d0\r
+#define TRAP_FRAME_LENGTH 0x3d0\r
+#define C_UNAT            0x28\r
+#define C_NATS            0x30\r
+#define C_PFS             0x8\r
+#define C_BSPSTORE        0x10\r
+#define C_RNAT            0x18\r
+#define C_RSC             0x20\r
+#define C_PREDS           0x38\r
+#define C_LC              0x40\r
+#define C_DCR             0x48\r
+#define C_R1              0x50\r
+#define C_GP              0x50\r
+#define C_R4              0x58\r
+#define C_R5              0x60\r
+#define C_R6              0x68\r
+#define C_R7              0x70\r
+#define C_SP              0x78\r
+#define C_R13             0x80\r
+#define C_F2              0x90\r
+#define C_F3              0xa0\r
+#define C_F4              0xb0\r
+#define C_F5              0xc0\r
+#define C_F16             0xd0\r
+#define C_F17             0xe0\r
+#define C_F18             0xf0\r
+#define C_F19             0x100\r
+#define C_F20             0x110\r
+#define C_F21             0x120\r
+#define C_F22             0x130\r
+#define C_F23             0x140\r
+#define C_F24             0x150\r
+#define C_F25             0x160\r
+#define C_F26             0x170\r
+#define C_F27             0x180\r
+#define C_F28             0x190\r
+#define C_F29             0x1a0\r
+#define C_F30             0x1b0\r
+#define C_F31             0x1c0\r
+#define C_FPSR            0x1d0\r
+#define C_B0              0x1d8\r
+#define C_B1              0x1e0\r
+#define C_B2              0x1e8\r
+#define C_B3              0x1f0\r
+#define C_B4              0x1f8\r
+#define C_B5              0x200\r
+#define TT_R2             0x8\r
+#define TT_R3             0x10\r
+#define TT_R8             0x18\r
+#define TT_R9             0x20\r
+#define TT_R10            0x28\r
+#define TT_R11            0x30\r
+#define TT_R14            0x38\r
+\r
+#endif _IA64GEN_H\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/math.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/math.c
new file mode 100644 (file)
index 0000000..860d129
--- /dev/null
@@ -0,0 +1,139 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  math.c\r
+\r
+Abstract:\r
+\r
+  64-bit Math worker functions for Intel Itanium(TM) processors.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
\r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand << Count;\r
+}\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand >> Count;\r
+}\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  )\r
+/*++  \r
+  \r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN UINT64   Dividend,\r
+  IN UINTN    Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+  N.B. only works for 31bit divisors!!\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
\r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+\r
+--*/\r
+{\r
+  if (Remainder) {\r
+    *Remainder = Dividend % Divisor;\r
+  }\r
+\r
+  return Dividend / Divisor;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s
new file mode 100644 (file)
index 0000000..e48a5e4
--- /dev/null
@@ -0,0 +1,106 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    pioflush.s \r
+//\r
+//  Abstract:\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+  .file  "pioflush.c"\r
+  .radix  D\r
+  .section  .text,  "ax", "progbits"\r
+  .align 32\r
+  .section  .pdata,  "a", "progbits"\r
+  .align 4\r
+  .section  .xdata,  "a", "progbits"\r
+  .align 8\r
+  .section  .data,  "wa", "progbits"\r
+  .align 16\r
+  .section  .rdata,  "a", "progbits"\r
+  .align 16\r
+  .section  .bss,  "wa", "nobits"\r
+  .align 16\r
+  .section  .tls$,  "was", "progbits"\r
+  .align 16\r
+  .section  .sdata,  "was", "progbits"\r
+  .align 16\r
+  .section  .sbss,  "was", "nobits"\r
+  .align 16\r
+  .section  .srdata,  "as", "progbits"\r
+  .align 16\r
+  .section  .rdata,  "a", "progbits"\r
+  .align 16\r
+  .section  .rtcode,  "ax", "progbits"\r
+  .align 32\r
+  .type  RtPioICacheFlush#  ,@function \r
+        .global RtPioICacheFlush#\r
+// Function compile flags: /Ogsy\r
+  .section  .rtcode\r
+\r
+// Begin code for function: RtPioICacheFlush:\r
+  .proc  RtPioICacheFlush#\r
+  .align 32\r
+RtPioICacheFlush:  \r
+// File e:\tmp\pioflush.c\r
+ {   .mii  //R-Addr: 0X00 \r
+  alloc  r3=2, 0, 0, 0            //11, 00000002H\r
+  cmp4.leu p0,p6=32, r33;;          //15, 00000020H\r
+  (p6)  mov  r33=32;;            //16, 00000020H\r
+ }\r
+ {   .mii  //R-Addr: 0X010 \r
+  nop.m   0\r
+  zxt4  r29=r33;;            //21\r
+  dep.z  r30=r29, 0, 5;;            //21, 00000005H\r
+ }\r
+ {   .mii  //R-Addr: 0X020 \r
+  cmp4.eq  p0,p7=r0, r30            //21\r
+  shr.u  r28=r29, 5;;            //19, 00000005H\r
+  (p7)  adds  r28=1, r28;;            //22, 00000001H\r
+ }\r
+ {   .mii  //R-Addr: 0X030 \r
+  nop.m   0\r
+  shl  r27=r28, 5;;            //25, 00000005H\r
+  zxt4  r26=r27;;            //25\r
+ }\r
+ {   .mfb  //R-Addr: 0X040 \r
+  add  r31=r26, r32            //25\r
+  nop.f   0\r
+  nop.b   0\r
+ }\r
+$L143:\r
+ {   .mii  //R-Addr: 0X050 \r
+  fc   r32              //27\r
+  adds  r32=32, r32;;            //28, 00000020H\r
+  cmp.ltu  p14,p15=r32, r31          //29\r
+ }\r
+ {   .mfb  //R-Addr: 0X060 \r
+  nop.m   0\r
+  nop.f   0\r
+  (p14)  br.cond.dptk.few $L143#;;          //29, 880000/120000\r
+ }\r
+ {   .mmi\r
+    sync.i;;\r
+    srlz.i\r
+    nop.i   0;;\r
+ }\r
+ {   .mfb  //R-Addr: 0X070 \r
+  nop.m   0\r
+  nop.f   0\r
+  br.ret.sptk.few b0;;            //31\r
+ }\r
+// End code for function:\r
+  .endp  RtPioICacheFlush#\r
+// END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c
new file mode 100644 (file)
index 0000000..e6d5c40
--- /dev/null
@@ -0,0 +1,118 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Processor.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiJump.h"\r
+#include "PeiHob.h"\r
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)\r
+#include EFI_GUID_DEFINITION (PeiTransferControl)\r
+\r
+EFI_STATUS\r
+WinNtFlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL   *This,\r
+  IN EFI_PHYSICAL_ADDRESS                       Start,\r
+  IN UINT64                                     Length\r
+  );\r
+\r
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL         mTransferControl = {\r
+  SetJump,\r
+  LongJump,\r
+  sizeof (EFI_JUMP_BUFFER)\r
+};\r
+\r
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  mFlushInstructionCache = {\r
+  WinNtFlushInstructionCacheFlush\r
+};\r
+\r
+EFI_STATUS\r
+InstallEfiPeiTransferControl (\r
+  IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the transfer control mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to transfer control mechanism.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Successfully installed.\r
+\r
+--*/\r
+{\r
+  *This = &mTransferControl;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InstallEfiPeiFlushInstructionCache (\r
+  IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the flush instruction cache mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to flush instruction cache mechanism.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Successfully installed\r
+\r
+--*/\r
+{\r
+  *This = &mFlushInstructionCache;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+WinNtFlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL   *This,\r
+  IN EFI_PHYSICAL_ADDRESS                       Start,\r
+  IN UINT64                                     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would provide support for flushing the CPU instruction cache.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to CPU Architectural Protocol interface\r
+  Start     - Start adddress in memory to flush\r
+  Length    - Length of memory to flush\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  RtPioICacheFlush ((UINT8 *) Start, (UINTN) Length);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s
new file mode 100644 (file)
index 0000000..4606437
--- /dev/null
@@ -0,0 +1,325 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//  setjmp.s\r
+//\r
+// Abstract:\r
+//\r
+//  Contains an implementation of setjmp and longjmp for the\r
+//  Itanium-based architecture.\r
+//\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+  .file  "setjmp.s"\r
+\r
+#include  <asm.h>\r
+#include  <ia_64gen.h>\r
+\r
+// int SetJump(struct jmp_buffer save)\r
+//\r
+//  Setup a non-local goto.\r
+//\r
+// Description:\r
+//\r
+//  SetJump stores the current register set in the area pointed to\r
+//  by "save".  It returns zero.  Subsequent calls to "LongJump" will\r
+//  restore the registers and return non-zero to the same location.\r
+//\r
+// On entry, r32 contains the pointer to the jmp_buffer\r
+//\r
+\r
+PROCEDURE_ENTRY(SetJump)\r
+  //\r
+  //  Make sure buffer is aligned at 16byte boundary\r
+  //\r
+  mov    r32 = r33        \r
+\r
+    add     r10 = -0x10,r0  ;;  // mask the lower 4 bits\r
+    and     r32 = r32, r10;; \r
+    add     r32 = 0x10, r32;;   // move to next 16 byte boundary\r
+\r
+    add    r10 = J_PREDS, r32  // skip Unats & pfs save area\r
+  add    r11 = J_BSP, r32\r
+  //\r
+  //  save immediate context\r
+  //\r
+  mov    r2 = ar.bsp     // save backing store pointer\r
+  mov    r3 = pr         // save predicates\r
+  ;;\r
+  //\r
+  // save user Unat register\r
+  //\r
+  mov    r16 = ar.lc        // save loop count register\r
+  mov    r14 = ar.unat     // save user Unat register\r
+\r
+  st8    [r10] = r3, J_LC-J_PREDS\r
+  st8    [r11] = r2, J_R4-J_BSP\r
+  ;;\r
+  st8    [r10] = r16, J_R5-J_LC\r
+  st8    [r32] = r14, J_NATS  // Note: Unat at the \r
+                    // beginning of the save area\r
+  mov    r15 = ar.pfs\r
+  ;;\r
+  //\r
+  //  save preserved general registers & NaT's\r
+  //\r
+  st8.spill  [r11] = r4, J_R6-J_R4\r
+  ;;\r
+  st8.spill  [r10] = r5, J_R7-J_R5 \r
+    ;;\r
+  st8.spill  [r11] = r6, J_SP-J_R6\r
+  ;;\r
+  st8.spill  [r10] = r7, J_F3-J_R7 \r
+    ;;\r
+  st8.spill  [r11] = sp, J_F2-J_SP\r
+  ;;\r
+  //\r
+  // save spilled Unat and pfs registers\r
+  //\r
+  mov    r2 = ar.unat       // save Unat register after spill\r
+  ;;\r
+  st8    [r32] = r2, J_PFS-J_NATS  // save unat for spilled regs\r
+  ;;\r
+  st8    [r32] = r15          // save pfs\r
+  //\r
+  //  save floating registers \r
+  //\r
+  stf.spill  [r11] = f2, J_F4-J_F2\r
+  stf.spill  [r10] = f3, J_F5-J_F3 \r
+  ;;\r
+  stf.spill  [r11] = f4, J_F16-J_F4\r
+  stf.spill  [r10] = f5, J_F17-J_F5 \r
+  ;;\r
+  stf.spill  [r11] = f16, J_F18-J_F16\r
+  stf.spill  [r10] = f17, J_F19-J_F17 \r
+  ;;\r
+  stf.spill  [r11] = f18, J_F20-J_F18\r
+  stf.spill  [r10] = f19, J_F21-J_F19 \r
+  ;;\r
+  stf.spill  [r11] = f20, J_F22-J_F20\r
+  stf.spill  [r10] = f21, J_F23-J_F21 \r
+  ;;\r
+  stf.spill  [r11] = f22, J_F24-J_F22\r
+  stf.spill  [r10] = f23, J_F25-J_F23 \r
+  ;;\r
+  stf.spill  [r11] = f24, J_F26-J_F24\r
+  stf.spill  [r10] = f25, J_F27-J_F25 \r
+  ;;\r
+  stf.spill  [r11] = f26, J_F28-J_F26\r
+  stf.spill  [r10] = f27, J_F29-J_F27 \r
+  ;;\r
+  stf.spill  [r11] = f28, J_F30-J_F28\r
+  stf.spill  [r10] = f29, J_F31-J_F29 \r
+  ;;\r
+  stf.spill  [r11] = f30, J_FPSR-J_F30\r
+  stf.spill  [r10] = f31, J_B0-J_F31    // size of f31 + fpsr\r
+  //\r
+  // save FPSR register & branch registers\r
+  //\r
+  mov    r2 = ar.fpsr  // save fpsr register\r
+  mov    r3 = b0 \r
+  ;;\r
+  st8    [r11] = r2, J_B1-J_FPSR\r
+  st8    [r10] = r3, J_B2-J_B0\r
+  mov    r2 = b1\r
+  mov    r3 = b2 \r
+  ;;\r
+  st8    [r11] = r2, J_B3-J_B1\r
+  st8    [r10] = r3, J_B4-J_B2\r
+  mov    r2 = b3\r
+  mov    r3 = b4 \r
+  ;;\r
+  st8    [r11] = r2, J_B5-J_B3\r
+  st8    [r10] = r3\r
+  mov    r2 = b5 \r
+  ;;\r
+  st8    [r11] = r2\r
+  ;;\r
+  //\r
+  // return\r
+  //\r
+  mov    r8 = r0        // return 0 from setjmp\r
+  mov    ar.unat = r14  // restore unat\r
+  br.ret.sptk  b0\r
+\r
+PROCEDURE_EXIT(SetJump)\r
+\r
+\r
+//\r
+// void LongJump(struct jmp_buffer *)\r
+//\r
+//  Perform a non-local goto.\r
+//\r
+// Description:\r
+//\r
+//  LongJump initializes the register set to the values saved by a\r
+//  previous 'SetJump' and jumps to the return location saved by that\r
+//  'SetJump'.  This has the effect of unwinding the stack and returning\r
+//  for a second time to the 'SetJump'.\r
+//\r
+\r
+PROCEDURE_ENTRY(LongJump)\r
+  //\r
+  //  Make sure buffer is aligned at 16byte boundary\r
+  //\r
+  mov    r32 = r33        \r
+\r
+    add     r10 = -0x10,r0  ;;  // mask the lower 4 bits\r
+    and     r32 = r32, r10;; \r
+    add     r32 = 0x10, r32;;   // move to next 16 byte boundary\r
+\r
+  //\r
+  // caching the return value as we do invala in the end\r
+  //\r
+///  mov    r8 = r33          // return value\r
+  mov    r8 = 1              // For now return hard coded 1\r
+\r
+  //\r
+  //  get immediate context\r
+  //\r
+  mov    r14 = ar.rsc    // get user RSC conf \r
+  add    r10 = J_PFS, r32  // get address of pfs\r
+  add    r11 = J_NATS, r32\r
+  ;;\r
+  ld8    r15 = [r10], J_BSP-J_PFS  // get pfs\r
+  ld8    r2 = [r11], J_LC-J_NATS      // get unat for spilled regs\r
+  ;;\r
+  mov    ar.unat = r2\r
+  ;;\r
+  ld8    r16 = [r10], J_PREDS-J_BSP  // get backing store pointer\r
+  mov    ar.rsc = r0        // put RSE in enforced lazy \r
+  mov    ar.pfs = r15\r
+  ;;\r
+  \r
+  //\r
+  // while returning from longjmp the BSPSTORE and BSP needs to be\r
+  // same and discard all the registers allocated after we did\r
+  // setjmp. Also, we need to generate the RNAT register since we\r
+  // did not flushed the RSE on setjmp.\r
+  //\r
+  mov    r17 = ar.bspstore  // get current BSPSTORE\r
+  ;;\r
+    cmp.ltu  p6,p7 = r17, r16  // is it less than BSP of \r
+(p6)  br.spnt.few  .flush_rse\r
+  mov    r19 = ar.rnat    // get current RNAT\r
+  ;;\r
+  loadrs              // invalidate dirty regs\r
+  br.sptk.many  .restore_rnat    // restore RNAT\r
+\r
+.flush_rse:\r
+  flushrs\r
+  ;;\r
+  mov    r19 = ar.rnat    // get current RNAT\r
+  mov    r17 = r16      // current BSPSTORE\r
+  ;;\r
+.restore_rnat:\r
+  //\r
+  // check if RNAT is saved between saved BSP and curr BSPSTORE\r
+  //\r
+  dep    r18 = 1,r16,3,6   // get RNAT address\r
+  ;;\r
+  cmp.ltu  p8,p9 = r18, r17  // RNAT saved on RSE\r
+  ;;\r
+(p8)  ld8    r19 = [r18]    // get RNAT from RSE\r
+  ;;\r
+  mov    ar.bspstore = r16  // set new BSPSTORE  \r
+  ;;\r
+  mov    ar.rnat = r19    // restore RNAT\r
+  mov    ar.rsc = r14    // restore RSC conf\r
+\r
+\r
+  ld8    r3 = [r11], J_R4-J_LC    // get lc register\r
+  ld8    r2 = [r10], J_R5-J_PREDS   // get predicates\r
+  ;;\r
+  mov    pr = r2, -1\r
+  mov    ar.lc = r3\r
+  //\r
+  //  restore preserved general registers & NaT's\r
+  //\r
+  ld8.fill  r4 = [r11], J_R6-J_R4\r
+  ;;\r
+  ld8.fill  r5 = [r10], J_R7-J_R5 \r
+  ld8.fill  r6 = [r11], J_SP-J_R6\r
+  ;;\r
+  ld8.fill  r7 = [r10], J_F2-J_R7\r
+  ld8.fill  sp = [r11], J_F3-J_SP\r
+  ;;\r
+  //\r
+  //  restore floating registers \r
+  //\r
+  ldf.fill  f2 = [r10], J_F4-J_F2\r
+  ldf.fill  f3 = [r11], J_F5-J_F3 \r
+  ;;\r
+  ldf.fill  f4 = [r10], J_F16-J_F4\r
+  ldf.fill  f5 = [r11], J_F17-J_F5 \r
+  ;;\r
+  ldf.fill  f16 = [r10], J_F18-J_F16\r
+  ldf.fill  f17 = [r11], J_F19-J_F17\r
+  ;;\r
+  ldf.fill  f18 = [r10], J_F20-J_F18\r
+  ldf.fill  f19 = [r11], J_F21-J_F19\r
+  ;;\r
+  ldf.fill  f20 = [r10], J_F22-J_F20\r
+  ldf.fill  f21 = [r11], J_F23-J_F21\r
+  ;;\r
+  ldf.fill  f22 = [r10], J_F24-J_F22\r
+  ldf.fill  f23 = [r11], J_F25-J_F23 \r
+  ;;\r
+  ldf.fill  f24 = [r10], J_F26-J_F24\r
+  ldf.fill  f25 = [r11], J_F27-J_F25\r
+  ;;\r
+  ldf.fill  f26 = [r10], J_F28-J_F26\r
+  ldf.fill  f27 = [r11], J_F29-J_F27\r
+  ;;\r
+  ldf.fill  f28 = [r10], J_F30-J_F28\r
+  ldf.fill  f29 = [r11], J_F31-J_F29 \r
+  ;;\r
+  ldf.fill  f30 = [r10], J_FPSR-J_F30\r
+  ldf.fill  f31 = [r11], J_B0-J_F31 ;;\r
+\r
+    //\r
+  // restore branch registers and fpsr\r
+  //\r
+  ld8    r16 = [r10], J_B1-J_FPSR  // get fpsr\r
+  ld8    r17 = [r11], J_B2-J_B0    // get return pointer\r
+  ;;\r
+  mov    ar.fpsr = r16\r
+  mov    b0 = r17\r
+  ld8    r2 = [r10], J_B3-J_B1\r
+  ld8    r3 = [r11], J_B4-J_B2\r
+  ;;\r
+  mov    b1 = r2\r
+  mov    b2 = r3\r
+  ld8    r2 = [r10], J_B5-J_B3\r
+  ld8    r3 = [r11]\r
+  ;;\r
+  mov    b3 = r2\r
+  mov    b4 = r3 \r
+  ld8    r2 = [r10]\r
+  ld8    r21 = [r32]      // get user unat\r
+  ;;\r
+  mov    b5 = r2\r
+  mov    ar.unat = r21\r
+\r
+  //\r
+  // invalidate ALAT\r
+  //\r
+  invala ;;\r
+\r
+  br.ret.sptk  b0\r
+PROCEDURE_EXIT(LongJump)\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
new file mode 100644 (file)
index 0000000..c276aa8
--- /dev/null
@@ -0,0 +1,1387 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeCoffLoader.c\r
+\r
+Abstract:\r
+\r
+  Tiano PE/COFF loader \r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+#include "PeCoffLoaderEx.h"\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+#include "peilib.h"\r
+#include "EfiHobLib.h"\r
+#include EFI_PPI_DEFINITION (NtLoadAsDll)\r
+#endif\r
+\r
+STATIC\r
+EFI_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext,\r
+  OUT    EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION    Hdr\r
+  );\r
+\r
+STATIC\r
+VOID*\r
+PeCoffLoaderImageAddress (\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  IN     UINTN                                 Address\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetImageInfo (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderRelocateImage (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLoadImage (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderUnloadImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
+  );\r
+\r
+#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)\r
+VOID\r
+AsmEfiSetBreakSupport (\r
+  IN UINTN  LoadAddr\r
+  );\r
+#endif\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader = {\r
+  PeCoffLoaderGetImageInfo,\r
+  PeCoffLoaderLoadImage,\r
+  PeCoffLoaderRelocateImage,\r
+  PeCoffLoaderUnloadImage\r
+};\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+EFI_NT_LOAD_AS_DLL_PPI          *mPeCoffLoaderWinNtLoadAsDll = NULL;\r
+#endif\r
+\r
+EFI_STATUS\r
+InstallEfiPeiPeCoffLoader (\r
+  IN EFI_PEI_SERVICES                          **PeiServices,\r
+  IN OUT  EFI_PEI_PE_COFF_LOADER_PROTOCOL      **This,\r
+  IN EFI_PEI_PPI_DESCRIPTOR                    *ThisPpi\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install PE/COFF loader PPI\r
+  \r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM\r
+\r
+  This        - Pointer to get Pei PE coff loader protocol as output\r
+  \r
+  ThisPpi     - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+  //\r
+  // For use by PEI Core and Modules\r
+  //\r
+  if (NULL != PeiServices) {\r
+    Status = (**PeiServices).LocatePpi (\r
+                              PeiServices,\r
+                              &gEfiNtLoadAsDllPpiGuid,\r
+                              0,\r
+                              NULL,\r
+                              &mPeCoffLoaderWinNtLoadAsDll\r
+                              );\r
+  } else {\r
+    //\r
+    // Now in SecMain or ERM usage, bind appropriately\r
+    //\r
+    PEI_ASSERT (PeiServices, (NULL != ThisPpi));\r
+\r
+    mPeCoffLoaderWinNtLoadAsDll = (EFI_NT_LOAD_AS_DLL_PPI *) ThisPpi;\r
+    PEI_ASSERT (PeiServices, (NULL != mPeCoffLoaderWinNtLoadAsDll));\r
+  }\r
+#endif\r
+\r
+  if (NULL != This) {\r
+    *This = &mPeCoffLoader;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext,\r
+  OUT    EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION    Hdr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the PE or TE Header from a PE/COFF or TE image\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+  PeHdr         - The buffer in which to return the PE32, PE32+, or TE header\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS if the PE or TE Header is read, \r
+  Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_IMAGE_DOS_HEADER  DosHdr;\r
+  UINTN                 Size;\r
+  UINT16                Magic;\r
+\r
+  //\r
+  // Read the DOS image header to check for it's existance\r
+  //\r
+  Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
+  Status = ImageContext->ImageRead (\r
+                           ImageContext->Handle,\r
+                           0,\r
+                           &Size,\r
+                           &DosHdr\r
+                           );\r
+  if (EFI_ERROR (Status)) {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+\r
+  ImageContext->PeCoffHeaderOffset = 0;\r
+  if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image \r
+    // header\r
+    //\r
+    ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;\r
+  }\r
+\r
+  //\r
+  // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much \r
+  // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic\r
+  // determins if this is a PE32 or PE32+ image. The magic is in the same \r
+  // location in both images.\r
+  //\r
+  Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);\r
+  Status = ImageContext->ImageRead (\r
+                           ImageContext->Handle,\r
+                           ImageContext->PeCoffHeaderOffset,\r
+                           &Size,\r
+                           Hdr.Pe32\r
+                           );\r
+  if (EFI_ERROR (Status)) {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Use Signature to figure out if we understand the image format\r
+  //\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    ImageContext->IsTeImage         = TRUE;\r
+    ImageContext->Machine           = Hdr.Te->Machine;\r
+    ImageContext->ImageType         = (UINT16)(Hdr.Te->Subsystem);\r
+    ImageContext->ImageSize         = 0;\r
+    ImageContext->SectionAlignment  = 4096;\r
+    ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;\r
+\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {\r
+    ImageContext->IsTeImage         = FALSE;\r
+    ImageContext->Machine           = Hdr.Pe32->FileHeader.Machine;\r
+    \r
+    //\r
+    // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.\r
+    //       It is for backward-compatibility consideration, because\r
+    //       some system will generate PE32+ image with PE32 Magic.\r
+    //\r
+    if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else {\r
+      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
+    }\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ||\r
+        Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+      //\r
+      // PE32 and PE32+ have the same offset for these fields.\r
+      // We use PE32 for both PE32 and PE32+ headers here.\r
+      //\r
+      ImageContext->ImageType         = Hdr.Pe32->OptionalHeader.Subsystem;\r
+      ImageContext->ImageSize         = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;\r
+      ImageContext->SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;\r
+      ImageContext->SizeOfHeaders     = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
+\r
+    } else {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
+      return EFI_UNSUPPORTED;    \r
+    }\r
+  } else {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) {\r
+    //\r
+    // If the PE/COFF loader does not support the image type return\r
+    // unsupported. This library can suport lots of types of images\r
+    // this does not mean the user of this library can call the entry\r
+    // point of the image. \r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+PeCoffLoaderCheckImageType (\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Checks the PE or TE header of a PE/COFF or TE image to determine if it supported\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS if the PE/COFF or TE image is supported\r
+  EFI_UNSUPPORTED of the PE/COFF or TE image is not supported.\r
+\r
+--*/\r
+{\r
+  switch (ImageContext->ImageType) {\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
+    ImageContext->ImageCodeMemoryType = EfiLoaderCode;\r
+    ImageContext->ImageDataMemoryType = EfiLoaderData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiBootServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiBootServicesData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
+  case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiRuntimeServicesData;\r
+    break;\r
+\r
+  default:\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetImageInfo (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves information on a PE/COFF image\r
+\r
+Arguments:\r
+\r
+  This          - Calling context\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS if the information on the PE/COFF image was collected.\r
+  EFI_UNSUPPORTED of the PE/COFF image is not supported.\r
+  Otherwise, the error status from reading the PE/COFF image using the \r
+    ImageContext->ImageRead() function\r
+\r
+  EFI_INVALID_PARAMETER   - ImageContext is NULL.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_UNION       HdrData;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DebugDirectoryEntry;\r
+  UINTN                                 Size;\r
+  UINTN                                 Index;\r
+  UINTN                                 DebugDirectoryEntryRva;\r
+  UINTN                                 DebugDirectoryEntryFileOffset;\r
+  UINTN                                 SectionHeaderOffset;\r
+  EFI_IMAGE_SECTION_HEADER              SectionHeader;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       DebugEntry;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  if (NULL == ImageContext) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError  = EFI_IMAGE_ERROR_SUCCESS;\r
+\r
+  Hdr.Union = &HdrData;\r
+  Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Verify machine type\r
+  //\r
+  Status = PeCoffLoaderCheckImageType (ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+\r
+  //\r
+  // Retrieve the base address of the image\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+       \r
+    //\r
+    // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.\r
+    //       It is for backward-compatibility consideration, because\r
+    //       some system will generate PE32+ image with PE32 Magic.\r
+    //\r
+    if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else {\r
+      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
+    }\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase;\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase;\r
+    }\r
+  } else {\r
+    ImageContext->ImageAddress = (EFI_PHYSICAL_ADDRESS)(Hdr.Te->ImageBase);\r
+  }\r
+\r
+  //\r
+  // Initialize the alternate destination address to 0 indicating that it\r
+  // should not be used.\r
+  //\r
+  ImageContext->DestinationAddress = 0;\r
+\r
+  //\r
+  // Initialize the codeview pointer.\r
+  //\r
+  ImageContext->CodeView    = NULL;\r
+  ImageContext->PdbPointer  = NULL;\r
+\r
+  //\r
+  // Three cases with regards to relocations:\r
+  // - Image has base relocs, RELOCS_STRIPPED==0    => image is relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but\r
+  //   has no base relocs to apply\r
+  // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.\r
+  //\r
+  // Look at the file header to determine if relocations have been stripped, and\r
+  // save this info in the image context for later use.\r
+  //\r
+  if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {\r
+    ImageContext->RelocationsStripped = TRUE;\r
+  } else {\r
+    ImageContext->RelocationsStripped = FALSE;\r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    //\r
+    // Use PE32 to access fields that have same offset in PE32 and PE32+\r
+    //\r
+    ImageContext->ImageSize         = (UINT64) Hdr.Pe32->OptionalHeader.SizeOfImage;\r
+    ImageContext->SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;\r
+    ImageContext->SizeOfHeaders     = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //     \r
+      // Use PE32 offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    } else {\r
+      //     \r
+      // Use PE32+ offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+    }    \r
+    \r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+\r
+      DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;\r
+\r
+      //\r
+      // Determine the file offset of the debug directory...  This means we walk\r
+      // the sections to find which section contains the RVA of the debug\r
+      // directory\r
+      //\r
+      DebugDirectoryEntryFileOffset = 0;\r
+\r
+      SectionHeaderOffset = (UINTN)(\r
+                               ImageContext->PeCoffHeaderOffset +\r
+                               sizeof (UINT32) + \r
+                               sizeof (EFI_IMAGE_FILE_HEADER) + \r
+                               Hdr.Pe32->FileHeader.SizeOfOptionalHeader\r
+                               );\r
+\r
+      for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {\r
+        //\r
+        // Read section header from file\r
+        //\r
+        Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 SectionHeaderOffset,\r
+                                 &Size,\r
+                                 &SectionHeader\r
+                                 );\r
+        if (EFI_ERROR (Status)) {\r
+          ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+            DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+\r
+          DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;\r
+          break;\r
+        }\r
+\r
+        SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      }\r
+\r
+      if (DebugDirectoryEntryFileOffset != 0) {\r
+        for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
+          //\r
+          // Read next debug directory entry\r
+          //\r
+          Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+          Status = ImageContext->ImageRead (\r
+                                   ImageContext->Handle,\r
+                                   DebugDirectoryEntryFileOffset,\r
+                                   &Size,\r
+                                   &DebugEntry\r
+                                   );\r
+          if (EFI_ERROR (Status)) {\r
+            ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+            return Status;\r
+          }\r
+\r
+          if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+            ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
+            if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {\r
+              ImageContext->ImageSize += DebugEntry.SizeOfData;\r
+            }\r
+\r
+            return EFI_SUCCESS;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+    //\r
+    // Because Te image only extracts base relocations and debug directory entries from\r
+    // Pe image and in Te image header there is not a field to describe the imagesize,\r
+    // we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize\r
+    //\r
+    ImageContext->ImageSize         = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);\r
+    ImageContext->SectionAlignment  = 4096;\r
+    ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;\r
+\r
+    DebugDirectoryEntry             = &Hdr.Te->DataDirectory[1];\r
+    DebugDirectoryEntryRva          = DebugDirectoryEntry->VirtualAddress;\r
+    SectionHeaderOffset             = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER));\r
+\r
+    DebugDirectoryEntryFileOffset   = 0;\r
+\r
+    for (Index = 0; Index < Hdr.Te->NumberOfSections; Index++) {\r
+      //\r
+      // Read section header from file\r
+      //\r
+      Size   = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      Status = ImageContext->ImageRead (\r
+                               ImageContext->Handle,\r
+                               SectionHeaderOffset,\r
+                               &Size,\r
+                               &SectionHeader\r
+                               );\r
+      if (EFI_ERROR (Status)) {\r
+        ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+\r
+      if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+          DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+        DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -\r
+                                        SectionHeader.VirtualAddress +\r
+                                        SectionHeader.PointerToRawData +\r
+                                        sizeof (EFI_TE_IMAGE_HEADER) -\r
+                                        Hdr.Te->StrippedSize;\r
+        break;\r
+      }\r
+\r
+      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+    }\r
+\r
+    if (DebugDirectoryEntryFileOffset != 0) {\r
+      for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
+        //\r
+        // Read next debug directory entry\r
+        //\r
+        Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 DebugDirectoryEntryFileOffset,\r
+                                 &Size,\r
+                                 &DebugEntry\r
+                                 );\r
+        if (EFI_ERROR (Status)) {\r
+          ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+          ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
+          return EFI_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID *\r
+PeCoffLoaderImageAddress (\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  IN     UINTN                                 Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts an image address to the loaded address\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+  Address       - The address to be converted to the loaded address\r
+\r
+Returns:\r
+\r
+  NULL if the address can not be converted, otherwise, the converted address\r
+\r
+--*/\r
+{\r
+  if (Address >= ImageContext->ImageSize) {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return NULL;\r
+  }\r
+\r
+  return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderRelocateImage (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Relocates a PE/COFF image in memory\r
+\r
+Arguments:\r
+\r
+  This         - Calling context\r
+\r
+  ImageContext - Contains information on the loaded image to relocate\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      if the PE/COFF image was relocated\r
+  EFI_LOAD_ERROR   if the image is not a valid PE/COFF image\r
+  EFI_UNSUPPORTED  not support\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *RelocDir;\r
+  UINT64                                Adjust;\r
+  EFI_IMAGE_BASE_RELOCATION             *RelocBase;\r
+  EFI_IMAGE_BASE_RELOCATION             *RelocBaseEnd;\r
+  UINT16                                *Reloc;\r
+  UINT16                                *RelocEnd;\r
+  CHAR8                                 *Fixup;\r
+  CHAR8                                 *FixupBase;\r
+  UINT16                                *F16;\r
+  UINT32                                *F32;  \r
+  UINT64                                *F64;\r
+  CHAR8                                 *FixupData;\r
+  EFI_PHYSICAL_ADDRESS                  BaseAddress;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+#ifdef EFI_NT_EMULATOR\r
+  VOID                                  *DllEntryPoint;\r
+  VOID                                  *ModHandle;\r
+\r
+  ModHandle = NULL;\r
+#endif\r
+\r
+  if (NULL == ImageContext) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // If there are no relocation entries, then we are done\r
+  //\r
+  if (ImageContext->RelocationsStripped) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // If the destination address is not 0, use that rather than the\r
+  // image address as the relocation target.\r
+  //\r
+  if (ImageContext->DestinationAddress != 0) {\r
+    BaseAddress = ImageContext->DestinationAddress;\r
+  } else {\r
+    BaseAddress = ImageContext->ImageAddress;\r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+    \r
+    //\r
+    // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.\r
+    //       It is for backward-compatibility consideration, because\r
+    //       some system will generate PE32+ image with PE32 Magic.\r
+    //\r
+    if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else {\r
+      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
+    }\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;\r
+      Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;\r
+  \r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      RelocDir  = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase;\r
+      Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;\r
+\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      RelocDir  = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    }\r
+\r
+    //\r
+    // Find the relocation block\r
+    // Per the PE/COFF spec, you can't assume that a given data directory\r
+    // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+    // the optional header to verify a desired directory entry is there.\r
+    //\r
+\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
+      RelocBaseEnd = PeCoffLoaderImageAddress (\r
+                      ImageContext,\r
+                      RelocDir->VirtualAddress + RelocDir->Size - 1\r
+                      );\r
+    } else {\r
+      //\r
+      // Set base and end to bypass processing below.\r
+      //\r
+      RelocBase = RelocBaseEnd = 0;\r
+    }\r
+  } else {\r
+    Hdr.Te             = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
+    Adjust             = (UINT64) (BaseAddress - Hdr.Te->ImageBase);\r
+    Hdr.Te->ImageBase  = (UINT64) (BaseAddress);\r
+\r
+    //\r
+    // Find the relocation block\r
+    //\r
+    RelocDir = &Hdr.Te->DataDirectory[0];\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
+                                    ImageContext->ImageAddress + \r
+                                    RelocDir->VirtualAddress +\r
+                                    sizeof(EFI_TE_IMAGE_HEADER) - \r
+                                    Hdr.Te->StrippedSize\r
+                                    );\r
+    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+  }\r
+  \r
+  //\r
+  // Run the relocation information and apply the fixups\r
+  //\r
+  FixupData = ImageContext->FixupData;\r
+  while (RelocBase < RelocBaseEnd) {\r
+\r
+    Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\r
+    RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
+    if (!(ImageContext->IsTeImage)) {\r
+      FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
+    } else {\r
+      FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
+                    RelocBase->VirtualAddress +\r
+                    sizeof(EFI_TE_IMAGE_HEADER) - \r
+                    Hdr.Te->StrippedSize\r
+                    );\r
+    }\r
+\r
+    if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||\r
+        (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + \r
+          (UINTN)ImageContext->ImageSize)) {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;\r
+      return EFI_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Run this relocation record\r
+    //\r
+    while (Reloc < RelocEnd) {\r
+\r
+      Fixup = FixupBase + (*Reloc & 0xFFF);\r
+      switch ((*Reloc) >> 12) {\r
+      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGH:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16  = (UINT16) (*F16 + (UINT16)(((UINT32)Adjust) >> 16));\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_LOW:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16  = (UINT16) (*F16 + (UINT16) Adjust);\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
+        F32   = (UINT32 *) Fixup;\r
+        *F32  = *F32 + (UINT32) Adjust;\r
+        if (FixupData != NULL) {\r
+          FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));\r
+          *(UINT32 *) FixupData = *F32;\r
+          FixupData             = FixupData + sizeof (UINT32);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_DIR64:\r
+        //\r
+        // For X64 and IPF\r
+        //\r
+        F64 = (UINT64 *) Fixup;\r
+        *F64 = *F64 + (UINT64) Adjust;\r
+        if (FixupData != NULL) {\r
+          FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));\r
+          *(UINT64 *)(FixupData) = *F64;\r
+          FixupData = FixupData + sizeof(UINT64);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHADJ:\r
+        //\r
+        // Return the same EFI_UNSUPPORTED return code as\r
+        // PeCoffLoaderRelocateImageEx() returns if it does not recognize\r
+        // the relocation type.\r
+        //\r
+        ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;\r
+        return EFI_UNSUPPORTED;\r
+\r
+      default:\r
+        //\r
+        // The common code does not handle some of the stranger IPF relocations\r
+        // PeCoffLoaderRelocateImageEx () addes support for these complex fixups\r
+        // on IPF and is a No-Op on other archtiectures.\r
+        //\r
+        Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);\r
+        if (EFI_ERROR (Status)) {\r
+          ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;\r
+          return Status;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Next relocation record\r
+      //\r
+      Reloc += 1;\r
+    }\r
+\r
+    //\r
+    // Next reloc block\r
+    //\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
+  }\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+  DllEntryPoint           = NULL;\r
+  ImageContext->ModHandle = NULL;\r
+  //\r
+  // Load the DLL if it's not an EBC image.\r
+  //\r
+  if ((ImageContext->PdbPointer != NULL) && \r
+      (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) {\r
+    Status = mPeCoffLoaderWinNtLoadAsDll->Entry (\r
+                                            ImageContext->PdbPointer,\r
+                                            &DllEntryPoint,\r
+                                            &ModHandle\r
+                                            );\r
+\r
+    if (!EFI_ERROR (Status) && DllEntryPoint != NULL) {\r
+      ImageContext->EntryPoint  = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;\r
+      ImageContext->ModHandle   = ModHandle;\r
+    }\r
+  }\r
+#endif\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLoadImage (\r
+  IN     EFI_PEI_PE_COFF_LOADER_PROTOCOL       *This,\r
+  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Loads a PE/COFF image into memory\r
+\r
+Arguments:\r
+\r
+  This         - Calling context\r
+\r
+  ImageContext - Contains information on image to load into memory\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            if the PE/COFF image was loaded\r
+  EFI_BUFFER_TOO_SMALL   if the caller did not provide a large enough buffer\r
+  EFI_LOAD_ERROR         if the image is a runtime driver with no relocations\r
+  EFI_INVALID_PARAMETER  if the image address is invalid\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  CheckContext;\r
+  EFI_IMAGE_SECTION_HEADER              *FirstSection;\r
+  EFI_IMAGE_SECTION_HEADER              *Section;\r
+  UINTN                                 NumberOfSections;\r
+  UINTN                                 Index;\r
+  CHAR8                                 *Base;\r
+  CHAR8                                 *End;\r
+  CHAR8                                 *MaxEnd;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
+  UINTN                                 Size;\r
+  UINT32                                TempDebugEntryRva;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  if (NULL == ImageContext) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // Copy the provided context info into our local version, get what we\r
+  // can from the original image, and then use that to make sure everything\r
+  // is legit.\r
+  //\r
+  CopyMem (&CheckContext, ImageContext, sizeof (EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT));\r
+\r
+  Status = PeCoffLoaderGetImageInfo (This, &CheckContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure there is enough allocated space for the image being loaded\r
+  //\r
+  if (ImageContext->ImageSize < CheckContext.ImageSize) {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+  if (ImageContext->ImageAddress == 0) {\r
+    //\r
+    // Image cannot be loaded into 0 address.\r
+    //\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // If there's no relocations, then make sure it's not a runtime driver,\r
+  // and that it's being loaded at the linked address.\r
+  //\r
+  if (CheckContext.RelocationsStripped) {\r
+    //\r
+    // If the image does not contain relocations and it is a runtime driver\r
+    // then return an error.\r
+    //\r
+    if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+      return EFI_LOAD_ERROR;\r
+    }\r
+    //\r
+    // If the image does not contain relocations, and the requested load address\r
+    // is not the linked address, then return an error.\r
+    //\r
+    if (CheckContext.ImageAddress != ImageContext->ImageAddress) {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Make sure the allocated space has the proper section alignment\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Read the entire PE/COFF or TE header into memory\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (VOID *) (UINTN) ImageContext->ImageAddress\r
+                            );\r
+\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      ImageContext->PeCoffHeaderOffset +\r
+                      sizeof(UINT32) + \r
+                      sizeof(EFI_IMAGE_FILE_HEADER) + \r
+                      Hdr.Pe32->FileHeader.SizeOfOptionalHeader\r
+      );\r
+    NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);\r
+  } else {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (VOID *)(UINTN)ImageContext->ImageAddress\r
+                            );\r
+\r
+    Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      sizeof(EFI_TE_IMAGE_HEADER)\r
+                      );\r
+    NumberOfSections  = (UINTN) (Hdr.Te->NumberOfSections);\r
+\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+    return EFI_LOAD_ERROR;\r
+  }\r
+\r
+  //\r
+  // Load each section of the image\r
+  //\r
+  Section = FirstSection;\r
+  for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {\r
+\r
+    //\r
+    // Compute sections address\r
+    //\r
+    Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);\r
+    End = PeCoffLoaderImageAddress (\r
+            ImageContext,\r
+            Section->VirtualAddress + Section->Misc.VirtualSize - 1\r
+            );\r
+    if (ImageContext->IsTeImage) {\r
+      Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);\r
+      End  = (CHAR8 *)((UINTN) End +  sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);\r
+    }\r
+\r
+    if (End > MaxEnd) {\r
+      MaxEnd = End;\r
+    }\r
+    //\r
+    // If the base start or end address resolved to 0, then fail.\r
+    //\r
+    if ((Base == NULL) || (End == NULL)) {\r
+      ImageContext->ImageError = EFI_IMAGE_ERROR_SECTION_NOT_LOADED;\r
+      return EFI_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Read the section\r
+    //\r
+    Size = (UINTN) Section->Misc.VirtualSize;\r
+    if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
+      Size = (UINTN) Section->SizeOfRawData;\r
+    }\r
+\r
+    if (Section->SizeOfRawData) {\r
+      if (!(ImageContext->IsTeImage)) {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      } else {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      }\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+    }\r
+\r
+    //\r
+    // If raw size is less then virt size, zero fill the remaining\r
+    //\r
+\r
+    if (Size < Section->Misc.VirtualSize) {\r
+      ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);\r
+    }\r
+\r
+    //\r
+    // Next Section\r
+    //\r
+    Section += 1;\r
+  }\r
+\r
+  Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+\r
+  //\r
+  // Get image's entry point\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+\r
+    //\r
+    // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.\r
+    //       It is for backward-compatibility consideration, because\r
+    //       some system will generate PE32+ image with PE32 Magic.\r
+    //\r
+    if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+    } else {\r
+      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
+    }\r
+\r
+    //\r
+    // Sizes of AddressOfEntryPoint are different so we need to do this safely\r
+    //\r
+    ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (\r
+                                                              ImageContext,\r
+                                                              (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint\r
+                                                              );\r
+\r
+  } else {\r
+    ImageContext->EntryPoint =  (EFI_PHYSICAL_ADDRESS) (\r
+                                (UINTN)ImageContext->ImageAddress  +\r
+                                (UINTN)Hdr.Te->AddressOfEntryPoint +\r
+                                (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                (UINTN)Hdr.Te->StrippedSize\r
+                                );\r
+  }\r
+\r
+  //\r
+  // Determine the size of the fixup data\r
+  //\r
+  // Per the PE/COFF spec, you can't assume that a given data directory\r
+  // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+  // the optional header to verify a desired directory entry is there.\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+    }\r
\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+    } else {\r
+      ImageContext->FixupDataSize = 0;\r
+    }\r
+  } else {\r
+    DirectoryEntry              = &Hdr.Te->DataDirectory[0];\r
+    ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+  }\r
+  //\r
+  // Consumer must allocate a buffer for the relocation fixup log.\r
+  // Only used for runtime drivers.\r
+  //\r
+  ImageContext->FixupData = NULL;\r
+\r
+  //\r
+  // Load the Codeview info if present\r
+  //\r
+  if (ImageContext->DebugDirectoryEntryRva != 0) {\r
+    if (!(ImageContext->IsTeImage)) {\r
+      DebugEntry = PeCoffLoaderImageAddress (\r
+                    ImageContext,\r
+                    ImageContext->DebugDirectoryEntryRva\r
+                    );\r
+    } else {\r
+      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(\r
+                      ImageContext->ImageAddress +\r
+                      ImageContext->DebugDirectoryEntryRva +\r
+                      sizeof(EFI_TE_IMAGE_HEADER) -\r
+                      Hdr.Te->StrippedSize\r
+                      );\r
+    }\r
+\r
+    if (DebugEntry != NULL) {\r
+      TempDebugEntryRva = DebugEntry->RVA;\r
+      if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {\r
+        Section--;\r
+        if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;\r
+        } else {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;\r
+        }\r
+      }\r
+\r
+      if (TempDebugEntryRva != 0) {\r
+        if (!(ImageContext->IsTeImage)) {\r
+          ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);\r
+        } else {\r
+          ImageContext->CodeView = (VOID *)(\r
+                                    (UINTN)ImageContext->ImageAddress +\r
+                                    (UINTN)TempDebugEntryRva +\r
+                                    (UINTN)sizeof (EFI_TE_IMAGE_HEADER) -\r
+                                    (UINTN) Hdr.Te->StrippedSize\r
+                                    );\r
+        }\r
+\r
+        if (ImageContext->CodeView == NULL) {\r
+          ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+          return EFI_LOAD_ERROR;\r
+        }\r
+\r
+        if (DebugEntry->RVA == 0) {\r
+          Size = DebugEntry->SizeOfData;\r
+          if (!(ImageContext->IsTeImage)) {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+          } else {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+            //\r
+            // Should we apply fix up to this field according to the size difference between PE and TE?\r
+            // Because now we maintain TE header fields unfixed, this field will also remain as they are\r
+            // in original PE image.\r
+            //\r
+          }\r
+\r
+          if (EFI_ERROR (Status)) {\r
+            ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;\r
+            return EFI_LOAD_ERROR;\r
+          }\r
+\r
+          DebugEntry->RVA = TempDebugEntryRva;\r
+        }\r
+\r
+        switch (*(UINT32 *) ImageContext->CodeView) {\r
+        case CODEVIEW_SIGNATURE_NB10:\r
+          ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+          break;\r
+\r
+        case CODEVIEW_SIGNATURE_RSDS:\r
+          ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+          break;\r
+\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)\r
+  AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));\r
+#endif\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderUnloadImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Unload a PE/COFF image from memory\r
+\r
+Arguments:\r
+\r
+  ImageContext - Contains information on image to load into memory\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            \r
+\r
+--*/\r
+{\r
+#ifdef EFI_NT_EMULATOR\r
+  //\r
+  // Calling Win32 API free library\r
+  //\r
+  mPeCoffLoaderWinNtLoadAsDll->FreeLibrary (ImageContext->ModHandle);\r
+\r
+#endif\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
new file mode 100644 (file)
index 0000000..c2d5bb3
--- /dev/null
@@ -0,0 +1,648 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiLib.c\r
+\r
+Abstract:\r
+\r
+  PEI Library Functions\r
\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PeiHob.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  );\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to zero for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT8  *Ptr;\r
+\r
+  Ptr = Buffer;\r
+  while (Size--) {\r
+    *(Ptr++) = 0;\r
+  }\r
+}\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+\r
+  Destination8  = Destination;\r
+  Source8       = Source;\r
+  if (((Source8 + Length) <= Destination8) || (Source8 >= Destination8)) {\r
+    while (Length--) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  } else {\r
+    while (Length--) {\r
+      *(Destination8 + Length) = *(Source8 + Length);\r
+    }\r
+  }\r
+}\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+\r
+  Destination8  = Destination;\r
+  Source8       = Source;\r
+  if (((Source8 + Length) <= Destination8) || (Source8 >= Destination8)) {\r
+    while (Length--) {\r
+      *(Destination8++) = *(Source8++);\r
+    }\r
+  } else {\r
+    while (Length--) {\r
+      *(Destination8 + Length) = *(Source8 + Length);\r
+    }\r
+  }\r
+}\r
+\r
+\r
+BOOLEAN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares two GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  = TRUE  if Guid1 == Guid2\r
+  = FALSE if Guid1 != Guid2 \r
+\r
+--*/\r
+{\r
+  if ((((INT32 *) Guid1)[0] - ((INT32 *) Guid2)[0]) == 0) {\r
+    if ((((INT32 *) Guid1)[1] - ((INT32 *) Guid2)[1]) == 0) {\r
+      if ((((INT32 *) Guid1)[2] - ((INT32 *) Guid2)[2]) == 0) {\r
+        if ((((INT32 *) Guid1)[3] - ((INT32 *) Guid2)[3]) == 0) {\r
+          return TRUE;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+VOID *\r
+EFIAPI\r
+ScanGuid (\r
+  IN VOID        *Buffer,\r
+  IN UINTN       Length,\r
+  IN EFI_GUID    *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
+  in the target buffer.\r
+\r
+  This function searches target the buffer specified by Buffer and Length from\r
+  the lowest address to the highest address at 128-bit increments for the 128-bit\r
+  GUID value that matches Guid.  If a match is found, then a pointer to the matching\r
+  GUID in the target buffer is returned.  If no match is found, then NULL is returned.\r
+  If Length is 0, then NULL is returned.\r
+  If Length > 0 and Buffer is NULL, then ASSERT().\r
+  If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+  If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+  If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). \r
+\r
+Arguments:\r
+\r
+  Buffer - Pointer to the target buffer to scan.\r
+  Length - Number of bytes in Buffer to scan.\r
+  Guid   - Value to search for in the target buffer.\r
+  \r
+Returns:\r
+  A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
+--*/\r
+{\r
+  EFI_GUID                 *GuidPtr;\r
+  EFI_PEI_SERVICES         **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  PEI_ASSERT(PeiServices, (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0));\r
+  PEI_ASSERT(PeiServices, (Length <= (EFI_MAX_ADDRESS - (UINTN)Buffer + 1)));\r
+  PEI_ASSERT(PeiServices, ((Length & (sizeof (*GuidPtr) - 1)) == 0));\r
+\r
+  GuidPtr = (EFI_GUID*)Buffer;\r
+  Buffer  = GuidPtr + Length / sizeof (*GuidPtr);\r
+  while (GuidPtr < (EFI_GUID*)Buffer) {\r
+    if (CompareGuid (GuidPtr, Guid)) {\r
+      return (VOID*)GuidPtr;\r
+    }\r
+    GuidPtr++;\r
+  }\r
+  return NULL;\r
+}\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+InvalidateInstructionCacheRange (\r
+  IN      VOID                      *Address,\r
+  IN      UINTN                     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Invalidates a range of instruction cache lines in the cache coherency domain\r
+  of the calling CPU.\r
+\r
+  Invalidates the instruction cache lines specified by Address and Length. If\r
+  Address is not aligned on a cache line boundary, then entire instruction\r
+  cache line containing Address is invalidated. If Address + Length is not\r
+  aligned on a cache line boundary, then the entire instruction cache line\r
+  containing Address + Length -1 is invalidated. This function may choose to\r
+  invalidate the entire instruction cache if that is more efficient than\r
+  invalidating the specified range. If Length is 0, the no instruction cache\r
+  lines are invalidated. Address is returned.\r
+\r
+  If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().\r
+\r
+Arguments:\r
+\r
+  Address   -     The base address of the instruction cache lines to\r
+                  invalidate. If the CPU is in a physical addressing mode, then\r
+                  Address is a physical address. If the CPU is in a virtual\r
+                  addressing mode, then Address is a virtual address.\r
+\r
+  Length    -      The number of bytes to invalidate from the instruction cache.\r
+\r
+ Returns:\r
+  Address\r
+\r
+**/\r
+{\r
+  PEI_ASSERT(GetPeiServicesTablePointer() , (Length <= EFI_MAX_ADDRESS - (UINTN)Address + 1));\r
+  return Address;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindNextVolume.\r
+\r
+Arguments:\r
+\r
+  Instance     - The Fv Volume Instance.\r
+  VolumeHandle - Pointer to the current Fv Volume to search.\r
+\r
+Returns:\r
+  EFI_STATUS\r
+  \r
+--*/\r
+  \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          FwVolHeader,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindNextFile.\r
+\r
+Arguments:\r
+\r
+  SearchType   - Filter to find only file of this type.\r
+  FwVolHeader  - Pointer to the current FV to search.\r
+  FileHandle   - Pointer to the file matching SearchType in FwVolHeader.\r
+                - NULL if file not found\r
+\r
+Returns:\r
+  EFI_STATUS\r
+  \r
+--*/  \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindFileByName (\r
+  IN  EFI_GUID              *FileName,\r
+  IN  EFI_PEI_FV_HANDLE     VolumeHandle,\r
+  OUT EFI_PEI_FILE_HANDLE   *FileHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindFileByName.\r
+\r
+Arguments:\r
+\r
+  FileName      - File name to search.\r
+  VolumeHandle  - The current FV to search.\r
+  FileHandle    - Pointer to the file matching name in VolumeHandle.\r
+                - NULL if file not found\r
+\r
+Returns:\r
+   EFI_STATUS\r
+   \r
+--*/  \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_FFS_FILE_HEADER        *FfsFileHeader,\r
+  IN OUT VOID                   **SectionData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsFindSectionData.\r
+\r
+Arguments:\r
+\r
+  SearchType      - Filter to find only sections of this type.\r
+  FileHandle      - Pointer to the current file to search.\r
+  SectionData     - Pointer to the Section matching SectionType in FfsFileHeader.\r
+                  - NULL if section not found\r
+\r
+Returns:\r
+  EFI_STATUS\r
+--*/\r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLibFfsGetVolumeInfo (\r
+  IN EFI_PEI_FV_HANDLE  *VolumeHandle,\r
+  OUT EFI_FV_INFO       *VolumeInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function FfsGetVolumeInfo.\r
+\r
+Arguments:\r
+\r
+  VolumeHandle    - The handle to Fv Volume.\r
+  VolumeInfo      - The pointer to volume information.\r
+  \r
+Returns:\r
+  EFI_STATUS\r
+--*/  \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r
+}\r
+\r
+\r
+\r
+VOID\r
+EFIAPI\r
+BuildFvHob (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build FvHob.\r
+\r
+Arguments:\r
+\r
+  BaseAddress    - Fv base address.\r
+  Length         - Fv Length.\r
+\r
+Returns:\r
+  NONE.\r
+--*/  \r
+{\r
+\r
+  EFI_STATUS               Status;  \r
+  EFI_HOB_FIRMWARE_VOLUME  *Hob;\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+  PeiServices = GetPeiServicesTablePointer();\r
+\r
+  //\r
+  // Check FV Signature\r
+  //\r
+  PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r
+\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_FV,\r
+                             sizeof (EFI_HOB_FIRMWARE_VOLUME),\r
+                             &Hob\r
+                             );\r
+  Hob->BaseAddress = BaseAddress;\r
+  Hob->Length      = Length;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+BuildFvHob2 (\r
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN UINT64                      Length,\r
+  IN EFI_GUID                    *FvNameGuid,\r
+  IN EFI_GUID                    *FileNameGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build FvHob2.\r
+\r
+Arguments:\r
+\r
+  BaseAddress  - Fv base address.\r
+  Length       - Fv length.\r
+  FvNameGuid   - Fv name.\r
+  FileNameGuid - File name which contians encapsulated Fv.\r
+\r
+Returns:\r
+   NONE.\r
+--*/  \r
+{\r
+\r
+  EFI_STATUS               Status;  \r
+  EFI_HOB_FIRMWARE_VOLUME2  *Hob;\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+  PeiServices = GetPeiServicesTablePointer();\r
+\r
+  //\r
+  // Check FV Signature\r
+  //\r
+  PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);\r
+\r
+  Status = (*PeiServices)->CreateHob (\r
+                             PeiServices,\r
+                             EFI_HOB_TYPE_FV2,\r
+                             sizeof (EFI_HOB_FIRMWARE_VOLUME2),\r
+                             &Hob\r
+                             );\r
+  Hob->BaseAddress = BaseAddress;\r
+  Hob->Length      = Length;\r
+  CopyMem ((VOID*)&Hob->FvName, FvNameGuid, sizeof(EFI_GUID));\r
+  CopyMem ((VOID*)&Hob->FileName, FileNameGuid, sizeof(EFI_GUID));\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN EFI_GUID                   *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The wrapper of Pei Core Service function LocatePpi.\r
+\r
+Arguments:\r
+\r
+  Guid          - Pointer to GUID of the PPI.\r
+  Instance      - Instance Number to discover.\r
+  PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r
+                returns a pointer to the descriptor (includes flags, etc)\r
+  Ppi           - Pointer to reference the found PPI\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS   if the PPI is in the database           \r
+            EFI_NOT_FOUND if the PPI is not in the database\r
+--*/  \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+  \r
+  PeiServices = GetPeiServicesTablePointer();\r
+  return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r
+}\r
+\r
+\r
+VOID \r
+EFIAPI\r
+BuildGuidDataHob (\r
+  IN EFI_GUID                   *Guid,\r
+  IN VOID                        *Data,\r
+  IN UINTN                       DataLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build Guid data Hob.\r
+\r
+Arguments:\r
+\r
+  Guid        - guid to build data hob.\r
+  Data        - data to build data hob.\r
+  DataLength  - the length of data.\r
+\r
+Returns:\r
+  NONE\r
+--*/  \r
+{\r
+  VOID              *HobData;\r
+  EFI_HOB_GUID_TYPE *Hob;\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+  PeiServices = GetPeiServicesTablePointer();\r
+  (*PeiServices)->CreateHob (\r
+                     PeiServices,\r
+                     EFI_HOB_TYPE_GUID_EXTENSION,\r
+                     (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength),\r
+                     &Hob\r
+                     );\r
+  CopyMem ((VOID*)&Hob->Name, (VOID*)Guid, sizeof(EFI_GUID));\r
+\r
+  HobData =  Hob + 1;\r
+\r
+  CopyMem (HobData, Data, DataLength);\r
+}\r
+\r
+\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate Memory.\r
+\r
+Arguments:\r
+\r
+  Pages - Pages to allocate.\r
+\r
+Returns:\r
+  = Address if successful to allocate memory. \r
+  = NULL    if fail to allocate memory.\r
+\r
+--*/  \r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Memory; \r
+  EFI_PEI_SERVICES      **PeiServices;\r
+\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  PeiServices = GetPeiServicesTablePointer();\r
+  Status = (*PeiServices)->AllocatePages (PeiServices, EfiBootServicesData, Pages, &Memory);\r
+  if (EFI_ERROR (Status)) {\r
+    Memory = 0;\r
+  }\r
+  return (VOID *) (UINTN) Memory;\r
+\r
+}\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf
new file mode 100644 (file)
index 0000000..b516841
--- /dev/null
@@ -0,0 +1,104 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    PeiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the PEI library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME         = PeiLib\r
+COMPONENT_TYPE    = LIBRARY\r
+\r
+[sources.common]\r
+  PeiLib.c\r
+  PeCoffLoader.c\r
+  Decompress.c\r
+  Debug.c\r
+  Hob\Hob.c\r
+  perf.c\r
+  print\print.c\r
+  print\print.h\r
+  FindFv.c\r
+\r
+[sources.ia32]\r
+#  ia32\Math.c\r
+  ia32\PeCoffLoaderEx.c\r
+  ia32\PeCoffLoaderEx.h\r
+  ia32\PerformancePrimitives.c\r
+  ia32\Processor.c\r
+  ia32\ProcessorAsms.Asm\r
+  ia32\SupportItpDebug.asm\r
+  ia32\efijump.h\r
+  ia32\ReadIdt.asm\r
+  ia32\WriteIdt.asm\r
+  ia32\PeiServicePointer.c\r
+\r
+[sources.x64]\r
+  x64\PeCoffLoaderEx.c\r
+  x64\PeCoffLoaderEx.h\r
+  x64\PerformancePrimitives.c\r
+  x64\Processor.c\r
+  x64\ProcessorAsms.Asm\r
+  x64\SupportItpDebug.asm\r
+  x64\efijump.h\r
+  x64\PeiServicePointer.c\r
+\r
+[sources.ipf]\r
+#  ipf\Math.c\r
+  ipf\PeCoffLoaderEx.c\r
+  ipf\PeCoffLoaderEx.h\r
+  ipf\PerformancePrimitives.s\r
+  ipf\Processor.c\r
+  ipf\EfiJump.h\r
+  ipf\SetJmp.s\r
+  ipf\Asm.h\r
+  ipf\PioFlush.s\r
+  ipf\SwitchStack.s\r
+  ipf\Ia_64Gen.h\r
+  ipf\HwAccess.s\r
+  ipf\PeiServicePointer.c\r
+  \r
+  \r
+[libraries.common]\r
+  EdkGuidLib\r
+  EfiCommonLib\r
+\r
+[libraries.ia32]\r
+  CpuIA32Lib\r
+\r
+[libraries.x64]\r
+  CpuIA32Lib\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include\r
+\r
+[includes.ia32.Nt32]\r
+  $(EDK_SOURCE)\Sample\Platform\Nt32\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c
new file mode 100644 (file)
index 0000000..cfc265e
--- /dev/null
@@ -0,0 +1,233 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Perf.c\r
+\r
+Abstract:\r
+\r
+  Support for performance primitives. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+#include "PeiHob.h"\r
+\r
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)\r
+\r
+//\r
+// Perfomance HOB data definitions\r
+//\r
+\r
+#define MAX_PEI_PERF_LOG_ENTRIES 28\r
+\r
+//\r
+// Prototype functions\r
+//  \r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  );\r
+\r
+\r
+VOID\r
+PeiPerfMeasure (\r
+  EFI_PEI_SERVICES              **PeiServices,\r
+  IN UINT16                     *Token,\r
+  IN EFI_FFS_FILE_HEADER        *FileHeader,\r
+  IN BOOLEAN                    EntryExit,\r
+  IN UINT64                     Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Log a timestamp count.\r
+\r
+Arguments:\r
+\r
+  PeiServices - Pointer to the PEI Core Services table\r
+  \r
+  Token       - Pointer to Token Name\r
+  \r
+  FileHeader  - Pointer to the file header\r
+\r
+  EntryExit   - Indicates start or stop measurement\r
+\r
+  Value       - The start time or the stop time\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                         Status;\r
+  EFI_HOB_GUID_TYPE                  *Hob;\r
+  EFI_HOB_GUID_DATA_PERFORMANCE_LOG  *PerfHobData;\r
+  PEI_PERFORMANCE_MEASURE_LOG_ENTRY  *Log;\r
+  EFI_PEI_PPI_DESCRIPTOR             *PerfHobDescriptor;\r
+  UINT64                             TimeCount;\r
+  INTN                               Index;\r
+  UINTN                              Index2;\r
+  EFI_GUID                           *Guid;\r
+  EFI_GUID                           *CheckGuid;\r
+\r
+  TimeCount = 0;\r
+  //\r
+  // Get the END time as early as possible to make it more accurate.\r
+  //\r
+  if (EntryExit) {\r
+    GetTimerValue (&TimeCount);\r
+  }\r
+\r
+  //\r
+  // Locate the Pei Performance Log Hob.\r
+  //\r
+  Status = (*PeiServices)->LocatePpi (\r
+                             PeiServices,\r
+                             &gEfiPeiPerformanceHobGuid,\r
+                             0,\r
+                             &PerfHobDescriptor,\r
+                             NULL\r
+                             );\r
+\r
+  //\r
+  // If the Performance Hob was not found, build and install one.\r
+  //\r
+  if (EFI_ERROR(Status)) {\r
+    Status = PeiBuildHobGuid (\r
+               PeiServices,\r
+               &gEfiPeiPerformanceHobGuid,\r
+               (sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG) +\r
+                 ((MAX_PEI_PERF_LOG_ENTRIES-1) * \r
+                 sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY)) +\r
+                 sizeof(EFI_PEI_PPI_DESCRIPTOR)\r
+               ),\r
+               &Hob\r
+               );\r
+    ASSERT_PEI_ERROR(PeiServices, Status);\r
+\r
+    PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(Hob+1);\r
+    PerfHobData->NumberOfEntries = 0;\r
+\r
+    PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(PerfHobData+1) +\r
+                                                     (sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) *\r
+                                                       (MAX_PEI_PERF_LOG_ENTRIES-1)\r
+                                                     )\r
+                                                  );\r
+    PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);\r
+    PerfHobDescriptor->Guid = &gEfiPeiPerformanceHobGuid;\r
+    PerfHobDescriptor->Ppi = NULL;\r
+\r
+    (*PeiServices)->InstallPpi (\r
+                      PeiServices,\r
+                      PerfHobDescriptor\r
+                      );\r
+  }\r
+\r
+  PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(((UINT8 *)(PerfHobDescriptor)) -\r
+                                                        ((sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) *\r
+                                                           (MAX_PEI_PERF_LOG_ENTRIES-1)\r
+                                                         )\r
+                                                         + sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG)\r
+                                                      )\r
+                                                     );\r
+\r
+  if (PerfHobData->NumberOfEntries >= MAX_PEI_PERF_LOG_ENTRIES) {\r
+    return;\r
+  }\r
+\r
+  if (!EntryExit) {\r
+    Log = &(PerfHobData->Log[PerfHobData->NumberOfEntries]);\r
+    (*PeiServices)->SetMem (Log, sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY), 0);\r
+\r
+    //\r
+    // If not NULL pointer, copy the file name\r
+    //\r
+    if (FileHeader != NULL) {\r
+      Log->Name = FileHeader->Name;\r
+    }\r
+\r
+    //\r
+    // Copy the description string\r
+    //\r
+    (*PeiServices)->CopyMem (\r
+                      &(Log->DescriptionString), \r
+                      Token,\r
+                      (PEI_PERF_MAX_DESC_STRING-1) * sizeof(UINT16)\r
+                      );\r
+\r
+    //\r
+    // Get the start time as late as possible to make it more accurate.\r
+    //\r
+    GetTimerValue (&TimeCount);\r
+\r
+    //\r
+    // Record the time stamp.\r
+    //\r
+    if (Value != 0) {\r
+      Log->StartTimeCount = Value;\r
+    } else {\r
+      Log->StartTimeCount = TimeCount;\r
+    }\r
+    Log->StopTimeCount = 0;\r
+\r
+    //\r
+    // Increment the number of valid log entries.\r
+    //\r
+    PerfHobData->NumberOfEntries++;\r
+\r
+  } else {\r
+\r
+    for (Index = PerfHobData->NumberOfEntries-1; Index >= 0; Index--) {\r
+      Log = NULL;\r
+      for (Index2 = 0; Index2 < PEI_PERF_MAX_DESC_STRING; Index2++) {\r
+        if (PerfHobData->Log[Index].DescriptionString[Index2] == 0) {\r
+          Log = &(PerfHobData->Log[Index]);\r
+          break;\r
+        }\r
+        if (PerfHobData->Log[Index].DescriptionString[Index2] !=\r
+            Token[Index2]) {\r
+          break;\r
+        }\r
+      }\r
+      if (Log != NULL) {\r
+        if (FileHeader != NULL) {\r
+          Guid = &(Log->Name);\r
+          CheckGuid = &(FileHeader->Name);\r
+          if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&\r
+              (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&\r
+              (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&\r
+              (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3]))  {\r
+            if (Value != 0) {\r
+              Log->StopTimeCount = Value;\r
+            } else {\r
+             Log->StopTimeCount = TimeCount;\r
+            }\r
+            break;\r
+          }\r
+        } else {\r
+          if (Value != 0) {\r
+            Log->StopTimeCount = Value;\r
+          } else {\r
+           Log->StopTimeCount = TimeCount;\r
+          }\r
+          break;\r
+        }\r
+      }\r
+    }\r
+            \r
+  }\r
+\r
+  return;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c
new file mode 100644 (file)
index 0000000..458bb9c
--- /dev/null
@@ -0,0 +1,795 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  Basic Ascii AvSPrintf() function named AvSPrint(). AvSPrint() enables very\r
+  simple implemenation of debug prints.\r
+\r
+  You can not Print more than PEI_LIB_MAX_PRINT_BUFFER characters at a \r
+  time. This makes the implementation very simple.\r
+\r
+  AvSPrint format specification has the follwoing form\r
+\r
+  %[flags][width]type\r
+\r
+  flags:\r
+    '-' - Left justify\r
+    '+' - Prefix a sign\r
+    ' ' - Prefix a blank\r
+    ',' - Place commas in numberss\r
+    '0' - Prefix for width with zeros\r
+    'l' - UINT64\r
+    'L' - UINT64\r
+\r
+  width:\r
+    '*' - Get width from a UINTN argumnet from the argument list\r
+    Decimal number that represents width of print\r
+\r
+  type:\r
+    'X' - argument is a UINTN hex number, prefix '0'\r
+    'x' - argument is a hex number\r
+    'd' - argument is a decimal number\r
+    'a' - argument is an ascii string \r
+    'S', 's' - argument is an Unicode string\r
+    'g' - argument is a pointer to an EFI_GUID\r
+    't' - argument is a pointer to an EFI_TIME structure\r
+    'c' - argument is an ascii character\r
+    'r' - argument is EFI_STATUS\r
+    '%' - Print a %\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+#include "Print.h"\r
+\r
+STATIC\r
+CHAR8 *\r
+GetFlagsAndWidth (\r
+  IN  CHAR8       *Format, \r
+  OUT UINTN       *Flags, \r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+ValueToString (\r
+  IN  OUT CHAR8   *Buffer, \r
+  IN  INT64       Value, \r
+  IN  UINTN       Flags, \r
+  IN  UINTN       Width\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+ValueTomHexStr (\r
+  IN  OUT CHAR8   *Buffer, \r
+  IN  UINT64      Value, \r
+  IN  UINTN       Flags, \r
+  IN  UINTN       Width\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN OUT CHAR8  *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN  EFI_TIME  *Time,\r
+  IN OUT CHAR8  *Buffer,\r
+  IN  UINTN     BufferSize\r
+  );\r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR8       *Buffer,\r
+  IN  UINTN       BufferSize\r
+  );\r
+\r
+\r
+UINTN\r
+ASPrint (\r
+  OUT CHAR8         *Buffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  ASPrint function to process format and place the results in Buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer     - Ascii buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
+               limit.\r
+\r
+  Format - Ascii format string see file header for more details.\r
+\r
+  ...    - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  UINTN   Return;\r
+  VA_LIST Marker;\r
+\r
+  VA_START(Marker, Format);\r
+  Return = AvSPrint(Buffer, BufferSize, Format, Marker);\r
+  VA_END (Marker);\r
+  \r
+  return Return;\r
+}\r
+\r
+\r
+UINTN\r
+AvSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint function to process format and place the results in Buffer. Since a \r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
+                  no limit.\r
+\r
+  FormatString  - Ascii format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  CHAR8     TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR8     *Buffer;\r
+  CHAR8     *AsciiStr;\r
+  CHAR16    *UnicodeStr;\r
+  CHAR8     *Format;\r
+  UINTN     Index;\r
+  UINTN     Flags;\r
+  UINTN     Width;\r
+  UINTN     Count;\r
+  UINTN     BufferLeft;\r
+  UINT64    Value;\r
+  EFI_GUID  *TmpGUID;\r
+\r
+  //\r
+  // Process the format string. Stop if Buffer is over run.\r
+  //\r
+  Buffer              = StartOfBuffer;\r
+  Format              = (CHAR8 *) FormatString;\r
+  BufferLeft          = BufferSize;\r
+  for (Index = 0; (*Format != '\0') && (Index < BufferSize - 1); Format++) {\r
+    if (*Format != '%') {\r
+      if ((*Format == '\n') && (Index < BufferSize - 2)) {\r
+        //\r
+        // If carage return add line feed\r
+        //\r
+        Buffer[Index++] = '\r';\r
+        BufferLeft -= sizeof (CHAR8);\r
+      }\r
+\r
+      Buffer[Index++] = *Format;\r
+      BufferLeft -= sizeof (CHAR8);\r
+    } else {\r
+      \r
+      //\r
+      // Now it's time to parse what follows after %\r
+      //\r
+      Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);\r
+      switch (*Format) {\r
+      case 'X':\r
+        Flags |= PREFIX_ZERO;\r
+        Width = sizeof (UINT64) * 2;\r
+\r
+      //\r
+      // break skiped on purpose\r
+      //\r
+      case 'x':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        ValueTomHexStr (TempBuffer, Value, Flags, Width);\r
+        AsciiStr = TempBuffer;\r
+\r
+        for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) {\r
+          Buffer[Index++] = *AsciiStr;\r
+        }\r
+        break;\r
+\r
+      case 'd':\r
+        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
+          Value = VA_ARG (Marker, UINT64);\r
+        } else {\r
+          Value = (UINTN) VA_ARG (Marker, UINTN);\r
+        }\r
+\r
+        ValueToString (TempBuffer, Value, Flags, Width);\r
+        AsciiStr = TempBuffer;\r
+\r
+        for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) {\r
+          Buffer[Index++] = *AsciiStr;\r
+        }\r
+        break;\r
+\r
+      case 's':\r
+      case 'S':\r
+        UnicodeStr = (CHAR16 *) VA_ARG (Marker, CHAR8 *);\r
+        if (UnicodeStr == NULL) {\r
+          UnicodeStr = L"<null string>";\r
+        }\r
+\r
+        for (Count = 0; (*UnicodeStr != '\0') && (Index < BufferSize - 1); UnicodeStr++, Count++) {\r
+          Buffer[Index++] = (CHAR8) *UnicodeStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (; (Count < Width) && (Index < BufferSize - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+\r
+        break;\r
+\r
+      case 'a':\r
+        AsciiStr = (CHAR8 *) VA_ARG (Marker, CHAR8 *);\r
+        if (AsciiStr == NULL) {\r
+          AsciiStr = "<null string>";\r
+        }\r
+\r
+        for (Count = 0; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++, Count++) {\r
+          Buffer[Index++] = *AsciiStr;\r
+        }\r
+        //\r
+        // Add padding if needed\r
+        //\r
+        for (; (Count < Width) && (Index < BufferSize - 1); Count++) {\r
+          Buffer[Index++] = ' ';\r
+        }\r
+        break;\r
+\r
+      case 'c':\r
+        Buffer[Index++] = (CHAR8) VA_ARG (Marker, UINTN);\r
+        break;\r
+\r
+      case 'g':\r
+        TmpGUID = VA_ARG (Marker, EFI_GUID *);\r
+        if (TmpGUID != NULL) {\r
+          Index += GuidToString (\r
+                    TmpGUID,\r
+                    &Buffer[Index],\r
+                    BufferLeft\r
+                    );\r
+        }\r
+        break;\r
+\r
+      case 't':\r
+        Index += TimeToString (\r
+                  VA_ARG (Marker, EFI_TIME *), \r
+                  &Buffer[Index],\r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case 'r':\r
+        Index += EfiStatusToString (\r
+                  VA_ARG (Marker, EFI_STATUS), \r
+                  &Buffer[Index],\r
+                  BufferLeft\r
+                  );\r
+        break;\r
+\r
+      case '%':\r
+        Buffer[Index++] = *Format;\r
+        break;\r
+\r
+      default:\r
+        //\r
+        // if the type is unknown print it to the screen\r
+        //\r
+        Buffer[Index++] = *Format;\r
+      }\r
+\r
+      BufferLeft = BufferSize - Index;\r
+    }\r
+  }\r
+\r
+  Buffer[Index++] = '\0';\r
+\r
+  return &Buffer[Index] - StartOfBuffer;\r
+}\r
+\r
+\r
+\r
+STATIC\r
+CHAR8 *\r
+GetFlagsAndWidth (\r
+  IN  CHAR8       *Format, \r
+  OUT UINTN       *Flags, \r
+  OUT UINTN       *Width,\r
+  IN OUT  VA_LIST *Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that parses flag and width information from the \r
+  Format string and returns the next index into the Format string that needs\r
+  to be parsed. See file headed for details of Flag and Width.\r
+\r
+Arguments:\r
+\r
+  Format - Current location in the AvSPrint format string.\r
+\r
+  Flags  - Returns flags\r
+\r
+  Width  - Returns width of element\r
+\r
+  Marker - Vararg list that may be paritally consumed and returned.\r
+\r
+Returns: \r
+\r
+  Pointer indexed into the Format string for all the information parsed\r
+  by this routine.\r
+\r
+--*/\r
+{\r
+  UINTN   Count;\r
+  BOOLEAN Done;\r
+\r
+  *Flags = 0;\r
+  *Width = 0;\r
+  for (Done = FALSE; !Done; ) {\r
+    Format++;\r
+\r
+    switch (*Format) {\r
+\r
+    case '-': *Flags |= LEFT_JUSTIFY; break;\r
+    case '+': *Flags |= PREFIX_SIGN;  break;\r
+    case ' ': *Flags |= PREFIX_BLANK; break;\r
+    case ',': *Flags |= COMMA_TYPE;   break;\r
+    case 'L':\r
+    case 'l': *Flags |= LONG_TYPE;    break;\r
+\r
+    case '*':\r
+      *Width = VA_ARG (*Marker, UINTN);\r
+      break;\r
+\r
+    case '0':\r
+      *Flags |= PREFIX_ZERO;\r
+    case '1':\r
+    case '2':\r
+    case '3':\r
+    case '4':\r
+    case '5':\r
+    case '6':\r
+    case '7':\r
+    case '8':\r
+    case '9':\r
+      Count = 0;\r
+      do {\r
+        Count = (Count * 10) + *Format - '0';\r
+        Format++;\r
+      } while ((*Format >= '0')  &&  (*Format <= '9'));\r
+      Format--;\r
+      *Width = Count;\r
+      break;\r
+\r
+    default:\r
+      Done = TRUE;\r
+    }\r
+  }\r
+  return Format;\r
+}\r
+\r
+static CHAR8 mHexStr[] = { '0','1','2','3','4','5','6','7',\r
+                          '8','9','A','B','C','D','E','F' };\r
+\r
+STATIC\r
+UINTN\r
+ValueTomHexStr (\r
+  IN  OUT CHAR8   *Buffer, \r
+  IN  UINT64      Value, \r
+  IN  UINTN       Flags, \r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that prints a Value as a hex number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii hex string of Value.\r
+\r
+  Value  - Hex value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing Hex string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  CHAR8   TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR8   *TempStr;\r
+  CHAR8   Prefix;\r
+  CHAR8   *BufferPtr;\r
+  UINTN   Count;\r
+  UINTN   Index;\r
+\r
+  TempStr = TempBuffer;\r
+  BufferPtr = Buffer;\r
+  \r
+  //\r
+  // Count starts at one since we will null terminate. Each iteration of the\r
+  // loop picks off one nibble. Oh yea TempStr ends up backwards\r
+  //\r
+  Count = 0;\r
+  do {\r
+    *(TempStr++) = mHexStr[Value & 0x0f];\r
+    Value = RShiftU64 (Value, 4);\r
+    Count++;\r
+  } while (Value != 0);\r
+\r
+  if (Flags & PREFIX_ZERO) {\r
+    Prefix = '0';\r
+  } else if (!(Flags & LEFT_JUSTIFY)) { \r
+    Prefix = ' ';\r
+  } else {\r
+    Prefix = 0x00;\r
+  }                    \r
+  for (Index = Count; Index < Width; Index++) {\r
+    *(TempStr++) = Prefix;\r
+  }\r
+\r
+  //\r
+  // Reverse temp string into Buffer.\r
+  //\r
+  if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {\r
+    TempStr = TempBuffer + Width;\r
+  }\r
+  Index = 0;\r
+  while (TempStr != TempBuffer) {\r
+    *(BufferPtr++) = *(--TempStr);\r
+    Index++;\r
+  }\r
+    \r
+  *BufferPtr = 0;\r
+  return Index;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+ValueToString (\r
+  IN  OUT CHAR8   *Buffer, \r
+  IN  INT64       Value, \r
+  IN  UINTN       Flags, \r
+  IN  UINTN       Width\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that prints a Value as a decimal number in Buffer\r
+\r
+Arguments:\r
+\r
+  Buffer - Location to place ascii decimal number string of Value.\r
+\r
+  Value  - Decimal value to convert to a string in Buffer.\r
+\r
+  Flags  - Flags to use in printing decimal string, see file header for details.\r
+\r
+  Width  - Width of hex value.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  CHAR8   TempBuffer[CHARACTER_NUMBER_FOR_VALUE];\r
+  CHAR8   *TempStr;\r
+  CHAR8   *BufferPtr;\r
+  UINTN   Count;\r
+  UINTN   NumberCount;\r
+  UINTN   Remainder;\r
+  BOOLEAN Negative;\r
+  UINTN   Index;\r
+\r
+  Negative    = FALSE;\r
+  TempStr     = TempBuffer;\r
+  BufferPtr   = Buffer;\r
+  Count       = 0;\r
+  NumberCount = 0;\r
+\r
+  if (Value < 0) {\r
+    Negative = TRUE;\r
+    Value    = -Value;\r
+  }\r
+\r
+  do {\r
+    Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder);\r
+    *(TempStr++) = (CHAR8)(Remainder + '0');\r
+    Count++;\r
+    NumberCount++;\r
+    if ((Flags & COMMA_TYPE) == COMMA_TYPE) {\r
+      if (NumberCount % 3 == 0 && Value != 0) {\r
+        *(TempStr++) = ',';\r
+        Count++;\r
+      }\r
+    }\r
+  } while (Value != 0);\r
+\r
+  if (Negative) {\r
+    *(BufferPtr++) = '-';\r
+    Count++;\r
+  }\r
+\r
+  //\r
+  // Reverse temp string into Buffer.\r
+  //\r
+  if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {\r
+    TempStr = TempBuffer + Width;\r
+  }\r
+  Index = 0;\r
+  while (TempStr != TempBuffer) {\r
+    *(BufferPtr++) = *(--TempStr);\r
+  }  \r
+\r
+  *BufferPtr = 0;\r
+  return Index;\r
+}\r
+\r
+STATIC\r
+UINTN\r
+GuidToString (\r
+  IN  EFI_GUID  *Guid,\r
+  IN  CHAR8     *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that prints an EFI_GUID.\r
+\r
+Arguments:\r
+\r
+  Guid       - Pointer to GUID to print.\r
+\r
+  Buffer     - Buffe to print Guid into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN Size;\r
+\r
+  Size = ASPrint (\r
+            Buffer,\r
+            BufferSize, \r
+            "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
+            (UINTN)Guid->Data1,                    \r
+            (UINTN)Guid->Data2,\r
+            (UINTN)Guid->Data3,\r
+            (UINTN)Guid->Data4[0],\r
+            (UINTN)Guid->Data4[1],\r
+            (UINTN)Guid->Data4[2],\r
+            (UINTN)Guid->Data4[3],\r
+            (UINTN)Guid->Data4[4],\r
+            (UINTN)Guid->Data4[5],\r
+            (UINTN)Guid->Data4[6],\r
+            (UINTN)Guid->Data4[7]\r
+            );\r
+\r
+  //\r
+  // ASPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+}\r
+\r
+\r
+STATIC\r
+UINTN\r
+TimeToString (\r
+  IN EFI_TIME   *Time,\r
+  OUT CHAR8     *Buffer,\r
+  IN  UINTN     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that prints EFI_TIME.\r
+\r
+Arguments:\r
+\r
+  Time       - Pointer to EFI_TIME sturcture to print.\r
+\r
+  Buffer     - Buffer to print Time into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{ \r
+  UINTN Size;\r
+\r
+  Size = ASPrint (\r
+            Buffer,\r
+            BufferSize, \r
+            "%02d/%02d/%04d  %02d:%02d",\r
+            (UINTN)Time->Month,\r
+            (UINTN)Time->Day,\r
+            (UINTN)Time->Year,\r
+            (UINTN)Time->Hour,\r
+            (UINTN)Time->Minute\r
+            );\r
+\r
+  //\r
+  // ASPrint will null terminate the string. The -1 skips the null\r
+  //\r
+  return Size - 1;\r
+} \r
+\r
+STATIC\r
+UINTN\r
+EfiStatusToString (\r
+  IN EFI_STATUS   Status,\r
+  OUT CHAR8       *Buffer,\r
+  IN  UINTN       BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  AvSPrint worker function that prints EFI_STATUS as a string. If string is\r
+  not known a hex value will be printed.\r
+\r
+Arguments:\r
+\r
+  Status     -  EFI_STATUS sturcture to print.\r
+\r
+  Buffer     - Buffer to print EFI_STATUS message string into.\r
+  \r
+  BufferSize - Size of Buffer.\r
+\r
+Returns: \r
+\r
+  Number of characters printed.  \r
+\r
+--*/\r
+{\r
+  UINTN   Size;\r
+  CHAR8   *Desc;\r
+  \r
+  if (Status == EFI_SUCCESS) {\r
+    Desc = "Success";\r
+  } else if (Status == EFI_LOAD_ERROR) {\r
+    Desc = "Load Error";\r
+  } else if (Status == EFI_INVALID_PARAMETER) {\r
+    Desc = "Invalid Parameter";\r
+  } else if (Status == EFI_UNSUPPORTED) {\r
+    Desc = "Unsupported";\r
+  } else if (Status == EFI_BAD_BUFFER_SIZE) {\r
+    Desc = "Bad Buffer Size";\r
+  } else if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    Desc = "Buffer Too Small";\r
+  } else if (Status == EFI_NOT_READY) {\r
+    Desc = "Not Ready";\r
+  } else if (Status == EFI_DEVICE_ERROR) {\r
+    Desc = "Device Error";\r
+  } else if (Status == EFI_WRITE_PROTECTED) {\r
+    Desc = "Write Protected";\r
+  } else if (Status == EFI_OUT_OF_RESOURCES) {\r
+    Desc = "Out of Resources";\r
+  } else if (Status == EFI_VOLUME_CORRUPTED) {\r
+    Desc = "Volume Corrupt";\r
+  } else if (Status == EFI_VOLUME_FULL) {\r
+    Desc = "Volume Full";\r
+  } else if (Status == EFI_NO_MEDIA) {\r
+    Desc = "No Media";\r
+  } else if (Status == EFI_MEDIA_CHANGED) {\r
+    Desc = "Media changed";\r
+  } else if (Status == EFI_NOT_FOUND) {\r
+    Desc = "Not Found";\r
+  } else if (Status == EFI_ACCESS_DENIED) {\r
+    Desc = "Access Denied";\r
+  } else if (Status == EFI_NO_RESPONSE) {\r
+    Desc = "No Response";\r
+  } else if (Status == EFI_NO_MAPPING) {\r
+    Desc = "No mapping";\r
+  } else if (Status == EFI_TIMEOUT) {\r
+    Desc = "Time out";\r
+  } else if (Status == EFI_NOT_STARTED) {\r
+    Desc = "Not started";\r
+  } else if (Status == EFI_ALREADY_STARTED) {\r
+    Desc = "Already started";\r
+  } else if (Status == EFI_ABORTED) {\r
+    Desc = "Aborted";\r
+  } else if (Status == EFI_ICMP_ERROR) {\r
+    Desc = "ICMP Error";\r
+  } else if (Status == EFI_TFTP_ERROR) {\r
+    Desc = "TFTP Error";\r
+  } else if (Status == EFI_PROTOCOL_ERROR) {\r
+    Desc = "Protocol Error";\r
+  } else if (Status == EFI_WARN_UNKNOWN_GLYPH) {\r
+    Desc = "Warning Unknown Glyph";\r
+  } else if (Status == EFI_WARN_DELETE_FAILURE) {\r
+    Desc = "Warning Delete Failure";\r
+  } else if (Status == EFI_WARN_WRITE_FAILURE) {\r
+    Desc = "Warning Write Failure";\r
+  } else if (Status == EFI_WARN_BUFFER_TOO_SMALL) {\r
+    Desc = "Warning Buffer Too Small";\r
+  } else {\r
+    Desc = NULL;\r
+  }\r
+  //\r
+  // If we found a match, copy the message to the user's buffer. Otherwise\r
+  // sprint the hex status code to their buffer.\r
+  //\r
+  if (Desc != NULL) {\r
+    Size = ASPrint (Buffer, BufferSize, "%a", Desc);\r
+  } else {\r
+    Size = ASPrint (Buffer, BufferSize, "%X", Status);\r
+  }\r
+  return Size - 1;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h
new file mode 100644 (file)
index 0000000..6641523
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  Private data for Print.c\r
+\r
+--*/\r
+\r
+#ifndef _PRINT_H_\r
+#define _PRINT_H_\r
+\r
+#define LEFT_JUSTIFY  0x01\r
+#define PREFIX_SIGN   0x02\r
+#define PREFIX_BLANK  0x04\r
+#define COMMA_TYPE    0x08\r
+#define LONG_TYPE     0x10\r
+#define PREFIX_ZERO   0x20\r
+\r
+//\r
+// Largest number of characters that can be printed out.\r
+//\r
+#define PEI_LIB_MAX_PRINT_BUFFER  (80 * 4)\r
+\r
+#include "EfiCommonLib.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..97b7f4c
--- /dev/null
@@ -0,0 +1,93 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+    IA-32 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiImage.h"\r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an IA-32 specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED   - relocate unsupported\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h
new file mode 100644 (file)
index 0000000..8217302
--- /dev/null
@@ -0,0 +1,85 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.h\r
+\r
+Abstract:\r
+\r
+    IA-32 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PE_COFF_LOADER_EX_H_\r
+#define _PE_COFF_LOADER_EX_H_\r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an IA-32 specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED   - relocate unsupported\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c
new file mode 100644 (file)
index 0000000..54241b2
--- /dev/null
@@ -0,0 +1,152 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeiServicePointer.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiApi.h"\r
+#include "PeiLib.h"\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+EFI_PEI_SERVICES  **gPeiServices;\r
+#endif\r
+\r
+\r
+VOID\r
+SetPeiServicesTablePointer (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PeiService pointer so that it can be retrieved anywhere.\r
+\r
+Arguments:\r
+\r
+  PeiServices     - The direct pointer to PeiServiceTable.\r
+  PhyscialAddress - The physcial address of variable PeiServices.\r
+  \r
+Returns:\r
+  NONE\r
+  \r
+--*/          \r
+{\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+  //\r
+  // For NT32, set EFI_PEI_SERVICES** to global variable.\r
+  //\r
+  gPeiServices = PeiServices;\r
+#else\r
+\r
+  //\r
+  // For X86 processor,the EFI_PEI_SERVICES** is stored in the \r
+  // 4 bytes immediately preceding the Interrupt Descriptor Table.\r
+  //\r
+  UINTN IdtBaseAddress;\r
+  IdtBaseAddress = (UINTN)ReadIdtBase();\r
+  *(UINTN*)(IdtBaseAddress - 4) = (UINTN)PeiServices;\r
+\r
+#endif  \r
+}\r
+\r
+\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer ( \r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  NONE.\r
+  \r
+Returns:\r
+  The direct pointer to PeiServiceTable.\r
+  \r
+--*/          \r
+{\r
+  EFI_PEI_SERVICES  **PeiServices;\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+  //\r
+  // For NT32, set EFI_PEI_SERVICES** to global variable.\r
+  //\r
+  PeiServices = gPeiServices;\r
+#else\r
+\r
+  //\r
+  // For X86 processor,the EFI_PEI_SERVICES** is stored in the \r
+  // 4 bytes immediately preceding the Interrupt Descriptor Table.\r
+  //\r
+  UINTN IdtBaseAddress;\r
+  IdtBaseAddress = (UINTN)ReadIdtBase();\r
+  PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(IdtBaseAddress - 4));\r
+#endif\r
+  return PeiServices;\r
+}\r
+\r
+\r
+VOID\r
+MigrateIdtTable (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
+  storing PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  PeiServices   - The direct pointer to PeiServiceTable.\r
+  \r
+Returns:\r
+\r
+  NONE.\r
+  \r
+--*/            \r
+{\r
+#ifndef EFI_NT_EMULATOR\r
+  UINT16          IdtEntrySize;\r
+  UINTN           OldIdtBase;\r
+  UINTN           Size;\r
+  VOID            *NewIdtBase;\r
+  EFI_STATUS      Status;\r
+  \r
+  IdtEntrySize    = ReadIdtLimit();\r
+  OldIdtBase      = ReadIdtBase();\r
+  Size = sizeof(PEI_IDT_TABLE) + (IdtEntrySize + 1);  \r
+  Status = (*PeiServices)->AllocatePool (PeiServices, Size, &NewIdtBase);\r
+  ASSERT_PEI_ERROR (PeiServices, Status);\r
+  (*PeiServices)->CopyMem ((VOID*)((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), (VOID*)OldIdtBase, (IdtEntrySize + 1));\r
+  SetIdtBase(((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), IdtEntrySize);\r
+  SetPeiServicesTablePointer(PeiServices);\r
+#endif\r
+}\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c
new file mode 100644 (file)
index 0000000..1050ae5
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PerformancePrimitives.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance library\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "CpuIA32.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get timer value.\r
+\r
+Arguments:\r
+\r
+  TimerValue  - Pointer to the returned timer value\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Successfully got timer value\r
+\r
+--*/\r
+{\r
+  *TimerValue = EfiReadTsc ();\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c
new file mode 100644 (file)
index 0000000..4010db2
--- /dev/null
@@ -0,0 +1,140 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Processor.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiJump.h"\r
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)\r
+#include EFI_GUID_DEFINITION (PeiTransferControl)\r
+\r
+//\r
+// Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+TransferControlSetJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TransferControlLongJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,\r
+  IN EFI_PHYSICAL_ADDRESS                     Start,\r
+  IN UINT64                                   Length\r
+  );\r
+\r
+//\r
+// Table declarations\r
+//\r
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL         mTransferControl = {\r
+  TransferControlSetJump,\r
+  TransferControlLongJump,\r
+  sizeof (EFI_JUMP_BUFFER)\r
+};\r
+\r
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  mFlushInstructionCache = {\r
+  FlushInstructionCacheFlush\r
+};\r
+\r
+\r
+EFI_STATUS\r
+InstallEfiPeiTransferControl (\r
+  IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the transfer control mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to transfer control mechanism.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Successfully installed.\r
+\r
+--*/\r
+{\r
+  *This = &mTransferControl;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InstallEfiPeiFlushInstructionCache (\r
+  IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the flush instruction cache mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to flush instruction cache mechanism.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Successfully installed\r
+\r
+--*/\r
+{\r
+  *This = &mFlushInstructionCache;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL   *This,\r
+  IN EFI_PHYSICAL_ADDRESS                       Start,\r
+  IN UINT64                                     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would provide support for flushing the CPU instruction cache.\r
+  In the case of IA32, this flushing is not necessary and is thus not implemented.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to CPU Architectural Protocol interface\r
+  Start     - Start adddress in memory to flush\r
+  Length    - Length of memory to flush\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm
new file mode 100644 (file)
index 0000000..bf0d5cb
--- /dev/null
@@ -0,0 +1,223 @@
+;\r
+; Copyright (c) 2004, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+; \r
+; Module Name:\r
+; \r
+;    ProcessorAsms.Asm\r
+;\r
+; Abstract:\r
+;       This is separated from processor.c to allow this functions to be built with /O1\r
+;\r
+; Notes:\r
+; - Masm uses "This", "ebx", etc as a directive.\r
+; - H2INC is still not embedded in our build process so I translated the struc manually.\r
+; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and \r
+;       did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level. \r
+;       Instead, I did a dummy referenced.\r
+;\r
+\r
+  .686P\r
+  .MMX\r
+  .MODEL SMALL\r
+  .CODE\r
+\r
+EFI_SUCCESS                     equ     0\r
+EFI_WARN_RETURN_FROM_LONG_JUMP  equ     5\r
+\r
+;\r
+; Generated by h2inc run manually\r
+;\r
+_EFI_JUMP_BUFFER                STRUCT 2t\r
+_ebx            DWORD           ?\r
+_esi            DWORD           ?\r
+_edi            DWORD           ?\r
+_ebp            DWORD           ?\r
+_esp            DWORD           ?\r
+_eip            DWORD           ?\r
+_EFI_JUMP_BUFFER                ENDS\r
+\r
+EFI_JUMP_BUFFER         TYPEDEF         _EFI_JUMP_BUFFER\r
+\r
+TransferControlSetJump      PROTO  C \\r
+        _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
+        Jump:PTR EFI_JUMP_BUFFER\r
+\r
+TransferControlLongJump     PROTO  C \\r
+        _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
+        Jump:PTR EFI_JUMP_BUFFER\r
+\r
+SwitchStacks    PROTO  C \\r
+   EntryPoint:PTR DWORD, \\r
+   Parameter:DWORD, \\r
+   NewStack:PTR DWORD, \\r
+   NewBsp:PTR DWORD\r
+   \r
+SwitchIplStacks PROTO  C \\r
+   EntryPoint:PTR DWORD, \\r
+   Parameter1:DWORD, \\r
+   Parameter2:DWORD, \\r
+   NewStack:PTR DWORD, \\r
+   NewBsp:PTR DWORD\r
+\r
+;\r
+;Routine Description:\r
+;\r
+;  This routine implements the IA32 variant of the SetJump call.  Its\r
+;  responsibility is to store system state information for a possible\r
+;  subsequent LongJump.\r
+;\r
+;Arguments:\r
+;\r
+;  Pointer to CPU context save buffer.\r
+;\r
+;Returns:\r
+;\r
+;  EFI_SUCCESS\r
+;\r
+TransferControlSetJump      PROC  C \\r
+  _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
+  Jump:PTR EFI_JUMP_BUFFER\r
+    \r
+  mov   eax, _This \r
+  mov   ecx, Jump\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._esi, esi\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._edi, edi\r
+  mov   eax, [ebp]\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax\r
+  lea   eax, [ebp+4]\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._esp, eax\r
+  mov   eax, [ebp+4]\r
+  mov   (EFI_JUMP_BUFFER PTR [ecx])._eip, eax\r
+  mov   eax, EFI_SUCCESS\r
+  \r
+  ret\r
+  \r
+TransferControlSetJump      ENDP\r
+\r
+;\r
+; Routine Description:\r
+; \r
+;  This routine implements the IA32 variant of the LongJump call.  Its\r
+;  responsibility is restore the system state to the Context Buffer and\r
+;  pass control back.\r
+;\r
+; Arguments:\r
+; \r
+;  Pointer to CPU context save buffer.\r
+;\r
+; Returns:\r
+;\r
+;  EFI_WARN_RETURN_FROM_LONG_JUMP\r
+;\r
+\r
+TransferControlLongJump     PROC  C \\r
+        _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \\r
+        Jump:PTR EFI_JUMP_BUFFER\r
+\r
+  push  ebx\r
+  push  esi\r
+  push  edi\r
+\r
+  mov   eax, _This\r
+    ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP\r
+  mov   eax, EFI_WARN_RETURN_FROM_LONG_JUMP          \r
+  mov   ecx, Jump\r
+  mov   ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx\r
+  mov   esi, (EFI_JUMP_BUFFER PTR [ecx])._esi\r
+  mov   edi, (EFI_JUMP_BUFFER PTR [ecx])._edi\r
+  mov   ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp\r
+  mov   esp, (EFI_JUMP_BUFFER PTR [ecx])._esp\r
+  add   esp, 4                                       ;pop the eip\r
+  jmp   DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip\r
+  mov   eax, EFI_WARN_RETURN_FROM_LONG_JUMP\r
+  \r
+  pop   edi\r
+  pop   esi\r
+  pop   ebx\r
+  ret\r
+  \r
+TransferControlLongJump     ENDP\r
+\r
+;\r
+; Routine Description:\r
+;       This allows the caller to switch the stack and goes to the new entry point\r
+;\r
+; Arguments:\r
+;       EntryPoint      - Pointer to the location to enter\r
+;       Parameter       - Parameter to pass in\r
+;       NewStack        - New Location of the stack\r
+;       NewBsp          - New BSP\r
+;\r
+; Returns:\r
+;\r
+;       Nothing. Goes to the Entry Point passing in the new parameters\r
+;\r
+SwitchStacks    PROC  C \\r
+  EntryPoint:PTR DWORD, \\r
+  Parameter:DWORD, \\r
+  NewStack:PTR DWORD, \\r
+  NewBsp:PTR DWORD\r
+  \r
+  push  ebx\r
+  mov   eax, NewBsp\r
+  mov   ebx, Parameter\r
+  mov   ecx, EntryPoint\r
+  mov   eax, NewStack\r
+  mov   esp, eax\r
+  push  ebx\r
+  push  0\r
+  jmp   ecx\r
+  \r
+  pop   ebx\r
+  ret\r
+  \r
+SwitchStacks    ENDP\r
+\r
+;\r
+; Routine Description:\r
+;       This allows the caller to switch the stack and goes to the new entry point\r
+;\r
+; Arguments:\r
+;       EntryPoint              - Pointer to the location to enter\r
+;       Parameter1/Parameter2   - Parameter to pass in\r
+;       NewStack                - New Location of the stack\r
+;       NewBsp                  - New BSP\r
+;\r
+; Returns:\r
+;\r
+;       Nothing. Goes to the Entry Point passing in the new parameters\r
+;\r
+SwitchIplStacks PROC  C \\r
+  EntryPoint:PTR DWORD, \\r
+  Parameter1:DWORD, \\r
+  Parameter2:DWORD, \\r
+  NewStack:PTR DWORD, \\r
+  NewBsp:PTR DWORD\r
+  \r
+  push  ebx\r
+  mov   eax, NewBsp         \r
+  mov   ebx, Parameter1\r
+  mov   edx, Parameter2\r
+  mov   ecx, EntryPoint\r
+  mov   eax, NewStack\r
+  mov   esp, eax\r
+\r
+  push  edx\r
+  push  ebx\r
+  call  ecx\r
+  \r
+  pop   ebx\r
+  ret\r
+  \r
+SwitchIplStacks ENDP\r
+\r
+  END\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm
new file mode 100644 (file)
index 0000000..27d5254
--- /dev/null
@@ -0,0 +1,60 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   ReadIdtBase.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   ReadIdtBase function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; ReadIdtBase (\r
+;   void\r
+;   )\r
+;\r
+; Abstract: Returns physical address of IDTR\r
+;\r
+ReadIdtBase     PROC    C PUBLIC\r
+                LOCAL   IdtrBuf:FWORD\r
+                sidt    IdtrBuf\r
+                mov     eax, DWORD PTR IdtrBuf + 2\r
+                ret\r
+ReadIdtBase     ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; UINT16\r
+; ReadIdtLimit (\r
+;   void\r
+;   )\r
+;\r
+; Abstract: Returns Limit of IDTR\r
+;\r
+ReadIdtLimit    PROC    C PUBLIC\r
+                LOCAL   IdtrBuf:FWORD\r
+                sidt    IdtrBuf\r
+                mov     ax, WORD PTR IdtrBuf\r
+                ret\r
+ReadIdtLimit    ENDP\r
+\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm
new file mode 100644 (file)
index 0000000..bc0f70a
--- /dev/null
@@ -0,0 +1,69 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.     \r
+;\r
+; Module Name:\r
+;\r
+;   SupportItpDebug.asm\r
+; \r
+; Abstract:\r
+; \r
+;   This is the code for debuging IA32, to add a break hook at loading every module\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+; PROC:PRIVATE\r
+  .686P\r
+  .MMX\r
+  .MODEL SMALL\r
+  .CODE\r
+\r
+AsmEfiSetBreakSupport  PROTO  C LoadAddr:DWORD\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  AsmEfiSetBreakSupport (\r
+;    IN UINTN  LoadAddr\r
+;    )\r
+;------------------------------------------------------------------------------\r
+\r
+AsmEfiSetBreakSupport  PROC  C LoadAddr:DWORD\r
+\r
+    mov eax, LoadAddr\r
+    mov dx,  60000\r
+    out dx,  eax\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    ret\r
+    \r
+AsmEfiSetBreakSupport  ENDP\r
+  END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm
new file mode 100644 (file)
index 0000000..c463499
--- /dev/null
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   WriteIdt.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   SetIdtBase function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .mmx\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; void\r
+; SetIdtBase (\r
+;   UINT32  IdtBase,\r
+;   UINT16  IdtLimit \r
+;   )\r
+;\r
+; Abstract: Set IDTR with the given physical address\r
+;\r
+SetIdtBase      PROC    C PUBLIC IdtBase:DWORD, IdtLimit:WORD\r
+                LOCAL   IdtrBuf:FWORD\r
+\r
+                mov     eax, IdtBase\r
+                mov     cx, IdtLimit\r
+                mov     DWORD PTR IdtrBuf + 2, eax                  ; write IDT base address\r
+                mov     WORD  PTR IdtrBuf, cx                        ; write ITD limit\r
+                lidt    FWORD PTR IdtrBuf\r
+                ret\r
+SetIdtBase      ENDP\r
+\r
+     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 (file)
index 0000000..cdd7ca8
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiJump.h\r
+\r
+Abstract:\r
+\r
+  This is the Setjump/Longjump pair for an IA32 processor.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_JUMP_H_\r
+#define _EFI_JUMP_H_\r
+\r
+typedef struct {\r
+  UINT32  ebx;\r
+  UINT32  esi;\r
+  UINT32  edi;\r
+  UINT32  ebp;\r
+  UINT32  esp;\r
+  UINT32  eip;\r
+} EFI_JUMP_BUFFER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h
new file mode 100644 (file)
index 0000000..5a37d87
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiJump.h\r
+\r
+Abstract:\r
+\r
+  This is the Setjump/Longjump pair for an x64 processor.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_JUMP_H_\r
+#define _EFI_JUMP_H_\r
+\r
+typedef struct {\r
+  UINT64 Rbx;\r
+  UINT64 Rsp;\r
+  UINT64 Rbp;\r
+  UINT64 Rdi;\r
+  UINT64 Rsi;\r
+  UINT64 R10;\r
+  UINT64 R11;\r
+  UINT64 R12;\r
+  UINT64 R13;\r
+  UINT64 R14;\r
+  UINT64 R15;\r
+  UINT64 Rip;\r
+} EFI_JUMP_BUFFER;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c
new file mode 100644 (file)
index 0000000..03802c1
--- /dev/null
@@ -0,0 +1,41 @@
+/*++\r
+\r
+Copyright 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+   IdtDumb.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+UINTN\r
+ReadIdtBase ( \r
+  VOID \r
+  ) \r
+{\r
+  \r
+  return 0;\r
+}\r
+\r
+\r
+VOID\r
+UpdateIdt (\r
+  UINT32  IdtBase,\r
+  UINT16  IdtLimit \r
+ )\r
+{\r
+  return;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c
new file mode 100644 (file)
index 0000000..8c7cb68
--- /dev/null
@@ -0,0 +1,117 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Math.c\r
+\r
+Abstract:\r
+\r
+  64-bit Math worker functions for x64\r
+\r
+--*/\r
+\r
+#include "Efi.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  \r
+  Count   - Number of times to shift left.\r
+  \r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+  \r
+--*/\r
+{\r
+  return Operand << Count;\r
+}\r
+\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit value returns \r
+  64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - \r
+  \r
+  Multiplier    - \r
+  \r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+}\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN UINT64   Dividend,\r
+  IN UINTN    Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+\r
+Arguments:\r
+\r
+  Dividend  - \r
+  \r
+  Divisor   - \r
+  \r
+  Remainder -\r
+  \r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+  \r
+N.B. only works for 31bit divisors!!\r
+    \r
+--*/\r
+{\r
+  return Dividend/Divisor;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..589bd00
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+  x64 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiImage.h"\r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup, \r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Performs an x64 specific relocation fixup\r
+\r
+Arguments:\r
+  Reloc      - Pointer to the relocation record\r
+  Fixup      - Pointer to the address to fix up\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+  EFI_UNSUPPORTED - relocate unsupported\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+{\r
+  if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || \r
+      (Machine ==  EFI_IMAGE_MACHINE_EBC)) {\r
+    return TRUE; \r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h
new file mode 100644 (file)
index 0000000..948fb01
--- /dev/null
@@ -0,0 +1,85 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.h\r
+\r
+Abstract:\r
+\r
+    x64 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PE_COFF_LOADER_EX_H_\r
+#define _PE_COFF_LOADER_EX_H_\r
+\r
+EFI_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an x64 specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED - relocate unsupported\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+  IN  UINT16  Machine\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported \r
+  does not mean the image can be executed it means the PE/COFF loader supports\r
+  loading and relocating of the image type. It's up to the caller to support\r
+  the entry point. \r
+\r
+  This function implies the basic PE/COFF loader/relocator supports IA32, EBC,\r
+  & X64 images. Calling the entry point in a correct mannor is up to the \r
+  consumer of this library.\r
+\r
+Arguments:\r
+\r
+  Machine   - Machine type from the PE Header.\r
+\r
+Returns:\r
+\r
+  TRUE      - if this PE/COFF loader can load the image\r
+  FALSE     - if this PE/COFF loader cannot load the image\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c
new file mode 100644 (file)
index 0000000..cdbf334
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+    PeiServicePointer.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiApi.h"\r
+\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)\r
+\r
+VOID\r
+SetPeiServicesTablePointer (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Save PeiService pointer so that it can be retrieved anywhere.\r
+\r
+Arguments:\r
+\r
+  PeiServices     - The direct pointer to PeiServiceTable.\r
+  PhyscialAddress - The physcial address of variable PeiServices.\r
+  \r
+Returns:\r
+  NONE\r
+  \r
+--*/        \r
+{\r
+  return;\r
+}\r
+\r
+EFI_PEI_SERVICES **\r
+GetPeiServicesTablePointer (\r
+  VOID \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  NONE.\r
+  \r
+Returns:\r
+  The direct pointer to PeiServiceTable.\r
+  \r
+--*/          \r
+{\r
+  return NULL;\r
+}\r
+\r
+\r
+VOID\r
+MigrateIdtTable (\r
+  IN EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
+  storing PeiService pointer.\r
+\r
+Arguments:\r
+\r
+  PeiServices   - The direct pointer to PeiServiceTable.\r
+  \r
+Returns:\r
+\r
+  NONE.\r
+  \r
+--*/  \r
+{\r
+  return;\r
+}\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c
new file mode 100644 (file)
index 0000000..f6ff783
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  PerformancePrimitives.c\r
+\r
+Abstract:\r
+\r
+  Support for Performance library\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "CpuIA32.h"\r
+\r
+EFI_STATUS\r
+GetTimerValue (\r
+  OUT UINT64    *TimerValue\r
+  )\r
+{\r
+  *TimerValue = EfiReadTsc ();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c
new file mode 100644 (file)
index 0000000..63cf848
--- /dev/null
@@ -0,0 +1,149 @@
+/*++\r
+\r
+Copyright 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+    Processor.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiJump.h"\r
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)\r
+#include EFI_GUID_DEFINITION (PeiTransferControl)\r
+\r
+//\r
+// Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+TransferControlSetJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TransferControlLongJump (\r
+  IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+  IN EFI_JUMP_BUFFER                    *Jump\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,\r
+  IN EFI_PHYSICAL_ADDRESS                     Start,\r
+  IN UINT64                                   Length\r
+  );\r
+\r
+//\r
+// Table declarations\r
+//\r
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = {\r
+  TransferControlSetJump,\r
+  TransferControlLongJump,\r
+  sizeof (EFI_JUMP_BUFFER)\r
+};\r
+\r
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  mFlushInstructionCache = {\r
+  FlushInstructionCacheFlush\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InstallEfiPeiTransferControl(\r
+  IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the transfer control mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to transfer control mechanism.\r
+\r
+Returns:\r
+\r
+  This       - Pointer to transfer control mechanism.\r
+\r
+--*/\r
+{\r
+  *This = &mTransferControl;\r
+  mTransferControl.SetJump = TransferControlSetJump;\r
+  mTransferControl.LongJump = TransferControlLongJump;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InstallEfiPeiFlushInstructionCache (\r
+  IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  **This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Installs the pointer to the flush instruction cache mechanism\r
+\r
+Arguments:\r
+\r
+  This       - Pointer to flush instruction cache mechanism.\r
+\r
+Returns:\r
+\r
+  This       - Pointer to flush instruction cache mechanism.\r
+\r
+--*/\r
+{\r
+  *This = &mFlushInstructionCache;\r
+  mFlushInstructionCache.Flush = FlushInstructionCacheFlush;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FlushInstructionCacheFlush (\r
+  IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL   *This,\r
+  IN EFI_PHYSICAL_ADDRESS                       Start,\r
+  IN UINT64                                     Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would provide support for flushing the CPU instruction cache.\r
+  In the case of IA32, this flushing is not necessary and is thus not implemented.\r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+  Start adddress in memory to flush\r
+  Length of memory to flush\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm
new file mode 100644 (file)
index 0000000..11a840e
--- /dev/null
@@ -0,0 +1,158 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+; \r
+; Module Name:\r
+;   ProcessorAsms.Asm\r
+;\r
+; Abstract:\r
+;   This is separated from processor.c to allow this functions to be built with /O1\r
+;\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+text  SEGMENT\r
+\r
+\r
+;\r
+; Routine Description:\r
+;   This allows the caller to switch the stack and goes to the new entry point\r
+;\r
+; Arguments:\r
+;   EntryPoint      - Pointer to the location to enter // rcx\r
+;   Parameter       - Parameter to pass in             // rdx\r
+;   NewStack        - New Location of the stack        // r8\r
+;   NewBsp          - New BSP                          // r9 - not used\r
+;\r
+; Returns:\r
+;   Nothing. Goes to the Entry Point passing in the new parameters\r
+;\r
+SwitchStacks  PROC  PUBLIC\r
+\r
+    ; Adjust stack for\r
+    ;   1) leave 4 registers space\r
+    ;   2) let it 16 bytes aligned after call\r
+    sub   r8, 20h\r
+    and   r8w, 0fff0h    ; do not assume 16 bytes aligned\r
+\r
+    mov   rsp,  r8       ; rsp = NewStack\r
+    mov   r10,  rcx      ; save EntryPoint\r
+    mov   rcx,  rdx      ; Arg1 = Parameter\r
+    call  r10            ; r10 = copy of EntryPoint\r
+ ;\r
+ ; no ret as we have a new stack and we jumped to the new location\r
+ ;     \r
+    ret\r
+  \r
+SwitchStacks    ENDP\r
+\r
+\r
+EFI_SUCCESS                     equ     0\r
+EFI_WARN_RETURN_FROM_LONG_JUMP  equ     5\r
+\r
+;\r
+; Generated by h2inc run manually\r
+;\r
+_EFI_JUMP_BUFFER                STRUCT 2t\r
+_rbx            QWORD           ?\r
+_rsp            QWORD           ?\r
+_rbp            QWORD           ?\r
+_rdi            QWORD           ?\r
+_rsi            QWORD           ?\r
+_r10            QWORD           ?\r
+_r11            QWORD           ?\r
+_r12            QWORD           ?\r
+_r13            QWORD           ?\r
+_r14            QWORD           ?\r
+_r15            QWORD           ?\r
+_rip            QWORD           ?\r
+_EFI_JUMP_BUFFER                ENDS\r
+\r
+EFI_JUMP_BUFFER         TYPEDEF         _EFI_JUMP_BUFFER\r
+\r
+\r
+;\r
+;Routine Description:\r
+;\r
+;  This routine implements the x64 variant of the SetJump call.  Its\r
+;  responsibility is to store system state information for a possible\r
+;  subsequent LongJump.\r
+;\r
+;Arguments:\r
+;\r
+;  Pointer to CPU context save buffer.\r
+;\r
+;Returns:\r
+;\r
+;  EFI_SUCCESS\r
+;\r
+; EFI_STATUS\r
+; EFIAPI\r
+; TransferControlLongJump (\r
+;   IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,\r
+;   IN EFI_JUMP_BUFFER                    *Jump\r
+;   );\r
+;\r
+; rcx - *This\r
+; rdx - JumpBuffer\r
+;\r
+PUBLIC  TransferControlSetJump\r
+TransferControlSetJump  PROC  \r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rbx, rbx\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rsp, rsp\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rbp, rbp\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rdi, rdi\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rsi, rsi\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r10, r10\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r11, r11\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r12, r12\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r13, r13\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r14, r14\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._r15, r15\r
+  mov   rax, QWORD PTR [rsp+0]\r
+  mov   (EFI_JUMP_BUFFER PTR [rdx])._rip, rax\r
+  mov   rax, EFI_SUCCESS  \r
+  ret\r
+  \r
+TransferControlSetJump      ENDP\r
+\r
+;\r
+; EFI_STATUS\r
+; EFIAPI\r
+; TransferControlLongJump (\r
+;   IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,  // rcx\r
+;   IN EFI_JUMP_BUFFER                    *Jump   // rdx\r
+;   );\r
+;\r
+;\r
+PUBLIC  TransferControlLongJump\r
+TransferControlLongJump  PROC  \r
+  ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP\r
+  mov   rax, EFI_WARN_RETURN_FROM_LONG_JUMP          \r
+  mov   rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx\r
+  mov   rsp, (EFI_JUMP_BUFFER PTR [rdx])._rsp\r
+  mov   rbp, (EFI_JUMP_BUFFER PTR [rdx])._rbp\r
+  mov   rdi, (EFI_JUMP_BUFFER PTR [rdx])._rdi\r
+  mov   rsi, (EFI_JUMP_BUFFER PTR [rdx])._rsi\r
+  mov   r10, (EFI_JUMP_BUFFER PTR [rdx])._r10\r
+  mov   r11, (EFI_JUMP_BUFFER PTR [rdx])._r11\r
+  mov   r12, (EFI_JUMP_BUFFER PTR [rdx])._r12\r
+  mov   r13, (EFI_JUMP_BUFFER PTR [rdx])._r13\r
+  mov   r14, (EFI_JUMP_BUFFER PTR [rdx])._r14\r
+  mov   r15, (EFI_JUMP_BUFFER PTR [rdx])._r15\r
+  add   rsp, 8                                       ;pop the eip\r
+  jmp   QWORD PTR (EFI_JUMP_BUFFER PTR [rdx])._rip\r
+  ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP\r
+  mov   rax, EFI_WARN_RETURN_FROM_LONG_JUMP\r
+  ret\r
+TransferControlLongJump  ENDP\r
+\r
+text  ENDS\r
+END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm
new file mode 100644 (file)
index 0000000..ff8af5a
--- /dev/null
@@ -0,0 +1,76 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation                                                         \r
+; All rights reserved. This program and the accompanying materials                          \r
+; are licensed and made available under the terms and conditions of the BSD License         \r
+; which accompanies this distribution.  The full text of the license may be found at        \r
+; http://opensource.org/licenses/bsd-license.php                                            \r
+;                                                                                           \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.     \r
+;\r
+; Module Name:\r
+;\r
+;   SupportItpDebug.asm\r
+; \r
+; Abstract:\r
+; \r
+;   This is the code for debuging X64, to add a break hook at loading every module\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+; PROC:PRIVATE\r
+  .CODE\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  AsmEfiSetBreakSupport (\r
+;    IN UINTN  LoadAddr    // rcx\r
+;    )\r
+;------------------------------------------------------------------------------\r
+\r
+AsmEfiSetBreakSupport  PROC    PUBLIC\r
+\r
+    mov dx,  60000\r
+    out dx,  eax\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    nop\r
+    ret\r
+    \r
+AsmEfiSetBreakSupport  ENDP\r
+  END\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
new file mode 100644 (file)
index 0000000..55e831c
--- /dev/null
@@ -0,0 +1,154 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Debug.c\r
+\r
+Abstract:\r
+\r
+  Support for Debug primatives. \r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)\r
+\r
+VOID\r
+EfiDebugAssert (\r
+  IN CHAR8    *FileName,\r
+  IN INTN     LineNumber,\r
+  IN CHAR8    *Description\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded BREAKPOINT ().\r
+  \r
+Arguments:\r
+\r
+  FileName    - File name of failing routine.\r
+\r
+  LineNumber  - Line number of failing ASSERT ().\r
+\r
+  Description - Description, usually the assertion,\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64];\r
+\r
+  EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);\r
+\r
+  EfiReportStatusCode (\r
+    (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
+    (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
+    0,\r
+    &gEfiCallerIdGuid,\r
+    (EFI_STATUS_CODE_DATA *) Buffer\r
+    );\r
+\r
+  //\r
+  // Put break point in module that contained the error.\r
+  //\r
+  EFI_BREAKPOINT ();\r
+}\r
+\r
+VOID\r
+EfiDebugVPrint (\r
+  IN  UINTN   ErrorLevel,\r
+  IN  CHAR8   *Format,\r
+  IN  VA_LIST Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+  \r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  Marker     - VarArgs\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64];\r
+\r
+  if (!(gRtErrorLevel & ErrorLevel)) {\r
+    return ;\r
+  }\r
+\r
+  EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);\r
+\r
+  EfiReportStatusCode (\r
+    EFI_DEBUG_CODE,\r
+    (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_DC_UNSPECIFIED),\r
+    (UINT32) ErrorLevel,\r
+    &gEfiCallerIdGuid,\r
+    (EFI_STATUS_CODE_DATA *) Buffer\r
+    );\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+EfiDebugPrint (\r
+  IN  UINTN                   ErrorLevel,\r
+  IN  CHAR8                   *Format,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT\r
+  information. If Error Logging hub is not loaded do nothing.\r
+\r
+  We use UINT64 buffers due to IPF alignment concerns.\r
+\r
+Arguments:\r
+\r
+  ErrorLevel - If error level is set do the debug print.\r
+\r
+  Format     - String to use for the print, followed by Print arguments.\r
+\r
+  ...        - VAR args for Format\r
+  \r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, Format);\r
+  EfiDebugVPrint (ErrorLevel, Format, Marker);\r
+  VA_END (Marker);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c
new file mode 100644 (file)
index 0000000..0ec1a08
--- /dev/null
@@ -0,0 +1,316 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+//\r
+// Driver Lib Module Globals\r
+//\r
+static EFI_RUNTIME_SERVICES *mRT;\r
+static EFI_EVENT            mRuntimeNotifyEvent     = NULL;\r
+static BOOLEAN              mRuntimeLibInitialized  = FALSE;\r
+static BOOLEAN              mEfiGoneVirtual         = FALSE;\r
+\r
+//\r
+// Runtime Global, but you should use the Lib functions\r
+//\r
+BOOLEAN                     mEfiAtRuntime = FALSE;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+#endif\r
+\r
+EFI_STATUS\r
+EfiConvertPointer (\r
+  IN UINTN                     DebugDisposition,\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mEfiAtRuntime = TRUE;\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     GoVirtualChildEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+\r
+  Status  = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+  if (EFI_ERROR (Status)) {\r
+    gStatusCode = NULL;\r
+  }\r
+#endif\r
+\r
+  //\r
+  // Register our ExitBootServices () notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  EFI_TPL_NOTIFY,\r
+                  RuntimeDriverExitBootServices,\r
+                  NULL,\r
+                  &mRuntimeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // To NOT register SetVirtualAddressMap () notify function,\r
+  // because we do not know how to trigger it without our EBC driver.\r
+  //\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiShutdownRuntimeDriverLib (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!mRuntimeLibInitialized) {\r
+    //\r
+    // You must call EfiInitializeRuntimeDriverLib() first\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized = FALSE;\r
+\r
+  //\r
+  // Close our ExitBootServices () notify function\r
+  //\r
+  if (mRuntimeNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (mRuntimeNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if ExitBootServices () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If ExitBootServices () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiAtRuntime;\r
+}\r
+\r
+BOOLEAN\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiGoneVirtual;\r
+}\r
+\r
+EFI_STATUS\r
+EfiReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+\r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+//\r
+// Cache Flush Routine.\r
+//\r
+EFI_STATUS\r
+EfiCpuFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS          Start,\r
+  IN UINT64                        Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush cache with specified range.\r
+\r
+Arguments:\r
+\r
+  Start   - Start address\r
+  Length  - Length in bytes\r
+\r
+Returns:\r
+\r
+  Status code\r
+  \r
+  EFI_SUCCESS - success\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf
new file mode 100644 (file)
index 0000000..aea21c4
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EfiRuntimeLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the EFI runtime library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME       = EfiRuntimeLib\r
+COMPONENT_TYPE  = LIBRARY\r
+\r
+[sources.common]\r
+  Debug.c\r
+  Event.c\r
+  Io.c\r
+  LibGlobals.c\r
+  GetImage.c\r
+  RtDevicePath.c\r
+\r
+[sources.ia32]\r
+  Ia32\RuntimeLib.c\r
+  Ia32\IoLib.c\r
+  Ia32\Lock.c\r
+  Ia32\PlatformIoLib.c\r
+  Ia32\Fvb.c\r
+\r
+[sources.x64]\r
+  x64\RuntimeLib.c\r
+  x64\IoLib.c\r
+  x64\Lock.c\r
+  x64\PlatformIoLib.c\r
+  x64\Fvb.c\r
+\r
+[sources.ipf]\r
+  Ipf\RuntimeLib.c\r
+  Ipf\Lock.c\r
+  Ipf\Fvb.c\r
+  Ipf\EsalLib.s\r
+  Ipf\IpfCpuCache.s\r
+\r
+[sources.ebc]\r
+  Ebc\RuntimeLib.c\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[libraries.common]\r
+  EdkGuidLib\r
+  EdkProtocolLib\r
+  EdkFrameworkProtocolLib\r
+  EfiGuidLib\r
+  EfiProtocolLib\r
+  ArchProtocolLib\r
+  EfiCommonLib\r
+\r
+[nmake.common]\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c
new file mode 100644 (file)
index 0000000..830938b
--- /dev/null
@@ -0,0 +1,353 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Event.c\r
+\r
+Abstract:\r
+\r
+  Support for Event lib fucntions.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+\r
+EFI_EVENT\r
+RtEfiLibCreateProtocolNotifyEvent (\r
+  IN EFI_GUID             *ProtocolGuid,\r
+  IN EFI_TPL              NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY     NotifyFunction,\r
+  IN VOID                 *NotifyContext,\r
+  OUT VOID                **Registration\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a protocol notification event and return it.\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid    - Protocol to register notification event on.\r
+\r
+  NotifyTpl       - Maximum TPL to single the NotifyFunction.\r
+\r
+  NotifyFunction  - EFI notification routine.\r
+\r
+  NotifyContext   - Context passed into Event when it is created.\r
+\r
+  Registration    - Registration key returned from RegisterProtocolNotify().\r
+\r
+Returns:\r
+\r
+  The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
+  is added to the system.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_EVENT   Event;\r
+\r
+  //\r
+  // Create the event\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  NotifyTpl,\r
+                  NotifyFunction,\r
+                  NotifyContext,\r
+                  &Event\r
+                  );\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Register for protocol notifactions on this event\r
+  //\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  ProtocolGuid,\r
+                  Event,\r
+                  Registration\r
+                  );\r
+\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Kick the event so we will perform an initial pass of\r
+  // current installed drivers\r
+  //\r
+  gBS->SignalEvent (Event);\r
+  return Event;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibGetSystemConfigurationTable (\r
+  IN EFI_GUID *TableGuid,\r
+  IN OUT VOID **Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the EFI 1.0 System Tabl entry with TableGuid\r
+\r
+Arguments:\r
+\r
+  TableGuid - Name of entry to return in the system table\r
+  Table     - Pointer in EFI system table associated with TableGuid\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Table returned;\r
+  EFI_NOT_FOUND - TableGuid not in EFI system table\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
+    if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+      *Table = gST->ConfigurationTable[Index].VendorTable;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+EfiConvertList (\r
+  IN UINTN                DebugDisposition,\r
+  IN OUT EFI_LIST_ENTRY   *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Conver the standard Lib double linked list to a virtual mapping.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)\r
+\r
+  ListHead         - Head of linked list to convert\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_LIST_ENTRY  *Link;\r
+  EFI_LIST_ENTRY  *NextLink;\r
+\r
+  //\r
+  // Convert all the ForwardLink & BackLink pointers in the list\r
+  //\r
+  Link = ListHead;\r
+  do {\r
+    NextLink = Link->ForwardLink;\r
+\r
+    EfiConvertPointer (\r
+      Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->ForwardLink\r
+      );\r
+\r
+    EfiConvertPointer (\r
+      Link->BackLink == ListHead ? DebugDisposition : 0,\r
+      (VOID **) &Link->BackLink\r
+      );\r
+\r
+    Link = NextLink;\r
+  } while (Link != ListHead);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+EventNotifySignalAllNullEvent (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  //\r
+  // This null event is a size efficent way to enusre that \r
+  // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.\r
+  // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into \r
+  // CreateEventEx() and this function is used to make the\r
+  // old error checking in CreateEvent() for Tiano extensions\r
+  // function.\r
+  //\r
+  return;\r
+}\r
+\r
+#endif\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RtEfiCreateEventLegacyBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *LegacyBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Legacy Boot Event.  \r
+  Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification by \r
+  declaring a GUID for the legacy boot event class. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  LegacyBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Returns:\r
+  EFI_SUCCESS   Event was created.\r
+  Other         Event was not created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+\r
+  if (NotifyFunction == NULL) {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  LegacyBootEvent\r
+                  );\r
+#else\r
+\r
+  EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventLegacyBootGuid,\r
+                  LegacyBootEvent\r
+                  );\r
+#endif\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RtEfiCreateEventReadyToBoot (\r
+  IN EFI_TPL                      NotifyTpl,\r
+  IN EFI_EVENT_NOTIFY             NotifyFunction,\r
+  IN VOID                         *NotifyContext,\r
+  OUT EFI_EVENT                   *ReadyToBootEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a Read to Boot Event.  \r
+  \r
+  Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
+  This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
+  added and now it's possible to not voilate the UEFI specification and use \r
+  the ready to boot event class defined in UEFI 2.0. This library supports\r
+  the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
+  work both ways.\r
+\r
+Arguments:\r
+  ReadyToBootEvent  Returns the EFI event returned from gBS->CreateEvent(Ex)\r
+\r
+Return:\r
+  EFI_SUCCESS   - Event was created.\r
+  Other         - Event was not created.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+\r
+  if (NotifyFunction == NULL) {\r
+    EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+    EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
+  //\r
+  // prior to UEFI 2.0 use Tiano extension to EFI\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  ReadyToBootEvent\r
+                  );\r
+#else\r
+\r
+  EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
+  //\r
+  // For UEFI 2.0 and the future use an Event Group\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EventType,\r
+                  NotifyTpl,\r
+                  WorkerNotifyFunction,\r
+                  NotifyContext,\r
+                  &gEfiEventReadyToBootGuid,\r
+                  ReadyToBootEvent\r
+                  );\r
+#endif\r
+  return Status;\r
+}
\ 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 (file)
index 0000000..990acff
--- /dev/null
@@ -0,0 +1,221 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  GetImage.c\r
+\r
+Abstract:\r
+\r
+  Image data extraction support for common use.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include "EfiImageFormat.h"\r
+\r
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)\r
+\r
+EFI_STATUS\r
+GetImageFromFv (\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  IN  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv,\r
+#else\r
+  IN  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
+#endif\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_FV_FILETYPE           FileType;\r
+  EFI_FV_FILE_ATTRIBUTES    Attributes;\r
+  UINT32                    AuthenticationStatus;\r
+\r
+  //\r
+  // Read desired section content in NameGuid file\r
+  //\r
+  *Buffer     = NULL;\r
+  *Size       = 0;\r
+  Status      = Fv->ReadSection (\r
+                      Fv,\r
+                      NameGuid,\r
+                      SectionType,\r
+                      0,\r
+                      Buffer,\r
+                      Size,\r
+                      &AuthenticationStatus\r
+                      );\r
+\r
+  if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {\r
+    //\r
+    // Try reading PE32 section, since the TE section does not exist\r
+    //\r
+    *Buffer = NULL;\r
+    *Size   = 0;\r
+    Status  = Fv->ReadSection (\r
+                    Fv,\r
+                    NameGuid,\r
+                    EFI_SECTION_PE32,\r
+                    0,\r
+                    Buffer,\r
+                    Size,\r
+                    &AuthenticationStatus\r
+                    );\r
+  }\r
+\r
+  if (EFI_ERROR (Status) && \r
+      ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) {\r
+    //\r
+    // Try reading raw file, since the desired section does not exist\r
+    //\r
+    *Buffer = NULL;\r
+    *Size   = 0;\r
+    Status  = Fv->ReadFile (\r
+                    Fv,\r
+                    NameGuid,\r
+                    Buffer,\r
+                    Size,\r
+                    &FileType,\r
+                    &Attributes,\r
+                    &AuthenticationStatus\r
+                    );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+GetImage (\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size\r
+  )\r
+{\r
+  return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE);\r
+}\r
+\r
+EFI_STATUS\r
+GetImageEx (\r
+  IN  EFI_HANDLE         ImageHandle,\r
+  IN  EFI_GUID           *NameGuid,\r
+  IN  EFI_SECTION_TYPE   SectionType,\r
+  OUT VOID               **Buffer,\r
+  OUT UINTN              *Size,\r
+  BOOLEAN                WithinImageFv\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_HANDLE                    *HandleBuffer;\r
+  UINTN                         HandleCount;\r
+  UINTN                         Index;\r
+  EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *ImageFv;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv;\r
+#else\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
+#endif\r
+\r
+  if (ImageHandle == NULL && WithinImageFv) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status  = EFI_NOT_FOUND;\r
+  ImageFv = NULL;\r
+  if (ImageHandle != NULL) {\r
+    Status = gBS->HandleProtocol (\r
+               ImageHandle,\r
+               &gEfiLoadedImageProtocolGuid,\r
+               &LoadedImage\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    Status = gBS->HandleProtocol (\r
+                    LoadedImage->DeviceHandle,\r
+                  #if (PI_SPECIFICATION_VERSION < 0x00010000)    \r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                  #else\r
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                  #endif\r
+                    &ImageFv\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size);\r
+    }\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS || WithinImageFv) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+                  &gEfiFirmwareVolumeProtocolGuid,\r
+                #else\r
+                  &gEfiFirmwareVolume2ProtocolGuid,\r
+                #endif\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Find desired image in all Fvs\r
+  //\r
+  for (Index = 0; Index < HandleCount; ++Index) {\r
+    Status = gBS->HandleProtocol (\r
+                    HandleBuffer[Index],\r
+                  #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                  #else\r
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                  #endif\r
+                    (VOID**)&Fv\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool(HandleBuffer);\r
+      return Status;\r
+    }\r
+\r
+    if (ImageFv != NULL && Fv == ImageFv) {\r
+      continue;\r
+    }\r
+\r
+    Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size);\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+  gBS->FreePool(HandleBuffer);\r
+\r
+  //\r
+  // Not found image\r
+  //\r
+  if (Index == HandleCount) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
new file mode 100644 (file)
index 0000000..b7571b4
--- /dev/null
@@ -0,0 +1,339 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Io.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib functions that wrape IoRead (), IoWrite, MemRead (), \r
+  and MemWrite ().\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+\r
+UINT8\r
+IoRead8 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT8 Buffer;\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+UINT16\r
+IoRead16 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT16  Buffer;\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+UINT32\r
+IoRead32 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte IO read\r
+\r
+Arguments:\r
+  Address - IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT32  Buffer;\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+VOID\r
+IoWrite8 (\r
+  IN  UINT64    Address,\r
+  IN  UINT8     Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiIoWrite (EfiCpuIoWidthUint8, Address, 1, &Data);\r
+}\r
+\r
+VOID\r
+IoWrite16 (\r
+  IN  UINT64    Address,\r
+  IN  UINT16    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiIoWrite (EfiCpuIoWidthUint16, Address, 1, &Data);\r
+}\r
+\r
+VOID\r
+IoWrite32 (\r
+  IN  UINT64    Address,\r
+  IN  UINT32    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte IO write\r
+\r
+Arguments:\r
+  Address - IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiIoWrite (EfiCpuIoWidthUint32, Address, 1, &Data);\r
+}\r
+\r
+UINT8\r
+MemRead8 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT8   Buffer;\r
+\r
+  EfiMemRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+UINT16\r
+MemRead16 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT16  Buffer;\r
+\r
+  EfiMemRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+UINT32\r
+MemRead32 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT32  Buffer;\r
+\r
+  EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+UINT64\r
+MemRead64 (\r
+  IN  UINT64    Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a eight byte Memory mapped IO read\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to read\r
+\r
+Returns: \r
+  Data read\r
+\r
+--*/\r
+{\r
+  UINT64  Buffer;\r
+\r
+  EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer);\r
+  return Buffer;\r
+}\r
+\r
+VOID\r
+MemWrite8 (\r
+  IN  UINT64    Address,\r
+  IN  UINT8     Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a one byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiMemWrite (EfiCpuIoWidthUint8, Address, 1, &Data);\r
+}\r
+\r
+VOID\r
+MemWrite16 (\r
+  IN  UINT64    Address,\r
+  IN  UINT16    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a two byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiMemWrite (EfiCpuIoWidthUint16, Address, 1, &Data);\r
+}\r
+\r
+VOID\r
+MemWrite32 (\r
+  IN  UINT64    Address,\r
+  IN  UINT32    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a four byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiMemWrite (EfiCpuIoWidthUint32, Address, 1, &Data);\r
+}\r
+\r
+VOID\r
+MemWrite64 (\r
+  IN  UINT64    Address,\r
+  IN  UINT64    Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Do a eight byte Memory mapped IO write\r
+\r
+Arguments:\r
+  Address - Memory mapped IO address to write\r
+  Data    - Data to write to Address\r
+\r
+Returns: \r
+  NONE\r
+\r
+--*/\r
+{\r
+  EfiMemWrite (EfiCpuIoWidthUint64, Address, 1, &Data);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s
new file mode 100644 (file)
index 0000000..92f35cc
--- /dev/null
@@ -0,0 +1,149 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    EsalLib.s\r
+//\r
+//  Abstract:\r
+//\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+.file  "EsalLib.s"\r
+\r
+#include  "IpfMacro.i"\r
+\r
+//\r
+// Exports\r
+//\r
+.global GetEsalEntryPoint\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// GetEsalEntryPoint\r
+//\r
+// Return Esal global and PSR register.\r
+//\r
+// On Entry :\r
+//\r
+//\r
+// Return Value:\r
+//        r8  = EFI_SAL_SUCCESS\r
+//        r9  = Physical Plabel\r
+//        r10 = Virtual Plabel\r
+//        r11 = psr\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (GetEsalEntryPoint)\r
+\r
+      NESTED_SETUP (0,8,0,0)\r
+\r
+EsalCalcStart:\r
+      mov   r8  = ip;;\r
+      add   r8  = (EsalEntryPoint - EsalCalcStart), r8;;\r
+      mov   r9  = r8;;\r
+      add   r10 = 0x10, r8;;\r
+      mov   r11 = psr;;\r
+      mov   r8  = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (GetEsalEntryPoint)\r
+\r
+\r
+\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// SetEsalPhysicalEntryPoint\r
+//\r
+// Set the dispatcher entry point\r
+//\r
+// On Entry:\r
+//  in0 = Physical address of Esal Dispatcher\r
+//  in1 = Physical GP\r
+//\r
+// Return Value: \r
+//   r8 = EFI_SAL_SUCCESS\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (SetEsalPhysicalEntryPoint)\r
+\r
+      NESTED_SETUP (2,8,0,0)\r
+\r
+EsalCalcStart1:\r
+      mov   r8   = ip;;\r
+      add   r8   = (EsalEntryPoint - EsalCalcStart1), r8;;\r
+      st8   [r8] = in0;;\r
+      add   r8   = 0x08, r8;;\r
+      st8   [r8] = in1;;\r
+      mov   r8   = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (SetEsalPhysicalEntryPoint)\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// SetEsalVirtualEntryPoint\r
+//\r
+// Register physical address of Esal globals.\r
+//\r
+// On Entry :\r
+//  in0 = Virtual address of Esal Dispatcher\r
+//  in1 = Virtual GP\r
+//\r
+// Return Value: \r
+//  r8 = EFI_SAL_ERROR\r
+// \r
+// As per static calling conventions. \r
+// \r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (SetEsalVirtualEntryPoint)\r
+\r
+      NESTED_SETUP (2,8,0,0)\r
+\r
+EsalCalcStart2:\r
+      mov   r8   = ip;;\r
+      add   r8   = (EsalEntryPoint - EsalCalcStart2), r8;;\r
+      add   r8   = 0x10, r8;;\r
+      st8   [r8] = in0;;\r
+      add   r8   = 0x08, r8;;\r
+      st8   [r8] = in1;;\r
+      mov   r8   = r0;;\r
+\r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (SetEsalVirtualEntryPoint)\r
+\r
+\r
+\r
+\r
+.align 32\r
+EsalEntryPoint: \r
+    data8 0   // Physical Entry\r
+    data8 0   //         GP\r
+    data8 0   // Virtual Entry\r
+    data8 0   //         GP\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c
new file mode 100644 (file)
index 0000000..266c6b1
--- /dev/null
@@ -0,0 +1,334 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Fvb.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano Firmware Volume Block \r
+  protocol abstraction at runtime.\r
+\r
+  All these functions convert EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID\r
+  class function to the Runtime Lib function. There is a 1 to 1 mapping.\r
+\r
+  If you are using any of these lib functions.you must first call FvbInitialize ().\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include "SalApi.h"\r
+\r
+EFI_STATUS\r
+EfiFvbInitialize (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Initialize globals and register Fvb Protocol notification function.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// The following functions wrap Fvb protocol in the Runtime Lib functions.\r
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r
+// thus the sequence of FVB protocol addition define Instance.\r
+//\r
+// EfiFvbInitialize () must be called before any of the following functions\r
+// must be called.\r
+//\r
+EFI_STATUS\r
+EfiFvbReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  Offset                - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, Read, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  Offset                - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, Write, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN UINTN                                Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, EraseBlock, Instance, Lba, 0, 0, 0, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN EFI_FVB_ATTRIBUTES                   Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *BaseAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  BaseAddress           - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (&Guid, GetPhysicalAddress, Instance, (UINT64) BaseAddress, 0, 0, 0, 0, 0).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetBlockSize (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  OUT UINTN                               *BlockSize,\r
+  OUT UINTN                               *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose block size is going to be\r
+                          returned\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns:\r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (\r
+          &Guid,\r
+          GetBlockSize,\r
+          Instance,\r
+          Lba,\r
+          (UINT64) BlockSize,\r
+          (UINT64) NumOfBlocks,\r
+          0,\r
+          0,\r
+          0\r
+          ).Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetLastLba         - Offset into the last block at which to end erasing\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+\r
+  return EfiCallEsalService (\r
+          &Guid,\r
+          EraseCustomBlockRange,\r
+          Instance,\r
+          StartLba,\r
+          OffsetStartLba,\r
+          LastLba,\r
+          OffsetLastLba,\r
+          0,\r
+          0\r
+          ).Status;\r
+}\r
+EFI_STATUS\r
+EfiFvbShutdown (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Release resources allocated in EfiFvbInitialize.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}
\ 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 (file)
index 0000000..8e387c2
--- /dev/null
@@ -0,0 +1,88 @@
+//++\r
+// Copyright (c) 2004, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+//  Module Name:\r
+//\r
+//    IpfCpuCache.s\r
+//\r
+//  Abstract:\r
+//\r
+//    Contains Misc assembly procedures to support IPF CPU AP.\r
+//\r
+// Revision History:\r
+//\r
+//--\r
+\r
+.file  "IpfCpuCache.s"\r
+\r
+#include  "IpfMacro.i"\r
+#include  "IpfDefines.h"\r
+\r
+//-----------------------------------------------------------------------------\r
+//++\r
+// Flush Cache\r
+//\r
+// Arguments : \r
+\r
+// Input = in0 = Starting Address to Flush.\r
+// Input = in1 = Length in bytes.\r
+// Input = b0 = return branch register.\r
+// On Entry :\r
+//\r
+// Return Value: \r
+//\r
+//  VOID\r
+//  SalFlushCache (\r
+//    IN UINT64   BaseToFlush,\r
+//    IN UINT64   LengthToFlush\r
+//    );\r
+//\r
+//--\r
+//---------------------------------------------------------------------------\r
+PROCEDURE_ENTRY (SalFlushCache)\r
+\r
+      NESTED_SETUP (5,8,0,0)\r
+            \r
+      mov         loc2 = ar.lc\r
+      \r
+      mov         loc3 = in0                  // Start address.\r
+      mov         loc4 = in1;;                // Length in bytes.\r
+      \r
+      cmp.eq  p6,p7 = loc4, r0;;               // If Length is zero then don't flush any cache\r
+      (p6)  br.spnt.many DoneFlushingC;;         \r
+      \r
+      add         loc4 = loc4,loc3 \r
+      mov         loc5 = 1;;\r
+      sub         loc4 = loc4, loc5 ;; // the End address to flush\r
+                                         \r
+      dep         loc3 = r0,loc3,0,5          \r
+      dep         loc4 = r0,loc4,0,5;;         \r
+      shr         loc3 = loc3,5             \r
+      shr         loc4 = loc4,5;;    // 32 byte cache line\r
+      \r
+      sub         loc4 = loc4,loc3;; // total flush count, It should be add 1 but \r
+                                     // the br.cloop will first execute one time \r
+      mov         loc3 = in0                  \r
+      mov         loc5 = 32      \r
+      mov         ar.lc = loc4;;\r
+\r
+StillFlushingC:\r
+      fc          loc3;; \r
+      sync.i;;\r
+      srlz.i;;\r
+      add         loc3 = loc5,loc3;;\r
+      br.cloop.sptk.few StillFlushingC;;\r
+\r
+DoneFlushingC:      \r
+      mov         ar.lc = loc2     \r
+      NESTED_RETURN\r
+\r
+PROCEDURE_EXIT (SalFlushCache)\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c
new file mode 100644 (file)
index 0000000..e7de998
--- /dev/null
@@ -0,0 +1,170 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Lock.c\r
+\r
+Abstract:\r
+\r
+  Support for locking lib services. These primitives may be implemented \r
+  as Esal calls but since these result in small code that us position\r
+  independent, we can use lib functions. ESAL calls have a significant\r
+  software overhead and too deep nesting is bad for the stack.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+extern\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock. There is \r
+  no concept of TPL at runtime hence priority is\r
+  ignored.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - Ignored\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+{\r
+  Lock->Tpl       = Priority;\r
+  Lock->OwnerTpl  = 0;\r
+  Lock->Lock      = 0;\r
+}\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock. For now,\r
+  only allow one level of nesting.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+{\r
+  if (Lock->Lock != 0) {\r
+    //\r
+    // Lock is already owned, so bail out\r
+    //\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+  }\r
+\r
+  Lock->Lock += 1;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  Lock owned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiAcquireLockOrFail (Lock);\r
+\r
+  //\r
+  // Lock was already locked.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    Lock unowned\r
+\r
+--*/\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  Tpl = Lock->OwnerTpl;\r
+\r
+  ASSERT (Lock->Lock == 1);\r
+  Lock->Lock -= 1;\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    gBS->RestoreTPL (Tpl);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
new file mode 100644 (file)
index 0000000..ae66cf4
--- /dev/null
@@ -0,0 +1,1317 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano Sal drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r
+#include "IpfDefines.h"\r
+#include "SalApi.h"\r
+\r
+//\r
+// Worker functions in EsalLib.s\r
+//\r
+SAL_RETURN_REGS\r
+GetEsalEntryPoint (\r
+  VOID\r
+  );\r
+\r
+SAL_RETURN_REGS\r
+SetEsalPhysicalEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  );\r
+\r
+SAL_RETURN_REGS\r
+SetEsalVirtualEntryPoint (\r
+  IN  UINT64  EntryPoint,\r
+  IN  UINT64  Gp\r
+  );\r
+\r
+VOID\r
+SalFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS  Start,\r
+  IN UINT64                Length\r
+  );\r
+\r
+//\r
+// Module Globals. It's not valid to use these after the\r
+// EfiRuntimeLibVirtualNotifyEvent has fired.\r
+//\r
+static EFI_EVENT                          mEfiVirtualNotifyEvent;\r
+static EFI_RUNTIME_SERVICES               *mRT;\r
+static EFI_PLABEL                         mPlabel;\r
+static EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;\r
+static BOOLEAN                            mRuntimeLibInitialized = FALSE;\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI and SAL can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in \r
+  lib to virtual mode.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_EVENT_NOTIFY  ChildNotify;\r
+\r
+  if (Context != NULL) {\r
+    //\r
+    // Call child event\r
+    //\r
+    ChildNotify = (EFI_EVENT_NOTIFY) (UINTN) Context;\r
+    ChildNotify (Event, NULL);\r
+  }\r
+\r
+  mRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mPlabel.EntryPoint);\r
+  mRT->ConvertPointer (EFI_INTERNAL_POINTER | EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);\r
+\r
+  SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
+\r
+  //\r
+  // Clear out BootService globals\r
+  //\r
+  gBS = NULL;\r
+  gST = NULL;\r
+  mRT = NULL;\r
+\r
+  //\r
+  // Pointers don't work you must use a direct lib call\r
+  //\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     GoVirtualChildEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_PLABEL  *Plabel;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST                     = SystemTable;\r
+  gBS                     = SystemTable->BootServices;\r
+  mRT                     = SystemTable->RuntimeServices;\r
+  Status                  = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // The protocol contains a function pointer, which is an indirect procedure call.\r
+  // An indirect procedure call goes through a plabel, and pointer to a function is\r
+  // a pointer to a plabel. To implement indirect procedure calls that can work in\r
+  // both physical and virtual mode, two plabels are required (one physical and one\r
+  // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r
+  // away. We cache it in a module global, so we can register the vitrual version.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Plabel              = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r
+\r
+  mPlabel.EntryPoint  = Plabel->EntryPoint;\r
+  mPlabel.GP          = Plabel->GP;\r
+\r
+  SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r
+\r
+  //\r
+  // Create a Virtual address change notification event. Pass in the callers\r
+  // GoVirtualChildEvent so it's get passed to the event as contex.\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+                  EFI_TPL_NOTIFY,\r
+                  EfiRuntimeLibVirtualNotifyEvent,\r
+                  (VOID *) GoVirtualChildEvent,\r
+                  &mEfiVirtualNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiShutdownRuntimeDriverLib (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!mRuntimeLibInitialized) {\r
+    //\r
+    // You must call EfiInitializeRuntimeDriverLib() first\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized = FALSE;\r
+\r
+  //\r
+  // Close SetVirtualAddressMap () notify function\r
+  //\r
+  Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+    \r
+EFI_STATUS\r
+RegisterEsalFunction (\r
+  IN  UINT64                                    FunctionId,\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC            Function,\r
+  IN  VOID                                      *ModuleGlobal\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class Function and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  FunctionId    - ID of function to register\r
+  ClassGuid     - GUID of function class \r
+  Function      - Function to register under ClassGuid/FunctionId pair\r
+  ModuleGlobal  - Module global for Function.\r
+\r
+Returns: \r
+  EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r
+\r
+--*/\r
+{\r
+  return mEsalBootService->AddExtendedSalProc (\r
+                            mEsalBootService,\r
+                            ClassGuid,\r
+                            FunctionId,\r
+                            Function,\r
+                            ModuleGlobal\r
+                            );\r
+}\r
+\r
+EFI_STATUS\r
+RegisterEsalClass (\r
+  IN  EFI_GUID                                  *ClassGuid,\r
+  IN  VOID                                      *ModuleGlobal,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register ESAL Class and it's asociated global.\r
+  This function is boot service only!\r
+\r
+Arguments:\r
+  ClassGuid     - GUID of function class \r
+  ModuleGlobal  - Module global for Function.\r
+  ...           - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r
+                  indicates the end of the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS - All members of ClassGuid registered\r
+\r
+--*/\r
+{\r
+  VA_LIST                         Args;\r
+  EFI_STATUS                      Status;\r
+  SAL_INTERNAL_EXTENDED_SAL_PROC  Function;\r
+  UINT64                          FunctionId;\r
+  EFI_HANDLE                      NewHandle;\r
+\r
+  VA_START (Args, ModuleGlobal);\r
+\r
+  Status = EFI_SUCCESS;\r
+  while (!EFI_ERROR (Status)) {\r
+    Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);\r
+    if (Function == NULL) {\r
+      break;\r
+    }\r
+\r
+    FunctionId  = VA_ARG (Args, UINT64);\r
+\r
+    Status      = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  NewHandle = NULL;\r
+  return gBS->InstallProtocolInterface (\r
+                &NewHandle,\r
+                ClassGuid,\r
+                EFI_NATIVE_INTERFACE,\r
+                NULL\r
+                );\r
+}\r
+\r
+SAL_RETURN_REGS\r
+EfiCallEsalService (\r
+  IN  EFI_GUID                                      *ClassGuid,\r
+  IN  UINT64                                        FunctionId,\r
+  IN  UINT64                                        Arg2,\r
+  IN  UINT64                                        Arg3,\r
+  IN  UINT64                                        Arg4,\r
+  IN  UINT64                                        Arg5,\r
+  IN  UINT64                                        Arg6,\r
+  IN  UINT64                                        Arg7,\r
+  IN  UINT64                                        Arg8\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call module that is not linked direclty to this module. This code is IP \r
+  relative and hides the binding issues of virtual or physical calling. The\r
+  function that gets dispatched has extra arguments that include the registered\r
+  module global and a boolean flag to indicate if the system is in virutal mode.\r
+\r
+Arguments:\r
+  ClassGuid   - GUID of function\r
+  FunctionId  - Function in ClassGuid to call\r
+  Arg2        - Argument 2 ClassGuid/FunctionId defined\r
+  Arg3        - Argument 3 ClassGuid/FunctionId defined\r
+  Arg4        - Argument 4 ClassGuid/FunctionId defined\r
+  Arg5        - Argument 5 ClassGuid/FunctionId defined\r
+  Arg6        - Argument 6 ClassGuid/FunctionId defined\r
+  Arg7        - Argument 7 ClassGuid/FunctionId defined\r
+  Arg8        - Argument 8 ClassGuid/FunctionId defined\r
+\r
+Returns: \r
+  Status of ClassGuid/FuncitonId\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS       ReturnReg;\r
+  SAL_EXTENDED_SAL_PROC EsalProc;\r
+\r
+  ReturnReg = GetEsalEntryPoint ();\r
+  if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r
+    return ReturnReg;\r
+  }\r
+\r
+  if (ReturnReg.r11 & PSR_IT_MASK) {\r
+    //\r
+    // Virtual mode plabel to entry point\r
+    //\r
+    EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10;\r
+  } else {\r
+    //\r
+    // Physical mode plabel to entry point\r
+    //\r
+    EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9;\r
+  }\r
+\r
+  return EsalProc (\r
+          ClassGuid,\r
+          FunctionId,\r
+          Arg2,\r
+          Arg3,\r
+          Arg4,\r
+          Arg5,\r
+          Arg6,\r
+          Arg7,\r
+          Arg8\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EfiConvertPointer (\r
+  IN UINTN                     DebugDisposition,\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+BOOLEAN\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r
+\r
+  return (BOOLEAN) (ReturnReg.r9 == 1);\r
+}\r
+\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if ExitBootService () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If ExitBootService () has been called\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r
+\r
+  return (BOOLEAN) (ReturnReg.r9 == 1);\r
+}\r
+\r
+EFI_STATUS\r
+EfiReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+\r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID;\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                StatusCode,\r
+                (UINT64) CodeType,\r
+                (UINT64) Value,\r
+                (UINT64) Instance,\r
+                (UINT64) CallerId,\r
+                (UINT64) Data,\r
+                0,\r
+                0\r
+                );\r
+\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+//\r
+//  Sal Reset Driver Class\r
+//\r
+VOID\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE     ResetType,\r
+  IN EFI_STATUS         ResetStatus,\r
+  IN UINTN              DataSize,\r
+  IN CHAR16             *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;\r
+\r
+  EfiCallEsalService (\r
+    &Guid,\r
+    ResetSystem,\r
+    (UINT64) ResetType,\r
+    (UINT64) ResetStatus,\r
+    (UINT64) DataSize,\r
+    (UINT64) ResetData,\r
+    0,\r
+    0,\r
+    0\r
+    );\r
+}\r
+//\r
+//  Sal MTC Driver Class\r
+//\r
+EFI_STATUS\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform¡¯s monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0);\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+//\r
+// Sal Variable Driver Class\r
+//\r
+EFI_STATUS\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalGetVariable,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                (UINT64) Attributes,\r
+                (UINT64) DataSize,\r
+                (UINT64) Data,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalGetNextVariableName,\r
+                (UINT64) VariableNameSize,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                0,\r
+                0,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalSetVariable,\r
+                (UINT64) VariableName,\r
+                (UINT64) VendorGuid,\r
+                (UINT64) Attributes,\r
+                (UINT64) DataSize,\r
+                (UINT64) Data,\r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+EFI_STATUS\r
+EfiQueryVariableInfo (\r
+  IN UINT32           Attributes,\r
+  OUT UINT64          *MaximumVariableStorageSize,\r
+  OUT UINT64          *RemainingVariableStorageSize,\r
+  OUT UINT64          *MaximumVariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (\r
+                &Guid,\r
+                EsalQueryVariableInfo,\r
+                (UINT64) Attributes,\r
+                (UINT64) MaximumVariableStorageSize,\r
+                (UINT64) RemainingVariableStorageSize,\r
+                (UINT64) MaximumVariableSize,\r
+                0, \r
+                0,\r
+                0\r
+                );\r
+  return (EFI_STATUS) ReturnReg.Status;\r
+}\r
+\r
+#endif\r
+\r
+//\r
+//  Sal RTC Driver Class.\r
+//\r
+EFI_STATUS\r
+EfiGetTime (\r
+  OUT EFI_TIME              *Time,\r
+  OUT EFI_TIME_CAPABILITIES *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device¡¯s\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetTime (\r
+  OUT EFI_TIME              *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN       *Enabled,\r
+  OUT BOOLEAN       *Pending,\r
+  OUT EFI_TIME      *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN        Enable,\r
+  IN EFI_TIME       *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0);\r
+  return ReturnReg.Status;\r
+}\r
+\r
+\r
+\r
+//\r
+//  Base IO Services\r
+//\r
+EFI_STATUS\r
+EfiIoRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of read transaction, and repeat operation to use\r
+  Address - IO address to read\r
+  Count   - Number of times to read the IO address.\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+\r
+  return ReturnReg.Status;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EfiIoWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, IoWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+\r
+  return ReturnReg.Status;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemRead (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN  OUT VOID                      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a Memory mapped IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of each read transaction.\r
+  Address - Memory mapped IO address to read\r
+  Count   - Number of Width quanta to read\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+\r
+  return ReturnReg.Status;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemWrite (\r
+  IN     EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                     Address,\r
+  IN     UINTN                      Count,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a memory mapped IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+\r
+  SAL_RETURN_REGS ReturnReg;\r
+\r
+  EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
+\r
+  ReturnReg = EfiCallEsalService (&Guid, MemWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+\r
+  return ReturnReg.Status;\r
+\r
+}\r
+\r
+\r
+#define EFI_PCI_ADDRESS_IPF(_seg, _bus, _devfunc, _reg) \\r
+    (((_seg) << 24) | ((_bus) << 16) | ((_devfunc) << 8) | (_reg)) & 0xFFFFFFFF\r
+\r
+//\r
+//  PCI Class Functions\r
+//\r
+UINT8\r
+PciRead8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle read\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64          Address;\r
+  SAL_RETURN_REGS Return;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  Return  = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 1, 0, 0, 0, 0, 0);\r
+\r
+  return (UINT8) Return.r9;\r
+}\r
+\r
+\r
+UINT16\r
+PciRead16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle read\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64          Address;\r
+  SAL_RETURN_REGS Return;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  Return  = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 2, 0, 0, 0, 0, 0);\r
+\r
+  return (UINT16) Return.r9;\r
+}\r
+\r
+UINT32\r
+PciRead32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle read\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64          Address;\r
+  SAL_RETURN_REGS Return;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  Return  = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 4, 0, 0, 0, 0, 0);\r
+\r
+  return (UINT32) Return.r9;\r
+}\r
+\r
+VOID\r
+PciWrite8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT8   Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle write\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64    Address;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 1, Data, 0, 0, 0, 0);\r
+}\r
+\r
+VOID\r
+PciWrite16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT16  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle write\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64    Address;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 2, Data, 0, 0, 0, 0);\r
+}\r
+\r
+VOID\r
+PciWrite32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT32  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle write\r
+\r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_GUID  Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+  UINT64    Address;\r
+\r
+  Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r
+  EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 4, Data, 0, 0, 0, 0);\r
+}\r
+\r
+//\r
+// Stall class functions\r
+//\r
+VOID\r
+EfiStall (\r
+  IN  UINTN   Microseconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+ Delay for at least the request number of microseconds\r
+\r
+Arguments:\r
+  Microseconds - Number of microseconds to delay.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_GUID        Guid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID;\r
+\r
+  if (EfiAtRuntime ()) {\r
+    EfiCallEsalService (&Guid, Stall, Microseconds, 4, 0, 0, 0, 0, 0);\r
+  } else {\r
+    gBS->Stall (Microseconds);\r
+  }\r
+}\r
+//\r
+// Cache Flush Routine.\r
+//\r
+EFI_STATUS\r
+EfiCpuFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS          Start,\r
+  IN UINT64                        Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush cache with specified range.\r
+\r
+Arguments:\r
+\r
+  Start   - Start address\r
+  Length  - Length in bytes\r
+\r
+Returns:\r
+\r
+  Status code\r
+  \r
+  EFI_SUCCESS - success\r
+\r
+--*/\r
+{\r
+  SalFlushCache (Start, Length);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c
new file mode 100644 (file)
index 0000000..7f141ec
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LibGlobals.c\r
+\r
+Abstract:\r
+\r
+  Lib Globals\r
+\r
+  gBS         - Pointer to the EFI Boot Services Table\r
+  gST         - Pointer to EFI System Table\r
+  gRtErrorLevel - Error level used with DEBUG () macro\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
+\r
+//\r
+// Lib globals that can ONLY be used at BootServices time!\r
+//\r
+EFI_BOOT_SERVICES *gBS;\r
+EFI_SYSTEM_TABLE  *gST;\r
+EFI_DXE_SERVICES  *gDS          = NULL;\r
+UINTN             gRtErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD;\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
new file mode 100644 (file)
index 0000000..ac77780
--- /dev/null
@@ -0,0 +1,705 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation                                                  \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RtDevicePath.c\r
+\r
+Abstract:\r
+\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include "RtDevicePath.h"\r
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
+#include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+\r
+STATIC\r
+VOID *\r
+InternalAllocatePool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
+  return Memory;\r
+}\r
+\r
+STATIC\r
+VOID *\r
+InternalAllocateCopyPool (\r
+  IN  UINTN   AllocationSize,\r
+  IN  VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool and use a buffer provided by \r
+  caller to fill it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+  \r
+  Buffer          - Buffer that will be filled into the buffer allocated\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = NULL;\r
+  gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
+  if (Memory != NULL) {\r
+    gBS->CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+STATIC\r
+VOID *\r
+InternalAllocateZeroPool (\r
+  IN  UINTN   AllocationSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate BootServicesData pool and zero it.\r
+\r
+Arguments:\r
+\r
+  AllocationSize  - The size to allocate\r
+\r
+Returns:\r
+\r
+  Pointer of the buffer allocated.\r
+\r
+--*/\r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = InternalAllocatePool (AllocationSize);\r
+  if (Memory != NULL) {\r
+    gBS->SetMem (Memory, AllocationSize, 0);\r
+  }\r
+\r
+  return Memory;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
+  OUT UINTN                         *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function retrieves the next device path instance from a device path data structure.\r
+\r
+Arguments:\r
+  DevicePath           - A pointer to a device path data structure.\r
+\r
+  Size                 - A pointer to the size of a device path instance in bytes.\r
+\r
+Returns:\r
+\r
+  This function returns a pointer to the current device path instance.\r
+  In addition, it returns the size in bytes of the current device path instance in Size,\r
+  and a pointer to the next device path instance in DevicePath.\r
+  If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ReturnValue;\r
+  UINT8                     Temp;\r
+\r
+  if (*DevicePath == NULL) {\r
+    if (Size != NULL) {\r
+      *Size = 0;\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Find the end of the device path instance\r
+  //\r
+  DevPath = *DevicePath;\r
+  while (!IsDevicePathEndType (DevPath)) {\r
+    DevPath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  //\r
+  // Compute the size of the device path instance\r
+  //\r
+  if (Size != NULL) {\r
+    *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+  }\r
+\r
+  //\r
+  // Make a copy and return the device path instance\r
+  //\r
+  Temp              = DevPath->SubType;\r
+  DevPath->SubType  = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
+  ReturnValue       = RtEfiDuplicateDevicePath (*DevicePath);\r
+  DevPath->SubType  = Temp;\r
+\r
+  //\r
+  // If DevPath is the end of an entire device path, then another instance\r
+  // does not follow, so *DevicePath is set to NULL.\r
+  //\r
+  if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {\r
+    *DevicePath = NULL;\r
+  } else {\r
+    *DevicePath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+BOOLEAN\r
+RtEfiIsDevicePathMultiInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE is this is a multi instance device path.\r
+\r
+Arguments:\r
+  DevicePath  - A pointer to a device path data structure.\r
+\r
+\r
+Returns:\r
+  TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi\r
+  instance.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
+\r
+  if (DevicePath == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  Node = DevicePath;\r
+  while (!EfiIsDevicePathEnd (Node)) {\r
+    if (EfiIsDevicePathEndInstance (Node)) {\r
+      return TRUE;\r
+    }\r
+\r
+    Node = EfiNextDevicePathNode (Node);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+UINTN\r
+RtEfiDevicePathSize (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Calculate the space size of a device path.\r
+\r
+Arguments:\r
+\r
+  DevicePath  - A specified device path\r
+\r
+Returns:\r
+\r
+  The size.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  if (DevicePath == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!EfiIsDevicePathEnd (DevicePath)) {\r
+    DevicePath = EfiNextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Compute the size and add back in the size of the end device path structure\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiDevicePathFromHandle (\r
+  IN EFI_HANDLE  Handle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get the device path protocol interface installed on a specified handle.\r
+\r
+Arguments:\r
+\r
+  Handle  - a specified handle\r
+\r
+Returns:\r
+\r
+  The device path protocol interface installed on that handle.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  DevicePath = NULL;\r
+  gBS->HandleProtocol (\r
+        Handle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        (VOID *) &DevicePath\r
+        );\r
+  return DevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiDuplicateDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Duplicate a device path structure.\r
+\r
+Arguments:\r
+\r
+  DevicePath  - The device path to duplicated.\r
+\r
+Returns:\r
+\r
+  The duplicated device path.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     Size;\r
+\r
+  if (DevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Compute the size\r
+  //\r
+  Size = RtEfiDevicePathSize (DevicePath);\r
+  if (Size == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Allocate space for duplicate device path\r
+  //\r
+  NewDevicePath = InternalAllocateCopyPool (Size, DevicePath);\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiAppendDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a Src1 and Src2 together.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Src2  - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  A pointer to the new device path is returned.\r
+  NULL is returned if space for the new device path could not be allocated from pool.\r
+  It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.\r
+\r
+--*/\r
+{\r
+  UINTN                     Size;\r
+  UINTN                     Size1;\r
+  UINTN                     Size2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath;\r
+\r
+  //\r
+  // If there's only 1 path, just duplicate it\r
+  //\r
+  if (!Src1) {\r
+    ASSERT (!IsDevicePathUnpacked (Src2));\r
+    return RtEfiDuplicateDevicePath (Src2);\r
+  }\r
+\r
+  if (!Src2) {\r
+    ASSERT (!IsDevicePathUnpacked (Src1));\r
+    return RtEfiDuplicateDevicePath (Src1);\r
+  }\r
+\r
+  //\r
+  // Allocate space for the combined device path. It only has one end node of\r
+  // length EFI_DEVICE_PATH_PROTOCOL\r
+  //\r
+  Size1         = RtEfiDevicePathSize (Src1);\r
+  Size2         = RtEfiDevicePathSize (Src2);\r
+  Size          = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+\r
+  NewDevicePath = InternalAllocateCopyPool (Size, Src1);\r
+\r
+  if (NewDevicePath != NULL) {\r
+\r
+    //\r
+    // Over write Src1 EndNode and do the copy\r
+    //\r
+    SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
+    EfiCopyMem (SecondDevicePath, Src2, Size2);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiAppendDevicePathNode (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Node\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to append a device path node to the end of another device path.\r
+\r
+Arguments:\r
+  Src1  - A pointer to a device path data structure.\r
+\r
+  Node - A pointer to a device path data structure.\r
+\r
+Returns:\r
+  This function returns a pointer to the new device path.\r
+  If there is not enough temporary pool memory available to complete this function,\r
+  then NULL is returned.\r
+\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Temp;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     NodeLength;\r
+\r
+  //\r
+  // Build a Node that has a terminator on it\r
+  //\r
+  NodeLength  = DevicePathNodeLength (Node);\r
+\r
+  Temp        = InternalAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node);\r
+  if (Temp == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Add and end device path node to convert Node to device path\r
+  //\r
+  NextNode = NextDevicePathNode (Temp);\r
+  SetDevicePathEndNode (NextNode);\r
+\r
+  //\r
+  // Append device paths\r
+  //\r
+  NewDevicePath = RtEfiAppendDevicePath (Src1, Temp);\r
+  gBS->FreePool (Temp);\r
+  return NewDevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiFileDevicePath (\r
+  IN EFI_HANDLE               Device  OPTIONAL,\r
+  IN CHAR16                   *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function allocates a device path for a file and appends it to an existiong\r
+  device path.\r
+\r
+Arguments:\r
+  Device     - A pointer to a device handle.\r
+\r
+  FileName   - A pointer to a Null-terminated Unicodestring.\r
+\r
+Returns:\r
+  A device path contain the file name.\r
+\r
+--*/\r
+{\r
+  UINTN                     Size;\r
+  FILEPATH_DEVICE_PATH      *FilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Eop;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  for (Size = 0; FileName[Size] != 0; Size++)\r
+    ;\r
+  Size        = (Size + 1) * 2;\r
+\r
+  FilePath    = InternalAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+\r
+  DevicePath  = NULL;\r
+\r
+  if (FilePath != NULL) {\r
+\r
+    //\r
+    // Build a file path\r
+    //\r
+    FilePath->Header.Type     = MEDIA_DEVICE_PATH;\r
+    FilePath->Header.SubType  = MEDIA_FILEPATH_DP;\r
+    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
+    EfiCopyMem (FilePath->PathName, FileName, Size);\r
+    Eop = NextDevicePathNode (&FilePath->Header);\r
+    SetDevicePathEndNode (Eop);\r
+\r
+    //\r
+    // Append file path to device's device path\r
+    //\r
+\r
+    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;\r
+    if (Device != NULL) {\r
+      DevicePath = RtEfiAppendDevicePath (\r
+                    RtEfiDevicePathFromHandle (Device),\r
+                    DevicePath\r
+                    );\r
+\r
+      gBS->FreePool (FilePath);\r
+    }\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+RtEfiAppendDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Src,\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Append a device path instance to another.\r
+\r
+Arguments:\r
+\r
+  Src       - The device path instance to be appended with.\r
+  Instance  - The device path instance appending the other.\r
+\r
+Returns:\r
+\r
+  The contaction of these two.\r
+\r
+--*/\r
+{\r
+  UINT8                     *Ptr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  UINTN                     SrcSize;\r
+  UINTN                     InstanceSize;\r
+\r
+  if (Src == NULL) {\r
+    return RtEfiDuplicateDevicePath (Instance);\r
+  }\r
+\r
+  SrcSize       = RtEfiDevicePathSize (Src);\r
+  InstanceSize  = RtEfiDevicePathSize (Instance);\r
+\r
+  Ptr           = InternalAllocateCopyPool (SrcSize + InstanceSize, Src);\r
+  if (Ptr != NULL) {\r
+\r
+    DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+\r
+    while (!IsDevicePathEnd (DevPath)) {\r
+      DevPath = NextDevicePathNode (DevPath);\r
+    }\r
+    //\r
+    // Convert the End to an End Instance, since we are\r
+    //  appending another instacne after this one its a good\r
+    //  idea.\r
+    //\r
+    DevPath->SubType  = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
+\r
+    DevPath           = NextDevicePathNode (DevPath);\r
+    EfiCopyMem (DevPath, Instance, InstanceSize);\r
+  }\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+RtEfiInitializeFwVolDevicepathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,\r
+  IN EFI_GUID                               *NameGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a Firmware Volume (FV) Media Device Path node.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability.\r
+\r
+Arguments:\r
+\r
+  FvDevicePathNode  - Pointer to a FV device path node to initialize\r
+  NameGuid          - FV file name to use in FvDevicePathNode\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000)\r
+  //\r
+  // Use old Device Path\r
+  //\r
+  FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+\r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  FvDevicePathNode->Piwg.Header.Type     = MEDIA_DEVICE_PATH;\r
+  FvDevicePathNode->Piwg.Header.SubType  = MEDIA_VENDOR_DP;\r
+  SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
+\r
+  //\r
+  // Add the GUID for generic PIWG device paths\r
+  //\r
+  EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID));\r
+\r
+  //\r
+  // Add in the FW Vol File Path PIWG defined inforation\r
+  //\r
+  FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
+\r
+#endif\r
+  EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID));\r
+}\r
+\r
+EFI_GUID *\r
+EFIAPI\r
+RtEfiGetNameGuidFromFwVolDevicePathNode (\r
+  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH   *FvDevicePathNode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
+  \r
+  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
+  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
+  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
+  device path is defined for PIWG extensions of device path. If the code \r
+  is compiled to conform with the UEFI 2.0 specification use the new device path\r
+  else use the old form for backwards compatability. The return value to this\r
+  function points to a location in FvDevicePathNode and it does not allocate\r
+  new memory for the GUID pointer that is returned.\r
+\r
+Arguments:\r
+\r
+  FvDevicePathNode  - Pointer to FV device path to check\r
+\r
+Returns:\r
+\r
+  NULL              - FvDevicePathNode is not valid.\r
+  Other             - FvDevicePathNode is valid and pointer to NameGuid was returned.\r
+\r
+--*/\r
+{\r
+#if (EFI_SPECIFICATION_VERSION != 0x00020000)\r
+  //\r
+  // Use old Device Path\r
+  //\r
+  if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
+    return &FvDevicePathNode->NameGuid;\r
+  }\r
+\r
+#else\r
+  //\r
+  // Use the new Device path that does not conflict with the UEFI 2.0\r
+  //\r
+  if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH &&\r
+      DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) {\r
+    if (EfiCompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
+      if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
+        return &FvDevicePathNode->NameGuid;\r
+      }\r
+    }\r
+  }\r
+#endif  \r
+  return NULL;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c
new file mode 100644 (file)
index 0000000..1cecb47
--- /dev/null
@@ -0,0 +1,617 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Fvb.c \r
+\r
+Abstract:\r
+\r
+  Firmware Volume Block Protocol Runtime Abstraction\r
+\r
+  mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the \r
+  index in the mFvbEntry array. This should be the same sequence as the FVB's\r
+  were described in the HOB. We have to remember the handle so we can tell if \r
+  the protocol has been reinstalled and it needs updateing.\r
+\r
+  If you are using any of these lib functions.you must first call FvbInitialize ().\r
+\r
+Key:\r
+  FVB - Firmware Volume Block\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)\r
+\r
+//\r
+// Lib will ASSERT if more FVB devices than this are added to the system.\r
+//\r
+UINTN             mFvbCount;\r
+VOID              *mFvbRegistration;\r
+VOID              *mFvbExtRegistration;\r
+static EFI_EVENT  mEfiFvbVirtualNotifyEvent;\r
+BOOLEAN           gEfiFvbInitialized = FALSE;\r
+EFI_EVENT         mFvbEvent;\r
+\r
+BOOLEAN\r
+IsMemoryRuntime (\r
+  IN VOID   *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check whether an address is runtime memory or not.\r
+\r
+Arguments:\r
+\r
+  Address - The Address being checked.\r
+  \r
+Returns: \r
+  TRUE    - The address is runtime memory.\r
+  FALSE   - The address is not runtime memory.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINT8                                TmpMemoryMap[1];\r
+  UINTN                                MapKey;\r
+  UINTN                                DescriptorSize;\r
+  UINT32                               DescriptorVersion;\r
+  UINTN                                MemoryMapSize;\r
+  EFI_MEMORY_DESCRIPTOR                *MemoryMap;\r
+  EFI_MEMORY_DESCRIPTOR                *MemoryMapPtr;\r
+  BOOLEAN                              IsRuntime;\r
+  UINTN                                Index;\r
+\r
+  IsRuntime = FALSE;\r
+\r
+  //\r
+  // Get System MemoryMapSize\r
+  //\r
+  MemoryMapSize = 1;\r
+  Status = gBS->GetMemoryMap (\r
+                  &MemoryMapSize,\r
+                  (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,\r
+                  &MapKey,\r
+                  &DescriptorSize,\r
+                  &DescriptorVersion\r
+                  );\r
+  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
+  //\r
+  // Enlarge space here, because we will allocate pool now.\r
+  //\r
+  MemoryMapSize += EFI_PAGE_SIZE;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  MemoryMapSize,\r
+                  (VOID**)&MemoryMap\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get System MemoryMap\r
+  //\r
+  Status = gBS->GetMemoryMap (\r
+                  &MemoryMapSize,\r
+                  MemoryMap,\r
+                  &MapKey,\r
+                  &DescriptorSize,\r
+                  &DescriptorVersion\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  MemoryMapPtr = MemoryMap;\r
+  //\r
+  // Search the request Address\r
+  //\r
+  for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {\r
+    if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&\r
+        ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart\r
+                                              + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {\r
+      //\r
+      // Found it\r
+      //\r
+      if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {\r
+        IsRuntime = TRUE;\r
+      }\r
+      break;\r
+    }\r
+    //\r
+    // Get next item\r
+    //\r
+    MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);\r
+  }\r
+\r
+  //\r
+  // Done\r
+  //\r
+  gBS->FreePool (MemoryMapPtr);\r
+\r
+  return IsRuntime;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+FvbNotificationFunction (\r
+  IN  EFI_EVENT       Event,\r
+  IN  VOID            *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r
+  reinstalled.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                         Status;\r
+  UINTN                              BufferSize;\r
+  EFI_HANDLE                         Handle;\r
+  UINTN                              Index;\r
+  UINTN                              UpdateIndex;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
+  EFI_FVB_EXTENSION_PROTOCOL         *FvbExtension;\r
+\r
+  while (TRUE) {\r
+    BufferSize = sizeof (Handle);\r
+    Status = gBS->LocateHandle (\r
+                    ByRegisterNotify,\r
+                    &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                    mFvbRegistration,\r
+                    &BufferSize,\r
+                    &Handle\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Exit Path of While Loop....\r
+      //\r
+      break;\r
+    }\r
+\r
+    UpdateIndex = MAX_FVB_COUNT;\r
+    for (Index = 0; Index < mFvbCount; Index++) {\r
+      if (mFvbEntry[Index].Handle == Handle) {\r
+        //\r
+        //  If the handle is already in the table just update the protocol\r
+        //\r
+        UpdateIndex = Index;\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (UpdateIndex == MAX_FVB_COUNT) {\r
+      //\r
+      // Use the next free slot for a new entry\r
+      //\r
+      UpdateIndex                   = mFvbCount;\r
+    }\r
+    //\r
+    // The array does not have enough entries\r
+    //\r
+    ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
+\r
+    //\r
+    //  Get the interface pointer and if it's ours, skip it.\r
+    //  We check Runtime here, because it has no reason to register\r
+    //  a boot time FVB protocol.\r
+    //\r
+    Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb);\r
+    ASSERT_EFI_ERROR (Status);\r
+    if (IsMemoryRuntime (Fvb)) {\r
+      //\r
+      // Increase mFvbCount if we need to add a new entry\r
+      //\r
+      if (UpdateIndex == mFvbCount) {\r
+        mFvbCount++;\r
+      }\r
+      mFvbEntry[UpdateIndex].Handle       = Handle;\r
+      mFvbEntry[UpdateIndex].Fvb          = Fvb;\r
+      mFvbEntry[UpdateIndex].FvbExtension = NULL;\r
+\r
+      Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension);\r
+      if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) {\r
+        mFvbEntry[UpdateIndex].FvbExtension = FvbExtension;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbInitialize (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Initialize globals and register Fvb Protocol notification function.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS - Fvb is successfully initialized\r
+  others                - Fail to initialize\r
+\r
+--*/\r
+{\r
+  UINTN Status;\r
+  mFvbCount = 0;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,\r
+                  (VOID *) &mFvbEntry\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);\r
+\r
+  mFvbEvent = RtEfiLibCreateProtocolNotifyEvent (\r
+    &gEfiFirmwareVolumeBlockProtocolGuid,\r
+    EFI_TPL_CALLBACK,\r
+    FvbNotificationFunction,\r
+    NULL,\r
+    &mFvbRegistration\r
+    );\r
+\r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  //\r
+  //  Status = gBS->CreateEvent (\r
+  //                EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+  //                EFI_TPL_NOTIFY,\r
+  //                EfiRuntimeLibFvbVirtualNotifyEvent,\r
+  //                NULL,\r
+  //                &mEfiFvbVirtualNotifyEvent\r
+  //                );\r
+  //  ASSERT_EFI_ERROR (Status);\r
+  //\r
+  gEfiFvbInitialized = TRUE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbShutdown (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Release resources allocated in EfiFvbInitialize.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  gBS->FreePool ((VOID *) mFvbEntry);\r
+  gBS->CloseEvent (mFvbEvent);\r
+  gEfiFvbInitialized = FALSE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// The following functions wrap Fvb protocol in the Runtime Lib functions.\r
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r
+// thus the sequence of FVB protocol addition define Instance.\r
+//\r
+// EfiFvbInitialize () must be called before any of the following functions\r
+// must be called.\r
+//\r
+\r
+EFI_STATUS\r
+EfiFvbReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  Offset                - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  Offset                - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+  \r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+\r
+Returns: \r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN EFI_FVB_ATTRIBUTES                   Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+\r
+Returns: \r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *BaseAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  BaseAddress           - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetBlockSize (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose block size is going to be\r
+                          returned\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+                          \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetLastLba         - Offset into the last block at which to end erasing\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+  \r
+  EFI_UNSUPPORTED       - not support\r
+  \r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (!(mFvbEntry[Instance].FvbExtension)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (\r
+                                            mFvbEntry[Instance].FvbExtension,\r
+                                            StartLba,\r
+                                            OffsetStartLba,\r
+                                            LastLba,\r
+                                            OffsetLastLba\r
+                                            );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c
new file mode 100644 (file)
index 0000000..3633471
--- /dev/null
@@ -0,0 +1,130 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  IoLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+\r
+extern EFI_CPU_IO_PROTOCOL  *gCpuIo;\r
+\r
+EFI_STATUS\r
+EfiIoRead (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of read transaction, and repeat operation to use\r
+  Address - IO address to read\r
+  Count   - Number of times to read the IO address.\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiIoWrite (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemRead (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a Memory mapped IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of each read transaction.\r
+  Address - Memory mapped IO address to read\r
+  Count   - Number of Width quanta to read\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemWrite (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH    Width,\r
+  IN  UINT64                       Address,\r
+  IN  UINTN                        Count,\r
+  IN  OUT VOID                     *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a memory mapped IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c
new file mode 100644 (file)
index 0000000..6b6147e
--- /dev/null
@@ -0,0 +1,177 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Lock.c\r
+\r
+Abstract:\r
+\r
+  Support for locking lib services.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+extern\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  Note on a check build ASSERT()s are used to ensure proper\r
+  lock usage.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - The task priority level of the lock\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+{\r
+  Lock->Tpl       = Priority;\r
+  Lock->OwnerTpl  = 0;\r
+  Lock->Lock      = 0;\r
+}\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+{\r
+  if (Lock->Lock != 0) {\r
+    //\r
+    // Lock is already owned, so bail out\r
+    //\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+  }\r
+\r
+  Lock->Lock += 1;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  Lock owned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiAcquireLockOrFail (Lock);\r
+\r
+  //\r
+  // Lock was already locked.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock, and\r
+    restores the previous task priority level.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    Lock unowned\r
+\r
+--*/\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  Tpl = Lock->OwnerTpl;\r
+\r
+  ASSERT (Lock->Lock == 1);\r
+  Lock->Lock -= 1;\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    gBS->RestoreTPL (Tpl);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c
new file mode 100644 (file)
index 0000000..ae7f6e5
--- /dev/null
@@ -0,0 +1,407 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformIoLib.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+\r
+#define PCI_CONFIG_INDEX_PORT    0xcf8\r
+#define PCI_CONFIG_DATA_PORT     0xcfc\r
+#define REFRESH_CYCLE_TOGGLE_BIT 0x10\r
+\r
+UINT32\r
+GetPciAddress (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Constructs PCI Address 32 bits\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  PciAddress to be written to Config Port\r
+\r
+--*/\r
+{\r
+  UINT32  Data;\r
+\r
+  Data  = (((UINT32) Segment) << 24);\r
+  Data |= (((UINT32) Bus) << 16);\r
+  Data |= (((UINT32) DevFunc) << 8);\r
+  Data |= (UINT32) Register;\r
+\r
+  return Data;\r
+\r
+}\r
+\r
+UINT8\r
+PciRead8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT8       Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+UINT16\r
+PciRead16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT16      Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+UINT32\r
+PciRead32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT32      Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+VOID\r
+PciWrite8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT8   Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+\r
+VOID\r
+PciWrite16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT16  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+\r
+VOID\r
+PciWrite32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT32  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+//\r
+// Delay Primative\r
+//\r
+VOID\r
+EfiStall (\r
+  IN  UINTN   Microseconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+ Delay for at least the request number of microseconds\r
+    \r
+Arguments:\r
+  Microseconds - Number of microseconds to delay.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  UINT8 Data;\r
+  UINT8 InitialState;\r
+  UINTN CycleIterations;\r
+\r
+  CycleIterations = 0;\r
+  Data            = 0;\r
+  InitialState    = 0;\r
+\r
+  if (EfiAtRuntime ()) {\r
+    //\r
+    // The time-source is 30 us granular, so calibrate the timing loop\r
+    // based on this baseline\r
+    // Error is possible 30us.\r
+    //\r
+    CycleIterations = (Microseconds - 1) / 30 + 1;\r
+\r
+    //\r
+    // Use the DMA Refresh timer in port 0x61.  Cheap but effective.\r
+    // The only issue is that the granularity is 30us, and we want to\r
+    // guarantee "at least" one full transition to avoid races.\r
+    //\r
+    //\r
+    //   _____________/----------\__________/--------\r
+    //\r
+    //                |<--15us-->|<--15us-->|\r
+    //\r
+    // --------------------------------------------------> Time (us)\r
+    //\r
+    while (CycleIterations--) {\r
+      EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+      Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      InitialState = Data;\r
+\r
+      //\r
+      // Capture first transition (strictly less than one period)\r
+      //\r
+      while (InitialState == Data) {\r
+        EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+        Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      }\r
+\r
+      InitialState = Data;\r
+      //\r
+      // Capture next transition (guarantee at least one full pulse)\r
+      //\r
+      while (InitialState == Data) {\r
+        EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+        Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      }\r
+    }\r
+  } else {\r
+    gBS->Stall (Microseconds);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c
new file mode 100644 (file)
index 0000000..d1a9080
--- /dev/null
@@ -0,0 +1,842 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+//\r
+// Driver Lib Module Globals\r
+//\r
+static EFI_RUNTIME_SERVICES *mRT;\r
+static EFI_EVENT            mRuntimeNotifyEvent     = NULL;\r
+static EFI_EVENT            mEfiVirtualNotifyEvent  = NULL;\r
+static BOOLEAN              mRuntimeLibInitialized  = FALSE;\r
+static BOOLEAN              mEfiGoneVirtual         = FALSE;\r
+\r
+//\r
+// Runtime Global, but you should use the Lib functions\r
+//\r
+EFI_CPU_IO_PROTOCOL         *gCpuIo;\r
+BOOLEAN                     mEfiAtRuntime = FALSE;\r
+FVB_ENTRY                   *mFvbEntry;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+#endif\r
+\r
+EFI_STATUS\r
+EfiConvertPointer (\r
+  IN UINTN                     DebugDisposition,\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+EFI_STATUS\r
+EfiConvertInternalPointer (\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call EfiConvertPointer() to convert internal pointer.\r
+\r
+Arguments:\r
+\r
+  Address - A pointer to a pointer that is to be fixed to be the value needed\r
+            for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibFvbVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert all pointers in mFvbEntry after ExitBootServices.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  if (mFvbEntry != NULL) {\r
+    for (Index = 0; Index < MAX_FVB_COUNT; Index++) {\r
+      if (NULL != mFvbEntry[Index].Fvb) {\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);\r
+      }\r
+\r
+      if (NULL != mFvbEntry[Index].FvbExtension) {\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);\r
+      }\r
+    }\r
+\r
+    EfiConvertInternalPointer ((VOID **) &mFvbEntry);\r
+  }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mEfiAtRuntime = TRUE;\r
+}\r
+\r
+extern BOOLEAN  gEfiFvbInitialized;\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in \r
+  lib to virtual mode.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;\r
+\r
+  if (Context != NULL) {\r
+    ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;\r
+    ChildNotifyEventHandler (Event, NULL);\r
+  }\r
+\r
+  if (gEfiFvbInitialized) {\r
+    EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);\r
+  }\r
+  //\r
+  // Update global for Runtime Services Table and IO\r
+  //\r
+  EfiConvertInternalPointer ((VOID **) &gCpuIo);\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  if (gStatusCode != NULL) {\r
+    EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);\r
+    EfiConvertInternalPointer ((VOID **) &gStatusCode);\r
+  }\r
+#endif\r
+  EfiConvertInternalPointer ((VOID **) &mRT);\r
+\r
+  //\r
+  // Clear out BootService globals\r
+  //\r
+  gBS             = NULL;\r
+  gST             = NULL;\r
+  mEfiGoneVirtual = TRUE;\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     GoVirtualChildEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+\r
+  Status  = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+  if (EFI_ERROR (Status)) {\r
+    gStatusCode = NULL;\r
+  }\r
+#endif\r
+\r
+  Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);\r
+  if (EFI_ERROR (Status)) {\r
+    gCpuIo = NULL;\r
+  }\r
+\r
+  //\r
+  // Register our ExitBootServices () notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  EFI_TPL_NOTIFY,\r
+                  RuntimeDriverExitBootServices,\r
+                  NULL,\r
+                  &mRuntimeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+                  EFI_TPL_NOTIFY,\r
+                  EfiRuntimeLibVirtualNotifyEvent,\r
+                  (VOID *) (UINTN) GoVirtualChildEvent,\r
+                  &mEfiVirtualNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiShutdownRuntimeDriverLib (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!mRuntimeLibInitialized) {\r
+    //\r
+    // You must call EfiInitializeRuntimeDriverLib() first\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized = FALSE;\r
+\r
+  //\r
+  // Close our ExitBootServices () notify function\r
+  //\r
+  if (mRuntimeNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (mRuntimeNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  // Close SetVirtualAddressMap () notify function\r
+  //\r
+  if (mEfiVirtualNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeSmmDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+  if (EFI_ERROR (Status)) {\r
+    gStatusCode = NULL;\r
+  }\r
+#endif\r
+\r
+  Status  = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);\r
+  if (EFI_ERROR (Status)) {\r
+    gCpuIo = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if ExitBootServices () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If ExitBootServices () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiAtRuntime;\r
+}\r
+\r
+BOOLEAN\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiGoneVirtual;\r
+}\r
+//\r
+// The following functions hide the mRT local global from the call to\r
+// runtime service in the EFI system table.\r
+//\r
+EFI_STATUS\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device¡¯s\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetTime (Time, Capabilities);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetTime (Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetWakeupTime (Enabled, Pending, Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetWakeupTime (Enable, Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+EFI_STATUS\r
+EfiQueryVariableInfo (\r
+  IN UINT32           Attributes,\r
+  OUT UINT64          *MaximumVariableStorageSize,\r
+  OUT UINT64          *RemainingVariableStorageSize,\r
+  OUT UINT64          *MaximumVariableSize\r
+  )\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);\r
+}\r
+\r
+#endif\r
+\r
+EFI_STATUS\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform¡¯s monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextHighMonotonicCount (HighCount);\r
+}\r
+\r
+VOID\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+}\r
+\r
+EFI_STATUS\r
+EfiReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+\r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
+  if (gStatusCode == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+#else\r
+  if (mRT == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Check whether EFI_RUNTIME_SERVICES has Tiano Extension\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (mRT->Hdr.Revision     == EFI_SPECIFICATION_VERSION     &&\r
+      mRT->Hdr.HeaderSize   == sizeof (EFI_RUNTIME_SERVICES) &&\r
+      mRT->ReportStatusCode != NULL) {\r
+    Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+  }\r
+#endif\r
+  return Status;\r
+}\r
+//\r
+// Cache Flush Routine.\r
+//\r
+EFI_STATUS\r
+EfiCpuFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS          Start,\r
+  IN UINT64                        Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush cache with specified range.\r
+\r
+Arguments:\r
+\r
+  Start   - Start address\r
+  Length  - Length in bytes\r
+\r
+Returns:\r
+\r
+  Status code\r
+  \r
+  EFI_SUCCESS - success\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c
new file mode 100644 (file)
index 0000000..de151cd
--- /dev/null
@@ -0,0 +1,620 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    Fvb.c \r
+\r
+Abstract:\r
+\r
+  Firmware Volume Block Protocol Runtime Abstraction\r
+\r
+  mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the \r
+  index in the mFvbEntry array. This should be the same sequence as the FVB's\r
+  were described in the HOB. We have to remember the handle so we can tell if \r
+  the protocol has been reinstalled and it needs updateing.\r
+\r
+  If you are using any of these lib functions.you must first call FvbInitialize ().\r
+\r
+Key:\r
+  FVB - Firmware Volume Block\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)\r
+\r
+//\r
+// Lib will ASSERT if more FVB devices than this are added to the system.\r
+//\r
+UINTN             mFvbCount;\r
+VOID              *mFvbRegistration;\r
+VOID              *mFvbExtRegistration;\r
+static EFI_EVENT  mEfiFvbVirtualNotifyEvent;\r
+BOOLEAN           gEfiFvbInitialized = FALSE;\r
+EFI_EVENT         mFvbEvent;\r
+\r
+BOOLEAN\r
+IsMemoryRuntime (\r
+  IN VOID   *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check whether an address is runtime memory or not.\r
+\r
+Arguments:\r
+\r
+  Address - The Address being checked.\r
+  \r
+Returns: \r
+  TRUE    - The address is runtime memory.\r
+  FALSE   - The address is not runtime memory.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINT8                                TmpMemoryMap[1];\r
+  UINTN                                MapKey;\r
+  UINTN                                DescriptorSize;\r
+  UINT32                               DescriptorVersion;\r
+  UINTN                                MemoryMapSize;\r
+  EFI_MEMORY_DESCRIPTOR                *MemoryMap;\r
+  EFI_MEMORY_DESCRIPTOR                *MemoryMapPtr;\r
+  BOOLEAN                              IsRuntime;\r
+  UINTN                                Index;\r
+\r
+  IsRuntime = FALSE;\r
+\r
+  //\r
+  // Get System MemoryMapSize\r
+  //\r
+  MemoryMapSize = 1;\r
+  Status = gBS->GetMemoryMap (\r
+                  &MemoryMapSize,\r
+                  (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,\r
+                  &MapKey,\r
+                  &DescriptorSize,\r
+                  &DescriptorVersion\r
+                  );\r
+  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
+  //\r
+  // Enlarge space here, because we will allocate pool now.\r
+  //\r
+  MemoryMapSize += EFI_PAGE_SIZE;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  MemoryMapSize,\r
+                  (VOID**)&MemoryMap\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get System MemoryMap\r
+  //\r
+  Status = gBS->GetMemoryMap (\r
+                  &MemoryMapSize,\r
+                  MemoryMap,\r
+                  &MapKey,\r
+                  &DescriptorSize,\r
+                  &DescriptorVersion\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  MemoryMapPtr = MemoryMap;\r
+  //\r
+  // Search the request Address\r
+  //\r
+  for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {\r
+    if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&\r
+        ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart\r
+                                              + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {\r
+      //\r
+      // Found it\r
+      //\r
+      if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {\r
+        IsRuntime = TRUE;\r
+      }\r
+      break;\r
+    }\r
+    //\r
+    // Get next item\r
+    //\r
+    MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);\r
+  }\r
+\r
+  //\r
+  // Done\r
+  //\r
+  gBS->FreePool (MemoryMapPtr);\r
+\r
+  return IsRuntime;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+FvbNotificationFunction (\r
+  IN  EFI_EVENT       Event,\r
+  IN  VOID            *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r
+  reinstalled.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                         Status;\r
+  UINTN                              BufferSize;\r
+  EFI_HANDLE                         Handle;\r
+  UINTN                              Index;\r
+  UINTN                              UpdateIndex;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
+  EFI_FVB_EXTENSION_PROTOCOL         *FvbExtension;\r
+\r
+  while (TRUE) {\r
+    BufferSize = sizeof (Handle);\r
+    Status = gBS->LocateHandle (\r
+                    ByRegisterNotify,\r
+                    &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                    mFvbRegistration,\r
+                    &BufferSize,\r
+                    &Handle\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Exit Path of While Loop....\r
+      //\r
+      break;\r
+    }\r
+\r
+    UpdateIndex = MAX_FVB_COUNT;\r
+    for (Index = 0; Index < mFvbCount; Index++) {\r
+      if (mFvbEntry[Index].Handle == Handle) {\r
+        //\r
+        //  If the handle is already in the table just update the protocol\r
+        //\r
+        UpdateIndex = Index;\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (UpdateIndex == MAX_FVB_COUNT) {\r
+      //\r
+      // Use the next free slot for a new entry\r
+      //\r
+      UpdateIndex                   = mFvbCount;\r
+    }\r
+    //\r
+    // The array does not have enough entries\r
+    //\r
+    ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
+\r
+    //\r
+    //  Get the interface pointer and if it's ours, skip it.\r
+    //  We check Runtime here, because it has no reason to register\r
+    //  a boot time FVB protocol.\r
+    //\r
+    Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb);\r
+    ASSERT_EFI_ERROR (Status);\r
+    if (IsMemoryRuntime (Fvb)) {\r
+      //\r
+      // Increase mFvbCount if we need to add a new entry\r
+      //\r
+      if (UpdateIndex == mFvbCount) {\r
+        mFvbCount++;\r
+      }\r
+      mFvbEntry[UpdateIndex].Handle       = Handle;\r
+      mFvbEntry[UpdateIndex].Fvb          = Fvb;\r
+      mFvbEntry[UpdateIndex].FvbExtension = NULL;\r
+\r
+      Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension);\r
+      if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) {\r
+        mFvbEntry[UpdateIndex].FvbExtension = FvbExtension;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbInitialize (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Initialize globals and register Fvb Protocol notification function.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS - Fvb is successfully initialized\r
+  others                - Fail to initialize\r
+\r
+--*/\r
+{\r
+  UINTN Status;\r
+  mFvbCount = 0;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,\r
+                  (VOID *) &mFvbEntry\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);\r
+\r
+  mFvbEvent = RtEfiLibCreateProtocolNotifyEvent (\r
+    &gEfiFirmwareVolumeBlockProtocolGuid,\r
+    EFI_TPL_CALLBACK,\r
+    FvbNotificationFunction,\r
+    NULL,\r
+    &mFvbRegistration\r
+    );\r
+\r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  //\r
+  //  Status = gBS->CreateEvent (\r
+  //                EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+  //                EFI_TPL_NOTIFY,\r
+  //                EfiRuntimeLibFvbVirtualNotifyEvent,\r
+  //                NULL,\r
+  //                &mEfiFvbVirtualNotifyEvent\r
+  //                );\r
+  //  ASSERT_EFI_ERROR (Status);\r
+  //\r
+  gEfiFvbInitialized = TRUE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbShutdown (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Release resources allocated in EfiFvbInitialize.\r
+\r
+Arguments:\r
+  None \r
+\r
+Returns: \r
+  EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  gBS->FreePool ((VOID *) mFvbEntry);\r
+\r
+  gBS->CloseEvent (mFvbEvent);\r
+\r
+  gEfiFvbInitialized = FALSE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// The following functions wrap Fvb protocol in the Runtime Lib functions.\r
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r
+// thus the sequence of FVB protocol addition define Instance.\r
+//\r
+// EfiFvbInitialize () must be called before any of the following functions\r
+// must be called.\r
+//\r
+\r
+EFI_STATUS\r
+EfiFvbReadBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  Offset                - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbWriteBlock (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  Offset                - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+  \r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+\r
+Returns: \r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN EFI_FVB_ATTRIBUTES                   Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+\r
+Returns: \r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *BaseAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  BaseAddress           - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbGetBlockSize (\r
+  IN UINTN                                        Instance,\r
+  IN EFI_LBA                                      Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose block size is going to be\r
+                          returned\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+                          \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+\r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);\r
+}\r
+\r
+EFI_STATUS\r
+EfiFvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetLastLba         - Offset into the last block at which to end erasing\r
+\r
+Returns: \r
+\r
+  Status code\r
+  \r
+  EFI_INVALID_PARAMETER - invalid parameter\r
+  \r
+  EFI_UNSUPPORTED       - not support\r
+  \r
+--*/\r
+{\r
+  if (Instance >= mFvbCount) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (!(mFvbEntry[Instance].FvbExtension)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (\r
+                                            mFvbEntry[Instance].FvbExtension,\r
+                                            StartLba,\r
+                                            OffsetStartLba,\r
+                                            LastLba,\r
+                                            OffsetLastLba\r
+                                            );\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c
new file mode 100644 (file)
index 0000000..bb244ce
--- /dev/null
@@ -0,0 +1,130 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  IoLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+\r
+extern EFI_CPU_IO_PROTOCOL  *gCpuIo;\r
+\r
+EFI_STATUS\r
+EfiIoRead (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of read transaction, and repeat operation to use\r
+  Address - IO address to read\r
+  Count   - Number of times to read the IO address.\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiIoWrite (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemRead (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH   Width,\r
+  IN  UINT64                      Address,\r
+  IN  UINTN                       Count,\r
+  IN  OUT VOID                    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a Memory mapped IO read into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of each read transaction.\r
+  Address - Memory mapped IO address to read\r
+  Count   - Number of Width quanta to read\r
+  Buffer  - Buffer to read data into. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EfiMemWrite (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH    Width,\r
+  IN  UINT64                       Address,\r
+  IN  UINTN                        Count,\r
+  IN  OUT VOID                     *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a memory mapped IO write into Buffer.\r
+\r
+Arguments:\r
+  Width   - Width of write transaction, and repeat operation to use\r
+  Address - IO address to write\r
+  Count   - Number of times to write the IO address.\r
+  Buffer  - Buffer to write data from. size is Width * Count\r
+\r
+Returns: \r
+  BugBug: Check with Mike to see if I can find this #define some ware else\r
+\r
+--*/\r
+{\r
+  return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c
new file mode 100644 (file)
index 0000000..d815d0c
--- /dev/null
@@ -0,0 +1,177 @@
+/*++\r
+\r
+Copyright (c) 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Lock.c\r
+\r
+Abstract:\r
+\r
+  Support for locking lib services.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+extern\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EfiInitializeLock (\r
+  IN OUT EFI_LOCK *Lock,\r
+  IN EFI_TPL      Priority\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+\r
+  Note on a check build ASSERT()s are used to ensure proper\r
+  lock usage.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+\r
+  Priority    - The task priority level of the lock\r
+\r
+    \r
+Returns:\r
+\r
+  An initialized Efi Lock structure.\r
+\r
+--*/\r
+{\r
+  Lock->Tpl       = Priority;\r
+  Lock->OwnerTpl  = 0;\r
+  Lock->Lock      = 0;\r
+}\r
+\r
+EFI_STATUS\r
+EfiAcquireLockOrFail (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize a basic mutual exclusion lock.   Each lock\r
+  provides mutual exclusion access at it's task priority\r
+  level.  Since there is no-premption (at any TPL) or\r
+  multiprocessor support, acquiring the lock only consists\r
+  of raising to the locks TPL.\r
+    \r
+Arguments:\r
+\r
+  Lock        - The EFI_LOCK structure to initialize\r
+   \r
+Returns:\r
+\r
+  EFI_SUCCESS       - Lock Owned.\r
+  EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
+\r
+--*/\r
+{\r
+  if (Lock->Lock != 0) {\r
+    //\r
+    // Lock is already owned, so bail out\r
+    //\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
+  }\r
+\r
+  Lock->Lock += 1;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EfiAcquireLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Raising to the task priority level of the mutual exclusion\r
+  lock, and then acquires ownership of the lock.\r
+    \r
+Arguments:\r
+\r
+  Lock - The lock to acquire\r
+    \r
+Returns:\r
+\r
+  Lock owned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = EfiAcquireLockOrFail (Lock);\r
+\r
+  //\r
+  // Lock was already locked.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+EfiReleaseLock (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Releases ownership of the mutual exclusion lock, and\r
+    restores the previous task priority level.\r
+    \r
+Arguments:\r
+\r
+    Lock - The lock to release\r
+    \r
+Returns:\r
+\r
+    Lock unowned\r
+\r
+--*/\r
+{\r
+  EFI_TPL Tpl;\r
+\r
+  Tpl = Lock->OwnerTpl;\r
+\r
+  ASSERT (Lock->Lock == 1);\r
+  Lock->Lock -= 1;\r
+\r
+  if (!EfiAtRuntime ()) {\r
+    //\r
+    // The check is just debug code for core inplementation. It must\r
+    //  always be true in a driver\r
+    //\r
+    gBS->RestoreTPL (Tpl);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c
new file mode 100644 (file)
index 0000000..c85de47
--- /dev/null
@@ -0,0 +1,409 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformIoLib.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+\r
+#define PCI_CONFIG_INDEX_PORT    0xcf8\r
+#define PCI_CONFIG_DATA_PORT     0xcfc\r
+#define REFRESH_CYCLE_TOGGLE_BIT 0x10\r
+\r
+UINT32\r
+GetPciAddress (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Constructs PCI Address 32 bits\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  PciAddress to be written to Config Port\r
+\r
+--*/\r
+{\r
+  UINT32  Data;\r
+\r
+  Data  = 0;\r
+\r
+  Data  = (((UINT32) Segment) << 24);\r
+  Data |= (((UINT32) Bus) << 16);\r
+  Data |= (((UINT32) DevFunc) << 8);\r
+  Data |= (UINT32) Register;\r
+\r
+  return Data;\r
+\r
+}\r
+\r
+UINT8\r
+PciRead8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT8       Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+UINT16\r
+PciRead16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT16      Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+UINT32\r
+PciRead32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle read\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+\r
+Returns:\r
+  Data read from PCI config space\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+  UINT32      Data;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+\r
+  return Data;\r
+}\r
+\r
+VOID\r
+PciWrite8 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT8   Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an one byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+\r
+VOID\r
+PciWrite16 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT16  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an two byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+\r
+VOID\r
+PciWrite32 (\r
+  UINT8   Segment,\r
+  UINT8   Bus,\r
+  UINT8   DevFunc,\r
+  UINT8   Register,\r
+  UINT32  Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform an four byte PCI config cycle write\r
+    \r
+Arguments:\r
+  Segment   - PCI Segment ACPI _SEG\r
+  Bus       - PCI Bus\r
+  DevFunc   - PCI Device(7:3) and Func(2:0)\r
+  Register  - PCI config space register\r
+  Data      - Data to write\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      PciAddress;\r
+  UINT32      PciAddress1;\r
+\r
+  PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);\r
+  //\r
+  // Set bit 31 for PCI config access\r
+  //\r
+  PciAddress1 = PciAddress;\r
+  PciAddress  = ((PciAddress & 0xFFFFFFFC) | (0x80000000));\r
+\r
+  Status      = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);\r
+}\r
+//\r
+// Delay Primative\r
+//\r
+VOID\r
+EfiStall (\r
+  IN  UINTN   Microseconds\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+ Delay for at least the request number of microseconds\r
+    \r
+Arguments:\r
+  Microseconds - Number of microseconds to delay.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  UINT8 Data;\r
+  UINT8 InitialState;\r
+  UINTN CycleIterations;\r
+\r
+  CycleIterations = 0;\r
+  Data            = 0;\r
+  InitialState    = 0;\r
+\r
+  if (EfiAtRuntime ()) {\r
+    //\r
+    // The time-source is 30 us granular, so calibrate the timing loop\r
+    // based on this baseline\r
+    // Error is possible 30us.\r
+    //\r
+    CycleIterations = (Microseconds - 1) / 30 + 1;\r
+\r
+    //\r
+    // Use the DMA Refresh timer in port 0x61.  Cheap but effective.\r
+    // The only issue is that the granularity is 30us, and we want to\r
+    // guarantee "at least" one full transition to avoid races.\r
+    //\r
+    //\r
+    //   _____________/----------\__________/--------\r
+    //\r
+    //                |<--15us-->|<--15us-->|\r
+    //\r
+    // --------------------------------------------------> Time (us)\r
+    //\r
+    while (CycleIterations--) {\r
+      EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+      Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      InitialState = Data;\r
+\r
+      //\r
+      // Capture first transition (strictly less than one period)\r
+      //\r
+      while (InitialState == Data) {\r
+        EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+        Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      }\r
+\r
+      InitialState = Data;\r
+      //\r
+      // Capture next transition (guarantee at least one full pulse)\r
+      //\r
+      while (InitialState == Data) {\r
+        EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);\r
+        Data &= REFRESH_CYCLE_TOGGLE_BIT;\r
+      }\r
+    }\r
+  } else {\r
+    gBS->Stall (Microseconds);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c
new file mode 100644 (file)
index 0000000..d9d5f70
--- /dev/null
@@ -0,0 +1,843 @@
+/*++\r
+\r
+Copyright (c) 2005 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    RuntimeLib.c\r
+\r
+Abstract:\r
+\r
+  Light weight lib to support Tiano drivers.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiRuntimeLib.h"\r
+#include EFI_PROTOCOL_DEFINITION (CpuIo)\r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+//\r
+// Driver Lib Module Globals\r
+//\r
+static EFI_RUNTIME_SERVICES *mRT;\r
+static EFI_EVENT            mRuntimeNotifyEvent     = NULL;\r
+static EFI_EVENT            mEfiVirtualNotifyEvent  = NULL;\r
+static BOOLEAN              mRuntimeLibInitialized  = FALSE;\r
+static BOOLEAN              mEfiGoneVirtual         = FALSE;\r
+\r
+//\r
+// Runtime Global, but you should use the Lib functions\r
+//\r
+EFI_CPU_IO_PROTOCOL         *gCpuIo;\r
+BOOLEAN                     mEfiAtRuntime = FALSE;\r
+FVB_ENTRY                   *mFvbEntry;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+#endif\r
+\r
+EFI_STATUS\r
+EfiConvertPointer (\r
+  IN UINTN                     DebugDisposition,\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+\r
+  DebugDisposition  - Supplies type information for the pointer being converted.\r
+  Address           - A pointer to a pointer that is to be fixed to be the value needed\r
+                      for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->ConvertPointer (DebugDisposition, Address);\r
+}\r
+\r
+EFI_STATUS\r
+EfiConvertInternalPointer (\r
+  IN OUT VOID                  *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call EfiConvertPointer() to convert internal pointer.\r
+\r
+Arguments:\r
+\r
+  Address - A pointer to a pointer that is to be fixed to be the value needed\r
+            for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibFvbVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert all pointers in mFvbEntry after ExitBootServices.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  if (mFvbEntry != NULL) {\r
+    for (Index = 0; Index < MAX_FVB_COUNT; Index++) {\r
+      if (NULL != mFvbEntry[Index].Fvb) {\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);\r
+      }\r
+\r
+      if (NULL != mFvbEntry[Index].FvbExtension) {\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);\r
+        EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);\r
+      }\r
+    }\r
+\r
+    EfiConvertInternalPointer ((VOID **) &mFvbEntry);\r
+  }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+RuntimeDriverExitBootServices (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set AtRuntime flag as TRUE after ExitBootServices\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mEfiAtRuntime = TRUE;\r
+}\r
+\r
+extern BOOLEAN  gEfiFvbInitialized;\r
+\r
+VOID\r
+EFIAPI\r
+EfiRuntimeLibVirtualNotifyEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert any pointers in \r
+  lib to virtual mode.\r
+\r
+Arguments:\r
+\r
+  Event   - The Event that is being processed\r
+  \r
+  Context - Event Context\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_EVENT_NOTIFY  ChildNotifyEventHandler;\r
+\r
+  if (Context != NULL) {\r
+    ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;\r
+    ChildNotifyEventHandler (Event, NULL);\r
+  }\r
+\r
+  if (gEfiFvbInitialized) {\r
+    EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);\r
+  }\r
+  //\r
+  // Update global for Runtime Services Table and IO\r
+  //\r
+  EfiConvertInternalPointer ((VOID **) &gCpuIo);\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  if (gStatusCode != NULL) {\r
+    EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);\r
+    EfiConvertInternalPointer ((VOID **) &gStatusCode);\r
+  }\r
+#endif\r
+  EfiConvertInternalPointer ((VOID **) &mRT);\r
+\r
+  //\r
+  // Clear out BootService globals\r
+  //\r
+  gBS             = NULL;\r
+  gST             = NULL;\r
+  mEfiGoneVirtual = TRUE;\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeRuntimeDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable,\r
+  IN EFI_EVENT_NOTIFY     GoVirtualChildEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+  GoVirtualChildEvent - Caller can register a virtual notification event.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+\r
+  Status  = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+  if (EFI_ERROR (Status)) {\r
+    gStatusCode = NULL;\r
+  }\r
+#endif\r
+\r
+  Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);\r
+  if (EFI_ERROR (Status)) {\r
+    gCpuIo = NULL;\r
+  }\r
+\r
+  //\r
+  // Register our ExitBootServices () notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  EFI_TPL_NOTIFY,\r
+                  RuntimeDriverExitBootServices,\r
+                  NULL,\r
+                  &mRuntimeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Register SetVirtualAddressMap () notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+                  EFI_TPL_NOTIFY,\r
+                  EfiRuntimeLibVirtualNotifyEvent,\r
+                  (VOID *) (UINTN) GoVirtualChildEvent,\r
+                  &mEfiVirtualNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiShutdownRuntimeDriverLib (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine will free some resources which have been allocated in\r
+  EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
+  it must call this routine to free the allocated resource before the exiting.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS     - Shotdown the Runtime Driver Lib successfully\r
+  EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!mRuntimeLibInitialized) {\r
+    //\r
+    // You must call EfiInitializeRuntimeDriverLib() first\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized = FALSE;\r
+\r
+  //\r
+  // Close our ExitBootServices () notify function\r
+  //\r
+  if (mRuntimeNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (mRuntimeNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  // Close SetVirtualAddressMap () notify function\r
+  //\r
+  if (mEfiVirtualNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EfiInitializeSmmDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize runtime Driver Lib if it has not yet been initialized. \r
+\r
+Arguments:\r
+\r
+  ImageHandle     - The firmware allocated handle for the EFI image.\r
+  \r
+  SystemTable     - A pointer to the EFI System Table.\r
+\r
+Returns: \r
+\r
+  EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mRuntimeLibInitialized) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  mRuntimeLibInitialized  = TRUE;\r
+\r
+  gST = SystemTable;\r
+  ASSERT (gST != NULL);\r
+\r
+  gBS = SystemTable->BootServices;\r
+  ASSERT (gBS != NULL);\r
+  mRT = SystemTable->RuntimeServices;\r
+  ASSERT (mRT != NULL);\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
+  if (EFI_ERROR (Status)) {\r
+    gStatusCode = NULL;\r
+  }\r
+#endif\r
+\r
+  Status  = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);\r
+  if (EFI_ERROR (Status)) {\r
+    gCpuIo = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+EfiAtRuntime (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if ExitBootServices () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If ExitBootServices () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiAtRuntime;\r
+}\r
+\r
+BOOLEAN\r
+EfiGoneVirtual (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE if SetVirtualAddressMap () has been called\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  TRUE - If SetVirtualAddressMap () has been called\r
+\r
+--*/\r
+{\r
+  return mEfiGoneVirtual;\r
+}\r
+//\r
+// The following functions hide the mRT local global from the call to\r
+// runtime service in the EFI system table.\r
+//\r
+EFI_STATUS\r
+EfiGetTime (\r
+  OUT EFI_TIME                    *Time,\r
+  OUT EFI_TIME_CAPABILITIES       *Capabilities\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current time and date information, and the time-keeping \r
+  capabilities of the hardware platform.\r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage to receive a snapshot of the current time.\r
+  Capabilities  - An optional pointer to a buffer to receive the real time clock device¡¯s\r
+                  capabilities.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetTime (Time, Capabilities);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetTime (\r
+  IN EFI_TIME                   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the current local time and date information.\r
+\r
+Arguments:\r
+\r
+  Time  - A pointer to the current time.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetTime (Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetWakeupTime (\r
+  OUT BOOLEAN                     *Enabled,\r
+  OUT BOOLEAN                     *Pending,\r
+  OUT EFI_TIME                    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the current wakeup alarm clock setting.\r
+\r
+Arguments:\r
+\r
+  Enabled - Indicates if the alarm is currently enabled or disabled.\r
+  Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r
+  Time    - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetWakeupTime (Enabled, Pending, Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetWakeupTime (\r
+  IN BOOLEAN                      Enable,\r
+  IN EFI_TIME                     *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the system wakeup alarm clock time.\r
+\r
+Arguments:\r
+\r
+  Enable  - Enable or disable the wakeup alarm.\r
+  Time    - If Enable is TRUE, the time to set the wakeup alarm for.\r
+            If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetWakeupTime (Enable, Time);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     * VendorGuid,\r
+  OUT UINT32                      *Attributes OPTIONAL,\r
+  IN OUT UINTN                    *DataSize,\r
+  OUT VOID                        *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - If not NULL, a pointer to the memory location to return the\r
+                  attributes bitmask for the variable.\r
+  DataSize      - On input, the size in bytes of the return Data buffer.\r
+                  On output the size of data returned in Data.\r
+  Data          - The buffer to return the contents of the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+EFI_STATUS\r
+EfiGetNextVariableName (\r
+  IN OUT UINTN                    *VariableNameSize,\r
+  IN OUT CHAR16                   *VariableName,\r
+  IN OUT EFI_GUID                 *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Enumerates the current variable names.\r
+\r
+Arguments:\r
+\r
+  VariableNameSize  - The size of the VariableName buffer.\r
+  VariableName      - On input, supplies the last VariableName that was returned\r
+                      by GetNextVariableName(). \r
+                      On output, returns the Nullterminated Unicode string of the\r
+                      current variable.\r
+  VendorGuid        - On input, supplies the last VendorGuid that was returned by\r
+                      GetNextVariableName(). \r
+                      On output, returns the VendorGuid of the current variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
+}\r
+\r
+EFI_STATUS\r
+EfiSetVariable (\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Sets the value of a variable.\r
+\r
+Arguments:\r
+\r
+  VariableName  - A Null-terminated Unicode string that is the name of the\r
+                  vendor¡¯s variable.\r
+  VendorGuid    - A unique identifier for the vendor.\r
+  Attributes    - Attributes bitmask to set for the variable.\r
+  DataSize      - The size in bytes of the Data buffer.\r
+  Data          - The contents for the variable.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+}\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+EFI_STATUS\r
+EfiQueryVariableInfo (\r
+  IN UINT32           Attributes,\r
+  OUT UINT64          *MaximumVariableStorageSize,\r
+  OUT UINT64          *RemainingVariableStorageSize,\r
+  OUT UINT64          *MaximumVariableSize\r
+  )\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This code returns information about the EFI variables.\r
+\r
+Arguments:\r
+\r
+  Attributes                      Attributes bitmask to specify the type of variables \r
+                                  on which to return information.\r
+  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
+                                  for the EFI variables associated with the attributes specified.\r
+  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available \r
+                                  for the EFI variables associated with the attributes specified.\r
+  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
+                                  associated with the attributes specified.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);\r
+}\r
+\r
+#endif\r
+\r
+\r
+EFI_STATUS\r
+EfiGetNextHighMonotonicCount (\r
+  OUT UINT32                      *HighCount\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the next high 32 bits of the platform¡¯s monotonic counter.\r
+\r
+Arguments:\r
+\r
+  HighCount - Pointer to returned value.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  return mRT->GetNextHighMonotonicCount (HighCount);\r
+}\r
+\r
+VOID\r
+EfiResetSystem (\r
+  IN EFI_RESET_TYPE               ResetType,\r
+  IN EFI_STATUS                   ResetStatus,\r
+  IN UINTN                        DataSize,\r
+  IN CHAR16                       *ResetData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Resets the entire platform.\r
+\r
+Arguments:\r
+\r
+  ResetType   - The type of reset to perform.\r
+  ResetStatus - The status code for the reset.\r
+  DataSize    - The size, in bytes, of ResetData.\r
+  ResetData   - A data buffer that includes a Null-terminated Unicode string, optionally\r
+                followed by additional binary data.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+}\r
+\r
+EFI_STATUS\r
+EfiReportStatusCode (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Status Code reporter\r
+\r
+Arguments:\r
+\r
+  CodeType    - Type of Status Code.\r
+  \r
+  Value       - Value to output for Status Code.\r
+  \r
+  Instance    - Instance Number of this status code.\r
+  \r
+  CallerId    - ID of the caller of this status code.\r
+  \r
+  Data        - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
+  if (gStatusCode == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+#else\r
+  if (mRT == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Check whether EFI_RUNTIME_SERVICES has Tiano Extension\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (mRT->Hdr.Revision     == EFI_SPECIFICATION_VERSION     &&\r
+      mRT->Hdr.HeaderSize   == sizeof (EFI_RUNTIME_SERVICES) &&\r
+      mRT->ReportStatusCode != NULL) {\r
+    Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+  }\r
+#endif\r
+  return Status;\r
+}\r
+\r
+//\r
+// Cache Flush Routine.\r
+//\r
+EFI_STATUS\r
+EfiCpuFlushCache (\r
+  IN EFI_PHYSICAL_ADDRESS          Start,\r
+  IN UINT64                        Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush cache with specified range.\r
+\r
+Arguments:\r
+\r
+  Start   - Start address\r
+  Length  - Length in bytes\r
+\r
+Returns:\r
+\r
+  Status code\r
+  \r
+  EFI_SUCCESS - success\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
new file mode 100644 (file)
index 0000000..f6e70d2
--- /dev/null
@@ -0,0 +1,51 @@
+;*****************************************************************************\r
+;*\r
+;*   Copyright (c) 2006, Intel Corporation                                                         \r
+;*   All rights reserved. This program and the accompanying materials                          \r
+;*   are licensed and made available under the terms and conditions of the BSD License         \r
+;*   which accompanies this distribution.  The full text of the license may be found at        \r
+;*   http://opensource.org/licenses/bsd-license.php                                            \r
+;*                                                                                             \r
+;*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;*   \r
+;*   Module Name:\r
+;*\r
+;*    Fx.asm\r
+;*  \r
+;*   Abstract:\r
+;*  \r
+;*    AsmFxRestore and AsmFxSave function\r
+;*  \r
+;*****************************************************************************\r
+\r
+    .586P\r
+    .model  flat,C\r
+    .xmm\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmFxSave (\r
+;   OUT IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFxSave PROC\r
+    mov     eax, [esp + 4]\r
+    fxsave  [eax]\r
+    ret\r
+AsmFxSave ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmFxRestore (\r
+;   IN CONST IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFxRestore  PROC\r
+    mov     eax, [esp + 4]\r
+    fxrstor [eax]\r
+    ret\r
+AsmFxRestore  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
new file mode 100644 (file)
index 0000000..b59583e
--- /dev/null
@@ -0,0 +1,199 @@
+;*****************************************************************************\r
+;*\r
+;*   Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+;*   All rights reserved. This program and the accompanying materials                          \r
+;*   are licensed and made available under the terms and conditions of the BSD License         \r
+;*   which accompanies this distribution.  The full text of the license may be found at        \r
+;*   http://opensource.org/licenses/bsd-license.php                                            \r
+;*                                                                                             \r
+;*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;*   \r
+;*   Module Name:\r
+;*\r
+;*    Thunk.asm\r
+;*  \r
+;*   Abstract:\r
+;*  \r
+;*    Real mode thunk\r
+;*  \r
+;*****************************************************************************\r
+\r
+    .686p\r
+\r
+EXTERNDEF   C   mCode16Size:DWORD\r
+\r
+CONST   SEGMENT FLAT    "DATA"  READONLY\r
+\r
+mCode16Size     DD      _TEXT16SIZE\r
+\r
+CONST   ENDS\r
+\r
+_DATA   SEGMENT FLAT    "DATA"\r
+\r
+NullSegSel      DQ      0\r
+_16BitCsSel     LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      9bh\r
+                DB      8fh             ; 16-bit segment\r
+                DB      0\r
+_16BitSsSel     LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      93h\r
+                DB      8fh            ; 16-bit segment\r
+                DB      0\r
+\r
+_16Gdtr         LABEL   FWORD\r
+                DW      $ - offset NullSegSel - 1\r
+                DD      offset NullSegSel\r
+\r
+_DATA   ENDS\r
+\r
+_TEXT   SEGMENT FLAT    "CODE"  PARA\r
+\r
+IA32_REGS   STRUC   4t\r
+_EDI        DD      ?\r
+_ESI        DD      ?\r
+_EBP        DD      ?\r
+_ESP        DD      ?\r
+_EBX        DD      ?\r
+_EDX        DD      ?\r
+_ECX        DD      ?\r
+_EAX        DD      ?\r
+_DS         DW      ?\r
+_ES         DW      ?\r
+_FS         DW      ?\r
+_GS         DW      ?\r
+_EFLAGS     DD      ?\r
+_EIP        DD      ?\r
+_CS         DW      ?\r
+_SS         DW      ?\r
+IA32_REGS   ENDS\r
+\r
+_STK16      STRUC   1t\r
+RetEip      DD      ?\r
+RetCs       DW      ?\r
+ThunkFlags  DW      ?\r
+SavedEsp    DD      ?\r
+SavedSs     DW      ?\r
+SavedGdtr   FWORD   ?\r
+SavedCr0    DD      ?\r
+SavedCr4    DD      ?\r
+_STK16      ENDS\r
+\r
+    ASSUME  ds:_DATA\r
+\r
+__Thunk16   PROC    USES    ebp ebx esi edi ds  es  fs  gs\r
+    ASSUME  esi:PTR IA32_REGS\r
+    mov     esi, [esp + 36]\r
+    movzx   edx, [esi]._SS\r
+    mov     edi, [esi]._ESP\r
+    add     edi, - sizeof (_STK16) - sizeof (IA32_REGS)\r
+    push    edi                         ; save stack offset\r
+    imul    eax, edx, 16                ; eax <- edx*16\r
+    add     edi, eax                    ; edi <- linear address of 16-bit stack\r
+    push    sizeof (IA32_REGS) / 4\r
+    pop     ecx\r
+    rep     movsd                       ; copy context to 16-bit stack\r
+    pop     ebx                         ; ebx <- 16-bit stack offset\r
+    mov     eax, offset @F              ; return offset\r
+    stosd\r
+    mov     eax, cs                     ; return segment\r
+    stosw\r
+    mov     eax, [esp + 40]             ; THUNK flags\r
+    stosw\r
+    mov     eax, esp\r
+    stosd                               ; save esp\r
+    mov     eax, ss                     ; save ss\r
+    stosw\r
+    sgdt    fword ptr [edi]             ; save GDTR\r
+    sidt    fword ptr [esp + 36]        ; save IDTR\r
+    mov     esi, cr0\r
+    mov     [edi + 6], esi              ; save CR0\r
+    and     esi, NOT 80000001h          ; esi <- CR0 to set\r
+    mov     eax, cr4\r
+    mov     [edi + 10], eax             ; save CR4\r
+    and     al, NOT 30h                 ; clear PAE & PSE\r
+    mov     edi, edx                    ; edi <- 16-bit stack segment\r
+    mov     edx, [esp + 44]\r
+    shl     edx, 16\r
+    push    edx\r
+    pop     edx\r
+    mov     dx, _16BitSsSel - NullSegSel\r
+    lgdt    _16Gdtr                     ; load 16-bit GDTR\r
+    DB      0eah\r
+    DD      offset @16Bit\r
+    DW      _16BitCsSel - NullSegSel    ; jmp far 8:@16Bit\r
+@16Bit:\r
+    mov     ss, dx\r
+    mov     cr0, esi                    ; disable protected mode\r
+    mov     cr4, eax                    ; disable PAE & PSE\r
+    db      67h, 0FFh, 06Ch, 024h, 0FCh ; jmp     dword ptr [esp-4]\r
+@@:\r
+    mov     eax, ss\r
+    shl     eax, 4\r
+    add     eax, esp                    ; eax <- address of 16-bit stack\r
+    lss     esp, fword ptr (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedEsp\r
+    lidt    fword ptr [esp + 36]        ; restore IDTR\r
+    ret\r
+__Thunk16   ENDP\r
+\r
+_TEXT   ENDS\r
+\r
+_TEXT16 SEGMENT USE16   "CODE"  PARA\r
+\r
+_Code16Addr PROC    C\r
+_Code16Addr ENDP\r
+\r
+RealMode    PROC\r
+    mov     ss, di                      ; set up stack\r
+    mov     esp, ebx\r
+    lidt    fword ptr cs:[_16Idtr - _Code16Addr]\r
+    popad\r
+    pop     ds\r
+    pop     es\r
+    pop     fs\r
+    pop     gs\r
+    add     sp, 4                       ; skip EFlags\r
+    test    (_STK16 ptr [esp + 8]).ThunkFlags, 1\r
+    jz      @F\r
+    pushf\r
+@@:\r
+    push    cs\r
+;    push    @FarCallRet - _Code16Addr\r
+    DB      68h                         ; push /iw\r
+    DW      @FarCallRet - _Code16Addr\r
+    jz      @F\r
+    jmp     fword ptr [esp + 6]\r
+@@:\r
+    jmp     fword ptr [esp + 4]\r
+@FarCallRet:\r
+    pushfd\r
+    push    gs\r
+    push    fs\r
+    push    es\r
+    push    ds\r
+    pushad\r
+    cli\r
+    DB      66h\r
+    lgdt    (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr\r
+    mov     eax, (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedCr4\r
+    mov     cr4, eax\r
+    mov     eax, (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedCr0\r
+    mov     cr0, eax                    ; restore CR0\r
+    jmp     fword ptr (_STK16 ptr [esp + sizeof (IA32_REGS)]).RetEip\r
+RealMode    ENDP\r
+\r
+_16Idtr     FWORD   (1 SHL 10) - 1\r
+\r
+_TEXT16END:\r
+\r
+_TEXT16SIZE = _TEXT16END - _Code16Addr\r
+\r
+_TEXT16 ENDS\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
new file mode 100644 (file)
index 0000000..226c016
--- /dev/null
@@ -0,0 +1,348 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Thunk16Lib.h\r
+\r
+Abstract:\r
+\r
+  Real Mode Thunk Header file\r
+\r
+--*/\r
+\r
+#ifndef __THUNK_16_LIB_H__\r
+#define __THUNK_16_LIB_H__\r
+#include "Tiano.h"\r
+\r
+//\r
+// Thunk Flags\r
+//\r
+#define THUNK_SAVE_FP_STATE         0x1\r
+#define THUNK_USER_STACK            0x2\r
+#define THUNK_INTERRUPT             0x10000\r
+\r
+//\r
+// Byte packed structure for 16-bit Real Mode FLAGS\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT32  CF:1;           // Carry Flag\r
+    UINT32  Reserved_0:1;   // Reserved\r
+    UINT32  PF:1;           // Parity Flag\r
+    UINT32  Reserved_1:1;   // Reserved\r
+    UINT32  AF:1;           // Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   // Reserved\r
+    UINT32  ZF:1;           // Zero Flag\r
+    UINT32  SF:1;           // Sign Flag\r
+    UINT32  TF:1;           // Trap Flag\r
+    UINT32  IF:1;           // Interrupt Enable Flag\r
+    UINT32  DF:1;           // Direction Flag\r
+    UINT32  OF:1;           // Overflow Flag\r
+    UINT32  IOPL:2;         // I/O Privilege Level\r
+    UINT32  NT:1;           // Nested Task\r
+    UINT32  Reserved_3:1;   // Reserved\r
+  } Bits;\r
+  UINTN     UintN;\r
+} IA32_FLAGS16;\r
+\r
+//\r
+// Byte packed structure for EFLAGS\r
+// 32-bits on IA32\r
+// 64-bits on X64\r
+//\r
+\r
+typedef union {\r
+  struct {\r
+    UINT32  CF:1;           // Carry Flag\r
+    UINT32  Reserved_0:1;   // Reserved\r
+    UINT32  PF:1;           // Parity Flag\r
+    UINT32  Reserved_1:1;   // Reserved\r
+    UINT32  AF:1;           // Auxiliary Carry Flag\r
+    UINT32  Reserved_2:1;   // Reserved\r
+    UINT32  ZF:1;           // Zero Flag\r
+    UINT32  SF:1;           // Sign Flag\r
+    UINT32  TF:1;           // Trap Flag\r
+    UINT32  IF:1;           // Interrupt Enable Flag\r
+    UINT32  DF:1;           // Direction Flag\r
+    UINT32  OF:1;           // Overflow Flag\r
+    UINT32  IOPL:2;         // I/O Privilege Level\r
+    UINT32  NT:1;           // Nested Task\r
+    UINT32  Reserved_3:1;   // Reserved\r
+    UINT32  RF:1;           // Resume Flag\r
+    UINT32  VM:1;           // Virtual 8086 Mode\r
+    UINT32  AC:1;           // Alignment Check\r
+    UINT32  VIF:1;          // Virtual Interrupt Flag\r
+    UINT32  VIP:1;          // Virtual Interrupt Pending\r
+    UINT32  ID:1;           // ID Flag\r
+    UINT32  Reserved_4:10;  // Reserved\r
+  } Bits;\r
+  UINTN     UintN;\r
+} IA32_EFLAGS32;\r
+\r
+//\r
+// Byte packed structure for an FP/SSE/SSE2 context\r
+//\r
+typedef struct {\r
+  UINT8  Buffer[512];\r
+} IA32_FX_BUFFER;\r
+\r
+//\r
+// Structures for the 16-bit real mode thunks\r
+//\r
+typedef struct {\r
+  UINT32                            Reserved1;\r
+  UINT32                            Reserved2;\r
+  UINT32                            Reserved3;\r
+  UINT32                            Reserved4;\r
+  UINT8                             BL;\r
+  UINT8                             BH;\r
+  UINT16                            Reserved5;\r
+  UINT8                             DL;\r
+  UINT8                             DH;\r
+  UINT16                            Reserved6;\r
+  UINT8                             CL;\r
+  UINT8                             CH;\r
+  UINT16                            Reserved7;\r
+  UINT8                             AL;\r
+  UINT8                             AH;\r
+  UINT16                            Reserved8;\r
+} IA32_BYTE_REGS;\r
+\r
+typedef struct {\r
+  UINT16                            DI;\r
+  UINT16                            Reserved1;\r
+  UINT16                            SI;\r
+  UINT16                            Reserved2;\r
+  UINT16                            BP;\r
+  UINT16                            Reserved3;\r
+  UINT16                            SP;\r
+  UINT16                            Reserved4;\r
+  UINT16                            BX;\r
+  UINT16                            Reserved5;\r
+  UINT16                            DX;\r
+  UINT16                            Reserved6;\r
+  UINT16                            CX;\r
+  UINT16                            Reserved7;\r
+  UINT16                            AX;\r
+  UINT16                            Reserved8;\r
+  UINT16                            DS;\r
+  UINT16                            ES;\r
+  UINT16                            FS;\r
+  UINT16                            GS;\r
+  IA32_FLAGS16                      Flags;\r
+  UINT16                            IP;\r
+  UINT16                            Reserved10;\r
+  UINT16                            CS;\r
+  UINT16                            SS;\r
+} IA32_WORD_REGS;\r
+\r
+typedef struct {\r
+  UINT32                            EDI;\r
+  UINT32                            ESI;\r
+  UINT32                            EBP;\r
+  UINT32                            ESP;\r
+  UINT32                            EBX;\r
+  UINT32                            EDX;\r
+  UINT32                            ECX;\r
+  UINT32                            EAX;\r
+  UINT16                            DS;\r
+  UINT16                            ES;\r
+  UINT16                            FS;\r
+  UINT16                            GS;\r
+  IA32_EFLAGS32                     EFLAGS;\r
+  UINT32                            EIP;\r
+  UINT16                            CS;\r
+  UINT16                            SS;\r
+} IA32_DWORD_REGS;\r
+\r
+typedef union {\r
+  IA32_DWORD_REGS                   E;\r
+  IA32_WORD_REGS                    X;\r
+  IA32_BYTE_REGS                    H;\r
+} IA32_REGISTER_SET;\r
+\r
+//\r
+// Byte packed structure for an 16-bit real mode thunks\r
+//\r
+typedef struct {\r
+  UINT32                            RealModeBuffer;\r
+  UINT32                            DefaultStack;\r
+} THUNK_CONTEXT;\r
+\r
+//\r
+// 16-bit thunking services\r
+//\r
+\r
+UINTN\r
+EFIAPI\r
+AsmThunk16GetProperties (\r
+  OUT     UINTN                     *MinimumStackSize OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the properties of this real mode thunk implementation. Currently\r
+  there are 2 properties has been defined, the minimum real mode buffer size\r
+  and the minimum stack size.\r
+\r
+Arguments:\r
+\r
+  MinimumStackSize  - The minimum size required for a 16-bit stack.\r
+\r
+Returns:\r
+\r
+  The minimum size of the real mode buffer needed by this thunk implementation\r
+  is returned.\r
+\r
+--*/\r
+;\r
+\r
+THUNK_CONTEXT *\r
+EFIAPI\r
+AsmThunk16SetProperties (\r
+  OUT     THUNK_CONTEXT             *ThunkContext,\r
+  IN      VOID                      *RealModeBuffer,\r
+  IN      UINTN                     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Tell this real mode thunk implementation the address and size of the real\r
+  mode buffer needed.\r
+\r
+Arguments:\r
+\r
+  ThunkContext    - The thunk context whose properties to set.\r
+  RealModeBuffer  - The address of the buffer allocated by caller. It should be\r
+                    aligned on a 16-byte boundary.\r
+                    This buffer must be in identity mapped pages.\r
+  BufferSize      - The size of RealModeBuffer. Must be larger than the minimum\r
+                    size required as returned by AsmThunk16GetProperties().\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+EFIAPI\r
+AsmThunk16Destroy (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reset all internal states to their initial values. The caller should not\r
+  release the real mode buffer until after a call to this function.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - The thunk context to destroy.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+IA32_REGISTER_SET *\r
+EFIAPI\r
+AsmThunk16FarCall86 (\r
+  IN      THUNK_CONTEXT             *ThunkContext,\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    ThunkFlags\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Make a far call to 16-bit code.\r
+\r
+  NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts\r
+        disabled because of GDTR and IDTR manipulations.\r
+        This function must be placed in identity mapped pages.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - Thunk context to use.\r
+  RegisterSet   - CPU registers would be set to the values contained in this\r
+                  structure before making the far call. Then CPU registers are\r
+                  copied back to this structure.\r
+                  CS:EIP points to the real mode code being called on input.\r
+                  SS:ESP points to the real mode stack if THUNK_USER_STACK is\r
+                  set on input, otherwise ignored.\r
+                  EFlages is ignored on input.\r
+                  On output, values of CS, EIP, SS and ESP should be ignored.\r
+  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
+                  THUNK_USER_STACK.\r
+                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
+                                        before/after calling real mode code.\r
+                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
+                                        used instead of the default stack.\r
+\r
+Returns:\r
+\r
+  RegisterSet is returned.\r
+\r
+--*/\r
+;\r
+\r
+IA32_REGISTER_SET *\r
+EFIAPI\r
+AsmThunk16Int86 (\r
+  IN      THUNK_CONTEXT             *ThunkContext,\r
+  IN      UINT8                     IntNumber,\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    ThunkFlags\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Invoke a 16-bit interrupt handler.\r
+\r
+  NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts\r
+        disabled because of GDTR and IDTR manipulations.\r
+        This function must be placed in identity mapped pages.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - Thunk context to use.\r
+  IntNumber     - The ordinal of the interrupt handler ranging from 0 to 255.\r
+  RegisterSet   - CPU registers would be set to the values contained in this\r
+                  structure before making the far call. Then CPU registers are\r
+                  copied back to this structure.\r
+                  SS:ESP points to the real mode stack if THUNK_USER_STACK is\r
+                  set on input, otherwise ignored.\r
+                  EFlages is ignored on input.\r
+                  On output, values of CS, EIP, SS and ESP should be ignored.\r
+  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
+                  THUNK_USER_STACK.\r
+                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
+                                        before/after calling real mode code.\r
+                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
+                                        used instead of the default stack.\r
+\r
+Returns:\r
+\r
+  RegisterSet is returned.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf
new file mode 100644 (file)
index 0000000..5134caf
--- /dev/null
@@ -0,0 +1,49 @@
+#/*++\r
+#\r
+#  Copyright (c) 2006, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#   Module Name:\r
+#\r
+#     Thunk16Lib.inf\r
+#\r
+#   Abstract:\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME            = Thunk16Lib\r
+COMPONENT_TYPE       = LIBRARY\r
+\r
+[sources.common]\r
+  x86Thunk.c\r
+\r
+[sources.ia32]\r
+  Ia32\Thunk16.asm\r
+  Ia32\Fx.asm\r
+\r
+[sources.x64]\r
+  X64\Thunk16.asm\r
+  X64\Fx.asm\r
+\r
+[includes.common]\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[libraries.common]\r
+\r
+\r
+[nmake.common]\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
new file mode 100644 (file)
index 0000000..77490b4
--- /dev/null
@@ -0,0 +1,46 @@
+;*****************************************************************************\r
+;*\r
+;*   Copyright (c) 2006, Intel Corporation                                                         \r
+;*   All rights reserved. This program and the accompanying materials                          \r
+;*   are licensed and made available under the terms and conditions of the BSD License         \r
+;*   which accompanies this distribution.  The full text of the license may be found at        \r
+;*   http://opensource.org/licenses/bsd-license.php                                            \r
+;*                                                                                             \r
+;*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;*   \r
+;*   Module Name:\r
+;*\r
+;*    Fx.asm\r
+;*  \r
+;*   Abstract:\r
+;*  \r
+;*    AsmFxRestore and AsmFxSave function\r
+;*  \r
+;*****************************************************************************\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmFxSave (\r
+;   OUT IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFxSave PROC\r
+    fxsave  [rcx]\r
+    ret\r
+AsmFxSave ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmFxRestore (\r
+;   IN CONST IA32_FX_BUFFER *Buffer\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmFxRestore  PROC\r
+    fxrstor [rcx]\r
+    ret\r
+AsmFxRestore  ENDP\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
new file mode 100644 (file)
index 0000000..641e8d2
--- /dev/null
@@ -0,0 +1,216 @@
+;*****************************************************************************\r
+;*\r
+;*   Copyright (c) 2006, Intel Corporation                                                         \r
+;*   All rights reserved. This program and the accompanying materials                          \r
+;*   are licensed and made available under the terms and conditions of the BSD License         \r
+;*   which accompanies this distribution.  The full text of the license may be found at        \r
+;*   http://opensource.org/licenses/bsd-license.php                                            \r
+;*                                                                                             \r
+;*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+;*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+;*   \r
+;*   Module Name:\r
+;*\r
+;*    Thunk.asm\r
+;*  \r
+;*   Abstract:\r
+;*  \r
+;*    Real mode thunk\r
+;*  \r
+;*****************************************************************************\r
+\r
+EXTERNDEF   mCode16Size:QWORD\r
+\r
+    .const\r
+\r
+mCode16Size     DQ      _Code16End - _Code16Addr\r
+\r
+    .data\r
+\r
+NullSegSel      DQ      0\r
+_16CsSegSel     LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      9bh\r
+                DB      8fh             ; 16-bit segment\r
+                DB      0\r
+_16DsSegSel     LABEL   QWORD\r
+                DW      -1\r
+                DW      0\r
+                DB      0\r
+                DB      93h\r
+                DB      8fh             ; 16-bit segment\r
+                DB      0\r
+\r
+_16Gdtr         LABEL   FWORD\r
+                DW      $ - offset NullSegSel - 1\r
+                DQ      offset NullSegSel\r
+\r
+    .code\r
+\r
+IA32_REGS   STRUC   4t\r
+_EDI        DD      ?\r
+_ESI        DD      ?\r
+_EBP        DD      ?\r
+_ESP        DD      ?\r
+_EBX        DD      ?\r
+_EDX        DD      ?\r
+_ECX        DD      ?\r
+_EAX        DD      ?\r
+_DS         DW      ?\r
+_ES         DW      ?\r
+_FS         DW      ?\r
+_GS         DW      ?\r
+_RFLAGS     DQ      ?\r
+_EIP        DD      ?\r
+_CS         DW      ?\r
+_SS         DW      ?\r
+IA32_REGS   ENDS\r
+\r
+_STK16      STRUC   1t\r
+RetEip      DD      ?\r
+RetCs       DW      ?\r
+ThunkFlags  DW      ?\r
+SavedGdtr   FWORD   ?\r
+Resvd1      DW      ?\r
+SavedCr0    DD      ?\r
+SavedCr4    DD      ?\r
+_STK16      ENDS\r
+\r
+_Thunk16    PROC    USES    rbp rbx rsi rdi r12 r13 r14 r15\r
+\r
+    push    fs\r
+    push    gs\r
+\r
+    mov     r12d, ds\r
+    mov     r13d, es\r
+    mov     r14d, ss\r
+    mov     r15, rsp\r
+    mov     rsi, rcx\r
+    movzx   r10, (IA32_REGS ptr [rsi])._SS\r
+    xor     rdi, rdi\r
+    mov     edi, (IA32_REGS ptr [rsi])._ESP\r
+    add     rdi, - sizeof (IA32_REGS) - sizeof (_STK16)\r
+    push    rdi\r
+    imul    rax, r10, 16\r
+    add     rdi, rax\r
+    push    sizeof (IA32_REGS) / 4\r
+    pop     rcx\r
+    rep     movsd\r
+    pop     rbx                         ; rbx <- 16-bit stack offset\r
+    lea     eax, @F                     ; return offset\r
+    stosd\r
+    mov     eax, cs                     ; return segment\r
+    stosw\r
+    mov     eax, edx                    ; THUNK Flags\r
+    stosw\r
+    sgdt    fword ptr [rsp + 58h]       ; save GDTR\r
+    mov     rax, [rsp + 58h]\r
+    stosq\r
+    mov     rax, cr0                    ; save CR0\r
+    mov     esi, eax                    ; esi <- CR0 to set\r
+    stosd\r
+    mov     rax, cr4                    ; save CR4\r
+    stosd\r
+    sidt    fword ptr [rsp + 58h]       ; save IDTR\r
+    and     esi, 07ffffffeh             ; clear PE & PG bits\r
+    mov     rdi, r10                    ; rdi <- 16-bit stack segment\r
+\r
+    shl     r8, 16\r
+    push    r8                          ; far jmp address\r
+    lea     eax, @16Bit\r
+    push    rax\r
+    mov     word ptr [rsp + 4], 8\r
+    lgdt    _16Gdtr\r
+    retf\r
+@16Bit:\r
+    DB      66h\r
+    mov     ecx, 0c0000080h\r
+    mov     cr0, rsi                    ; disable PE & PG\r
+    rdmsr\r
+    and     ah, NOT 1\r
+    wrmsr                               ; clear LME bit\r
+    mov     rax, cr4\r
+    and     al, NOT 30h                 ; clear PAE & PSE\r
+    mov     cr4, rax\r
+    retf\r
+@@:\r
+    xor     rax, rax\r
+    mov     eax, ss\r
+    shl     eax, 4\r
+    add     eax, esp                    ; rax <- address of 16-bit stack\r
+    mov     rsp, r15\r
+    lidt    fword ptr [rsp + 58h]       ; restore IDTR\r
+    mov     ds, r12d\r
+    mov     es, r13d\r
+    mov     ss, r14d\r
+    pop     gs\r
+    pop     fs\r
+    ret\r
+_Thunk16    ENDP\r
+\r
+    ALIGN   10h\r
+\r
+_Code16Addr PROC\r
+_Code16Addr ENDP\r
+\r
+RealMode    PROC\r
+    mov     ss, edi\r
+    mov     sp, bx                      ; set up 16-bit stack\r
+    DB      2eh, 0fh, 1, 1eh\r
+    DW      _16Idtr - _Code16Addr       ; lidt _16Idtr\r
+    DB      66h, 61h                    ; popad\r
+    DB      1fh                         ; pop ds\r
+    DB      7                           ; pop es\r
+    pop     fs\r
+    pop     gs\r
+\r
+    add     esp, 8                      ; skip RFLAGS\r
+    DB      67h, 0f7h, 44h, 24h, 0eh, 1, 0  ; test [esp + 0eh], 1\r
+    jz      @F\r
+    pushfq                              ; pushf, actually\r
+@@:\r
+    DB      0eh                         ; push cs\r
+    DB      68h                         ; push /iw\r
+    DW      @FarCallRet - _Code16Addr\r
+    jz      @F\r
+    DB      66h\r
+    jmp     fword ptr [esp + 6]\r
+@@:\r
+    DB      66h\r
+    jmp     fword ptr [esp + 4]\r
+@FarCallRet:\r
+    DB      66h\r
+    push    0                           ; push a dword of zero\r
+    pushf                               ; pushfd, actually\r
+    push    gs\r
+    push    fs\r
+    DB      6                           ; push es\r
+    DB      1eh                         ; push ds\r
+    DB      66h, 60h                    ; pushad\r
+    cli\r
+\r
+    DB      66h\r
+    lgdt    (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedGdtr\r
+    DB      66h\r
+    mov     eax, (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedCr4\r
+    mov     cr4, rax\r
+    DB      66h\r
+    mov     ecx, 0c0000080h\r
+    rdmsr\r
+    or      ah, 1\r
+    wrmsr                               ; set LME\r
+    DB      66h\r
+    mov     eax, (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedCr0\r
+    mov     cr0, rax\r
+    DB      66h\r
+    jmp     fword ptr (_STK16 ptr [esp + sizeof(IA32_REGS)]).RetEip\r
+\r
+RealMode    ENDP\r
+\r
+_16Idtr     FWORD   (1 SHL 10) - 1\r
+\r
+_Code16End:\r
+\r
+    END\r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c
new file mode 100644 (file)
index 0000000..9bd77e2
--- /dev/null
@@ -0,0 +1,320 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  x86Thunk.c\r
+\r
+Abstract:\r
+\r
+  Real Mode Thunk Functions\r
+\r
+--*/\r
+\r
+#include "Thunk16Lib.h"\r
+#include "EfiCommonLib.h"\r
+\r
+#define IA32API __cdecl\r
+\r
+extern CONST UINTN                  mCode16Size;\r
+\r
+extern\r
+IA32_REGISTER_SET *\r
+IA32API\r
+_Thunk16 (\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    ThunkFlags,\r
+  IN      UINT32                    RealModeCs\r
+  );\r
+\r
+extern\r
+VOID\r
+IA32API\r
+_Code16Addr (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+IA32API\r
+AsmFxRestore (\r
+  IN CONST IA32_FX_BUFFER *Buffer\r
+  );\r
+\r
+VOID\r
+IA32API\r
+AsmFxSave (\r
+  OUT IA32_FX_BUFFER *Buffer\r
+  );\r
+\r
+//\r
+// Implementation\r
+//\r
+STATIC\r
+IA32_REGISTER_SET *\r
+AsmThunk16 (\r
+  IN      THUNK_CONTEXT             *ThunkContext,\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    ThunkFlags\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Do the 16-bit thunk code.\r
+\r
+  NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts\r
+        disabled because of GDTR and IDTR manipulations.\r
+        This function must be placed in identity mapped pages.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - Thunk context to use.\r
+  RegisterSet   - CPU registers would be set to the values contained in this\r
+                  structure before making the far call. Then CPU registers are\r
+                  copied back to this structure.\r
+                  SS:ESP points to the real mode stack if THUNK_USER_STACK is\r
+                  set on input, otherwise ignored.\r
+                  EFlages is ignored on input.\r
+                  On output, values of CS, EIP, SS and ESP should be ignored.\r
+  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
+                  THUNK_USER_STACK.\r
+                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
+                                        before/after calling real mode code.\r
+                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
+                                        used instead of the default stack.\r
+\r
+Returns:\r
+\r
+  RegisterSet is returned.\r
+\r
+--*/\r
+{\r
+  IA32_FX_BUFFER                    *FpSavedState;\r
+  UINT8                             FpBuffer[sizeof (*FpSavedState) + 0x10];\r
+\r
+  FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf);\r
+\r
+  if (!(ThunkFlags & THUNK_USER_STACK)) {\r
+    RegisterSet->E.ESP = (UINT16)ThunkContext->DefaultStack;\r
+    RegisterSet->E.SS = (UINT16)((ThunkContext->DefaultStack >> 4) & 0xf000);\r
+  }\r
+\r
+  if (ThunkFlags & THUNK_SAVE_FP_STATE) {\r
+    AsmFxSave (FpSavedState);\r
+  }\r
+\r
+  EfiCommonLibCopyMem (\r
+    RegisterSet,\r
+    _Thunk16 (\r
+      RegisterSet,\r
+      (UINT16)(ThunkFlags >> 16),\r
+      ThunkContext->RealModeBuffer >> 4\r
+      ),\r
+    sizeof (*RegisterSet)\r
+    );\r
+\r
+  if (ThunkFlags & THUNK_SAVE_FP_STATE) {\r
+    AsmFxRestore (FpSavedState);\r
+  }\r
+\r
+  return RegisterSet;\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsmThunk16GetProperties (\r
+  OUT     UINTN                     *MinimumStackSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Returns the properties of this real mode thunk implementation. Currently\r
+  there are 2 properties has been defined, the minimum real mode buffer size\r
+  and the minimum stack size.\r
+\r
+Arguments:\r
+\r
+  MinimumStackSize  - The minimum size required for a 16-bit stack.\r
+\r
+Returns:\r
+\r
+  The minimum size of the real mode buffer needed by this thunk implementation\r
+  is returned.\r
+\r
+--*/\r
+{\r
+  //\r
+  // This size should be large enough to hold the register set as well as saved\r
+  // CPU contexts including GDTR, CR0 and CR4\r
+  //\r
+  if (MinimumStackSize) {\r
+    *MinimumStackSize = sizeof (IA32_REGISTER_SET) + 0x200;\r
+  }\r
+\r
+  return mCode16Size;\r
+}\r
+\r
+THUNK_CONTEXT *\r
+EFIAPI\r
+AsmThunk16SetProperties (\r
+  OUT     THUNK_CONTEXT             *ThunkContext,\r
+  IN      VOID                      *RealModeBuffer,\r
+  IN      UINTN                     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Tell this real mode thunk implementation the address and size of the real\r
+  mode buffer needed.\r
+\r
+Arguments:\r
+\r
+  ThunkContext    - The thunk context whose properties to set.\r
+  RealModeBuffer  - The address of the buffer allocated by caller. It should be\r
+                    aligned on a 16-byte boundary.\r
+                    This buffer must be in identity mapped pages.\r
+  BufferSize      - The size of RealModeBuffer. Must be larger than the minimum\r
+                    size required as returned by AsmThunk16GetProperties().\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  BufferSize &= ~3;\r
+\r
+  ThunkContext->RealModeBuffer = (UINT32)(UINTN)RealModeBuffer;\r
+  ThunkContext->DefaultStack   = (UINT32)(ThunkContext->RealModeBuffer + BufferSize);\r
+  EfiCommonLibCopyMem (RealModeBuffer, (VOID*)(UINTN)_Code16Addr, mCode16Size);\r
+\r
+  return ThunkContext;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+AsmThunk16Destroy (\r
+  IN OUT  THUNK_CONTEXT             *ThunkContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reset all internal states to their initial values. The caller should not\r
+  release the real mode buffer until after a call to this function.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - The thunk context to destroy.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  ThunkContext->RealModeBuffer = 0;\r
+}\r
+\r
+IA32_REGISTER_SET *\r
+EFIAPI\r
+AsmThunk16FarCall86 (\r
+  IN      THUNK_CONTEXT             *ThunkContext,\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    Flags\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Make a far call to 16-bit code.\r
+\r
+  NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts\r
+        disabled because of GDTR and IDTR manipulations.\r
+        This function must be placed in identity mapped pages.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - Thunk context to use.\r
+  RegisterSet   - CPU registers would be set to the values contained in this\r
+                  structure before making the far call. Then CPU registers are\r
+                  copied back to this structure.\r
+                  CS:EIP points to the real mode code being called on input.\r
+                  SS:ESP points to the real mode stack if THUNK_USER_STACK is\r
+                  set on input, otherwise ignored.\r
+                  EFlages is ignored on input.\r
+                  On output, values of CS, EIP, SS and ESP should be ignored.\r
+  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
+                  THUNK_USER_STACK.\r
+                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
+                                        before/after calling real mode code.\r
+                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
+                                        used instead of the default stack.\r
+\r
+Returns:\r
+\r
+  RegisterSet is returned.\r
+\r
+--*/\r
+{\r
+  return AsmThunk16 (ThunkContext, RegisterSet, Flags);\r
+}\r
+\r
+IA32_REGISTER_SET *\r
+EFIAPI\r
+AsmThunk16Int86 (\r
+  IN      THUNK_CONTEXT             *ThunkContext,\r
+  IN      UINT8                     IntNumber,\r
+  IN OUT  IA32_REGISTER_SET         *RegisterSet,\r
+  IN      UINT32                    Flags\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Invoke a 16-bit interrupt handler.\r
+\r
+  NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts\r
+        disabled because of GDTR and IDTR manipulations.\r
+        This function must be placed in identity mapped pages.\r
+\r
+Arguments:\r
+\r
+  ThunkContext  - Thunk context to use.\r
+  IntNumber     - The ordinal of the interrupt handler ranging from 0 to 255.\r
+  RegisterSet   - CPU registers would be set to the values contained in this\r
+                  structure before making the far call. Then CPU registers are\r
+                  copied back to this structure.\r
+                  SS:ESP points to the real mode stack if THUNK_USER_STACK is\r
+                  set on input, otherwise ignored.\r
+                  EFlages is ignored on input.\r
+                  On output, values of CS, EIP, SS and ESP should be ignored.\r
+  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
+                  THUNK_USER_STACK.\r
+                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
+                                        before/after calling real mode code.\r
+                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
+                                        used instead of the default stack.\r
+\r
+Returns:\r
+\r
+  RegisterSet is returned.\r
+\r
+--*/\r
+{\r
+  RegisterSet->E.EIP = (UINT16)((UINT32 *)NULL)[IntNumber];\r
+  RegisterSet->E.CS  = (UINT16)(((UINT32 *)NULL)[IntNumber] >> 16);\r
+\r
+  return AsmThunk16 (ThunkContext, RegisterSet, Flags | THUNK_INTERRUPT);\r
+}\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c
new file mode 100644 (file)
index 0000000..9293d10
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BaseMemoryTest.c\r
+\r
+Abstract:\r
+\r
+  PEI memory test PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (BaseMemoryTest)\r
+\r
+EFI_GUID  gPeiBaseMemoryTestPpiGuid = PEI_BASE_MEMORY_TEST_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiBaseMemoryTestPpiGuid, "PeiBaseMemoryTest", "Pei Base Memory Test PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h
new file mode 100644 (file)
index 0000000..9498c16
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BaseMemoryTest.h\r
+\r
+Abstract:\r
+\r
+  Pei memory test PPI as defined in Tiano\r
+\r
+  Used to Pei memory test in PEI\r
+\r
+--*/\r
+\r
+#ifndef _BASE_MEMORY_TEST_H_\r
+#define _BASE_MEMORY_TEST_H_\r
+\r
+#define PEI_BASE_MEMORY_TEST_GUID \\r
+  { \\r
+    0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (PEI_BASE_MEMORY_TEST_PPI);\r
+\r
+typedef enum {\r
+  Ignore,\r
+  Quick,\r
+  Sparse,\r
+  Extensive\r
+} PEI_MEMORY_TEST_OP;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_BASE_MEMORY_TEST) (\r
+  IN  EFI_PEI_SERVICES                   **PeiServices,\r
+  IN PEI_BASE_MEMORY_TEST_PPI            * This,\r
+  IN  EFI_PHYSICAL_ADDRESS               BeginAddress,\r
+  IN  UINT64                             MemoryLength,\r
+  IN  PEI_MEMORY_TEST_OP                 Operation,\r
+  OUT EFI_PHYSICAL_ADDRESS               * ErrorAddress\r
+  );\r
+\r
+typedef struct _PEI_BASE_MEMORY_TEST_PPI {\r
+  PEI_BASE_MEMORY_TEST  BaseMemoryTest;\r
+} PEI_BASE_MEMORY_TEST_PPI;\r
+\r
+extern EFI_GUID gPeiBaseMemoryTestPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf
new file mode 100644 (file)
index 0000000..1fc4350
--- /dev/null
@@ -0,0 +1,51 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkPpiLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file for the Edk PPI library.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkPpiLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+    BaseMemoryTest\BaseMemoryTest.h\r
+    BaseMemoryTest\BaseMemoryTest.c\r
+    FlashMap\FlashMap.h\r
+    FlashMap\FlashMap.c\r
+    PeiInMemory\PeiInMemory.h\r
+    PeiInMemory\PeiInMemory.c\r
+    StatusCodeMemory\StatusCodeMemory.h\r
+    StatusCodeMemory\StatusCodeMemory.c\r
+    OperatorPresence\OperatorPresence.h\r
+    OperatorPresence\OperatorPresence.c\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c
new file mode 100644 (file)
index 0000000..db90583
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashMap.c\r
+\r
+Abstract:\r
+\r
+  Flash Map PPI GUID as defined in Tiano\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (FlashMap)\r
+\r
+EFI_GUID  gPeiFlashMapPpiGuid = PEI_FLASH_MAP_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiFlashMapPpiGuid, "Flash Map", "Flash Map PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h
new file mode 100644 (file)
index 0000000..7203055
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashMap.h\r
+\r
+Abstract:\r
+\r
+  FlashMap PPI defined in Tiano\r
+\r
+  This code abstracts FlashMap access\r
+\r
+--*/\r
+\r
+#ifndef _PEI_FLASH_MAP_PPI_H_\r
+#define _PEI_FLASH_MAP_PPI_H_\r
+\r
+#define PEI_FLASH_MAP_PPI_GUID \\r
+  { \\r
+    0xf34c2fa0, 0xde88, 0x4270, 0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c \\r
+  }\r
+\r
+#include "EfiFlashMap.h"\r
+\r
+EFI_FORWARD_DECLARATION (PEI_FLASH_MAP_PPI);\r
+\r
+//\r
+// Functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_GET_FLASH_AREA_INFO) (\r
+  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN PEI_FLASH_MAP_PPI            * This,\r
+  IN  EFI_FLASH_AREA_TYPE         AreaType,\r
+  IN  EFI_GUID                    * AreaTypeGuid,\r
+  OUT UINT32                      *NumEntries,\r
+  OUT EFI_FLASH_SUBAREA_ENTRY     **Entries\r
+  );\r
+\r
+//\r
+// PEI_FLASH_MAP_PPI\r
+//\r
+typedef struct _PEI_FLASH_MAP_PPI {\r
+  PEI_GET_FLASH_AREA_INFO GetAreaInfo;\r
+} PEI_FLASH_MAP_PPI;\r
+\r
+extern EFI_GUID gPeiFlashMapPpiGuid;\r
+\r
+#endif // _PEI_FLASH_MAP_PPI_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c
new file mode 100644 (file)
index 0000000..a5a2e14
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.            \r
+\r
+Module Name:\r
+\r
+  OperatorPresence.c\r
+\r
+Abstract:\r
+\r
+  PPI GUID definition for PEI_OPERATOR_PRESENCE_PPI\r
+\r
+--*/\r
+\r
+#include <Tiano.h>\r
+\r
+#include EFI_PPI_DEFINITION (OperatorPresence)\r
+\r
+EFI_GUID gPeiOperatorPresencePpiGuid = PEI_OPERATOR_PRESENCE_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiOperatorPresencePpiGuid, "OperatorPresence", "Operator Presence Detection");\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h
new file mode 100644 (file)
index 0000000..8d866de
--- /dev/null
@@ -0,0 +1,34 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.            \r
+\r
+Module Name:\r
+\r
+  OperatorPresence.h\r
+\r
+Abstract:\r
+\r
+  PPI published by the PEIM who's responsible for detecting operator presence\r
+\r
+--*/\r
+\r
+#ifndef _PEI_OPERATOR_PRESENCE_H_\r
+#define _PEI_OPERATOR_PRESENCE_H_\r
+\r
+#define PEI_OPERATOR_PRESENCE_PPI_GUID  \\r
+  { 0x20a7378c, 0xaa83, 0x4ce1, 0x82, 0x1f, 0x47, 0x40, 0xee, 0x1b, 0x3f, 0x9f }\r
+\r
+typedef struct _PEI_OPERATOR_PRESENCE_PPI {\r
+  BOOLEAN                           OperatorPresent;\r
+} PEI_OPERATOR_PRESENCE_PPI;\r
+\r
+extern EFI_GUID                     gPeiOperatorPresencePpiGuid;\r
+\r
+#endif  //  _PEI_OPERATOR_PRESENCE_H_\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c
new file mode 100644 (file)
index 0000000..c081660
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiInMemory.c\r
+\r
+Abstract:\r
+\r
+  Capsule on Fat Usb Disk GUID.\r
+\r
+  This is the contract between the recovery module and device recovery module\r
+  in order to convey the name of a given recovery module type\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION(PeiInMemory)\r
+\r
+EFI_GUID gPeiInMemoryGuid = PEI_IN_MEMORY_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiInMemoryGuid, "PeiInMemory", "PEIM In Memory");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h
new file mode 100644 (file)
index 0000000..571c617
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeiInMemory.h\r
+    \r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#ifndef _PEI_IN_MEMORY_H\r
+#define _PEI_IN_MEMORY_H\r
+        \r
+#define PEI_IN_MEMORY_GUID \\r
+  {0x643b8786, 0xb417, 0x48d2, 0x8f, 0x5e, 0x78, 0x19, 0x93, 0x1c, 0xae, 0xd8}\r
+  \r
+extern EFI_GUID gPeiInMemoryGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c
new file mode 100644 (file)
index 0000000..683baef
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeMemory.c\r
+\r
+Abstract:\r
+\r
+  Status Code Memory descriptor\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include EFI_PPI_DEFINITION (StatusCodeMemory)\r
+\r
+EFI_GUID gPeiStatusCodeMemoryPpiGuid = PEI_STATUS_CODE_MEMORY_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gPeiStatusCodeMemoryPpiGuid, "StatusCodeMemory", "Status Code memory descriptor.");\r
diff --git a/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h
new file mode 100644 (file)
index 0000000..46543f1
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StatusCodeMemory.h\r
+    \r
+Abstract:\r
+\r
+  Status Code memory descriptor PPI.  Contains information about memory that \r
+  the Status Code PEIM may use to journal Status Codes.\r
+\r
+--*/\r
+\r
+#ifndef _PEI_STATUS_CODE_MEMORY_PPI_H_\r
+#define _PEI_STATUS_CODE_MEMORY_PPI_H_\r
+\r
+//\r
+// GUID definition\r
+//\r
+#define PEI_STATUS_CODE_MEMORY_PPI_GUID \\r
+  { 0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b }\r
+\r
+//\r
+// Data types\r
+//\r
+typedef struct {\r
+  EFI_STATUS_CODE_TYPE    Type;\r
+  EFI_STATUS_CODE_VALUE   Value;\r
+  UINT32                  Instance;\r
+} EFI_STATUS_CODE_ENTRY;\r
+\r
+//\r
+// PPI definition\r
+//\r
+typedef struct {\r
+  UINTN                   FirstEntry;\r
+  UINTN                   LastEntry;\r
+  EFI_PHYSICAL_ADDRESS    Address;\r
+  UINTN                   Length;\r
+} PEI_STATUS_CODE_MEMORY_PPI;\r
+\r
+extern EFI_GUID gPeiStatusCodeMemoryPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c
new file mode 100644 (file)
index 0000000..9915598
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleControl.c\r
+\r
+Abstract:\r
+\r
+  Abstraction of a Text mode or GOP/UGA screen\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (ConsoleControl)\r
+\r
+\r
+EFI_GUID gEfiConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiConsoleControlProtocolGuid, "Console Control Protocol", "Console Control Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h
new file mode 100644 (file)
index 0000000..5185cc7
--- /dev/null
@@ -0,0 +1,122 @@
+/*++ \r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleControl.h\r
+\r
+Abstract:\r
+\r
+  Abstraction of a Text mode or GOP/UGA screen\r
+\r
+--*/\r
+\r
+#ifndef __CONSOLE_CONTROL_H__\r
+#define __CONSOLE_CONTROL_H__\r
+\r
+#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \\r
+  { 0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 }\r
+\r
+typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL   EFI_CONSOLE_CONTROL_PROTOCOL;\r
+\r
+\r
+typedef enum {\r
+  EfiConsoleControlScreenText,\r
+  EfiConsoleControlScreenGraphics,\r
+  EfiConsoleControlScreenMaxValue\r
+} EFI_CONSOLE_CONTROL_SCREEN_MODE;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) (\r
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,\r
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   *Mode,\r
+  OUT BOOLEAN                           *GopUgaExists,  OPTIONAL  \r
+  OUT BOOLEAN                           *StdInLocked    OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information. Also returns info about existence\r
+    of Graphics Output devices or UGA Draw devices in system, and if the Std In\r
+    device is locked. All the arguments are optional and only returned if a non\r
+    NULL pointer is passed in.\r
+\r
+  Arguments:\r
+    This         - Protocol instance pointer.\r
+    Mode         - Are we in text of grahics mode.\r
+    GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device\r
+    StdInLocked  - TRUE if StdIn device is keyboard locked\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+\r
+--*/\r
+;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) (\r
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,\r
+  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set the current mode to either text or graphics. Graphics is\r
+    for Quiet Boot.\r
+\r
+  Arguments:\r
+    This  - Protocol instance pointer.\r
+    Mode  - Mode to set the \r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+\r
+--*/\r
+;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) (\r
+  IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,\r
+  IN CHAR16                             *Password\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Lock Std In devices until Password is typed.\r
+\r
+  Arguments:\r
+    This     - Protocol instance pointer.\r
+    Password - Password needed to unlock screen. NULL means unlock keyboard\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - Mode information returned.\r
+    EFI_DEVICE_ERROR - Std In not locked\r
+\r
+--*/\r
+;\r
+\r
+\r
+\r
+typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL {\r
+  EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE           GetMode;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE           SetMode;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN        LockStdIn;\r
+} EFI_CONSOLE_CONTROL_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiConsoleControlProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c
new file mode 100644 (file)
index 0000000..cfe4a0a
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    CustomizedDecompress.c\r
+    \r
+Abstract:\r
+\r
+  The GUID for the user Customized Decompress Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(CustomizedDecompress)\r
+\r
+EFI_GUID gEfiCustomizedDecompressProtocolGuid = EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiCustomizedDecompressProtocolGuid, "Cutomized Decompress", "Customized Decompression Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h
new file mode 100644 (file)
index 0000000..8e23745
--- /dev/null
@@ -0,0 +1,139 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CustomizedDecompress.h\r
+    \r
+Abstract:\r
+\r
+  The user Customized Decompress Protocol Interface\r
+\r
+--*/\r
+\r
+#ifndef _CUSTOMIZED_DECOMPRESS_H_\r
+#define _CUSTOMIZED_DECOMPRESS_H_\r
+\r
+#define EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID \\r
+  { 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_GET_INFO) (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL       *This,\r
+  IN   VOID                                   *Source,\r
+  IN   UINT32                                 SourceSize,\r
+  OUT  UINT32                                 *DestinationSize,\r
+  OUT  UINT32                                 *ScratchSize\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The GetInfo() function retrieves the size of the uncompressed buffer \r
+  and the temporary scratch buffer required to decompress the buffer \r
+  specified by Source and SourceSize.  If the size of the uncompressed\r
+  buffer or the size of the scratch buffer cannot be determined from \r
+  the compressed data specified by Source and SourceData, then \r
+  EFI_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
+  buffer is returned in DestinationSize, the size of the scratch buffer is \r
+  returned in ScratchSize, and EFI_SUCCESS is returned.\r
+  \r
+  The GetInfo() function does not have scratch buffer available to perform \r
+  a thorough checking of the validity of the source data. It just retrieves\r
+  the 'Original Size' field from the beginning bytes of the source data and\r
+  output it as DestinationSize.  And ScratchSize is specific to the decompression\r
+  implementation.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size, in bytes, of source buffer.\r
+  DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer\r
+                    that will be generated when the compressed buffer specified \r
+                    by Source and SourceSize is decompressed.\r
+  ScratchSize     - A pointer to the size, in bytes, of the scratch buffer that \r
+                    is required to decompress the compressed buffer specified by\r
+                    Source and SourceSize.\r
+\r
+Returns:\r
+  EFI_SUCCESS     - The size of the uncompressed data was returned in DestinationSize\r
+                    and the size of the scratch buffer was returned in ScratchSize.\r
+  EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch\r
+                  buffer cannot be determined from the compressed data specified by \r
+                  Source and SourceData.\r
+\r
+--*/\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS) (\r
+  IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL         *This,\r
+  IN     VOID*                                  Source,\r
+  IN     UINT32                                 SourceSize,\r
+  IN OUT VOID*                                  Destination,\r
+  IN     UINT32                                 DestinationSize,\r
+  IN OUT VOID*                                  Scratch,\r
+  IN     UINT32                                 ScratchSize\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Decompress() function extracts decompressed data to its original form.\r
+  \r
+  This protocol is designed so that the decompression algorithm can be \r
+  implemented without using any memory services.  As a result, the \r
+  Decompress() function is not allowed to call AllocatePool() or \r
+  AllocatePages() in its implementation.  It is the caller's responsibility \r
+  to allocate and free the Destination and Scratch buffers.\r
+  \r
+  If the compressed source data specified by Source and SourceSize is \r
+  sucessfully decompressed into Destination, then EFI_SUCCESS is returned.  \r
+  If the compressed source data specified by Source and SourceSize is not in \r
+  a valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size of source data.\r
+  Destination     - On output, the destination buffer that contains \r
+                    the uncompressed data.\r
+  DestinationSize - The size of destination buffer. The size of destination\r
+                    buffer needed is obtained from GetInfo().\r
+  Scratch         - A temporary scratch buffer that is used to perform the \r
+                    decompression.\r
+  ScratchSize     - The size of scratch buffer. The size of scratch buffer needed\r
+                    is obtained from GetInfo().\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Decompression completed successfully, and the uncompressed \r
+                    buffer is returned in Destination.\r
+  EFI_INVALID_PARAMETER \r
+                  - The source buffer specified by Source and SourceSize is \r
+                    corrupted (not in a valid compressed format).\r
+\r
+--*/\r
+\r
+typedef struct _EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL {\r
+  EFI_CUSTOMIZED_DECOMPRESS_GET_INFO    GetInfo;\r
+  EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS  Decompress;\r
+} EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiCustomizedDecompressProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c
new file mode 100644 (file)
index 0000000..3303fc3
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DebugAssert.c\r
+\r
+Abstract:\r
+\r
+  This protocol allows provides debug services to a driver. This is not \r
+  debugger support, but things like ASSERT() and DEBUG() macros\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(DebugAssert)\r
\r
+\r
+EFI_GUID gEfiDebugAssertProtocolGuid = EFI_DEBUG_ASSERT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDebugAssertProtocolGuid, "EFI Debug Assert", "Efi Debug Assert Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h
new file mode 100644 (file)
index 0000000..1748693
--- /dev/null
@@ -0,0 +1,89 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugAssert.h\r
+\r
+Abstract:\r
+\r
+  This protocol allows provides debug services to a driver. This is not \r
+  debugger support, but things like ASSERT() and DEBUG() macros\r
+\r
+--*/\r
+\r
+#ifndef _DEBUG_ASSERT_H_\r
+#define _DEBUG_ASSERT_H_\r
+\r
+\r
+#define EFI_DEBUG_ASSERT_PROTOCOL_GUID \\r
+  { 0xbe499c92, 0x7d4b, 0x11d4, 0xbc, 0xee, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_DEBUG_ASSERT_PROTOCOL);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUG_ASSERT) (\r
+  IN EFI_DEBUG_ASSERT_PROTOCOL  *This,\r
+  IN CHAR8                              *FileName,\r
+  IN INTN                               LineNumber,\r
+  IN CHAR8                              *Description\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEBUG_PRINT) (\r
+  IN EFI_DEBUG_ASSERT_PROTOCOL  *This,\r
+  IN  UINTN                             ErrorLevel,\r
+  IN  CHAR8                             *Format,\r
+  IN  VA_LIST                           Marker\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_POST_CODE) (\r
+  IN EFI_DEBUG_ASSERT_PROTOCOL  *This,\r
+  IN  UINT16                            PostCode,\r
+  IN  CHAR8                             *PostCodeString  OPTIONAL\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_GET_ERROR_LEVEL) (\r
+  IN EFI_DEBUG_ASSERT_PROTOCOL  *This,\r
+  IN  UINTN                             *ErrorLevel\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_ERROR_LEVEL) (\r
+  IN EFI_DEBUG_ASSERT_PROTOCOL  *This,\r
+  IN  UINTN                             ErrorLevel\r
+  );\r
+\r
+typedef struct _EFI_DEBUG_ASSERT_PROTOCOL {\r
+  \r
+  EFI_DEBUG_ASSERT    Assert;\r
+  EFI_DEBUG_PRINT     Print;\r
+  EFI_POST_CODE       PostCode;\r
+\r
+  EFI_GET_ERROR_LEVEL GetErrorLevel;\r
+  EFI_SET_ERROR_LEVEL SetErrorLevel;\r
+\r
+} EFI_DEBUG_ASSERT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDebugAssertProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c
new file mode 100644 (file)
index 0000000..3efa661
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DebugMask.c\r
+\r
+Abstract:\r
+\r
+  This protocol is used to abstract the Debug Mask serivces for \r
+  the specific driver or application image.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(DebugMask)\r
\r
+\r
+EFI_GUID gEfiDebugMaskProtocolGuid = EFI_DEBUG_MASK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDebugMaskProtocolGuid, "DebugMask Protocol", "Efi Debug Mask Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h
new file mode 100644 (file)
index 0000000..8a8e638
--- /dev/null
@@ -0,0 +1,68 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugMask.h\r
+\r
+Abstract:\r
+\r
+  This protocol is used to abstract the Debug Mask serivces for \r
+  the specific driver or application image.\r
+\r
+--*/\r
+\r
+#ifndef _DEBUG_MASK_H_\r
+#define _DEBUG_MASK_H_\r
+\r
+//\r
+//4C8A2451-C207-405b-9694-99EA13251341\r
+//\r
+#define EFI_DEBUG_MASK_PROTOCOL_GUID \\r
+  { 0x4c8a2451, 0xc207, 0x405b, 0x96, 0x94, 0x99, 0xea, 0x13, 0x25, 0x13, 0x41 }\r
+\r
+\r
+#define EFI_DEBUG_MASK_REVISION        0x00010000\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_DEBUG_MASK_PROTOCOL);\r
+\r
+//\r
+// DebugMask member functions definition\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_GET_DEBUG_MASK) (\r
+  IN EFI_DEBUG_MASK_PROTOCOL      *This,             // Calling context\r
+  IN OUT UINTN                    *CurrentDebugMask  // Ptr to store current debug mask\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EFI_SET_DEBUG_MASK) (\r
+  IN  EFI_DEBUG_MASK_PROTOCOL     *This,             // Calling context\r
+  IN  UINTN                       NewDebugMask       // New Debug Mask value to set\r
+  );\r
+\r
+//\r
+// DebugMask protocol definition\r
+//\r
+typedef struct _EFI_DEBUG_MASK_PROTOCOL {\r
+  INT64                               Revision;\r
+  EFI_GET_DEBUG_MASK                  GetDebugMask;\r
+  EFI_SET_DEBUG_MASK                  SetDebugMask;\r
+} EFI_DEBUG_MASK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDebugMaskProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c
new file mode 100644 (file)
index 0000000..e8c4773
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DebugSerialIo.c\r
+\r
+Abstract:\r
+\r
+  Debug Serial IO protocol.\r
+\r
+  Abstraction of a basic serial device. Targeted at 16550 UART, but\r
+  could be much more generic.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (DebugSerialIo)\r
+\r
+EFI_GUID  gEfiDebugSerialIoProtocolGuid = EFI_DEBUG_SERIAL_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDebugSerialIoProtocolGuid, "DebugSerialIo Protocol", "EFI 1.0 DebugSerial IO Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h
new file mode 100644 (file)
index 0000000..22278f5
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DebugSerialIo.h\r
+\r
+Abstract:\r
+\r
+  Debug Serial IO protocol.\r
+\r
+  Abstraction of a basic serial device. Targeted at 16550 UART, but\r
+  could be much more generic.\r
+\r
+--*/\r
+\r
+#ifndef _DEBUG_SERIAL_IO_H_\r
+#define _DEBUG_SERIAL_IO_H_\r
+\r
+#define EFI_DEBUG_SERIAL_IO_PROTOCOL_GUID \\r
+{ 0xe683dc4f, 0x9ed, 0x4f22, { 0x86, 0x6b, 0x8e, 0x40, 0x46, 0x94, 0x7c, 0x6c } }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DEBUG_SERIAL_IO_PROTOCOL);\r
+\r
+#include EFI_PROTOCOL_DEFINITION (SerialIo)\r
+\r
+extern EFI_GUID gEfiDebugSerialIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c
new file mode 100644 (file)
index 0000000..fb09f30
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DiskInfo.c\r
+\r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (DiskInfo)\r
+\r
+EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiDiskInfoProtocolGuid, "Disk Info Protocol", "Disk Info Protocol");\r
+\r
+EFI_GUID gEfiDiskInfoIdeInterfaceGuid = EFI_DISK_INFO_IDE_INTERFACE_GUID;\r
+EFI_GUID gEfiDiskInfoScsiInterfaceGuid = EFI_DISK_INFO_SCSI_INTERFACE_GUID;\r
+EFI_GUID gEfiDiskInfoUsbInterfaceGuid = EFI_DISK_INFO_USB_INTERFACE_GUID;\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h
new file mode 100644 (file)
index 0000000..3de25d9
--- /dev/null
@@ -0,0 +1,174 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DiskInfo.h\r
+\r
+Abstract:\r
+\r
+  Disk Info protocol is used to export Inquiry Data for a drive.\r
+  Its needed to support low level formating of drives in a mannor\r
+  thats DOS compatible.\r
+\r
+--*/\r
+\r
+#ifndef __DISK_INFO_H__\r
+#define __DISK_INFO_H__\r
+\r
+#define EFI_DISK_INFO_PROTOCOL_GUID \\r
+  { \\r
+    0xd432a67f, 0x14dc, 0x484b, 0xb3, 0xbb, 0x3f, 0x2, 0x91, 0x84, 0x93, 0x27 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_DISK_INFO_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_INFO_INQUIRY) (\r
+  IN EFI_DISK_INFO_PROTOCOL           * This,\r
+  IN OUT VOID                         *InquiryData,\r
+  IN OUT UINT32                       *IntquiryDataSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the results of the Inquiry command to a drive in InquiryData.\r
+    Data format of Inquiry data is defined by the Interface GUID.\r
+\r
+  Arguments:\r
+    This        - Protocol instance pointer.\r
+    InquiryData - Results of Inquiry command to device\r
+    InquiryDataSize - Size of InquiryData in bytes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - InquiryData valid\r
+    EFI_NOT_FOUND     - Device does not support this data class\r
+    EFI_DEVICE_ERROR  - Error reading InquiryData from device \r
+    EFI_BUFFER_TOO_SMALL - IntquiryDataSize not big enough\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_INFO_IDENTIFY) (\r
+  IN EFI_DISK_INFO_PROTOCOL           * This,\r
+  IN OUT VOID                         *IdentifyData,\r
+  IN OUT UINT32                       *IdentifyDataSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the results of the Identify command to a drive in IdentifyData.\r
+    Data format of Identify data is defined by the Interface GUID.\r
+\r
+  Arguments:\r
+    This        - Protocol instance pointer.\r
+    IdentifyData - Results of Identify command to device\r
+    IdentifyDataSize - Size of IdentifyData in bytes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - IdentifyData valid\r
+    EFI_NOT_FOUND     - Device does not support this data class\r
+    EFI_DEVICE_ERROR  - Error reading IdentifyData from device \r
+    EFI_BUFFER_TOO_SMALL - IdentifyDataSize not big enough\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_INFO_SENSE_DATA) (\r
+  IN EFI_DISK_INFO_PROTOCOL           * This,\r
+  IN OUT VOID                         *SenseData,\r
+  IN OUT UINT32                       *SenseDataSize,\r
+  OUT UINT8                           *SenseDataNumber\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the results of the Request Sense command to a drive in SenseData.\r
+    Data format of Sense data is defined by the Interface GUID.\r
+\r
+  Arguments:\r
+    This            - Protocol instance pointer.\r
+    SenseData       - Results of Request Sense command to device\r
+    SenseDataSize   - Size of SenseData in bytes.\r
+    SenseDataNumber - Type of SenseData\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - InquiryData valid\r
+    EFI_NOT_FOUND     - Device does not support this data class\r
+    EFI_DEVICE_ERROR  - Error reading InquiryData from device \r
+    EFI_BUFFER_TOO_SMALL - SenseDataSize not big enough\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_INFO_WHICH_IDE) (\r
+  IN EFI_DISK_INFO_PROTOCOL           * This,\r
+  OUT UINT32                          *IdeChannel,\r
+  OUT UINT32                          *IdeDevice\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the results of the Request Sense command to a drive in SenseData.\r
+    Data format of Sense data is defined by the Interface GUID.\r
+\r
+  Arguments:\r
+    This        - Protocol instance pointer.\r
+    IdeChannel  - Primary or Secondary\r
+    IdeDevice   - Master or Slave\r
+\r
+  Returns:\r
+    EFI_SUCCESS       - IdeChannel and IdeDevice are valid\r
+    EFI_UNSUPPORTED   - This is not an IDE device\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// GUIDs for EFI_DISK_INFO_PROTOCOL.Interface. Defines the format of the\r
+// buffers returned by member functions\r
+//\r
+#define EFI_DISK_INFO_IDE_INTERFACE_GUID \\r
+  { \\r
+    0x5e948fe3, 0x26d3, 0x42b5, 0xaf, 0x17, 0x61, 0x2, 0x87, 0x18, 0x8d, 0xec \\r
+  }\r
+extern EFI_GUID gEfiDiskInfoIdeInterfaceGuid;\r
+\r
+#define EFI_DISK_INFO_SCSI_INTERFACE_GUID \\r
+  { \\r
+    0x8f74baa, 0xea36, 0x41d9, 0x95, 0x21, 0x21, 0xa7, 0xf, 0x87, 0x80, 0xbc \\r
+  }\r
+extern EFI_GUID gEfiDiskInfoScsiInterfaceGuid;\r
+\r
+#define EFI_DISK_INFO_USB_INTERFACE_GUID \\r
+  { \\r
+    0xcb871572, 0xc11a, 0x47b5, 0xb4, 0x92, 0x67, 0x5e, 0xaf, 0xa7, 0x77, 0x27 \\r
+  }\r
+extern EFI_GUID gEfiDiskInfoUsbInterfaceGuid;\r
+\r
+typedef struct _EFI_DISK_INFO_PROTOCOL {\r
+  EFI_GUID                  Interface;\r
+  EFI_DISK_INFO_INQUIRY     Inquiry;\r
+  EFI_DISK_INFO_IDENTIFY    Identify;\r
+  EFI_DISK_INFO_SENSE_DATA  SenseData;\r
+  EFI_DISK_INFO_WHICH_IDE   WhichIde;\r
+} EFI_DISK_INFO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiDiskInfoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf
new file mode 100644 (file)
index 0000000..7d769c0
--- /dev/null
@@ -0,0 +1,111 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkProtocolLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkProtocolLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+\r
+[nmake.common]\r
+\r
+[sources.common]\r
+  ConsoleControl\ConsoleControl.h\r
+  ConsoleControl\ConsoleControl.c\r
+  CustomizedDecompress\CustomizedDecompress.c\r
+  CustomizedDecompress\CustomizedDecompress.h\r
+  DebugAssert\DebugAssert.h\r
+  DebugAssert\DebugAssert.c\r
+  DebugMask\DebugMask.h\r
+  DebugMask\DebugMask.c\r
+  DebugSerialIo\DebugSerialIo.h\r
+  DebugSerialIo\DebugSerialIo.c\r
+  DiskInfo\DiskInfo.h\r
+  DiskInfo\DiskInfo.c\r
+  EfiOemBadging\EfiOemBadging.h\r
+  EfiOemBadging\EfiOemBadging.c\r
+  FaultTolerantWriteLite\FaultTolerantWriteLite.h\r
+  FaultTolerantWriteLite\FaultTolerantWriteLite.c\r
+  FirmwareVolumeDispatch\FirmwareVolumeDispatch.h\r
+  FirmwareVolumeDispatch\FirmwareVolumeDispatch.c\r
+  FvbExtension\FvbExtension.h\r
+  FvbExtension\FvbExtension.c\r
+  GenericMemoryTest\GenericMemoryTest.h\r
+  GenericMemoryTest\GenericMemoryTest.c\r
+  GuidedSectionExtraction\GuidedSectionExtraction.h\r
+  GuidedSectionExtraction\GuidedSectionExtraction.c\r
+  IsaAcpi\IsaAcpi.h\r
+  IsaAcpi\IsaAcpi.c\r
+  IsaIo\IsaIo.h\r
+  IsaIo\IsaIo.c\r
+  LegacyBiosThunk\LegacyBiosThunk.h\r
+  LegacyBiosThunk\LegacyBiosThunk.c\r
+  LoadPe32Image\LoadPe32Image.h\r
+  LoadPe32Image\LoadPe32Image.c\r
+  NicIp4Config\NicIp4Config.h\r
+  NicIp4Config\NicIp4Config.c\r
+  PciHotPlugRequest\PciHotPlugRequest.h\r
+  PciHotPlugRequest\PciHotPlugRequest.c\r
+  Performance\Performance.h\r
+  Performance\Performance.c\r
+  PlatformMemTest\PlatformMemTest.h\r
+  PlatformMemTest\PlatformMemTest.c\r
+  Print\Print.h\r
+  Print\Print.c\r
+  PxeDhcp4\PxeDhcp4.h\r
+  PxeDhcp4\PxeDhcp4.c\r
+  PxeDhcp4Callback\PxeDhcp4Callback.h\r
+  PxeDhcp4Callback\PxeDhcp4Callback.c\r
+  Tcp\Tcp.h\r
+  Tcp\Tcp.c\r
+  TianoDecompress\TianoDecompress.h\r
+  TianoDecompress\TianoDecompress.c\r
+  UgaSplash\UgaSplash.h\r
+  UgaSplash\UgaSplash.c\r
+  UsbAtapi\UsbAtapi.h\r
+  UsbAtapi\UsbAtapi.c\r
+  VariableStore\VariableStore.h\r
+  VariableStore\VariableStore.c\r
+  VirtualMemoryAccess\VirtualMemoryAccess.h\r
+  VirtualMemoryAccess\VirtualMemoryAccess.c\r
+  TcgService\TcgService.h\r
+  TcgService\TcgService.c\r
+  Ps2Policy\Ps2Policy.h\r
+  Ps2Policy\Ps2Policy.c\r
+  VgaMiniPort\VgaMiniPort.h\r
+  VgaMiniPort\VgaMiniPort.c\r
+\r
+[sources.ipf]\r
+  ExtendedSalBootService\ExtendedSalBootService.c\r
+  ExtendedSalBootService\ExtendedSalBootService.h\r
+  ExtendedSalGuid\ExtendedSalGuid.c\r
+  ExtendedSalGuid\ExtendedSalGuid.h\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c
new file mode 100644 (file)
index 0000000..bb48e17
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiOEMBadging.c \r
+    \r
+Abstract:\r
+\r
+    EFI OEM Badging Protocol definition source file\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging)\r
+\r
+EFI_GUID  gEfiOEMBadgingProtocolGuid = EFI_OEM_BADGING_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiOEMBadgingProtocolGuid, "OEM Badging Protocol", "OEM Badging Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h
new file mode 100644 (file)
index 0000000..0dceb7f
--- /dev/null
@@ -0,0 +1,79 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    EfiOEMBadging.h\r
+    \r
+Abstract:\r
+\r
+    EFI OEM Badging Protocol definition header file\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_OEM_BADGING_H_\r
+#define _EFI_OEM_BADGING_H_\r
+\r
+//\r
+// GUID for EFI OEM Badging Protocol\r
+//\r
+#define EFI_OEM_BADGING_PROTOCOL_GUID \\r
+  { 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc }\r
+  \r
+\r
+EFI_FORWARD_DECLARATION (EFI_OEM_BADGING_PROTOCOL);\r
+\r
+typedef enum {\r
+  EfiBadgingFormatBMP,\r
+  EfiBadgingFormatJPEG,\r
+  EfiBadgingFormatTIFF,\r
+  EfiBadgingFormatGIF,\r
+  EfiBadgingFormatUnknown\r
+} EFI_BADGING_FORMAT;\r
+\r
+typedef enum {\r
+  EfiBadgingDisplayAttributeLeftTop,\r
+  EfiBadgingDisplayAttributeCenterTop,\r
+  EfiBadgingDisplayAttributeRightTop,\r
+  EfiBadgingDisplayAttributeCenterRight,\r
+  EfiBadgingDisplayAttributeRightBottom,\r
+  EfiBadgingDisplayAttributeCenterBottom,\r
+  EfiBadgingDisplayAttributeLeftBottom,\r
+  EfiBadgingDisplayAttributeCenterLeft,\r
+  EfiBadgingDisplayAttributeCenter,\r
+  EfiBadgingDisplayAttributeCustomized\r
+} EFI_BADGING_DISPLAY_ATTRIBUTE;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_BADGING_GET_IMAGE) (\r
+  IN     EFI_OEM_BADGING_PROTOCOL          *This,\r
+  IN OUT UINT32                            *Instance,\r
+     OUT EFI_BADGING_FORMAT                *Format,\r
+     OUT UINT8                             **ImageData,\r
+     OUT UINTN                             *ImageSize,\r
+     OUT EFI_BADGING_DISPLAY_ATTRIBUTE     *Attribute,\r
+     OUT UINTN                             *CoordinateX,   \r
+     OUT UINTN                             *CoordinateY   \r
+);\r
+\r
+\r
+typedef struct _EFI_OEM_BADGING_PROTOCOL {\r
+  EFI_BADGING_GET_IMAGE       GetImage;\r
+} EFI_OEM_BADGING_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiOEMBadgingProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c
new file mode 100644 (file)
index 0000000..9613745
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    ExtendedSalBootService.c\r
+\r
+Abstract:\r
+\r
+  This is a protocol creates infrastructure to register Extended Sal Procs.\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(ExtendedSalBootService)\r
+\r
+EFI_GUID gEfiExtendedSalBootServiceProtocolGuid = EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID;\r
+EFI_GUID_STRING(&gEfiExtendedSalBootServiceProtocolGuid, "EXT SAL", "Extended Sal Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h
new file mode 100644 (file)
index 0000000..8c7e105
--- /dev/null
@@ -0,0 +1,118 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ExtendedSalBootService.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _EXTENDED_SAL_PROTOCOL_H_\r
+#define _EXTENDED_SAL_PROTOCOL_H_\r
+\r
+#include "SalApi.h"\r
+#include "LinkedList.h"\r
+#include EFI_PROTOCOL_CONSUMER (CpuIo)\r
+\r
+\r
+#define EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID   \\r
+  {0xde0ee9a4,0x3c7a,0x44f2,0xb7,0x8b,0xe3,0xcc,0xd6,0x9c,0x3a,0xf7}\r
+\r
+#define EXTENDED_SAL_SIGNATURE  EFI_SIGNATURE_32('e', 's', 'a', 'l')\r
+\r
+#define SAL_MIN_STATE_SIZE    0x400 * 1\r
+#define PAL_SCARTCH_SIZE      0x400 * 3\r
+#define ALIGN_MINSTATE_SIZE   512\r
+#define MAX_SAL_RECORD_SIZE   8*1024\r
+\r
+#define SAL_RUNTIMESERVICE\r
+\r
+typedef UINT16    EFI_SAL_PROCESSOR_ID;\r
+\r
+EFI_FORWARD_DECLARATION (EXTENDED_SAL_BOOT_SERVICE_PROTOCOL);\r
+\r
+typedef\r
+SAL_RUNTIMESERVICE\r
+SAL_RETURN_REGS\r
+(EFIAPI *SAL_EXTENDED_SAL_PROC) (\r
+  IN  EFI_GUID                                    *ClassGuid,\r
+  IN   UINT64                                      FunctionId,\r
+  IN  UINT64                                      Arg2,\r
+  IN  UINT64                                      Arg3,\r
+  IN  UINT64                                      Arg4,\r
+  IN  UINT64                                      Arg5,\r
+  IN  UINT64                                      Arg6,\r
+  IN  UINT64                                      Arg7,\r
+  IN  UINT64                                      Arg8\r
+  );\r
+\r
+typedef\r
+SAL_RUNTIMESERVICE\r
+SAL_RETURN_REGS\r
+(EFIAPI *SAL_INTERNAL_EXTENDED_SAL_PROC) (\r
+  IN  UINT64                                      FunctionId,\r
+  IN  UINT64                                      Arg2,\r
+  IN  UINT64                                      Arg3,\r
+  IN  UINT64                                      Arg4,\r
+  IN  UINT64                                      Arg5,\r
+  IN  UINT64                                      Arg6,\r
+  IN  UINT64                                      Arg7,\r
+  IN  UINT64                                      Arg8,\r
+  IN  SAL_EXTENDED_SAL_PROC                       ExtendedSalProc,\r
+  IN   BOOLEAN                                     VirtualMode,\r
+  IN  VOID                                        *ModuleGlobal\r
+  ); \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EXTENDED_SAL_ADD_SST_INFO) (\r
+  IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL  *This,\r
+  IN  UINT16                                      SalAVersion,\r
+  IN   UINT16                                      SalBVersion,\r
+  IN  CHAR8                                        *OemId,\r
+  IN  CHAR8                                        *ProductId\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EXTENDED_SAL_ADD_SST_ENTRY) (\r
+  IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL  *This,\r
+  IN  UINT8                                        EntryType,\r
+  IN   UINT8                                        *TableEntry,\r
+  IN  UINTN                                        EntrySize\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EXTENDED_SAL_REGISTER_INTERNAL_PROC) (\r
+  IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL  *This,\r
+  IN  EFI_GUID                                    *ClassGuid,\r
+  IN   UINT64                                      FunctionId,\r
+  IN  SAL_INTERNAL_EXTENDED_SAL_PROC              InternalSalProc,\r
+  IN  VOID                                        *PhysicalModuleGlobal\r
+  );\r
+\r
+//\r
+// Extended Sal Boot Service Protocol Interface\r
+//\r
+typedef struct _EXTENDED_SAL_BOOT_SERVICE_PROTOCOL{\r
+  EXTENDED_SAL_ADD_SST_INFO                       AddSalSystemTableInfo;\r
+  EXTENDED_SAL_ADD_SST_ENTRY                      AddSalSystemTableEntry;\r
+  EXTENDED_SAL_REGISTER_INTERNAL_PROC             AddExtendedSalProc;   \r
+  SAL_EXTENDED_SAL_PROC                           ExtendedSalProc;\r
+  SAL_PROC                                        SalProc;\r
+} EXTENDED_SAL_BOOT_SERVICE_PROTOCOL;\r
+\r
+extern EFI_GUID   gEfiExtendedSalBootServiceProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c
new file mode 100644 (file)
index 0000000..2d8624d
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ExtendedSalGuid.c\r
+\r
+Abstract:\r
+\r
+  The Extended SAL Lock Services protocol as defined in SAL CIS.\r
+\r
+  This protocol is installed by the entity that supplies low level\r
+  lock primitives that work in dual mode. There are 3 functions\r
+  as defined below.\r
+                   \r
+--*/\r
+\r
+\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(ExtendedSalGuid)\r
+\r
+EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalStallServicesProtocolGuid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalLockServicesProtocolGuid = EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalResetServicesProtocolGuid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalMpServicesProtocolGuid = EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalPalServicesProtocolGuid = EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalPciServicesProtocolGuid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid = EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalElogServicesProtocolGuid = EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid = EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid = EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID;\r
+EFI_GUID gEfiExtendedSalSstGuid = EFI_EXTENDED_SAL_SST_GUID;\r
+\r
+\r
+EFI_GUID_STRING(&gEfiExtendedSalBaseIoServicesProtocolGuid, "SAL IO", "Extended SAL Base IO Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalStallServicesProtocolGuid, "SAL STALL", "Extended SAL Stall Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalLockServicesProtocolGuid, "SAL LOCK", "Extended SAL Lock Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalVirtualServicesProtocolGuid, "SAL VIRT", "Extended SAL Virtual Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalRtcServicesProtocolGuid, "SAL RTC", "Extended SAL Lock RTC Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalVariableServicesProtocolGuid, "SAL VARIABLE", "Extended SAL Variable Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalMtcServicesProtocolGuid, "SAL MTC", "Extended SAL MTC Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalResetServicesProtocolGuid, "SAL RESET", "Extended SAL Reset Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalStatusCodeServicesProtocolGuid, "SAL STATUS CODE", "Extended SAL Status Call Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalFvBlockServicesProtocolGuid, "SAL FVB", "Extended SAL FVB Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalMpServicesProtocolGuid, "SAL MP", "Extended SAL MP Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalPalServicesProtocolGuid, "SAL PAL", "Extended SAL PAL Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL BASE", "Extended SAL Base Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL MCA", "Extended SAL MCA Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalPciServicesProtocolGuid, "SAL PCI", "Extended SAL PCI Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalCacheServicesProtocolGuid, "SAL CACHE", "Extended SAL Cache Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalMcaLogServicesProtocolGuid, "MCA LOG", "Extended SAL MCA LOG Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalElogServicesProtocolGuid, "ELOG", "Extended SAL ELOG Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalSensorServicesProtocolGuid, "SENSOR", "Extended SAL SENSOR Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalSmComLayerServicesProtocolGuid, "SAL SM COM", "Extended SAL SM COM Services Protocol");\r
+EFI_GUID_STRING(&gEfiExtendedSalSstGuid, "SST SET UP", "SAL System Table Header Set up");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h
new file mode 100644 (file)
index 0000000..44361c1
--- /dev/null
@@ -0,0 +1,283 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ExtendedSalGuid.h\r
+\r
+Abstract:\r
+\r
+                  \r
+--*/\r
+\r
+#ifndef _EXTENDED_SAL_GUID_H_\r
+#define _EXTENDED_SAL_GUID_H_\r
+\r
+//\r
+// Extended SAL Services protocol GUIDs\r
+//\r
+\r
+#define EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID \\r
+  { 0x5aea42b5, 0x31e1, 0x4515, 0xbc, 0x31, 0xb8, 0xd5, 0x25, 0x75, 0x65, 0xa6 }\r
+\r
+#define EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID \\r
+  { 0x53a58d06, 0xac27, 0x4d8c, 0xb5, 0xe9, 0xf0, 0x8a, 0x80, 0x65, 0x41, 0x70 }\r
+\r
+#define EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID  \\r
+  { 0x76b75c23, 0xfe4f, 0x4e17, 0xa2, 0xad, 0x1a, 0x65, 0x3d, 0xbb, 0x49, 0x4a }\r
+\r
+#define EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID  \\r
+  { 0xc1a74056, 0x260e, 0x4871, 0xa0, 0x31, 0xe6, 0x45, 0xa6, 0x5b, 0x6e, 0x11 }\r
+\r
+#define EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID  \\r
+  { 0x7e97a470, 0xefdb, 0x4d02, 0x8f, 0xce, 0x61, 0x90, 0xd2, 0x7b, 0xa2, 0x96 }\r
+\r
+#define EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID  \\r
+  { 0x4ecb6c53, 0xc641, 0x4370, 0x8c, 0xb2, 0x3b, 0x0e, 0x49, 0x6e, 0x83, 0x78 }\r
+\r
+#define EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID  \\r
+  { 0x899afd18, 0x75e8, 0x408b, 0xa4, 0x1a, 0x6e, 0x2e, 0x7e, 0xcd, 0xf4, 0x54 }\r
+\r
+#define EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID  \\r
+  { 0x7d019990, 0x8ce1, 0x46f5, 0xa7, 0x76, 0x3c, 0x51, 0x98, 0x67, 0x6a, 0xa0 }\r
+\r
+#define EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID  \\r
+  { 0xdbd91d, 0x55e9, 0x420f, 0x96, 0x39, 0x5e, 0x9f, 0x84, 0x37, 0xb4, 0x4f }\r
+\r
+#define EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID \\r
+  { 0xa2271df1, 0xbcbb, 0x4f1d, 0x98, 0xa9, 0x06, 0xbc, 0x17, 0x2f, 0x07, 0x1a }\r
+\r
+#define EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID \\r
+  { 0x697d81a2, 0xcf18, 0x4dc0, 0x9e, 0x0d, 0x06, 0x11, 0x3b, 0x61, 0x8a, 0x3f }\r
+\r
+#define EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID \\r
+  { 0xe1cd9d21, 0x0fc2, 0x438d, 0x97, 0x03, 0x04, 0xe6, 0x6d, 0x96, 0x1e, 0x57 }\r
+\r
+#define EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID \\r
+  { 0xd9e9fa06, 0x0fe0, 0x41c3, 0x96, 0xfb, 0x83, 0x42, 0x5a, 0x33, 0x94, 0xf8 }\r
+\r
+#define EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID \\r
+  { 0x2a591128, 0x6cc7, 0x42b1, 0x8a, 0xf0, 0x58, 0x93, 0x3b, 0x68, 0x2d, 0xbb }\r
+\r
+#define EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID \\r
+  { 0xa46b1a31, 0xad66, 0x4905, 0x92, 0xf6, 0x2b, 0x46, 0x59, 0xdc, 0x30, 0x63 }\r
+\r
+#define EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID \\r
+  { 0xedc9494, 0x2743, 0x4ba5,  0x88, 0x18, 0x0a, 0xef, 0x52, 0x13, 0xf1, 0x88 }\r
+\r
+#define EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID \\r
+  { 0xcb3fd86e, 0x38a3, 0x4c03, 0x9a, 0x5c, 0x90, 0xcf, 0xa3, 0xa2, 0xab, 0x7a }\r
+\r
+#define EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID \\r
+  { 0xd5e4ee5f, 0x3e0a, 0x453c, 0xa7, 0x25, 0xb6, 0x92, 0xbb, 0x6, 0x36, 0x5a }\r
+\r
+#define EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID \\r
+  { 0x4a153b6e, 0x85a1, 0x4982, 0x98, 0xf4, 0x6a, 0x8c, 0xfc, 0xa4, 0xab, 0xa1 }\r
+\r
+#define EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID \\r
+  { 0x4356799, 0x81b7, 0x4e08,  0xa3, 0x8d, 0xd9, 0x78, 0xfa, 0x47, 0xba, 0x42 }\r
+\r
+#define EFI_EXTENDED_SAL_SST_GUID \\r
+  { 0x38802700, 0x868a, 0x4b4e, 0x81, 0xd4, 0x4f, 0x1b, 0xdc, 0xcf, 0xb4, 0x6f }\r
+\r
+//\r
+// Extended Sal Proc Function IDs.\r
+//\r
+\r
+//\r
+// BugBug: These enums are name colisions waiting to happen. They should all be\r
+//         prefixed with Esal! It might be better to just make them #define, so\r
+//         they would be all caps.\r
+//\r
+\r
+typedef enum {\r
+  IoRead,\r
+  IoWrite,\r
+  MemRead,\r
+  MemWrite\r
+} EFI_EXTENDED_SAL_BASE_IO_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  Stall\r
+} EFI_EXTENDED_SAL_STALL_FUNC_ID;\r
+\r
+\r
+typedef enum {\r
+  InitializeLockService,\r
+  AcquireLockService,\r
+  ReleaseLockService,\r
+  MaxLockServiceFunctionId\r
+} EFI_EXTENDED_SAL_LOCK_SERVICES_FUNC_ID;\r
+\r
+//\r
+// BugBug : Covert the first 3 functions into a lib functions\r
+// and move SalRegisterPhysicalAddress to SAL BASE Class\r
+//\r
+typedef enum {\r
+  SetVirtualAddress,\r
+  IsVirtual,\r
+  IsEfiRuntime,\r
+  SalRegisterPhysicalAddress\r
+} EFI_EXTENDED_SAL_VIRTUAL_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  GetTime,\r
+  SetTime,\r
+  GetWakeupTime,\r
+  SetWakeupTime,\r
+  GetRtcFreq,\r
+  InitializeThreshold,\r
+  BumpThresholdCount,\r
+  GetThresholdCount\r
+} EFI_EXTENDED_SAL_RTC_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  EsalGetVariable,\r
+  EsalGetNextVariableName,\r
+  EsalSetVariable\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  ,\r
+  EsalQueryVariableInfo\r
+#endif\r
+} EFI_EXTENDED_SAL_VARIABLE_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  GetNextHighMonotonicCount\r
+} EFI_EXTENDED_SAL_MTC_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  ResetSystem\r
+} EFI_EXTENDED_SAL_RESET_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  StatusCode\r
+} EFI_EXTENDED_SAL_STATUS_CODE_FUNC_ID;\r
+\r
+typedef enum {\r
+  ReportStatusCode\r
+} EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  Read,\r
+  Write,\r
+  EraseBlock,\r
+  GetVolumeAttributes,\r
+  SetVolumeAttributes,\r
+  GetPhysicalAddress,\r
+  GetBlockSize,\r
+  EraseCustomBlockRange,\r
+} EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  AddCpuData,\r
+  RemoveCpuData,\r
+  ModifyCpuData,\r
+  GetCpuDataByID,\r
+  GetCpuDataByIndex,\r
+  SendIpi,\r
+  CurrentProcInfo,\r
+  NumProcessors,\r
+  SetMinState,\r
+  GetMinState\r
+} EFI_EXTENDED_SAL_MP_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  PalProc,\r
+  SetNewPalEntry,\r
+  GetNewPalEntry\r
+} EFI_EXTENDED_SAL_PAL_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalSetVectors,\r
+  SalMcRendez,\r
+  SalMcSetParams,\r
+  EsalGetVectors,\r
+  EsalMcGetParams,\r
+  EsalMcGetMcParams,\r
+  EsalGetMcCheckinFlags,\r
+  EsalGetPlatformBaseFreq\r
+} EFI_EXTENDED_SAL_BASE_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  McaGetStateInfo,\r
+  McaRegisterCpu\r
+} EFI_EXTENDED_SAL_MCA_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalPciConfigRead,\r
+  SalPciConfigWrite\r
+} EFI_EXTENDED_SAL_PCI_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalCacheInit,\r
+  SalCacheFlush\r
+} EFI_EXTENDED_SAL_CACHE_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalGetStateInfo,\r
+  SalGetStateInfoSize,\r
+  SalClearStateInfo,\r
+  EsalGetStateBuffer,\r
+  EsalSaveStateBuffer\r
+} EFI_EXTENDED_SAL_MCA_LOG_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalSetEventLogData,\r
+  SalGetEventLogData,\r
+  SalEraseEventLogData,\r
+  SalActivateEventLogData\r
+} EFI_EXTENDED_SAL_ELOG_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  EsalGetComControllerInfo,\r
+  EsalSendComData,\r
+  EsalReceiveComData \r
+} EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  SalUpdatePal\r
+} EFI_EXTENDED_SAL_UPDATE_PAL_SERVICES_FUNC_ID;\r
+\r
+typedef enum {\r
+  EsalReadSensorInfo,   \r
+  EsalReadSensorStatus,\r
+  EsalRearmSensor,\r
+  EsalReadSensorData  \r
+} EFI_EXTENDED_SAL_SENSOR_SERVICES_FUNC_ID;\r
+\r
+typedef struct {\r
+  UINT64      ProtoData;       \r
+} ESAL_GUID_DUMMY_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalStallServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalLockServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalResetServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalMpServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalPalServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalPciServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalElogServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid;\r
+extern EFI_GUID gEfiExtendedSalSstGuid;\r
+\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c
new file mode 100644 (file)
index 0000000..da6120c
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FaultTolerantWriteLite.c\r
+\r
+Abstract:\r
+\r
+  This is a simple fault tolerant write driver, based on PlatformFd library.\r
+  And it only supports write BufferSize <= SpareAreaLength.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"                  \r
+#include EFI_PROTOCOL_DEFINITION(FaultTolerantWriteLite)\r
+\r
+EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid = EFI_FTW_LITE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiFaultTolerantWriteLiteProtocolGuid, "FaultTolerantWriteLite Protocol", \r
+                 "Fault Tolerant Write Lite protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h
new file mode 100644 (file)
index 0000000..bbddd38
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FaultTolerantWriteLite.h\r
+\r
+Abstract:\r
+\r
+  This is a simple fault tolerant write driver, based on PlatformFd library.\r
+  And it only supports write BufferSize <= SpareAreaLength.\r
+\r
+--*/\r
+\r
+#ifndef _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_\r
+#define _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_\r
+\r
+#define EFI_FTW_LITE_PROTOCOL_GUID \\r
+{ 0x3f557189, 0x8dae, 0x45ae, 0xa0, 0xb3, 0x2b, 0x99, 0xca, 0x7a, 0xa7, 0xa0 }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_FTW_LITE_PROTOCOL);\r
+\r
+//\r
+// Protocol API definitions\r
+//\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_FTW_LITE_WRITE) (\r
+  IN EFI_FTW_LITE_PROTOCOL             *This,\r
+  IN EFI_HANDLE                        FvbHandle,\r
+  IN EFI_LBA                           Lba,\r
+  IN UINTN                             Offset,\r
+  IN UINTN                             *NumBytes,\r
+  IN VOID                              *Buffer\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Starts a target block update. This records information about the write \r
+  in fault tolerant storage and will complete the write in a recoverable \r
+  manner, ensuring at all times that either the original contents or \r
+  the modified contents are available.\r
+\r
+Arguments:\r
+\r
+  This             - Calling context\r
+  FvBlockHandle    - The handle of FVB protocol that provides services for \r
+                     reading, writing, and erasing the target block.\r
+  Lba              - The logical block address of the target block.  \r
+  Offset           - The offset within the target block to place the data.\r
+  Length           - The number of bytes to write to the target block.\r
+  Buffer           - The data to write.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - The function completed successfully\r
+  EFI_ABORTED          - The function could not complete successfully.\r
+  EFI_BAD_BUFFER_SIZE  - The write would span a block boundary, \r
+                         which is not a valid action.\r
+  EFI_ACCESS_DENIED    - No writes have been allocated.\r
+  EFI_NOT_READY        - The last write has not been completed.  \r
+                         Restart () must be called to complete it.\r
+\r
+--*/\r
+\r
+//\r
+// Protocol declaration\r
+//\r
+typedef struct _EFI_FTW_LITE_PROTOCOL {\r
+  EFI_FTW_LITE_WRITE               Write;\r
+} EFI_FTW_LITE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c
new file mode 100644 (file)
index 0000000..0d1e304
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeDispatch.c\r
+\r
+Abstract:\r
+\r
+  Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+  Presence of this protocol tells the dispatch to dispatch from this Firmware \r
+  Volume\r
\r
+--*/\r
+\r
+#include "Tiano.h"                  \r
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch)\r
+\r
+EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid = EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (&gEfiFirmwareVolumeDispatchProtocolGuid, "FirmwareVolumeDispatch Protocol", \r
+                 "Firmware Volume Dispatch protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h
new file mode 100644 (file)
index 0000000..e23a941
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FirmwareVolumeDispatch.h\r
+\r
+Abstract:\r
+\r
+  Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume\r
+  specification.\r
+\r
+  Presence of this protocol tells the dispatch to dispatch from this Firmware \r
+  Volume\r
+\r
+--*/\r
+\r
+#ifndef __FIRMWARE_VOLUME_DISPATCH_H__\r
+#define __FIRMWARE_VOLUME_DISPATCH_H__\r
+\r
+#define EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID \\r
+  { 0x7aa35a69, 0x506c, 0x444f, 0xa7, 0xaf, 0x69, 0x4b, 0xf5, 0x6f, 0x71, 0xc8 }\r
+\r
+\r
+extern EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c
new file mode 100644 (file)
index 0000000..e9243af
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    FvbExtension.c\r
+\r
+Abstract:\r
+\r
+  IPMI Extension Protocol to extend the FVB functionality to multiple erase blocks\r
+  at different block offsets.\r
+\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(FvbExtension)\r
+\r
+EFI_GUID gEfiFvbExtensionProtocolGuid = EFI_FVB_EXTENSION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiFvbExtensionProtocolGuid, "FVB EXTENSION", "FVB EXTENSION");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h
new file mode 100644 (file)
index 0000000..4ebc857
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    FvbExtension.h\r
+\r
+Abstract:\r
+\r
+  FVB Extension protocol that extends the FVB Class in a component fashion.\r
+\r
+--*/\r
+\r
+#ifndef _FVB_EXTENSION_H_\r
+#define _FVB_EXTENSION_H_\r
+\r
+#define EFI_FVB_EXTENSION_PROTOCOL_GUID  \\r
+  {0x53a4c71b, 0xb581, 0x4170, 0x91, 0xb3, 0x8d, 0xb8, 0x7a, 0x4b, 0x5c, 0x46 }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_FVB_EXTENSION_PROTOCOL);\r
+\r
+//\r
+//  FVB Extension Function Prototypes\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_FV_ERASE_CUSTOM_BLOCK) (\r
+  IN EFI_FVB_EXTENSION_PROTOCOL   *This,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+);\r
+\r
+//\r
+// IPMI TRANSPORT PROTOCOL\r
+//\r
+typedef struct _EFI_FVB_EXTENSION_PROTOCOL {\r
+  EFI_FV_ERASE_CUSTOM_BLOCK               EraseFvbCustomBlock;\r
+ } EFI_FVB_EXTENSION_PROTOCOL;\r
+\r
+extern EFI_GUID                           gEfiFvbExtensionProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c
new file mode 100644 (file)
index 0000000..f9ad8f5
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenericMemoryTest.c\r
+\r
+Abstract:\r
+\r
+  The generic memory test protocol is used to test EFI memory.\r
+\r
+  For more information please look at EfiMemoryTest.doc\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (GenericMemoryTest)\r
+\r
+EFI_GUID  gEfiGenericMemTestProtocolGuid = EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiGenericMemTestProtocolGuid, "GenericMemoryTest Protocol", "Tiano Generic Memory Test Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h
new file mode 100644 (file)
index 0000000..c43615a
--- /dev/null
@@ -0,0 +1,154 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    GenericMemoryTest.h\r
+\r
+Abstract:\r
+\r
+    The EFI generic memory test protocol\r
+    For more information please look at EfiMemoryTest.doc\r
+\r
+--*/\r
+\r
+#ifndef __GENERIC_MEMORY_TEST_H__\r
+#define __GENERIC_MEMORY_TEST_H__\r
+\r
+#define EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID  \\r
+  { 0x309de7f1, 0x7f5e, 0x4ace, 0xb4, 0x9c, 0x53, 0x1b, 0xe5, 0xaa, 0x95, 0xef}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_GENERIC_MEMORY_TEST_PROTOCOL);\r
+\r
+typedef enum {\r
+  IGNORE,\r
+  QUICK,\r
+  SPARSE,\r
+  EXTENSIVE,\r
+  MAXLEVEL\r
+} EXTENDMEM_COVERAGE_LEVEL;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MEMORY_TEST_INIT) (\r
+  IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
+  IN  EXTENDMEM_COVERAGE_LEVEL                 Level,\r
+  OUT BOOLEAN                                  *RequireSoftECCInit\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Initialize the generic memory test.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Level                 - The coverage level of the memory test.\r
+    RequireSoftECCInit    - Indicate if the memory need software ECC init.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The generic memory test initialized correctly.\r
+    EFI_NO_MEDIA          - There is not any non-tested memory found, in this\r
+                            function if not any non-tesed memory found means \r
+                            that the memory test driver have not detect any\r
+                            non-tested extended memory of current system.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PERFORM_MEMORY_TEST) (\r
+  IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
+  OUT UINT64                                   *TestedMemorySize,\r
+  OUT UINT64                                   *TotalMemorySize,\r
+  OUT BOOLEAN                                  *ErrorOut,\r
+  IN BOOLEAN                                   IfTestAbort\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Perform the memory test.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    TestedMemorySize      - Return the tested extended memory size.\r
+    TotalMemorySize       - Return the whole system physical memory size, this \r
+                            value may be changed if in some case some error \r
+                            DIMMs be disabled.\r
+    ErrorOut              - Any time the memory error occurs, this will be TRUE.\r
+    IfTestAbort           - Indicate if the user press "ESC" to skip the memory\r
+                            test.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - One block of memory test ok, the block size is hide\r
+                            internally.\r
+    EFI_NOT_FOUND         - Indicate all the non-tested memory blocks have \r
+                            already go through.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MEMORY_TEST_FINISHED) (\r
+  IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    The memory test finished.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Successful free all the generic memory test driver\r
+                            allocated resource and notify to platform memory\r
+                            test driver that memory test finished.\r
+\r
+--*/\r
+;\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_MEMORY_TEST_COMPATIBLE_RANGE) (\r
+  IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                     StartAddress,\r
+  IN  UINT64                                   Length\r
+  )\r
+/*++\r
+  \r
+  Routine Description:\r
+    Provide capability to test compatible range which used by some sepcial\r
+    driver required using memory range before BDS perform memory test.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    StartAddress          - The start address of the memory range.\r
+    Length                - The memory range's length.\r
+    \r
+  Return:\r
+    EFI_SUCCESS           - The compatible memory range pass the memory test.\r
+    EFI_DEVICE_ERROR      - The compatible memory range test find memory error\r
+                            and also return return the error address.\r
+    \r
+--*/\r
+;\r
+\r
+typedef struct _EFI_GENERIC_MEMORY_TEST_PROTOCOL {\r
+  EFI_MEMORY_TEST_INIT              MemoryTestInit;\r
+  EFI_PERFORM_MEMORY_TEST           PerformMemoryTest;\r
+  EFI_MEMORY_TEST_FINISHED          Finished;\r
+  EFI_MEMORY_TEST_COMPATIBLE_RANGE  CompatibleRangeTest;\r
+} EFI_GENERIC_MEMORY_TEST_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiGenericMemTestProtocolGuid;\r
+#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 (file)
index 0000000..a3743fe
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidedSectionExtraction.c\r
+\r
+Abstract:\r
+\r
+  GUIDed section extraction protocol as defined in the Tiano File Image \r
+  Format specification.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
+\r
+//\r
+// may add more GUIDed section extraction protocol GUID here.\r
+//\r
+EFI_GUID  gEfiCrc32GuidedSectionExtractionProtocolGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (\r
+    &gEfiSectionExtractionProtocolGuid, "CRC32 GUIDed Section Extraction Protocol",\r
+      "Tiano CRC32 GUIDed Section Extraction Protocol"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h b/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h
new file mode 100644 (file)
index 0000000..9deb5c8
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidedSectionExtraction.h\r
+\r
+Abstract:\r
+\r
+  GUIDed section extraction protocol as defined in the Tiano File\r
+  Image Format specification.\r
+\r
+  This interface provides a means of decoding a GUID defined encapsulation \r
+  section. There may be multiple different GUIDs associated with the GUIDed\r
+  section extraction protocol. That is, all instances of the GUIDed section\r
+  extraction protocol must have the same interface structure.\r
+\r
+--*/\r
+\r
+#ifndef _GUIDED_SECTION_EXTRACTION_PROTOCOL_H\r
+#define _GUIDED_SECTION_EXTRACTION_PROTOCOL_H\r
+\r
+#include "EfiFirmwareFileSystem.h"\r
+\r
+//\r
+// Protocol GUID definition. Each GUIDed section extraction protocol has the\r
+// same interface but with different GUID. All the GUIDs is defined here.\r
+// May add multiple GUIDs here.\r
+//\r
+#define EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID \\r
+  { \\r
+    0xFC1BCDB0, 0x7D31, 0x49aa, 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL);\r
+\r
+//\r
+// Protocol member functions\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXTRACT_GUIDED_SECTION) (\r
+  IN  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL          * This,\r
+  IN  VOID                                            *InputSection,\r
+  OUT VOID                                            **OutputBuffer,\r
+  OUT UINTN                                           *OutputSize,\r
+  OUT UINT32                                          *AuthenticationStatus\r
+  );\r
+\r
+//\r
+// Protocol definition\r
+//\r
+typedef struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL {\r
+  EFI_EXTRACT_GUIDED_SECTION  ExtractSection;\r
+} EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL;\r
+\r
+//\r
+// may add other GUID here\r
+//\r
+extern EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c
new file mode 100644 (file)
index 0000000..aafd75c
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IsaAcpi.c\r
+    \r
+Abstract:\r
+\r
+    EFI ISA ACPI Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (IsaAcpi)\r
+\r
+EFI_GUID  gEfiIsaAcpiProtocolGuid = EFI_ISA_ACPI_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiIsaAcpiProtocolGuid, "ISA Acpi Protocol", "ISA Acpi Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h
new file mode 100644 (file)
index 0000000..e9c879b
--- /dev/null
@@ -0,0 +1,177 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IsaAcpi.h\r
+    \r
+Abstract:\r
+\r
+    EFI ISA Acpi Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _ISA_ACPI_H_\r
+#define _ISA_ACPI_H_\r
+\r
+#define EFI_ISA_ACPI_PROTOCOL_GUID \\r
+        {0x64a892dc, 0x5561, 0x4536, 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55}\r
+\r
+EFI_FORWARD_DECLARATION (EFI_ISA_ACPI);\r
+\r
+//\r
+// Resource Attribute definition\r
+//\r
+#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE   0x01\r
+#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE    0x02\r
+#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE  0x04\r
+#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE   0x08\r
+\r
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_MASK                 0x03\r
+\r
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_COMPATIBILITY        0x00\r
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_A                    0x01\r
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_B                    0x02\r
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_F                    0x03\r
+#define EFI_ISA_ACPI_DMA_COUNT_BY_BYTE                   0x04\r
+#define EFI_ISA_ACPI_DMA_COUNT_BY_WORD                   0x08\r
+#define EFI_ISA_ACPI_DMA_BUS_MASTER                      0x10\r
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT             0x20\r
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT  0x40\r
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_16_BIT            0x80\r
+\r
+#define EFI_ISA_ACPI_MEMORY_WIDTH_MASK                   0x03\r
+\r
+#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT                  0x00\r
+#define EFI_ISA_ACPI_MEMORY_WIDTH_16_BIT                 0x01\r
+#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT_AND_16_BIT       0x02\r
+#define EFI_ISA_ACPI_MEMORY_WRITEABLE                    0x04\r
+#define EFI_ISA_ACPI_MEMORY_CACHEABLE                    0x08\r
+#define EFI_ISA_ACPI_MEMORY_SHADOWABLE                   0x10\r
+#define EFI_ISA_ACPI_MEMORY_EXPANSION_ROM                0x20\r
+\r
+#define EFI_ISA_ACPI_IO_DECODE_10_BITS                   0x01\r
+#define EFI_ISA_ACPI_IO_DECODE_16_BITS                   0x02\r
+\r
+//\r
+// Resource List definition: \r
+// at first, the resource was defined as below\r
+// but in the future, it will be defined again that follow ACPI spec: ACPI resource type\r
+// so that, in this driver, we can interpret the ACPI table and get the ISA device information. \r
+//\r
\r
+typedef enum {\r
+  EfiIsaAcpiResourceEndOfList,\r
+  EfiIsaAcpiResourceIo,\r
+  EfiIsaAcpiResourceMemory,\r
+  EfiIsaAcpiResourceDma,\r
+  EfiIsaAcpiResourceInterrupt\r
+} EFI_ISA_ACPI_RESOURCE_TYPE;\r
+\r
+typedef struct {\r
+  EFI_ISA_ACPI_RESOURCE_TYPE  Type;\r
+  UINT32                      Attribute;\r
+  UINT32                      StartRange;\r
+  UINT32                      EndRange;\r
+} EFI_ISA_ACPI_RESOURCE;\r
+\r
+typedef struct {\r
+  UINT32                      HID;\r
+  UINT32                      UID;\r
+} EFI_ISA_ACPI_DEVICE_ID;\r
+\r
+typedef struct {\r
+  EFI_ISA_ACPI_DEVICE_ID      Device;\r
+  EFI_ISA_ACPI_RESOURCE       *ResourceItem;\r
+} EFI_ISA_ACPI_RESOURCE_LIST;\r
+\r
+//\r
+// Prototypes for the ISA ACPI Protocol\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_DEVICE_ENUMERATE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  OUT EFI_ISA_ACPI_DEVICE_ID         **Device\r
+  );\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_SET_DEVICE_POWER) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device,\r
+  IN BOOLEAN                         OnOff\r
+  );\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_GET_CUR_RESOURCE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device,\r
+  OUT EFI_ISA_ACPI_RESOURCE_LIST     **ResourceList\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_GET_POS_RESOURCE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device,\r
+  OUT EFI_ISA_ACPI_RESOURCE_LIST     **ResourceList\r
+  );\r
+  \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_SET_RESOURCE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device,\r
+  IN EFI_ISA_ACPI_RESOURCE_LIST      *ResourceList\r
+  );    \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_ENABLE_DEVICE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device,\r
+  IN BOOLEAN                         Enable\r
+  );    \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_INIT_DEVICE) (\r
+  IN EFI_ISA_ACPI            *This,\r
+  IN EFI_ISA_ACPI_DEVICE_ID          *Device\r
+  );  \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_ACPI_INTERFACE_INIT) (\r
+  IN EFI_ISA_ACPI            *This\r
+  );\r
+\r
+//\r
+// Interface structure for the ISA ACPI Protocol\r
+//\r
+typedef struct _EFI_ISA_ACPI {\r
+  EFI_ISA_ACPI_DEVICE_ENUMERATE     DeviceEnumerate;\r
+  EFI_ISA_ACPI_SET_DEVICE_POWER     SetPower;\r
+  EFI_ISA_ACPI_GET_CUR_RESOURCE     GetCurResource;\r
+  EFI_ISA_ACPI_GET_POS_RESOURCE     GetPosResource;\r
+  EFI_ISA_ACPI_SET_RESOURCE         SetResource;\r
+  EFI_ISA_ACPI_ENABLE_DEVICE        EnableDevice;\r
+  EFI_ISA_ACPI_INIT_DEVICE          InitDevice;\r
+  EFI_ISA_ACPI_INTERFACE_INIT       InterfaceInit;\r
+} EFI_ISA_ACPI_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiIsaAcpiProtocolGuid;\r
+  \r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c
new file mode 100644 (file)
index 0000000..3b868be
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    IsaIo.c\r
+    \r
+Abstract:\r
+\r
+    EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL \r
+    based on macro SIZE_REDUCTION_ISA_COMBINED.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (IsaIo)\r
+\r
+#ifndef SIZE_REDUCTION_ISA_COMBINED\r
+//\r
+// EFI_ISA_IO_PROTOCOL\r
+//\r
+EFI_GUID  gEfiIsaIoProtocolGuid = EFI_ISA_IO_PROTOCOL_GUID;\r
+EFI_GUID_STRING(&gEfiIsaIoProtocolGuid, "ISA IO Protocol", "ISA IO Protocol");\r
+\r
+#else\r
+//\r
+// EFI_LIGHT_ISA_IO_PROTOCOL\r
+//\r
+EFI_GUID  gEfiLightIsaIoProtocolGuid = EFI_LIGHT_ISA_IO_PROTOCOL_GUID;\r
+EFI_GUID_STRING(&gEfiLightIsaIoProtocolGuid, "Light ISA IO Protocol", "Light ISA IO Protocol");\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h
new file mode 100644 (file)
index 0000000..efedbee
--- /dev/null
@@ -0,0 +1,362 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    IsaIo.h\r
+    \r
+Abstract:\r
+\r
+    EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL \r
+    based on macro SIZE_REDUCTION_ISA_COMBINED.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_ISA_IO_H\r
+#define _EFI_ISA_IO_H\r
+\r
+//\r
+// Common definitions for Light ISA I/O Protocol and ISA I/O Protocol\r
+//\r
+\r
+#include EFI_PROTOCOL_DEFINITION(IsaAcpi)\r
+\r
+typedef enum {\r
+  EfiIsaIoWidthUint8,\r
+  EfiIsaIoWidthUint16,\r
+  EfiIsaIoWidthUint32,\r
+  EfiIsaIoWidthReserved,\r
+  EfiIsaIoWidthFifoUint8,\r
+  EfiIsaIoWidthFifoUint16,\r
+  EfiIsaIoWidthFifoUint32,\r
+  EfiIsaIoWidthFifoReserved,\r
+  EfiIsaIoWidthFillUint8,\r
+  EfiIsaIoWidthFillUint16,\r
+  EfiIsaIoWidthFillUint32,\r
+  EfiIsaIoWidthFillReserved,\r
+  EfiIsaIoWidthMaximum\r
+} EFI_ISA_IO_PROTOCOL_WIDTH;\r
+\r
+//\r
+// Attributes for common buffer allocations\r
+//\r
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE  0x080    // Map a memory range so write are combined\r
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED         0x800    // Map a memory range so all r/w accesses are cached\r
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_DISABLE        0x1000   // Disable a memory range \r
+\r
+//\r
+// Channel attribute for DMA operations\r
+//\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE  0x001\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A           0x002\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B           0x004\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C           0x008\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8           0x010\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16          0x020\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE       0x040\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE       0x080\r
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE   0x100\r
+\r
+typedef enum {\r
+  EfiIsaIoOperationBusMasterRead,\r
+  EfiIsaIoOperationBusMasterWrite,\r
+  EfiIsaIoOperationBusMasterCommonBuffer,\r
+  EfiIsaIoOperationSlaveRead,\r
+  EfiIsaIoOperationSlaveWrite,\r
+  EfiIsaIoOperationMaximum\r
+} EFI_ISA_IO_PROTOCOL_OPERATION;\r
+\r
+#ifndef SIZE_REDUCTION_ISA_COMBINED\r
+\r
+//\r
+// Specific for ISA I/O Protocol\r
+//\r
+\r
+#define EFI_INTERFACE_DEFINITION_FOR_ISA_IO EFI_ISA_IO_PROTOCOL\r
+#define EFI_ISA_IO_PROTOCOL_VERSION         &gEfiIsaIoProtocolGuid\r
+#define EFI_ISA_IO_OPERATION_TOKEN          EfiIsaIoOperationBusMasterWrite\r
+\r
+\r
+//\r
+// Global ID for the ISA I/O Protocol\r
+//\r
+\r
+#define EFI_ISA_IO_PROTOCOL_GUID \\r
+  { 0x7ee2bd44, 0x3da0, 0x11d4, 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_ISA_IO_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_IO_MEM) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This,\r
+  IN     EFI_ISA_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT32                       Offset,\r
+  IN     UINTN                        Count,\r
+  IN OUT VOID                         *Buffer\r
+  );\r
+\r
+typedef struct {\r
+  EFI_ISA_IO_PROTOCOL_IO_MEM  Read;\r
+  EFI_ISA_IO_PROTOCOL_IO_MEM  Write;\r
+} EFI_ISA_IO_PROTOCOL_ACCESS;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_COPY_MEM) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This,\r
+  IN     EFI_ISA_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT32                       DestOffset,\r
+  IN     UINT32                       SrcOffset,\r
+  IN     UINTN                        Count\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP) (\r
+  IN EFI_ISA_IO_PROTOCOL    *This,\r
+  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
+  IN     UINT8                          ChannelNumber      OPTIONAL,\r
+  IN     UINT32                         ChannelAttributes,\r
+  IN     VOID                           *HostAddress,\r
+  IN OUT UINTN                          *NumberOfBytes,\r
+  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
+  OUT    VOID                           **Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This,\r
+  IN  VOID                         *Mapping\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This,\r
+  IN  EFI_ALLOCATE_TYPE            Type,\r
+  IN  EFI_MEMORY_TYPE              MemoryType,\r
+  IN  UINTN                        Pages,\r
+  OUT VOID                         **HostAddress,\r
+  IN  UINT64                       Attributes\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_FREE_BUFFER) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This,\r
+  IN  UINTN                        Pages,\r
+  IN  VOID                         *HostAddress\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH) (\r
+  IN EFI_ISA_IO_PROTOCOL  *This\r
+  );\r
+\r
+//\r
+// Interface structure for the ISA I/O Protocol\r
+//\r
+typedef struct _EFI_ISA_IO_PROTOCOL {\r
+  EFI_ISA_IO_PROTOCOL_ACCESS           Mem;\r
+  EFI_ISA_IO_PROTOCOL_ACCESS           Io;\r
+  EFI_ISA_IO_PROTOCOL_COPY_MEM         CopyMem;\r
+  EFI_ISA_IO_PROTOCOL_MAP              Map;\r
+  EFI_ISA_IO_PROTOCOL_UNMAP            Unmap;\r
+  EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER  AllocateBuffer;\r
+  EFI_ISA_IO_PROTOCOL_FREE_BUFFER      FreeBuffer;\r
+  EFI_ISA_IO_PROTOCOL_FLUSH            Flush;\r
+  EFI_ISA_ACPI_RESOURCE_LIST           *ResourceList;\r
+  UINT32                               RomSize;\r
+  VOID                                 *RomImage;\r
+} EFI_ISA_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiIsaIoProtocolGuid;\r
+\r
+#else\r
+\r
+//\r
+// Specific for Light ISA I/O Protocol\r
+//\r
+\r
+#define EFI_INTERFACE_DEFINITION_FOR_ISA_IO EFI_LIGHT_ISA_IO_PROTOCOL\r
+#define EFI_ISA_IO_PROTOCOL_VERSION         &gEfiLightIsaIoProtocolGuid\r
+#define EFI_ISA_IO_OPERATION_TOKEN          EfiIsaIoOperationSlaveWrite  \r
+\r
+#define ADD_SERIAL_NAME(x, y)\r
+\r
+//\r
+// Global ID for the Light ISA I/O Protocol\r
+//\r
+\r
+#define EFI_LIGHT_ISA_IO_PROTOCOL_GUID \\r
+  { 0x7cc7ed80, 0x9a68, 0x4781, 0x80, 0xe4, 0xda, 0x16, 0x99, 0x10, 0x5a, 0xfe }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LIGHT_ISA_IO_PROTOCOL);\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM) (\r
+  IN     EFI_LIGHT_ISA_IO_PROTOCOL    *This,\r
+  IN     EFI_ISA_IO_PROTOCOL_WIDTH    Width,\r
+  IN     UINT32                       Offset,\r
+  IN     UINTN                        Count,\r
+  IN OUT VOID                         *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an ISA I/O Read/Write Cycle\r
+  EFI_LIGHT_ISA_IO_PROTOCOL doesn't verfiy access for I/O operation.\r
+\r
+Arguments:\r
+\r
+  This                  - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.\r
+  Width                 - Signifies the width of the I/O operation.\r
+  Offset                - The offset in ISA I/O space to start the I/O operation.  \r
+  Count                 - The number of I/O operations to perform. \r
+  Buffer                - The source/destination buffer\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data was read from or written to the device sucessfully.\r
+  EFI_UNSUPPORTED       - The Offset is not valid for this device.\r
+  EFI_INVALID_PARAMETER - Width or Count, or both, were invalid.\r
+  EFI_OUT_OF_RESOURCES  - The request could not be completed due to a lack of resources.\r
+\r
+--*/  \r
+;\r
+\r
+typedef struct {\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM  Read;\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM  Write;\r
+} EFI_LIGHT_ISA_IO_PROTOCOL_ACCESS;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_MAP) (\r
+  IN     EFI_LIGHT_ISA_IO_PROTOCOL      *This,\r
+  IN     EFI_ISA_IO_PROTOCOL_OPERATION  Operation,\r
+  IN     UINT8                          ChannelNumber      OPTIONAL,\r
+  IN     UINT32                         ChannelAttributes,\r
+  IN     VOID                           *HostAddress,\r
+  IN OUT UINTN                          *NumberOfBytes,\r
+  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
+  OUT    VOID                           **Mapping\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Maps a memory region for DMA, EFI_LIGHT_ISA_IO_PROTOCOL only supports \r
+  Slave read/write operation to save code size.\r
+\r
+Arguments:\r
+\r
+  This                  - A pointer to the EFI_LIGHT_ISA_IO_PROTOCOL instance.\r
+  Operation             - Indicates the type of DMA (slave or bus master), and if \r
+                          the DMA operation is going to read or write to system memory. \r
+  ChannelNumber         - The slave channel number to use for this DMA operation. \r
+                          If Operation and ChannelAttributes shows that this device \r
+                          performs bus mastering DMA, then this field is ignored.  \r
+                          The legal range for this field is 0..7.  \r
+  ChannelAttributes     - The attributes of the DMA channel to use for this DMA operation\r
+  HostAddress           - The system memory address to map to the device.  \r
+  NumberOfBytes         - On input the number of bytes to map.  On output the number \r
+                          of bytes that were mapped.\r
+  DeviceAddress         - The resulting map address for the bus master device to use \r
+                          to access the hosts HostAddress.  \r
+  Mapping               - A resulting value to pass to EFI_ISA_IO.Unmap().\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The range was mapped for the returned NumberOfBytes.\r
+  EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.\r
+  EFI_UNSUPPORTED       - The HostAddress can not be mapped as a common buffer.\r
+  EFI_DEVICE_ERROR      - The system hardware could not map the requested address.\r
+  EFI_OUT_OF_RESOURCES  - The memory pages could not be allocated.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_UNMAP) (\r
+  IN EFI_LIGHT_ISA_IO_PROTOCOL     *This,\r
+  IN  VOID                         *Mapping\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Unmaps a memory region for DMA\r
+\r
+Arguments:\r
+\r
+  This             - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.\r
+  Mapping          - The mapping value returned from EFI_ISA_IO.Map().\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      - The range was unmapped.\r
+  EFI_DEVICE_ERROR - The data was not committed to the target system memory.\r
+\r
+--*/  \r
+;      \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_FLUSH) (\r
+  IN EFI_LIGHT_ISA_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flushes a DMA buffer\r
+\r
+Arguments:\r
+\r
+  This             - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      - The buffers were flushed.\r
+  EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.\r
+\r
+--*/  \r
+;\r
+\r
+//\r
+// Interface structure for the Light ISA I/O Protocol\r
+//\r
+typedef struct _EFI_LIGHT_ISA_IO_PROTOCOL {\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_ACCESS     Io;\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_MAP        Map;\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_UNMAP      Unmap;\r
+  EFI_LIGHT_ISA_IO_PROTOCOL_FLUSH      Flush;\r
+  EFI_ISA_ACPI_RESOURCE_LIST           *ResourceList;\r
+  UINT32                               RomSize;\r
+  VOID                                 *RomImage;\r
+} EFI_LIGHT_ISA_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLightIsaIoProtocolGuid;\r
+\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c
new file mode 100644 (file)
index 0000000..a9d29dd
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LegacyBiosThunk.c\r
+    \r
+Abstract:\r
+\r
+  Legacy BIOS Thunk Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBiosThunk)\r
+\r
+EFI_GUID  gEfiLegacyBiosThunkProtocolGuid = EFI_LEGACY_BIOS_THUNK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLegacyBiosThunkProtocolGuid, "Legacy BIOS Thunk Protocol", "Legacy BIOS Thunk Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h
new file mode 100644 (file)
index 0000000..80ee5ab
--- /dev/null
@@ -0,0 +1,120 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  LegacyBiosThunk.h\r
+    \r
+Abstract:\r
+\r
+  The EFI Legacy BIOS Thunk Protocol is used to abstract Thunk16 call.\r
+\r
+  Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow \r
+  well known naming conventions.\r
+\r
+  Thunk - A thunk is a transition from one processor mode to another. A Thunk\r
+          is a transition from native EFI mode to 16-bit mode. A reverse thunk\r
+          would be a transition from 16-bit mode to native EFI mode.\r
+\r
+\r
+  Note: Note: Note: Note: Note: Note: Note:\r
+\r
+  You most likely should not use this protocol! Find the EFI way to solve the\r
+  problem to make your code portable\r
+\r
+  Note: Note: Note: Note: Note: Note: Note:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_LEGACY_BIOS_THUNK_H_\r
+#define _EFI_LEGACY_BIOS_THUNK_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)\r
+\r
+#define EFI_LEGACY_BIOS_THUNK_PROTOCOL_GUID \\r
+  { \\r
+    0x4c51a7ba, 0x7195, 0x442d, 0x87, 0x92, 0xbe, 0xea, 0x6e, 0x2f, 0xf6, 0xec \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_THUNK_PROTOCOL);\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_THUNK_INT86) (\r
+  IN EFI_LEGACY_BIOS_THUNK_PROTOCOL   * This,\r
+  IN  UINT8                           BiosInt,\r
+  IN OUT  EFI_IA32_REGISTER_SET       * Regs\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Thunk to 16-bit real mode and execute a software interrupt with a vector \r
+    of BiosInt. Regs will contain the 16-bit register context on entry and \r
+    exit.\r
+\r
+  Arguments:\r
+    This    - Protocol instance pointer.\r
+    BiosInt - Processor interrupt vector to invoke\r
+    Reg     - Register contexted passed into (and returned) from thunk to \r
+              16-bit mode\r
+\r
+  Returns:\r
+    FALSE   - Thunk completed, and there were no BIOS errors in the target code.\r
+              See Regs for status.\r
+    TRUE    - There was a BIOS erro in the target code.\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LEGACY_BIOS_THUNK_FARCALL86) (\r
+  IN EFI_LEGACY_BIOS_THUNK_PROTOCOL   * This,\r
+  IN  UINT16                          Segment,\r
+  IN  UINT16                          Offset,\r
+  IN  EFI_IA32_REGISTER_SET           * Regs,\r
+  IN  VOID                            *Stack,\r
+  IN  UINTN                           StackSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the \r
+    16-bit register context on entry and exit. Arguments can be passed on \r
+    the Stack argument\r
+\r
+  Arguments:\r
+    This      - Protocol instance pointer.\r
+    Segment   - Segemnt of 16-bit mode call\r
+    Offset    - Offset of 16-bit mdoe call\r
+    Reg       - Register contexted passed into (and returned) from thunk to \r
+                16-bit mode\r
+    Stack     - Caller allocated stack used to pass arguments\r
+    StackSize - Size of Stack in bytes\r
+\r
+  Returns:\r
+    FALSE     - Thunk completed, and there were no BIOS errors in the target code.\r
+                See Regs for status.\r
+    TRUE      - There was a BIOS erro in the target code.\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _EFI_LEGACY_BIOS_THUNK_PROTOCOL {\r
+  EFI_LEGACY_BIOS_THUNK_INT86                 Int86;\r
+  EFI_LEGACY_BIOS_THUNK_FARCALL86             FarCall86;\r
+} EFI_LEGACY_BIOS_THUNK_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLegacyBiosThunkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c
new file mode 100644 (file)
index 0000000..c113919
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    LoadPe32Image.c\r
+\r
+Abstract:\r
+\r
+    Load PE32 Image Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (LoadPe32Image)\r
+\r
+EFI_GUID  gEfiLoadPeImageGuid = PE32_IMAGE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiLoadPeImageGuid, "LoadPe32Image Protocol", "Tiano Load Pe32 Image Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h
new file mode 100644 (file)
index 0000000..07f8e4c
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    LoadPe32Image.h\r
+\r
+Abstract:\r
+\r
+    Load PE32 Image Protocol\r
+\r
+--*/\r
+\r
+#ifndef _LOAD_PE32_IMAGE_H_\r
+#define _LOAD_PE32_IMAGE_H_\r
+\r
+#define PE32_IMAGE_PROTOCOL_GUID  \\r
+  {0x5cb5c776,0x60d5,0x45ee,0x88,0x3c,0x45,0x27,0x8,0xcd,0x74,0x3f }\r
+\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE                                 0x00\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION                 0x01\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION  0x02\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PE32_IMAGE_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *LOAD_PE_IMAGE) (\r
+  IN EFI_PE32_IMAGE_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                       ParentImageHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL         *FilePath,\r
+  IN  VOID                             *SourceBuffer       OPTIONAL,\r
+  IN  UINTN                            SourceSize,\r
+  IN  EFI_PHYSICAL_ADDRESS             DstBuffer           OPTIONAL,\r
+  OUT UINTN                            *NumberOfPages      OPTIONAL,\r
+  OUT EFI_HANDLE                       *ImageHandle,\r
+  OUT EFI_PHYSICAL_ADDRESS             *EntryPoint         OPTIONAL,\r
+  IN  UINT32                           Attribute\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *UNLOAD_PE_IMAGE) (\r
+  IN EFI_PE32_IMAGE_PROTOCOL  *This,\r
+  IN EFI_HANDLE                       ImageHandle\r
+  );\r
+\r
+typedef struct _EFI_PE32_IMAGE_PROTOCOL {\r
+  LOAD_PE_IMAGE     LoadPeImage;\r
+  UNLOAD_PE_IMAGE  UnLoadPeImage;\r
+} EFI_PE32_IMAGE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiLoadPeImageGuid;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c
new file mode 100644 (file)
index 0000000..102bb14
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  NicIp4Config.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (NicIp4Config)\r
+\r
+EFI_GUID gEfiNicIp4ConfigProtocolGuid = EFI_NIC_IP4_CONFIG_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING (\r
+  &gEfiNicIp4ConfigProtocolGuid, \r
+  "NicIP4Config Protocol",  \r
+  "NicIP4Config Protocol"\r
+  );\r
+\r
+EFI_GUID gEfiNicIp4ConfigVariableGuid  = EFI_NIC_IP4_CONFIG_VARIABLE_GUID;\r
+\r
+EFI_GUID_STRING(\r
+  &gEfiNicIp4ConfigVariableGuid, \r
+  "Ip4 Static Config", \r
+  "Ip4 Configuration Data"\r
+  );\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h
new file mode 100644 (file)
index 0000000..76e4255
--- /dev/null
@@ -0,0 +1,118 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+  NicIp4Config.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _NIC_IP4_CONFIG_H_\r
+#define _NIC_IP4_CONFIG_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)\r
+\r
+#define EFI_NIC_IP4_CONFIG_PROTOCOL_GUID \\r
+  {0xdca3d4d, 0x12da, 0x4728, 0xbf, 0x7e, 0x86, 0xce, 0xb9, 0x28, 0xd0, 0x67}\r
+\r
+#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID  \\r
+  {0xd8944553, 0xc4dd, 0x41f4, 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b}\r
+\r
+#define EFI_NIC_IP4_CONFIG_VARIABLE          L"EfiNicIp4ConfigVariable"\r
+\r
+\r
+typedef struct _EFI_NIC_IP4_CONFIG_PROTOCOL EFI_NIC_IP4_CONFIG_PROTOCOL;\r
+\r
+typedef enum {\r
+  //\r
+  // Config source: dhcp or static\r
+  //\r
+  IP4_CONFIG_SOURCE_DHCP     = 0,\r
+  IP4_CONFIG_SOURCE_STATIC,\r
+  IP4_CONFIG_SOURCE_MAX,\r
+  \r
+  IP4_NIC_NAME_LENGTH        = 64,\r
+  MAX_IP4_CONFIG_IN_VARIABLE = 16,\r
+};\r
+\r
+//\r
+// The following structures are used by drivers/applications other\r
+// than EFI_IP4_PROTOCOL, such as ifconfig shell application, to \r
+// communicate the IP configuration information to EFI_IP4_CONFIG_PROTOCOL. \r
+// EFI_IP4_CONFIG_PROTOCOL in turn is used by EFI_IP4_PROTOCOL to get \r
+// the default IP4 configuration. ifconfig can't use the EFI_IP4_PROTOCOL\r
+// because it don't know how to configure the default IP address even\r
+// it has got the address. \r
+//\r
+// NIC_ADDR contains the interface's type and MAC address to identify\r
+// a specific NIC. NIC_IP4_CONFIG_INFO contains the IP4 configure \r
+// parameters for that NIC. IP4_CONFIG_VARIABLE is the EFI variable to \r
+// save the configuration. NIC_IP4_CONFIG_INFO and IP4_CONFIG_VARIABLE \r
+// is of variable length.\r
+//\r
+// EFI_NIC_IP4_CONFIG_PROTOCOL is a priority protocol, not defined by UEFI2.0\r
+//\r
+typedef struct {\r
+  UINT16                    Type;\r
+  UINT8                     Len;\r
+  EFI_MAC_ADDRESS           MacAddr;\r
+} NIC_ADDR;\r
+\r
+typedef struct {\r
+  NIC_ADDR                  NicAddr;    // Link layer address to identify the NIC\r
+  UINT32                    Source;     // Static or DHCP\r
+  BOOLEAN                   Perment;    // Survive the reboot or not\r
+  EFI_IP4_IPCONFIG_DATA     Ip4Info;    // IP addresses\r
+} NIC_IP4_CONFIG_INFO;\r
+\r
+typedef struct {\r
+  UINT32                    Len;        // Total length of the variable\r
+  UINT16                    CheckSum;   // CheckSum, the same as IP4 head checksum\r
+  UINT32                    Count;      // Number of NIC_IP4_CONFIG_INFO follows\r
+  NIC_IP4_CONFIG_INFO       ConfigInfo;\r
+} IP4_CONFIG_VARIABLE;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_NIC_IP4_CONFIG_GET_INFO) (\r
+  IN EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
+  IN OUT UINTN                    *Len,\r
+  OUT NIC_IP4_CONFIG_INFO         *NicConfig     OPTIONAL \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_NIC_IP4_CONFIG_SET_INFO) (\r
+  IN EFI_NIC_IP4_CONFIG_PROTOCOL  *This,\r
+  IN NIC_IP4_CONFIG_INFO          *NicConfig,    OPTIONAL\r
+  IN BOOLEAN                      ReConfig \r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_NIC_IP4_CONFIG_GET_NAME) (\r
+  IN  EFI_NIC_IP4_CONFIG_PROTOCOL *This,\r
+  IN  UINT16                      *Name,         OPTIONAL\r
+  IN  NIC_ADDR                    *NicAddr       OPTIONAL \r
+  );\r
+\r
+typedef \r
+struct _EFI_NIC_IP4_CONFIG_PROTOCOL {\r
+  EFI_NIC_IP4_CONFIG_GET_NAME     GetName;\r
+  EFI_NIC_IP4_CONFIG_GET_INFO     GetInfo;\r
+  EFI_NIC_IP4_CONFIG_SET_INFO     SetInfo;\r
+};\r
+\r
+extern EFI_GUID gEfiNicIp4ConfigVariableGuid;\r
+extern EFI_GUID gEfiNicIp4ConfigProtocolGuid;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c
new file mode 100644 (file)
index 0000000..53bb2f5
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciHotPlugRequest.c\r
+\r
+Abstract:\r
+\r
+  \r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (PciHotPlugRequest)\r
+\r
+EFI_GUID  gEfiPciHotPlugRequestProtocolGuid = EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPciHotPlugRequestProtocolGuid, "Pci Hot Plug Request Protocol", "Tiano Hot Plug Request Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h
new file mode 100644 (file)
index 0000000..7a73473
--- /dev/null
@@ -0,0 +1,55 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PciHotPlugRequest.h\r
+\r
+Abstract:\r
+\r
+  \r
\r
+--*/\r
+\r
+#ifndef _PCI_HOTPLUG_REQUEST_H_\r
+#define _PCI_HOTPLUG_REQUEST_H_\r
+\r
+#define EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID \\r
+{0x19cb87ab,0x2cb9,0x4665,0x83,0x60,0xdd,0xcf,0x60,0x54,0xf7,0x9d}\r
+\r
+typedef enum {\r
+  EfiPciHotPlugRequestAdd,\r
+  EfiPciHotplugRequestRemove\r
+} EFI_PCI_HOTPLUG_OPERATION;\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PCI_HOTPLUG_REQUEST_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_HOTPLUG_REQUEST_NOTIFY) (\r
+ IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL *This,\r
+ IN EFI_PCI_HOTPLUG_OPERATION        Operation,\r
+ IN EFI_HANDLE                       Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL         *RemainingDevicePath OPTIONAL,\r
+ IN OUT UINT8                        *NumberOfChildren,\r
+ IN OUT EFI_HANDLE                   *ChildHandleBuffer\r
+);\r
+\r
+\r
+\r
+typedef struct _EFI_PCI_HOTPLUG_REQUEST_PROTOCOL {\r
+  EFI_PCI_HOTPLUG_REQUEST_NOTIFY     Notify;\r
+} EFI_PCI_HOTPLUG_REQUEST_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiPciHotPlugRequestProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c
new file mode 100644 (file)
index 0000000..f9ecf1e
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    Performance.c\r
+\r
+Abstract:\r
+\r
+  DXE performance checking infrastructure\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (Performance)\r
+\r
+EFI_GUID  gEfiPerformanceProtocolGuid = EFI_PERFORMANCE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPerformanceProtocolGuid, "Performance Protocol", "Performance Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h
new file mode 100644 (file)
index 0000000..ab502ff
--- /dev/null
@@ -0,0 +1,103 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Performance.h\r
+\r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_PERFORMANCE_H_\r
+#define _EFI_PERFORMANCE_H_\r
+\r
+#define EFI_PERFORMANCE_PROTOCOL_GUID \\r
+  { 0xFFECFFFF, 0x923C, 0x14d2, 0x9E, 0x3F, 0x22, 0xA0, 0xC9, 0x69, 0x56, 0x3B }\r
+\r
+#define EFI_NULL_GUID \\r
+  { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PERFORMANCE_PROTOCOL);\r
+\r
+#define DXE_TOK L"DXE"\r
+#define SHELL_TOK L"SHELL"\r
+#define PEI_TOK L"PEI"\r
+#define BDS_TOK L"BDS"\r
+#define DRIVERBINDING_START_TOK L"DriverBinding:Start"\r
+#define DRIVERBINDING_SUPPORT_TOK L"DriverBinding:Support"\r
+#define START_IMAGE_TOK L"StartImage"\r
+#define LOAD_IMAGE_TOK L"LoadImage"\r
+\r
+#define DXE_PHASE 0\r
+#define SHELL_PHASE 1\r
+#define PEI_PHASE 2\r
+\r
+#define EFI_PERF_TOKEN_LENGTH        32\r
+#define EFI_PERF_HOST_LENGTH         32\r
+#define EFI_PERF_PDBFILENAME_LENGTH  28\r
+\r
+typedef struct {\r
+  EFI_HANDLE        Handle; \r
+  UINT16            Token[EFI_PERF_TOKEN_LENGTH];\r
+  UINT16            Host[EFI_PERF_HOST_LENGTH];\r
+  UINT64            StartTick;\r
+  UINT64            EndTick;\r
+  EFI_GUID          GuidName;\r
+  UINT8             PdbFileName[EFI_PERF_PDBFILENAME_LENGTH];\r
+  UINT8             Phase;\r
+} EFI_GAUGE_DATA ;\r
+\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI * EFI_PERF_START_GAUGE) (\r
+  IN EFI_PERFORMANCE_PROTOCOL *This,\r
+  IN EFI_HANDLE        Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI * EFI_PERF_END_GAUGE) (\r
+  IN EFI_PERFORMANCE_PROTOCOL *This,\r
+  IN EFI_HANDLE        Handle,\r
+  IN UINT16           *Token,\r
+  IN UINT16           *Host,\r
+  IN UINT64           Ticker\r
+  );\r
+\r
+\r
+typedef \r
+EFI_GAUGE_DATA *\r
+(EFIAPI * EFI_PERF_GET_GAUGE) (\r
+  IN EFI_PERFORMANCE_PROTOCOL *This,\r
+  IN EFI_HANDLE                       Handle,     \r
+  IN UINT16                           *Token,     \r
+  IN UINT16                           *Host,      \r
+  IN EFI_GAUGE_DATA                   *PrevGauge      \r
+  );\r
+\r
+\r
+typedef struct _EFI_PERFORMANCE_PROTOCOL{\r
+  EFI_PERF_START_GAUGE  StartGauge;\r
+  EFI_PERF_END_GAUGE    EndGauge;\r
+  EFI_PERF_GET_GAUGE    GetGauge;\r
+} EFI_PERFORMANCE_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPerformanceProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c
new file mode 100644 (file)
index 0000000..6e0f3e8
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformMemTest.c\r
+\r
+Abstract:\r
+\r
+  // TBD defined in the Tiano specification??\r
+\r
+  The Platform memory test protocol is used to provide platform specific\r
+  information and functionality for memory test\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (PlatformMemTest)\r
+\r
+EFI_GUID  gEfiPlatformMemTestGuid = EFI_PLATFORM_MEMTEST_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPlatformMemTestGuid, "Platform Memory Test Protocol", "Platform MemTest protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h
new file mode 100644 (file)
index 0000000..356563e
--- /dev/null
@@ -0,0 +1,258 @@
+\r
+ /*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PlatformMemtest.h\r
+\r
+Abstract:\r
+  This files defines the protocol produced by platform memory test driver.\r
+   \r
+--*/\r
+\r
+#ifndef __PLATFORM_MEMTEST_H__\r
+#define __PLATFORM_MEMTEST_H__\r
+\r
+\r
+#include EFI_PROTOCOL_CONSUMER (Hii)\r
+#include EFI_PROTOCOL_CONSUMER (GenericMemoryTest)\r
+\r
+\r
+#define EFI_PLATFORM_MEMTEST_PROTOCOL_GUID \\r
+  { 0x859ba18, 0x7dd7, 0x4ed7, 0xa8, 0x8e, 0x10, 0x9c, 0x63, 0x91, 0x7b, 0xdd }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_PLATFORM_MEMTEST_PROTOCOL);\r
+\r
+\r
+// \r
+// Basic type definitions\r
+//\r
+typedef UINT16  EFI_DIMM_ID;   \r
+#define EFI_INVALID_DIMM_ID 0xFFFF\r
+\r
+//\r
+// This describes the capabilities\r
+//\r
+typedef struct {\r
+  UINT32                HwCap;\r
+  EFI_PHYSICAL_ADDRESS  InitBlockSize;\r
+  EFI_PHYSICAL_ADDRESS  TestBlockSize;  \r
+} EFI_PLATFORM_MEMTEST_CAPABILITIES;\r
+\r
+//\r
+// This defines the platform driver phases to use in notify phase \r
+//\r
+typedef enum {\r
+  EfiMemtestPhaseBegin,\r
+  EfiMemtestPhaseEnd,\r
+  EfiMemtestPhaseMaximum  \r
+} EFI_MEMTEST_PHASE ;\r
+\r
+\r
+//\r
+// Definitions of Capability bits\r
+//\r
+#define EFI_MEMTEST_CAP_NONE          0X00000000 \r
+#define EFI_MEMTEST_CAP_ECC            0X00000001  \r
+#define EFI_MEMTEST_CAP_HW_TEST        0X00000002 \r
+#define EFI_MEMTEST_CAP_HW_INIT        0X00000004 \r
+\r
+//\r
+// This describes the pattern for testing all memory cells\r
+//\r
+typedef struct {\r
+  UINT32         Count;      // Number of patterns\r
+  UINT32         Width;      // Width of patterns\r
+  VOID          *Pattern;    // Array of patterns\r
+}EFI_MEMTEST_DATA_PATTERN;\r
+\r
+//\r
+// This describes the data and address line patterns\r
+//\r
+typedef struct {\r
+  UINT32                 Count;    // Number of patterns\r
+  EFI_PHYSICAL_ADDRESS  *Address;  // Array of addresses\r
+  EFI_PHYSICAL_ADDRESS  *Pattern;  // Array of patterns\r
+} EFI_MEMTEST_ADDRESS_PATTERN;\r
+\r
+\r
+#define   EFI_INVALID_DIMM_ID   0xFFFF\r
+\r
+//\r
+// DIMM information exported by the platform driver\r
+//\r
+\r
+typedef struct {  \r
+  EFI_DIMM_ID         DimmId; \r
+  STRING_REF           DimmReference;\r
+} EFI_MEMTEST_DIMM_INFO;\r
+\r
+\r
+//\r
+// Various types of errors\r
+//\r
+typedef enum {\r
+  EfiMemtestCorrectableError = 1,\r
+  EfiMemtestUncorrectableError,\r
+  EfiMemtestErrorMaximum,\r
+} EFI_DIMM_ERROR;\r
+\r
+//\r
+// Actions to be taken.  \r
+//\r
+typedef enum {\r
+  EfiMemtestActionReport = 1,\r
+  EfiMemtestActionDisableMem,\r
+  EfiMemtestActionMaximum,\r
+} EFI_MEMTEST_ERROR_ACTION;\r
+\r
+\r
+//\r
+// Structure indicating a policy entry.\r
+//\r
+\r
+typedef struct {\r
+  EFI_DIMM_ERROR            ErrorType;\r
+  UINT32                    Threshold;\r
+  EFI_MEMTEST_ERROR_ACTION  Action;\r
+} EFI_MEMTEST_POLICY_ENTRY;\r
+\r
+\r
+\r
+//\r
+// Error Information.\r
+//\r
+typedef struct {\r
+  EFI_DIMM_ERROR  Error;\r
+  EFI_DIMM_ID     DimmId;\r
+} EFI_PLATFORM_MEMTEST_ERROR;\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_MEMTEST_NOTIFY_PHASE) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL    *This,\r
+  IN EFI_MEMTEST_PHASE                        Phase\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL  *This,\r
+  OUT  EFI_PLATFORM_MEMTEST_CAPABILITIES      *Capabilities,\r
+  OUT  EFI_MEMTEST_ADDRESS_PATTERN            *AddressPattern,\r
+  OUT  EFI_MEMTEST_DATA_PATTERN               *DataPattern,\r
+  OUT  EFI_MEMTEST_DATA_PATTERN               *MemoryPattern,\r
+  OUT  UINT32                                 *EntryCount,\r
+  OUT  EFI_MEMTEST_POLICY_ENTRY               **PolicyGrid\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL         *This,\r
+  IN OUT EFI_MEMTEST_DIMM_INFO                    *DimmInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL    *This,\r
+  IN EFI_PHYSICAL_ADDRESS                     Start,\r
+  IN EFI_PHYSICAL_ADDRESS                     Size\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL  *This,\r
+  IN EXTENDMEM_COVERAGE_LEVEL               Level,\r
+  IN EFI_PHYSICAL_ADDRESS                   Start,\r
+  IN EFI_PHYSICAL_ADDRESS                   Size,\r
+  OUT UINTN                                 *ErrorCount,\r
+  OUT EFI_PLATFORM_MEMTEST_ERROR            **ErrorInfo\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_FLUSH_BUFFER) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL   *This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR)  (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL   *This,\r
+  OUT  UINT32                                *ErrorCount,\r
+  OUT EFI_PLATFORM_MEMTEST_ERROR             **ErrorInfo\r
+\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL  *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  FailingAddress,\r
+  IN  UINT8                                 Expected,\r
+  IN  UINT8                                 Found,\r
+  OUT  UINT32                               *ErrorInfoCount,\r
+  OUT EFI_PLATFORM_MEMTEST_ERROR            **ErrorInfoBuffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_CLEAR_ERROR) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL   *This\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_DISABLE_DIMM) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL   *This,\r
+  IN UINT16                                 *DimmCount,\r
+  IN EFI_DIMM_ID                            *DimmIds,\r
+  IN BOOLEAN                                 RebootRequired\r
+\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_PLATFORM_MEMTEST_OVERLAP) (\r
+  IN EFI_PLATFORM_MEMTEST_PROTOCOL   *This,\r
+  IN  EFI_DIMM_ID                           DimmId,  \r
+  IN  EFI_PHYSICAL_ADDRESS                  start,\r
+  IN  EFI_PHYSICAL_ADDRESS                  Size,\r
+  OUT BOOLEAN                               *Overlap\r
+  );\r
+\r
+typedef struct _EFI_PLATFORM_MEMTEST_PROTOCOL {\r
+  EFI_PLATFORM_MEMTEST_NOTIFY_PHASE       NotifyPhase;\r
+  EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO  GetPlatformInfo;\r
+  EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO GetNextDimmInfo;\r
+  EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY  InitializeMem;\r
+  EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST     HwTest;\r
+  EFI_PLATFORM_MEMTEST_FLUSH_BUFFER       FlushBuffer;\r
+  EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR    CheckError;\r
+  EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM    LocateBadDimm;\r
+  EFI_PLATFORM_MEMTEST_CLEAR_ERROR        ClearError;\r
+  EFI_PLATFORM_MEMTEST_DISABLE_DIMM       DisableDimm;\r
+  EFI_PLATFORM_MEMTEST_OVERLAP            Overlap;\r
+} EFI_PLATFORM_MEMTEST_PROTOCOL;\r
+\r
+\r
+\r
+extern EFI_GUID gEfiPlatformMemTestGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c
new file mode 100644 (file)
index 0000000..b9ff6f9
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.c\r
+\r
+Abstract:\r
+\r
+  This file defines the Print protocol interface to provide a unified\r
+  print function\r
\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (Print)\r
+\r
+EFI_GUID gEfiPrintProtocolGuid = EFI_PRINT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPrintProtocolGuid, "Print Protocol", "Print 1.0 protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h
new file mode 100644 (file)
index 0000000..eba79cd
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Print.h\r
+\r
+Abstract:\r
+\r
+  This file defines the Print protocol\r
+\r
+--*/\r
+\r
+#ifndef _PPRINT_H_\r
+#define _PPRINT_H_\r
+\r
+#define EFI_PRINT_PROTOCOL_GUID  \\r
+   { 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_PRINT_PROTOCOL);\r
+\r
+typedef struct _EFI_PRINT_PROTOCOL EFI_PRINT_PROTOCOL;\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *EFI_VSPRINT) (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+typedef struct _EFI_PRINT_PROTOCOL {\r
+  EFI_VSPRINT                                   VSPrint;\r
+} EFI_PRINT_PROTOCOL;\r
+\r
+\r
+extern EFI_GUID gEfiPrintProtocolGuid;\r
+\r
+#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 (file)
index 0000000..9884125
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Ps2Policy.c\r
+    \r
+Abstract:\r
+\r
+  Protocol used for PS/2 Policy definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (Ps2Policy)\r
+\r
+EFI_GUID  gEfiPs2PolicyProtocolGuid = EFI_PS2_POLICY_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPs2PolicyProtocolGuid, "PS2 Policy", "Policy for Configuring PS2");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h b/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h
new file mode 100644 (file)
index 0000000..4b27040
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Ps2Policy.h\r
+    \r
+Abstract:\r
+\r
+  Protocol used for PS/2 Policy definition.\r
+\r
+--*/\r
+\r
+#ifndef _PS2_POLICY_PROTOCOL_H_\r
+#define _PS2_POLICY_PROTOCOL_H_\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PS2_POLICY_PROTOCOL);\r
+\r
+#define EFI_PS2_POLICY_PROTOCOL_GUID \\r
+  { \\r
+    0x4df19259, 0xdc71, 0x4d46, 0xbe, 0xf1, 0x35, 0x7b, 0xb5, 0x78, 0xc4, 0x18 \\r
+  }\r
+\r
+#define EFI_KEYBOARD_CAPSLOCK   0x0004\r
+#define EFI_KEYBOARD_NUMLOCK    0x0002\r
+#define EFI_KEYBOARD_SCROLLLOCK 0x0001\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PS2_INIT_HARDWARE) (\r
+  IN  EFI_HANDLE              Handle\r
+  );\r
+\r
+typedef struct _EFI_PS2_POLICY_PROTOCOL {\r
+  UINT8                 KeyboardLight;\r
+  EFI_PS2_INIT_HARDWARE Ps2InitHardware;\r
+} EFI_PS2_POLICY_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiPs2PolicyProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c
new file mode 100644 (file)
index 0000000..7daeed7
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeDhcp4.c\r
+\r
+Abstract:\r
+  PxeDhcp4 GUID declaration\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PxeDhcp4)\r
+\r
+EFI_GUID  gEfiPxeDhcp4ProtocolGuid = EFI_PXE_DHCP4_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPxeDhcp4ProtocolGuid, "PXE DHCP4 Protocol", "PXE DHCPv4 Protocol");\r
+\r
+/* EOF - PxeDhcp4.c */\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h
new file mode 100644 (file)
index 0000000..50101d3
--- /dev/null
@@ -0,0 +1,350 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeDhcp4.h\r
+\r
+Abstract:\r
+  EFI PXE DHCPv4 protocol definition\r
+\r
+--*/\r
+\r
+#ifndef _PXEDHCP4_H_\r
+#define _PXEDHCP4_H_\r
+\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// PXE DHCPv4 GUID definition\r
+//\r
+\r
+#define EFI_PXE_DHCP4_PROTOCOL_GUID \\r
+  { 0x03c4e624, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x29, 0x3f, 0xc1, 0x4d }\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// Interface definition\r
+//\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_PROTOCOL);\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// Descriptions of the DHCP version 4 header and options can be found\r
+// in RFC-2131 and RFC-2132 at www.ietf.org\r
+//\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+\r
+  UINT8 op;\r
+#define BOOTP_REQUEST   1\r
+#define BOOTP_REPLY   2\r
+\r
+  UINT8 htype;\r
+\r
+  UINT8 hlen;\r
+\r
+  UINT8 hops;\r
+\r
+  UINT32 xid;\r
+\r
+  UINT16 secs;\r
+#define DHCP4_INITIAL_SECONDS 4\r
+\r
+  UINT16 flags;\r
+#define DHCP4_BROADCAST_FLAG  0x8000\r
+\r
+  UINT32 ciaddr;\r
+\r
+  UINT32 yiaddr;\r
+\r
+  UINT32 siaddr;\r
+\r
+  UINT32 giaddr;\r
+\r
+  UINT8 chaddr[16];\r
+\r
+  UINT8 sname[64];\r
+\r
+  UINT8 fname[128];\r
+\r
+//\r
+// This is the minimum option length as specified in RFC-2131.\r
+// The packet must be padded out this far with DHCP4_PAD.\r
+// DHCPv4 packets are usually 576 bytes in length.  This length\r
+// includes the IPv4 and UDPv4 headers but not the media header.\r
+// Note: Not all DHCP relay agents will forward DHCPv4 packets\r
+// if they are less than 384 bytes or exceed 576 bytes.  Even if\r
+// the underlying hardware can handle smaller and larger packets,\r
+// many older relay agents will not accept them.\r
+//\r
+  UINT32 magik;\r
+#define DHCP4_MAGIK_NUMBER  0x63825363\r
+\r
+  UINT8 options[308];\r
+\r
+} DHCP4_HEADER;\r
+#pragma pack()\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// DHCPv4 packet definition.  Room for 576 bytes including IP and\r
+// UDP header.\r
+//\r
+\r
+#define DHCP4_MAX_PACKET_SIZE     576\r
+#define DHCP4_UDP_HEADER_SIZE     8\r
+#define DHCP4_IP_HEADER_SIZE      20\r
+\r
+#pragma pack(1)\r
+typedef union _DHCP4_PACKET {\r
+  UINT32 _force_data_alignment;\r
+\r
+  UINT8 raw[1500];\r
+\r
+  DHCP4_HEADER dhcp4;\r
+} DHCP4_PACKET;\r
+#pragma pack()\r
+\r
+#define DHCP4_SERVER_PORT 67\r
+#define DHCP4_CLIENT_PORT 68\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// DHCPv4 and PXE option numbers.\r
+//\r
+\r
+#define DHCP4_PAD                             0\r
+#define DHCP4_END                             255\r
+#define DHCP4_SUBNET_MASK                     1\r
+#define DHCP4_TIME_OFFSET                     2\r
+#define DHCP4_ROUTER_LIST                     3\r
+#define DHCP4_TIME_SERVERS                    4\r
+#define DHCP4_NAME_SERVERS                    5\r
+#define DHCP4_DNS_SERVERS                     6\r
+#define DHCP4_LOG_SERVERS                     7\r
+#define DHCP4_COOKIE_SERVERS                  8\r
+#define DHCP4_LPR_SREVERS                     9\r
+#define DHCP4_IMPRESS_SERVERS                 10\r
+#define DHCP4_RESOURCE_LOCATION_SERVERS       11\r
+#define DHCP4_HOST_NAME                       12\r
+#define DHCP4_BOOT_FILE_SIZE                  13\r
+#define DHCP4_DUMP_FILE                       14\r
+#define DHCP4_DOMAIN_NAME                     15\r
+#define DHCP4_SWAP_SERVER                     16\r
+#define DHCP4_ROOT_PATH                       17\r
+#define DHCP4_EXTENSION_PATH                  18\r
+#define DHCP4_IP_FORWARDING                   19\r
+#define DHCP4_NON_LOCAL_SOURCE_ROUTE          20\r
+#define DHCP4_POLICY_FILTER                   21\r
+#define DHCP4_MAX_DATAGRAM_SIZE               22\r
+#define DHCP4_DEFAULT_TTL                     23\r
+#define DHCP4_MTU_AGING_TIMEOUT               24\r
+#define DHCP4_MTU_SIZES                       25\r
+#define DHCP4_MTU_TO_USE                      26\r
+#define DHCP4_ALL_SUBNETS_LOCAL               27\r
+#define DHCP4_BROADCAST_ADDRESS               28\r
+#define DHCP4_PERFORM_MASK_DISCOVERY          29\r
+#define DHCP4_RESPOND_TO_MASK_REQ             30\r
+#define DHCP4_PERFORM_ROUTER_DISCOVERY        31\r
+#define DHCP4_ROUTER_SOLICIT_ADDRESS          32\r
+#define DHCP4_STATIC_ROUTER_LIST              33\r
+#define DHCP4_USE_ARP_TRAILERS                34\r
+#define DHCP4_ARP_CACHE_TIMEOUT               35\r
+#define DHCP4_ETHERNET_ENCAPSULATION          36\r
+#define DHCP4_TCP_DEFAULT_TTL                 37\r
+#define DHCP4_TCP_KEEP_ALIVE_INT              38\r
+#define DHCP4_KEEP_ALIVE_GARBAGE              39\r
+#define DHCP4_NIS_DOMAIN_NAME                 40\r
+#define DHCP4_NIS_SERVERS                     41\r
+#define DHCP4_NTP_SERVERS                     42\r
+#define DHCP4_VENDOR_SPECIFIC                 43\r
+# define PXE_MTFTP_IP                         1\r
+# define PXE_MTFTP_CPORT                      2\r
+# define PXE_MTFTP_SPORT                      3\r
+# define PXE_MTFTP_TMOUT                      4\r
+# define PXE_MTFTP_DELAY                      5\r
+# define PXE_DISCOVERY_CONTROL                6\r
+#  define PXE_DISABLE_BROADCAST_DISCOVERY     0x01\r
+#  define PXE_DISABLE_MULTICAST_DISCOVERY     0x02\r
+#  define PXE_ACCEPT_ONLY_PXE_BOOT_SERVERS    0x04\r
+#  define PXE_DO_NOT_PROMPT                   0x08\r
+# define PXE_DISCOVERY_MCAST_ADDR             7\r
+# define PXE_BOOT_SERVERS                     8\r
+# define PXE_BOOT_MENU                        9\r
+# define PXE_BOOT_PROMPT                      10\r
+# define PXE_MCAST_ADDRS_ALLOC                11\r
+# define PXE_CREDENTIAL_TYPES                 12\r
+# define PXE_BOOT_ITEM                        71\r
+#define DHCP4_NBNS_SERVERS                    44\r
+#define DHCP4_NBDD_SERVERS                    45\r
+#define DHCP4_NETBIOS_NODE_TYPE               46\r
+#define DHCP4_NETBIOS_SCOPE                   47\r
+#define DHCP4_XWINDOW_SYSTEM_FONT_SERVERS     48\r
+#define DHCP4_XWINDOW_SYSTEM_DISPLAY_MANAGERS 49\r
+#define DHCP4_REQUESTED_IP_ADDRESS            50\r
+#define DHCP4_LEASE_TIME                      51\r
+#define DHCP4_OPTION_OVERLOAD                 52\r
+# define DHCP4_OVERLOAD_FNAME                 1\r
+# define DHCP4_OVERLOAD_SNAME                 2\r
+# define DHCP4_OVERLOAD_FNAME_AND_SNAME       3\r
+#define DHCP4_MESSAGE_TYPE                    53\r
+# define DHCP4_MESSAGE_TYPE_DISCOVER          1\r
+# define DHCP4_MESSAGE_TYPE_OFFER             2\r
+# define DHCP4_MESSAGE_TYPE_REQUEST           3\r
+# define DHCP4_MESSAGE_TYPE_DECLINE           4\r
+# define DHCP4_MESSAGE_TYPE_ACK               5\r
+# define DHCP4_MESSAGE_TYPE_NAK               6\r
+# define DHCP4_MESSAGE_TYPE_RELEASE           7\r
+# define DHCP4_MESSAGE_TYPE_INFORM            8\r
+#define DHCP4_SERVER_IDENTIFIER               54\r
+#define DHCP4_PARAMETER_REQUEST_LIST          55\r
+#define DHCP4_ERROR_MESSAGE                   56\r
+#define DHCP4_MAX_MESSAGE_SIZE                57\r
+# define DHCP4_DEFAULT_MAX_MESSAGE_SIZE       576\r
+#define DHCP4_RENEWAL_TIME                    58\r
+#define DHCP4_REBINDING_TIME                  59\r
+#define DHCP4_CLASS_IDENTIFIER                60\r
+#define DHCP4_CLIENT_IDENTIFIER               61\r
+#define DHCP4_NISPLUS_DOMAIN_NAME             64\r
+#define DHCP4_NISPLUS_SERVERS                 65\r
+#define DHCP4_TFTP_SERVER_NAME                66\r
+#define DHCP4_BOOTFILE                        67\r
+#define DHCP4_MOBILE_IP_HOME_AGENTS           68\r
+#define DHCP4_SMPT_SERVERS                    69\r
+#define DHCP4_POP3_SERVERS                    70\r
+#define DHCP4_NNTP_SERVERS                    71\r
+#define DHCP4_WWW_SERVERS                     72\r
+#define DHCP4_FINGER_SERVERS                  73\r
+#define DHCP4_IRC_SERVERS                     74\r
+#define DHCP4_STREET_TALK_SERVERS             75\r
+#define DHCP4_STREET_TALK_DIR_ASSIST_SERVERS  76\r
+#define DHCP4_NDS_SERVERS                     85\r
+#define DHCP4_NDS_TREE_NAME                   86\r
+#define DHCP4_NDS_CONTEXT                     87\r
+#define DHCP4_SYSTEM_ARCHITECTURE             93\r
+#define DHCP4_NETWORK_ARCHITECTURE            94\r
+#define DHCP4_PLATFORM_ID                     97\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+//\r
+// DHCP4 option format.\r
+//\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8 op;\r
+  UINT8 len;\r
+  UINT8 data[1];\r
+} DHCP4_OP;\r
+#pragma pack()\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+\r
+typedef struct {\r
+  DHCP4_PACKET Discover;\r
+  DHCP4_PACKET Offer;\r
+  DHCP4_PACKET Request;\r
+  DHCP4_PACKET AckNak;\r
+  BOOLEAN SetupCompleted;\r
+  BOOLEAN InitCompleted;\r
+  BOOLEAN SelectCompleted;\r
+  BOOLEAN IsBootp;\r
+  BOOLEAN IsAck;\r
+} EFI_PXE_DHCP4_DATA;\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_RUN) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  IN OPTIONAL UINTN         OpLen,\r
+  IN OPTIONAL VOID          *OpList\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_SETUP) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL          *This,\r
+  IN OPTIONAL EFI_PXE_DHCP4_DATA     * NewData\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_INIT) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  IN UINTN                  SecondsTimeout,\r
+  OUT UINTN                 *Offers,\r
+  OUT DHCP4_PACKET          **OfferList\r
+  );\r
+\r
+#define DHCP4_MIN_SECONDS   1\r
+#define DHCP4_MAX_SECONDS   60\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_SELECT) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  IN UINTN                  SecondsTimeout,\r
+  IN DHCP4_PACKET           * offer\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_RENEW) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  UINTN                     seconds_timeout\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_REBIND) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  UINTN                     seconds_timeout\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_RELEASE) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL * This\r
+  );\r
+\r
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
+\r
+#define EFI_PXE_DHCP4_PROTOCOL_REVISION    0x00010000\r
+\r
+typedef struct _EFI_PXE_DHCP4_PROTOCOL {\r
+  UINT64 Revision;\r
+  EFI_PXE_DHCP4_RUN Run;\r
+  EFI_PXE_DHCP4_SETUP Setup;\r
+  EFI_PXE_DHCP4_INIT Init;\r
+  EFI_PXE_DHCP4_SELECT Select;\r
+  EFI_PXE_DHCP4_RENEW Renew;\r
+  EFI_PXE_DHCP4_REBIND Rebind;\r
+  EFI_PXE_DHCP4_RELEASE Release;\r
+  EFI_PXE_DHCP4_DATA *Data;\r
+} EFI_PXE_DHCP4_PROTOCOL;\r
+\r
+//\r
+//\r
+//\r
+\r
+extern EFI_GUID gEfiPxeDhcp4ProtocolGuid;\r
+\r
+#endif /* _PXEDHCP4_H_ */\r
+/* EOF - PxeDhcp4.h */\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c
new file mode 100644 (file)
index 0000000..39101c7
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeDhcp4Callback.c\r
+\r
+Abstract:\r
+  PxeDhcp4Callback protocol GUID definition.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (PxeDhcp4CallBack)\r
+\r
+EFI_GUID  gEfiPxeDhcp4CallbackProtocolGuid = EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPxeDhcp4CallbackProtocolGuid, "PXE DHCP4 Callback Protocol", "PXE DHCP IPv4 Callback Protocol");\r
+\r
+/* EOF - PxeDhcp4Callback.c */\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h
new file mode 100644 (file)
index 0000000..9c1b07a
--- /dev/null
@@ -0,0 +1,86 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  PxeDhcp4Callback.h\r
+\r
+Abstract:\r
+  EFI PXE DHCP4 Callback protocol definition.\r
+\r
+--*/\r
+\r
+#ifndef _PXE_DHCP4CALLBACK_H\r
+#define _PXE_DHCP4CALLBACK_H\r
+\r
+#include "..\PxeDhcp4\PxeDhcp4.h"\r
+\r
+//\r
+// GUID definition\r
+//\r
+\r
+#define EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID \\r
+{ 0xc1544c01, 0x92a4, 0x4198, 0x8a, 0x84, 0x77, 0x85, 0x83, 0xc2, 0x36, 0x21 }\r
+\r
+\r
+//\r
+// Revision number\r
+//\r
+\r
+#define EFI_PXE_DHCP4_CALLBACK_INTERFACE_REVISION   0x00010000\r
+\r
+//\r
+// Interface definition\r
+//\r
+\r
+EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_CALLBACK_PROTOCOL);\r
+\r
+typedef enum {\r
+  EFI_PXE_DHCP4_FUNCTION_FIRST,\r
+  EFI_PXE_DHCP4_FUNCTION_INIT,\r
+  EFI_PXE_DHCP4_FUNCTION_SELECT,\r
+  EFI_PXE_DHCP4_FUNCTION_RENEW,\r
+  EFI_PXE_DHCP4_FUNCTION_REBIND,\r
+  EFI_PXE_DHCP4_FUNCTION_LAST\r
+} EFI_PXE_DHCP4_FUNCTION;\r
+\r
+typedef enum {\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_FIRST,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_ABORT,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_ABORT,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_ABORT,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_CONTINUE,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_CONTINUE,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_CONTINUE,\r
+  EFI_PXE_DHCP4_CALLBACK_STATUS_LAST\r
+} EFI_PXE_DHCP4_CALLBACK_STATUS;\r
+\r
+typedef\r
+EFI_PXE_DHCP4_CALLBACK_STATUS\r
+(EFIAPI *EFI_PXE_DHCP4_CALLBACK) (\r
+  IN EFI_PXE_DHCP4_PROTOCOL *This,\r
+  IN EFI_PXE_DHCP4_FUNCTION Function,\r
+  IN UINT32                 PacketLen,\r
+  IN DHCP4_PACKET           *Packet OPTIONAL\r
+  );\r
+\r
+typedef struct _EFI_PXE_DHCP4_CALLBACK_PROTOCOL {\r
+  UINT64                      Revision;\r
+  EFI_PXE_DHCP4_CALLBACK      Callback;\r
+} EFI_PXE_DHCP4_CALLBACK_PROTOCOL;\r
+\r
+//\r
+// GUID declaration\r
+//\r
+\r
+extern EFI_GUID gEfiPxeDhcp4CallbackProtocolGuid;\r
+\r
+#endif /* _PXE_DHCP4CALLBACK_H */\r
+/* EOF - PxeDhcp4Callback.h */\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c
new file mode 100644 (file)
index 0000000..2af838d
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TcgService.c\r
+\r
+Abstract:\r
+\r
+  TcgService Protocol GUID as defined in TCG_EFI_Protocol_1_20_Final\r
+\r
+  See http://trustedcomputinggroup.org for the latest specification\r
+\r
+--*/\r
+\r
+#include <Tiano.h>\r
+\r
+#include EFI_PROTOCOL_DEFINITION(TcgService)\r
+\r
+EFI_GUID gEfiTcgProtocolGuid = EFI_TCG_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTcgServiceProtocolGuid, "TcgService", "TCG Services Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h
new file mode 100644 (file)
index 0000000..0a8cf7d
--- /dev/null
@@ -0,0 +1,128 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TcgService.h\r
+\r
+Abstract:\r
+\r
+  TCG Service Protocol as defined in TCG_EFI_Protocol_1_20_Final\r
+\r
+  See http://trustedcomputinggroup.org for the latest specification\r
+\r
+--*/\r
+\r
+#ifndef _TCG_SERVICE_PROTOCOL_H_\r
+#define _TCG_SERVICE_PROTOCOL_H_\r
+\r
+#include <EfiTpm.h>\r
+\r
+#define EFI_TCG_PROTOCOL_GUID  \\r
+  {0xf541796d, 0xa62e, 0x4954, 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd}\r
+\r
+#define TSS_EVENT_DATA_MAX_SIZE   256\r
+\r
+EFI_FORWARD_DECLARATION (EFI_TCG_PROTOCOL);\r
+\r
+//\r
+// Set structure alignment to 1-byte\r
+//\r
+#pragma pack (push, 1)\r
+\r
+typedef struct {\r
+  UINT8  Major;\r
+  UINT8  Minor;\r
+  UINT8  RevMajor;\r
+  UINT8  RevMinor;\r
+} TCG_VERSION;\r
+\r
+typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY {\r
+  UINT8          Size;                // Size of this structure\r
+  TCG_VERSION    StructureVersion;    \r
+  TCG_VERSION    ProtocolSpecVersion;\r
+  UINT8          HashAlgorithmBitmap; // Hash algorithms  \r
+                                      // this protocol is capable of : 01=SHA-1\r
+  BOOLEAN        TPMPresentFlag;      // 00h = TPM not present\r
+  BOOLEAN        TPMDeactivatedFlag;  // 01h = TPM currently deactivated\r
+} TCG_EFI_BOOT_SERVICE_CAPABILITY;\r
+\r
+typedef UINT32   TCG_ALGORITHM_ID;\r
+\r
+//\r
+// Restore original structure alignment\r
+//\r
+#pragma pack (pop)\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_STATUS_CHECK) (\r
+  IN      EFI_TCG_PROTOCOL          *This,\r
+  OUT     TCG_EFI_BOOT_SERVICE_CAPABILITY\r
+                                    *ProtocolCapability,\r
+  OUT     UINT32                    *TCGFeatureFlags,\r
+  OUT     EFI_PHYSICAL_ADDRESS      *EventLogLocation,\r
+  OUT     EFI_PHYSICAL_ADDRESS      *EventLogLastEntry\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_HASH_ALL) (\r
+  IN      EFI_TCG_PROTOCOL          *This,\r
+  IN      UINT8                     *HashData,\r
+  IN      UINT64                    HashDataLen,\r
+  IN      TCG_ALGORITHM_ID          AlgorithmId,\r
+  IN OUT  UINT64                    *HashedDataLen,\r
+  IN OUT  UINT8                     **HashedDataResult\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_LOG_EVENT) (\r
+  IN      EFI_TCG_PROTOCOL          *This,\r
+  IN      TCG_PCR_EVENT             *TCGLogData,\r
+  IN OUT  UINT32                    *EventNumber,\r
+  IN      UINT32                    Flags\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM) (\r
+  IN      EFI_TCG_PROTOCOL          *This,\r
+  IN      UINT32                    TpmInputParamterBlockSize,\r
+  IN      UINT8                     *TpmInputParamterBlock,\r
+  IN      UINT32                    TpmOutputParameterBlockSize,\r
+  IN      UINT8                     *TpmOutputParameterBlock\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT) (\r
+  IN      EFI_TCG_PROTOCOL          *This,\r
+  IN      UINT8                     *HashData,\r
+  IN      UINT64                    HashDataLen,\r
+  IN      TCG_ALGORITHM_ID          AlgorithmId,\r
+  IN OUT  TCG_PCR_EVENT             *TCGLogData,\r
+  IN OUT  UINT32                    *EventNumber,\r
+     OUT  EFI_PHYSICAL_ADDRESS      *EventLogLastEntry\r
+  );\r
+\r
+typedef struct _EFI_TCG_PROTOCOL {\r
+  EFI_TCG_STATUS_CHECK              StatusCheck;\r
+  EFI_TCG_HASH_ALL                  HashAll;\r
+  EFI_TCG_LOG_EVENT                 LogEvent;\r
+  EFI_TCG_PASS_THROUGH_TO_TPM       PassThroughToTpm;\r
+  EFI_TCG_HASH_LOG_EXTEND_EVENT     HashLogExtendEvent;\r
+} EFI_TCG_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiTcgProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c
new file mode 100644 (file)
index 0000000..8575d07
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  Tcp.c\r
+\r
+Abstract:\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(Tcp)\r
+\r
+\r
+EFI_GUID gEfiTcpProtocolGuid = EFI_TCP_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTcpProtocolGuid, "Transmission Control Protocol", "EFI Transmission Control Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h
new file mode 100644 (file)
index 0000000..f1b79fa
--- /dev/null
@@ -0,0 +1,110 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    tcp.h\r
+\r
+Abstract:\r
+\r
+    EFI Transmission Control Protocol\r
+\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+#ifndef _EFITCP_H\r
+#define _EFITCP_H\r
+\r
+\r
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCode)\r
+\r
+//\r
+// PXE Base Code protocol\r
+//\r
+\r
+#define EFI_TCP_PROTOCOL_GUID \\r
+    { 0x02b3d5f2, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_TCP_PROTOCOL);\r
+\r
+\r
+typedef UINT16 EFI_PXE_BASE_CODE_TCP_PORT;\r
+\r
+//\r
+// Port Receive Filter definitions\r
+//\r
+#define EFI_PXE_BASE_CODE_MAX_PORTCNT             8\r
+typedef struct {\r
+    UINT8                       Filters;\r
+    UINT8                       IpCnt;\r
+    UINT16                      reserved;\r
+    EFI_IP_ADDRESS              IpList[EFI_PXE_BASE_CODE_MAX_PORTCNT];\r
+} EFI_TCP_PORT_FILTER;\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP_WRITE) (\r
+    IN EFI_PXE_BASE_CODE_PROTOCOL        *This,\r
+    IN UINT16                                    OpFlags,\r
+    IN UINT16                                    *UrgentPointer,\r
+    IN UINT32                                    *SequenceNumber,\r
+    IN UINT32                                    *AckNumber,\r
+    IN UINT16                                    *HlenResCode,\r
+    IN UINT16                                    *Window,\r
+    IN EFI_IP_ADDRESS                            *DestIp,\r
+    IN UINT16                                    *DestPort,\r
+    IN EFI_IP_ADDRESS                            *GatewayIp,  OPTIONAL\r
+    IN EFI_IP_ADDRESS                            *SrcIp,      OPTIONAL\r
+    IN UINT16                                    *SrcPort,    OPTIONAL\r
+    IN UINTN                                     *HeaderSize, OPTIONAL\r
+    IN VOID                                      *HeaderPtr,  OPTIONAL\r
+    IN UINTN                                     *BufferSize,\r
+    IN VOID                                      *BufferPtr\r
+    );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP_READ) (\r
+    IN EFI_PXE_BASE_CODE_PROTOCOL        *This,\r
+    IN UINT16                                    OpFlags,\r
+    IN OUT EFI_IP_ADDRESS                        *DestIp,      OPTIONAL\r
+    IN OUT UINT16                                *DestPort,    OPTIONAL\r
+    IN OUT EFI_IP_ADDRESS                        *SrcIp,       OPTIONAL\r
+    IN OUT UINT16                                *SrcPort,     OPTIONAL\r
+    IN UINTN                                     *HeaderSize,  OPTIONAL\r
+    IN VOID                                      *HeaderPtr,   OPTIONAL\r
+    IN OUT UINTN                                 *BufferSize,\r
+    IN VOID                                      *BufferPtr\r
+    );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCP_SET_PORT_FILTER) (\r
+    IN EFI_PXE_BASE_CODE_PROTOCOL    *This,\r
+    IN EFI_TCP_PORT_FILTER                   *NewFilter\r
+    );\r
+\r
+//\r
+// TCP Protocol structure\r
+//\r
+typedef struct _EFI_TCP_PROTOCOL {\r
+    EFI_TCP_WRITE             TcpWrite;\r
+    EFI_TCP_READ              TcpRead;\r
+    EFI_TCP_SET_PORT_FILTER   SetPortFilter;\r
+} EFI_TCP_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiTcpProtocolGuid;\r
+\r
+#endif /* _EFITCP_H */\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c
new file mode 100644 (file)
index 0000000..bdee96d
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    TianoDecompress.c\r
+    \r
+Abstract:\r
+\r
+  The GUID for the Tiano Decompress Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION(TianoDecompress)\r
+\r
+EFI_GUID gEfiTianoDecompressProtocolGuid = EFI_TIANO_DECOMPRESS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTianoDecompressProtocolGuid, "Tiano Decompress", "Tiano Decompression Protocol");\r
+\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h
new file mode 100644 (file)
index 0000000..7ca8532
--- /dev/null
@@ -0,0 +1,139 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoDecompress.h\r
+    \r
+Abstract:\r
+\r
+  The Tiano Decompress Protocol Interface\r
+\r
+--*/\r
+\r
+#ifndef _TIANO_DECOMPRESS_H_\r
+#define _TIANO_DECOMPRESS_H_\r
+\r
+#define EFI_TIANO_DECOMPRESS_PROTOCOL_GUID  \\r
+  { 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_TIANO_DECOMPRESS_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TIANO_DECOMPRESS_GET_INFO) (\r
+  IN EFI_TIANO_DECOMPRESS_PROTOCOL  *This,\r
+  IN   VOID                                   *Source,\r
+  IN   UINT32                                 SourceSize,\r
+  OUT  UINT32                                 *DestinationSize,\r
+  OUT  UINT32                                 *ScratchSize\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The GetInfo() function retrieves the size of the uncompressed buffer \r
+  and the temporary scratch buffer required to decompress the buffer \r
+  specified by Source and SourceSize.  If the size of the uncompressed\r
+  buffer or the size of the scratch buffer cannot be determined from \r
+  the compressed data specified by Source and SourceData, then \r
+  EFI_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
+  buffer is returned in DestinationSize, the size of the scratch buffer is \r
+  returned in ScratchSize, and EFI_SUCCESS is returned.\r
+  \r
+  The GetInfo() function does not have scratch buffer available to perform \r
+  a thorough checking of the validity of the source data. It just retrieves\r
+  the 'Original Size' field from the beginning bytes of the source data and\r
+  output it as DestinationSize.  And ScratchSize is specific to the decompression\r
+  implementation.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size, in bytes, of source buffer.\r
+  DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer\r
+                    that will be generated when the compressed buffer specified \r
+                    by Source and SourceSize is decompressed.\r
+  ScratchSize     - A pointer to the size, in bytes, of the scratch buffer that \r
+                    is required to decompress the compressed buffer specified by\r
+                    Source and SourceSize.\r
+\r
+Returns:\r
+  EFI_SUCCESS     - The size of the uncompressed data was returned in DestinationSize\r
+                    and the size of the scratch buffer was returned in ScratchSize.\r
+  EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch\r
+                  buffer cannot be determined from the compressed data specified by \r
+                  Source and SourceData.\r
+\r
+--*/\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TIANO_DECOMPRESS_DECOMPRESS) (\r
+  IN EFI_TIANO_DECOMPRESS_PROTOCOL  *This,\r
+  IN     VOID*                                  Source,\r
+  IN     UINT32                                 SourceSize,\r
+  IN OUT VOID*                                  Destination,\r
+  IN     UINT32                                 DestinationSize,\r
+  IN OUT VOID*                                  Scratch,\r
+  IN     UINT32                                 ScratchSize\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Decompress() function extracts decompressed data to its original form.\r
+  \r
+  This protocol is designed so that the decompression algorithm can be \r
+  implemented without using any memory services.  As a result, the \r
+  Decompress() function is not allowed to call AllocatePool() or \r
+  AllocatePages() in its implementation.  It is the caller's responsibility \r
+  to allocate and free the Destination and Scratch buffers.\r
+  \r
+  If the compressed source data specified by Source and SourceSize is \r
+  sucessfully decompressed into Destination, then EFI_SUCCESS is returned.  \r
+  If the compressed source data specified by Source and SourceSize is not in \r
+  a valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
+\r
+Arguments:\r
+\r
+  This            - The protocol instance pointer\r
+  Source          - The source buffer containing the compressed data.\r
+  SourceSize      - The size of source data.\r
+  Destination     - On output, the destination buffer that contains \r
+                    the uncompressed data.\r
+  DestinationSize - The size of destination buffer. The size of destination\r
+                    buffer needed is obtained from GetInfo().\r
+  Scratch         - A temporary scratch buffer that is used to perform the \r
+                    decompression.\r
+  ScratchSize     - The size of scratch buffer. The size of scratch buffer needed\r
+                    is obtained from GetInfo().\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Decompression completed successfully, and the uncompressed \r
+                    buffer is returned in Destination.\r
+  EFI_INVALID_PARAMETER \r
+                  - The source buffer specified by Source and SourceSize is \r
+                    corrupted (not in a valid compressed format).\r
+\r
+--*/\r
+\r
+typedef struct _EFI_TIANO_DECOMPRESS_PROTOCOL {\r
+  EFI_TIANO_DECOMPRESS_GET_INFO    GetInfo;\r
+  EFI_TIANO_DECOMPRESS_DECOMPRESS  Decompress;\r
+} EFI_TIANO_DECOMPRESS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiTianoDecompressProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c
new file mode 100644 (file)
index 0000000..ca6ef68
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    UgaSplash.c\r
+\r
+Abstract:\r
+\r
+  UGA Splash protocol.\r
+\r
+  Abstraction of a very simple graphics device splash screen.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (UgaSplash)\r
+\r
+EFI_GUID  gEfiUgaSplashProtocolGuid = EFI_UGA_SPLASH_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUgaSplashProtocolGuid, "UGA Splash Protocol", "UGA Splash Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h
new file mode 100644 (file)
index 0000000..91f17a8
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    UgaSplash.h\r
+\r
+Abstract:\r
+\r
+  UGA Splash screen protocol.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+--*/\r
+\r
+#ifndef __UGA_SPLASH_H__\r
+#define __UGA_SPLASH_H__\r
+\r
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)\r
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
+\r
+\r
+#define EFI_UGA_SPLASH_PROTOCOL_GUID \\r
+  { 0xa45b3a0d, 0x2e55, 0x4c03, 0xad, 0x9c, 0x27, 0xd4, 0x82, 0xb, 0x50, 0x7e }\r
+\r
+typedef struct _EFI_UGA_SPLASH_PROTOCOL   EFI_UGA_SPLASH_PROTOCOL;\r
+\r
+\r
+typedef struct _EFI_UGA_SPLASH_PROTOCOL {\r
+  UINT32                        PixelWidth;\r
+  UINT32                        PixelHeight;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Image;\r
+} EFI_UGA_SPLASH_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUgaSplashProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c
new file mode 100644 (file)
index 0000000..2a0d0c1
--- /dev/null
@@ -0,0 +1,31 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    UsbAtapi.c\r
+    \r
+Abstract:\r
+\r
+    EFI USB Atapi Protocol\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (UsbIo)\r
+#include EFI_PROTOCOL_DEFINITION (UsbAtapi)\r
+\r
+EFI_GUID  gEfiUsbAtapiProtocolGuid = EFI_USB_ATAPI_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiUsbAtapiProtocolGuid, "Usb Atapi Protocol", "Usb Atapi Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h
new file mode 100644 (file)
index 0000000..3fdc76e
--- /dev/null
@@ -0,0 +1,83 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    UsbAtapi.h\r
+    \r
+Abstract:\r
+\r
+    EFI Atapi Protocol definition.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_USB_ATAPI_H\r
+#define _EFI_USB_ATAPI_H\r
+\r
+//\r
+// Transfer protocol types\r
+//\r
+#define BOT    0x50\r
+#define CBI0  0x00\r
+#define CBI1  0x01\r
+\r
+//\r
+// SubClass Code (defines command set)\r
+//\r
+#define EFI_USB_SUBCLASS_RBC            0x01\r
+#define EFI_USB_SUBCLASS_ATAPI          0x02\r
+#define EFI_USB_SUBCLASS_QIC_157        0x03\r
+#define EFI_USB_SUBCLASS_UFI            0x04\r
+#define EFI_USB_SUBCLASS_SFF_8070i      0x05\r
+#define EFI_USB_SUBCLASS_SCSI           0x06\r
+#define EFI_USB_SUBCLASS_RESERVED_LOW   0x07\r
+#define EFI_USB_SUBCLASS_RESERVED_HIGH  0xff\r
+//\r
+// Global GUID for transfer protocol interface\r
+//\r
+#define EFI_USB_ATAPI_PROTOCOL_GUID \\r
+    { 0x2B2F68DA, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_USB_ATAPI_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_ATAPI_PACKET_CMD) (\r
+  IN EFI_USB_ATAPI_PROTOCOL  *This,\r
+  IN  VOID                            *Command,\r
+  IN  UINT8                            CommandSize,\r
+  IN  VOID                            *DataBuffer,\r
+  IN  UINT32                          BufferLength,\r
+  IN  EFI_USB_DATA_DIRECTION          Direction,\r
+  IN  UINT16                          TimeOutInMilliSeconds\r
+);    \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_USB_MASS_STORAGE_RESET) (\r
+  IN EFI_USB_ATAPI_PROTOCOL  *This,\r
+  IN  BOOLEAN                         ExtendedVerification\r
+);\r
+\r
+//\r
+//  Protocol Interface Structure\r
+//\r
+typedef struct _EFI_USB_ATAPI_PROTOCOL {\r
+  EFI_USB_ATAPI_PACKET_CMD        UsbAtapiPacketCmd;\r
+  EFI_USB_MASS_STORAGE_RESET      UsbAtapiReset;\r
+  UINT32                          CommandProtocol;\r
+} EFI_USB_ATAPI_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUsbAtapiProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c
new file mode 100644 (file)
index 0000000..2fe8493
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  VariableStore.c\r
+\r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+//\r
+// The variable store protocol interface is specific to the reference\r
+// implementation. The initialization code adds variable store devices\r
+// to the system, and the FW connects to the devices to provide the\r
+// variable store interfaces through these devices.\r
+//\r
+//\r
+// Variable Store Device protocol\r
+//\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (VariableStore)\r
+\r
+EFI_GUID  gEfiVariableStoreProtocolGuid = EFI_VARIABLE_STORE_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiVariableStoreProtocolGuid, "Variable Storage Protocol", "Tiano Variable Storage Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h
new file mode 100644 (file)
index 0000000..5ab888b
--- /dev/null
@@ -0,0 +1,105 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  VariableStore.h\r
+\r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _VARIABLE_STORE_H\r
+#define _VARIABLE_STORE_H\r
+\r
+//\r
+// The variable store protocol interface is specific to the reference\r
+// implementation. The initialization code adds variable store devices\r
+// to the system, and the FW connects to the devices to provide the\r
+// variable store interfaces through these devices.\r
+//\r
+\r
+//\r
+// Variable Store Device protocol\r
+//\r
+#define EFI_VARIABLE_STORE_PROTOCOL_GUID    \\r
+  { 0xf088cd91, 0xa046, 0x11d2, 0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_VARIABLE_STORE_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLEAR_STORE) (\r
+  IN EFI_VARIABLE_STORE_PROTOCOL   *This,\r
+  IN OUT VOID                              *Scratch\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_READ_STORE) (\r
+  IN EFI_VARIABLE_STORE_PROTOCOL   *This,\r
+  IN UINTN                                 Offset,\r
+  IN UINTN                                 BufferSize,\r
+  OUT VOID                                 *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UPDATE_STORE) (\r
+  IN EFI_VARIABLE_STORE_PROTOCOL   *This,\r
+  IN UINTN                                 Offset,\r
+  IN UINTN                                 BufferSize,\r
+  IN VOID                                  *Buffer\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_CLEANUP_STORE) (\r
+  IN EFI_VARIABLE_STORE_PROTOCOL   *This\r
+  );\r
+\r
+typedef struct _EFI_VARIABLE_STORE_PROTOCOL {\r
+  \r
+  //\r
+  // Number of banks and bank size\r
+  //\r
+  UINT32                      Attributes;\r
+  UINT32                      BankSize;\r
+\r
+  //\r
+  // Functions to access the storage banks\r
+  //\r
+  EFI_CLEAR_STORE             ClearStore;\r
+  EFI_READ_STORE              ReadStore;\r
+  EFI_UPDATE_STORE            UpdateStore;\r
+  EFI_CLEANUP_STORE           CleanupStore;\r
+\r
+} EFI_VARIABLE_STORE_PROTOCOL;\r
+\r
+//\r
+//\r
+//  ClearStore()        - A function to clear the requested storage bank.  A cleared\r
+//                        bank contains all "on" bits.\r
+//\r
+//  ReadStore()         - Read data from the requested store.\r
+//\r
+//  UpdateStore()       - Updates data on the requested store. The FW will only\r
+//                        ever issue updates to clear bits in the store. Updates must \r
+//                        be performed in LSb to MSb order of the update buffer.\r
+//\r
+//  CleanupStore()      - Do garbage collection and reclaim operation.\r
+//\r
+\r
+extern EFI_GUID gEfiVariableStoreProtocolGuid;\r
+\r
+#endif // _VARIABLE_STORE_H\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c
new file mode 100644 (file)
index 0000000..edc3989
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    VgaMiniPort.c\r
+    \r
+Abstract:\r
+\r
+    EFI VGA Mini Port Protocol\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (VgaMiniPort)\r
+\r
+EFI_GUID  gEfiVgaMiniPortProtocolGuid = EFI_VGA_MINI_PORT_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiVgaMiniPortProtocolGuid, "VGA Mini Port Protocol", "EFI VGA Mini Port Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h
new file mode 100644 (file)
index 0000000..40304ab
--- /dev/null
@@ -0,0 +1,70 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    VgaMiniPort.h\r
+    \r
+Abstract:\r
+\r
+    Vga Mini port binding for a VGA controller\r
+\r
+--*/\r
+\r
+#ifndef _VGA_MINI_PORT_H\r
+#define _VGA_MINI_PORT_H\r
+\r
+#define EFI_VGA_MINI_PORT_PROTOCOL_GUID \\r
+  { \\r
+    0xc7735a2f, 0x88f5, 0x4882, 0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 \\r
+  }\r
+\r
+EFI_FORWARD_DECLARATION (EFI_VGA_MINI_PORT_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_VGA_MINI_PORT_SET_MODE) (\r
+  IN EFI_VGA_MINI_PORT_PROTOCOL          * This,\r
+  IN UINTN                               ModeNumber\r
+  );\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Sets the text display mode of a VGA controller\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    Mode                 - Mode number.  0 - 80x25   1-80x50\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The mode was set\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly.\r
+\r
+--*/\r
+typedef struct _EFI_VGA_MINI_PORT_PROTOCOL {\r
+  EFI_VGA_MINI_PORT_SET_MODE  SetMode;\r
+\r
+  UINT64                      VgaMemoryOffset;\r
+  UINT64                      CrtcAddressRegisterOffset;\r
+  UINT64                      CrtcDataRegisterOffset;\r
+\r
+  UINT8                       VgaMemoryBar;\r
+  UINT8                       CrtcAddressRegisterBar;\r
+  UINT8                       CrtcDataRegisterBar;\r
+\r
+  UINT8                       MaxMode;\r
+} EFI_VGA_MINI_PORT_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiVgaMiniPortProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c
new file mode 100644 (file)
index 0000000..cfc5e0d
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VirtualMemoryAccess.c\r
+\r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (VirtualMemoryAccess)\r
+\r
+EFI_GUID  gEfiVirtualMemoryAccessProtocolGuid = EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING\r
+  (&gEfiVirtualMemoryAccessProtocolGuid, "Virtual Memory Access Protocol", "Tiano Virtual Memory Access Protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h
new file mode 100644 (file)
index 0000000..c0e1fde
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VirtualmemoryAccess.h\r
+\r
+Abstract:\r
+\r
+  \r
+--*/\r
+\r
+#ifndef _VIRTUAL_MEMORY_ACCESS_H_\r
+#define _VIRTUAL_MEMORY_ACCESS_H_\r
+\r
+#define EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID \\r
+  {0x745d377a, 0xb988, 0x47b2, 0xb1, 0x8f, 0xbb, 0xc8, 0xd, 0xc5, 0x66, 0x98}\r
+\r
+\r
+EFI_FORWARD_DECLARATION (EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL);\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_MAP) (\r
+  IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                        MappingAddress,\r
+  IN  UINTN                                       NumberOfBytes,\r
+  IN  EFI_PHYSICAL_ADDRESS                        MappedAddress\r
+); \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_UNMAP) (\r
+  IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL  *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                        MappedAddress,\r
+  IN  UINTN                                       PageSizeInByte\r
+);  \r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE) (\r
+  IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This,\r
+  IN  UINTN                                      *PageSizeInByte\r
+);\r
+\r
+\r
+typedef struct _EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL {\r
+  EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE   GetPageSize;\r
+  EFI_VIRTUAL_MEMORY_ACCESS_MAP             Map;\r
+  EFI_VIRTUAL_MEMORY_ACCESS_UNMAP           UnMap;\r
+} EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiVirtualMemoryAccessProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EdkCompatibilityPkg/License.txt b/EdkCompatibilityPkg/License.txt
new file mode 100644 (file)
index 0000000..67db1ea
--- /dev/null
@@ -0,0 +1,30 @@
+Copyright (c) 2004, Intel Corporation\r
+All rights reserved.\r
+\r
+Redistribution and use in source and binary forms, with or without\r
+modification, are permitted provided that the following conditions are\r
+met:\r
+\r
+  . Redistributions of source code must retain the above copyright\r
+notice, this list of conditions and the following disclaimer.\r
\r
+  . Redistributions in binary form must reproduce the above copyright\r
+notice, this list of conditions and the following disclaimer in the\r
+documentation and/or other materials provided with the distribution.\r
+\r
+  . Neither the name of the Intel Corporation nor the names of its\r
+contributors may be used to endorse or promote products derived from\r
+this software without specific prior written permission.\r
+\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
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 (file)
index 0000000..2954da9
--- /dev/null
@@ -0,0 +1,1766 @@
+=======================================================================\r
+List of Implemented Fixes and Changes for Maintenance Releases of PCCTS\r
+\r
+\r
+ For a summary of the most significant changes see CHANGES_SUMMARY.TXT\r
+\r
+=======================================================================\r
+\r
+                               DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+\r
+        -------------------------------------------------------\r
+        Note:  Items #153 to #1 are now in a separate file named\r
+                CHANGES_FROM_133_BEFORE_MR13.txt\r
+        -------------------------------------------------------\r
+\r
+#261. (Changed in MR19) Defer token fetch for C++ mode\r
+\r
+    Item #216 has been revised to indicate that use of the defer fetch\r
+    option (ZZDEFER_FETCH) requires dlg option -i.\r
+\r
+#260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes.\r
+\r
+    ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg \r
+    generated lexers.  The default value has been raised to 32,000 and\r
+    the value used by antlr, dlg, and sorcerer has also been raised to\r
+    32,000.\r
+\r
+#259. (MR22) Default function arguments in C++ mode.\r
+\r
+    If a rule is declared:\r
+\r
+            rr [int i = 0] : ....\r
+\r
+    then the declaration generated by pccts resembles:\r
+\r
+            void rr(int i = 0);\r
+\r
+    however, the definition must omit the default argument:\r
+\r
+            void rr(int i) {...}\r
+\r
+    In the past the default value was not omitted.  In MR22\r
+    the generated code resembles:\r
+\r
+            void rr(int i /* = 0 */ ) {...}\r
+\r
+    Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de)\r
+\r
+#258. (MR22)  Using a base class for your parser\r
+\r
+    In item #102 (MR10) the class statement was extended to allow one\r
+    to specify a base class other than ANTLRParser for the generated\r
+    parser.  It turned out that this was less than useful because\r
+    the constructor still specified ANTLRParser as the base class.\r
+\r
+    The class statement now uses the first identifier appearing after\r
+    the ":" as the name of the base class.  For example:\r
+\r
+        class MyParser : public FooParser {\r
+\r
+    Generates in MyParser.h:\r
+\r
+            class MyParser : public FooParser {\r
+\r
+    Generates in MyParser.cpp something that resembles:\r
+\r
+            MyParser::MyParser(ANTLRTokenBuffer *input) :\r
+                                         FooParser(input,1,0,0,4)\r
+            {\r
+               token_tbl = _token_tbl;\r
+               traceOptionValueDefault=1;              // MR10 turn trace ON\r
+            }\r
+\r
+    The base class must constructor must have a signature similar to\r
+    that of ANTLRParser.\r
+\r
+#257. (MR21a) Removed dlg statement that -i has no effect in C++ mode.\r
+\r
+    This was incorrect.\r
+\r
+#256. (MR21a) Malformed syntax graph causes crash after error message.\r
+\r
+    In the past, certain kinds of errors in the very first grammar\r
+    element could cause the construction of a malformed graph \r
+    representing the grammar.  This would eventually result in a\r
+    fatal internal error.  The code has been changed to be more\r
+    resistant to this particular error.\r
+\r
+#255. (MR21a) ParserBlackBox(FILE* f) \r
+\r
+    This constructor set openByBlackBox to the wrong value.\r
+\r
+    Reported by Kees Bakker (kees_bakker@tasking.nl).\r
+\r
+#254. (MR21a) Reporting syntax error at end-of-file\r
+\r
+    When there was a syntax error at the end-of-file the syntax\r
+    error routine would substitute "<eof>" for the programmer's\r
+    end-of-file symbol.  This substitution is now done only when\r
+    the programmer does not define his own end-of-file symbol\r
+    or the symbol begins with the character "@".\r
+\r
+    Reported by Kees Bakker (kees_bakker@tasking.nl).\r
+\r
+#253. (MR21) Generation of block preamble (-preamble and -preamble_first)\r
+\r
+    The antlr option -preamble causes antlr to insert the code\r
+    BLOCK_PREAMBLE at the start of each rule and block.  It does\r
+    not insert code before rules references, token references, or\r
+    actions.  By properly defining the macro BLOCK_PREAMBLE the\r
+    user can generate code which is specific to the start of blocks.\r
+\r
+    The antlr option -preamble_first is similar, but inserts the\r
+    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
+    PreambleFirst_123 is equivalent to the first set defined by\r
+    the #FirstSetSymbol described in Item #248.\r
+\r
+    I have not investigated how these options interact with guess\r
+    mode (syntactic predicates).\r
+\r
+#252. (MR21) Check for null pointer in trace routine\r
+\r
+    When some trace options are used when the parser is generated\r
+    without the trace enabled, the current rule name may be a\r
+    NULL pointer.  A guard was added to check for this in\r
+    restoreState.\r
+\r
+    Reported by Douglas E. Forester (dougf@projtech.com).\r
+\r
+#251. (MR21) Changes to #define zzTRACE_RULES\r
+\r
+    The macro zzTRACE_RULES was being use to pass information to\r
+    AParser.h.  If this preprocessor symbol was not properly\r
+    set the first time AParser.h was #included, the declaration\r
+    of zzTRACEdata would be omitted (it is used by the -gd option).\r
+    Subsequent #includes of AParser.h would be skipped because of \r
+    the #ifdef guard, so the declaration of zzTracePrevRuleName would\r
+    never be made.  The result was that proper compilation was very \r
+    order dependent.\r
+\r
+    The declaration of zzTRACEdata was made unconditional and the\r
+    problem of removing unused declarations will be left to optimizers.\r
+    \r
+    Diagnosed by Douglas E. Forester (dougf@projtech.com).\r
+\r
+#250. (MR21) Option for EXPERIMENTAL change to error sets for blocks\r
+\r
+    The antlr option -mrblkerr turns on an experimental feature\r
+    which is supposed to provide more accurate syntax error messages\r
+    for k=1, ck=1 grammars.  When used with k>1 or ck>1 grammars the\r
+    behavior should be no worse than the current behavior.\r
+\r
+    There is no problem with the matching of elements or the computation\r
+    of prediction expressions in pccts.  The task is only one of listing\r
+    the most appropriate tokens in the error message.  The error sets used\r
+    in pccts error messages are approximations of the exact error set when\r
+    optional elements in (...)* or (...)+ are involved.  While entirely\r
+    correct, the error messages are sometimes not 100% accurate.  \r
+\r
+    There is also a minor philosophical issue.  For example, suppose the\r
+    grammar expects the token to be an optional A followed by Z, and it \r
+    is X.  X, of course, is neither A nor Z, so an error message is appropriate.\r
+    Is it appropriate to say "Expected Z" ?  It is correct, it is accurate,\r
+    but it is not complete.  \r
+\r
+    When k>1 or ck>1 the problem of providing the exactly correct\r
+    list of tokens for the syntax error messages ends up becoming\r
+    equivalent to evaluating the prediction expression for the\r
+    alternatives twice. However, for k=1 ck=1 grammars the prediction\r
+    expression can be computed easily and evaluated cheaply, so I\r
+    decided to try implementing it to satisfy a particular application.\r
+    This application uses the error set in an interactive command language\r
+    to provide prompts which list the alternatives available at that\r
+    point in the parser.  The user can then enter additional tokens to\r
+    complete the command line.  To do this required more accurate error \r
+    sets then previously provided by pccts.\r
+\r
+    In some cases the default pccts behavior may lead to more robust error\r
+    recovery or clearer error messages then having the exact set of tokens.\r
+    This is because (a) features like -ge allow the use of symbolic names for\r
+    certain sets of tokens, so having extra tokens may simply obscure things\r
+    and (b) the error set is use to resynchronize the parser, so a good\r
+    choice is sometimes more important than having the exact set.\r
+\r
+    Consider the following example:\r
+\r
+            Note:  All examples code has been abbreviated\r
+            to the absolute minimum in order to make the\r
+            examples concise.\r
+\r
+        star1 : (A)* Z;\r
+\r
+    The generated code resembles:\r
+\r
+           old                new (with -mrblkerr)\r
+        -------------         --------------------\r
+        for (;;) {            for (;;) {\r
+            match(A);           match(A);\r
+        }                     }\r
+        match(Z);             if (! A and ! Z) then\r
+                                FAIL(...{A,Z}...);\r
+                              }\r
+                              match(Z);\r
+\r
+\r
+        With input X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, Z\r
+\r
+    For the example:\r
+\r
+        star2 : (A|B)* Z;\r
+\r
+           old                      new (with -mrblkerr)\r
+        -------------               --------------------\r
+        for (;;) {                  for (;;) {\r
+          if (!A and !B) break;       if (!A and !B) break;\r
+          if (...) {                  if (...) {\r
+            <same ...>                  <same ...>\r
+          }                           }\r
+          else {                      else {\r
+            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
+          }                           }\r
+        }                           }\r
+        match(B);                   if (! A and ! B and !Z) then\r
+                                        FAIL(...{A,B,Z}...);\r
+                                    }\r
+                                    match(B);\r
+\r
+        With input X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+\r
+            This includes the choice of looping back to the\r
+            star block.\r
+\r
+    The code for plus blocks:\r
+\r
+        plus1 : (A)+ Z;\r
+\r
+    The generated code resembles:\r
+\r
+           old                  new (with -mrblkerr)\r
+        -------------           --------------------\r
+        do {                    do {\r
+          match(A);               match(A);\r
+        } while (A)             } while (A)\r
+        match(Z);               if (! A and ! Z) then\r
+                                  FAIL(...{A,Z}...);\r
+                                }\r
+                                match(Z);\r
+\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, Z\r
+\r
+            This includes the choice of looping back to the\r
+            plus block.\r
+\r
+    For the example:\r
+\r
+        plus2 : (A|B)+ Z;\r
+\r
+           old                    new (with -mrblkerr)\r
+        -------------             --------------------\r
+        do {                        do {\r
+          if (A) {                    <same>\r
+            match(A);                 <same>\r
+          } else if (B) {             <same>\r
+            match(B);                 <same>\r
+          } else {                    <same>\r
+            if (cnt > 1) break;       <same>\r
+            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
+          }                           }\r
+          cnt++;                      <same>\r
+        }                           }\r
+\r
+        match(Z);                   if (! A and ! B and !Z) then\r
+                                        FAIL(...{A,B,Z}...);\r
+                                    }\r
+                                    match(B);\r
+\r
+        With input X\r
+            old message: Found X, expected A, B, Z\r
+            new message: Found X, expected A, B\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+\r
+            This includes the choice of looping back to the\r
+            star block.\r
+    \r
+#249. (MR21) Changes for DEC/VMS systems\r
+\r
+    Jean-François Piéronne (jfp@altavista.net) has updated some\r
+    VMS related command files and fixed some minor problems related\r
+    to building pccts under the DEC/VMS operating system.  For DEC/VMS\r
+    users the most important differences are:\r
+\r
+        a.  Revised makefile.vms\r
+        b.  Revised genMMS for genrating VMS style makefiles.\r
+\r
+#248. (MR21) Generate symbol for first set of an alternative\r
+\r
+    pccts can generate a symbol which represents the tokens which may\r
+    appear at the start of a block:\r
+\r
+        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
+\r
+    This will generate the symbol rr_FirstSet of type SetWordType with\r
+    elements Foo and Bar set. The bits can be tested using code similar \r
+    to the following:\r
+\r
+        if (set_el(Foo, &rr_FirstSet)) { ...\r
+\r
+    This can be combined with the C array zztokens[] or the C++ routine\r
+    tokenName() to get the print name of the token in the first set.\r
+\r
+    The size of the set is given by the newly added enum SET_SIZE, a \r
+    protected member of the generated parser's class.  The number of\r
+    elements in the generated set will not be exactly equal to the \r
+    value of SET_SIZE because of synthetic tokens created by #tokclass,\r
+    #errclass, the -ge option, and meta-tokens such as epsilon, and\r
+    end-of-file.\r
+\r
+    The #FirstSetSymbol must appear immediately before a block\r
+    such as (...)+, (...)*, and {...}, and (...).  It may not appear\r
+    immediately before a token, a rule reference, or action.  However\r
+    a token or rule reference can be enclosed in a (...) in order to\r
+    make the use of #pragma FirstSetSymbol legal.\r
+\r
+            rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo;   //  Illegal\r
+\r
+            rr_ok :  #FirstSetSymbol(rr_ok_FirstSet) (Foo);  //  Legal\r
+    \r
+    Do not confuse FirstSetSymbol sets with the sets used for testing\r
+    lookahead. The sets used for FirstSetSymbol have one element per bit,\r
+    so the number of bytes  is approximately the largest token number\r
+    divided by 8.  The sets used for testing lookahead store 8 lookahead \r
+    sets per byte, so the length of the array is approximately the largest\r
+    token number.\r
+\r
+    If there is demand, a similar routine for follow sets can be added.\r
+\r
+#247. (MR21) Misleading error message on syntax error for optional elements.\r
+\r
+    Prior to MR21, tokens which were optional did not appear in syntax\r
+    error messages if the block which immediately followed detected a \r
+    syntax error.\r
+\r
+    Consider the following grammar which accepts Number, Word, and Other:\r
+\r
+            rr : {Number} Word;\r
+\r
+    For this rule the code resembles:\r
+\r
+            if (LA(1) == Number) {\r
+                match(Number);\r
+                consume();\r
+            }\r
+            match(Word);\r
+\r
+    Prior to MR21, the error message for input "$ a" would be:\r
+\r
+            line 1: syntax error at "$" missing Word\r
+\r
+    With MR21 the message will be:\r
+\r
+            line 1: syntax error at "$" expecting Word, Number.\r
+\r
+    The generate code resembles:\r
+\r
+            if ( (LA(1)==Number) ) {\r
+                zzmatch(Number);\r
+                consume();\r
+            }\r
+            else {\r
+                if ( (LA(1)==Word) ) {\r
+                    /* nothing */\r
+                }\r
+                else {\r
+                    FAIL(... message for both Number and Word ...);\r
+                }\r
+            }\r
+            match(Word);\r
+        \r
+    The code generated for optional blocks in MR21 is slightly longer\r
+    than the previous versions, but it should give better error messages.\r
+\r
+    The code generated for:\r
+\r
+            { a | b | c }\r
+\r
+    should now be *identical* to:\r
+\r
+            ( a | b | c | )\r
+\r
+    which was not the case prior to MR21.\r
+\r
+    Reported by Sue Marvin (sue@siara.com).\r
+\r
+#246. (Changed in MR21) Use of $(MAKE) for calls to make\r
+\r
+    Calls to make from the makefiles were replaced with $(MAKE)\r
+    because of problems when using gmake.\r
+\r
+    Reported with fix by Sunil K.Vallamkonda (sunil@siara.com).\r
+\r
+#245. (Changed in MR21) Changes to genmk\r
+\r
+    The following command line options have been added to genmk:\r
+\r
+        -cfiles ... \r
+            \r
+            To add a user's C or C++ files into makefile automatically.\r
+            The list of files must be enclosed in apostrophes.  This\r
+            option may be specified multiple times.\r
+\r
+        -compiler ...\r
+    \r
+            The name of the compiler to use for $(CCC) or $(CC).  The\r
+            default in C++ mode is "CC".  The default in C mode is "cc".\r
+\r
+        -pccts_path ...\r
+\r
+            The value for $(PCCTS), the pccts directory.  The default\r
+            is /usr/local/pccts.\r
+\r
+    Contributed by Tomasz Babczynski (t.babczynski@ict.pwr.wroc.pl).\r
+\r
+#244. (Changed in MR21) Rename variable "not" in antlr.g\r
+\r
+    When antlr.g is compiled with a C++ compiler, a variable named\r
+    "not" causes problems.  Reported by Sinan Karasu\r
+    (sinan.karasu@boeing.com).\r
+\r
+#243  (Changed in MR21) Replace recursion with iteration in zzfree_ast\r
+\r
+    Another refinement to zzfree_ast in ast.c to limit recursion.\r
+\r
+    NAKAJIMA Mutsuki (muc@isr.co.jp).\r
+\r
+\r
+#242.  (Changed in MR21) LineInfoFormatStr\r
+\r
+    Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h.\r
+\r
+#241. (Changed in MR21) Changed macro PURIFY to a no-op\r
+\r
+                ***********************\r
+                *** NOT IMPLEMENTED ***\r
+                ***********************\r
+\r
+        The PURIFY macro was changed to a no-op because it was causing \r
+        problems when passing C++ objects.\r
+    \r
+        The old definition:\r
+    \r
+            #define PURIFY(r,s)     memset((char *) &(r),'\\0',(s));\r
+    \r
+        The new definition:\r
+    \r
+            #define PURIFY(r,s)     /* nothing */\r
+#endif\r
+\r
+#240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE\r
+\r
+    Added test for NULL token pointer.\r
+\r
+    Suggested by Peter Keller (keller@ebi.ac.uk)\r
+\r
+#239. (Changed in MR21) C++ mode AParser::traceGuessFail\r
+\r
+    If tracing is turned on when the code has been generated\r
+    without trace code, a failed guess generates a trace report\r
+    even though there are no other trace reports.  This\r
+    make the behavior consistent with other parts of the\r
+    trace system.\r
+\r
+    Reported by David Wigg (wiggjd@sbu.ac.uk).\r
+\r
+#238. (Changed in MR21) Namespace version #include files\r
+\r
+    Changed reference from CStdio to cstdio (and other\r
+    #include file names) in the namespace version of pccts.\r
+    Should have known better.\r
+\r
+#237. (Changed in MR21) ParserBlackBox(FILE*)\r
+    \r
+    In the past, ParserBlackBox would close the FILE in the dtor\r
+    even though it was not opened by ParserBlackBox.  The problem\r
+    is that there were two constructors, one which accepted a file   \r
+    name and did an fopen, the other which accepted a FILE and did\r
+    not do an fopen.  There is now an extra member variable which\r
+    remembers whether ParserBlackBox did the open or not.\r
+\r
+    Suggested by Mike Percy (mpercy@scires.com).\r
+\r
+#236. (Changed in MR21) tmake now reports down pointer problem\r
+\r
+    When ASTBase::tmake attempts to update the down pointer of \r
+    an AST it checks to see if the down pointer is NULL.  If it\r
+    is not NULL it does not do the update and returns NULL.\r
+    An attempt to update the down pointer is almost always a\r
+    result of a user error.  This can lead to difficult to find\r
+    problems during tree construction.\r
+\r
+    With this change, the routine calls a virtual function\r
+    reportOverwriteOfDownPointer() which calls panic to\r
+    report the problem.  Users who want the old behavior can\r
+    redefined the virtual function in their AST class.\r
+\r
+    Suggested by Sinan Karasu (sinan.karasu@boeing.com)\r
+\r
+#235. (Changed in MR21) Made ANTLRParser::resynch() virtual\r
+\r
+    Suggested by Jerry Evans (jerry@swsl.co.uk).\r
+\r
+#234. (Changed in MR21) Implicit int for function return value\r
+\r
+    ATokenBuffer:bufferSize() did not specify a type for the\r
+    return value.\r
+\r
+    Reported by Hai Vo-Ba (hai@fc.hp.com).\r
+\r
+#233. (Changed in MR20) Converted to MSVC 6.0\r
+\r
+    Due to external circumstances I have had to convert to MSVC 6.0\r
+    The MSVC 5.0 project files (.dsw and .dsp) have been retained as\r
+    xxx50.dsp and xxx50.dsw.  The MSVC 6.0 files are named xxx60.dsp\r
+    and xxx60.dsw (where xxx is the related to the directory/project).\r
+\r
+#232. (Changed in MR20) Make setwd bit vectors protected in parser.h\r
+\r
+    The access for the setwd array in the parser header was not\r
+    specified.  As a result, it would depend on the code which \r
+    preceded it.  In MR20 it will always have access "protected".\r
+\r
+    Reported by Piotr Eljasiak (eljasiak@zt.gdansk.tpsa.pl).\r
+\r
+#231. (Changed in MR20) Error in token buffer debug code.\r
+\r
+    When token buffer debugging is selected via the pre-processor\r
+    symbol DEBUG_TOKENBUFFER there is an erroneous check in\r
+    AParser.cpp:\r
+\r
+        #ifdef DEBUG_TOKENBUFFER\r
+            if (i >= inputTokens->bufferSize() ||\r
+                inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
+        ...\r
+        #endif\r
+\r
+    Reported by David Wigg (wiggjd@sbu.ac.uk).\r
+\r
+#230. (Changed in MR20) Fixed problem with #define for -gd option\r
+\r
+    There was an error in setting zzTRACE_RULES for the -gd (trace) option.\r
+\r
+    Reported by Gary Funck (gary@intrepid.com).\r
+\r
+#229. (Changed in MR20) Additional "const" for literals\r
+\r
+    "const" was added to the token name literal table.\r
+    "const" was added to some panic() and similar routine\r
+\r
+#228. (Changed in MR20) dlg crashes on "()"\r
+\r
+    The following token defintion will cause DLG to crash.\r
+\r
+        #token "()"\r
+\r
+    When there is a syntax error in a regular expression\r
+    many of the dlg routines return a structure which has\r
+    null pointers.  When this is accessed by callers it\r
+    generates the crash.\r
+\r
+    I have attempted to fix the more common cases.\r
+\r
+    Reported by  Mengue Olivier (dolmen@bigfoot.com).\r
+\r
+#227. (Changed in MR20) Array overwrite\r
+\r
+    Steveh Hand (sassth@unx.sas.com) reported a problem which\r
+    was traced to a temporary array which was not properly\r
+    resized for deeply nested blocks.  This has been fixed.\r
+\r
+#226. (Changed in MR20) -pedantic conformance\r
+   \r
+    G. Hobbelt (i_a@mbh.org) and THM made many, many minor \r
+    changes to create prototypes for all the functions and\r
+    bring antlr, dlg, and sorcerer into conformance with\r
+    the gcc -pedantic option.\r
+\r
+    This may require uses to add pccts/h/pcctscfg.h to some\r
+    files or makefiles in order to have __USE_PROTOS defined.\r
+\r
+#225  (Changed in MR20) AST stack adjustment in C mode\r
+\r
+    The fix in #214 for AST stack adjustment in C mode missed \r
+    some cases.\r
+\r
+    Reported with fix by Ger Hobbelt (i_a@mbh.org).\r
+\r
+#224  (Changed in MR20) LL(1) and LL(2) with #pragma approx\r
+\r
+    This may take a record for the oldest, most trival, lexical\r
+    error in pccts.  The regular expressions for LL(1) and LL(2)\r
+    lacked an escape for the left and right parenthesis.\r
+\r
+    Reported by Ger Hobbelt (i_a@mbh.org).\r
+\r
+#223  (Changed in MR20) Addition of IBM_VISUAL_AGE directory\r
+\r
+    Build files for antlr, dlg, and sorcerer under IBM Visual Age \r
+    have been contributed by Anton Sergeev (ags@mlc.ru).  They have\r
+    been placed in the pccts/IBM_VISUAL_AGE directory.\r
+\r
+#222  (Changed in MR20) Replace __STDC__ with __USE_PROTOS\r
+\r
+    Most occurrences of __STDC__ replaced with __USE_PROTOS due to\r
+    complaints from several users.\r
+\r
+#221  (Changed in MR20) Added #include for DLexerBase.h to PBlackBox.\r
+\r
+    Added #include for DLexerBase.h to PBlackBox.\r
+\r
+#220  (Changed in MR19) strcat arguments reversed in #pred parse\r
+\r
+    The arguments to strcat are reversed when creating a print\r
+    name for a hash table entry for use with #pred feature.\r
+\r
+    Problem diagnosed and fix reported by Scott Harrington \r
+    (seh4@ix.netcom.com).\r
+\r
+#219. (Changed in MR19) C Mode routine zzfree_ast\r
+\r
+    Changes to reduce use of recursion for AST trees with only right\r
+    links or only left links in the C mode routine zzfree_ast.\r
+\r
+    Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp).\r
+\r
+#218. (Changed in MR19) Changes to support unsigned char in C mode\r
+\r
+    Changes to antlr.h and err.h to fix omissions in use of zzchar_t\r
+\r
+    Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp).\r
+\r
+#217. (Changed in MR19) Error message when dlg -i and -CC options selected\r
+    \r
+    *** This change was rescinded by item #257 ***\r
+\r
+    The parsers generated by pccts in C++ mode are not able to support the\r
+    interactive lexer option (except, perhaps, when using the deferred fetch\r
+    parser option.(Item #216).\r
+\r
+    DLG now warns when both -i and -CC are selected.\r
+\r
+    This warning was suggested by David Venditti (07751870267-0001@t-online.de).\r
+\r
+#216. (Changed in MR19) Defer token fetch for C++ mode\r
+\r
+    Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de)\r
+\r
+    Normally, pccts keeps the lookahead token buffer completely filled.\r
+    This requires max(k,ck) tokens of lookahead.  For some applications\r
+    this can cause deadlock problems.  For example, there may be cases\r
+    when the parser can't tell when the input has been completely consumed\r
+    until the parse is complete, but the parse can't be completed because \r
+    the input routines are waiting for additional tokens to fill the\r
+    lookahead buffer.\r
+    \r
+    When the ANTLRParser class is built with the pre-processor option \r
+    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
+    until LA(i) or LT(i) is called. \r
+\r
+    To test whether this option has been built into the ANTLRParser class\r
+    use "isDeferFetchEnabled()".\r
+\r
+    Using the -gd trace option with the default tracein() and traceout()\r
+    routines will defeat the effort to defer the fetch because the\r
+    trace routines print out information about the lookahead token at\r
+    the start of the rule.\r
+    \r
+    Because the tracein and traceout routines are virtual it is \r
+    easy to redefine them in your parser:\r
+\r
+        class MyParser {\r
+        <<\r
+            virtual void tracein(ANTLRChar * ruleName)\r
+                { fprintf(stderr,"Entering: %s\n", ruleName); }\r
+            virtual void traceout(ANTLRChar * ruleName)\r
+                { fprintf(stderr,"Leaving: %s\n", ruleName); }\r
+        >>\r
\r
+    The originals for those routines are pccts/h/AParser.cpp\r
\r
+    This requires use of the dlg option -i (interactive lexer).\r
+\r
+    This is experimental.  The interaction with guess mode (syntactic\r
+    predicates)is not known.\r
+\r
+#215. (Changed in MR19) Addition of reset() to DLGLexerBase\r
+\r
+    There was no obvious way to reset the lexer for reuse.  The\r
+    reset() method now does this.\r
+\r
+    Suggested by David Venditti (07751870267-0001@t-online.de).\r
+\r
+#214. (Changed in MR19)  C mode: Adjust AST stack pointer at exit\r
+\r
+    In C mode the AST stack pointer needs to be reset if there will\r
+    be multiple calls to the ANTLRx macros.\r
+\r
+    Reported with fix by Paul D. Smith (psmith@baynetworks.com).\r
+\r
+#213. (Changed in MR18)  Fatal error with -mrhoistk (k>1 hoisting)\r
+\r
+    When rearranging code I forgot to un-comment a critical line of\r
+    code that handles hoisting of predicates with k>1 lookahead.  This\r
+    is now fixed.\r
+\r
+    Reported by Reinier van den Born (reinier@vnet.ibm.com).\r
+\r
+#212. (Changed in MR17)  Mac related changes by Kenji Tanaka\r
+\r
+    Kenji Tanaka (kentar@osa.att.ne.jp) has made a number of changes for\r
+    Macintosh users.\r
+\r
+    a.  The following Macintosh MPW files aid in installing pccts on Mac:\r
+\r
+            pccts/MPW_Read_Me\r
+\r
+            pccts/install68K.mpw\r
+            pccts/installPPC.mpw\r
+\r
+            pccts/antlr/antlr.r\r
+            pccts/antlr/antlr68K.make\r
+            pccts/antlr/antlrPPC.make\r
+\r
+            pccts/dlg/dlg.r\r
+            pccts/dlg/dlg68K.make\r
+            pccts/dlg/dlgPPC.make\r
+\r
+            pccts/sorcerer/sor.r\r
+            pccts/sorcerer/sor68K.make\r
+            pccts/sorcerer/sorPPC.make\r
+    \r
+       They completely replace the previous Mac installation files.\r
+            \r
+    b. The most significant is a change in the MAC_FILE_CREATOR symbol\r
+       in pcctscfg.h:\r
+\r
+        old: #define MAC_FILE_CREATOR 'MMCC'   /* Metrowerks C/C++ Text files */\r
+        new: #define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
+\r
+    c.  Added calls to special_fopen_actions() where necessary.\r
+\r
+#211. (Changed in MR16a)  C++ style comment in dlg\r
+\r
+    This has been fixed.\r
+\r
+#210. (Changed in MR16a)  Sor accepts \r\n, \r, or \n for end-of-line\r
+\r
+    A user requested that Sorcerer be changed to accept other forms\r
+    of end-of-line.\r
+\r
+#209. (Changed in MR16) Name of files changed.\r
+\r
+        Old:  CHANGES_FROM_1.33\r
+        New:  CHANGES_FROM_133.txt\r
+\r
+        Old:  KNOWN_PROBLEMS\r
+        New:  KNOWN_PROBLEMS.txt\r
+\r
+#208. (Changed in MR16) Change in use of pccts #include files\r
+\r
+    There were problems with MS DevStudio when mixing Sorcerer and\r
+    PCCTS in the same source file.  The problem is caused by the\r
+    redefinition of setjmp in the MS header file setjmp.h.  In\r
+    setjmp.h the pre-processor symbol setjmp was redefined to be\r
+    _setjmp.  A later effort to execute #include <setjmp.h> resulted \r
+    in an effort to #include <_setjmp.h>.  I'm not sure whether this\r
+    is a bug or a feature.  In any case, I decided to fix it by\r
+    avoiding the use of pre-processor symbols in #include statements\r
+    altogether.  This has the added benefit of making pre-compiled\r
+    headers work again.\r
+\r
+    I've replaced statements:\r
+\r
+        old: #include PCCTS_SETJMP_H\r
+        new: #include "pccts_setjmp.h"\r
+\r
+    Where pccts_setjmp.h contains:\r
+\r
+            #ifndef __PCCTS_SETJMP_H__\r
+            #define __PCCTS_SETJMP_H__\r
+    \r
+            #ifdef PCCTS_USE_NAMESPACE_STD\r
+            #include <Csetjmp>\r
+            #else\r
+            #include <setjmp.h>\r
+            #endif\r
+\r
+            #endif\r
+        \r
+    A similar change has been made for other standard header files\r
+    required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc.\r
+\r
+    Reported by Jeff Vincent (JVincent@novell.com) and Dale Davis\r
+    (DalDavis@spectrace.com).\r
+\r
+#207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff]\r
+\r
+    dlg will report that this is an invalid range.\r
+\r
+    Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):\r
+\r
+        I think this problem is not specific to unsigned chars\r
+        because dlg reports no error for the range [\0x00-\0xfe].\r
+\r
+        I've found that information on range is kept in field\r
+        letter (unsigned char) of Attrib struct. Unfortunately\r
+        the letter value internally is for some reasons increased\r
+        by 1, so \0xff is represented here as 0.\r
+\r
+        That's why dlg complains about the range [\0x00-\0xff] in\r
+        dlg_p.g:\r
+\r
+        if ($$.letter > $2.letter) {\r
+          error("invalid range  ", zzline);\r
+        } \r
+\r
+    The fix is:\r
+\r
+        if ($$.letter > $2.letter && 255 != $$2.letter) {\r
+          error("invalid range  ", zzline);\r
+        } \r
+\r
+#206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor\r
+\r
+    The ANTLRParser destructor now frees zzFAILtext.\r
+\r
+    Problem and fix reported by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#205. (Changed in MR16) DLGStringReset argument now const\r
+\r
+    Changed: void DLGStringReset(DLGChar *s) {...}\r
+    To:      void DLGStringReset(const DLGChar *s) {...}\r
+\r
+    Suggested by Dale Davis (daldavis@spectrace.com)\r
+\r
+#204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h\r
+    \r
+    Reported by Oleg Dashevskii (olegdash@my-dejanews.com).\r
+\r
+#203. (Changed in MR15) Addition of sorcerer to distribution kit\r
+\r
+    I have finally caved in to popular demand.  The pccts 1.33mr15\r
+    kit will include sorcerer.  The separate sorcerer kit will be\r
+    discontinued.\r
+\r
+#202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit\r
+\r
+    Previously there was one workspace that contained projects for\r
+    all three parts of pccts: antlr, dlg, and sorcerer.  Now each\r
+    part (and directory) has its own workspace/project and there\r
+    is an additional workspace/project to build a library from the\r
+    .cpp files in the pccts/h directory.\r
+\r
+    The library build will create pccts_debug.lib or pccts_release.lib\r
+    according to the configuration selected.  \r
+\r
+    If you don't want to build pccts 1.33MR15 you can download a\r
+    ready-to-run kit for win32 from http://www.polhode.com/win32.zip.\r
+    The ready-to-run for win32 includes executables, a pre-built static\r
+    library for the .cpp files in the pccts/h directory, and a  sample\r
+    application\r
+\r
+    You will need to define the environment variable PCCTS to point to\r
+    the root of the pccts directory hierarchy.\r
+\r
+#201. (Changed in MR15) Several fixes by K.J. Cummings (cummings@peritus.com)\r
+\r
+      Generation of SETJMP rather than SETJMP_H in gen.c.\r
+\r
+      (Sor B19) Declaration of ref_vars_inits for ref_var_inits in\r
+      pccts/sorcerer/sorcerer.h.\r
+\r
+#200. (Changed in MR15) Remove operator=() in AToken.h\r
+\r
+      User reported that WatCom couldn't handle use of\r
+      explicit operator =().  Replace with equivalent\r
+      using cast operator.\r
+\r
+#199. (Changed in MR15) Don't allow use of empty #tokclass\r
+\r
+      Change antlr.g to disallow empty #tokclass sets.\r
+\r
+      Reported by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#198. Revised ANSI C grammar due to efforts by Manuel Kessler\r
+\r
+      Manuel Kessler (mlkessler@cip.physik.uni-wuerzburg.de)\r
+\r
+          Allow trailing ... in function parameter lists.\r
+          Add bit fields.\r
+          Allow old-style function declarations.\r
+          Support cv-qualified pointers.\r
+          Better checking of combinations of type specifiers.\r
+          Release of memory for local symbols on scope exit.\r
+          Allow input file name on command line as well as by redirection.\r
+\r
+              and other miscellaneous tweaks.\r
+\r
+      This is not part of the pccts distribution kit. It must be\r
+      downloaded separately from:\r
+\r
+            http://www.polhode.com/ansi_mr15.zip\r
+\r
+#197. (Changed in MR14) Resetting the lookahead buffer of the parser\r
+\r
+      Explanation and fix by Sinan Karasu (sinan.karasu@boeing.com)\r
+\r
+      Consider the code used to prime the lookahead buffer LA(i)\r
+      of the parser when init() is called:\r
+\r
+        void\r
+        ANTLRParser::\r
+        prime_lookahead()\r
+        {\r
+            int i;\r
+            for(i=1;i<=LLk; i++) consume();\r
+            dirty=0;\r
+            //lap = 0;      // MR14 - Sinan Karasu (sinan.karusu@boeing.com)\r
+            //labase = 0;   // MR14\r
+            labase=lap;     // MR14\r
+        }\r
+\r
+      When the parser is instantiated, lap=0,labase=0 is set.\r
+\r
+      The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is\r
+      computed.  Therefore, lap(before the loop) == lap (after the loop).\r
+\r
+      Now the only problem comes in when one does an init() of the parser\r
+      after an Eof has been seen. At that time, lap could be non zero.\r
+      Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2,\r
+      then\r
+\r
+        consume()\r
+        {\r
+            NLA = inputTokens->getToken()->getType();\r
+            dirty--;\r
+            lap = (lap+1)&(LLk-1);\r
+        }\r
+\r
+      or expanding NLA,\r
+\r
+        token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType();\r
+        dirty--;\r
+        lap = (lap+1)&(LLk-1);\r
+\r
+      so now we prime locations 1 and 2.  In prime_lookahead it used to set\r
+      lap=0 and labase=0.  Now, the next token will be read from location 0,\r
+      NOT 1 as it should have been.\r
+\r
+      This was never caught before, because if a parser is just instantiated,\r
+      then lap and labase are 0, the offending assignment lines are\r
+      basically no-ops, since the for loop wraps around back to 0.\r
+\r
+#196. (Changed in MR14) Problems with "(alpha)? beta" guess\r
+\r
+    Consider the following syntactic predicate in a grammar\r
+    with 2 tokens of lookahead (k=2 or ck=2):\r
+\r
+        rule  : ( alpha )? beta ;\r
+        alpha : S t ;\r
+        t     : T U\r
+              | T\r
+              ;\r
+        beta  : S t Z ;\r
+\r
+    When antlr computes the prediction expression with one token\r
+    of lookahead for alts 1 and 2 of rule t it finds an ambiguity.\r
+\r
+    Because the grammar has a lookahead of 2 it tries to compute\r
+    two tokens of lookahead for alts 1 and 2 of t.  Alt 1 clearly\r
+    has a lookahead of (T U).  Alt 2 is one token long so antlr\r
+    tries to compute the follow set of alt 2, which means finding\r
+    the things which can follow rule t in the context of (alpha)?.\r
+    This cannot be computed, because alpha is only part of a rule,\r
+    and antlr can't tell what part of beta is matched by alpha and\r
+    what part remains to be matched.  Thus it impossible for antlr\r
+    to  properly determine the follow set of rule t.\r
+\r
+    Prior to 1.33MR14, the follow of (alpha)? was computed as\r
+    FIRST(beta) as a result of the internal representation of\r
+    guess blocks.\r
+\r
+    With MR14 the follow set will be the empty set for that context.\r
+\r
+    Normally, one expects a rule appearing in a guess block to also\r
+    appear elsewhere.  When the follow context for this other use\r
+    is "ored" with the empty set, the context from the other use\r
+    results, and a reasonable follow context results.  However if\r
+    there is *no* other use of the rule, or it is used in a different\r
+    manner then the follow context will be inaccurate - it was\r
+    inaccurate even before MR14, but it will be inaccurate in a\r
+    different way.\r
+\r
+    For the example given earlier, a reasonable way to rewrite the\r
+    grammar:\r
+\r
+        rule  : ( alpha )? beta\r
+        alpha : S t ;\r
+        t     : T U\r
+              | T\r
+              ;\r
+        beta  : alpha Z ;\r
+\r
+    If there are no other uses of the rule appearing in the guess\r
+    block it will generate a test for EOF - a workaround for\r
+    representing a null set in the lookahead tests.\r
+\r
+    If you encounter such a problem you can use the -alpha option\r
+    to get additional information:\r
+\r
+    line 2: error: not possible to compute follow set for alpha\r
+              in an "(alpha)? beta" block.\r
+\r
+    With the antlr -alpha command line option the following information\r
+    is inserted into the generated file:\r
+\r
+    #if 0\r
+\r
+      Trace of references leading to attempt to compute the follow set of\r
+      alpha in an "(alpha)? beta" block. It is not possible for antlr to\r
+      compute this follow set because it is not known what part of beta has\r
+      already been matched by alpha and what part remains to be matched.\r
+\r
+      Rules which make use of the incorrect follow set will also be incorrect\r
+\r
+         1 #token T              alpha/2   line 7     brief.g\r
+         2 end alpha             alpha/3   line 8     brief.g\r
+         2 end (...)? block at   start/1   line 2     brief.g\r
+\r
+    #endif\r
+\r
+    At the moment, with the -alpha option selected the program marks\r
+    any rules which appear in the trace back chain (above) as rules with\r
+    possible problems computing follow set.\r
+\r
+    Reported by Greg Knapen (gregory.knapen@bell.ca).\r
+\r
+#195. (Changed in MR14) #line directive not at column 1\r
+\r
+      Under certain circunstances a predicate test could generate\r
+      a #line directive which was not at column 1.\r
+\r
+      Reported with fix by David KÃ¥gedal  (davidk@lysator.liu.se)\r
+      (http://www.lysator.liu.se/~davidk/).\r
+\r
+#194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass\r
+\r
+      In C mode with the demand lookahead option there is a bug in the\r
+      code which handles matches for #tokclass (zzsetmatch and\r
+      zzsetmatch_wsig).\r
+\r
+      The bug causes the lookahead pointer to get out of synchronization\r
+      with the current token pointer.\r
+\r
+      The problem was reported with a fix by Ger Hobbelt (hobbelt@axa.nl).\r
+\r
+#193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD\r
+\r
+      The pcctscfg.h now contains the following definitions:\r
+\r
+        #ifdef PCCTS_USE_NAMESPACE_STD\r
+        #define PCCTS_STDIO_H     <Cstdio>\r
+        #define PCCTS_STDLIB_H    <Cstdlib>\r
+        #define PCCTS_STDARG_H    <Cstdarg>\r
+        #define PCCTS_SETJMP_H    <Csetjmp>\r
+        #define PCCTS_STRING_H    <Cstring>\r
+        #define PCCTS_ASSERT_H    <Cassert>\r
+        #define PCCTS_ISTREAM_H   <istream>\r
+        #define PCCTS_IOSTREAM_H  <iostream>\r
+        #define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
+        #else\r
+        #define PCCTS_STDIO_H     <stdio.h>\r
+        #define PCCTS_STDLIB_H    <stdlib.h>\r
+        #define PCCTS_STDARG_H    <stdarg.h>\r
+        #define PCCTS_SETJMP_H    <setjmp.h>\r
+        #define PCCTS_STRING_H    <string.h>\r
+        #define PCCTS_ASSERT_H    <assert.h>\r
+        #define PCCTS_ISTREAM_H   <istream.h>\r
+        #define PCCTS_IOSTREAM_H  <iostream.h>\r
+        #define PCCTS_NAMESPACE_STD\r
+        #endif\r
+\r
+      The runtime support in pccts/h uses these pre-processor symbols\r
+      consistently.\r
+\r
+      Also, antlr and dlg have been changed to generate code which uses\r
+      these pre-processor symbols rather than having the names of the\r
+      #include files hard-coded in the generated code.\r
+\r
+      This required the addition of "#include pcctscfg.h" to a number of\r
+      files in pccts/h.\r
+\r
+      It appears that this sometimes causes problems for MSVC 5 in\r
+      combination with the "automatic" option for pre-compiled headers.\r
+      In such cases disable the "automatic" pre-compiled headers option.\r
+\r
+      Suggested by Hubert Holin (Hubert.Holin@Bigfoot.com).\r
+\r
+#192. (Changed in MR14) Change setText() to accept "const ANTLRChar *"\r
+\r
+      Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *).\r
+      This allows literal strings to be used to initialize tokens.  Since\r
+      the usual token implementation (ANTLRCommonToken)  makes a copy of the\r
+      input string, this was an unnecessary limitation.\r
+\r
+      Suggested by Bob McWhirter (bob@netwrench.com).\r
+\r
+#191. (Changed in MR14) HP/UX aCC compiler compatibility problem\r
+\r
+      Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and\r
+      zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp.\r
+\r
+      Reported by David Cook (dcook@bmc.com).\r
+\r
+#190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem\r
+\r
+      Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp\r
+\r
+      Reported by David Cook (dcook@bmc.com).\r
+\r
+#189. (Changed in MR14) -gxt switch in C mode\r
+\r
+      The -gxt switch in C mode didn't work because of incorrect\r
+      initialization.\r
+\r
+      Reported by Sinan Karasu (sinan@boeing.com).\r
+\r
+#188. (Changed in MR14) Added pccts/h/DLG_stream_input.h\r
+\r
+      This is a DLG stream class based on C++ istreams.\r
+\r
+      Contributed by Hubert Holin (Hubert.Holin@Bigfoot.com).\r
+\r
+#187. (Changed in MR14) Rename config.h to pcctscfg.h\r
+\r
+      The PCCTS configuration file has been renamed from config.h to\r
+      pcctscfg.h.  The problem with the original name is that it led\r
+      to name collisions when pccts parsers were combined with other\r
+      software.\r
+\r
+      All of the runtime support routines in pccts/h/* have been\r
+      changed to use the new name.  Existing software can continue\r
+      to use pccts/h/config.h. The contents of pccts/h/config.h is\r
+      now just "#include "pcctscfg.h".\r
+\r
+      I don't have a record of the user who suggested this.\r
+\r
+#186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier\r
+\r
+      Classes in the C++ runtime support routines are now declared:\r
+\r
+        class DllExportPCCTS className ....\r
+\r
+      By default, the pre-processor symbol is defined as the empty\r
+      string.  This if for use by MSVC++ users to create DLL classes.\r
+\r
+      Suggested by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase\r
+\r
+      Normally, the ASTBase class is derived from PCCTS_AST which contains\r
+      functions useful to Sorcerer.  If these are not necessary then the\r
+      user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which\r
+      will cause the ASTBase class to replace references to PCCTS_AST with\r
+      references to ASTBase where necessary.\r
+\r
+      The class ASTDoublyLinkedBase will contain a pure virtual function\r
+      shallowCopy() that was formerly defined in class PCCTS_AST.\r
+\r
+      Suggested by Bob McWhirter (bob@netwrench.com).\r
+\r
+#184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h\r
+\r
+      Reported by Hubert Holin (Hubert.Holin@bigfoot.com).\r
+\r
+#183. (Changed in MR14) -f to specify file with names of grammar files\r
+\r
+      In DEC/VMS it is difficult to specify very long command lines.\r
+      The -f option allows one to place the names of the grammar files\r
+      in a data file in order to bypass limitations of the DEC/VMS\r
+      command language interpreter.\r
+\r
+      Addition supplied by Bernard Giroud (b_giroud@decus.ch).\r
+\r
+#182. (Changed in MR14) Output directory option for DEC/VMS\r
+\r
+      Fix some problems with the -o option under DEC/VMS.\r
+\r
+      Fix supplied by Bernard Giroud (b_giroud@decus.ch).\r
+\r
+#181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar()\r
+\r
+      Changed DLGStringInput to cast the character using (unsigned char)\r
+      so that languages with character codes greater than 127 work\r
+      without changes.\r
+\r
+      Suggested by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#180. (Added in MR14) ANTLRParser::getEofToken()\r
+\r
+      Added "ANTLRToken ANTLRParser::getEofToken() const" to match the\r
+      setEofToken routine.\r
+\r
+      Requested by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream\r
+\r
+      The BufFileInput class described in Item #142 neglected to release\r
+      the allocated buffer when an instance was destroyed.\r
+\r
+      Reported by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets\r
+\r
+      In 1.33 vanilla, and all maintenance releases prior to MR14\r
+      there is a bug in the handling of guess blocks which use the\r
+      "long" form:\r
+\r
+                  (alpha)? beta\r
+\r
+      inside a (...)*, (...)+, or {...} block.\r
+\r
+      This problem does *not* apply to the case where beta is omitted\r
+      or when the syntactic predicate is on the leading edge of an\r
+      alternative.\r
+\r
+      The problem is that both alpha and beta are stored in the\r
+      syntax diagram, and that some analysis routines would fail\r
+      to skip the alpha portion when it was not on the leading edge.\r
+      Consider the following grammar with -ck 2:\r
+\r
+                r : ( (A)? B )* C D\r
+\r
+                  | A B      /* forces -ck 2 computation for old antlr    */\r
+                             /*              reports ambig for alts 1 & 2 */\r
+\r
+                  | B C      /* forces -ck 2 computation for new antlr    */\r
+                             /*              reports ambig for alts 1 & 3 */\r
+                  ;\r
+\r
+      The prediction expression for the first alternative should be\r
+      LA(1)={B C} LA(2)={B C D}, but previous versions of antlr\r
+      would compute the prediction expression as LA(1)={A C} LA(2)={B D}\r
+\r
+      Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided\r
+      a very clear example of the problem and identified the probable cause.\r
+\r
+#177. (Changed in MR14) #tokdefs and #token with regular expression\r
+\r
+      In MR13 the change described by Item #162 caused an existing\r
+      feature of antlr to fail.  Prior to the change it was possible\r
+      to give regular expression definitions and actions to tokens\r
+      which were defined via the #tokdefs directive.\r
+\r
+      This now works again.\r
+\r
+      Reported by Manfred Kogler (km@cast.uni-linz.ac.at).\r
+\r
+#176. (Changed in MR14) Support for #line in antlr source code\r
+\r
+      Note: this was implemented by Arpad Beszedes (beszedes@inf.u-szeged.hu).\r
+\r
+      In 1.33MR14 it is possible for a pre-processor to generate #line\r
+      directives in the antlr source and have those line numbers and file\r
+      names used in antlr error messages and in the #line directives\r
+      generated by antlr.\r
+\r
+      The #line directive may appear in the following forms:\r
+\r
+            #line ll "sss" xx xx ...\r
+\r
+      where ll represents a line number, "sss" represents the name of a file\r
+      enclosed in quotation marks, and xxx are arbitrary integers.\r
+\r
+      The following form (without "line") is not supported at the moment:\r
+\r
+            # ll "sss" xx xx ...\r
+\r
+      The result:\r
+\r
+        zzline\r
+\r
+            is replaced with ll from the # or #line directive\r
+\r
+        FileStr[CurFile]\r
+\r
+            is updated with the contents of the string (if any)\r
+            following the line number\r
+\r
+      Note\r
+      ----\r
+      The file-name string following the line number can be a complete\r
+      name with a directory-path. Antlr generates the output files from\r
+      the input file name (by replacing the extension from the file-name\r
+      with .c or .cpp).\r
+\r
+      If the input file (or the file-name from the line-info) contains\r
+      a path:\r
+\r
+        "../grammar.g"\r
+\r
+      the generated source code will be placed in "../grammar.cpp" (i.e.\r
+      in the parent directory).  This is inconvenient in some cases\r
+      (even the -o switch can not be used) so the path information is\r
+      removed from the #line directive.  Thus, if the line-info was\r
+\r
+        #line 2 "../grammar.g"\r
+\r
+      then the current file-name will become "grammar.g"\r
+\r
+      In this way, the generated source code according to the grammar file\r
+      will always be in the current directory, except when the -o switch\r
+      is used.\r
+\r
+#175. (Changed in MR14) Bug when guess block appears at start of (...)*\r
+\r
+      In 1.33 vanilla and all maintenance releases prior to 1.33MR14\r
+      there is a bug when a guess block appears at the start of a (...)+.\r
+      Consider the following k=1 (ck=1) grammar:\r
+\r
+            rule :\r
+                  ( (STAR)? ZIP )* ID ;\r
+\r
+      Prior to 1.33MR14, the generated code resembled:\r
+\r
+        ...\r
+        zzGUESS_BLOCK\r
+        while ( 1 ) {\r
+            if ( ! LA(1)==STAR) break;\r
+            zzGUESS\r
+            if ( !zzrv ) {\r
+                zzmatch(STAR);\r
+                zzCONSUME;\r
+                zzGUESS_DONE\r
+                zzmatch(ZIP);\r
+                zzCONSUME;\r
+            ...\r
+\r
+      Note that the routine uses STAR for the prediction expression\r
+      rather than ZIP.  With 1.33MR14 the generated code resembles:\r
+\r
+        ...\r
+        while ( 1 ) {\r
+            if ( ! LA(1)==ZIP) break;\r
+        ...\r
+\r
+      This problem existed only with (...)* blocks and was caused\r
+      by the slightly more complicate graph which represents (...)*\r
+      blocks.  This caused the analysis routine to compute the first\r
+      set for the alpha part of the "(alpha)? beta" rather than the\r
+      beta part.\r
+\r
+      Both (...)+ and {...} blocks handled the guess block correctly.\r
+\r
+      Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided\r
+      a very clear example of the problem and identified the probable cause.\r
+\r
+#174. (Changed in MR14) Bug when action precedes syntactic predicate\r
+\r
+      In 1.33 vanilla, and all maintenance releases prior to MR14,\r
+      there was a bug when a syntactic predicate was immediately\r
+      preceded by an action.  Consider the following -ck 2 grammar:\r
+\r
+            rule :\r
+                   <<int i;>>\r
+                   (alpha)? beta C\r
+                 | A B\r
+                 ;\r
+\r
+            alpha : A ;\r
+            beta  : A B;\r
+\r
+      Prior to MR14, the code generated for the first alternative\r
+      resembled:\r
+\r
+        ...\r
+        zzGUESS\r
+        if ( !zzrv && LA(1)==A && LA(2)==A) {\r
+            alpha();\r
+            zzGUESS_DONE\r
+            beta();\r
+            zzmatch(C);\r
+            zzCONSUME;\r
+        } else {\r
+        ...\r
+\r
+      The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly\r
+      wrong because LA(2) should be matched to B (first[2] of beta is {B}).\r
+\r
+      With 1.33MR14 the prediction expression is:\r
+\r
+        ...\r
+        if ( !zzrv && LA(1)==A && LA(2)==B) {\r
+            alpha();\r
+            zzGUESS_DONE\r
+            beta();\r
+            zzmatch(C);\r
+            zzCONSUME;\r
+        } else {\r
+        ...\r
+\r
+      This will only affect users in which alpha is shorter than\r
+      than max(k,ck) and there is an action immediately preceding\r
+      the syntactic predicate.\r
+\r
+      This problem was reported by reported by Arpad Beszedes\r
+      (beszedes@inf.u-szeged.hu) who provided a very clear example\r
+      of the problem and identified the presence of the init-action\r
+      as the likely culprit.\r
+\r
+#173. (Changed in MR13a) -glms for Microsoft style filenames with -gl\r
+\r
+      With the -gl option antlr generates #line directives using the\r
+      exact name of the input files specified on the command line.\r
+      An oddity of the Microsoft C and C++ compilers is that they\r
+      don't accept file names in #line directives containing "\"\r
+      even though these are names from the native file system.\r
+\r
+      With -glms option, the "\" in file names appearing in #line\r
+      directives is replaced with a "/" in order to conform to\r
+      Microsoft compiler requirements.\r
+\r
+      Reported by Erwin Achermann (erwin.achermann@switzerland.org).\r
+\r
+#172. (Changed in MR13) \r\n in antlr source counted as one line\r
+\r
+      Some MS software uses \r\n to indicate a new line.  Antlr\r
+      now recognizes this in counting lines.\r
+\r
+      Reported by Edward L. Hepler (elh@ece.vill.edu).\r
+\r
+#171. (Changed in MR13) #tokclass L..U now allowed\r
+\r
+      The following is now allowed:\r
+\r
+            #tokclass ABC { A..B C }\r
+\r
+      Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)\r
+\r
+#170. (Changed in MR13) Suppression for predicates with lookahead depth >1\r
+\r
+      In MR12 the capability for suppression of predicates with lookahead\r
+      depth=1 was introduced.  With MR13 this had been extended to\r
+      predicates with lookahead depth > 1 and released for use by users\r
+      on an experimental basis.\r
+\r
+      Consider the following grammar with -ck 2 and the predicate in rule\r
+      "a" with depth 2:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
+                ;\r
+\r
+            b   : A B C\r
+                ;\r
+\r
+      Normally, the predicate would be hoisted into rule r1 in order to\r
+      determine whether to call rule "ab".  However it should *not* be\r
+      hoisted because, even if p is false, there is a valid alternative\r
+      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
+\r
+      If "-info p" command line option is present the following information\r
+      will appear in the generated code:\r
+\r
+                while ( (LA(1)==A)\r
+        #if 0\r
+\r
+        Part (or all) of predicate with depth > 1 suppressed by alternative\r
+            without predicate\r
+\r
+        pred  <<  p(LATEXT(2))>>?\r
+                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
+          tree context:\r
+            (root = A\r
+               B\r
+            )\r
+\r
+        The token sequence which is suppressed: ( A B )\r
+        The sequence of references which generate that sequence of tokens:\r
+\r
+           1 to ab          r1/1       line 1     t1.g\r
+           2 ab             ab/1       line 4     t1.g\r
+           3 to b           ab/2       line 5     t1.g\r
+           4 b              b/1        line 11    t1.g\r
+           5 #token A       b/1        line 11    t1.g\r
+           6 #token B       b/1        line 11    t1.g\r
+\r
+        #endif\r
+\r
+      A slightly more complicated example:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
+                ;\r
+\r
+            b   : <<q(LATEXT(2))>>? D E\r
+                ;\r
+\r
+\r
+      In this case, the sequence (D E) in rule "a" which lies behind\r
+      the guard is used to suppress the predicate with context (D E)\r
+      in rule b.\r
+\r
+                while ( (LA(1)==A || LA(1)==D)\r
+            #if 0\r
+\r
+            Part (or all) of predicate with depth > 1 suppressed by alternative\r
+                without predicate\r
+\r
+            pred  <<  q(LATEXT(2))>>?\r
+                              depth=k=2  rule b  line 11  t2.g\r
+              tree context:\r
+                (root = D\r
+                   E\r
+                )\r
+\r
+            The token sequence which is suppressed: ( D E )\r
+            The sequence of references which generate that sequence of tokens:\r
+\r
+               1 to ab          r1/1       line 1     t2.g\r
+               2 ab             ab/1       line 4     t2.g\r
+               3 to a           ab/1       line 4     t2.g\r
+               4 a              a/1        line 8     t2.g\r
+               5 #token D       a/1        line 8     t2.g\r
+               6 #token E       a/1        line 8     t2.g\r
+\r
+            #endif\r
+            &&\r
+            #if 0\r
+\r
+            pred  <<  p(LATEXT(2))>>?\r
+                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
+              tree context:\r
+                (root = A\r
+                   B\r
+                )\r
+\r
+            #endif\r
+\r
+            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
+                ab();\r
+                ...\r
+\r
+#169. (Changed in MR13) Predicate test optimization for depth=1 predicates\r
+\r
+      When the MR12 generated a test of a predicate which had depth 1\r
+      it would use the depth >1 routines, resulting in correct but\r
+      inefficient behavior.  In MR13, a bit test is used.\r
+\r
+#168. (Changed in MR13) Token expressions in context guards\r
+\r
+      The token expressions appearing in context guards such as:\r
+\r
+            (A B)? => <<test(LT(1))>>?  someRule\r
+\r
+      are computed during an early phase of antlr processing.  As\r
+      a result, prior to MR13, complex expressions such as:\r
+\r
+            ~B\r
+            L..U\r
+            ~L..U\r
+            TokClassName\r
+            ~TokClassName\r
+\r
+      were not computed properly.  This resulted in incorrect\r
+      context being computed for such expressions.\r
+\r
+      In MR13 these context guards are verified for proper semantics\r
+      in the initial phase and then re-evaluated after complex token\r
+      expressions have been computed in order to produce the correct\r
+      behavior.\r
+\r
+      Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu).\r
+\r
+#167. (Changed in MR13) ~L..U\r
+\r
+      Prior to MR13, the complement of a token range was\r
+      not properly computed.\r
+\r
+#166. (Changed in MR13) token expression L..U\r
+\r
+      The token U was represented as an unsigned char, restricting\r
+      the use of L..U to cases where U was assigned a token number\r
+      less than 256.  This is corrected in MR13.\r
+\r
+#165. (Changed in MR13) option -newAST\r
+\r
+      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
+      "new AST(ANTLRTokenPtr)".  This option generates a call\r
+      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
+      to define a parser member function to create an AST object.\r
+\r
+      Similar changes for ASTBase::tmake and ASTBase::link were not\r
+      thought necessary since they do not create AST objects, only\r
+      use existing ones.\r
+\r
+#164. (Changed in MR13) Unused variable _astp\r
+\r
+      For many compilations, we have lived with warnings about\r
+      the unused variable _astp.  It turns out that this varible\r
+      can *never* be used because the code which references it was\r
+      commented out.\r
+\r
+      This investigation was sparked by a note from Erwin Achermann\r
+      (erwin.achermann@switzerland.org).\r
+\r
+#163. (Changed in MR13) Incorrect makefiles for testcpp examples\r
+\r
+      All the examples in pccts/testcpp/* had incorrect definitions\r
+      in the makefiles for the symbol "CCC".  Instead of CCC=CC they\r
+      had CC=$(CCC).\r
+\r
+      There was an additional problem in testcpp/1/test.g due to the\r
+      change in ANTLRToken::getText() to a const member function\r
+      (Item #137).\r
+\r
+      Reported by Maurice Mass (maas@cuci.nl).\r
+\r
+#162. (Changed in MR13) Combining #token with #tokdefs\r
+\r
+      When it became possible to change the print-name of a\r
+      #token (Item #148) it became useful to give a #token\r
+      statement whose only purpose was to giving a print name\r
+      to the #token.  Prior to this change this could not be\r
+      combined with the #tokdefs feature.\r
+\r
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
+\r
+#160. (Changed in MR13) Omissions in list of names for remap.h\r
+\r
+      When a user selects the -gp option antlr creates a list\r
+      of macros in remap.h to rename some of the standard\r
+      antlr routines from zzXXX to userprefixXXX.\r
+\r
+      There were number of omissions from the remap.h name\r
+      list related to the new trace facility.  This was reported,\r
+      along with a fix, by Bernie Solomon (bernard@ug.eds.com).\r
+\r
+#159. (Changed in MR13) Violations of classic C rules\r
+\r
+      There were a number of violations of classic C style in\r
+      the distribution kit.  This was reported, along with fixes,\r
+      by Bernie Solomon (bernard@ug.eds.com).\r
+\r
+#158. (Changed in MR13) #header causes problem for pre-processors\r
+\r
+      A user who runs the C pre-processor on antlr source suggested\r
+      that another syntax be allowed.  With MR13 such directives\r
+      such as #header, #pragma, etc. may be written as "\#header",\r
+      "\#pragma", etc.  For escaping pre-processor directives inside\r
+      a #header use something like the following:\r
+\r
+            \#header\r
+            <<\r
+                \#include <stdio.h>\r
+            >>\r
+\r
+#157. (Fixed in MR13) empty error sets for rules with infinite recursion\r
+\r
+      When the first set for a rule cannot be computed due to infinite\r
+      left recursion and it is the only alternative for a block then\r
+      the error set for the block would be empty.  This would result\r
+      in a fatal error.\r
+\r
+      Reported by Darin Creason (creason@genedax.com)\r
+\r
+#156. (Changed in MR13) DLGLexerBase::getToken() now public\r
+\r
+#155. (Changed in MR13) Context behind predicates can suppress\r
+\r
+      With -mrhoist enabled the context behind a guarded predicate can\r
+      be used to suppress other predicates.  Consider the following grammar:\r
+\r
+        r0 : (r1)+;\r
+\r
+        r1  : rp\r
+            | rq\r
+            ;\r
+        rp  : <<p LATEXT(1)>>? B ;\r
+        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
+\r
+      In earlier versions both predicates "p" and "q" would be hoisted into\r
+      rule r0. With MR12c predicate p is suppressed because the context which\r
+      follows predicate q includes "B" which can "cover" predicate "p".  In\r
+      other words, in trying to decide in r0 whether to call r1, it doesn't\r
+      really matter whether p is false or true because, either way, there is\r
+      a valid choice within r1.\r
+\r
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
+\r
+      A common error, even among experienced pccts users, is to code\r
+      an init-action to inhibit hoisting rather than a leading action.\r
+      An init-action does not inhibit hoisting.\r
+\r
+      This was coded:\r
+\r
+        rule1 : <<;>> rule2\r
+\r
+      This is what was meant:\r
+\r
+        rule1 : <<;>> <<;>> rule2\r
+\r
+      With MR13, the user can code:\r
+\r
+        rule1 : <<;>> <<nohoist>> rule2\r
+\r
+      The following will give an error message:\r
+\r
+        rule1 : <<nohoist>> rule2\r
+\r
+      If the <<nohoist>> appears as an init-action rather than a leading\r
+      action an error message is issued.  The meaning of an init-action\r
+      containing "nohoist" is unclear: does it apply to just one\r
+      alternative or to all alternatives ?\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+        -------------------------------------------------------\r
+        Note:  Items #153 to #1 are now in a separate file named\r
+                CHANGES_FROM_133_BEFORE_MR13.txt\r
+        -------------------------------------------------------\r
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 (file)
index 0000000..5e2c020
--- /dev/null
@@ -0,0 +1,3666 @@
+\r
+    ------------------------------------------------------------\r
+           This is the second part of a two part file.\r
+      This is a list of changes to pccts 1.33 prior to MR13\r
+       For more recent information see CHANGES_FROM_133.txt\r
+    ------------------------------------------------------------\r
+\r
+                               DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+\r
+#153. (Changed in MR12b) Bug in computation of -mrhoist suppression set\r
+\r
+      Consider the following grammar with k=1 and "-mrhoist on":\r
+\r
+            r1  : (A)? => ((p>>? x      /* l1 */\r
+                | r2                    /* l2 */\r
+                ;\r
+            r2  :  A                    /* l4 */\r
+                | (B)? => <<q>>? y      /* l5 */\r
+                ;\r
+\r
+      In earlier versions the mrhoist routine would see that both l1 and\r
+      l2 contained predicates and would assume that this prevented either\r
+      from acting to suppress the other predicate.  In the example above\r
+      it didn't realize the A at line l4 is capable of suppressing the\r
+      predicate at l1 even though alt l2 contains (indirectly) a predicate.\r
+\r
+      This is fixed  in MR12b.\r
+\r
+      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
+\r
+#153. (Changed in MR12a) Bug in computation of -mrhoist suppression set\r
+\r
+      An oversight similar to that described in Item #152 appeared in\r
+      the computation of the set that "covered" a predicate.  If a\r
+      predicate expression included a term such as p=AND(q,r) the context\r
+      of p was taken to be context(q) & context(r), when it should have\r
+      been context(q) | context(r).  This is fixed in MR12a.\r
+\r
+#152. (Changed in MR12) Bug in generation of predicate expressions\r
+\r
+      The primary purpose for MR12 is to make quite clear that MR11 is\r
+      obsolete and to fix the bug related to predicate expressions.\r
+\r
+      In MR10 code was added to optimize the code generated for\r
+      predicate expression tests.  Unfortunately, there was a\r
+      significant oversight in the code which resulted in a bug in\r
+      the generation of code for predicate expression tests which\r
+      contained predicates combined using AND:\r
+\r
+            r0 : (r1)* "@" ;\r
+            r1 : (AAA)? => <<p LATEXT(1)>>? r2 ;\r
+            r2 : (BBB)? => <<q LATEXT(1)>>? Q\r
+               | (BBB)? => <<r LATEXT(1)>>? Q\r
+               ;\r
+\r
+      In MR11 (and MR10 when using "-mrhoist on") the code generated\r
+      for r0 to predict r1 would be equivalent to:\r
+\r
+        if ( LA(1)==Q &&\r
+                (LA(1)==AAA && LA(1)==BBB) &&\r
+                    ( p && ( q || r )) ) {\r
+\r
+      This is incorrect because it expresses the idea that LA(1)\r
+      *must* be AAA in order to attempt r1, and *must* be BBB to\r
+      attempt r2.  The result was that r1 became unreachable since\r
+      both condition can not be simultaneously true.\r
+\r
+      The general philosophy of code generation for predicates\r
+      can be summarized as follows:\r
+\r
+            a. If the context is true don't enter an alt\r
+               for which the corresponding predicate is false.\r
+\r
+               If the context is false then it is okay to enter\r
+               the alt without evaluating the predicate at all.\r
+\r
+            b. A predicate created by ORing of predicates has\r
+               context which is the OR of their individual contexts.\r
+\r
+            c. A predicate created by ANDing of predicates has\r
+               (surprise) context which is the OR of their individual\r
+               contexts.\r
+\r
+            d. Apply these rules recursively.\r
+\r
+            e. Remember rule (a)\r
+\r
+      The correct code should express the idea that *if* LA(1) is\r
+      AAA then p must be true to attempt r1, but if LA(1) is *not*\r
+      AAA then it is okay to attempt r1, provided that *if* LA(1) is\r
+      BBB then one of q or r must be true.\r
+\r
+        if ( LA(1)==Q &&\r
+                ( !(LA(1)==AAA || LA(1)==BBB) ||\r
+                    ( ! LA(1) == AAA || p) &&\r
+                    ( ! LA(1) == BBB || q || r ) ) ) {\r
+\r
+      I believe this is fixed in MR12.\r
+\r
+      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
+\r
+#151a. (Changed in MR12) ANTLRParser::getLexer()\r
+\r
+      As a result of several requests, I have added public methods to\r
+      get a pointer to the lexer belonging to a parser.\r
+\r
+            ANTLRTokenStream *ANTLRParser::getLexer() const\r
+\r
+                Returns a pointer to the lexer being used by the\r
+                parser.  ANTLRTokenStream is the base class of\r
+                DLGLexer\r
+\r
+            ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const\r
+\r
+                Returns a pointer to the lexer being used by the\r
+                ANTLRTokenBuffer.  ANTLRTokenStream is the base\r
+                class of DLGLexer\r
+\r
+      You must manually cast the ANTLRTokenStream to your program's\r
+      lexer class. Because the name of the lexer's class is not fixed.\r
+      Thus it is impossible to incorporate it into the DLGLexerBase\r
+      class.\r
+\r
+#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
+\r
+      The template class ParserBlackBox now has a member getLexer()\r
+      which returns a pointer to the lexer.\r
+\r
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
+\r
+      See Item #127 for more information.\r
+\r
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
+\r
+      If there is more than one rule which is not referenced by any\r
+      other rule then all such rules are listed.  This is useful for\r
+      alerting one to rules which are not used, but which can still\r
+      contribute to ambiguity.  For example:\r
+\r
+            start : a Z ;\r
+            unused: a A ;\r
+            a     : (A)+ ;\r
+\r
+      will cause an ambiguity report for rule "a" which will be\r
+      difficult to understand if the user forgets about rule "unused"\r
+      simply because it is not used in the grammar.\r
+\r
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
+\r
+      In a #token statement like the following:\r
+\r
+            #token Plus "\+"\r
+\r
+      the string "Plus" appears in the zztokens array (C mode) and\r
+      token_tbl (C++ mode).  This string is used in most error\r
+      messages.  In MR11 one has the option of using some other string,\r
+      (e.g.  "+") in those tables.\r
+\r
+      In MR11 one can write:\r
+\r
+            #token Plus ("+")             "\+"\r
+            #token RP   ("(")             "\("\r
+            #token COM  ("comment begin") "/\*"\r
+\r
+      A #token statement is allowed to appear in more than one #lexclass\r
+      with different regular expressions.  However, the token name appears\r
+      only once in the zztokens/token_tbl array.  This means that only\r
+      one substitute can be specified for a given #token name.  The second\r
+      attempt to define a substitute name (different from the first) will\r
+      result in an error message.\r
+\r
+#147. (Changed in MR11) Bug in follow set computation\r
+\r
+      There is a bug in 1.33 vanilla and all maintenance releases\r
+      prior to MR11 in the computation of the follow set.  The bug is\r
+      different than that described in Item #82 and probably more\r
+      common.  It was discovered in the ansi.g grammar while testing\r
+      the "ambiguity aid" (Item #119). The search for a bug started\r
+      when the ambiguity aid was unable to discover the actual source\r
+      of an ambiguity reported by antlr.\r
+\r
+      The problem appears when an optimization of the follow set\r
+      computation is used inappropriately.  The result is that the\r
+      follow set used is the "worst case".  In other words, the error\r
+      can lead to false reports of ambiguity.  The good news is that\r
+      if you have a grammar in which you have addressed all reported\r
+      ambiguities you are ok.  The bad news is that you may have spent\r
+      time fixing ambiguities that were not real, or used k=2 when\r
+      ck=2 might have been sufficient, and so on.\r
+\r
+      The following grammar demonstrates the problem:\r
+\r
+        ------------------------------------------------------------\r
+            expr          :   ID ;\r
+\r
+            start         :   stmt SEMI ;\r
+\r
+            stmt          :   CASE expr COLON\r
+                          |   expr SEMI\r
+                          |   plain_stmt\r
+                          ;\r
+\r
+            plain_stmt    :   ID COLON ;\r
+        ------------------------------------------------------------\r
+\r
+      When compiled with k=1 and ck=2 it will report:\r
+\r
+         warning: alts 2 and 3 of the rule itself ambiguous upon\r
+                                             { IDENTIFIER }, { COLON }\r
+\r
+      When antlr analyzes "stmt" it computes the first[1] set of all\r
+      alternatives.  It finds an ambiguity between alts 2 and 3 for ID.\r
+      It then computes the first[2] set for alternatives 2 and 3 to resolve\r
+      the ambiguity.  In computing the first[2] set of "expr" (which is\r
+      only one token long) it needs to determine what could follow "expr".\r
+      Under a certain combination of circumstances antlr forgets that it\r
+      is trying to analyze "stmt" which can only be followed by SEMI and\r
+      adds to the first[2] set of "expr" the "global" follow set (including\r
+      "COLON") which could follow "expr" (under other conditions) in the\r
+      phrase "CASE expr COLON".\r
+\r
+#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
+\r
+      It can be difficult to determine which alternatives are causing\r
+      pccts to work hard to resolve an ambiguity.  In some cases the\r
+      ambiguity is successfully resolved after much CPU time so there\r
+      is no message at all.\r
+\r
+      A rough measure of the amount of work being peformed which is\r
+      independent of the CPU speed and system load is the number of\r
+      tnodes created.  Using "-info t" gives information about the\r
+      total number of tnodes created and the peak number of tnodes.\r
+\r
+        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
+\r
+      It also puts in the generated C or C++ file the number of tnodes\r
+      created for a rule (at the end of the rule).  However this\r
+      information is not sufficient to locate the alternatives within\r
+      a rule which are causing the creation of tnodes.\r
+\r
+      Using:\r
+\r
+             antlr -treport 100000 ....\r
+\r
+      causes antlr to list on stdout any alternatives which require the\r
+      creation of more than 100,000 tnodes, along with the lookahead sets\r
+      for those alternatives.\r
+\r
+      The following is a trivial case from the ansi.g grammar which shows\r
+      the format of the report.  This report might be of more interest\r
+      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
+\r
+      -------------------------------------------------------------------------\r
+        There were 0 tuples whose ambiguity could not be resolved\r
+             by full lookahead\r
+        There were 157 tnodes created to resolve ambiguity between:\r
+\r
+          Choice 1: statement/2  line 475  file ansi.g\r
+          Choice 2: statement/3  line 476  file ansi.g\r
+\r
+            Intersection of lookahead[1] sets:\r
+\r
+               IDENTIFIER\r
+\r
+            Intersection of lookahead[2] sets:\r
+\r
+               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
+               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
+               NOT              SIZEOF           OCTALINT         DECIMALINT\r
+               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
+               STRING           CHARACTER\r
+      -------------------------------------------------------------------------\r
+\r
+#145. (Documentation)  Generation of Expression Trees\r
+\r
+      Item #99 was misleading because it implied that the optimization\r
+      for tree expressions was available only for trees created by\r
+      predicate expressions and neglected to mention that it required\r
+      the use of "-mrhoist on".  The optimization applies to tree\r
+      expressions created for grammars with k>1 and for predicates with\r
+      lookahead depth >1.\r
+\r
+      In MR11 the optimized version is always used so the -mrhoist on\r
+      option need not be specified.\r
+\r
+#144. (Changed in MR11) Incorrect test for exception group\r
+\r
+      In testing for a rule's exception group the label a pointer\r
+      is compared against '\0'.  The intention is "*pointer".\r
+\r
+      Reported by Jeffrey C. Fried (Jeff@Fried.net).\r
+\r
+#143. (Changed in MR11) Optional ";" at end of #token statement\r
+\r
+      Fixes problem of:\r
+\r
+            #token X "x"\r
+\r
+            <<\r
+                parser action\r
+            >>\r
+\r
+      Being confused with:\r
+\r
+            #token X "x" <<lexical action>>\r
+\r
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
+\r
+      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
+      BufFileInput derived from DLGInputStream which provides a\r
+      function lookahead(char *string) to test characters in the\r
+      input stream more than one character ahead.\r
+\r
+      The default amount of lookahead is specified by the constructor\r
+      and defaults to 8 characters.  This does *not* include the one\r
+      character of lookahead maintained internally by DLG in member "ch"\r
+      and which is not available for testing via BufFileInput::lookahead().\r
+\r
+      This is a useful class for overcoming the one-character-lookahead\r
+      limitation of DLG without resorting to a lexer capable of\r
+      backtracking (like flex) which is not integrated with antlr as is\r
+      DLG.\r
+\r
+      There are no restrictions on copying or using BufFileInput.* except\r
+      that the authorship and related information must be retained in the\r
+      source code.\r
+\r
+      The class is located in pccts/h/BufFileInput.* of the kit.\r
+\r
+#141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume()\r
+\r
+      A debug aid has been added to file ANTLRParser::consume() in\r
+      file AParser.cpp:\r
+\r
+            #ifdef ZZDEBUG_CONSUME_ACTION\r
+                zzdebug_consume_action();\r
+            #endif\r
+\r
+      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
+\r
+#140. (Changed in MR11) #pred to define predicates\r
+\r
+      +---------------------------------------------------+\r
+      | Note: Assume "-prc on" for this entire discussion |\r
+      +---------------------------------------------------+\r
+\r
+      A problem with predicates is that each one is regarded as\r
+      unique and capable of disambiguating cases where two\r
+      alternatives have identical lookahead.  For example:\r
+\r
+        rule : <<pred(LATEXT(1))>>? A\r
+             | <<pred(LATEXT(1))>>? A\r
+             ;\r
+\r
+      will not cause any error messages or warnings to be issued\r
+      by earlier versions of pccts.  To compare the text of the\r
+      predicates is an incomplete solution.\r
+\r
+      In 1.33MR11 I am introducing the #pred statement in order to\r
+      solve some problems with predicates.  The #pred statement allows\r
+      one to give a symbolic name to a "predicate literal" or a\r
+      "predicate expression" in order to refer to it in other predicate\r
+      expressions or in the rules of the grammar.\r
+\r
+      The predicate literal associated with a predicate symbol is C\r
+      or C++ code which can be used to test the condition.  A\r
+      predicate expression defines a predicate symbol in terms of other\r
+      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
+      can be defined in terms of a predicate literal, a predicate\r
+      expression, or *both*.\r
+\r
+      When a predicate symbol is defined with both a predicate literal\r
+      and a predicate expression, the predicate literal is used to generate\r
+      code, but the predicate expression is used to check for two\r
+      alternatives with identical predicates in both alternatives.\r
+\r
+      Here are some examples of #pred statements:\r
+\r
+        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
+        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
+        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
+        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
+        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
+\r
+      I hope that the use of EBNF notation to describe the syntax of the\r
+      #pred statement will not cause problems for my readers (joke).\r
+\r
+        predStatement : "#pred"\r
+                            CapitalizedName\r
+                              (\r
+                                  "<<predicate_literal>>?"\r
+                                | "<<predicate_literal>>?"  predOrExpr\r
+                                | predOrExpr\r
+                              )\r
+                      ;\r
+\r
+        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
+\r
+        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
+\r
+        predPrimary   : CapitalizedName\r
+                      | "!" predPrimary\r
+                      | "(" predOrExpr ")"\r
+                      ;\r
+\r
+      What is the purpose of this nonsense ?\r
+\r
+      To understand how predicate symbols help, you need to realize that\r
+      predicate symbols are used in two different ways with two different\r
+      goals.\r
+\r
+        a. Allow simplification of predicates which have been combined\r
+           during predicate hoisting.\r
+\r
+        b. Allow recognition of identical predicates which can't disambiguate\r
+           alternatives with common lookahead.\r
+\r
+      First we will discuss goal (a).  Consider the following rule:\r
+\r
+            rule0: rule1\r
+                 | ID\r
+                 | ...\r
+                 ;\r
+\r
+            rule1: rule2\r
+                 | rule3\r
+                 ;\r
+\r
+            rule2: <<isX(LATEXT(1))>>? ID ;\r
+            rule3: <<!isX(LATEXT(1)>>? ID ;\r
+\r
+      When the predicates in rule2 and rule3 are combined by hoisting\r
+      to create a prediction expression for rule1 the result is:\r
+\r
+            if ( LA(1)==ID\r
+                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
+\r
+      This is inefficient, but more importantly, can lead to false\r
+      assumptions that the predicate expression distinguishes the rule1\r
+      alternative with some other alternative with lookahead ID.  In\r
+      MR11 one can write:\r
+\r
+            #pred IsX     <<isX(LATEXT(1))>>?\r
+\r
+            ...\r
+\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<!IsX>>? ID ;\r
+\r
+      During hoisting MR11 recognizes this as a special case and\r
+      eliminates the predicates.  The result is a prediction\r
+      expression like the following:\r
+\r
+            if ( LA(1)==ID ) { rule1(); ...\r
+\r
+      Please note that the following cases which appear to be equivalent\r
+      *cannot* be simplified by MR11 during hoisting because the hoisting\r
+      logic only checks for a "!" in the predicate action, not in the\r
+      predicate expression for a predicate symbol.\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     <<!isX(LATEXT(1))>>?\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     !IsX\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+      Now we will discuss goal (b).\r
+\r
+      When antlr discovers that there is a lookahead ambiguity between\r
+      two alternatives it attempts to resolve the ambiguity by searching\r
+      for predicates in both alternatives.  In the past any predicate\r
+      would do, even if the same one appeared in both alternatives:\r
+\r
+            rule: <<p(LATEXT(1))>>? X\r
+                | <<p(LATEXT(1))>>? X\r
+                ;\r
+\r
+      The #pred statement is a start towards solving this problem.\r
+      During ambiguity resolution (*not* predicate hoisting) the\r
+      predicates for the two alternatives are expanded and compared.\r
+      Consider the following example:\r
+\r
+            #pred Upper     <<isUpper(LATEXT(1))>>?\r
+            #pred Lower     <<isLower(LATEXT(1))>>?\r
+            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
+\r
+            rule0: rule1\r
+                 | <<Alpha>>? ID\r
+                 ;\r
+\r
+            rule1:\r
+                 | rule2\r
+                 | rule3\r
+                 ...\r
+                 ;\r
+\r
+            rule2: <<Upper>>? ID;\r
+            rule3: <<Lower>>? ID;\r
+\r
+      The definition of #pred Alpha expresses:\r
+\r
+            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
+\r
+            b. to analyze the predicate use the information that\r
+               Alpha is equivalent to the union of Upper and Lower,\r
+\r
+      During ambiguity resolution the definition of Alpha is expanded\r
+      into "Upper || Lower" and compared with the predicate in the other\r
+      alternative, which is also "Upper || Lower".  Because they are\r
+      identical MR11 will report a problem.\r
+\r
+    -------------------------------------------------------------------------\r
+      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
+             (file t10.g alt 1 line 5 and alt 2 line 6)\r
+             are identical when compared without context and may have no\r
+             resolving power for some lookahead sequences.\r
+    -------------------------------------------------------------------------\r
+\r
+      If you use the "-info p" option the output file will contain:\r
+\r
+    +----------------------------------------------------------------------+\r
+    |#if 0                                                                 |\r
+    |                                                                      |\r
+    |The following predicates are identical when compared without          |\r
+    |  lookahead context information.  For some ambiguous lookahead        |\r
+    |  sequences they may not have any power to resolve the ambiguity.     |\r
+    |                                                                      |\r
+    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 1 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  Upper>>?                                              |\r
+    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |      pred  <<  Lower>>?                                              |\r
+    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |  The predicate for choice 1 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 1  t10.g               |\r
+    |                                                                      |\r
+    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 2  t10.g               |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 2 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |  pred  <<  Alpha>>?                                                  |\r
+    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
+    |    set context:                                                      |\r
+    |       ID                                                             |\r
+    |                                                                      |\r
+    |  The predicate for choice 2 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |  OR expr                                                             |\r
+    |                                                                      |\r
+    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 1  t10.g                 |\r
+    |                                                                      |\r
+    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 2  t10.g                 |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |#endif                                                                |\r
+    +----------------------------------------------------------------------+\r
+\r
+      The comparison of the predicates for the two alternatives takes\r
+      place without context information, which means that in some cases\r
+      the predicates will be considered identical even though they operate\r
+      on disjoint lookahead sets.  Consider:\r
+\r
+            #pred Alpha\r
+\r
+            rule1: <<Alpha>>? ID\r
+                 | <<Alpha>>? Label\r
+                 ;\r
+\r
+      Because the comparison of predicates takes place without context\r
+      these will be considered identical.  The reason for comparing\r
+      without context is that otherwise it would be necessary to re-evaluate\r
+      the entire predicate expression for each possible lookahead sequence.\r
+      This would require more code to be written and more CPU time during\r
+      grammar analysis, and it is not yet clear whether anyone will even make\r
+      use of the new #pred facility.\r
+\r
+      A temporary workaround might be to use different #pred statements\r
+      for predicates you know have different context.  This would avoid\r
+      extraneous warnings.\r
+\r
+      The above example might be termed a "false positive".  Comparison\r
+      without context will also lead to "false negatives".  Consider the\r
+      following example:\r
+\r
+            #pred Alpha\r
+            #pred Beta\r
+\r
+            rule1: <<Alpha>>? A\r
+                 | rule2\r
+                 ;\r
+\r
+            rule2: <<Alpha>>? A\r
+                 | <<Beta>>?  B\r
+                 ;\r
+\r
+      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
+      appears to be different than the predicate Alpha used for alt1.\r
+      However, the context of Beta is B.  Thus when the lookahead is A\r
+      Beta will have no resolving power and Alpha will be used for both\r
+      alternatives.  Using the same predicate for both alternatives isn't\r
+      very helpful, but this will not be detected with 1.33MR11.\r
+\r
+      To properly handle this the predicate expression would have to be\r
+      evaluated for each distinct lookahead context.\r
+\r
+      To determine whether two predicate expressions are identical is\r
+      difficult.  The routine may fail to identify identical predicates.\r
+\r
+      The #pred feature also compares predicates to see if a choice between\r
+      alternatives which is resolved by a predicate which makes the second\r
+      choice unreachable.  Consider the following example:\r
+\r
+            #pred A         <<A(LATEXT(1)>>?\r
+            #pred B         <<B(LATEXT(1)>>?\r
+            #pred A_or_B    A || B\r
+\r
+            r   : s\r
+                | t\r
+                ;\r
+            s   : <<A_or_B>>? ID\r
+                ;\r
+            t   : <<A>>? ID\r
+                ;\r
+\r
+        ----------------------------------------------------------------------------\r
+        t11.g, line 5: warning: the predicate used to disambiguate the\r
+               first choice of  rule r\r
+             (file t11.g alt 1 line 5 and alt 2 line 6)\r
+             appears to "cover" the second predicate when compared without context.\r
+             The second predicate may have no resolving power for some lookahead\r
+               sequences.\r
+        ----------------------------------------------------------------------------\r
+\r
+#139. (Changed in MR11) Problem with -gp in C++ mode\r
+\r
+      The -gp option to add a prefix to rule names did not work in\r
+      C++ mode.  This has been fixed.\r
+\r
+      Reported by Alexey Demakov (demakov@kazbek.ispras.ru).\r
+\r
+#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems\r
+\r
+      Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for\r
+      building antlr and dlg with Win95/NT development tools that\r
+      are not based on MSVC5.  They are pccts/antlr/AntlrMS.mak and\r
+      pccts/dlg/DlgMS.mak.\r
+\r
+      The first line of the makefiles require a definition of PCCTS_HOME.\r
+\r
+      These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*\r
+      supplied by Jeff Vincent (JVincent@novell.com).\r
+\r
+#137. (Changed in MR11) Token getType(), getText(), getLine() const members\r
+\r
+      --------------------------------------------------------------------\r
+      If you use ANTLRCommonToken this change probably does not affect you.\r
+      --------------------------------------------------------------------\r
+\r
+      For a long time it has bothered me that these accessor functions\r
+      in ANTLRAbstractToken were not const member functions.  I have\r
+      refrained from changing them because it require users to modify\r
+      existing token class definitions which are derived directly\r
+      from ANTLRAbstractToken.  I think it is now time.\r
+\r
+      For those who are not used to C++, a "const member function" is a\r
+      member function which does not modify its own object - the thing\r
+      to which "this" points. This is quite different from a function\r
+      which does not modify its arguments\r
+\r
+      Most token definitions based on ANTLRAbstractToken have something like\r
+      the following in order to create concrete definitions of the pure\r
+      virtual methods in ANTLRAbstractToken:\r
+\r
+        class MyToken : public ANTLRAbstractToken {\r
+            ...\r
+            ANTLRTokenType getType() {return _type; }\r
+            int getLine()            {return _line; }\r
+            ANTLRChar * getText()    {return _text; }\r
+            ...\r
+        }\r
+\r
+      The required change is simply to put "const" following the function\r
+      prototype in the header (.h file) and the definition file (.cpp if\r
+      it is not inline):\r
+\r
+        class MyToken : public ANTLRAbstractToken {\r
+            ...\r
+            ANTLRTokenType getType() const {return _type; }\r
+            int getLine() const            {return _line; }\r
+            ANTLRChar * getText() const    {return _text; }\r
+            ...\r
+        }\r
+\r
+      This was originally proposed a long time ago by Bruce\r
+      Guenter (bruceg@qcc.sk.ca).\r
+\r
+#136. (Changed in MR11) Added getLength() to ANTLRCommonToken\r
+\r
+      Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken\r
+      now have a member function:\r
+\r
+            int getLength() const { return strlen(getText()) }\r
+\r
+      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
+\r
+#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k\r
+\r
+#134a. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
+\r
+       There is a typographical error in the definition of BITWISEOREQ:\r
+\r
+        #token BITWISEOREQ "!=" should be "\|="\r
+\r
+       When this change is combined with the bugfix to the follow set cache\r
+       problem (Item #147) and a minor rearrangement of the grammar\r
+       (Item #134b) it becomes a k=1 ck=2 grammar.\r
+\r
+#134b. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
+\r
+      The following changes were made in the ansi.g grammar (along with\r
+      using -mrhoist on):\r
+\r
+        ansi.g\r
+        ======\r
+        void tracein(char *)     ====>    void tracein(const char *)\r
+        void traceout(char *)    ====>    void traceout(const char *)\r
+\r
+        <LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?\r
+        ====> <<isTypeName(LT(1)->getText())>>?\r
+\r
+        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
+                        isTypeName(LT(2)->getText()) : 1>>?\r
+        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
+\r
+        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
+                        isTypeName(LT(2)->getText()) : 1>>?\r
+        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
+\r
+        added to init(): traceOptionValueDefault=0;\r
+        added to init(): traceOption(-1);\r
+\r
+        change rule "statement":\r
+\r
+            statement\r
+                :   plain_label_statement\r
+                |   case_label_statement\r
+                |   <<;>> expression SEMICOLON\r
+                |   compound_statement\r
+                |   selection_statement\r
+                |   iteration_statement\r
+                |   jump_statement\r
+                |   SEMICOLON\r
+                ;\r
+\r
+            plain_label_statement\r
+                :   IDENTIFIER COLON statement\r
+                ;\r
+\r
+            case_label_statement\r
+                :   CASE constant_expression COLON statement\r
+                |   DEFAULT COLON statement\r
+            ;\r
+\r
+        support.cpp\r
+        ===========\r
+        void tracein(char *)     ====>    void tracein(const char *)\r
+        void traceout(char *)    ====>    void traceout(const char *)\r
+\r
+        added to tracein():  ANTLRParser::tracein(r);  // call superclass method\r
+        added to traceout(): ANTLRParser::traceout(r); // call superclass method\r
+\r
+        Makefile\r
+        ========\r
+        added to AFLAGS: -mrhoist on -prc on\r
+\r
+#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser\r
+\r
+      In checking T.J. Parr's ANSI C grammar for compatibility with\r
+      1.33MR11 discovered that it was inconvenient to have the\r
+      trace facilities with protected access.\r
+\r
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
+\r
+      Prior to 1.33MR11, there would be no ambiguity warning when the\r
+      very same predicate was used to disambiguate both alternatives:\r
+\r
+        test: ref B\r
+            | ref C\r
+            ;\r
+\r
+        ref : <<pred(LATEXT(1)>>? A\r
+\r
+      In 1.33MR11 this will cause the warning:\r
+\r
+        warning: the predicates used to disambiguate rule test\r
+            (file v98.g alt 1 line 1 and alt 2 line 2)\r
+             are identical and have no resolving power\r
+\r
+        -----------------  Note  -----------------\r
+\r
+          This is different than the following case\r
+\r
+                test: <<pred(LATEXT(1))>>? A B\r
+                    | <<pred(LATEXT(1)>>?  A C\r
+                    ;\r
+\r
+          In this case there are two distinct predicates\r
+          which have exactly the same text.  In the first\r
+          example there are two references to the same\r
+          predicate.  The problem represented by this\r
+          grammar will be addressed later.\r
+\r
+#131. (Changed in 1.33MR11) Case insensitive command line options\r
+\r
+      Command line switches like "-CC" and keywords like "on", "off",\r
+      and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.\r
+\r
+#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string\r
+\r
+      The ANTLR_VERSION was not an integer, making it difficult to\r
+      perform conditional compilation based on the antlr version.\r
+\r
+      Henceforth, ANTLR_VERSION will be:\r
+\r
+            (base_version * 10000) + release number\r
+\r
+            thus 1.33MR11 will be: 133*100+11 = 13311\r
+\r
+      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).\r
+\r
+#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h\r
+\r
+      The following code is now inserted into <parserName>.h amd\r
+      stdpccts.h:\r
+\r
+            #ifndef ANTLR_VERSION\r
+            #define ANTLR_VERSION 13311\r
+            #endif\r
+\r
+      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)\r
+\r
+#128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+\r
+\r
+      Prior to 1.33MR11, the following grammar would generate\r
+      redundant tests for the "while" condition.\r
+\r
+        rule2 : (<<pred>>? X)+ X\r
+              | B\r
+              ;\r
+\r
+      The code would resemble:\r
+\r
+            if (LA(1)==X) {\r
+                if (pred) {\r
+                    do {\r
+                        if (!pred) {zzfailed_pred("  pred");}\r
+                        zzmatch(X); zzCONSUME;\r
+                    } while (LA(1)==X && pred && pred);\r
+            } else {...\r
+\r
+      With 1.33MR11 the redundant predicate test is omitted.\r
+\r
+#127. (Changed in 1.33MR11)\r
+\r
+                    Count Syntax Errors     Count DLG Errors\r
+                    -------------------     ----------------\r
+\r
+       C++ mode     ANTLRParser::           DLGLexerBase::\r
+                      syntaxErrCount          lexErrCount\r
+       C mode       zzSyntaxErrCount        zzLexErrCount\r
+\r
+       The C mode variables are global and initialized to 0.\r
+       They are *not* reset to 0 automatically when antlr is\r
+       restarted.\r
+\r
+       The C++ mode variables are public.  They are initialized\r
+       to 0 by the constructors.  They are *not* reset to 0 by the\r
+       ANTLRParser::init() method.\r
+\r
+       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
+\r
+#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
+\r
+       The #first <<...>> inserts the specified text in the output\r
+       files before any other #include statements required by pccts.\r
+       The only things before the #first text are comments and\r
+       a #define ANTLR_VERSION.\r
+\r
+       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
+       Zoltan (alexin@inf.u-szeged.hu).\r
+\r
+#125. (Changed in 1.33MR11) Lookahead for (guard)? && <<p>>? predicates\r
+\r
+       When implementing the new style of guard predicate (Item #113)\r
+       in 1.33MR10 I decided to temporarily ignore the problem of\r
+       computing the "narrowest" lookahead context.\r
+\r
+       Consider the following k=1 grammar:\r
+\r
+            start : a\r
+                  | b\r
+                  ;\r
+\r
+            a     : (A)? && <<pred1(LATEXT(1))>>? ab ;\r
+            b     : (B)? && <<pred2(LATEXT(1))>>? ab ;\r
+\r
+            ab    : A | B ;\r
+\r
+       In MR10 the context for both "a" and "b" was {A B} because this is\r
+       the first set of rule "ab".  Normally, this is not a problem because\r
+       the predicate which follows the guard inhibits any ambiguity report\r
+       by antlr.\r
+\r
+       In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}.\r
+\r
+#124. A Note on the New "&&" Style Guarded Predicates\r
+\r
+        I've been asked several times, "What is the difference between\r
+        the old "=>" style guard predicates and the new style "&&" guard\r
+        predicates, and how do you choose one over the other" ?\r
+\r
+        The main difference is that the "=>" does not apply the\r
+        predicate if the context guard doesn't match, whereas\r
+        the && form always does.  What is the significance ?\r
+\r
+        If you have a predicate which is not on the "leading edge"\r
+        it is cannot be hoisted.  Suppose you need a predicate that\r
+        looks at LA(2).  You must introduce it manually.  The\r
+        classic example is:\r
+\r
+            castExpr :\r
+                     LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     | STRUCT ID\r
+                     ;\r
+\r
+        The problem  is that isTypeName() isn't on the leading edge\r
+        of typeName, so it won't be hoisted into castExpr to help\r
+        make a decision on which production to choose.\r
+\r
+        The *first* attempt to fix it is this:\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        Unfortunately, this won't work because it ignores\r
+        the problem of STRUCT.  The solution is to apply\r
+        isTypeName() in castExpr if LA(2) is an ID and\r
+        don't apply it when LA(2) is STRUCT:\r
+\r
+            castExpr :\r
+                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        In conclusion, the "=>" style guarded predicate is\r
+        useful when:\r
+\r
+            a. the tokens required for the predicate\r
+               are not on the leading edge\r
+            b. there are alternatives in the expression\r
+               selected by the predicate for which the\r
+               predicate is inappropriate\r
+\r
+        If (b) were false, then one could use a simple\r
+        predicate (assuming "-prc on"):\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     ;\r
+\r
+        So, when do you use the "&&" style guarded predicate ?\r
+\r
+        The new-style "&&" predicate should always be used with\r
+        predicate context.  The context guard is in ADDITION to\r
+        the automatically computed context.  Thus it useful for\r
+        predicates which depend on the token type for reasons\r
+        other than context.\r
+\r
+        The following example is contributed by Reinier van den Born\r
+        (reinier@vnet.ibm.com).\r
+\r
+ +-------------------------------------------------------------------------+\r
+ | This grammar has two ways to call functions:                            |\r
+ |                                                                         |\r
+ |  - a "standard" call syntax with parens and comma separated args        |\r
+ |  - a shell command like syntax (no parens and spacing separated args)   |\r
+ |                                                                         |\r
+ | The former also allows a variable to hold the name of the function,     |\r
+ | the latter can also be used to call external commands.                  |\r
+ |                                                                         |\r
+ | The grammar (simplified) looks like this:                               |\r
+ |                                                                         |\r
+ |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is function name */              |\r
+ |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is var containing fun name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   command    : ID expr*          /* ID is function name */              |\r
+ |              | path expr*        /* path is external command name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   path       : ID                /* left out slashes and such */        |\r
+ |              | "@" ID            /* ID is environment var */            |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   expr       : ....                                                     |\r
+ |              | "(" expr ")";                                            |\r
+ |                                                                         |\r
+ |   call       : fun_call                                                 |\r
+ |              | command                                                  |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | Obviously the call is wildly ambiguous. This is more or less how this   |\r
+ | is to be resolved:                                                      |\r
+ |                                                                         |\r
+ |    A call begins with an ID or an @ followed by an ID.                  |\r
+ |                                                                         |\r
+ |    If it is an ID and if it is an ext. command name  -> command         |\r
+ |                       if followed by a paren         -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ |    If it is an @  and if the ID is a var name        -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ | One can implement these rules quite neatly using && predicates:         |\r
+ |                                                                         |\r
+ |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
+ |              | (ID)?     && <<isExtCmdName>>?     command               |\r
+ |              | (ID "(")?                          fun_call              |\r
+ |              |                                    command               |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | This can be done better, so it is not an ideal example, but it          |\r
+ | conveys the principle.                                                  |\r
+ +-------------------------------------------------------------------------+\r
+\r
+#123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h\r
+\r
+        The return value of operators in ANTLRTokenPtr:\r
+\r
+        changed: unsigned ... operator !=(...)\r
+             to: int ... operator != (...)\r
+        changed: unsigned ... operator ==(...)\r
+             to: int ... operator == (...)\r
+\r
+        Suggested by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
+\r
+         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
+         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
+\r
+        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#121. (Changed in 1.33MR11)  Another attempt to fix -o (output dir) option\r
+\r
+      Another attempt is made to improve the -o option of antlr, dlg,\r
+      and sorcerer.  This one by JVincent (JVincent@novell.com).\r
+\r
+      The current rule:\r
+\r
+        a. If -o  is not specified than any explicit directory\r
+           names are retained.\r
+\r
+        b. If -o is specified than the -o directory name overrides any\r
+           explicit directory names.\r
+\r
+        c. The directory name of the grammar file is *not* stripped\r
+           to create the main output file.  However it is stil subject\r
+           to override by the -o directory name.\r
+\r
+#120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr\r
+\r
+      Added option 0 (e.g. "-info 0") which is a noop.\r
+\r
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
+\r
+      The user can ask for additional information on ambiguities reported\r
+      by antlr to stdout.  At the moment, only one ambiguity report can\r
+      be created in an antlr run.\r
+\r
+      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
+\r
+      The following options control the reporting of ambiguities:\r
+\r
+          -aa ruleName       Selects reporting by name of rule\r
+          -aa lineNumber     Selects reporting by line number\r
+                               (file name not compared)\r
+\r
+          -aam               Selects "multiple" reporting for a token\r
+                             in the intersection set of the\r
+                             alternatives.\r
+\r
+                             For instance, the token ID may appear dozens\r
+                             of times in various paths as the program\r
+                             explores the rules which are reachable from\r
+                             the point of an ambiguity. With option -aam\r
+                             every possible path the search program\r
+                             encounters is reported.\r
+\r
+                             Without -aam only the first encounter is\r
+                             reported.  This may result in incomplete\r
+                             information, but the information may be\r
+                             sufficient and much shorter.\r
+\r
+          -aad depth         Selects the depth of the search.\r
+                             The default value is 1.\r
+\r
+                             The number of paths to be searched, and the\r
+                             size of the report can grow geometrically\r
+                             with the -ck value if a full search for all\r
+                             contributions to the source of the ambiguity\r
+                             is explored.\r
+\r
+                             The depth represents the number of tokens\r
+                             in the lookahead set which are matched against\r
+                             the set of ambiguous tokens.  A depth of 1\r
+                             means that the search stops when a lookahead\r
+                             sequence of just one token is matched.\r
+\r
+                             A k=1 ck=6 grammar might generate 5,000 items\r
+                             in a report if a full depth 6 search is made\r
+                             with the Ambiguity Aid.  The source of the\r
+                             problem may be in the first token and obscured\r
+                             by the volume of data - I hesitate to call\r
+                             it information.\r
+\r
+                             When the user selects a depth > 1, the search\r
+                             is first performed at depth=1 for both\r
+                             alternatives, then depth=2 for both alternatives,\r
+                             etc.\r
+\r
+      Sample output for rule grammar in antlr.g itself:\r
+\r
+  +---------------------------------------------------------------------+\r
+  | Ambiguity Aid                                                       |\r
+  |                                                                     |\r
+  |   Choice 1: grammar/70                 line 632  file a.g           |\r
+  |   Choice 2: grammar/82                 line 644  file a.g           |\r
+  |                                                                     |\r
+  |   Intersection of lookahead[1] sets:                                |\r
+  |                                                                     |\r
+  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
+  |  2 to error                       grammar/73       line 635   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/74       line 636   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
+  |  2 to class_def                   grammar/75       line 637   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
+  |  2 to error                       grammar/93       line 655   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/94       line 656   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
+  |  2 to class_def                   grammar/95       line 657   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
+  +---------------------------------------------------------------------+\r
+\r
+      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
+      when all lookahead sets [i] with i<k all have degree one) the\r
+      reports appear in the following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          for (alternative=1; alternative <=2 ; alternative++) {\r
+            while (matches-are-found) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      For reporting a k-tuple ambiguity, the reports appear in the\r
+      following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          while (matches-are-found) {\r
+            for (alternative=1; alternative <=2 ; alternative++) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      This is because matches are generated in different ways for\r
+      linear lookahead and k-tuples.\r
+\r
+#118. (Changed in 1.33MR11) DEC VMS makefile and VMS related changes\r
+\r
+      Revised makefiles for DEC/VMS operating system for antlr, dlg,\r
+      and sorcerer.\r
+\r
+      Reduced names of routines with external linkage to less than 32\r
+      characters to conform to DEC/VMS linker limitations.\r
+\r
+      Jean-Francois Pieronne discovered problems with dlg and antlr\r
+      due to the VMS linker not being case sensitive for names with\r
+      external linkage.  In dlg the problem was with "className" and\r
+      "ClassName".  In antlr the problem was with "GenExprSets" and\r
+      "genExprSets".\r
+\r
+      Added genmms, a version of genmk for the DEC/VMS version of make.\r
+      The source is in directory pccts/support/DECmms.\r
+\r
+      All VMS contributions by Jean-Francois Pieronne (jfp@iname.com).\r
+\r
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
+\r
+      The hoisting of predicates into rules to create prediction\r
+      expressions is a problem in antlr.  Consider the following\r
+      example (k=1 with -prc on):\r
+\r
+        start   : (a)* "@" ;\r
+        a       : b | c ;\r
+        b       : <<isUpper(LATEXT(1))>>? A ;\r
+        c       : A ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if (LA(1)==A &&\r
+                    (!LA(1)==A || isUpper())) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      This code is wrong because it makes rule "c" unreachable from\r
+      "start".  The essence of the problem is that antlr fails to\r
+      recognize that there can be a valid alternative within "a" even\r
+      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
+\r
+      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
+      "start" is suppressed because it recognizes that "c" can\r
+      cover all the cases where the predicate is false:\r
+\r
+        while {\r
+            if (LA(1)==A) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate suppression in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where\r
+            the predicate is false.\r
+\r
+           WITH predicate: line 7  v1.g\r
+           WITHOUT predicate: line 7  v1.g\r
+\r
+        The context set for the predicate:\r
+\r
+             A\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 9  v1.g\r
+            set context:\r
+               A\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 5 v1.g) to rule a\r
+            #1  in rule a (line 7 v1.g)\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      A predicate can be suppressed by a combination of alternatives\r
+      which, taken together, cover a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b | ca | cb | cc ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
+\r
+        ca      : A ;\r
+        cb      : B ;\r
+        cc      : C ;\r
+\r
+      Consider a more complex example in which "c" covers only part of\r
+      a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b\r
+                | c\r
+                ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>?\r
+                    ( A\r
+                    | X\r
+                    );\r
+\r
+        c       : A\r
+                ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
+      the non-covered lookahead.  The code resembles:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                  (! (LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate restriction in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Restricting the context of a predicate because of overlap\r
+          in the lookahead set between the alternative with the\r
+          semantic predicate and one without\r
+        Without this restriction the alternative without the predicate\r
+          could not be reached when input matched the context of the\r
+          predicate and the predicate was false.\r
+\r
+           WITH predicate: line 11  v4.g\r
+           WITHOUT predicate: line 12  v4.g\r
+\r
+        The original context set for the predicate:\r
+\r
+             A                X\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The intersection of the two sets\r
+\r
+             A\r
+\r
+        The original predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               A                X\r
+            tree context: null\r
+\r
+        The new (modified) form of the predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      The bad news about -mrhoist:\r
+\r
+        (a) -mrhoist does not analyze predicates with lookahead\r
+            depth > 1.\r
+\r
+        (b) -mrhoist does not look past a guarded predicate to\r
+            find context which might cover other predicates.\r
+\r
+      For these cases you might want to use syntactic predicates.\r
+      When a semantic predicate fails during guess mode the guess\r
+      fails and the next alternative is tried.\r
+\r
+      Limitation (a) is illustrated by the following example:\r
+\r
+        start    : (stmt)* EOF ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+\r
+      This is not much different from the first example, except that\r
+      it requires two tokens of lookahead context to determine what\r
+      to do.  This predicate is NOT suppressed because the current version\r
+      is unable to handle predicates with depth > 1.\r
+\r
+      A predicate can be combined with other predicates during hoisting.\r
+      In those cases the depth=1 predicates are still handled.  Thus,\r
+      in the following example the isUpper() predicate will be suppressed\r
+      by line #4 when hoisted from "bizarre" into "start", but will still\r
+      be present in "bizarre" in order to predict "stmt".\r
+\r
+        start    : (bizarre)* EOF ;     // #1\r
+                                        // #2\r
+        bizarre  : stmt                 // #3\r
+                 | A                    // #4\r
+                 ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+                 | <<isUpper(LATEXT(1))>>? A\r
+\r
+      Limitation (b) is illustrated by the following example of a\r
+      context guarded predicate:\r
+\r
+        rule : (A)? <<p>>?          // #1\r
+                     (A             // #2\r
+                     |B             // #3\r
+                     )              // #4\r
+             | <<q>> B              // #5\r
+             ;\r
+\r
+      Recall that this means that when the lookahead is NOT A then\r
+      the predicate "p" is ignored and it attempts to match "A|B".\r
+      Ideally, the "B" at line #3 should suppress predicate "q".\r
+      However, the current version does not attempt to look past\r
+      the guard predicate to find context which might suppress other\r
+      predicates.\r
+\r
+      In some cases -mrhoist will lead to the reporting of ambiguities\r
+      which were not visible before:\r
+\r
+        start   : (a)* "@";\r
+        a       : bc | d;\r
+        bc      : b  | c ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? A;\r
+        c       : A ;\r
+\r
+        d       : A ;\r
+\r
+      In this case there is a true ambiguity in "a" between "bc" and "d"\r
+      which can both match "A".  Without -mrhoist the predicate in "b"\r
+      is hoisted into "a" and there is no ambiguity reported.  However,\r
+      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
+      should be) making the ambiguity in "a" apparent.\r
+\r
+      The motivations for these changes were hoisting problems reported\r
+      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
+\r
+#116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *)\r
+\r
+      The prototype for C++ mode routine tracein (and traceout) has changed from\r
+      "char *" to "const char *".\r
+\r
+#115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode\r
+\r
+      The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig\r
+      neglected to consider guess mode.  When control passed to the rule's\r
+      parse exception handler the routine would exit without ever closing the\r
+      guess block. This would lead to unpredictable behavior.\r
+\r
+      In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be\r
+      identical.\r
+\r
+#114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes\r
+\r
+      There was a slight difference in the way C and C++ mode resynchronized\r
+      following a parsing error.  The C routine would sometimes skip an extra\r
+      token before attempting to resynchronize.\r
+\r
+      The C routine was changed to match the C++ routine.\r
+\r
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
+\r
+      The existing context guarded predicate:\r
+\r
+            rule : (guard)? => <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      generates code which resembles:\r
+\r
+            if (lookahead(expr) && (!guard || pred)) {\r
+              expr()\r
+            } else ....\r
+\r
+      This is not suitable for some applications because it allows\r
+      expr() to be invoked when the predicate is false.  This is\r
+      intentional because it is meant to mimic automatically computed\r
+      predicate context.\r
+\r
+      The new context guarded predicate uses the guard information\r
+      differently because it has a different goal.  Consider:\r
+\r
+            rule : (guard)? && <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      The new style of context guarded predicate is equivalent to:\r
+\r
+            rule : <<guard==true && pred>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      It generates code which resembles:\r
+\r
+            if (lookahead(expr) && guard && pred) {\r
+                expr();\r
+            } else ...\r
+\r
+      Both forms of guarded predicates severely restrict the form of\r
+      the context guard: it can contain no rule references, no\r
+      (...)*, no (...)+, and no {...}.  It may contain token and\r
+      token class references, and alternation ("|").\r
+\r
+      Addition for 1.33MR11: in the token expression all tokens must\r
+      be at the same height of the token tree:\r
+\r
+            (A ( B | C))? && ...            is ok (all height 2)\r
+            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
+            (A B C D | E F G H)? && ...     is ok (all height 4)\r
+            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
+\r
+      This restriction is required in order to properly compute the lookahead\r
+      set for expressions like:\r
+\r
+            rule1 : (A B C)? && <<pred>>? rule2 ;\r
+            rule2 : (A|X) (B|Y) (C|Z);\r
+\r
+      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
+\r
+#112. (Changed in 1.33MR10) failed validation predicate in C guess mode\r
+\r
+      John Lilley (jlilley@empathy.com) suggested that failed validation\r
+      predicates abort a guess rather than reporting a failed error.\r
+      This was installed in C++ mode (Item #4).  Only now was it noticed\r
+      that the fix was never installed for C mode.\r
+\r
+#111. (Changed in 1.33MR10) moved zzTRACEIN to before init action\r
+\r
+      When the antlr -gd switch is present antlr generates calls to\r
+      zzTRACEIN at the start of a rule and zzTRACEOUT at the exit\r
+      from a rule.  Prior to 1.33MR10 Tthe call to zzTRACEIN was\r
+      after the init-action, which could cause confusion because the\r
+      init-actions were reported with the name of the enclosing rule,\r
+      rather than the active rule.\r
+\r
+#110. (Changed in 1.33MR10) antlr command line copied to generated file\r
+\r
+      The antlr command line is now copied to the generated file near\r
+      the start.\r
+\r
+#109. (Changed in 1.33MR10) improved trace information\r
+\r
+      The quality of the trace information provided by the "-gd"\r
+      switch has been improved significantly.  Here is an example\r
+      of the output from a test program.  It shows the rule name,\r
+      the first token of lookahead, the call depth, and the guess\r
+      status:\r
+\r
+        exit rule gusxx {"?"} depth 2\r
+        enter rule gusxx {"?"} depth 2\r
+        enter rule gus1 {"o"} depth 3 guessing\r
+        guess done - returning to rule gus1 {"o"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        exit rule gus1 {"Z"} depth 3 guessing\r
+        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
+        enter rule gus1 {"o"} depth 3\r
+        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
+        exit rule gus1 {"Z"} depth 3\r
+        line 1: syntax error at "Z" missing SC\r
+            ...\r
+\r
+      Rule trace reporting is controlled by the value of the integer\r
+      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
+      otherwise it is disabled.  Tracing during guess mode is controlled\r
+      by the value of the integer [zz]traceGuessOptionValue.  When\r
+      it is positive AND [zz]traceOptionValue is positive rule trace\r
+      is reported in guess mode.\r
+\r
+      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
+      can be adjusted by subroutine calls listed below.\r
+\r
+      Depending on the presence or absence of the antlr -gd switch\r
+      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
+      the parser is initialized or [zz]traceReset() is called the\r
+      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
+      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
+      but, as noted earlier, nothing will be reported unless\r
+      [zz]traceOptionValue is also positive.\r
+\r
+      When the parser state is saved/restored the value of the trace\r
+      variables are also saved/restored.  If a restore causes a change in\r
+      reporting behavior from on to off or vice versa this will be reported.\r
+\r
+      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
+      is added to appropriate output files.\r
+\r
+        C++ mode\r
+        --------\r
+        int     traceOption(int delta)\r
+        int     traceGuessOption(int delta)\r
+        void    traceReset()\r
+        int     traceOptionValueDefault\r
+\r
+        C mode\r
+        --------\r
+        int     zzTraceOption(int delta)\r
+        int     zzTraceGuessOption(int delta)\r
+        void    zzTraceReset()\r
+        int     zzTraceOptionValueDefault\r
+\r
+      The argument "delta" is added to the traceOptionValue.  To\r
+      turn on trace when inside a particular rule one:\r
+\r
+        rule : <<traceOption(+1);>>\r
+               (\r
+                rest-of-rule\r
+               )\r
+               <<traceOption(-1);>>\r
+       ;  /* fail clause */ <<traceOption(-1);>>\r
+\r
+      One can use the same idea to turn *off* tracing within a\r
+      rule by using a delta of (-1).\r
+\r
+      An improvement in the rule trace was suggested by Sramji\r
+      Ramanathan (ps@kumaran.com).\r
+\r
+#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
+\r
+                            NOTE\r
+        ------------------------------------------------------\r
+        This mechanism only works for heap allocated variables\r
+        ------------------------------------------------------\r
+\r
+      The rewrite of the trace provides the machinery necessary\r
+      to properly free variables or undo actions following a\r
+      failed guess.\r
+\r
+      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
+      as part of the zzGUESS macro.  When a guess is opened\r
+      the value of zzrv is 0.  When a longjmp() is executed to\r
+      undo the guess, the value of zzrv will be 1.\r
+\r
+      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
+      as part of the zzGUESS_DONE macro.  This is executed\r
+      whether the guess succeeds or fails as part of closing\r
+      the guess.\r
+\r
+      The guessSeq is a sequence number which is assigned to each\r
+      guess and is incremented by 1 for each guess which becomes\r
+      active.  It is needed by the user to associate the start of\r
+      a guess with the failure and/or completion (closing) of a\r
+      guess.\r
+\r
+      Guesses are nested.  They must be closed in the reverse\r
+      of the order that they are opened.\r
+\r
+      In order to free memory used by a variable during a guess\r
+      a user must write a routine which can be called to\r
+      register the variable along with the current guess sequence\r
+      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
+      fails, all variables tagged with the corresponding guess\r
+      sequence number should be released.  This is ugly, but\r
+      it would require a major rewrite of antlr 1.33 to use\r
+      some mechanism other than setjmp()/longjmp().\r
+\r
+      The order of calls for a *successful* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The order of calls for a *failed* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_HOOK(guessSeq,1);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The default definitions of these macros are empty strings.\r
+\r
+      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
+      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
+      can be used without change in both C and C++ versions.\r
+\r
+      ----------------------------------------------------------------------\r
+        <<\r
+\r
+        #include "AToken.h"\r
+\r
+        typedef ANTLRCommonToken ANTLRToken;\r
+\r
+        #include "DLGLexer.h"\r
+\r
+        int main() {\r
+\r
+          {\r
+            DLGFileInput     in(stdin);\r
+            DLGLexer         lexer(&in,2000);\r
+            ANTLRTokenBuffer pipe(&lexer,1);\r
+            ANTLRCommonToken aToken;\r
+            P                parser(&pipe);\r
+\r
+            lexer.setToken(&aToken);\r
+            parser.init();\r
+            parser.start();\r
+          };\r
+\r
+          fclose(stdin);\r
+          fclose(stdout);\r
+          return 0;\r
+        }\r
+\r
+        >>\r
+\r
+        <<\r
+        char *s=NULL;\r
+\r
+        #undef zzUSER_GUESS_HOOK\r
+        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
+        #undef zzUSER_GUESS_DONE_HOOK\r
+        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
+\r
+        void myGuessHook(int guessSeq,int zzrv) {\r
+          if (zzrv == 0) {\r
+            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
+          } else if (zzrv == 1) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
+          } else if (zzrv == 2) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
+          };\r
+        }\r
+\r
+        >>\r
+\r
+        #token A    "a"\r
+        #token      "[\t \ \n]"     <<skip();>>\r
+\r
+        class P {\r
+\r
+        start : (top)+\r
+              ;\r
+\r
+        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
+              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
+              ; <<if (s != NULL) free(s); s=NULL; >>\r
+\r
+        which : which2\r
+              ;\r
+\r
+        which2 : which3\r
+              ;\r
+        which3\r
+              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
+              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
+              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
+              ;\r
+\r
+        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
+\r
+        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
+\r
+        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
+\r
+        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
+\r
+        }\r
+      ----------------------------------------------------------------------\r
+\r
+      This is a silly example, but illustrates the idea.  For the input\r
+      "a ::" with tracing enabled the output begins:\r
+\r
+      ----------------------------------------------------------------------\r
+        enter rule "start" depth 1\r
+        enter rule "top" depth 2\r
+        User hook: starting guess #1\r
+        enter rule "which" depth 3 guessing\r
+        enter rule "which2" depth 4 guessing\r
+        enter rule "which3" depth 5 guessing\r
+        User hook: starting guess #2\r
+        enter rule "label" depth 6 guessing\r
+        guess failed\r
+        User hook: failed guess #2\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #2\r
+        User hook: starting guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        exit rule "which3" depth 5 guessing\r
+        exit rule "which2" depth 4 guessing\r
+        exit rule "which" depth 3 guessing\r
+        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
+        User hook: ending guess #1\r
+        enter rule "which" depth 3\r
+        .....\r
+      ----------------------------------------------------------------------\r
+\r
+      Remember:\r
+\r
+        (a) Only init-actions are executed during guess mode.\r
+        (b) A rule can be invoked multiple times during guess mode.\r
+        (c) If the guess succeeds the rule will be called once more\r
+              without guess mode so that normal actions will be executed.\r
+            This means that the init-action might need to distinguish\r
+              between guess mode and non-guess mode using the variable\r
+              [zz]guessing.\r
+\r
+#107. (Changed in 1.33MR10) construction of ASTs in guess mode\r
+\r
+      Prior to 1.33MR10, when using automatic AST construction in C++\r
+      mode for a rule, an AST would be constructed for elements of the\r
+      rule even while in guess mode.  In MR10 this no longer occurs.\r
+\r
+#106. (Changed in 1.33MR10) guess variable confusion\r
+\r
+      In C++ mode a guess which failed always restored the parser state\r
+      using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10,\r
+      C mode required an explicit call to zzGUESS_DONE after the\r
+      call to zzGUESS_FAIL.\r
+\r
+      Consider:\r
+\r
+        rule : (alpha)? beta\r
+             | ...\r
+             ;\r
+\r
+      The generated code resembles:\r
+\r
+            zzGUESS\r
+            if (!zzrv && LA(1)==ID) {   <==== line #1\r
+                alpha\r
+                zzGUESS_DONE\r
+                beta\r
+            } else {\r
+              if (! zzrv) zzGUESS_DONE  <==== line #2a\r
+              ....\r
+\r
+      However, in some cases line #2 was rendered:\r
+\r
+              if (guessing) zzGUESS_DONE  <==== line #2b\r
+\r
+      This would work for simple test cases, but would fail in\r
+      some cases where there was a guess while another guess was active.\r
+      One kind of failure would be to match up the zzGUESS_DONE at line\r
+      #2b with the "outer" guess which was still active.  The outer\r
+      guess would "succeed" when only the inner guess should have\r
+      succeeded.\r
+\r
+      In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and\r
+      and C++ mode should be identical.\r
+\r
+      The same problem appears in 1.33 vanilla in some places.  For\r
+      example:\r
+\r
+            start : { (sub)? } ;\r
+\r
+      or:\r
+\r
+            start : (\r
+                       B\r
+                    |  ( sub )?\r
+                    |  C\r
+                    )+\r
+                    ;\r
+\r
+      generates incorrect code.\r
+\r
+      The general principle is:\r
+\r
+        (a) use [zz]guessing only when deciding between a call to zzFAIL\r
+              or zzGUESS_FAIL\r
+\r
+        (b) use zzrv in all other cases\r
+\r
+      This problem was discovered while testing changes to item #105.\r
+      I believe this is now fixed.  My apologies.\r
+\r
+#105. (Changed in 1.33MR10) guess block as single alt of (...)+\r
+\r
+      Prior to 1.33MR10 the following constructs:\r
+\r
+        rule_plus : (\r
+                       (sub)?\r
+                    )+\r
+                    ;\r
+\r
+        rule_star : (\r
+                      (sub)?\r
+                    )*\r
+                    ;\r
+\r
+      generated incorrect code for the guess block (which could result\r
+      in runtime errors) because of an incorrect optimization of a\r
+      block with only a single alternative.\r
+\r
+      The fix caused some changes to the fix described in Item #49\r
+      because there are now three code generation sequences for (...)+\r
+      blocks containing a guess block:\r
+\r
+        a. single alternative which is a guess block\r
+        b. multiple alternatives in which the last is a guess block\r
+        c. all other cases\r
+\r
+      Forms like "rule_star" can have unexpected behavior when there\r
+      is a syntax error: if the subrule "sub" is not matched *exactly*\r
+      then "rule_star" will consume no tokens.\r
+\r
+      Reported by Esa Pulkkinen (esap@cs.tut.fi).\r
+\r
+#104. (Changed in 1.33MR10) -o option for dlg\r
+\r
+      There was problem with the code added by item #74 to handle the\r
+      -o option of dlg.  This should fix it.\r
+\r
+#103. (Changed in 1.33MR10) ANDed semantic predicates\r
+\r
+      Rescinded.\r
+\r
+      The optimization was a mistake.\r
+      The resulting problem is described in Item #150.\r
+\r
+#102. (Changed in 1.33MR10) allow "class parser : .... {"\r
+\r
+      The syntax of the class statement ("class parser-name {")\r
+      has been extended to allow for the specification of base\r
+      classes.  An arbirtrary number of tokens may now appear\r
+      between the class name and the "{".  They are output\r
+      again when the class declaration is generated.  For\r
+      example:\r
+\r
+        class Parser : public MyBaseClassANTLRparser {\r
+\r
+      This was suggested by a user, but I don't have a record\r
+      of who it was.\r
+\r
+#101. (Changed in 1.33MR10) antlr -info command line switch\r
+\r
+        -info\r
+\r
+            p   - extra predicate information in generated file\r
+\r
+            t   - information about tnode use:\r
+                    at the end of each rule in generated file\r
+                    summary on stderr at end of program\r
+\r
+            m   - monitor progress\r
+                    prints name of each rule as it is started\r
+                    flushes output at start of each rule\r
+\r
+            f   - first/follow set information to stdout\r
+\r
+            0   - no operation (added in 1.33MR11)\r
+\r
+      The options may be combined and may appear in any order.\r
+      For example:\r
+\r
+        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
+\r
+#100a. (Changed in 1.33MR10) Predicate tree simplification\r
+\r
+      When the same predicates can be referenced in more than one\r
+      alternative of a block large predicate trees can be formed.\r
+\r
+      The difference that these optimizations make is so dramatic\r
+      that I have decided to use it even when -mrhoist is not selected.\r
+\r
+      Consider the following grammar:\r
+\r
+        start : ( all )* ;\r
+\r
+        all   : a\r
+              | d\r
+              | e\r
+              | f\r
+              ;\r
+\r
+        a     : c A B\r
+              | c A C\r
+              ;\r
+\r
+        c     : <<AAA(LATEXT(2))>>?\r
+              ;\r
+\r
+        d     : <<BBB(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        e     : <<CCC(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        f     : e X Y\r
+              ;\r
+\r
+      In rule "a" there is a reference to rule "c" in both alternatives.\r
+      The length of the predicate AAA is k=2 and it can be followed in\r
+      alternative 1 only by (A B) while in alternative 2 it can be\r
+      followed only by (A C).  Thus they do not have identical context.\r
+\r
+      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
+      elimination of the duplicate reference to predicate CCC.\r
+\r
+      The table below summarized the kind of simplification performed by\r
+      1.33MR10.  In the table, X and Y stand for single predicates\r
+      (not trees).\r
+\r
+        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
+        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
+\r
+        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
+        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
+        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
+        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
+\r
+        (AND X)               => X\r
+        (OR X)                => X\r
+\r
+      In a test with a complex grammar for a real application, a predicate\r
+      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
+\r
+      In 1.33MR10 there is a greater effort to release memory used\r
+      by predicates once they are no longer in use.\r
+\r
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
+\r
+      The following optimizations require that -mrhoist be selected.\r
+\r
+      It is relatively easy to optimize the code generated for predicate\r
+      gates when they are of the form:\r
+\r
+            (AND X Y Z ...)\r
+        or  (OR  X Y Z ...)\r
+\r
+      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
+      predicate trees.\r
+\r
+      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
+      ANDed together to create a single Tree context for the group and\r
+      context tests for the individual predicates are suppressed:\r
+\r
+            --------------------------------------------------\r
+            Note: This was incorrect.  The contexts should be\r
+            ORed together.  This has been fixed.  A more \r
+            complete description is available in item #152.\r
+            ---------------------------------------------------\r
+\r
+      Optimization 1:  (AND X Y Z ...)\r
+\r
+        Suppose the context for Xtest is LA(1)==LP and the context for\r
+        Ytest is LA(1)==LP && LA(2)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
+                        ( (! LA(1)==LP || Xtest) &&\r
+                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
+                        )) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
+\r
+      Optimization 2: (OR X Y Z ...) with identical contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is also LA(1)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==ID) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==ID && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
+\r
+      Optimization 3: (OR X Y Z ...) with distinct contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is LA(1)==LP.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==LP) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==LP && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                        (zzpf=0,\r
+                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
+                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
+                            !zzpf) {\r
+\r
+            These may appear to be of similar complexity at first,\r
+            but the non-optimized version contains two tests of each\r
+            context while the optimized version contains only one\r
+            such test, as well as eliminating some of the inverted\r
+            logic (" !(...) || ").\r
+\r
+      Optimization 4: Computation of predicate gate trees\r
+\r
+        When generating code for the gates of predicate expressions\r
+        antlr 1.33 vanilla uses a recursive procedure to generate\r
+        "&&" and "||" expressions for testing the lookahead. As each\r
+        layer of the predicate tree is exposed a new set of "&&" and\r
+        "||" expressions on the lookahead are generated.  In many\r
+        cases the lookahead being tested has already been tested.\r
+\r
+        With -mrhoist a lookahead tree is computed for the entire\r
+        lookahead expression.  This means that predicates with identical\r
+        context or context which is a subset of another predicate's\r
+        context disappear.\r
+\r
+        This is especially important for predicates formed by rules\r
+        like the following:\r
+\r
+            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
+            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
+\r
+        These predicates are combined using AND since both must be\r
+        satisfied for rule upperCaseVowel.  They have identical\r
+        context which makes this optimization very effective.\r
+\r
+      The affect of Items #100a and #100b together can be dramatic.  In\r
+      a very large (but real world) grammar one particular predicate\r
+      expression was reduced from an (unreadable) 50 predicate leaves,\r
+      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
+      3 predicate leaves (all different) and a *single* LA(1) term.\r
+\r
+#99.  (Changed in 1.33MR10) Code generation for expression trees\r
+\r
+      Expression trees are used for k>1 grammars and predicates with\r
+      lookahead depth >1.  This optimization must be enabled using\r
+      "-mrhoist on".  (Clarification added for 1.33MR11).\r
+\r
+      In the processing of expression trees, antlr can generate long chains\r
+      of token comparisons.  Prior to 1.33MR10 there were many redundant\r
+      parenthesis which caused problems for compilers which could handle\r
+      expressions of only limited complexity.  For example, to test an\r
+      expression tree (root R A B C D), antlr would generate something\r
+      resembling:\r
+\r
+        (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D)))))\r
+\r
+      If there were twenty tokens to test then there would be twenty\r
+      parenthesis at the end of the expression.\r
+\r
+      In 1.33MR10 the generated code for tree expressions resembles:\r
+\r
+        (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D))\r
+\r
+      For "complex" expressions the output is indented to reflect the LA\r
+      number being tested:\r
+\r
+        (LA(1)==R\r
+            && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D\r
+               || LA(2)==E || LA(2)==F)\r
+        || LA(1)==S\r
+            && (LA(2)==G || LA(2)==H))\r
+\r
+\r
+      Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl),\r
+\r
+#98.  (Changed in 1.33MR10) Option "-info p"\r
+\r
+      When the user selects option "-info p" the program will generate\r
+      detailed information about predicates.  If the user selects\r
+      "-mrhoist on" additional detail will be provided explaining\r
+      the promotion and suppression of predicates.  The output is part\r
+      of the generated file and sandwiched between #if 0/#endif statements.\r
+\r
+      Consider the following k=1 grammar:\r
+\r
+        start : ( all ) * ;\r
+\r
+        all   : ( a\r
+                | b\r
+                )\r
+                ;\r
+\r
+        a     : c B\r
+              ;\r
+\r
+        c     : <<LATEXT(1)>>?\r
+              | B\r
+              ;\r
+\r
+        b     : <<LATEXT(1)>>? X\r
+              ;\r
+\r
+      Below is an excerpt of the output for rule "start" for the three\r
+      predicate options (off, on, and maintenance release style hoisting).\r
+\r
+      For those who do not wish to use the "-mrhoist on" option for code\r
+      generation the option can be used in a "diagnostic" mode to provide\r
+      valuable information:\r
+\r
+            a. where one should insert null actions to inhibit hoisting\r
+            b. a chain of rule references which shows where predicates are\r
+               being hoisted\r
+\r
+      ======================================================================\r
+      Example of "-info p" with "-mrhoist on"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where the\r
+           predicate is false.\r
+\r
+           WITH predicate: line 11  v36.g\r
+           WITHOUT predicate: line 12  v36.g\r
+\r
+        The context set for the predicate:\r
+\r
+             B\r
+\r
+        The lookahead set for alt WITHOUT the semantic predicate:\r
+\r
+             B\r
+\r
+        The predicate:\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 1 v36.g) to rule all\r
+            #1  in rule all (line 3 v36.g) to rule a\r
+            #2  in rule a (line 8 v36.g) to rule c\r
+            #3  in rule c (line 11 v36.g)\r
+\r
+        #endif\r
+        &&\r
+        #if 0\r
+\r
+        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+          set context:\r
+             X\r
+          tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p"  with the default -prc setting ( "-prc off")\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p" with "-prc on" and "-mrhoist off"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+\r
+#97.  (Fixed in 1.33MR10) "Predicate applied for more than one ... "\r
+\r
+      In 1.33 vanilla, the grammar listed below produced this message for\r
+      the first alternative (only) of rule "b":\r
+\r
+            warning: predicate applied for >1 lookahead 1-sequences\r
+                [you may only want one lookahead 1-sequence to apply.\r
+                Try using a context guard '(...)? =>'\r
+\r
+      In 1.33MR10 the message is issued for both alternatives.\r
+\r
+          top     : (a)*;\r
+          a       : b | c ;\r
+\r
+          b       : <<PPP(LATEXT(1))>>? ( AAA | BBB )\r
+                  | <<QQQ(LATEXT(1))>>? ( XXX | YYY )\r
+                  ;\r
+\r
+          c       : AAA | XXX;\r
+\r
+#96.  (Fixed in 1.33MR10) Guard predicates ignored when -prc off\r
+\r
+      Prior to 1.33MR10, guard predicate code was not generated unless\r
+      "-prc on" was selected.\r
+\r
+      This was incorrect, since "-prc off"  (the default) is supposed to\r
+      disable only AUTOMATIC computation of predicate context, not the\r
+      programmer specified context supplied by guard predicates.\r
+\r
+#95.  (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck)\r
+\r
+      Prior to 1.33MR10, predicate guards were computed to k tokens rather\r
+      than max(k,ck).  Consider the following grammar:\r
+\r
+        a     : ( A B C)? => <<AAA(LATEXT(1))>>? (A|X) (B|Y) (C|Z) ;\r
+\r
+      The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on"\r
+      for the predicate in "a" resembles:\r
+\r
+        if ( (! LA(1)==A) || AAA(LATEXT(1))) {...\r
+\r
+      With 1.33MR10 and the same options the code resembles:\r
+\r
+        if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {...\r
+\r
+#94.  (Fixed in 1.33MR10) Predicates followed by rule references\r
+\r
+      Prior to 1.33MR10, a semantic predicate which referenced a token\r
+      which was off the end of the rule caused an incomplete context\r
+      to be computed (with "-prc on") for the predicate under some circum-\r
+      stances.  In some cases this manifested itself as illegal C code\r
+      (e.g. "LA(2)==[Ep](1)" in the k=2 examples below:\r
+\r
+          all     : ( a ) *;\r
+\r
+          a       : <<AAA(LATEXT(2))>>? ID X\r
+                  | <<BBB(LATEXT(2))>>? Y\r
+                  | Z\r
+                  ;\r
+\r
+      This might also occur when the semantic predicate was followed\r
+      by a rule reference which was shorter than the length of the\r
+      semantic predicate:\r
+\r
+        all       : ( a ) *;\r
+\r
+        a         : <<AAA(LATEXT(2))>>? ID X\r
+                  | <<BBB(LATEXT(2))>>? y\r
+                  | Z\r
+                  ;\r
+\r
+        y         : Y ;\r
+\r
+      Depending on circumstance, the resulting context might be too\r
+      generous because it was too short, or too restrictive because\r
+      of missing alternatives.\r
+\r
+#93.  (Changed in 1.33MR10) Definition of Purify macro\r
+\r
+      Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition\r
+      for the Purify macro:\r
+\r
+        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
+\r
+      Note: This may not be the right thing to do for C++ objects that\r
+      have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
+\r
+      For those cases one should #define PURIFY to an empty macro in the\r
+      #header or #first actions.\r
+\r
+#92.  (Fixed in 1.33MR10) Guarded predicates and hoisting\r
+\r
+      When a guarded predicate participates in hoisting it is linked into\r
+      a predicate expression tree.  Prior to 1.33MR10 this link was never\r
+      cleared and the next time the guard was used to construct a new\r
+      tree the link could contain a spurious reference to another element\r
+      which had previosly been joined to it in the semantic predicate tree.\r
+\r
+      For example:\r
+\r
+        start  : ( all ) *;\r
+        all    : ( a | b ) ;\r
+\r
+        start2 : ( all2 ) *;\r
+        all2    : ( a ) ;\r
+\r
+        a     : (A)? => <<AAA(LATEXT(1))>>?  A ;\r
+        b     : (B)? => <<BBB(LATEXT(1))>>?  B ;\r
+\r
+      Prior to 1.33MR10 the code for "start2" would include a spurious\r
+      reference to the BBB predicate which was left from constructing\r
+      the predicate tree for rule "start" (i.e. or(AAA,BBB) ).\r
+\r
+      In 1.33MR10 this problem is avoided by cloning the original guard\r
+      each time it is linked into a predicate tree.\r
+\r
+#91.  (Changed in 1.33MR10) Extensive changes to semantic pred hoisting\r
+\r
+            ============================================\r
+            This has been rendered obsolete by Item #117\r
+            ============================================\r
+\r
+#90.  (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck)\r
+\r
+      There is a bug in antlr 1.33 vanilla and all maintenance releases\r
+      prior to 1.33MR10 which allows semantic predicates to reference\r
+      an LT(i) or LATEXT(i) where i is larger than max(k,ck).  When\r
+      this occurs antlr will attempt to mark the ith element of an array\r
+      in which there are only max(k,ck) elements.  The result cannot\r
+      be predicted.\r
+\r
+      Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error\r
+      in 1.33MR10.\r
+\r
+#89.  Rescinded\r
+\r
+#88.  (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode\r
+\r
+        Consider the behavior of a semantic predicate during guess mode:\r
+\r
+            rule : a:A (\r
+                         <<test($a)>>? b:B\r
+                         | c:C\r
+                       );\r
+\r
+        Prior to MR10 the assignment of the token or attribute to\r
+        $a did not occur during guess mode, which would cause the\r
+        semantic predicate to misbehave because $a would be null.\r
+\r
+        In 1.33MR10 a semantic predicate with a reference to an\r
+        element label (such as $a) forces the assignment to take\r
+        place even in guess mode.\r
+\r
+        In order to work, this fix REQUIRES use of the $label format\r
+        for token pointers and attributes referenced in semantic\r
+        predicates.\r
+\r
+        The fix does not apply to semantic predicates using the\r
+        numeric form to refer to attributes (e.g. <<test($1)>>?).\r
+        The user will receive a warning for this case.\r
+\r
+        Reported by Rob Trout (trout@mcs.cs.kent.edu).\r
+\r
+#87.  (Fixed in 1.33MR10) Malformed guard predicates\r
+\r
+      Context guard predicates may contain only references to\r
+      tokens.  They may not contain references to (...)+ and\r
+      (...)* blocks.  This is now checked.  This replaces the\r
+      fatal error message in item #78 with an appropriate\r
+      (non-fatal) error messge.\r
+\r
+      In theory, context guards should be allowed to reference\r
+      rules.  However, I have not had time to fix this.\r
+      Evaluation of the guard takes place before all rules have\r
+      been read, making it difficult to resolve a forward reference\r
+      to rule "zzz" - it hasn't been read yet !  To postpone evaluation\r
+      of the guard until all rules have been read is too much\r
+      for the moment.\r
+\r
+#86.  (Fixed in 1.33MR10) Unequal set size in set_sub\r
+\r
+      Routine set_sub() in pccts/support/set/set.h  did not work\r
+      correctly when the sets were of unequal sizes.  Rewrote\r
+      set_equ to make it simpler and remove unnecessary and\r
+      expensive calls to set_deg().  This routine was not used\r
+      in 1.33 vanila.\r
+\r
+#85.  (Changed in 1.33MR10) Allow redefinition of MaxNumFiles\r
+\r
+      Raised the maximum number of input files to 99 from 20.\r
+      Put a #ifndef/#endif around the "#define MaxNumFiles 99".\r
+\r
+#84.  (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE\r
+\r
+      Initialize zzBadTok to NULL in zzRULE macro of AParser.h.\r
+      in order to get rid of warning messages.\r
+\r
+#83.  (Fixed in 1.33MR10) False warnings with -w2 for #tokclass\r
+\r
+      When -w2 is selected antlr gives inappropriate warnings about\r
+      #tokclass names not having any associated regular expressions.\r
+      Since a #tokclass is not a "real" token it will never have an\r
+      associated regular expression and there should be no warning.\r
+\r
+      Reported by Derek Pappas (derek.pappas@eng.sun.com)\r
+\r
+#82.  (Fixed in 1.33MR10) Computation of follow sets with multiple cycles\r
+\r
+      Reinier van den Born (reinier@vnet.ibm.com) reported a problem\r
+      in the computation of follow sets by antlr.  The problem (bug)\r
+      exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10.\r
+\r
+      The problem involves the computation of follow sets when there are\r
+      cycles - rules which have mutual references.  I believe the problem\r
+      is restricted to cases where there is  more than one cycle AND\r
+      elements of those cycles have rules in common.  Even when this\r
+      occurs it may not affect the code generated - but it might.  It\r
+      might also lead to undetected ambiguities.\r
+\r
+      There were no changes in antlr or dlg output from the revised version.\r
+\r
+      The following fragment demonstates the problem by giving different\r
+      follow sets (option -pa) for var_access when built with k=1 and ck=2 on\r
+      1.33 vanilla and 1.33MR10:\r
+\r
+        echo_statement : ECHO ( echo_expr )*\r
+                       ;\r
+\r
+        echo_expr      : ( command )?\r
+                       | expression\r
+                       ;\r
+\r
+        command        : IDENTIFIER\r
+                             { concat }\r
+                       ;\r
+\r
+        expression     : operand ( OPERATOR operand )*\r
+                       ;\r
+\r
+        operand        : value\r
+                       | START command END\r
+                       ;\r
+\r
+        value          : concat\r
+                       | TYPE operand\r
+                       ;\r
+\r
+        concat         : var_access { CONCAT value }\r
+                       ;\r
+\r
+        var_access     : IDENTIFIER { INDEX }\r
+\r
+                       ;\r
+#81.  (Changed in 1.33MR10) C mode use of attributes and ASTs\r
+\r
+       Reported by Isaac Clark (irclark@mindspring.com).\r
+\r
+       C mode code ignores attributes returned by rules which are\r
+       referenced using element labels when ASTs are enabled (-gt option).\r
+\r
+         1. start : r:rule t:Token <<$start=$r;>>\r
+\r
+                The $r refrence will not work when combined with\r
+                the -gt option.\r
+\r
+         2. start : t:Token         <<$start=$t;>>\r
+\r
+                The $t reference works in all cases.\r
+\r
+         3. start : rule            <<$0=$1;>>\r
+\r
+                Numeric labels work in all cases.\r
+\r
+       With MR10 the user will receive an error message for case 1 when\r
+       the -gt option is used.\r
+\r
+#80.  (Fixed in 1.33MR10) (...)? as last alternative of block\r
+\r
+        A construct like the following:\r
+\r
+            rule : a\r
+                 | (b)?\r
+                 ;\r
+\r
+        does not make sense because there is no alternative when\r
+        the guess block fails.  This is now reported as a warning\r
+        to the user.\r
+\r
+        Previously, there was a code generation error for this case:\r
+        the guess block was not "closed"  when the guess failed.\r
+        This could cause an infinite loop or other problems.  This\r
+        is now fixed.\r
+\r
+        Example problem:\r
+\r
+            #header<<\r
+            #include <stdio.h>\r
+            #include "charptr.h"\r
+            >>\r
+\r
+            <<\r
+            #include "charptr.c"\r
+            main ()\r
+            {\r
+             ANTLR(start(),stdin);\r
+            }\r
+            >>\r
+\r
+            #token "[\ \t]+"        << zzskip(); >>\r
+            #token "[\n]"           << zzline++; zzskip(); >>\r
+\r
+            #token Word     "[a-z]+"\r
+            #token Number   "[0-9]+"\r
+\r
+\r
+            start : (test1)?\r
+                  | (test2)?\r
+                  ;\r
+            test1 : (Word Word Word Word)?\r
+                  | (Word Word Word Number)?\r
+                  ;\r
+            test2 : (Word Word Number Word)?\r
+                  | (Word Word Number Number)?\r
+            ;\r
+\r
+        Test data which caused infinite loop:\r
+\r
+            a 1 a a\r
+\r
+#79.  (Changed in 1.33MR10) Use of -fh with multiple parsers\r
+\r
+        Previously, antlr always used the pre-processor symbol\r
+        STDPCCTS_H as a gate for the file stdpccts.h.  This\r
+        caused problems when there were multiple parsers defined\r
+        because they used the same gate symbol.\r
+\r
+        In 1.33MR10, the -fh filename is used to generate the\r
+        gate file for stdpccts.h.  For instance:\r
+\r
+            antlr -fh std_parser1.h\r
+\r
+        generates the pre-processor symbol "STDPCCTS_std_parser1_H".\r
+\r
+        Reported by Ramanathan Santhanam (ps@kumaran.com).\r
+\r
+#78.  (Changed in 1.33MR9) Guard predicates that refer to rules\r
+\r
+                ------------------------\r
+                Please refer to Item #87\r
+                ------------------------\r
+\r
+        Guard predicates are processed during an early phase\r
+        of antlr (during parsing) before all data structures\r
+        are completed.\r
+\r
+        There is an apparent bug in earlier versions of 1.33\r
+        which caused guard predicates which contained references\r
+        to rules (rather than tokens) to reference a structure\r
+        which hadn't yet been initialized.\r
+\r
+        In some cases (perhaps all cases) references to rules\r
+        in guard predicates resulted in the use of "garbage".\r
+\r
+#79.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Previously, the maximum length file name was set\r
+        arbitrarily to 300 characters in antlr, dlg, and sorcerer.\r
+\r
+        The config.h file now attempts to define the maximum length\r
+        filename using _MAX_PATH from stdlib.h before falling back\r
+        to using the value 300.\r
+\r
+#78.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Put #ifndef/#endif around definition of ZZLEXBUFSIZE in\r
+        antlr.\r
+\r
+#77.  (Changed in 1.33MR9) Arithmetic overflow for very large grammars\r
+\r
+        In routine HandleAmbiguities() antlr attempts to compute the\r
+        number of possible elements in a set that is order of\r
+        number-of-tokens raised to the number-of-lookahead-tokens power.\r
+        For large grammars or large lookahead (e.g. -ck 7) this can\r
+        cause arithmetic overflow.\r
+\r
+        With 1.33MR9, arithmetic overflow in this computation is reported\r
+        the first time it happens.  The program continues to run and\r
+        the program branches based on the assumption that the computed\r
+        value is larger than any number computed by counting actual cases\r
+        because 2**31 is larger than the number of bits in most computers.\r
+\r
+        Before 1.33MR9 overflow was not reported.  The behavior following\r
+        overflow is not predictable by anyone but the original author.\r
+\r
+                            NOTE\r
+\r
+            In 1.33MR10 the warning message is suppressed.\r
+            The code which detects the overflow allows the\r
+            computation to continue without an error.  The\r
+            error message itself made made users worry.\r
+\r
+#76.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Jeff Vincent has convinced me to make ANTLRCommonToken and\r
+        ANTLRCommonNoRefCountToken use variable length strings\r
+        allocated from the heap rather than fixed length strings.\r
+        By suitable definition of setText(), the copy constructor,\r
+        and operator =() it is possible to maintain "copy" semantics.\r
+        By "copy" semantics I mean that when a token is copied from\r
+        an existing token it receives its own, distinct, copy of the\r
+        text allocated from the heap rather than simply a pointer\r
+        to the original token's text.\r
+\r
+        ============================================================\r
+                        W * A * R * N * I * N * G\r
+        ============================================================\r
+\r
+        It is possible that this may cause problems for some users.\r
+        For those users I have included the old version of AToken.h as\r
+        pccts/h/AToken_traditional.h.\r
+\r
+#75.  (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        Make DLGStringInput const correct.  Since this is infrequently\r
+        subclassed, it should affect few users, I hope.\r
+\r
+#74.  (Changed in 1.33MR9) -o (output directory) option\r
+\r
+        Antlr does not properly handle the -o output directory option\r
+        when the filename of the grammar contains a directory part.  For\r
+        example:\r
+\r
+            antlr -o outdir pccts_src/myfile.g\r
+\r
+        causes antlr create a file called "outdir/pccts_src/myfile.cpp.\r
+        It SHOULD create outdir/myfile.cpp\r
+\r
+        The suggested code fix has been installed in antlr, dlg, and\r
+        Sorcerer.\r
+\r
+#73.  (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist\r
+\r
+            ============================================\r
+            This has been rendered obsolete by Item #117\r
+            ============================================\r
+\r
+#72.  (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX\r
+\r
+        The following methods in ANTLRParser were made virtual at\r
+        the request of S. Bochnak (S.Bochnak@microTool.com.pl):\r
+\r
+            saveState() and restoreState()\r
+            guess(), guess_fail(), and guess_done()\r
+\r
+#71.  (Changed in 1.33MR9) Access to omitted command line argument\r
+\r
+        If a switch requiring arguments is the last thing on the\r
+        command line, and the argument is omitted, antlr would core.\r
+\r
+            antlr test.g -prc\r
+\r
+        instead of\r
+\r
+            antlr test.g -prc off\r
+\r
+#70.  (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files\r
+\r
+        The following MSVC .dsp and .mak files for pccts and sorcerer\r
+        were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl)\r
+        and Jeff Vincent (JVincent@novell.com)\r
+\r
+        PCCTS Distribution Kit\r
+        ----------------------\r
+        pccts/PCCTSMSVC50.dsw\r
+\r
+        pccts/antlr/AntlrMSVC50.dsp\r
+        pccts/antlr/AntlrMSVC50.mak\r
+\r
+        pccts/dlg/DlgMSVC50.dsp\r
+        pccts/dlg/DlgMSVC50.mak\r
+\r
+        pccts/support/msvc.dsp\r
+\r
+        Sorcerer Distribution Kit\r
+        -------------------------\r
+        pccts/sorcerer/SorcererMSVC50.dsp\r
+        pccts/sorcerer/SorcererMSVC50.mak\r
+\r
+        pccts/sorcerer/lib/msvc.dsp\r
+\r
+#69.  (Changed in 1.33MR9) Change "unsigned int" to plain "int"\r
+\r
+       Declaration of max_token_num in misc.c as "unsigned int"\r
+       caused comparison between signed and unsigned ints giving\r
+       warning message without any special benefit.\r
+\r
+#68.  (Changed in 1.33MR9) Add void return for dlg internal_error()\r
+\r
+       Get rid of "no return value" message in internal_error()\r
+       in file dlg/support.c and dlg/dlg.h.\r
+\r
+#67.  (Changed in Sor) sor.g: lisp() has no return value\r
+\r
+       Added a "void" for the return type.\r
+\r
+#66.  (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif\r
+\r
+       A user needed to be able to change the ZZLEXBUFSIZE for\r
+       sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif\r
+\r
+#65.  (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug\r
+\r
+       Jeff Vincent (JVincent@novell.com) found that deepCopy()\r
+       made new copies of only the direct descendents.  No new\r
+       copies were made of sibling nodes,  Sibling pointers are\r
+       set to zero by shallowCopy().\r
+\r
+           PCCTS_AST::deepCopy() has been changed to make a\r
+           deep copy in the traditional sense.\r
+\r
+           The deepCopy() routine depends on the behavior of\r
+           shallowCopy().  In all sor examples I've found,\r
+           shallowCopy() zeroes the right and down pointers.\r
+\r
+       Original Tree       Original deepCopy()     Revised deepCopy\r
+       -------------       -------------------     ----------------\r
+            a->b->c         A                       A\r
+            |               |                       |\r
+            d->e->f         D                       D->E->F\r
+            |               |                       |\r
+            g->h->i         G                       G->H->I\r
+               |                                       |\r
+               j->k                                    J->K\r
+\r
+        While comparing deepCopy() for C++ mode with ast_dup for\r
+        C mode I found a problem with ast_dup().\r
+\r
+           Routine ast_dup() has been changed to make a deep copy\r
+           in the traditional sense.\r
+\r
+       Original Tree       Original ast_dup()      Revised ast_dup()\r
+       -------------       -------------------     ----------------\r
+            a->b->c         A->B->C                 A\r
+            |               |                       |\r
+            d->e->f         D->E->F                 D->E->F\r
+            |               |                       |\r
+            g->h->i         G->H->I                 G->H->I\r
+               |               |                       |\r
+               j->k            J->K                    J->K\r
+\r
+\r
+        I believe this affects transform mode sorcerer programs only.\r
+\r
+#64.  (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable()\r
+\r
+#63.  (Changed in 1.33MR8) h/charptr.h does not zero pointer after free\r
+\r
+        The charptr.h routine now zeroes the pointer after free().\r
+\r
+        Reported by Jens Tingleff (jensting@imaginet.fr)\r
+\r
+#62.  (Changed in 1.33MR8) ANTLRParser::resynch had static variable\r
+\r
+        The static variable "consumed" in ANTLRParser::resynch was\r
+        changed into an instance variable of the class with the\r
+        name "resynchConsumed".\r
+\r
+        Reported by S.Bochnak@microTool.com.pl\r
+\r
+#61.  (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values\r
+\r
+        Previously, the following code would cause antlr to core when\r
+        it tried to generate code for rule1 because rule2 had no return\r
+        values ("upward inheritance"):\r
+\r
+            rule1 : <<int i; int j>>\r
+                    rule2 > [i,j]\r
+                  ;\r
+\r
+            rule2 : Anything ;\r
+\r
+        Reported by S.Bochnak@microTool.com.pl\r
+\r
+        Verified correct operation of antlr MR8 when missing or extra\r
+        inheritance arguments for all combinations.  When there are\r
+        missing or extra arguments code will still be generated even\r
+        though this might cause the invocation of a subroutine with\r
+        the wrong number of arguments.\r
+\r
+#60.  (Changed in 1.33MR7) Major changes to exception handling\r
+\r
+        There were significant problems in the handling of exceptions\r
+        in 1.33 vanilla.  The general problem is that it can only\r
+        process one level of exception handler.  For example, a named\r
+        exception handler, an exception handler for an alternative, or\r
+        an exception for a subrule  always went to the rule's exception\r
+        handler if there was no "catch" which matched the exception.\r
+\r
+        In 1.33MR7 the exception handlers properly "nest".  If an\r
+        exception handler does not have a matching "catch" then the\r
+        nextmost outer exception handler is checked for an appropriate\r
+        "catch" clause, and so on until an exception handler with an\r
+        appropriate "catch" is found.\r
+\r
+        There are still undesirable features in the way exception\r
+        handlers are implemented, but I do not have time to fix them\r
+        at the moment:\r
+\r
+            The exception handlers for alternatives are outside the\r
+            block containing the alternative.  This makes it impossible\r
+            to access variables declared in a block or to resume the\r
+            parse by "falling through".  The parse can still be easily\r
+            resumed in other ways, but not in the most natural fashion.\r
+\r
+            This results in an inconsistentcy between named exception\r
+            handlers and exception handlers for alternatives.  When\r
+            an exception handler for an alternative "falls through"\r
+            it goes to the nextmost outer handler - not the "normal\r
+            action".\r
+\r
+        A major difference between 1.33MR7 and 1.33 vanilla is\r
+        the default action after an exception is caught:\r
+\r
+            1.33 Vanilla\r
+            ------------\r
+            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
+            and the code drops through to the code following the exception.\r
+            For named exception handlers this is the "normal action".\r
+            For alternative exception handlers this is the rule's handler.\r
+\r
+            1.33MR7\r
+            -------\r
+            In 1.33MR7 the signal value is NOT automatically set to zero.\r
+\r
+            There are two cases:\r
+\r
+                For named exception handlers: if the signal value has been\r
+                set to zero the code drops through to the "normal action".\r
+\r
+                For all other cases the code branches to the nextmost outer\r
+                exception handler until it reaches the handler for the rule.\r
+\r
+        The following macros have been defined for convenience:\r
+\r
+            C/C++ Mode Name\r
+            --------------------\r
+            (zz)suppressSignal\r
+                  set signal & return signal arg to 0 ("NoSignal")\r
+            (zz)setSignal(intValue)\r
+                  set signal & return signal arg to some value\r
+            (zz)exportSignal\r
+                  copy the signal value to the return signal arg\r
+\r
+        I'm not sure why PCCTS make a distinction between the local\r
+        signal value and the return signal argument, but I'm loathe\r
+        to change the code. The burden of copying the local signal\r
+        value to the return signal argument can be given to the\r
+        default signal handler, I suppose.\r
+\r
+#59.  (Changed in 1.33MR7) Prototypes for some functions\r
+\r
+        Added prototypes for the following functions to antlr.h\r
+\r
+            zzconsumeUntil()\r
+            zzconsumeUntilToken()\r
+\r
+#58.  (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h\r
+\r
+#57.  (Changed in 1.33MR7) Format of #line directive\r
+\r
+        Previously, the -gl directive for line 1234 would\r
+        resemble:  "# 1234 filename.g".  This caused problems\r
+        for some compilers/pre-processors.  In MR7 it generates\r
+        "#line 1234 filename.g".\r
+\r
+#56.  (Added in 1.33MR7) Jan Mikkelsen <janm@zeta.org.au>\r
+\r
+        Move PURIFY macro invocaton to after rule's init action.\r
+\r
+#55.  (Fixed in 1.33MR7) Unitialized variables in ANTLRParser\r
+\r
+        Member variables inf_labase and inf_last were not initialized.\r
+        (See item #50.)\r
+\r
+#54.  (Fixed in 1.33MR6) Brad Schick (schick@interacess.com)\r
+\r
+        Previously, the following constructs generated the same\r
+        code:\r
+\r
+        rule1 : (A B C)?\r
+              | something-else\r
+              ;\r
+\r
+        rule2 : (A B C)? ()\r
+              | something-else\r
+              ;\r
+\r
+        In all versions of pccts rule1 guesses (A B C) and then\r
+        consume all three tokens if the guess succeeds.  In MR6\r
+        rule2 guesses (A B C)  but consumes NONE of the tokens\r
+        when the guess succeeds because "()" matches epsilon.\r
+\r
+#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
+\r
+        The Book is silent about what happens after an exception\r
+        is caught.\r
+\r
+        The following code fragment prints "Error Action" followed\r
+        by "Normal Action".\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+        ;\r
+\r
+        The reason for "Normal Action" is that the normal flow of the\r
+        program after a user-written exception handler is to "drop through".\r
+        In the case of an exception handler for a rule this results in\r
+        the exection of a "return" statement.  In the case of an\r
+        exception handler attached to an alternative, rule, or token\r
+        this is the code that would have executed had there been no\r
+        exception.\r
+\r
+        The user can achieve the desired result by using a "return"\r
+        statement.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n"); return;>>\r
+        ;\r
+\r
+        The most powerful mechanism for recovery from parse errors\r
+        in pccts is syntactic predicates because they provide\r
+        backtracking.  Exceptions allow "return", "break",\r
+        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
+        changing the _signal value.\r
+\r
+#52.  (Fixed in 1.33MR6) Exceptions without syntactic predicates\r
+\r
+        The following generates bad code in 1.33 if no syntactic\r
+        predicates are present in the grammar.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+\r
+        There is a reference to a guess variable.  In C mode\r
+        this causes a compiler error.  In C++ mode it generates\r
+        an extraneous check on member "guessing".\r
+\r
+        In MR6 correct code is generated for both C and C++ mode.\r
+\r
+#51.  (Added to 1.33MR6) Exception operator "@" used without exceptions\r
+\r
+        In MR6 added a warning when the exception operator "@" is\r
+        used and no exception group is defined.  This is probably\r
+        a case where "\@" or "@" is meant.\r
+\r
+#50.  (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no)\r
+                                    http://www.candleweb.no/~gunnar/\r
+\r
+        Routines zzsave_antlr_state and zzrestore_antlr_state don't\r
+        save and restore all the data needed when switching states.\r
+\r
+        Suggested patch applied to antlr.h and err.h for MR6.\r
+\r
+#49.  (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com)\r
+\r
+        Generated code failed to turn off guess mode when leaving a\r
+        (...)+ block which contained a guess block.  The result was\r
+        an infinite loop.  For example:\r
+\r
+                rule : (\r
+                         (x)?\r
+                         | y\r
+                       )+\r
+\r
+        Suggested code fix implemented in MR6.  Replaced\r
+\r
+            ... else if (zzcnt>1) break;\r
+\r
+        with:\r
+\r
+          C++ mode:\r
+              ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;};\r
+          C mode:\r
+              ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;};\r
+\r
+#48.  (Fixed in 1.33MR6) Invalid exception element causes core\r
+\r
+        A label attached to an invalid construct can cause\r
+        pccts to crash while processing the exception associated\r
+        with the label.  For example:\r
+\r
+        rule : t:(B C)\r
+                exception[t] catch MismatchedToken: <<printf(...);>>\r
+\r
+        Version MR6 generates the message:\r
+\r
+           reference in exception handler to undefined label 't'\r
+\r
+#47.  (Fixed in 1.33MR6) Manuel Ornato\r
+\r
+        Under some circumstances involving a k >1 or ck >1\r
+        grammar and a loop block (i.e.  (...)* ) pccts will\r
+        fail to detect a syntax error and loop indefinitely.\r
+        The problem did not exist in 1.20, but has existed\r
+        from 1.23 to the present.\r
+\r
+        Fixed in MR6.\r
+\r
+        ---------------------------------------------------\r
+        Complete test program\r
+        ---------------------------------------------------\r
+        #header<<\r
+        #include <stdio.h>\r
+        #include "charptr.h"\r
+        >>\r
+\r
+        <<\r
+        #include "charptr.c"\r
+        main ()\r
+        {\r
+         ANTLR(global(),stdin);\r
+        }\r
+        >>\r
+\r
+        #token "[\ \t]+"        << zzskip(); >>\r
+        #token "[\n]"           << zzline++; zzskip(); >>\r
+\r
+        #token B        "b"\r
+        #token C        "c"\r
+        #token D        "d"\r
+        #token E        "e"\r
+        #token LP       "\("\r
+        #token RP       "\)"\r
+\r
+        #token ANTLREOF "@"\r
+\r
+        global : (\r
+                   (E liste)\r
+                 | liste\r
+                 | listed\r
+                 )  ANTLREOF\r
+        ;\r
+\r
+        listeb : LP ( B ( B | C )* ) RP ;\r
+        listec : LP ( C ( B | C )* ) RP ;\r
+        listed : LP ( D ( B | C )* ) RP ;\r
+        liste : ( listeb | listec )* ;\r
+\r
+        ---------------------------------------------------\r
+        Sample data causing infinite loop\r
+        ---------------------------------------------------\r
+        e (d c)\r
+        ---------------------------------------------------\r
+\r
+#46.  (Fixed in 1.33MR6) Robert Richter\r
+                (Robert.Richter@infotech.tu-chemnitz.de)\r
+\r
+        This item from the list of known problems was\r
+        fixed by item #18 (below).\r
+\r
+#45.  (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com)\r
+\r
+        The dependency scanner in VC++ mistakenly sees a\r
+        reference to an MPW #include file even though properly\r
+        #ifdef/#endif in config.h.  The suggested workaround\r
+        has been implemented:\r
+\r
+                #ifdef MPW\r
+                .....\r
+                #define MPW_CursorCtl_Header <CursorCtl.h>\r
+                #include MPW_CursorCtl_Header\r
+                .....\r
+                #endif\r
+\r
+#44.  (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c\r
+\r
+        Added (char *) cast for systems where malloc returns "void *".\r
+\r
+#43.  (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        Add setLeft() and setUp methods to ASTDoublyLinkedBase\r
+        for symmetry with setRight() and setDown() methods.\r
+\r
+#42.  (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca)\r
+\r
+        C++ style comment in antlr.c corrected.\r
+\r
+#41.  (Added in 1.33MR6) antlr -stdout\r
+\r
+        Using "antlr -stdout ..." forces the text that would\r
+        normally go to the grammar.c or grammar.cpp file to\r
+        stdout.\r
+\r
+#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
+\r
+        Using "antlr -tab number ..." changes the tab stops\r
+        for the grammar.c or grammar.cpp file.  The number\r
+        must be between 0 and 8.  Using 0 gives tab characters,\r
+        values between 1 and 8 give the appropriate number of\r
+        space characters.\r
+\r
+#39.  (Fixed in 1.33MR5) Jan Mikkelsen <janm@zeta.org.au>\r
+\r
+        Commas in function prototype still not correct under\r
+        some circumstances.  Suggested code fix installed.\r
+\r
+#38.  (Fixed in 1.33MR5) ANTLRTokenBuffer constructor\r
+\r
+        Have ANTLRTokenBuffer ctor initialize member "parser" to null.\r
+\r
+#37.  (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        In ANTLRParser::FAIL(int k,...) released memory pointed to by\r
+        f[i] (as well as f itself.  Should only free f itself.\r
+\r
+#36.  (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu)\r
+\r
+        Neglected to properly declare isDLGmaxToken() when fixing problem\r
+        reported by Andreas Magnusson.\r
+\r
+        Undo "_retv=NULL;" change which caused problems for return values\r
+        from rules whose return values weren't pointers.\r
+\r
+        Failed to create bin directory if it didn't exist.\r
+\r
+#35.  (Fixed in 1.33MR2) Andreas Magnusson\r
+(Andreas.Magnusson@mailbox.swipnet.se)\r
+\r
+        Repair bug introduced by 1.33MR1 for #tokdefs.  The original fix\r
+        placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum\r
+        in order to fix a problem with an aggresive compiler assigning an 8\r
+        bit enum which might be too narrow.  This caused #tokdefs to assume\r
+        that there were 9999 real tokens.  The repair to the fix causes antlr to\r
+        ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file.\r
+\r
+#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
+\r
+        Previously there was no public function for changing the line\r
+        number maintained by the lexer.\r
+\r
+#33.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
+\r
+        Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE\r
+        in pccts/h/AParser.cpp.\r
+\r
+#32.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
+\r
+        In PCCTSAST.cpp lines 405 and 466:  Change\r
+\r
+                free (t)\r
+           to\r
+                free ( (char *)t );\r
+\r
+        to match prototype.\r
+\r
+#31.   (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer\r
+                        Pointer to parser in DLGLexerBase\r
+\r
+        The ANTLRTokenBuffer class now contains a pointer to the\r
+        parser which is using it.  This is established by the\r
+        ANTLRParser constructor calling ANTLRTokenBuffer::\r
+        setParser(ANTLRParser *p).\r
+\r
+        When ANTLRTokenBuffer::setParser(ANTLRParser *p) is\r
+        called it saves the pointer to the parser and then\r
+        calls ANTLRTokenStream::setParser(ANTLRParser *p)\r
+        so that the lexer can also save a pointer to the\r
+        parser.\r
+\r
+        There is also a function getParser() in each class\r
+        with the obvious purpose.\r
+\r
+        It is possible that these functions will return NULL\r
+        under some circumstances (e.g. a non-DLG lexer is used).\r
+\r
+#30.   (Added to 1.33MR1) function tokenName(int token) standard\r
+\r
+        The generated parser class now includes the\r
+        function:\r
+\r
+          static const ANTLRChar * tokenName(int token)\r
+\r
+        which returns a pointer to the "name" corresponding\r
+        to the token.\r
+\r
+        The base class (ANTLRParser) always includes the\r
+        member function:\r
+\r
+          const ANTLRChar * parserTokenName(int token)\r
+\r
+        which can be accessed by objects which have a pointer\r
+        to an ANTLRParser, but do not know the name of the\r
+        parser class (e.g. ANTLRTokenBuffer and DLGLexerBase).\r
+\r
+#29.   (Added to 1.33MR1) Debugging DLG lexers\r
+\r
+        If the pre-processor symbol DEBUG_LEXER is defined\r
+        then DLexerBase will include code for printing out\r
+        key information about tokens which are recognized.\r
+\r
+        The debug feature of the lexer is controlled by:\r
+\r
+          int previousDebugValue=lexer.debugLexer(newValue);\r
+\r
+                        a value of 0 disables output\r
+                        a value of 1 enables output\r
+\r
+        Even if the lexer debug code is compiled into DLexerBase\r
+        it must be enabled before any output is generated.  For\r
+        example:\r
+\r
+           DLGFileInput         in(stdin);\r
+           MyDLG                lexer(&in,2000);\r
+\r
+           lexer.setToken(&aToken);\r
+\r
+           #if DEBUG_LEXER\r
+             lexer.debugLexer(1);       // enable debug information\r
+           #endif\r
+\r
+#28.   (Added to 1.33MR1) More control over DLG header\r
+\r
+        Version 1.33MR1 adds the following directives to PCCTS\r
+        for C++ mode:\r
+\r
+          #lexprefix  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                after the #include "DLexerBase.h" but\r
+                before the start of the class definition.\r
+\r
+          #lexmember  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                as part of the DLGLexer class body.  It\r
+                appears immediately after the start of\r
+                the class and a "public: statement.\r
+\r
+#27.   (Fixed in 1.33MR1) Comments in DLG actions\r
+\r
+        Previously, DLG would not recognize comments as a special case.\r
+        Thus, ">>" in the comments would cause errors.  This is fixed.\r
+\r
+#26.   (Fixed in 1.33MR1) Removed static variables from error routines\r
+\r
+        Previously, the existence of statically allocated variables\r
+        in some of the parser's member functions posed a danger when\r
+        there was more than one parser active.\r
+\r
+        Replaced with dynamically allocated/freed variables in 1.33MR1.\r
+\r
+#25.  (Fixed in 1.33MR1)  Use of string literals in semantic predicates\r
+\r
+        Previously, it was not possible to place a string literal in\r
+        a semantic predicate because it was not properly "stringized"\r
+        for the report of a failed predicate.\r
+\r
+#24.  (Fixed in 1.33MR1)  Continuation lines for semantic predicates\r
+\r
+        Previously, it was not possible to continue semantic\r
+        predicates across a line because it was not properly\r
+        "stringized" for the report of a failed predicate.\r
+\r
+                rule : <<ifXYZ()>>?[ a very\r
+                                        long statement ]\r
+\r
+#23.  (Fixed in 1.33MR1)  {...} envelope for failed semantic predicates\r
+\r
+        Previously, there was a code generation error for failed\r
+        semantic predicates:\r
+\r
+          rule : <<xyz()>>?[ stmt1; stmt2; ]\r
+\r
+        which generated code which resembled:\r
+\r
+          if (! xyz()) stmt1; stmt2;\r
+\r
+        It now puts the statements in a {...} envelope:\r
+\r
+          if (! xyz()) { stmt1; stmt2; };\r
+\r
+#22.  (Fixed in 1.33MR1)  Continuation of #token across lines using "\"\r
+\r
+        Previously, it was not possible to continue a #token regular\r
+        expression across a line.  The trailing "\" and newline caused\r
+        a newline to be inserted into the regular expression by DLG.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#21.  (Fixed in 1.33MR1)  Use of ">>" (right shift operator in DLG actions\r
+\r
+        It is now possible to use the C++ right shift operator ">>"\r
+        in DLG actions by using the normal escapes:\r
+\r
+                #token "shift-right"     << value=value \>\> 1;>>\r
+\r
+#20.  (Version 1.33/19-Jan-97 Karl Eccleson <karle@microrobotics.co.uk>\r
+                            P.A. Keller (P.A.Keller@bath.ac.uk)\r
+\r
+        There is a problem due to using exceptions with the -gh option.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#19.  (Fixed in 1.33MR1)             Tom Piscotti and John Lilley\r
+\r
+        There were problems suppressing messages to stdin and stdout\r
+        when running in a window environment because some functions\r
+        which uses fprint were not virtual.\r
+\r
+        Suggested change now in 1.33MR1.\r
+\r
+        I believe all functions containing error messages (excluding those\r
+        indicating internal inconsistency) have been placed in functions\r
+        which are virtual.\r
+\r
+#18.  (Version 1.33/ 22-Nov-96)  John Bair (jbair@iftime.com)\r
+\r
+        Under some combination of options a required "return _retv" is\r
+        not generated.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#17.  (Version 1.33/3-Sep-96) Ron House  (house@helios.usq.edu.au)\r
+\r
+        The routine ASTBase::predorder_action omits two "tree->"\r
+        prefixes, which results in the preorder_action belonging\r
+        to the wrong node to be invoked.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#16.  (Version 1.33/7-Jun-96)       Eli Sternheim <eli@interhdl.com>\r
+\r
+        Routine consumeUntilToken() does not check for end-of-file\r
+        condition.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#15.  (Version 1.33/8 Apr 96)   Asgeir Olafsson <olafsson@cstar.ac.com>\r
+\r
+        Problem with tree duplication of doubly linked ASTs in ASTBase.cpp.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#14.  (Version 1.33/28-Feb-96)   Andreas.Magnusson@mailbox.swipnet.se\r
+\r
+        Problem with definition of operator = (const ANTLRTokenPtr rhs).\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#13.  (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com)\r
+\r
+        Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in\r
+        block with destructors.\r
+\r
+        Apparently fixed. Can't locate "goto".\r
+\r
+#12.  (Version 1.33/10-Nov-95)  Minor problems with 1.33 code\r
+\r
+        The following items have been fixed in 1.33MR1:\r
+\r
+          1.  pccts/antlr/main.c line 142\r
+\r
+                "void" appears in classic C code\r
+\r
+          2.  no makefile in support/genmk\r
+\r
+          3.  EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS\r
+\r
+                pccts/h/PCCTSAST.cpp\r
+                pccts/h/DLexerBase.cpp\r
+                pccts/testcpp/6/test.g\r
+\r
+          4.  use of "signed int" isn't accepted by AT&T cfront\r
+\r
+                pccts/h/PCCTSAST.h line 42\r
+\r
+          5.  in call to ANTLRParser::FAIL the var arg err_k is passed as\r
+              "int" but is declared "unsigned int".\r
+\r
+          6.  I believe that a failed validation predicate still does not\r
+              get put in a "{...}" envelope, despite the release notes.\r
+\r
+          7. The #token ">>" appearing in the DLG grammar description\r
+             causes DLG to generate the string literal "\>\>" which\r
+             is non-conforming and will cause some compilers to\r
+             complain (scan.c function act10 line 143 of source code).\r
+\r
+#11.  (Version 1.32b6)  Dave Kuhlman     (dkuhlman@netcom.com)\r
+\r
+        Problem with file close in gen.c.  Already fixed in 1.33.\r
+\r
+#10.  (Version 1.32b6/29-Aug-95)\r
+\r
+        pccts/antlr/main.c contains a C++ style comments on lines 149\r
+        and 176 which causes problems for most C compilers.\r
+\r
+         Already fixed in 1.33.\r
+\r
+#9.   (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h"\r
+\r
+        The file pccts/h/dlgauto.h should probably contain a #include\r
+        "config.h" as it uses the #define symbol __USE_PROTOS.\r
+\r
+        Added to 1.33MR1.\r
+\r
+#8.   (Version 1.32b4/6-Mar-95)  Michael T. Richter (mtr@igs.net)\r
+\r
+        In C++ output mode anonymous tokens from in-line regular expressions\r
+        can create enum values which are too wide for the datatype of the enum\r
+        assigned by the C++ compiler.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#7.   (Version 1.32b4/6-Mar-95)  C++ does not imply __STDC__\r
+\r
+        In err.h the combination of # directives assumes that a C++\r
+        compiler has __STDC__ defined.  This is not necessarily true.\r
+\r
+        This problem also appears in the use of __USE_PROTOS which\r
+        is appropriate for both Standard C and C++ in antlr/gen.c\r
+        and antlr/lex.c\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#6.   (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType"\r
+\r
+        Already fixed in 1.33.\r
+\r
+#5.   (23-Jan-95)        Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil\r
+\r
+        The fail action following a semantic predicate is not enclosed in\r
+        "{...}". This can lead to problems when the fail action contains\r
+        more than one statement.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#4 .  (Version 1.33/31-Mar-96)   jlilley@empathy.com (John Lilley)\r
+\r
+        Put briefly, a semantic predicate ought to abort a guess if it fails.\r
+\r
+        Correction suggested by J. Lilley has been added to 1.33MR1.\r
+\r
+#3 .  (Version 1.33)             P.A.Keller@bath.ac.uk\r
+\r
+        Extra commas are placed in the K&R style argument list for rules\r
+        when using both exceptions and ASTs.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#2.   (Version 1.32b6/2-Oct-95)  Brad Schick <schick@interaccess.com>\r
+\r
+        Construct #[] generates zzastnew() in C++ mode.\r
+\r
+        Already fixed in 1.33.\r
+\r
+#1.   (Version 1.33)     Bob Bailey (robert@oakhill.sps.mot.com)\r
+\r
+        Previously, config.h assumed that all PC systems required\r
+        "short" file names.  The user can now override that\r
+        assumption with "#define LONGFILENAMES".\r
+\r
+        Added to 1.33MR1.\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt
new file mode 100644 (file)
index 0000000..91defae
--- /dev/null
@@ -0,0 +1,2049 @@
+======================================================================\r
+\r
+                       CHANGES_SUMMARY.TXT\r
+\r
+        A QUICK overview of changes from 1.33 in reverse order\r
+\r
+  A summary of additions rather than bug fixes and minor code changes.\r
+\r
+          Numbers refer to items in CHANGES_FROM_133*.TXT\r
+             which may contain additional information.\r
+\r
+                          DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+======================================================================\r
+\r
+#258. You can specify a user-defined base class for your parser\r
+\r
+    The base class must constructor must have a signature similar to\r
+    that of ANTLRParser.\r
+\r
+#253. Generation of block preamble (-preamble and -preamble_first)\r
+\r
+    The antlr option -preamble causes antlr to insert the code\r
+    BLOCK_PREAMBLE at the start of each rule and block.\r
+\r
+    The antlr option -preamble_first is similar, but inserts the\r
+    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
+    PreambleFirst_123 is equivalent to the first set defined by\r
+    the #FirstSetSymbol described in Item #248.\r
+\r
+#248. Generate symbol for first set of an alternative\r
+\r
+        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
+\r
+#216. Defer token fetch for C++ mode\r
+\r
+    When the ANTLRParser class is built with the pre-processor option \r
+    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
+    until LA(i) or LT(i) is called. \r
+\r
+#215. Use reset() to reset DLGLexerBase\r
+#188. Added pccts/h/DLG_stream_input.h\r
+#180. Added ANTLRParser::getEofToken()\r
+#173. -glms for Microsoft style filenames with -gl\r
+#170. Suppression for predicates with lookahead depth >1\r
+\r
+      Consider the following grammar with -ck 2 and the predicate in rule\r
+      "a" with depth 2:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
+                ;\r
+\r
+            b   : A B C\r
+                ;\r
+\r
+      Normally, the predicate would be hoisted into rule r1 in order to\r
+      determine whether to call rule "ab".  However it should *not* be\r
+      hoisted because, even if p is false, there is a valid alternative\r
+      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
+\r
+      If "-info p" command line option is present the following information\r
+      will appear in the generated code:\r
+\r
+                while ( (LA(1)==A)\r
+        #if 0\r
+\r
+        Part (or all) of predicate with depth > 1 suppressed by alternative\r
+            without predicate\r
+\r
+        pred  <<  p(LATEXT(2))>>?\r
+                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
+          tree context:\r
+            (root = A\r
+               B\r
+            )\r
+\r
+        The token sequence which is suppressed: ( A B )\r
+        The sequence of references which generate that sequence of tokens:\r
+\r
+           1 to ab          r1/1       line 1     t1.g\r
+           2 ab             ab/1       line 4     t1.g\r
+           3 to b           ab/2       line 5     t1.g\r
+           4 b              b/1        line 11    t1.g\r
+           5 #token A       b/1        line 11    t1.g\r
+           6 #token B       b/1        line 11    t1.g\r
+\r
+        #endif\r
+\r
+      A slightly more complicated example:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
+                ;\r
+\r
+            b   : <<q(LATEXT(2))>>? D E\r
+                ;\r
+\r
+\r
+      In this case, the sequence (D E) in rule "a" which lies behind\r
+      the guard is used to suppress the predicate with context (D E)\r
+      in rule b.\r
+\r
+                while ( (LA(1)==A || LA(1)==D)\r
+            #if 0\r
+\r
+            Part (or all) of predicate with depth > 1 suppressed by alternative\r
+                without predicate\r
+\r
+            pred  <<  q(LATEXT(2))>>?\r
+                              depth=k=2  rule b  line 11  t2.g\r
+              tree context:\r
+                (root = D\r
+                   E\r
+                )\r
+\r
+            The token sequence which is suppressed: ( D E )\r
+            The sequence of references which generate that sequence of tokens:\r
+\r
+               1 to ab          r1/1       line 1     t2.g\r
+               2 ab             ab/1       line 4     t2.g\r
+               3 to a           ab/1       line 4     t2.g\r
+               4 a              a/1        line 8     t2.g\r
+               5 #token D       a/1        line 8     t2.g\r
+               6 #token E       a/1        line 8     t2.g\r
+\r
+            #endif\r
+            &&\r
+            #if 0\r
+\r
+            pred  <<  p(LATEXT(2))>>?\r
+                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
+              tree context:\r
+                (root = A\r
+                   B\r
+                )\r
+\r
+            #endif\r
+\r
+            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
+                ab();\r
+                ...\r
+\r
+#165. (Changed in MR13) option -newAST\r
+\r
+      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
+      "new AST(ANTLRTokenPtr)".  This option generates a call\r
+      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
+      to define a parser member function to create an AST object.\r
+\r
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
+\r
+#158. (Changed in MR13) #header causes problem for pre-processors\r
+\r
+      A user who runs the C pre-processor on antlr source suggested\r
+      that another syntax be allowed.  With MR13 such directives\r
+      such as #header, #pragma, etc. may be written as "\#header",\r
+      "\#pragma", etc.  For escaping pre-processor directives inside\r
+      a #header use something like the following:\r
+\r
+            \#header\r
+            <<\r
+                \#include <stdio.h>\r
+            >>\r
+\r
+#155. (Changed in MR13) Context behind predicates can suppress\r
+\r
+      With -mrhoist enabled the context behind a guarded predicate can\r
+      be used to suppress other predicates.  Consider the following grammar:\r
+\r
+        r0 : (r1)+;\r
+\r
+        r1  : rp\r
+            | rq\r
+            ;\r
+        rp  : <<p LATEXT(1)>>? B ;\r
+        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
+\r
+      In earlier versions both predicates "p" and "q" would be hoisted into\r
+      rule r0. With MR12c predicate p is suppressed because the context which\r
+      follows predicate q includes "B" which can "cover" predicate "p".  In\r
+      other words, in trying to decide in r0 whether to call r1, it doesn't\r
+      really matter whether p is false or true because, either way, there is\r
+      a valid choice within r1.\r
+\r
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
+\r
+      A common error, even among experienced pccts users, is to code\r
+      an init-action to inhibit hoisting rather than a leading action.\r
+      An init-action does not inhibit hoisting.\r
+\r
+      This was coded:\r
+\r
+        rule1 : <<;>> rule2\r
+\r
+      This is what was meant:\r
+\r
+        rule1 : <<;>> <<;>> rule2\r
+\r
+      With MR13, the user can code:\r
+\r
+        rule1 : <<;>> <<nohoist>> rule2\r
+\r
+      The following will give an error message:\r
+\r
+        rule1 : <<nohoist>> rule2\r
+\r
+      If the <<nohoist>> appears as an init-action rather than a leading\r
+      action an error message is issued.  The meaning of an init-action\r
+      containing "nohoist" is unclear: does it apply to just one\r
+      alternative or to all alternatives ?\r
+\r
+#151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer()\r
+\r
+      You must manually cast the ANTLRTokenStream to your program's\r
+      lexer class. Because the name of the lexer's class is not fixed.\r
+      Thus it is impossible to incorporate it into the DLGLexerBase\r
+      class.\r
+\r
+#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
+\r
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
+\r
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
+\r
+      If there is more than one rule which is not referenced by any\r
+      other rule then all such rules are listed.  This is useful for\r
+      alerting one to rules which are not used, but which can still\r
+      contribute to ambiguity.\r
+\r
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
+\r
+      One can write:\r
+\r
+            #token Plus ("+")             "\+"\r
+            #token RP   ("(")             "\("\r
+            #token COM  ("comment begin") "/\*"\r
+\r
+      The string in parenthesis will be used in syntax error messages.\r
+\r
+#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
+\r
+      It can be difficult to determine which alternatives are causing\r
+      pccts to work hard to resolve an ambiguity.  In some cases the\r
+      ambiguity is successfully resolved after much CPU time so there\r
+      is no message at all.\r
+\r
+      A rough measure of the amount of work being peformed which is\r
+      independent of the CPU speed and system load is the number of\r
+      tnodes created.  Using "-info t" gives information about the\r
+      total number of tnodes created and the peak number of tnodes.\r
+\r
+        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
+\r
+      It also puts in the generated C or C++ file the number of tnodes\r
+      created for a rule (at the end of the rule).  However this\r
+      information is not sufficient to locate the alternatives within\r
+      a rule which are causing the creation of tnodes.\r
+\r
+      Using:\r
+\r
+             antlr -treport 100000 ....\r
+\r
+      causes antlr to list on stdout any alternatives which require the\r
+      creation of more than 100,000 tnodes, along with the lookahead sets\r
+      for those alternatives.\r
+\r
+      The following is a trivial case from the ansi.g grammar which shows\r
+      the format of the report.  This report might be of more interest\r
+      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
+\r
+      -------------------------------------------------------------------------\r
+        There were 0 tuples whose ambiguity could not be resolved\r
+             by full lookahead\r
+        There were 157 tnodes created to resolve ambiguity between:\r
+\r
+          Choice 1: statement/2  line 475  file ansi.g\r
+          Choice 2: statement/3  line 476  file ansi.g\r
+\r
+            Intersection of lookahead[1] sets:\r
+\r
+               IDENTIFIER\r
+\r
+            Intersection of lookahead[2] sets:\r
+\r
+               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
+               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
+               NOT              SIZEOF           OCTALINT         DECIMALINT\r
+               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
+               STRING           CHARACTER\r
+      -------------------------------------------------------------------------\r
+\r
+#143. (Changed in MR11) Optional ";" at end of #token statement\r
+\r
+      Fixes problem of:\r
+\r
+            #token X "x"\r
+\r
+            <<\r
+                parser action\r
+            >>\r
+\r
+      Being confused with:\r
+\r
+            #token X "x" <<lexical action>>\r
+\r
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
+\r
+      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
+      BufFileInput derived from DLGInputStream which provides a\r
+      function lookahead(char *string) to test characters in the\r
+      input stream more than one character ahead.\r
+      The class is located in pccts/h/BufFileInput.* of the kit.\r
+\r
+#140. #pred to define predicates\r
+\r
+      +---------------------------------------------------+\r
+      | Note: Assume "-prc on" for this entire discussion |\r
+      +---------------------------------------------------+\r
+\r
+      A problem with predicates is that each one is regarded as\r
+      unique and capable of disambiguating cases where two\r
+      alternatives have identical lookahead.  For example:\r
+\r
+        rule : <<pred(LATEXT(1))>>? A\r
+             | <<pred(LATEXT(1))>>? A\r
+             ;\r
+\r
+      will not cause any error messages or warnings to be issued\r
+      by earlier versions of pccts.  To compare the text of the\r
+      predicates is an incomplete solution.\r
+\r
+      In 1.33MR11 I am introducing the #pred statement in order to\r
+      solve some problems with predicates.  The #pred statement allows\r
+      one to give a symbolic name to a "predicate literal" or a\r
+      "predicate expression" in order to refer to it in other predicate\r
+      expressions or in the rules of the grammar.\r
+\r
+      The predicate literal associated with a predicate symbol is C\r
+      or C++ code which can be used to test the condition.  A\r
+      predicate expression defines a predicate symbol in terms of other\r
+      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
+      can be defined in terms of a predicate literal, a predicate\r
+      expression, or *both*.\r
+\r
+      When a predicate symbol is defined with both a predicate literal\r
+      and a predicate expression, the predicate literal is used to generate\r
+      code, but the predicate expression is used to check for two\r
+      alternatives with identical predicates in both alternatives.\r
+\r
+      Here are some examples of #pred statements:\r
+\r
+        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
+        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
+        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
+        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
+        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
+\r
+      I hope that the use of EBNF notation to describe the syntax of the\r
+      #pred statement will not cause problems for my readers (joke).\r
+\r
+        predStatement : "#pred"\r
+                            CapitalizedName\r
+                              (\r
+                                  "<<predicate_literal>>?"\r
+                                | "<<predicate_literal>>?"  predOrExpr\r
+                                | predOrExpr\r
+                              )\r
+                      ;\r
+\r
+        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
+\r
+        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
+\r
+        predPrimary   : CapitalizedName\r
+                      | "!" predPrimary\r
+                      | "(" predOrExpr ")"\r
+                      ;\r
+\r
+      What is the purpose of this nonsense ?\r
+\r
+      To understand how predicate symbols help, you need to realize that\r
+      predicate symbols are used in two different ways with two different\r
+      goals.\r
+\r
+        a. Allow simplification of predicates which have been combined\r
+           during predicate hoisting.\r
+\r
+        b. Allow recognition of identical predicates which can't disambiguate\r
+           alternatives with common lookahead.\r
+\r
+      First we will discuss goal (a).  Consider the following rule:\r
+\r
+            rule0: rule1\r
+                 | ID\r
+                 | ...\r
+                 ;\r
+\r
+            rule1: rule2\r
+                 | rule3\r
+                 ;\r
+\r
+            rule2: <<isX(LATEXT(1))>>? ID ;\r
+            rule3: <<!isX(LATEXT(1)>>? ID ;\r
+\r
+      When the predicates in rule2 and rule3 are combined by hoisting\r
+      to create a prediction expression for rule1 the result is:\r
+\r
+            if ( LA(1)==ID\r
+                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
+\r
+      This is inefficient, but more importantly, can lead to false\r
+      assumptions that the predicate expression distinguishes the rule1\r
+      alternative with some other alternative with lookahead ID.  In\r
+      MR11 one can write:\r
+\r
+            #pred IsX     <<isX(LATEXT(1))>>?\r
+\r
+            ...\r
+\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<!IsX>>? ID ;\r
+\r
+      During hoisting MR11 recognizes this as a special case and\r
+      eliminates the predicates.  The result is a prediction\r
+      expression like the following:\r
+\r
+            if ( LA(1)==ID ) { rule1(); ...\r
+\r
+      Please note that the following cases which appear to be equivalent\r
+      *cannot* be simplified by MR11 during hoisting because the hoisting\r
+      logic only checks for a "!" in the predicate action, not in the\r
+      predicate expression for a predicate symbol.\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     <<!isX(LATEXT(1))>>?\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     !IsX\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+      Now we will discuss goal (b).\r
+\r
+      When antlr discovers that there is a lookahead ambiguity between\r
+      two alternatives it attempts to resolve the ambiguity by searching\r
+      for predicates in both alternatives.  In the past any predicate\r
+      would do, even if the same one appeared in both alternatives:\r
+\r
+            rule: <<p(LATEXT(1))>>? X\r
+                | <<p(LATEXT(1))>>? X\r
+                ;\r
+\r
+      The #pred statement is a start towards solving this problem.\r
+      During ambiguity resolution (*not* predicate hoisting) the\r
+      predicates for the two alternatives are expanded and compared.\r
+      Consider the following example:\r
+\r
+            #pred Upper     <<isUpper(LATEXT(1))>>?\r
+            #pred Lower     <<isLower(LATEXT(1))>>?\r
+            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
+\r
+            rule0: rule1\r
+                 | <<Alpha>>? ID\r
+                 ;\r
+\r
+            rule1:\r
+                 | rule2\r
+                 | rule3\r
+                 ...\r
+                 ;\r
+\r
+            rule2: <<Upper>>? ID;\r
+            rule3: <<Lower>>? ID;\r
+\r
+      The definition of #pred Alpha expresses:\r
+\r
+            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
+\r
+            b. to analyze the predicate use the information that\r
+               Alpha is equivalent to the union of Upper and Lower,\r
+\r
+      During ambiguity resolution the definition of Alpha is expanded\r
+      into "Upper || Lower" and compared with the predicate in the other\r
+      alternative, which is also "Upper || Lower".  Because they are\r
+      identical MR11 will report a problem.\r
+\r
+    -------------------------------------------------------------------------\r
+      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
+             (file t10.g alt 1 line 5 and alt 2 line 6)\r
+             are identical when compared without context and may have no\r
+             resolving power for some lookahead sequences.\r
+    -------------------------------------------------------------------------\r
+\r
+      If you use the "-info p" option the output file will contain:\r
+\r
+    +----------------------------------------------------------------------+\r
+    |#if 0                                                                 |\r
+    |                                                                      |\r
+    |The following predicates are identical when compared without          |\r
+    |  lookahead context information.  For some ambiguous lookahead        |\r
+    |  sequences they may not have any power to resolve the ambiguity.     |\r
+    |                                                                      |\r
+    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 1 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  Upper>>?                                              |\r
+    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |      pred  <<  Lower>>?                                              |\r
+    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |  The predicate for choice 1 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 1  t10.g               |\r
+    |                                                                      |\r
+    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 2  t10.g               |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 2 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |  pred  <<  Alpha>>?                                                  |\r
+    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
+    |    set context:                                                      |\r
+    |       ID                                                             |\r
+    |                                                                      |\r
+    |  The predicate for choice 2 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |  OR expr                                                             |\r
+    |                                                                      |\r
+    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 1  t10.g                 |\r
+    |                                                                      |\r
+    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 2  t10.g                 |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |#endif                                                                |\r
+    +----------------------------------------------------------------------+\r
+\r
+      The comparison of the predicates for the two alternatives takes\r
+      place without context information, which means that in some cases\r
+      the predicates will be considered identical even though they operate\r
+      on disjoint lookahead sets.  Consider:\r
+\r
+            #pred Alpha\r
+\r
+            rule1: <<Alpha>>? ID\r
+                 | <<Alpha>>? Label\r
+                 ;\r
+\r
+      Because the comparison of predicates takes place without context\r
+      these will be considered identical.  The reason for comparing\r
+      without context is that otherwise it would be necessary to re-evaluate\r
+      the entire predicate expression for each possible lookahead sequence.\r
+      This would require more code to be written and more CPU time during\r
+      grammar analysis, and it is not yet clear whether anyone will even make\r
+      use of the new #pred facility.\r
+\r
+      A temporary workaround might be to use different #pred statements\r
+      for predicates you know have different context.  This would avoid\r
+      extraneous warnings.\r
+\r
+      The above example might be termed a "false positive".  Comparison\r
+      without context will also lead to "false negatives".  Consider the\r
+      following example:\r
+\r
+            #pred Alpha\r
+            #pred Beta\r
+\r
+            rule1: <<Alpha>>? A\r
+                 | rule2\r
+                 ;\r
+\r
+            rule2: <<Alpha>>? A\r
+                 | <<Beta>>?  B\r
+                 ;\r
+\r
+      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
+      appears to be different than the predicate Alpha used for alt1.\r
+      However, the context of Beta is B.  Thus when the lookahead is A\r
+      Beta will have no resolving power and Alpha will be used for both\r
+      alternatives.  Using the same predicate for both alternatives isn't\r
+      very helpful, but this will not be detected with 1.33MR11.\r
+\r
+      To properly handle this the predicate expression would have to be\r
+      evaluated for each distinct lookahead context.\r
+\r
+      To determine whether two predicate expressions are identical is\r
+      difficult.  The routine may fail to identify identical predicates.\r
+\r
+      The #pred feature also compares predicates to see if a choice between\r
+      alternatives which is resolved by a predicate which makes the second\r
+      choice unreachable.  Consider the following example:\r
+\r
+            #pred A         <<A(LATEXT(1)>>?\r
+            #pred B         <<B(LATEXT(1)>>?\r
+            #pred A_or_B    A || B\r
+\r
+            r   : s\r
+                | t\r
+                ;\r
+            s   : <<A_or_B>>? ID\r
+                ;\r
+            t   : <<A>>? ID\r
+                ;\r
+\r
+        ----------------------------------------------------------------------------\r
+        t11.g, line 5: warning: the predicate used to disambiguate the\r
+               first choice of  rule r\r
+             (file t11.g alt 1 line 5 and alt 2 line 6)\r
+             appears to "cover" the second predicate when compared without context.\r
+             The second predicate may have no resolving power for some lookahead\r
+               sequences.\r
+        ----------------------------------------------------------------------------\r
+\r
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
+\r
+      Prior to 1.33MR11, there would be no ambiguity warning when the\r
+      very same predicate was used to disambiguate both alternatives:\r
+\r
+        test: ref B\r
+            | ref C\r
+            ;\r
+\r
+        ref : <<pred(LATEXT(1)>>? A\r
+\r
+      In 1.33MR11 this will cause the warning:\r
+\r
+        warning: the predicates used to disambiguate rule test\r
+            (file v98.g alt 1 line 1 and alt 2 line 2)\r
+             are identical and have no resolving power\r
+\r
+        -----------------  Note  -----------------\r
+\r
+          This is different than the following case\r
+\r
+                test: <<pred(LATEXT(1))>>? A B\r
+                    | <<pred(LATEXT(1)>>?  A C\r
+                    ;\r
+\r
+          In this case there are two distinct predicates\r
+          which have exactly the same text.  In the first\r
+          example there are two references to the same\r
+          predicate.  The problem represented by this\r
+          grammar will be addressed later.\r
+\r
+\r
+#127. (Changed in 1.33MR11)\r
+\r
+                    Count Syntax Errors     Count DLG Errors\r
+                    -------------------     ----------------\r
+\r
+       C++ mode     ANTLRParser::           DLGLexerBase::\r
+                      syntaxErrCount          lexErrCount\r
+       C mode       zzSyntaxErrCount        zzLexErrCount\r
+\r
+       The C mode variables are global and initialized to 0.\r
+       They are *not* reset to 0 automatically when antlr is\r
+       restarted.\r
+\r
+       The C++ mode variables are public.  They are initialized\r
+       to 0 by the constructors.  They are *not* reset to 0 by the\r
+       ANTLRParser::init() method.\r
+\r
+       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
+\r
+#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
+\r
+       The #first <<...>> inserts the specified text in the output\r
+       files before any other #include statements required by pccts.\r
+       The only things before the #first text are comments and\r
+       a #define ANTLR_VERSION.\r
+\r
+       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
+       Zoltan (alexin@inf.u-szeged.hu).\r
+\r
+#124. A Note on the New "&&" Style Guarded Predicates\r
+\r
+        I've been asked several times, "What is the difference between\r
+        the old "=>" style guard predicates and the new style "&&" guard\r
+        predicates, and how do you choose one over the other" ?\r
+\r
+        The main difference is that the "=>" does not apply the\r
+        predicate if the context guard doesn't match, whereas\r
+        the && form always does.  What is the significance ?\r
+\r
+        If you have a predicate which is not on the "leading edge"\r
+        it is cannot be hoisted.  Suppose you need a predicate that\r
+        looks at LA(2).  You must introduce it manually.  The\r
+        classic example is:\r
+\r
+            castExpr :\r
+                     LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     | STRUCT ID\r
+                     ;\r
+\r
+        The problem  is that isTypeName() isn't on the leading edge\r
+        of typeName, so it won't be hoisted into castExpr to help\r
+        make a decision on which production to choose.\r
+\r
+        The *first* attempt to fix it is this:\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        Unfortunately, this won't work because it ignores\r
+        the problem of STRUCT.  The solution is to apply\r
+        isTypeName() in castExpr if LA(2) is an ID and\r
+        don't apply it when LA(2) is STRUCT:\r
+\r
+            castExpr :\r
+                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        In conclusion, the "=>" style guarded predicate is\r
+        useful when:\r
+\r
+            a. the tokens required for the predicate\r
+               are not on the leading edge\r
+            b. there are alternatives in the expression\r
+               selected by the predicate for which the\r
+               predicate is inappropriate\r
+\r
+        If (b) were false, then one could use a simple\r
+        predicate (assuming "-prc on"):\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     ;\r
+\r
+        So, when do you use the "&&" style guarded predicate ?\r
+\r
+        The new-style "&&" predicate should always be used with\r
+        predicate context.  The context guard is in ADDITION to\r
+        the automatically computed context.  Thus it useful for\r
+        predicates which depend on the token type for reasons\r
+        other than context.\r
+\r
+        The following example is contributed by Reinier van den Born\r
+        (reinier@vnet.ibm.com).\r
+\r
+ +-------------------------------------------------------------------------+\r
+ | This grammar has two ways to call functions:                            |\r
+ |                                                                         |\r
+ |  - a "standard" call syntax with parens and comma separated args        |\r
+ |  - a shell command like syntax (no parens and spacing separated args)   |\r
+ |                                                                         |\r
+ | The former also allows a variable to hold the name of the function,     |\r
+ | the latter can also be used to call external commands.                  |\r
+ |                                                                         |\r
+ | The grammar (simplified) looks like this:                               |\r
+ |                                                                         |\r
+ |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is function name */              |\r
+ |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is var containing fun name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   command    : ID expr*          /* ID is function name */              |\r
+ |              | path expr*        /* path is external command name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   path       : ID                /* left out slashes and such */        |\r
+ |              | "@" ID            /* ID is environment var */            |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   expr       : ....                                                     |\r
+ |              | "(" expr ")";                                            |\r
+ |                                                                         |\r
+ |   call       : fun_call                                                 |\r
+ |              | command                                                  |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | Obviously the call is wildly ambiguous. This is more or less how this   |\r
+ | is to be resolved:                                                      |\r
+ |                                                                         |\r
+ |    A call begins with an ID or an @ followed by an ID.                  |\r
+ |                                                                         |\r
+ |    If it is an ID and if it is an ext. command name  -> command         |\r
+ |                       if followed by a paren         -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ |    If it is an @  and if the ID is a var name        -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ | One can implement these rules quite neatly using && predicates:         |\r
+ |                                                                         |\r
+ |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
+ |              | (ID)?     && <<isExtCmdName>>?     command               |\r
+ |              | (ID "(")?                          fun_call              |\r
+ |              |                                    command               |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | This can be done better, so it is not an ideal example, but it          |\r
+ | conveys the principle.                                                  |\r
+ +-------------------------------------------------------------------------+\r
+\r
+#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
+\r
+         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
+         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
+\r
+        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
+\r
+      The user can ask for additional information on ambiguities reported\r
+      by antlr to stdout.  At the moment, only one ambiguity report can\r
+      be created in an antlr run.\r
+\r
+      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
+\r
+      The following options control the reporting of ambiguities:\r
+\r
+          -aa ruleName       Selects reporting by name of rule\r
+          -aa lineNumber     Selects reporting by line number\r
+                               (file name not compared)\r
+\r
+          -aam               Selects "multiple" reporting for a token\r
+                             in the intersection set of the\r
+                             alternatives.\r
+\r
+                             For instance, the token ID may appear dozens\r
+                             of times in various paths as the program\r
+                             explores the rules which are reachable from\r
+                             the point of an ambiguity. With option -aam\r
+                             every possible path the search program\r
+                             encounters is reported.\r
+\r
+                             Without -aam only the first encounter is\r
+                             reported.  This may result in incomplete\r
+                             information, but the information may be\r
+                             sufficient and much shorter.\r
+\r
+          -aad depth         Selects the depth of the search.\r
+                             The default value is 1.\r
+\r
+                             The number of paths to be searched, and the\r
+                             size of the report can grow geometrically\r
+                             with the -ck value if a full search for all\r
+                             contributions to the source of the ambiguity\r
+                             is explored.\r
+\r
+                             The depth represents the number of tokens\r
+                             in the lookahead set which are matched against\r
+                             the set of ambiguous tokens.  A depth of 1\r
+                             means that the search stops when a lookahead\r
+                             sequence of just one token is matched.\r
+\r
+                             A k=1 ck=6 grammar might generate 5,000 items\r
+                             in a report if a full depth 6 search is made\r
+                             with the Ambiguity Aid.  The source of the\r
+                             problem may be in the first token and obscured\r
+                             by the volume of data - I hesitate to call\r
+                             it information.\r
+\r
+                             When the user selects a depth > 1, the search\r
+                             is first performed at depth=1 for both\r
+                             alternatives, then depth=2 for both alternatives,\r
+                             etc.\r
+\r
+      Sample output for rule grammar in antlr.g itself:\r
+\r
+  +---------------------------------------------------------------------+\r
+  | Ambiguity Aid                                                       |\r
+  |                                                                     |\r
+  |   Choice 1: grammar/70                 line 632  file a.g           |\r
+  |   Choice 2: grammar/82                 line 644  file a.g           |\r
+  |                                                                     |\r
+  |   Intersection of lookahead[1] sets:                                |\r
+  |                                                                     |\r
+  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
+  |  2 to error                       grammar/73       line 635   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/74       line 636   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
+  |  2 to class_def                   grammar/75       line 637   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
+  |  2 to error                       grammar/93       line 655   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/94       line 656   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
+  |  2 to class_def                   grammar/95       line 657   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
+  +---------------------------------------------------------------------+\r
+\r
+      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
+      when all lookahead sets [i] with i<k all have degree one) the\r
+      reports appear in the following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          for (alternative=1; alternative <=2 ; alternative++) {\r
+            while (matches-are-found) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      For reporting a k-tuple ambiguity, the reports appear in the\r
+      following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          while (matches-are-found) {\r
+            for (alternative=1; alternative <=2 ; alternative++) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      This is because matches are generated in different ways for\r
+      linear lookahead and k-tuples.\r
+\r
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
+\r
+      The hoisting of predicates into rules to create prediction\r
+      expressions is a problem in antlr.  Consider the following\r
+      example (k=1 with -prc on):\r
+\r
+        start   : (a)* "@" ;\r
+        a       : b | c ;\r
+        b       : <<isUpper(LATEXT(1))>>? A ;\r
+        c       : A ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if (LA(1)==A &&\r
+                    (!LA(1)==A || isUpper())) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      This code is wrong because it makes rule "c" unreachable from\r
+      "start".  The essence of the problem is that antlr fails to\r
+      recognize that there can be a valid alternative within "a" even\r
+      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
+\r
+      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
+      "start" is suppressed because it recognizes that "c" can\r
+      cover all the cases where the predicate is false:\r
+\r
+        while {\r
+            if (LA(1)==A) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate suppression in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where\r
+            the predicate is false.\r
+\r
+           WITH predicate: line 7  v1.g\r
+           WITHOUT predicate: line 7  v1.g\r
+\r
+        The context set for the predicate:\r
+\r
+             A\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 9  v1.g\r
+            set context:\r
+               A\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 5 v1.g) to rule a\r
+            #1  in rule a (line 7 v1.g)\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      A predicate can be suppressed by a combination of alternatives\r
+      which, taken together, cover a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b | ca | cb | cc ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
+\r
+        ca      : A ;\r
+        cb      : B ;\r
+        cc      : C ;\r
+\r
+      Consider a more complex example in which "c" covers only part of\r
+      a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b\r
+                | c\r
+                ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>?\r
+                    ( A\r
+                    | X\r
+                    );\r
+\r
+        c       : A\r
+                ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
+      the non-covered lookahead.  The code resembles:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                  (! (LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate restriction in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Restricting the context of a predicate because of overlap\r
+          in the lookahead set between the alternative with the\r
+          semantic predicate and one without\r
+        Without this restriction the alternative without the predicate\r
+          could not be reached when input matched the context of the\r
+          predicate and the predicate was false.\r
+\r
+           WITH predicate: line 11  v4.g\r
+           WITHOUT predicate: line 12  v4.g\r
+\r
+        The original context set for the predicate:\r
+\r
+             A                X\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The intersection of the two sets\r
+\r
+             A\r
+\r
+        The original predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               A                X\r
+            tree context: null\r
+\r
+        The new (modified) form of the predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      The bad news about -mrhoist:\r
+\r
+        (a) -mrhoist does not analyze predicates with lookahead\r
+            depth > 1.\r
+\r
+        (b) -mrhoist does not look past a guarded predicate to\r
+            find context which might cover other predicates.\r
+\r
+      For these cases you might want to use syntactic predicates.\r
+      When a semantic predicate fails during guess mode the guess\r
+      fails and the next alternative is tried.\r
+\r
+      Limitation (a) is illustrated by the following example:\r
+\r
+        start    : (stmt)* EOF ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+\r
+      This is not much different from the first example, except that\r
+      it requires two tokens of lookahead context to determine what\r
+      to do.  This predicate is NOT suppressed because the current version\r
+      is unable to handle predicates with depth > 1.\r
+\r
+      A predicate can be combined with other predicates during hoisting.\r
+      In those cases the depth=1 predicates are still handled.  Thus,\r
+      in the following example the isUpper() predicate will be suppressed\r
+      by line #4 when hoisted from "bizarre" into "start", but will still\r
+      be present in "bizarre" in order to predict "stmt".\r
+\r
+        start    : (bizarre)* EOF ;     // #1\r
+                                        // #2\r
+        bizarre  : stmt                 // #3\r
+                 | A                    // #4\r
+                 ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+                 | <<isUpper(LATEXT(1))>>? A\r
+\r
+      Limitation (b) is illustrated by the following example of a\r
+      context guarded predicate:\r
+\r
+        rule : (A)? <<p>>?          // #1\r
+                     (A             // #2\r
+                     |B             // #3\r
+                     )              // #4\r
+             | <<q>> B              // #5\r
+             ;\r
+\r
+      Recall that this means that when the lookahead is NOT A then\r
+      the predicate "p" is ignored and it attempts to match "A|B".\r
+      Ideally, the "B" at line #3 should suppress predicate "q".\r
+      However, the current version does not attempt to look past\r
+      the guard predicate to find context which might suppress other\r
+      predicates.\r
+\r
+      In some cases -mrhoist will lead to the reporting of ambiguities\r
+      which were not visible before:\r
+\r
+        start   : (a)* "@";\r
+        a       : bc | d;\r
+        bc      : b  | c ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? A;\r
+        c       : A ;\r
+\r
+        d       : A ;\r
+\r
+      In this case there is a true ambiguity in "a" between "bc" and "d"\r
+      which can both match "A".  Without -mrhoist the predicate in "b"\r
+      is hoisted into "a" and there is no ambiguity reported.  However,\r
+      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
+      should be) making the ambiguity in "a" apparent.\r
+\r
+      The motivations for these changes were hoisting problems reported\r
+      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
+\r
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
+\r
+      The existing context guarded predicate:\r
+\r
+            rule : (guard)? => <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      generates code which resembles:\r
+\r
+            if (lookahead(expr) && (!guard || pred)) {\r
+              expr()\r
+            } else ....\r
+\r
+      This is not suitable for some applications because it allows\r
+      expr() to be invoked when the predicate is false.  This is\r
+      intentional because it is meant to mimic automatically computed\r
+      predicate context.\r
+\r
+      The new context guarded predicate uses the guard information\r
+      differently because it has a different goal.  Consider:\r
+\r
+            rule : (guard)? && <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      The new style of context guarded predicate is equivalent to:\r
+\r
+            rule : <<guard==true && pred>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      It generates code which resembles:\r
+\r
+            if (lookahead(expr) && guard && pred) {\r
+                expr();\r
+            } else ...\r
+\r
+      Both forms of guarded predicates severely restrict the form of\r
+      the context guard: it can contain no rule references, no\r
+      (...)*, no (...)+, and no {...}.  It may contain token and\r
+      token class references, and alternation ("|").\r
+\r
+      Addition for 1.33MR11: in the token expression all tokens must\r
+      be at the same height of the token tree:\r
+\r
+            (A ( B | C))? && ...            is ok (all height 2)\r
+            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
+            (A B C D | E F G H)? && ...     is ok (all height 4)\r
+            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
+\r
+      This restriction is required in order to properly compute the lookahead\r
+      set for expressions like:\r
+\r
+            rule1 : (A B C)? && <<pred>>? rule2 ;\r
+            rule2 : (A|X) (B|Y) (C|Z);\r
+\r
+      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
+\r
+#109. (Changed in 1.33MR10) improved trace information\r
+\r
+      The quality of the trace information provided by the "-gd"\r
+      switch has been improved significantly.  Here is an example\r
+      of the output from a test program.  It shows the rule name,\r
+      the first token of lookahead, the call depth, and the guess\r
+      status:\r
+\r
+        exit rule gusxx {"?"} depth 2\r
+        enter rule gusxx {"?"} depth 2\r
+        enter rule gus1 {"o"} depth 3 guessing\r
+        guess done - returning to rule gus1 {"o"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        exit rule gus1 {"Z"} depth 3 guessing\r
+        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
+        enter rule gus1 {"o"} depth 3\r
+        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
+        exit rule gus1 {"Z"} depth 3\r
+        line 1: syntax error at "Z" missing SC\r
+            ...\r
+\r
+      Rule trace reporting is controlled by the value of the integer\r
+      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
+      otherwise it is disabled.  Tracing during guess mode is controlled\r
+      by the value of the integer [zz]traceGuessOptionValue.  When\r
+      it is positive AND [zz]traceOptionValue is positive rule trace\r
+      is reported in guess mode.\r
+\r
+      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
+      can be adjusted by subroutine calls listed below.\r
+\r
+      Depending on the presence or absence of the antlr -gd switch\r
+      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
+      the parser is initialized or [zz]traceReset() is called the\r
+      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
+      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
+      but, as noted earlier, nothing will be reported unless\r
+      [zz]traceOptionValue is also positive.\r
+\r
+      When the parser state is saved/restored the value of the trace\r
+      variables are also saved/restored.  If a restore causes a change in\r
+      reporting behavior from on to off or vice versa this will be reported.\r
+\r
+      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
+      is added to appropriate output files.\r
+\r
+        C++ mode\r
+        --------\r
+        int     traceOption(int delta)\r
+        int     traceGuessOption(int delta)\r
+        void    traceReset()\r
+        int     traceOptionValueDefault\r
+\r
+        C mode\r
+        --------\r
+        int     zzTraceOption(int delta)\r
+        int     zzTraceGuessOption(int delta)\r
+        void    zzTraceReset()\r
+        int     zzTraceOptionValueDefault\r
+\r
+      The argument "delta" is added to the traceOptionValue.  To\r
+      turn on trace when inside a particular rule one:\r
+\r
+        rule : <<traceOption(+1);>>\r
+               (\r
+                rest-of-rule\r
+               )\r
+               <<traceOption(-1);>>\r
+       ;  /* fail clause */ <<traceOption(-1);>>\r
+\r
+      One can use the same idea to turn *off* tracing within a\r
+      rule by using a delta of (-1).\r
+\r
+      An improvement in the rule trace was suggested by Sramji\r
+      Ramanathan (ps@kumaran.com).\r
+\r
+#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
+\r
+                            NOTE\r
+        ------------------------------------------------------\r
+        This mechanism only works for heap allocated variables\r
+        ------------------------------------------------------\r
+\r
+      The rewrite of the trace provides the machinery necessary\r
+      to properly free variables or undo actions following a\r
+      failed guess.\r
+\r
+      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
+      as part of the zzGUESS macro.  When a guess is opened\r
+      the value of zzrv is 0.  When a longjmp() is executed to\r
+      undo the guess, the value of zzrv will be 1.\r
+\r
+      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
+      as part of the zzGUESS_DONE macro.  This is executed\r
+      whether the guess succeeds or fails as part of closing\r
+      the guess.\r
+\r
+      The guessSeq is a sequence number which is assigned to each\r
+      guess and is incremented by 1 for each guess which becomes\r
+      active.  It is needed by the user to associate the start of\r
+      a guess with the failure and/or completion (closing) of a\r
+      guess.\r
+\r
+      Guesses are nested.  They must be closed in the reverse\r
+      of the order that they are opened.\r
+\r
+      In order to free memory used by a variable during a guess\r
+      a user must write a routine which can be called to\r
+      register the variable along with the current guess sequence\r
+      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
+      fails, all variables tagged with the corresponding guess\r
+      sequence number should be released.  This is ugly, but\r
+      it would require a major rewrite of antlr 1.33 to use\r
+      some mechanism other than setjmp()/longjmp().\r
+\r
+      The order of calls for a *successful* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The order of calls for a *failed* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_HOOK(guessSeq,1);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The default definitions of these macros are empty strings.\r
+\r
+      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
+      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
+      can be used without change in both C and C++ versions.\r
+\r
+      ----------------------------------------------------------------------\r
+        <<\r
+\r
+        #include "AToken.h"\r
+\r
+        typedef ANTLRCommonToken ANTLRToken;\r
+\r
+        #include "DLGLexer.h"\r
+\r
+        int main() {\r
+\r
+          {\r
+            DLGFileInput     in(stdin);\r
+            DLGLexer         lexer(&in,2000);\r
+            ANTLRTokenBuffer pipe(&lexer,1);\r
+            ANTLRCommonToken aToken;\r
+            P                parser(&pipe);\r
+\r
+            lexer.setToken(&aToken);\r
+            parser.init();\r
+            parser.start();\r
+          };\r
+\r
+          fclose(stdin);\r
+          fclose(stdout);\r
+          return 0;\r
+        }\r
+\r
+        >>\r
+\r
+        <<\r
+        char *s=NULL;\r
+\r
+        #undef zzUSER_GUESS_HOOK\r
+        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
+        #undef zzUSER_GUESS_DONE_HOOK\r
+        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
+\r
+        void myGuessHook(int guessSeq,int zzrv) {\r
+          if (zzrv == 0) {\r
+            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
+          } else if (zzrv == 1) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
+          } else if (zzrv == 2) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
+          };\r
+        }\r
+\r
+        >>\r
+\r
+        #token A    "a"\r
+        #token      "[\t \ \n]"     <<skip();>>\r
+\r
+        class P {\r
+\r
+        start : (top)+\r
+              ;\r
+\r
+        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
+              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
+              ; <<if (s != NULL) free(s); s=NULL; >>\r
+\r
+        which : which2\r
+              ;\r
+\r
+        which2 : which3\r
+              ;\r
+        which3\r
+              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
+              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
+              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
+              ;\r
+\r
+        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
+\r
+        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
+\r
+        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
+\r
+        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
+\r
+        }\r
+      ----------------------------------------------------------------------\r
+\r
+      This is a silly example, but illustrates the idea.  For the input\r
+      "a ::" with tracing enabled the output begins:\r
+\r
+      ----------------------------------------------------------------------\r
+        enter rule "start" depth 1\r
+        enter rule "top" depth 2\r
+        User hook: starting guess #1\r
+        enter rule "which" depth 3 guessing\r
+        enter rule "which2" depth 4 guessing\r
+        enter rule "which3" depth 5 guessing\r
+        User hook: starting guess #2\r
+        enter rule "label" depth 6 guessing\r
+        guess failed\r
+        User hook: failed guess #2\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #2\r
+        User hook: starting guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        exit rule "which3" depth 5 guessing\r
+        exit rule "which2" depth 4 guessing\r
+        exit rule "which" depth 3 guessing\r
+        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
+        User hook: ending guess #1\r
+        enter rule "which" depth 3\r
+        .....\r
+      ----------------------------------------------------------------------\r
+\r
+      Remember:\r
+\r
+        (a) Only init-actions are executed during guess mode.\r
+        (b) A rule can be invoked multiple times during guess mode.\r
+        (c) If the guess succeeds the rule will be called once more\r
+              without guess mode so that normal actions will be executed.\r
+            This means that the init-action might need to distinguish\r
+              between guess mode and non-guess mode using the variable\r
+              [zz]guessing.\r
+\r
+#101. (Changed in 1.33MR10) antlr -info command line switch\r
+\r
+        -info\r
+\r
+            p   - extra predicate information in generated file\r
+\r
+            t   - information about tnode use:\r
+                    at the end of each rule in generated file\r
+                    summary on stderr at end of program\r
+\r
+            m   - monitor progress\r
+                    prints name of each rule as it is started\r
+                    flushes output at start of each rule\r
+\r
+            f   - first/follow set information to stdout\r
+\r
+            0   - no operation (added in 1.33MR11)\r
+\r
+      The options may be combined and may appear in any order.\r
+      For example:\r
+\r
+        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
+\r
+#100a. (Changed in 1.33MR10) Predicate tree simplification\r
+\r
+      When the same predicates can be referenced in more than one\r
+      alternative of a block large predicate trees can be formed.\r
+\r
+      The difference that these optimizations make is so dramatic\r
+      that I have decided to use it even when -mrhoist is not selected.\r
+\r
+      Consider the following grammar:\r
+\r
+        start : ( all )* ;\r
+\r
+        all   : a\r
+              | d\r
+              | e\r
+              | f\r
+              ;\r
+\r
+        a     : c A B\r
+              | c A C\r
+              ;\r
+\r
+        c     : <<AAA(LATEXT(2))>>?\r
+              ;\r
+\r
+        d     : <<BBB(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        e     : <<CCC(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        f     : e X Y\r
+              ;\r
+\r
+      In rule "a" there is a reference to rule "c" in both alternatives.\r
+      The length of the predicate AAA is k=2 and it can be followed in\r
+      alternative 1 only by (A B) while in alternative 2 it can be\r
+      followed only by (A C).  Thus they do not have identical context.\r
+\r
+      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
+      elimination of the duplicate reference to predicate CCC.\r
+\r
+      The table below summarized the kind of simplification performed by\r
+      1.33MR10.  In the table, X and Y stand for single predicates\r
+      (not trees).\r
+\r
+        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
+        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
+\r
+        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
+        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
+        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
+        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
+\r
+        (AND X)               => X\r
+        (OR X)                => X\r
+\r
+      In a test with a complex grammar for a real application, a predicate\r
+      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
+\r
+      In 1.33MR10 there is a greater effort to release memory used\r
+      by predicates once they are no longer in use.\r
+\r
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
+\r
+      The following optimizations require that -mrhoist be selected.\r
+\r
+      It is relatively easy to optimize the code generated for predicate\r
+      gates when they are of the form:\r
+\r
+            (AND X Y Z ...)\r
+        or  (OR  X Y Z ...)\r
+\r
+      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
+      predicate trees.\r
+\r
+      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
+      ANDed together to create a single Tree context for the group and\r
+      context tests for the individual predicates are suppressed:\r
+\r
+            --------------------------------------------------\r
+            Note: This was incorrect.  The contexts should be\r
+            ORed together.  This has been fixed.  A more \r
+            complete description is available in item #152.\r
+            ---------------------------------------------------\r
+\r
+      Optimization 1:  (AND X Y Z ...)\r
+\r
+        Suppose the context for Xtest is LA(1)==LP and the context for\r
+        Ytest is LA(1)==LP && LA(2)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
+                        ( (! LA(1)==LP || Xtest) &&\r
+                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
+                        )) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
+\r
+      Optimization 2: (OR X Y Z ...) with identical contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is also LA(1)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==ID) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==ID && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
+\r
+      Optimization 3: (OR X Y Z ...) with distinct contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is LA(1)==LP.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==LP) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==LP && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                        (zzpf=0,\r
+                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
+                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
+                            !zzpf) {\r
+\r
+            These may appear to be of similar complexity at first,\r
+            but the non-optimized version contains two tests of each\r
+            context while the optimized version contains only one\r
+            such test, as well as eliminating some of the inverted\r
+            logic (" !(...) || ").\r
+\r
+      Optimization 4: Computation of predicate gate trees\r
+\r
+        When generating code for the gates of predicate expressions\r
+        antlr 1.33 vanilla uses a recursive procedure to generate\r
+        "&&" and "||" expressions for testing the lookahead. As each\r
+        layer of the predicate tree is exposed a new set of "&&" and\r
+        "||" expressions on the lookahead are generated.  In many\r
+        cases the lookahead being tested has already been tested.\r
+\r
+        With -mrhoist a lookahead tree is computed for the entire\r
+        lookahead expression.  This means that predicates with identical\r
+        context or context which is a subset of another predicate's\r
+        context disappear.\r
+\r
+        This is especially important for predicates formed by rules\r
+        like the following:\r
+\r
+            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
+            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
+\r
+        These predicates are combined using AND since both must be\r
+        satisfied for rule upperCaseVowel.  They have identical\r
+        context which makes this optimization very effective.\r
+\r
+      The affect of Items #100a and #100b together can be dramatic.  In\r
+      a very large (but real world) grammar one particular predicate\r
+      expression was reduced from an (unreadable) 50 predicate leaves,\r
+      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
+      3 predicate leaves (all different) and a *single* LA(1) term.\r
+\r
+#98.  (Changed in 1.33MR10) Option "-info p"\r
+\r
+      When the user selects option "-info p" the program will generate\r
+      detailed information about predicates.  If the user selects\r
+      "-mrhoist on" additional detail will be provided explaining\r
+      the promotion and suppression of predicates.  The output is part\r
+      of the generated file and sandwiched between #if 0/#endif statements.\r
+\r
+      Consider the following k=1 grammar:\r
+\r
+        start : ( all ) * ;\r
+\r
+        all   : ( a\r
+                | b\r
+                )\r
+                ;\r
+\r
+        a     : c B\r
+              ;\r
+\r
+        c     : <<LATEXT(1)>>?\r
+              | B\r
+              ;\r
+\r
+        b     : <<LATEXT(1)>>? X\r
+              ;\r
+\r
+      Below is an excerpt of the output for rule "start" for the three\r
+      predicate options (off, on, and maintenance release style hoisting).\r
+\r
+      For those who do not wish to use the "-mrhoist on" option for code\r
+      generation the option can be used in a "diagnostic" mode to provide\r
+      valuable information:\r
+\r
+            a. where one should insert null actions to inhibit hoisting\r
+            b. a chain of rule references which shows where predicates are\r
+               being hoisted\r
+\r
+      ======================================================================\r
+      Example of "-info p" with "-mrhoist on"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where the\r
+           predicate is false.\r
+\r
+           WITH predicate: line 11  v36.g\r
+           WITHOUT predicate: line 12  v36.g\r
+\r
+        The context set for the predicate:\r
+\r
+             B\r
+\r
+        The lookahead set for alt WITHOUT the semantic predicate:\r
+\r
+             B\r
+\r
+        The predicate:\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 1 v36.g) to rule all\r
+            #1  in rule all (line 3 v36.g) to rule a\r
+            #2  in rule a (line 8 v36.g) to rule c\r
+            #3  in rule c (line 11 v36.g)\r
+\r
+        #endif\r
+        &&\r
+        #if 0\r
+\r
+        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+          set context:\r
+             X\r
+          tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p"  with the default -prc setting ( "-prc off")\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p" with "-prc on" and "-mrhoist off"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+\r
+#60.  (Changed in 1.33MR7) Major changes to exception handling\r
+\r
+        There were significant problems in the handling of exceptions\r
+        in 1.33 vanilla.  The general problem is that it can only\r
+        process one level of exception handler.  For example, a named\r
+        exception handler, an exception handler for an alternative, or\r
+        an exception for a subrule  always went to the rule's exception\r
+        handler if there was no "catch" which matched the exception.\r
+\r
+        In 1.33MR7 the exception handlers properly "nest".  If an\r
+        exception handler does not have a matching "catch" then the\r
+        nextmost outer exception handler is checked for an appropriate\r
+        "catch" clause, and so on until an exception handler with an\r
+        appropriate "catch" is found.\r
+\r
+        There are still undesirable features in the way exception\r
+        handlers are implemented, but I do not have time to fix them\r
+        at the moment:\r
+\r
+            The exception handlers for alternatives are outside the\r
+            block containing the alternative.  This makes it impossible\r
+            to access variables declared in a block or to resume the\r
+            parse by "falling through".  The parse can still be easily\r
+            resumed in other ways, but not in the most natural fashion.\r
+\r
+            This results in an inconsistentcy between named exception\r
+            handlers and exception handlers for alternatives.  When\r
+            an exception handler for an alternative "falls through"\r
+            it goes to the nextmost outer handler - not the "normal\r
+            action".\r
+\r
+        A major difference between 1.33MR7 and 1.33 vanilla is\r
+        the default action after an exception is caught:\r
+\r
+            1.33 Vanilla\r
+            ------------\r
+            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
+            and the code drops through to the code following the exception.\r
+            For named exception handlers this is the "normal action".\r
+            For alternative exception handlers this is the rule's handler.\r
+\r
+            1.33MR7\r
+            -------\r
+            In 1.33MR7 the signal value is NOT automatically set to zero.\r
+\r
+            There are two cases:\r
+\r
+                For named exception handlers: if the signal value has been\r
+                set to zero the code drops through to the "normal action".\r
+\r
+                For all other cases the code branches to the nextmost outer\r
+                exception handler until it reaches the handler for the rule.\r
+\r
+        The following macros have been defined for convenience:\r
+\r
+            C/C++ Mode Name\r
+            --------------------\r
+            (zz)suppressSignal\r
+                  set signal & return signal arg to 0 ("NoSignal")\r
+            (zz)setSignal(intValue)\r
+                  set signal & return signal arg to some value\r
+            (zz)exportSignal\r
+                  copy the signal value to the return signal arg\r
+\r
+        I'm not sure why PCCTS make a distinction between the local\r
+        signal value and the return signal argument, but I'm loathe\r
+        to change the code. The burden of copying the local signal\r
+        value to the return signal argument can be given to the\r
+        default signal handler, I suppose.\r
+\r
+#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
+\r
+        The Book is silent about what happens after an exception\r
+        is caught.\r
+\r
+        The following code fragment prints "Error Action" followed\r
+        by "Normal Action".\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+        ;\r
+\r
+        The reason for "Normal Action" is that the normal flow of the\r
+        program after a user-written exception handler is to "drop through".\r
+        In the case of an exception handler for a rule this results in\r
+        the exection of a "return" statement.  In the case of an\r
+        exception handler attached to an alternative, rule, or token\r
+        this is the code that would have executed had there been no\r
+        exception.\r
+\r
+        The user can achieve the desired result by using a "return"\r
+        statement.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n"); return;>>\r
+        ;\r
+\r
+        The most powerful mechanism for recovery from parse errors\r
+        in pccts is syntactic predicates because they provide\r
+        backtracking.  Exceptions allow "return", "break",\r
+        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
+        changing the _signal value.\r
+\r
+#41.  (Added in 1.33MR6) antlr -stdout\r
+\r
+        Using "antlr -stdout ..." forces the text that would\r
+        normally go to the grammar.c or grammar.cpp file to\r
+        stdout.\r
+\r
+#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
+\r
+        Using "antlr -tab number ..." changes the tab stops\r
+        for the grammar.c or grammar.cpp file.  The number\r
+        must be between 0 and 8.  Using 0 gives tab characters,\r
+        values between 1 and 8 give the appropriate number of\r
+        space characters.\r
+\r
+#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
+\r
+        Previously there was no public function for changing the line\r
+        number maintained by the lexer.\r
+\r
+#28.   (Added to 1.33MR1) More control over DLG header\r
+\r
+        Version 1.33MR1 adds the following directives to PCCTS\r
+        for C++ mode:\r
+\r
+          #lexprefix  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                after the #include "DLexerBase.h" but\r
+                before the start of the class definition.\r
+\r
+          #lexmember  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                as part of the DLGLexer class body.  It\r
+                appears immediately after the start of\r
+                the class and a "public: statement.\r
+\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt
new file mode 100644 (file)
index 0000000..352428e
--- /dev/null
@@ -0,0 +1,184 @@
+\r
+    =======================================================\r
+    Known Problems In PCCTS - Last revised 14 November 1998\r
+    =======================================================\r
+\r
+#14. Parsing bug in dlg\r
+\r
+    THM: I have been unable to reproduce this problem.\r
+\r
+    Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com).\r
+\r
+    The regular expression parser (in rexpr.c) fails while\r
+    trying to parse the following regular expression:\r
+\r
+            {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+\r
+\r
+    See my comment in the following excerpt from rexpr.c:\r
+\r
+    /*\r
+     * <regExpr>        ::= <andExpr> ( '|' {<andExpr>} )*\r
+     *\r
+     * Return -1 if syntax error\r
+     * Return  0 if none found\r
+     * Return  1 if a regExrp was found\r
+     */\r
+       static\r
+       regExpr(g)\r
+       GraphPtr g;\r
+       {\r
+           Graph g1, g2;\r
+       \r
+           if ( andExpr(&g1) == -1 )\r
+           {\r
+               return -1;\r
+           }\r
+       \r
+           while ( token == '|' )\r
+           {\r
+               int a;\r
+               next();\r
+               a = andExpr(&g2);\r
+               if ( a == -1 ) return -1;   /* syntax error below */\r
+               else if ( !a ) return 1;    /* empty alternative */\r
+               g1 = BuildNFA_AorB(g1, g2);\r
+           }\r
+       \r
+           if ( token!='\0' ) return -1;\r
+       *****\r
+       ***** It appears to fail here becuause token is 125 - the closing '}'\r
+       ***** If I change it to:\r
+       *****    if ( token!='\0' && token!='}' && token!= ')' ) return -1;\r
+       *****\r
+       ***** It succeeds, but I'm not sure this is the corrrect approach.\r
+       *****\r
+           *g = g1;\r
+           return 1;\r
+       }\r
+\r
+#13. dlg reports an invalid range for: [\0x00-\0xff]\r
+\r
+    Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):\r
+\r
+    Fixed in MR16.\r
+\r
+#12. Strings containing comment actions\r
+\r
+     Sequences that looked like C style comments appearing in string\r
+     literals are improperly parsed by antlr/dlg.\r
+\r
+        << fprintf(out," /* obsolete */ ");\r
+\r
+     For this case use:\r
+\r
+        << fprintf(out," \/\* obsolete \*\/ ");\r
+\r
+     Reported by K.J. Cummings (cummings@peritus.com).\r
+\r
+#11. User hook for deallocation of variables on guess fail\r
+\r
+     The mechanism outlined in Item #108 works only for\r
+     heap allocated variables.\r
+\r
+#10. Label re-initialization in ( X {y:Y} )*\r
+\r
+     If a label assignment is optional and appears in a\r
+     (...)* or (...)+ block it will not be reset to NULL\r
+     when it is skipped by a subsequent iteration.\r
+\r
+     Consider the example:\r
+\r
+            ( X { y:Y })* Z\r
+\r
+     with input:\r
+\r
+            X Y X Z\r
+\r
+     The first time through the block Y will be matched and\r
+     y will be set to point to the token.  On the second\r
+     iteration of the (...)* block there is no match for Y.\r
+     But y will not be reset to NULL, as the user might\r
+     expect, it will contain a reference to the Y that was\r
+     matched in the first iteration.\r
+\r
+     The work-around is to manually reset y:\r
+\r
+            ( X << y = NULL; >> { y:Y } )* Z\r
+\r
+        or\r
+\r
+            ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z\r
+\r
+     Reported by Jeff Vincent (JVincent@novell.com).\r
+\r
+#9. PCCTAST.h PCCTSAST::setType() is a noop\r
+\r
+#8. #tokdefs with ~Token and .\r
+\r
+    THM: I have been unable to reproduce this problem.\r
+\r
+    When antlr uses #tokdefs to define tokens the fields of\r
+    #errclass and #tokclass do not get properly defined.\r
+    When it subsequently attempts to take the complement of\r
+    the set of tokens (using ~Token or .) it can refer to\r
+    tokens which don't have names, generating a fatal error.\r
+\r
+#7. DLG crashes on some invalid inputs\r
+\r
+    THM:  In MR20 have fixed the most common cases.\r
+\r
+    The following token defintion will cause DLG to crash.\r
+\r
+        #token "()"\r
+\r
+    Reported by  Mengue Olivier (dolmen@bigfoot.com).\r
+\r
+#6. On MS systems \n\r is treated as two new lines\r
+\r
+    Fixed.\r
+\r
+#5. Token expressions in #tokclass\r
+\r
+    #errclass does not support TOK1..TOK2 or ~TOK syntax.\r
+    #tokclass does not support ~TOKEN syntax\r
+\r
+    A workaround for #errclass TOK1..TOK2 is to use a\r
+    #tokclass.\r
+\r
+    Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)\r
+\r
+#4. A #tokdef must appear "early" in the grammar file.\r
+\r
+    The "early" section of the grammar file is the only\r
+    place where the following directives may appear:\r
+\r
+        #header\r
+        #first\r
+        #tokdefs\r
+        #parser\r
+\r
+    Any other kind of statement signifiies the end of the\r
+    "early" section.\r
+\r
+#3. Use of PURIFY macro for C++ mode\r
+\r
+    Item #93 of the CHANGES_FROM_1.33 describes the use of\r
+    the PURIFY macro to zero arguments to be passed by\r
+    upward inheritance.\r
+\r
+        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
+\r
+    This may not be the right thing to do for C++ objects that\r
+    have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
+\r
+    For those cases one should #define PURIFY to be an empty macro\r
+    in the #header or #first actions.\r
+\r
+#2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80.\r
+\r
+#1. The quality of support for systems with 8.3 file names leaves\r
+    much to be desired.  Since the kit is distributed using the\r
+    long file names and the make file uses long file names it requires\r
+    some effort to generate.  This will probably not be changed due\r
+    to the large number of systems already written using the long\r
+    file names.\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README
new file mode 100644 (file)
index 0000000..84e0312
--- /dev/null
@@ -0,0 +1,171 @@
+---------------------------------------------------------------------------------\r
+README for pccts 1.33mr20 (Maintenance Release #20) release date 5 August 1999\r
+---------------------------------------------------------------------------------\r
+\r
+                          Parr Research Corporation\r
+                                    with\r
+                  Purdue University Electrical Engineering\r
+                                    and\r
+                       University of Minnesota, AHPCRC\r
+\r
+                                Terence Parr\r
+                                Russell Quong\r
+                                 Will Cohen\r
+                                 Hank Dietz\r
+\r
+\r
+A central place for information about PCCTS 1.33 is:\r
+\r
+        http://www.polhode.com/pccts.html\r
+\r
+The maintenance release is available from:\r
+\r
+        http://www.polhode.com/pccts133mr.zip\r
+\r
+There is a ready-to-run version for win32 for Microsoft Visual Studio\r
+at the same site.  It is available from:\r
+\r
+        http://www.polhode.com/win32.zip\r
+\r
+There is a newsgroup dedicated to pccts 1.33 and related topics:\r
+\r
+        comp.compilers.tools.pccts\r
+\r
+You may also want to register for the antlr-interest mailing list\r
+which is provided gratis by the following service:\r
+\r
+        http://www.onesite.com\r
+\r
+New users should visit http://www.polhode.com/pccts.html in\r
+order to get the following document:\r
+\r
+        "Notes For New Users of PCCTS"\r
+\r
+This is a Postscript file of about 40 pages which is extremely \r
+useful for someone starting out. It is a based on 1.33mr7 so is a\r
+little bit out-of-date.  The section on semantic predicates is\r
+very out of date, but I have not had time to revise it.\r
+\r
+When you have a little more experience, be sure to review the\r
+following documents in the distribution kit:\r
+\r
+            CHANGES_FROM_133.txt\r
+            CHANGES_FROM_133_BEFORE_MR13.txt\r
+            KNOWN_PROBLEMS.txt\r
+\r
+-------------------------------------------------------------------------\r
+                      INSTALLATION (Unix)\r
+-------------------------------------------------------------------------\r
+0. Download http://www.polhode.com/pccts133mr.zip\r
+\r
+1. Unzip the distribution kit to your preferred location.\r
+\r
+2. cd to the main pccts directory.\r
+\r
+3. make\r
+\r
+   This will create:\r
+\r
+        antlr.exe\r
+        dlg.exe\r
+        sorcerer.exe\r
+        genmk.exe\r
+\r
+4. Add pccts/bin to your path.\r
+\r
+5. To get an up-to-date list of program options execute the\r
+   program with no command line options.  To get up-to-date\r
+   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
+   at:\r
+\r
+           http://www.polhode.com/pccts.html.\r
+\r
+6. You need not create a library.  The makefile created by genmk\r
+   assumes that the files are not part of a library. \r
+\r
+   If you wish to create a library from elements of pccts/h:\r
+\r
+   If the first letter of the filename is lowercase (uppercase) it is\r
+   related to the code generated using the pccts C mode (C++ mode).\r
+   Some of the .c and .cpp files in the h directory are not meant to\r
+   be placed in a library and will not compile because they are meant\r
+   to be #include in pccts generated files which are grammar specific.\r
+\r
+   For C++ users place the following elements in the library:\r
+\r
+        AParser.cpp\r
+        ASTBase.cpp\r
+        ATokenBuffer.cpp\r
+        BufFileInput.cpp (optional)\r
+        DLexerBase.cpp\r
+        PCCTSAST.cpp\r
+        SList.cpp\r
+\r
+-------------------------------------------------------------------------\r
+                    INSTALLATION (Win32)\r
+-------------------------------------------------------------------------\r
+\r
+I've tried to keep the win32 kit to the minimum necessary to get \r
+up and running.  The complete kit contains additional information\r
+(some historical), source code, and DevStudio projects for \r
+rebuilding pccts from the source code.\r
+\r
+The kit is now distributed with both MSVC 5 and MSVC6 style projects.\r
+\r
+0. Download http://www.polhode.com/win32.zip.\r
+\r
+   You may also wish to download:\r
+\r
+        http://www.polhode.com/CHANGES_FROM_133.txt\r
+        http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt\r
+        http://www.polhode.com/KNOWN_PROBLEMS.txt\r
+\r
+1. Unzip the distribution kit to your preferred location.\r
+\r
+   This will create:\r
+\r
+         a pccts directory tree\r
+            pccts/bin/*.exe\r
+            pccts/lib/*.lib\r
+            pccts/h/*\r
+            sorcerer/lib/*\r
+            sorcerer/h/*\r
+\r
+         an example directory tree\r
+            example\calcAST\*\r
+            example\simple\*\r
+\r
+2. Define the environment variable PCCTS to point to the main\r
+   pccts directory.\r
+\r
+3. Try building the simple project: example\simple\simple50.dsw\r
+   or simple60.dsw.\r
+\r
+4. Try building the complex project: example\calcAST\calcAST50.dsw\r
+   or calcAST60.dsw.\r
+\r
+-------------------------------------------------------------------------\r
+                      INSTALLATION (DEC/VMS)\r
+-------------------------------------------------------------------------\r
+\r
+DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net)\r
+\r
+0. Download http://www.polhode.com/pccts133mr.zip\r
+\r
+1. Unzip the distribution kit to your preferred location.\r
+\r
+2. set default to the main pccts directory.\r
+\r
+3. @makefile.vms\r
+\r
+   This will create in directory [.bin]:\r
+\r
+        antlr.exe\r
+        dlg.exe\r
+        sorcerer.exe\r
+        genmk.exe\r
+\r
+5. To get an up-to-date list of program options execute the\r
+   program with no command line options.  To get up-to-date\r
+   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
+   at http://www.polhode.com/pccts.html.\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe
new file mode 100644 (file)
index 0000000..a2bfa1f
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe
new file mode 100644 (file)
index 0000000..166f8b7
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe
new file mode 100644 (file)
index 0000000..9b34335
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp
new file mode 100644 (file)
index 0000000..13b91e5
--- /dev/null
@@ -0,0 +1,815 @@
+/* ANTLRParser.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdlib.h"\r
+#include "pccts_stdarg.h"\r
+#include "pccts_string.h"\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+/* I have to put this here due to C++ limitation\r
+ * that you can't have a 'forward' decl for enums.\r
+ * I hate C++!!!!!!!!!!!!!!!\r
+ * Of course, if I could use real templates, this would go away.\r
+ */\r
+// MR1\r
+// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
+// MR1                         ANTLRTokenType enum\r
+// MR1\r
+\r
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999};          // MR1\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include ATOKEN_H\r
+#include ATOKENBUFFER_H\r
+#include APARSER_H\r
+\r
+static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000;    /* MR14 */\r
+static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000;  /* MR14 */\r
+\r
+                 /* L o o k a h e a d  M a c r o s */\r
+\r
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte;\r
+ * we only use 8 bits of it.\r
+ */\r
+SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = {\r
+       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
+       0x00000010, 0x00000020, 0x00000040, 0x00000080\r
+};\r
+\r
+char ANTLRParser::eMsgBuffer[500] = "";\r
+\r
+ANTLRParser::\r
+~ANTLRParser()\r
+{\r
+       delete [] token_type;\r
+    delete [] zzFAILtext;       // MR16 Manfred Kogler\r
+}\r
+\r
+ANTLRParser::\r
+ANTLRParser(ANTLRTokenBuffer *_inputTokens,\r
+                       int k,\r
+                       int use_inf_look,\r
+                       int dlook,\r
+                       int ssize)\r
+{\r
+       LLk = k;\r
+       can_use_inf_look = use_inf_look;\r
+/* MR14 */    if (dlook != 0) {\r
+/* MR14 */      panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode");\r
+/* MR14 */\r
+/* MR14 */    };\r
+    demand_look = 0;    /* demand_look = dlook; */\r
+    bsetsize = ssize;\r
+       guessing = 0;\r
+       token_tbl = NULL;\r
+       eofToken = (ANTLRTokenType)1;\r
+\r
+       // allocate lookahead buffer\r
+       token_type = new ANTLRTokenType[LLk];\r
+       lap = 0;\r
+       labase = 0;\r
+#ifdef ZZDEFER_FETCH\r
+       stillToFetch = 0;                                                   // MR19\r
+#endif\r
+       dirty = 0;\r
+    inf_labase = 0;                                                     // MR7\r
+    inf_last = 0;                                                       // MR7\r
+       /* prime lookahead buffer, point to inputTokens */\r
+       this->inputTokens = _inputTokens;\r
+       this->inputTokens->setMinTokens(k);\r
+       _inputTokens->setParser(this);                                                      // MR1\r
+    resynchConsumed=1;                                                  // MR8\r
+    zzFAILtext=NULL;                                                    // MR9\r
+    traceOptionValueDefault=0;                                          // MR10\r
+    traceReset();                                                       // MR10\r
+    zzGuessSeq=0;                                                       // MR10\r
+    syntaxErrCount=0;                                                   // MR11\r
+}\r
+\r
+void ANTLRParser::init()\r
+{\r
+   prime_lookahead();\r
+   resynchConsumed=1;                                                   // MR8\r
+   traceReset();                                                        // MR10\r
+}\r
+\r
+void ANTLRParser::traceReset()\r
+{\r
+   traceOptionValue=traceOptionValueDefault;\r
+   traceGuessOptionValue=1;\r
+   traceCurrentRuleName=NULL;\r
+   traceDepth=0;\r
+}\r
+\r
+int ANTLRParser::\r
+guess(ANTLRParserState *st)\r
+{\r
+       saveState(st);\r
+       guessing = 1;\r
+       return setjmp(guess_start.state);\r
+}\r
+\r
+void ANTLRParser::\r
+saveState(ANTLRParserState *buf)\r
+{\r
+       buf->guess_start = guess_start;\r
+       buf->guessing = guessing;\r
+       buf->inf_labase = inf_labase;\r
+       buf->inf_last = inf_last;\r
+       buf->dirty = dirty;\r
+    buf->traceOptionValue=traceOptionValue;            /* MR10 */\r
+    buf->traceGuessOptionValue=traceGuessOptionValue;  /* MR10 */\r
+    buf->traceCurrentRuleName=traceCurrentRuleName;    /* MR10 */\r
+    buf->traceDepth=traceDepth;                        /* MR10 */\r
+}\r
+\r
+void ANTLRParser::\r
+restoreState(ANTLRParserState *buf)\r
+{\r
+       int     i;\r
+    int     prevTraceOptionValue;\r
+\r
+       guess_start = buf->guess_start;\r
+       guessing = buf->guessing;\r
+       inf_labase = buf->inf_labase;\r
+       inf_last = buf->inf_last;\r
+       dirty = buf->dirty;\r
+\r
+       // restore lookahead buffer from k tokens before restored TokenBuffer position\r
+       // if demand_look, then I guess we don't look backwards for these tokens.\r
+       for (i=1; i<=LLk; i++) token_type[i-1] =\r
+               inputTokens->bufferedToken(i-LLk)->getType();\r
+       lap = 0;\r
+       labase = 0;\r
+\r
+    /* MR10 */\r
+\r
+    prevTraceOptionValue=traceOptionValue;\r
+    traceOptionValue=buf->traceOptionValue;\r
+    if ( (prevTraceOptionValue > 0) !=\r
+             (traceOptionValue > 0)) {\r
+      if (traceCurrentRuleName != NULL) {  /* MR21 */\r
+          if (traceOptionValue > 0) {\r
+            fprintf(stderr,\r
+                   "trace enable restored in rule %s depth %d\n",\r
+                   traceCurrentRuleName,\r
+                   traceDepth);\r
+          };\r
+          if (traceOptionValue <= 0) {\r
+            fprintf(stderr,\r
+            "trace disable restored in rule %s depth %d\n",\r
+            traceCurrentRuleName, /* MR21 */\r
+            traceDepth);\r
+          };\r
+       }\r
+    };\r
+    traceGuessOptionValue=buf->traceGuessOptionValue;\r
+    traceCurrentRuleName=buf->traceCurrentRuleName;\r
+    traceDepth=buf->traceDepth;\r
+    traceGuessDone(buf);\r
+}\r
+\r
+/* Get the next symbol from the input stream; put it into lookahead buffer;\r
+ * fill token_type[] fast reference cache also.  NLA is the next place where\r
+ * a lookahead ANTLRAbstractToken should go.\r
+ */\r
+void ANTLRParser::\r
+consume()\r
+{\r
+\r
+#ifdef ZZDEBUG_CONSUME_ACTION\r
+    zzdebug_consume_action();\r
+#endif\r
+\r
+// MR19 V.H. Simonis\r
+//      Defer Fetch feature\r
+//      Moves action of consume() into LA() function\r
+\r
+#ifdef ZZDEFER_FETCH\r
+      stillToFetch++;\r
+#else\r
+      NLA = inputTokens->getToken()->getType();\r
+      dirty--;\r
+      lap = (lap+1)&(LLk-1);\r
+#endif\r
+\r
+}\r
+\r
+_ANTLRTokenPtr ANTLRParser::\r
+LT(int i)\r
+{\r
+\r
+// MR19 V.H. Simonis\r
+//      Defer Fetch feature\r
+//      Moves action of consume() into LA() function\r
+\r
+#ifdef ZZDEFER_FETCH\r
+    undeferFetch();\r
+#endif\r
+\r
+#ifdef DEBUG_TOKENBUFFER\r
+       if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
+       {\r
+               char buf[2000];                 /* MR20 Was "static" */\r
+        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);\r
+               panic(buf);\r
+       }\r
+#endif\r
+       return inputTokens->bufferedToken(i-LLk);\r
+}\r
+\r
+void\r
+ANTLRParser::\r
+look(int k)\r
+{\r
+       int i, c = k - (LLk-dirty);\r
+       for (i=1; i<=c; i++) consume();\r
+}\r
+\r
+/* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK);\r
+ */\r
+void\r
+ANTLRParser::\r
+prime_lookahead()\r
+{\r
+       int i;\r
+       for(i=1;i<=LLk; i++) consume();\r
+       dirty=0;\r
+       // lap = 0;     // MR14 Sinan Karasu (sinan.karasu@boeing.com)\r
+       // labase = 0;  // MR14\r
+    labase=lap;     // MR14\r
+}\r
+\r
+/* check to see if the current input symbol matches '_t'.\r
+ * During NON demand lookahead mode, dirty will always be 0 and\r
+ * hence the extra code for consuming tokens in _match is never\r
+ * executed; the same routine can be used for both modes.\r
+ */\r
+int ANTLRParser::\r
+_match(ANTLRTokenType _t, ANTLRChar **MissText,\r
+          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
+          SetWordType **MissSet)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( LA(1)!=_t ) {\r
+               *MissText=NULL;\r
+               *MissTok= _t; *BadTok = LT(1);\r
+               *MissSet=NULL;\r
+               return 0;\r
+       }\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+/* check to see if the current input symbol matches '_t'.\r
+ * Used during exception handling.\r
+ */\r
+int ANTLRParser::\r
+_match_wsig(ANTLRTokenType _t)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( LA(1)!=_t ) return 0;\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+/* check to see if the current input symbol matches any token in a set.\r
+ * During NON demand lookahead mode, dirty will always be 0 and\r
+ * hence the extra code for consuming tokens in _match is never\r
+ * executed; the same routine can be used for both modes.\r
+ */\r
+int ANTLRParser::\r
+_setmatch(SetWordType *tset, ANTLRChar **MissText,\r
+          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
+          SetWordType **MissSet)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( !set_el(LA(1), tset) ) {\r
+               *MissText=NULL;\r
+               *MissTok= (ANTLRTokenType)0; *BadTok=LT(1);\r
+               *MissSet=tset;\r
+               return 0;\r
+       }\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+int ANTLRParser::\r
+_setmatch_wsig(SetWordType *tset)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( !set_el(LA(1), tset) ) return 0;\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+                   /* Exception handling routines */\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
+//\r
+void ANTLRParser::\r
+consumeUntil(SetWordType *st)\r
+{\r
+       ANTLRTokenType          tmp;                                                            // MR1\r
+       const                   int Eof=1;                                          // MR1\r
+       while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); }       // MR1\r
+}\r
+\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
+//\r
+void ANTLRParser::\r
+consumeUntilToken(int t)\r
+{\r
+       int     tmp;                                                            // MR1\r
+       const   int Eof=1;                                                  // MR1\r
+       while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); }                 // MR1\r
+}\r
+\r
+\r
+                        /* Old error stuff */\r
+\r
+void ANTLRParser::\r
+resynch(SetWordType *wd,SetWordType mask)\r
+{\r
+\r
+/* MR8              S.Bochnak@microtool.com.pl                          */\r
+/* MR8              Change file scope static "consumed" to instance var */\r
+\r
+       /* if you enter here without having consumed a token from last resynch\r
+        * force a token consumption.\r
+        */\r
+/* MR8 */      if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;}\r
+\r
+       /* if current token is in resynch set, we've got what we wanted */\r
+\r
+/* MR8 */      if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;}\r
+       \r
+       /* scan until we find something in the resynch set */\r
+\r
+               while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();}\r
+\r
+/* MR8 */      resynchConsumed=1;\r
+}\r
+\r
+/* standard error reporting function that assumes DLG-based scanners;\r
+ * you should redefine in subclass to change it or if you use your\r
+ * own scanner.\r
+ */\r
+void ANTLRParser::\r
+syn(_ANTLRTokenPtr tok, ANTLRChar *egroup, SetWordType *eset,\r
+       ANTLRTokenType etok, int k)\r
+{\r
+       int line;\r
+\r
+       line = LT(1)->getLine();\r
+\r
+    syntaxErrCount++;                                   /* MR11 */\r
+       fprintf(stderr, "line %d: syntax error at \"%s\"",\r
+                                       line,\r
+                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')? \r
+                                        "<eof>":LT(1)->getText() /* MR21a */);\r
+       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+       if ( k==1 ) fprintf(stderr, " missing");\r
+       else\r
+       {\r
+               fprintf(stderr, "; \"%s\" not", LT(1)->getText());\r
+               if ( set_deg(eset)>1 ) fprintf(stderr, " in");\r
+       }\r
+       if ( set_deg(eset)>0 ) edecode(eset);\r
+       else fprintf(stderr, " %s", token_tbl[etok]);\r
+       if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);\r
+       fprintf(stderr, "\n");\r
+}\r
+\r
+/* is b an element of set p? */\r
+int ANTLRParser::\r
+set_el(ANTLRTokenType b, SetWordType *p)\r
+{\r
+       return( p[DIVWORD(b)] & bitmask[MODWORD(b)] );\r
+}\r
+\r
+int ANTLRParser::\r
+set_deg(SetWordType *a)\r
+{\r
+       /* Fast compute degree of a set... the number\r
+          of elements present in the set.  Assumes\r
+          that all word bits are used in the set\r
+       */\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(a[bsetsize]);\r
+       register int degree = 0;\r
+\r
+       if ( a == NULL ) return 0;\r
+       while ( p < endp )\r
+       {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if (t & *b) ++degree;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+               p++;\r
+       }\r
+\r
+       return(degree);\r
+}\r
+\r
+void ANTLRParser::\r
+edecode(SetWordType *a)\r
+{\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(p[bsetsize]);\r
+       register unsigned e = 0;\r
+\r
+       if ( set_deg(a)>1 ) fprintf(stderr, " {");\r
+       do {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if ( t & *b ) fprintf(stderr, " %s", token_tbl[e]);\r
+                       e++;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+       } while (++p < endp);\r
+       if ( set_deg(a)>1 ) fprintf(stderr, " }");\r
+}\r
+\r
+/* input looks like:\r
+ *      zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk)\r
+ * where the zzMiss stuff is set here to the token that did not match\r
+ * (and which set wasn't it a member of).\r
+ */\r
+\r
+// MR9 29-Sep-97    Stan Bochnak (S.Bochnak@microTool.com.pl)\r
+// MR9              Original fix to static allocated text didn't\r
+// MR9                work because a pointer to it was passed back\r
+// MR9                to caller.  Replace with instance variable.\r
+\r
+const int   SETWORDCOUNT=20;\r
+\r
+void\r
+ANTLRParser::FAIL(int k, ...)\r
+{\r
+//\r
+//  MR1 10-Apr-97      \r
+//\r
+\r
+    if (zzFAILtext == NULL) zzFAILtext=new char [1000];          // MR9\r
+    SetWordType **f=new SetWordType *[SETWORDCOUNT];             // MR1 // MR9\r
+    SetWordType **miss_set;\r
+    ANTLRChar **miss_text;\r
+    _ANTLRTokenPtr *bad_tok;\r
+    ANTLRChar **bad_text;\r
+//\r
+//  7-Apr-97 133MR1\r
+//             err_k is passed as a "int *", not "unsigned *"\r
+//\r
+    int        *err_k;                                                         // MR1\r
+    int i;\r
+    va_list ap;\r
+\r
+    va_start(ap, k);\r
+\r
+    zzFAILtext[0] = '\0';\r
+       if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer");\r
+    for (i=1; i<=k; i++)    /* collect all lookahead sets */\r
+    {\r
+        f[i-1] = va_arg(ap, SetWordType *);\r
+    }\r
+    for (i=1; i<=k; i++)    /* look for offending token */\r
+    {\r
+        if ( i>1 ) strcat(zzFAILtext, " ");\r
+        strcat(zzFAILtext, LT(i)->getText());\r
+        if ( !set_el(LA(i), f[i-1]) ) break;\r
+    }\r
+    miss_set = va_arg(ap, SetWordType **);\r
+    miss_text = va_arg(ap, ANTLRChar **);\r
+    bad_tok = va_arg(ap, _ANTLRTokenPtr *);\r
+    bad_text = va_arg(ap, ANTLRChar **);\r
+    err_k = va_arg(ap, int *);                                                         // MR1\r
+    if ( i>k )\r
+    {\r
+        /* bad; lookahead is permutation that cannot be matched,\r
+         * but, the ith token of lookahead is valid at the ith position\r
+         * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
+         */\r
+        *miss_set = NULL;\r
+        *miss_text = LT(1)->getText();\r
+        *bad_tok = LT(1);\r
+        *bad_text = (*bad_tok)->getText();\r
+        *err_k = k;\r
+//\r
+//  MR4 20-May-97      erroneously deleted contents of f[]\r
+//  MR4                                reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
+//  MR1 10-Apr-97      release temporary storage\r
+//\r
+      delete [] f;                                                      // MR1\r
+      return;                                                           // MR1\r
+    }\r
+/*  fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
+    *miss_set = f[i-1];\r
+    *miss_text = zzFAILtext;\r
+    *bad_tok = LT(i);\r
+    *bad_text = (*bad_tok)->getText();\r
+    if ( i==1 ) *err_k = 1;\r
+    else *err_k = k;\r
+//\r
+//  MR4 20-May-97      erroneously deleted contents of f[]\r
+//  MR4                              reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
+//  MR1 10-Apr-97      release temporary storage\r
+//\r
+    delete [] f;                                                        // MR1\r
+    return;                                                             // MR1\r
+}\r
+\r
+int ANTLRParser::\r
+_match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows)\r
+{\r
+       if ( dirty==LLk ) consume();\r
+\r
+       if ( LA(1)!=tokenWanted )\r
+       {\r
+        syntaxErrCount++;                                   /* MR11 */\r
+               fprintf(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               LT(1)->getLine(),\r
+                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
+                               token_tbl[tokenWanted]);\r
+               consumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               dirty++;\r
+               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
+/*             if ( !demand_look ) consume(); */\r
+               return 1;\r
+       }\r
+}\r
+\r
+\r
+int ANTLRParser::\r
+_setmatch_wdfltsig(SetWordType *tokensWanted,\r
+                                       ANTLRTokenType tokenTypeOfSet,\r
+                                       SetWordType *whatFollows)\r
+{\r
+       if ( dirty==LLk ) consume();\r
+       if ( !set_el(LA(1), tokensWanted) )\r
+       {\r
+        syntaxErrCount++;                                   /* MR11 */\r
+               fprintf(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               LT(1)->getLine(),\r
+                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
+                               token_tbl[tokenTypeOfSet]);\r
+               consumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               dirty++;\r
+               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
+/*             if ( !demand_look ) consume(); */\r
+               return 1;\r
+       }\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsgd(char *err,int d)\r
+{\r
+       sprintf(eMsgBuffer, err, d);    // dangerous, but I don't care\r
+       return eMsgBuffer;\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsg(char *err, char *s)\r
+{\r
+       sprintf(eMsgBuffer, err, s);\r
+       return eMsgBuffer;\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsg2(char *err,char *s, char *t)\r
+{\r
+       sprintf(eMsgBuffer, err, s, t);\r
+       return eMsgBuffer;\r
+}\r
+\r
+void ANTLRParser::\r
+panic(const char *msg)  // MR20 const\r
+{\r
+       fprintf(stderr, "ANTLR panic: %s\n", msg);\r
+       exit(PCCTS_EXIT_FAILURE);           // MR1\r
+}\r
+\r
+const ANTLRChar *ANTLRParser::          // MR1\r
+parserTokenName(int tok) {              // MR1\r
+       return token_tbl[tok];              // MR1\r
+}                                       // MR1\r
+\r
+void ANTLRParser::traceGuessDone(const ANTLRParserState *state) {\r
+\r
+  int   doIt=0;\r
+\r
+  if (traceCurrentRuleName == NULL) return;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
+        state->traceCurrentRuleName,\r
+        LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+        state->traceDepth);\r
+    if (state->guessing != 0) {\r
+      fprintf(stderr," (guess mode continues - an enclosing guess is still active)");\r
+    } else {\r
+      fprintf(stderr," (guess mode ends)");\r
+    };\r
+    fprintf(stderr,"\n");\r
+  };\r
+}\r
+\r
+void ANTLRParser::traceGuessFail() {\r
+\r
+  int   doIt=0;\r
+\r
+  if (traceCurrentRuleName == NULL) return;     /* MR21 */\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess failed\n");\r
+  };\r
+}\r
+\r
+/* traceOption:\r
+     zero value turns off trace\r
+*/\r
+\r
+void ANTLRParser::tracein(const ANTLRChar * rule) {\r
+\r
+  int       doIt=0;\r
+\r
+  traceDepth++;\r
+  traceCurrentRuleName=rule;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"enter rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+            traceDepth);\r
+    if (guessing) fprintf(stderr," guessing");\r
+    fprintf(stderr,"\n");\r
+  };\r
+  return;\r
+}\r
+\r
+void ANTLRParser::traceout(const ANTLRChar * rule) {\r
+\r
+  int       doIt=0;\r
+\r
+  traceDepth--;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"exit rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+            traceDepth+1);\r
+    if (guessing) fprintf(stderr," guessing");\r
+    fprintf(stderr,"\n");\r
+  };\r
+}\r
+\r
+int ANTLRParser::traceOption(int delta) {\r
+\r
+    int     prevValue=traceOptionValue;\r
+\r
+    traceOptionValue=traceOptionValue+delta;\r
+\r
+    if (traceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && traceOptionValue > 0) {\r
+        fprintf(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+      if (prevValue > 0 && traceOptionValue <= 0) {\r
+        fprintf(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+    };\r
+\r
+    return  prevValue;\r
+}\r
+\r
+int ANTLRParser::traceGuessOption(int delta) {\r
+\r
+    int     prevValue=traceGuessOptionValue;\r
+\r
+    traceGuessOptionValue=traceGuessOptionValue+delta;\r
+\r
+    if (traceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && traceGuessOptionValue > 0) {\r
+        fprintf(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+      if (prevValue > 0 && traceGuessOptionValue <= 0) {\r
+        fprintf(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+    };\r
+    return prevValue;\r
+}\r
+\r
+// MR19 V.H. Simonis Defer Fetch feature\r
+\r
+void ANTLRParser::undeferFetch()\r
+{\r
+\r
+#ifdef ZZDEFER_FETCH\r
+    if (stillToFetch) {\r
+        for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) {\r
+               NLA = inputTokens->getToken()->getType();\r
+               dirty--;\r
+               lap = (lap+1)&(LLk-1);\r
+        }\r
+        stillToFetch = 0;\r
+    }\r
+#else\r
+    return;\r
+#endif\r
+\r
+}\r
+\r
+int ANTLRParser::isDeferFetchEnabled()\r
+{\r
+#ifdef ZZDEFER_FETCH\r
+    return 1;\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h
new file mode 100644 (file)
index 0000000..85fe921
--- /dev/null
@@ -0,0 +1,358 @@
+/* ANTLRParser.h\r
+ *\r
+ * Define the generic ANTLRParser superclass, which is subclassed to\r
+ * define an actual parser.\r
+ *\r
+ * Before entry into this file: ANTLRTokenType must be set.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef APARSER_H_GATE\r
+#define APARSER_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_setjmp.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENBUFFER_H\r
+\r
+#ifdef ZZCAN_GUESS\r
+#ifndef ZZINF_LOOK\r
+#define ZZINF_LOOK\r
+#endif\r
+#endif\r
+\r
+\r
+#define NLA      (token_type[lap&(LLk-1)])/* --> next LA */\r
+\r
+typedef unsigned char SetWordType;\r
+\r
+/* Define external bit set stuff (for SetWordType) */\r
+#define EXT_WORDSIZE  (sizeof(char)*8)\r
+#define EXT_LOGWORDSIZE  3\r
+\r
+           /* s y n t a c t i c  p r e d i c a t e  s t u f f */\r
+\r
+#ifndef zzUSER_GUESS_HOOK\r
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_DONE_HOOK\r
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
+#endif\r
+\r
+/* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */\r
+\r
+#define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen)\r
+#ifndef zzUSER_GUESS_FAIL_HOOK\r
+#define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq)\r
+#endif\r
+\r
+\r
+typedef struct _zzjmp_buf {\r
+      jmp_buf state;\r
+    } zzjmp_buf;\r
+\r
+/* these need to be macros not member functions */\r
+#define zzGUESS_BLOCK    ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen;\r
+#define zzNON_GUESS_MODE  if ( !guessing )\r
+#define zzGUESS_FAIL    guess_fail();\r
+\r
+/*  Note:  zzGUESS_DONE does not execute longjmp() */\r
+\r
+#define zzGUESS_DONE    {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
+#define zzGUESS        saveState(&zzst); \\r
+              guessing = 1; \\r
+                            zzGuessSeqFrozen = ++zzGuessSeq; \\r
+              _marker = inputTokens->mark(); \\r
+              zzrv = setjmp(guess_start.state); \\r
+                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
+                if ( zzrv ) zzGUESS_DONE\r
+\r
+#define zzTRACEdata     const ANTLRChar *zzTracePrevRuleName = NULL;\r
+\r
+#ifndef zzTRACEIN\r
+#define zzTRACEIN(r)  zzTracePrevRuleName=traceCurrentRuleName;tracein(r);\r
+#endif\r
+#ifndef zzTRACEOUT\r
+#define zzTRACEOUT(r)  traceout(r);traceCurrentRuleName=zzTracePrevRuleName;\r
+#endif\r
+\r
+                  /* a n t l r  p a r s e r  d e f */\r
+\r
+struct ANTLRParserState {\r
+  /* class variables */\r
+  zzjmp_buf guess_start;\r
+  int guessing;\r
+\r
+  int inf_labase;\r
+  int inf_last;\r
+\r
+  int dirty;\r
+\r
+    int             traceOptionValue;       // MR10\r
+    int             traceGuessOptionValue;  // MR10\r
+    const ANTLRChar *traceCurrentRuleName;  // MR10\r
+    int             traceDepth;             // MR10\r
+\r
+};\r
+\r
+/* notes:\r
+ *\r
+ * multiple inheritance is a cool way to include what stuff is needed\r
+ * in this structure (like guess stuff).  however, i'm not convinced that\r
+ * multiple inheritance works correctly on all platforms.  not that\r
+ * much space is used--just include all possibly useful members.\r
+ *\r
+ * the class should also be a template with arguments for the lookahead\r
+ * depth and so on.  that way, more than one parser can be defined (as\r
+ * each will probably have different lookahead requirements).  however,\r
+ * am i sure that templates work?  no, i'm not sure.\r
+ *\r
+ * no attributes are maintained and, hence, the 'asp' variable is not\r
+ * needed.  $i can still be referenced, but it refers to the token\r
+ * associated with that rule element.  question: where are the token's\r
+ * stored if not on the software stack?  in local variables created\r
+ * and assigned to by antlr.\r
+ */\r
+class ANTLRParser {\r
+protected:\r
+  /* class variables */\r
+  static SetWordType bitmask[sizeof(SetWordType)*8];\r
+  static char eMsgBuffer[500];\r
+\r
+protected:\r
+  int LLk;          // number of lookahead symbols (old LL_K)\r
+  int demand_look;\r
+  ANTLRTokenType eofToken;      // when do I stop during resynch()s\r
+  int bsetsize;                 // size of bitsets created by ANTLR in\r
+                        // units of SetWordType\r
+\r
+  ANTLRTokenBuffer *inputTokens;  //place to get input tokens\r
+\r
+  zzjmp_buf guess_start;    // where to jump back to upon failure\r
+  int guessing;        // if guessing (using (...)? predicate)\r
+\r
+  // infinite lookahead stuff\r
+  int can_use_inf_look;    // set by subclass (generated by ANTLR)\r
+  int inf_lap;\r
+  int inf_labase;\r
+  int inf_last;\r
+  int *_inf_line;\r
+\r
+  const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const\r
+\r
+  int dirty;          // used during demand lookahead\r
+\r
+  ANTLRTokenType *token_type;    // fast reference cache of token.getType()\r
+//  ANTLRLightweightToken **token;  // the token with all its attributes\r
+  int lap;\r
+  int labase;\r
+#ifdef ZZDEFER_FETCH\r
+  int stillToFetch;                               // MR19 V.H. Simonis\r
+#endif\r
+\r
+private:\r
+  void fill_inf_look();\r
+\r
+protected:\r
+  virtual void guess_fail() {                         // MR9 27-Sep-97 make virtual\r
+        traceGuessFail();                               // MR10\r
+        longjmp(guess_start.state, 1); }                // MR9\r
+  virtual void guess_done(ANTLRParserState *st) {     // MR9 27-Sep-97 make virtual\r
+         restoreState(st); }                            // MR9\r
+  virtual int guess(ANTLRParserState *);              // MR9 27-Sep-97 make virtual\r
+  void look(int);\r
+    int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,\r
+         _ANTLRTokenPtr *, SetWordType **);\r
+    int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,\r
+         _ANTLRTokenPtr *, SetWordType **);\r
+    int _match_wsig(ANTLRTokenType);\r
+    int _setmatch_wsig(SetWordType *);\r
+    virtual void consume();\r
+    virtual void resynch(SetWordType *wd,SetWordType mask); // MR21\r
+  void prime_lookahead();\r
+  virtual void tracein(const ANTLRChar *r);              // MR10\r
+  virtual void traceout(const ANTLRChar *r);             // MR10\r
+  static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);}  // x % EXT_WORDSIZE // MR9\r
+  static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;}  // x / EXT_WORDSIZE // MR9\r
+  int set_deg(SetWordType *);\r
+  int set_el(ANTLRTokenType, SetWordType *);\r
+  virtual void edecode(SetWordType *);        // MR1\r
+  virtual void FAIL(int k, ...);              // MR1\r
+    int                 traceOptionValue;                           // MR10\r
+    int                 traceGuessOptionValue;                      // MR10\r
+    const ANTLRChar     *traceCurrentRuleName;                      // MR10\r
+    int                 traceDepth;                                 // MR10\r
+    void                traceReset();                               // MR10\r
+    virtual void        traceGuessFail();                           // MR10\r
+    virtual void        traceGuessDone(const ANTLRParserState *);   // MR10\r
+    int                 zzGuessSeq;                                 // MR10\r
+\r
+public:\r
+  ANTLRParser(ANTLRTokenBuffer *,\r
+        int k=1,\r
+        int use_inf_look=0,\r
+        int demand_look=0,\r
+        int bsetsize=1);\r
+  virtual ~ANTLRParser();\r
+\r
+  virtual void init();\r
+  \r
+  ANTLRTokenType LA(int i)\r
+  {\r
+//\r
+//  MR14 demand look will always be 0 for C++ mode\r
+//\r
+////  return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :\r
+////            token_type[(lap+(i)-1)&(LLk-1)];\r
+\r
+// MR19 V.H. Simonis Defer fetch feature\r
+\r
+#ifdef ZZDEFER_FETCH\r
+      undeferFetch();\r
+#endif\r
+    return token_type[(lap+(i)-1)&(LLk-1)];\r
+  }\r
+  _ANTLRTokenPtr LT(int i);\r
+\r
+  void setEofToken(ANTLRTokenType t)  { eofToken = t; }\r
+  ANTLRTokenType getEofToken() const  { return eofToken; }    // MR14\r
+\r
+  void noGarbageCollectTokens()  { inputTokens->noGarbageCollectTokens(); }\r
+  void garbageCollectTokens()    { inputTokens->garbageCollectTokens(); }\r
+\r
+    virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,\r
+           SetWordType *eset, ANTLRTokenType etok, int k);\r
+  virtual void saveState(ANTLRParserState *);     // MR9 27-Sep-97 make virtual\r
+  virtual void restoreState(ANTLRParserState *);  // MR9 27-Sep-97 make virtual\r
+\r
+  virtual void panic(const char *msg); // MR20 const\r
+  static char *eMsgd(char *,int);\r
+  static char *eMsg(char *,char *);\r
+  static char *eMsg2(char *,char *,char *);\r
+\r
+  void consumeUntil(SetWordType *st);\r
+  void consumeUntilToken(int t);\r
+\r
+  virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,\r
+           ANTLRTokenType tokenTypeOfSet,\r
+           SetWordType *whatFollows);\r
+  virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,\r
+           SetWordType *whatFollows);\r
+  \r
+  const ANTLRChar * parserTokenName(int tok);      // MR1\r
+\r
+    int                 traceOptionValueDefault;        // MR11\r
+    int                 traceOption(int delta);         // MR11\r
+    int                 traceGuessOption(int delta);    // MR11\r
+\r
+//  MR8  5-Aug-97   S.Bochnak@microtool.com.pl\r
+//  MR8             Move resynch static local variable\r
+//  MR8               to class instance\r
+\r
+    int                 syntaxErrCount;                      // MR12\r
+    ANTLRTokenStream   *getLexer() const {                   // MR12\r
+      return inputTokens ? inputTokens->getLexer() : 0; }    // MR12\r
+protected:                                              // MR8\r
+    int     resynchConsumed;                            // MR8\r
+    char    *zzFAILtext; // workarea required by zzFAIL // MR9\r
+    void    undeferFetch();                             // MR19 V.H. Simonis\r
+    int     isDeferFetchEnabled();                      // MR19 V.H. Simonis\r
+};\r
+\r
+#define zzmatch(_t)              \\r
+  if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \\r
+         (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#define zzmatch_wsig(_t,handler)            \\r
+  if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
+\r
+#define zzsetmatch(_ts)              \\r
+  if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \\r
+         (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#define zzsetmatch_wsig(_ts, handler)        \\r
+  if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
+\r
+/* For the dflt signal matchers, a FALSE indicates that an error occurred\r
+ * just like the other matchers, but in this case, the routine has already\r
+ * recovered--we do NOT want to consume another token.  However, when\r
+ * the match was successful, we do want to consume hence _signal=0 so that\r
+ * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;"\r
+ * preamble.\r
+ */\r
+#define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \\r
+  if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \\r
+    _signal = MismatchedToken;\r
+\r
+#define zzmatch_wdfltsig(tokenWanted, whatFollows) \\r
+  if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken;\r
+\r
+\r
+//  MR1  10-Apr-97   zzfailed_pred() macro does not backtrack\r
+//  MR1        in guess mode.\r
+//  MR1      Identification and correction due to J. Lilley\r
+\r
+#ifndef zzfailed_pred\r
+#define zzfailed_pred(_p) \\r
+  if (guessing) { \\r
+    zzGUESS_FAIL; \\r
+  } else { \\r
+    fprintf(stdout,"line %d: semantic error; failed predicate: '%s'\n", \\r
+  LT(1)->getLine(), _p); \\r
+  }\r
+#endif\r
+\r
+#define zzRULE \\r
+    SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0;  \\r
+    _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)"";  \\r
+    int zzErrk=1,zzpf=0; \\r
+        zzTRACEdata \\r
+    ANTLRChar *zzMissText=(ANTLRChar *)"";\r
+\r
+#endif\r
+\r
+        /* S t a n d a r d  E x c e p t i o n  S i g n a l s */\r
+\r
+#define NoSignal      0\r
+#define MismatchedToken    1\r
+#define NoViableAlt      2\r
+#define NoSemViableAlt    3\r
+\r
+/* MR7  Allow more control over signalling                                  */\r
+/*        by adding "Unwind" and "SetSignal"                                */\r
+\r
+#define Unwind              4\r
+#define setSignal(newValue) *_retsignal=_signal=(newValue)\r
+#define suppressSignal       *_retsignal=_signal=0\r
+#define exportSignal        *_retsignal=_signal\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp
new file mode 100644 (file)
index 0000000..433a260
--- /dev/null
@@ -0,0 +1,244 @@
+/* Abstract syntax tree manipulation functions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdarg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "ASTBase.h"\r
+\r
+/* ensure that tree manipulation variables are current after a rule\r
+ * reference\r
+ */\r
+void\r
+ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_sibling == NULL ) return;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+       else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;\r
+       if ( *_tail==NULL ) *_tail = *_sibling;\r
+       while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;\r
+}\r
+\r
+/* add a child node to the current sibling list */\r
+void\r
+ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_tail != NULL ) (*_tail)->_right = this;\r
+       else {\r
+               *_sibling = this;\r
+               if ( *_root != NULL ) (*_root)->_down = *_sibling;\r
+       }\r
+       *_tail = this;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+}\r
+\r
+/* make a new AST node.  Make the newly-created\r
+ * node the root for the current sibling list.  If a root node already\r
+ * exists, make the newly-created node the root of the current root.\r
+ */\r
+void\r
+ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_root != NULL )\r
+               if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;\r
+       *_root = this;\r
+       (*_root)->_down = *_sibling;\r
+}\r
+\r
+/* Apply preorder_action(), etc.. to root then each sibling */\r
+//\r
+//  7-Apr-97 133MR1\r
+//     Fix suggested by Ron House (house@helios.usq.edu.au)\r
+//\r
+void\r
+ASTBase::preorder()\r
+{\r
+       ASTBase *tree = this;\r
+\r
+       while ( tree!= NULL )\r
+       {\r
+               if ( tree->_down != NULL ) {\r
+                       tree->preorder_before_action();                 // MR1  \r
+               };\r
+               tree->preorder_action();\r
+               if ( tree->_down!=NULL )\r
+               {\r
+                       tree->_down->preorder();\r
+                       tree->preorder_after_action();                  // MR1\r
+               }\r
+               tree = tree->_right;\r
+       }\r
+}\r
+\r
+/* free all AST nodes in tree; apply func to each before freeing */\r
+void\r
+ASTBase::destroy()\r
+{\r
+   ASTBase* tree = this;\r
+   while (tree) {\r
+      if (tree->_down) tree->_down->destroy();\r
+\r
+      ASTBase* cur = tree;\r
+      tree = tree->_right;\r
+      delete cur;\r
+   }\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually siblins lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ */\r
+ASTBase *\r
+ASTBase::tmake(ASTBase *root, ...)\r
+{\r
+       va_list ap;\r
+       register ASTBase *child, *sibling=NULL, *tail, *w;\r
+\r
+       va_start(ap, root);\r
+\r
+       if ( root != NULL )\r
+               if ( root->_down != NULL ) {  \r
+            root->reportOverwriteOfDownPointer();  /* MR21 Report problem which almost always an error */\r
+            return NULL;\r
+        }\r
+       child = va_arg(ap, ASTBase *);\r
+       while ( child != NULL )\r
+       {\r
+               for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->_right = child; tail = w;}\r
+               child = va_arg(ap, ASTBase *);\r
+       }\r
+       if ( root==NULL ) root = sibling;\r
+       else root->_down = sibling;\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+\r
+/* tree duplicate */\r
+// forgot to check for NULL this (TJP July 23,1995)\r
+ASTBase *\r
+ASTBase::dup()\r
+{\r
+       ASTBase *u, *t=this;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+/*\r
+       u = new ASTBase;\r
+       *u = *t;\r
+*/\r
+       u = (ASTBase *)this->shallowCopy();\r
+       if ( t->_right!=NULL ) u->_right = t->_right->dup();\r
+       else u->_right = NULL;\r
+       if ( t->_down!=NULL ) u->_down = t->_down->dup();\r
+       else u->_down = NULL;\r
+       return u;\r
+}\r
+#endif\r
+\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)\r
+//\r
+/* tree duplicate */\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+\r
+ASTBase *\r
+ASTDoublyLinkedBase::dup()\r
+{\r
+       ASTDoublyLinkedBase *u, *t=this;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+       u = (ASTDoublyLinkedBase *)this->shallowCopy();\r
+       u->_up = NULL;          /* set by calling invocation */\r
+       u->_left = NULL;\r
+       if (t->_right!=NULL) {                                          // MR1\r
+          u->_right=t->_right->dup();                                  // MR1\r
+         ((ASTDoublyLinkedBase *)u->_right)->_left = u;                // MR1\r
+        } else {                                                       // MR1\r
+         u->_right = NULL;                                             // MR1\r
+        };                                                             // MR1\r
+       if (t->_down!=NULL) {                                           // MR1\r
+         u->_down = t->_down->dup();                                   // MR1\r
+          ((ASTDoublyLinkedBase *)u->_down)->_up = u;                  // MR1\r
+        } else {                                                       // MR1\r
+         u->_down = NULL;                                              // MR1\r
+        };                                                             // MR1\r
+       return u;\r
+}\r
+\r
+#endif\r
+\r
+/*\r
+ * Set the 'up', and 'left' pointers of all nodes in 't'.\r
+ * Initial call is double_link(your_tree, NULL, NULL).\r
+ */\r
+void\r
+ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)\r
+{\r
+    ASTDoublyLinkedBase *t = this;\r
+\r
+    t->_left = (ASTDoublyLinkedBase *) left;\r
+    t->_up = (ASTDoublyLinkedBase *) up;\r
+    if (t->_down != NULL)\r
+               ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);\r
+    if (t->_right != NULL)\r
+               ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);\r
+}\r
+\r
+// MR21 ASTBase::reportOverwriteOfDownPointer\r
+\r
+void ASTBase::reportOverwriteOfDownPointer()\r
+{\r
+    panic("Attempt to overwrite down pointer in ASTBase::tmake");\r
+}\r
+\r
+// MR21 ASTBase::panic\r
+\r
+void ASTBase::panic(const char *msg)\r
+{\r
+       fprintf(stderr,"ASTBase panic: %s\n", msg);\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h
new file mode 100644 (file)
index 0000000..a5b3116
--- /dev/null
@@ -0,0 +1,119 @@
+/* Abstract syntax tree\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ASTBase_H\r
+#define ASTBase_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+#include "PCCTSAST.h"\r
+#endif\r
+\r
+/*\r
+ * Notes:\r
+ *\r
+ * To specify a copy constructor, subclass one of these classes and\r
+ * give the copy constructor.  To use dup(), you must define shallowCopy().\r
+ * shallowCopy() can use either a copy constructor or just copy the node\r
+ * itself.\r
+ */\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+class DllExportPCCTS ASTBase {\r
+#else\r
+class DllExportPCCTS ASTBase : public PCCTS_AST {\r
+#endif\r
+\r
+protected:\r
+  ASTBase *_right, *_down;\r
+\r
+public:\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+  ASTBase *right()  { return _right; }\r
+  ASTBase *down()      { return _down; }\r
+  void setRight(ASTBase *t)  { _right = (ASTBase *)t; }\r
+  void setDown(ASTBase *t)  { _down = (ASTBase *)t; }\r
+#else\r
+  PCCTS_AST *right()  { return _right; }  // define the SORCERER interface\r
+  PCCTS_AST *down()  { return _down; }\r
+  void setRight(PCCTS_AST *t)  { _right = (ASTBase *)t; }\r
+  void setDown(PCCTS_AST *t)  { _down = (ASTBase *)t; }\r
+#endif\r
+  ASTBase() { _right = _down = NULL; }\r
+  virtual ~ASTBase() { ; }\r
+#ifndef PCCTS_NOT_USING_SOR\r
+  virtual ASTBase *dup();\r
+#endif\r
+  void destroy();\r
+  void preorder();\r
+  static ASTBase *tmake(ASTBase *, ...);\r
+  static void link(ASTBase **, ASTBase **, ASTBase **);\r
+  void subchild(ASTBase **, ASTBase **, ASTBase **);\r
+  void subroot(ASTBase **, ASTBase **, ASTBase **);\r
+  virtual void preorder_action() { ; }\r
+  virtual void preorder_before_action() { printf(" ("); }\r
+  virtual void preorder_after_action() { printf(" )"); }\r
+    virtual void panic(const char *msg);         /* MR21 */\r
+    virtual void reportOverwriteOfDownPointer(); /* MR21 */\r
+};\r
+\r
+class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {\r
+protected:\r
+    ASTDoublyLinkedBase *_left, *_up;\r
+\r
+public:\r
+  void double_link(ASTBase *left, ASTBase *up);\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+  virtual ASTBase *dup();\r
+#endif\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+  ASTBase *left() { return _left; }\r
+  ASTBase *up() { return _up; }\r
+  void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; }    // MR6\r
+  void setUp(ASTBase *t)   { _up = (ASTDoublyLinkedBase *)t; }      // MR6\r
+#else\r
+  PCCTS_AST *left() { return _left; }\r
+  PCCTS_AST *up() { return _up; }\r
+  void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; }  // MR6\r
+  void setUp(PCCTS_AST *t)   { _up = (ASTDoublyLinkedBase *)t; }  // MR6\r
+#endif\r
+\r
+};\r
+\r
+class AST;  // announce that this class will be coming along shortly\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp
new file mode 100644 (file)
index 0000000..88df14b
--- /dev/null
@@ -0,0 +1,82 @@
+/* ATokPtr.C\r
+ *\r
+ * ANTLRToken MUST be defined before entry to this file.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Written by Russell Quong June 30, 1995\r
+ * Adapted by Terence Parr to ANTLR stuff\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "ATokPtr.h"\r
+\r
+void ANTLRTokenPtr::ref() const\r
+{\r
+    if (ptr_ != NULL) {\r
+               ptr_->ref();\r
+       }\r
+}\r
+\r
+void ANTLRTokenPtr::deref()\r
+{\r
+    if (ptr_ != NULL)\r
+    {\r
+               ptr_->deref();\r
+               if ( ptr_->nref()==0 )\r
+               {\r
+                   delete ptr_;\r
+                       ptr_ = NULL;\r
+               }\r
+    }\r
+}\r
+\r
+ANTLRTokenPtr::~ANTLRTokenPtr()\r
+{\r
+    deref();\r
+}\r
+\r
+//\r
+//  8-Apr-97   MR1     Make operator -> a const member function\r
+//                       as weall as some other member functions\r
+//\r
+void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs)     // MR1\r
+{\r
+    lhs.ref(); // protect against "xp = xp"; ie same underlying object\r
+    deref();\r
+    ptr_ = lhs.ptr_;\r
+}\r
+\r
+void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)\r
+{\r
+    if (addr != NULL) {\r
+       addr->ref();\r
+    }\r
+    deref();\r
+    ptr_ = addr;\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h
new file mode 100644 (file)
index 0000000..3e825f6
--- /dev/null
@@ -0,0 +1,88 @@
+/* ATokPtr.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Written by Russell Quong June 30, 1995\r
+ * Adapted by Terence Parr to ANTLR stuff\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ATokPtr_h\r
+#define ATokPtr_h\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+// pointer to a reference counted object\r
+// robust in that an unused ANTLRTokenPtr can point to NULL.\r
+\r
+class ANTLRAbstractToken;\r
+\r
+class DllExportPCCTS ANTLRTokenPtr {\r
+public:\r
+    ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}\r
+    ANTLRTokenPtr(const ANTLRTokenPtr &lhs)  {ptr_ = lhs.ptr_; lhs.ref();}\r
+    ~ANTLRTokenPtr();\r
+\r
+    // use ANTLRTokenPtr as a pointer to ANTLRToken\r
+//\r
+//  8-Apr-97  MR1  Make operator -> a const member function\r
+//        as well as some other member functions\r
+//\r
+    ANTLRAbstractToken *operator-> () const { return ptr_; }    // MR1\r
+//\r
+//  7-Apr-97 133MR1\r
+//       Fix suggested by Andreas Magnusson\r
+//      (Andreas.Magnusson@mailbox.swipnet.se)\r
+    void operator = (const ANTLRTokenPtr & lhs);          // MR1\r
+    void operator = (ANTLRAbstractToken *addr);\r
+    int operator != (const ANTLRTokenPtr &q) const          // MR1 // MR11 unsigned -> int\r
+  { return this->ptr_ != q.ptr_; }\r
+    int operator == (const ANTLRTokenPtr &q) const        // MR1 // MR11 unsigned -> int\r
+  { return this->ptr_ == q.ptr_; }\r
+    int operator == (const ANTLRAbstractToken *addr) const      // MR11\r
+    { return this->ptr_ == addr; }\r
+    int operator != (const ANTLRAbstractToken *addr) const      // MR11\r
+    { return this->ptr_ != addr; }\r
+\r
+    void ref() const;\r
+    void deref();\r
+\r
+protected:\r
+    ANTLRAbstractToken *ptr_;\r
+};\r
+\r
+//typedef ANTLRTokenPtr _ANTLRTokenPtr;\r
+\r
+/*\r
+ * Since you cannot redefine operator->() to return one of the user's\r
+ * token object types, we must down cast.  This is a drag.  Here's\r
+ * a macro that helps.  template: "mytoken(a-smart-ptr)->myfield".\r
+ */\r
+#define mytoken(tk) ((ANTLRToken *)(tk.operator->()))\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h
new file mode 100644 (file)
index 0000000..ef14516
--- /dev/null
@@ -0,0 +1,305 @@
+/* ANTLRToken.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ATOKEN_H_GATE\r
+#define ATOKEN_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_string.h"\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+// MR9      RJV (JVincent@novell.com) Not needed for variable length strings\r
+\r
+//// MR9 #ifndef ANTLRCommonTokenTEXTSIZE\r
+//// MR9 #define ANTLRCommonTokenTEXTSIZE          100\r
+//// MR9 #endif\r
+\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char ANTLRChar;\r
+\r
+/* D E F I N E  S M A R T  P O I N T E R S */\r
+\r
+//#include ATOKPTR_H   not tested yet, leave out\r
+class ANTLRAbstractToken;\r
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
+\r
+class ANTLRAbstractToken {\r
+public:\r
+    virtual ~ANTLRAbstractToken() {;}\r
+    virtual ANTLRTokenType getType() const = 0;\r
+    virtual void setType(ANTLRTokenType t) = 0;\r
+    virtual int getLine() const = 0;\r
+    virtual void setLine(int line) = 0;\r
+    virtual ANTLRChar *getText() const = 0;\r
+    virtual void setText(const ANTLRChar *) = 0;\r
+\r
+    /* This function will disappear when I can use templates */\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *text,\r
+                      int line) = 0;\r
+\r
+  /* define to satisfy ANTLRTokenBuffer's need to determine whether or\r
+     not a token object can be destroyed.  If nref()==0, no one has\r
+     a reference, and the object may be destroyed.  This function defaults\r
+     to 1, hence, if you use deleteTokens() message with a token object\r
+     not derived from ANTLRCommonRefCountToken, the parser will compile\r
+     but will not delete objects after they leave the token buffer.\r
+    */\r
+\r
+  virtual unsigned nref() const { return 1; }     // MR11\r
+  virtual void ref() {;}\r
+  virtual void deref() {;}\r
+\r
+  virtual void panic(const char *msg)             // MR20 const\r
+    {\r
+      fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg);\r
+      exit(PCCTS_EXIT_FAILURE);\r
+    }\r
+};\r
+\r
+/* This class should be subclassed.  It cannot store token type or text */\r
+\r
+class ANTLRRefCountToken : public ANTLRAbstractToken {\r
+public:\r
+#ifdef DBG_REFCOUNTTOKEN\r
+  static int ctor;\r
+  static int dtor;\r
+#endif\r
+protected:\r
+    unsigned refcnt_;\r
+#ifdef DBG_REFCOUNTTOKEN\r
+  char object[200];\r
+#endif\r
+\r
+public:\r
+  ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar *s)\r
+#ifndef DBG_REFCOUNTTOKEN\r
+    {\r
+      refcnt_ = 0;\r
+    }\r
+#else\r
+  {\r
+    ctor++;\r
+    refcnt_ = 0;\r
+    if ( t==1 ) sprintf(object,"tok_EOF");\r
+    else sprintf(object,"tok_%s",s);\r
+    fprintf(stderr, "ctor %s #%d\n",object,ctor);\r
+  }\r
+#endif\r
+  ANTLRRefCountToken()\r
+#ifndef DBG_REFCOUNTTOKEN\r
+    { refcnt_ = 0; }\r
+#else\r
+    {\r
+      ctor++;\r
+      refcnt_ = 0;\r
+      sprintf(object,"tok_blank");\r
+      fprintf(stderr, "ctor %s #%d\n",object,ctor);\r
+    }\r
+  virtual ~ANTLRRefCountToken()\r
+    {\r
+      dtor++;\r
+      if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n");\r
+      fprintf(stderr, "dtor %s #%d\n", object, dtor);\r
+      object[0]='\0';\r
+    }\r
+#endif\r
+\r
+  // reference counting stuff needed by ANTLRTokenPtr.\r
+  // User should not access these; for C++ language reasons, we had\r
+  // to make these public.  Yuck.\r
+\r
+  void ref()          { refcnt_++; }\r
+  void deref()        { refcnt_--; }\r
+  unsigned nref()  const { return refcnt_; }   // MR11\r
+\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+  {\r
+    panic("call to ANTLRRefCountToken::makeToken()\n");\r
+    return NULL;\r
+  }\r
+};\r
+\r
+class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {\r
+protected:\r
+  ANTLRTokenType _type;\r
+  int _line;\r
+  ANTLRChar *_text;               // MR9 RJV\r
+\r
+public:\r
+  ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s)\r
+  { setType(t); _line = 0; _text = NULL; setText(s); }\r
+  ANTLRCommonNoRefCountToken()\r
+  { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }\r
+\r
+  ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; }  // MR9 RJV: Added Destructor to remove string\r
+\r
+  ANTLRTokenType getType() const   { return _type; }\r
+  void setType(ANTLRTokenType t)  { _type = t; }\r
+  virtual int getLine() const    { return _line; }\r
+  void setLine(int line)        { _line = line; }\r
+  ANTLRChar *getText() const     { return _text; }\r
+    int getLength() const           { return strlen(getText()); }       // MR11\r
+\r
+// MR9 RJV: Added code for variable length strings to setText()\r
+\r
+  void setText(const ANTLRChar *s)\r
+  {  if (s != _text) {\r
+          if (_text) delete [] _text;\r
+          if (s != NULL) {\r
+           _text = new ANTLRChar[strlen(s)+1];\r
+            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
+            strcpy(_text,s);\r
+        } else {\r
+            _text = new ANTLRChar[1];\r
+            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
+            strcpy(_text,"");\r
+          };\r
+        };\r
+  }\r
+\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+    {\r
+      ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;\r
+      t->setType(tt); t->setText(txt); t->setLine(line);\r
+      return t;\r
+    }\r
+\r
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
+\r
+   ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) :\r
+         ANTLRAbstractToken(from) {\r
+    setType(from._type);\r
+   setLine(from._line);\r
+     _text=NULL;\r
+     setText(from._text);\r
+  };\r
+\r
+// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
+\r
+   virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) {\r
+\r
+//////  MR15 WatCom can't hack use of operator =()\r
+//////  Use this:  *( (ANTRLAbstractToken *) this)=rhs;\r
+\r
+     *( (ANTLRAbstractToken *) this ) = rhs;\r
+\r
+     setType(rhs._type);\r
+    setLine(rhs._line);\r
+     setText(rhs._text);\r
+     return *this;\r
+   };\r
+};\r
+\r
+class ANTLRCommonToken : public ANTLRRefCountToken {\r
+protected:\r
+  ANTLRTokenType       _type;\r
+  int                  _line;\r
+  ANTLRChar           *_text;               // MR9 RJV:Added\r
+\r
+public:\r
+  ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s)\r
+    { setType(t); _line = 0; _text = NULL; setText(s); }                    // MR9\r
+  ANTLRCommonToken()\r
+    { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }   // MR9\r
+\r
+  virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string\r
+\r
+  ANTLRTokenType getType() const   { return _type; }\r
+  void setType(ANTLRTokenType t)  { _type = t; }\r
+  virtual int getLine() const    { return _line; }\r
+  void setLine(int line)        { _line = line; }\r
+  ANTLRChar *getText() const    { return _text; }\r
+    int getLength() const           { return strlen(getText()); }       // MR11\r
+\r
+// MR9 RJV: Added code for variable length strings to setText()\r
+\r
+  void setText(const ANTLRChar *s)\r
+  {  if (s != _text) {\r
+          if (_text) delete [] _text;\r
+          if (s != NULL) {\r
+           _text = new ANTLRChar[strlen(s)+1];\r
+            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
+            strcpy(_text,s);\r
+        } else {\r
+            _text = new ANTLRChar[1];\r
+            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
+            strcpy(_text,"");\r
+          };\r
+        };\r
+  }\r
+\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+  {\r
+    ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
+    t->setLine(line);\r
+    return t;\r
+  }\r
+\r
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
+\r
+   ANTLRCommonToken (const ANTLRCommonToken& from) :\r
+         ANTLRRefCountToken(from) {\r
+    setType(from._type);\r
+   setLine(from._line);\r
+     _text=NULL;\r
+     setText(from._text);\r
+  };\r
+\r
+// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
+\r
+   virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) {\r
+\r
+//////  MR15 WatCom can't hack use of operator =()\r
+//////  Use this instead:   *( (ANTRLRRefCountToken *) this)=rhs;\r
+\r
+     *( (ANTLRRefCountToken *) this) = rhs;\r
+\r
+     setType(rhs._type);\r
+    setLine(rhs._line);\r
+     setText(rhs._text);\r
+     return *this;\r
+   };\r
+};\r
+\r
+// used for backward compatibility\r
+typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp
new file mode 100644 (file)
index 0000000..a7b10c7
--- /dev/null
@@ -0,0 +1,345 @@
+/* ANTLRTokenBuffer.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+typedef int ANTLRTokenType;  // fool AToken.h into compiling\r
+\r
+class ANTLRParser;          /* MR1 */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include ATOKENBUFFER_H\r
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
+\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+static unsigned char test[1000];\r
+#endif\r
+\r
+#ifdef DBG_REFCOUNTTOKEN\r
+int ANTLRCommonToken::ctor = 0;\r
+int ANTLRCommonToken::dtor = 0;\r
+#endif\r
+\r
+ANTLRTokenBuffer::\r
+ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */\r
+{\r
+  this->input = _input;\r
+  this->k = _k;\r
+  buffer_size = chunk_size = _chunk_size_formal;\r
+  buffer = (_ANTLRTokenPtr *)\r
+       calloc(chunk_size+1,sizeof(_ANTLRTokenPtr ));\r
+  if ( buffer == NULL ) {\r
+    panic("cannot alloc token buffer");\r
+  }\r
+  buffer++;        // leave the first elem empty so tp-1 is valid ptr\r
+\r
+  tp = &buffer[0];\r
+  last = tp-1;\r
+  next = &buffer[0];\r
+  num_markers = 0;\r
+  end_of_buffer = &buffer[buffer_size-1];\r
+  // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))];\r
+  threshold = &buffer[(int)(buffer_size / 2)];\r
+  _deleteTokens = 1;   // assume we delete tokens\r
+  parser=NULL;        // MR5 - uninitialized reference\r
+}\r
+\r
+static void f() {;}\r
+ANTLRTokenBuffer::\r
+~ANTLRTokenBuffer()\r
+{\r
+  f();\r
+  // Delete all remaining tokens (from 0..last inclusive)\r
+  if ( _deleteTokens )\r
+  {\r
+    _ANTLRTokenPtr *z;\r
+    for (z=buffer; z<=last; z++)\r
+    {\r
+      (*z)->deref();\r
+//      z->deref();\r
+#ifdef DBG_REFCOUNTTOKEN\r
+          fprintf(stderr, "##########dtor: deleting token '%s' (ref %d)\n",\r
+              ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
+#endif\r
+      if ( (*z)->nref()==0 )\r
+      {\r
+        delete (*z);\r
+      }\r
+    }\r
+  }\r
+\r
+  if ( buffer!=NULL ) free((char *)(buffer-1));\r
+}\r
+\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+#include "pccts_stdio.h"\r
+PCCTS_NAMESPACE_STD\r
+#endif\r
+\r
+_ANTLRTokenPtr ANTLRTokenBuffer::\r
+getToken()\r
+{\r
+  if ( tp <= last )  // is there any buffered lookahead still to be read?\r
+  {\r
+    return *tp++;  // read buffered lookahead\r
+  }\r
+  // out of buffered lookahead, get some more "real"\r
+  // input from getANTLRToken()\r
+  if ( num_markers==0 )\r
+  {\r
+    if( next > threshold )\r
+    {\r
+#ifdef DBG_TBUF\r
+fprintf(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);\r
+#endif\r
+      makeRoom();\r
+    }\r
+  }\r
+  else {\r
+    if ( next > end_of_buffer )\r
+    {\r
+#ifdef DBG_TBUF\r
+fprintf(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size);\r
+#endif\r
+      extendBuffer();\r
+    }\r
+  }\r
+  *next = getANTLRToken();\r
+  (*next)->ref();        // say we have a copy of this pointer in buffer\r
+  last = next;\r
+  next++;\r
+  tp = last;\r
+  return *tp++;\r
+}\r
+\r
+void ANTLRTokenBuffer::\r
+rewind(int pos)\r
+{\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+  fprintf(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]);\r
+  test[pos]--;\r
+#endif\r
+  tp = &buffer[pos];\r
+  num_markers--;\r
+}\r
+\r
+/*\r
+ * This function is used to specify that the token pointers read\r
+ * by the ANTLRTokenBuffer should be buffered up (to be reused later).\r
+ */\r
+int ANTLRTokenBuffer::\r
+mark()\r
+{\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+  test[tp-buffer]++;\r
+  fprintf(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]);\r
+#endif\r
+  num_markers++;\r
+  return tp - buffer;\r
+}\r
+\r
+/*\r
+ * returns the token pointer n positions ahead.\r
+ * This implies that bufferedToken(1) gets the NEXT symbol of lookahead.\r
+ * This is used in conjunction with the ANTLRParser lookahead buffer.\r
+ *\r
+ * No markers are set or anything.  A bunch of input is buffered--that's all.\r
+ * The tp pointer is left alone as the lookahead has not been advanced\r
+ * with getToken().  The next call to getToken() will find a token\r
+ * in the buffer and won't have to call getANTLRToken().\r
+ *\r
+ * If this is called before a consume() is done, how_many_more_i_need is\r
+ * set to 'n'.\r
+ */\r
+_ANTLRTokenPtr ANTLRTokenBuffer::\r
+bufferedToken(int n)\r
+{\r
+//  int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1;\r
+  int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1;\r
+  // Make sure that at least n tokens are available in the buffer\r
+#ifdef DBG_TBUF\r
+  fprintf(stderr, "bufferedToken(%d)\n", n);\r
+#endif\r
+  for (int i=1; i<=how_many_more_i_need; i++)\r
+  {\r
+    if ( next > end_of_buffer )  // buffer overflow?\r
+    {\r
+      extendBuffer();\r
+    }\r
+    *next = getANTLRToken();\r
+    (*next)->ref();    // say we have a copy of this pointer in buffer\r
+    last = next;\r
+    next++;\r
+  }\r
+  return tp[n - 1];\r
+}\r
+\r
+/* If no markers are set, the none of the input needs to be saved (except\r
+ * for the lookahead Token pointers).  We save only k-1 token pointers as\r
+ * we are guaranteed to do a getANTLRToken() right after this because otherwise\r
+ * we wouldn't have needed to extend the buffer.\r
+ *\r
+ * If there are markers in the buffer, we need to save things and so\r
+ * extendBuffer() is called.\r
+ */\r
+void ANTLRTokenBuffer::\r
+makeRoom()\r
+{\r
+#ifdef DBG_TBUF\r
+  fprintf(stderr, "in makeRoom.................\n");\r
+  fprintf(stderr, "num_markers==%d\n", num_markers);\r
+#endif\r
+/*\r
+  if ( num_markers == 0 )\r
+  {\r
+*/\r
+#ifdef DBG_TBUF\r
+    fprintf(stderr, "moving lookahead and resetting next\n");\r
+\r
+    _ANTLRTokenPtr *r;\r
+    fprintf(stderr, "tbuf = [");\r
+    for (r=buffer; r<=last; r++)\r
+    {\r
+      if ( *r==NULL ) fprintf(stderr, " xxx");\r
+      else fprintf(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());\r
+    }\r
+    fprintf(stderr, " ]\n");\r
+\r
+    fprintf(stderr,\r
+    "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer);\r
+#endif\r
+\r
+    // Delete all tokens from 0..last-(k-1) inclusive\r
+    if ( _deleteTokens )\r
+    {\r
+      _ANTLRTokenPtr *z;\r
+      for (z=buffer; z<=last-(k-1); z++)\r
+      {\r
+        (*z)->deref();\r
+//        z->deref();\r
+#ifdef DBG_REFCOUNTTOKEN\r
+          fprintf(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n",\r
+              ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
+#endif\r
+        if ( (*z)->nref()==0 )\r
+        {\r
+          delete (*z);\r
+        }\r
+      }\r
+    }\r
+\r
+    // reset the buffer to initial conditions, but move k-1 symbols\r
+    // to the beginning of buffer and put new input symbol at k\r
+    _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1;\r
+//    ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1;\r
+#ifdef DBG_TBUF\r
+    fprintf(stderr, "lookahead buffer = [");\r
+#endif\r
+    for (int i=1; i<=(k-1); i++)\r
+    {\r
+      *p++ = *q++;\r
+#ifdef DBG_TBUF\r
+      fprintf(stderr,\r
+      " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());\r
+#endif\r
+    }\r
+#ifdef DBG_TBUF\r
+    fprintf(stderr, " ]\n");\r
+#endif\r
+    next = &buffer[k-1];\r
+    tp = &buffer[k-1];  // tp points to what will be filled in next\r
+    last = tp-1;\r
+#ifdef DBG_TBUF\r
+    fprintf(stderr,\r
+    "after: tp=%d, last=%d, next=%d\n",\r
+    tp-buffer, last-buffer, next-buffer);\r
+#endif\r
+/*\r
+  }\r
+  else {\r
+    extendBuffer();\r
+  }\r
+*/\r
+}\r
+\r
+/* This function extends 'buffer' by chunk_size and returns with all\r
+ * pointers at the same relative positions in the buffer (the buffer base\r
+ * address could have changed in realloc()) except that 'next' comes\r
+ * back set to where the next token should be stored.  All other pointers\r
+ * are untouched.\r
+ */\r
+void\r
+ANTLRTokenBuffer::\r
+extendBuffer()\r
+{\r
+  int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer;\r
+#ifdef DBG_TBUF\r
+  fprintf(stderr, "extending physical buffer\n");\r
+#endif\r
+  buffer_size += chunk_size;\r
+  buffer = (_ANTLRTokenPtr *)\r
+    realloc((char *)(buffer-1),\r
+        (buffer_size+1)*sizeof(_ANTLRTokenPtr ));\r
+  if ( buffer == NULL ) {\r
+    panic("cannot alloc token buffer");\r
+  }\r
+  buffer++;        // leave the first elem empty so tp-1 is valid ptr\r
+\r
+  tp = buffer + save_tp;  // put the pointers back to same relative position\r
+  last = buffer + save_last;\r
+  next = buffer + save_next;\r
+  end_of_buffer = &buffer[buffer_size-1];\r
+  // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))];\r
+  threshold = &buffer[(int)(buffer_size / 2)];\r
+\r
+/*\r
+  // zero out new token ptrs so we'll know if something to delete in buffer\r
+  ANTLRAbstractToken **p = end_of_buffer-chunk_size+1;\r
+  for (; p<=end_of_buffer; p++) *p = NULL;\r
+*/\r
+}\r
+\r
+ANTLRParser * ANTLRTokenBuffer::        // MR1\r
+setParser(ANTLRParser *p) {          // MR1\r
+  ANTLRParser  *old=parser;          // MR1\r
+  parser=p;              // MR1\r
+  input->setParser(p);            // MR1\r
+  return old;              // MR1\r
+}                // MR1\r
+                // MR1\r
+ANTLRParser * ANTLRTokenBuffer::        // MR1\r
+getParser() {              // MR1\r
+  return parser;            // MR1\r
+}                // MR1\r
+\r
+/* to avoid having to link in another file just for the smart token ptr\r
+ * stuff, we include it here.  Ugh.\r
+ */\r
+#include ATOKPTR_C\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h
new file mode 100644 (file)
index 0000000..719e059
--- /dev/null
@@ -0,0 +1,106 @@
+/* ANTLRTokenBuffer.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ATOKENBUFFER_H_GATE\r
+#define ATOKENBUFFER_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+/*\r
+ * The parser is "attached" to an ANTLRTokenBuffer via interface\r
+ * functions: getToken() and bufferedToken().  The object that actually\r
+ * consumes characters and constructs tokens is connected to the\r
+ * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();\r
+ * where ANTLRTokenStream is really just a behavior (class with no data).\r
+ * C++ does not have this abstraction and hence we simply have come up\r
+ * with a fancy name for "void *".  See the note in ANTLRTokenStream.h on\r
+ * the "behavior" of ANTLRTokenStream.\r
+ */\r
+\r
+class ANTLRParser;          // MR1\r
+\r
+class DllExportPCCTS ANTLRTokenBuffer {\r
+protected:\r
+  ANTLRTokenStream *input;        // where do I get tokens\r
+  int buffer_size;\r
+  int chunk_size;\r
+  int num_markers;\r
+  int k;                          // Need at least this many tokens in buffer\r
+  _ANTLRTokenPtr *buffer;  // buffer used for arbitrary lookahead\r
+  _ANTLRTokenPtr *tp;        // pts into buffer; current token ptr\r
+  _ANTLRTokenPtr *last;      // pts to last valid token in buffer\r
+  _ANTLRTokenPtr *next;      // place to put token from getANTLRToken()\r
+  _ANTLRTokenPtr *end_of_buffer;\r
+  /* when you try to write a token past this and there are no markers\r
+     set, then move k-1 tokens back to the beginning of the buffer.\r
+     We want to stay away from the end of the buffer because we have\r
+     to extend it if a marker is set and we reach the end (we cannot\r
+     move tokens to the beginning of the buffer in this case).\r
+   */\r
+  _ANTLRTokenPtr *threshold;\r
+  unsigned char _deleteTokens;\r
+\r
+  // This function is filled in by the subclass; it initiates fetch of input\r
+  virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }\r
+  void makeRoom();\r
+  void extendBuffer();\r
+\r
+public:\r
+  ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);\r
+  virtual ~ANTLRTokenBuffer();\r
+  virtual _ANTLRTokenPtr getToken();\r
+  virtual void rewind(int pos);\r
+  virtual int mark();\r
+  virtual _ANTLRTokenPtr bufferedToken(int i);\r
+\r
+  void noGarbageCollectTokens()  { _deleteTokens=0; }\r
+  void garbageCollectTokens()    { _deleteTokens=1; }\r
+\r
+  virtual int bufferSize() { return buffer_size; }\r
+  virtual int minTokens() { return k; }\r
+  virtual void setMinTokens(int k_new) { k = k_new; }\r
+\r
+  virtual void panic(const char *msg) { exit(PCCTS_EXIT_FAILURE); } /* MR20 const */\r
+protected:            // MR1\r
+  ANTLRParser  *parser;      // MR1\r
+public:              // MR1\r
+  ANTLRParser  *setParser(ANTLRParser *p);  // MR1\r
+  ANTLRParser  *getParser();          // MR1\r
+    ANTLRTokenStream *getLexer() const {    // MR12\r
+      return input;}                        // MR12\r
+};\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h
new file mode 100644 (file)
index 0000000..a603707
--- /dev/null
@@ -0,0 +1,51 @@
+/* ANTLRTokenStream.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ATOKENSTREAM_H_GATE\r
+#define ATOKENSTREAM_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+/* This is really a behavior or protocol; it merely indicates the behavior\r
+ * required of the input and output of an ANTLRTokenBuffer.  You could\r
+ * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer\r
+ * with a type cast (in which case, your getANTLRToken() would have to\r
+ * explicitly cast the input pointer to your REAL type (typically your lexer)).\r
+ */\r
+\r
+class ANTLRParser;              // MR1\r
+\r
+class DllExportPCCTS ANTLRTokenStream {\r
+public:\r
+    virtual _ANTLRTokenPtr getToken() = 0;\r
+  virtual ANTLRParser * setParser(ANTLRParser *p) {return 0; };   // MR12\r
+  virtual ANTLRParser * getParser() { return 0; };            // MR12\r
+};\r
+\r
+#endif\r
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 (file)
index 0000000..b4d6947
--- /dev/null
@@ -0,0 +1,215 @@
+/* ANTLRToken.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ATOKEN_H_GATE\r
+#define ATOKEN_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_string.h"\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef ANTLRCommonTokenTEXTSIZE\r
+#define ANTLRCommonTokenTEXTSIZE          100\r
+#endif\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char ANTLRChar;\r
+\r
+/* D E F I N E  S M A R T  P O I N T E R S */\r
+\r
+#include "pcctscfg.h"\r
+\r
+//#include ATOKPTR_H   not tested yet, leave out\r
+class ANTLRAbstractToken;\r
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
+\r
+class DllExportPCCTS ANTLRAbstractToken {\r
+public:\r
+    virtual ~ANTLRAbstractToken() {;}\r
+    virtual ANTLRTokenType getType() = 0;\r
+    virtual void setType(ANTLRTokenType t) = 0;\r
+    virtual int getLine() = 0;\r
+    virtual void setLine(int line) = 0;\r
+    virtual ANTLRChar *getText() = 0;\r
+    virtual void setText(ANTLRChar *) = 0;\r
+\r
+    /* This function will disappear when I can use templates */\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *text,\r
+                      int line) = 0;\r
+\r
+  /* define to satisfy ANTLRTokenBuffer's need to determine whether or\r
+     not a token object can be destroyed.  If nref()==0, no one has\r
+     a reference, and the object may be destroyed.  This function defaults\r
+     to 1, hence, if you use deleteTokens() message with a token object\r
+     not derived from ANTLRCommonRefCountToken, the parser will compile\r
+     but will not delete objects after they leave the token buffer.\r
+    */\r
+  virtual unsigned nref() { return 1; }\r
+  virtual void ref() {;}\r
+  virtual void deref() {;}\r
+\r
+  virtual void panic(char *msg)\r
+    {\r
+      fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg);\r
+      exit(PCCTS_EXIT_FAILURE);\r
+    }\r
+};\r
+\r
+/* This class should be subclassed.  It cannot store token type or text */\r
+\r
+class DllExportPCCTS ANTLRRefCountToken : public ANTLRAbstractToken {\r
+public:\r
+#ifdef DBG_REFCOUNTTOKEN\r
+  static int ctor;\r
+  static int dtor;\r
+#endif\r
+protected:\r
+    unsigned refcnt_;\r
+#ifdef DBG_REFCOUNTTOKEN\r
+  char object[200];\r
+#endif\r
+\r
+public:\r
+  ANTLRRefCountToken(ANTLRTokenType t, ANTLRChar *s)\r
+#ifndef DBG_REFCOUNTTOKEN\r
+    {\r
+      refcnt_ = 0;\r
+    }\r
+#else\r
+  {\r
+    ctor++;\r
+    refcnt_ = 0;\r
+    if ( t==1 ) sprintf(object,"tok_EOF");\r
+    else sprintf(object,"tok_%s",s);\r
+    fprintf(stderr, "ctor %s #%d\n",object,ctor);\r
+  }\r
+#endif\r
+  ANTLRRefCountToken()\r
+#ifndef DBG_REFCOUNTTOKEN\r
+    { refcnt_ = 0; }\r
+#else\r
+    {\r
+      ctor++;\r
+      refcnt_ = 0;\r
+      sprintf(object,"tok_blank");\r
+      fprintf(stderr, "ctor %s #%d\n",object,ctor);\r
+    }\r
+  virtual ~ANTLRRefCountToken()\r
+    {\r
+      dtor++;\r
+      if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n");\r
+      fprintf(stderr, "dtor %s #%d\n", object, dtor);\r
+      object[0]='\0';\r
+    }\r
+#endif\r
+\r
+  // reference counting stuff needed by ANTLRTokenPtr.\r
+  // User should not access these; for C++ language reasons, we had\r
+  // to make these public.  Yuck.\r
+  void ref()    { refcnt_++; }\r
+  void deref()  { refcnt_--; }\r
+  unsigned nref()  { return refcnt_; }\r
+\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+  {\r
+    panic("call to ANTLRRefCountToken::makeToken()\n");\r
+    return NULL;\r
+  }\r
+};\r
+\r
+class DllExportPCCTS ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {\r
+protected:\r
+  ANTLRTokenType _type;\r
+  int _line;\r
+  ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1];\r
+\r
+public:\r
+  ANTLRCommonNoRefCountToken(ANTLRTokenType t, ANTLRChar *s)\r
+    { setType(t); _line = 0; setText(s); }\r
+  ANTLRCommonNoRefCountToken()\r
+    { setType((ANTLRTokenType)0); _line = 0; setText(""); }\r
+\r
+  ANTLRTokenType getType()   { return _type; }\r
+  void setType(ANTLRTokenType t)  { _type = t; }\r
+  virtual int getLine()     { return _line; }\r
+  void setLine(int line)    { _line = line; }\r
+  ANTLRChar *getText()     { return _text; }\r
+  void setText(ANTLRChar *s)\r
+    { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); }\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+    {\r
+      ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;\r
+      t->setType(tt); t->setText(txt); t->setLine(line);\r
+      return t;\r
+    }\r
+};\r
+\r
+class DllExportPCCTS ANTLRCommonToken : public ANTLRRefCountToken {\r
+protected:\r
+  ANTLRTokenType _type;\r
+  int _line;\r
+  ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1];\r
+\r
+public:\r
+  ANTLRCommonToken(ANTLRTokenType t, ANTLRChar *s) : ANTLRRefCountToken(t,s)\r
+    { setType(t); _line = 0; setText(s); }\r
+  ANTLRCommonToken()\r
+    { setType((ANTLRTokenType)0); _line = 0; setText(""); }\r
+  virtual ~ANTLRCommonToken() {;}\r
+\r
+  ANTLRTokenType getType()   { return _type; }\r
+  void setType(ANTLRTokenType t)  { _type = t; }\r
+  virtual int getLine()     { return _line; }\r
+  void setLine(int line)    { _line = line; }\r
+  ANTLRChar *getText()     { return _text; }\r
+  void setText(ANTLRChar *s)\r
+    { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); }\r
+  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                      ANTLRChar *txt,\r
+                      int line)\r
+    {\r
+      ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
+      t->setLine(line);\r
+      return t;\r
+    }\r
+};\r
+\r
+// used for backward compatibility\r
+typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp
new file mode 100644 (file)
index 0000000..99d08a4
--- /dev/null
@@ -0,0 +1,100 @@
+// FILE:        BufFileInput.cpp\r
+// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
+// CREATION:    26-JAN-1998\r
+// DESCRIPTION: File Input Stream with lookahead for Scanner.\r
+//   See file BufFileInput.h for details\r
+\r
+// Change History:\r
+//\r
+//   22-Jun-1998    assert.h -> PCCTS_ASSERT_H\r
+//                  string.h -> PCCTS_STRING_H\r
+//\r
+//   28-May-1998    Add virtual destructor to release buffer.\r
+//\r
+//                  Add dummy definition for ANTLRTokenType\r
+//                  to allow compilation without knowing\r
+//                  token type codes.\r
+//\r
+//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
+//                  (1.33MR14)\r
+//\r
+//   20-Jul-1998    MR14a - Reorder initialization list for ctor.\r
+//\r
+\r
+enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 };\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_assert.h"\r
+#include "pccts_string.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "BufFileInput.h"\r
+\r
+BufFileInput::BufFileInput( FILE *f, int buf_size )\r
+: input( f ),\r
+  buf( new int[buf_size] ),\r
+  size( buf_size ),\r
+  start( 0 ),\r
+  len( 0 )\r
+{\r
+}\r
+\r
+BufFileInput::~BufFileInput()\r
+{\r
+  delete [] buf;\r
+}\r
+\r
+int BufFileInput::nextChar( void )\r
+{\r
+    if( len > 0 )\r
+    {\r
+        // get char from buffer\r
+        int c = buf[start];\r
+\r
+        if( c != EOF )\r
+        {\r
+            start++; start %= size;\r
+            len--;\r
+        }\r
+        return c;\r
+    } else {\r
+        // get char from file\r
+        int c = getc( input );\r
+\r
+        if( c == EOF )\r
+        {\r
+            // if EOF - put it in the buffer as indicator\r
+            buf[start] = EOF;\r
+            len++;\r
+        }\r
+        return c;\r
+    }\r
+}\r
+\r
+int BufFileInput::lookahead( char* s )\r
+{\r
+    int l = strlen( s );\r
+\r
+    assert( 0 < l && l <= size );\r
+\r
+    while( len < l )\r
+    {\r
+        int c = getc( input );\r
+\r
+        buf[ (start+len) % size ] = c;\r
+\r
+        len++;\r
+\r
+        if( c == EOF ) return 0;\r
+    }\r
+\r
+    for( int i = 0; i < l; i++ )\r
+    {\r
+        if( s[i] != buf[ (start+i) % size ] ) return 0;\r
+    }\r
+    return 1;\r
+}\r
+\r
+// End of file BufFileInput.cpp\r
+\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h
new file mode 100644 (file)
index 0000000..ea54c0e
--- /dev/null
@@ -0,0 +1,53 @@
+// FILE:        BufFileInput.h\r
+// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
+// CREATION:    26-JAN-1998\r
+// DESCRIPTION: File Input Stream with lookahead for Scanner\r
+// Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0\r
+\r
+// Change History:\r
+//\r
+//   28-May-1998    Add virtual destructor to release buffer\r
+//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
+//                  (1.33MR14)\r
+\r
+#ifndef BufFileInput_h\r
+#define BufFileInput_h\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "DLexerBase.h"\r
+\r
+class DllExportPCCTS BufFileInput : public DLGInputStream\r
+{\r
+public:\r
+    // constructor\r
+    // f - input stream\r
+    // buf_size - size of buffer (maximal length for string in is_in)\r
+\r
+    BufFileInput(FILE *f, int buf_size = 8 );\r
+\r
+    virtual ~BufFileInput();\r
+\r
+    // gets next char from stream\r
+\r
+    virtual int nextChar( void );\r
+\r
+    // looks in stream and compares next l characters with s\r
+    // returns the result of comparision\r
+\r
+    int lookahead( char* s );\r
+\r
+private:\r
+    FILE *input; // input stream;\r
+    int* buf;    // buffer\r
+    int  size;   // size of buffer\r
+    int  start;  // position of the first symbol in buffer\r
+    int  len;    // count of characters in buffers\r
+};\r
+\r
+#endif\r
+// end of file BufFileInput.h\r
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 (file)
index 0000000..39892bb
--- /dev/null
@@ -0,0 +1,98 @@
+\r
+/************************************************************/\r
+/*                              */\r
+/*    Predefined char stream: Input from (c++) stream.  */\r
+/*                              */\r
+/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998.    */\r
+/*                              */\r
+/* This is completely free stuff, do whatever you want with  */\r
+/* it (but then, I will take no responsability for whatever  */\r
+/* may happen if you do either... caveat emptor!).      */\r
+/*                              */\r
+/************************************************************/\r
+\r
+#ifndef _DLG_STREAM_INPUT_H\r
+#define _DLG_STREAM_INPUT_H\r
+\r
+#include "pccts_istream.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef DLGX_H\r
+#include "DLexerBase.h"\r
+#endif\r
+\r
+\r
+// NOTES:  The semantics of the copy constructor\r
+//      and the affectation operator may be unwaranted...\r
+//      and the stream may not be reset.\r
+//\r
+//      It would have been so much nicer for nextChar()\r
+//      to throw (of for the DLGInputStream to change status)\r
+//      upon hiting EOF than to return an "int"...\r
+\r
+template  <\r
+        class E,\r
+        class T = ::std::char_traits<E>\r
+      >\r
+class DLG_stream_input : public DLGInputStream\r
+{\r
+public:\r
+  \r
+            DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)\r
+  :  input(p_input_stream)\r
+  {\r
+    // nothing to do!\r
+  };\r
+  \r
+            DLG_stream_input(const DLG_stream_input & a_recopier)\r
+  :  input(a_recopier.input)\r
+  {\r
+    // nothing to do!\r
+  };\r
+  \r
+  virtual        ~DLG_stream_input()\r
+  {\r
+    this->purge();  // bloody templarized lookup...\r
+  };\r
+  \r
+  DLG_stream_input  operator = (const DLG_stream_input & a_affecter)\r
+  {\r
+    if (this != &a_affecter)\r
+    {\r
+      input = a_affecter.input;\r
+    }\r
+\r
+    return(*this);\r
+  };\r
+  \r
+  virtual int      nextChar()\r
+  {\r
+    E  extracted_stuff;\r
+    \r
+    input->get(extracted_stuff);\r
+    \r
+    if  (*input)\r
+    {\r
+      return(int(extracted_stuff));\r
+    }\r
+    else\r
+    {\r
+      return(EOF);\r
+    }\r
+  };\r
+  \r
+protected:\r
+  \r
+  ::std::basic_istream<E,T> *  input;\r
+  \r
+private:\r
+  \r
+  void  purge()\r
+  {\r
+    // nothing to do!\r
+  };\r
+};\r
+\r
+#endif /* _DLG_STREAM_INPUT_H */\r
+\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp
new file mode 100644 (file)
index 0000000..003253b
--- /dev/null
@@ -0,0 +1,188 @@
+/* DLexer.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#define ZZINC {if ( track_columns ) (++_endcol);}\r
+\r
+#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}\r
+\r
+#define ZZNEWSTATE     (newstate = dfa[state][cl])\r
+\r
+#ifndef ZZCOPY\r
+#define ZZCOPY \\r
+       /* Truncate matching buffer to size (not an error) */   \\r
+       if (nextpos < lastpos){                         \\r
+               *(nextpos++) = ch;                      \\r
+       }else{                                                  \\r
+               bufovf = 1;                                     \\r
+       }\r
+#endif\r
+\r
+void DLGLexer::\r
+mode( int m )\r
+{\r
+       /* points to base of dfa table */\r
+       if (m<MAX_MODE){\r
+               automaton = m;\r
+               /* have to redo class since using different compression */\r
+               cl = ZZSHIFT(ch);\r
+       }else{\r
+               sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);\r
+               errstd(ebuf);\r
+       }\r
+}\r
+\r
+ANTLRTokenType DLGLexer::\r
+nextTokenType(void)\r
+{\r
+       register int state, newstate;\r
+       /* last space reserved for the null char */\r
+       register DLGChar *lastpos;\r
+       ANTLRTokenType tk;\r
+\r
+skip:\r
+       bufovf = 0;\r
+       lastpos = &_lextext[_bufsize-1];\r
+       nextpos = _lextext;\r
+       _begcol = _endcol+1;\r
+more:\r
+       _begexpr = nextpos;\r
+       if ( interactive ) {\r
+               /* interactive version of automaton */\r
+               /* if there is something in ch, process it */\r
+               state = newstate = dfa_base[automaton];\r
+               if (charfull){\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+               while (alternatives[newstate]){\r
+                       state = newstate;\r
+                       ZZGETC;\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+               /* figure out if last character really part of token */\r
+               if ((state != dfa_base[automaton]) && (newstate == DfaStates)){\r
+                       charfull = 1;\r
+                       --nextpos;\r
+               }else{\r
+                       charfull = 0;\r
+                       state = newstate;\r
+               }\r
+               *(nextpos) = '\0';\r
+               /* Able to transition out of start state to some non err state?*/\r
+               if ( state == dfa_base[automaton] ){\r
+                       /* make sure doesn't get stuck */\r
+                       advance();\r
+               }\r
+       }\r
+       else { /* non-interactive version of automaton */\r
+               if (!charfull)\r
+                       advance();\r
+               else\r
+                       ZZINC;\r
+               state = dfa_base[automaton];\r
+               while (ZZNEWSTATE != DfaStates) {\r
+                       state = newstate;\r
+                       ZZCOPY;\r
+                       ZZGETC;\r
+                       ZZINC;\r
+               }\r
+               charfull = 1;\r
+               if ( state == dfa_base[automaton] ){\r
+                       if (nextpos < lastpos){\r
+                               *(nextpos++) = ch;\r
+                       }else{\r
+                               bufovf = 1;\r
+                       }\r
+                       *nextpos = '\0';\r
+                       /* make sure doesn't get stuck */\r
+                       advance();\r
+               }else{\r
+                       *nextpos = '\0';\r
+               }\r
+       }\r
+       if ( track_columns ) _endcol -= charfull;\r
+       _endexpr = nextpos -1;\r
+       add_erase = 0;\r
+#ifdef OLD\r
+       tk = (ANTLRTokenType)\r
+                (*actions[accepts[state]])(this);      // must pass this manually\r
+                                                                                       // actions is not a [] of pointers\r
+                                                                                       // to member functions.\r
+#endif\r
+       tk = (this->*actions[accepts[state]])();\r
+\r
+// MR1\r
+// MR1 11-Apr-97  Help for tracking DLG results\r
+// MR1\r
+\r
+#ifdef DEBUG_LEXER\r
+\r
+/* MR1 */        if (debugLexerFlag) {\r
+/* MR1 */         if (parser != NULL) {\r
+/* MR1 */           printf("\ntoken name=%s",parser->parserTokenName(tk));\r
+/* MR1 */         } else {\r
+/* MR1 */           printf("\ntoken nnumber=%d",tk);\r
+/* MR1 */         };\r
+/* MR1 */         printf(" lextext=(%s) mode=%d",\r
+/* MR1 */               (_lextext[0]=='\n' && _lextext[1]==0) ?\r
+/* MR1 */                      "newline" : _lextext,\r
+/* MR1 */                              automaton);\r
+/* MR1 */          if (interactive && !charfull) {\r
+/* MR1 */           printf(" char=empty");\r
+/* MR1 */          } else {\r
+/* MR1 */           if (ch=='\n') {\r
+/* MR1 */             printf(" char=newline");\r
+/* MR1 */           } else {\r
+/* MR1 */             printf(" char=(%c)",ch);\r
+/* MR1 */           };\r
+/* MR1 */         };\r
+/* MR1 */         printf(" %s\n",\r
+/* MR1 */               (add_erase==1 ? "skip()" :\r
+/* MR1 */                add_erase==2 ? "more()" :\r
+/* MR1 */                ""));\r
+/* MR1 */        };\r
+\r
+#endif\r
+\r
+       switch (add_erase) {\r
+               case 1: goto skip;\r
+               case 2: goto more;\r
+       }\r
+       return tk;\r
+}\r
+\r
+void DLGLexer::\r
+advance()\r
+{\r
+       if ( input==NULL ) err_in();\r
+       ZZGETC; charfull = 1; ZZINC;\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp
new file mode 100644 (file)
index 0000000..220a846
--- /dev/null
@@ -0,0 +1,268 @@
+/* DLGLexerBase.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+/* I have to put this here due to C++ limitation\r
+ * that you can't have a 'forward' decl for enums.\r
+ * I hate C++!!!!!!!!!!!!!!!\r
+ */\r
+\r
+// MR1\r
+// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
+// MR1                         ANTLRTokenType enum\r
+// MR1\r
+\r
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE,              // MR1\r
+                                        WITH_SOME_GOOD_IDEAS=9999};    // MR1\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+#include DLEXERBASE_H\r
+\r
+DLGLexerBase::\r
+DLGLexerBase(DLGInputStream *in,\r
+            unsigned bufsize,\r
+            int _interactive,\r
+            int _track_columns)\r
+{\r
+       this->_bufsize = bufsize;\r
+       this->_lextext = new DLGChar[_bufsize];\r
+       if ( this->_lextext==NULL ) {\r
+           panic("text buffer is NULL");\r
+       }\r
+       this->_begexpr = this->_endexpr = NULL;\r
+       this->ch = this->bufovf = 0;\r
+       this->nextpos = NULL;\r
+       this->cl = 0;\r
+       this->add_erase = 0;\r
+       this->input = in;\r
+       this->_begcol = 0;\r
+       this->_endcol = 0;\r
+       this->_line = 1;\r
+       this->charfull = 0;\r
+       this->automaton = 0;\r
+       this->token_to_fill = NULL;\r
+       this->interactive = _interactive;\r
+       this->track_columns = _track_columns;\r
+       this->debugLexerFlag = 0;                                       // MR1\r
+       this->parser = NULL;                                            // MR1\r
+    this->lexErrCount=0;                        // MR11\r
+}\r
+\r
+// MR19  THM \r
+\r
+void DLGLexerBase::reset()\r
+{\r
+       this->charfull = 0;\r
+       this->_begcol = 0;\r
+       this->_endcol = 0;\r
+       this->automaton = 0;\r
+       this->_line=1;\r
+       this->lexErrCount=0;\r
+}\r
+\r
+void DLGLexerBase::\r
+setInputStream( DLGInputStream *in )\r
+{\r
+       this->input = in;\r
+       _line = 1;\r
+       charfull = 0;\r
+}\r
+\r
+/* saves dlg state, but not what feeds dlg (such as file position) */\r
+void DLGLexerBase::\r
+saveState(DLGState *state)\r
+{\r
+       state->input = input;\r
+       state->interactive = interactive;\r
+       state->track_columns = track_columns;\r
+       state->auto_num = automaton;\r
+       state->add_erase = add_erase;\r
+       state->lookc = ch;\r
+       state->char_full = charfull;\r
+       state->begcol = _begcol;\r
+       state->endcol = _endcol;\r
+       state->line = _line;\r
+       state->lextext = _lextext;\r
+       state->begexpr = _begexpr;\r
+       state->endexpr = _endexpr;\r
+       state->bufsize = _bufsize;\r
+       state->bufovf = bufovf;\r
+       state->nextpos = nextpos;\r
+       state->class_num = cl;\r
+       state->debugLexerFlag = debugLexerFlag;                         // MR1\r
+       state->parser = parser;                                         // MR1\r
+}\r
+\r
+void DLGLexerBase::\r
+restoreState(DLGState *state)\r
+{\r
+       input = state->input;\r
+       interactive = state->interactive;\r
+       track_columns = state->track_columns;\r
+       automaton = state->auto_num;\r
+       add_erase = state->add_erase;\r
+       ch = state->lookc;\r
+       charfull = state->char_full;\r
+       _begcol = state->begcol;\r
+       _endcol = state->endcol;\r
+       _line = state->line;\r
+       _lextext = state->lextext;\r
+       _begexpr = state->begexpr;\r
+       _endexpr = state->endexpr;\r
+       _bufsize = state->bufsize;\r
+       bufovf = state->bufovf;\r
+       nextpos = state->nextpos;\r
+       cl = state->class_num;\r
+       debugLexerFlag = state->debugLexerFlag;                         // MR1\r
+       parser = state->parser;                                         // MR1\r
+}\r
+\r
+/* erase what is currently in the buffer, and get a new reg. expr */\r
+void DLGLexerBase::\r
+skip()\r
+{\r
+       add_erase = 1;\r
+}\r
+\r
+/* don't erase what is in the lextext buffer, add on to it */\r
+void DLGLexerBase::\r
+more()\r
+{\r
+       add_erase = 2;\r
+}\r
+\r
+/* substitute c for the reg. expr last matched and is in the buffer */\r
+void DLGLexerBase::\r
+replchar(DLGChar c)\r
+{\r
+       /* can't allow overwriting null at end of string */\r
+       if (_begexpr < &_lextext[_bufsize-1]){\r
+               *_begexpr = c;\r
+               *(_begexpr+1) = '\0';\r
+       }\r
+       _endexpr = _begexpr;\r
+       nextpos = _begexpr + 1;\r
+}\r
+\r
+/* replace the string s for the reg. expr last matched and in the buffer */\r
+\r
+void DLGLexerBase::\r
+replstr(const DLGChar *s) /* MR20 const */\r
+{\r
+       register DLGChar *l= &_lextext[_bufsize -1];\r
+\r
+       nextpos = _begexpr;\r
+       if (s){\r
+               while ((nextpos <= l) && (*(nextpos++) = *(s++))){\r
+                       /* empty */\r
+               }\r
+               /* correct for NULL at end of string */\r
+               nextpos--;\r
+       }\r
+       if ((nextpos <= l) && (*(--s) == 0)){\r
+               bufovf = 0;\r
+       }else{\r
+               bufovf = 1;\r
+       }\r
+       *(nextpos) = '\0';\r
+       _endexpr = nextpos - 1;\r
+}\r
+\r
+void DLGLexerBase::\r
+errstd(const char *s)                               /* MR20 const */\r
+{\r
+        lexErrCount++;                              /* MR11 */\r
+        fprintf(stderr,\r
+                "%s near line %d (text was '%s')\n",\r
+                ((s == NULL) ? "Lexical error" : s),\r
+                _line,_lextext);\r
+}\r
+\r
+int DLGLexerBase::\r
+err_in()\r
+{\r
+       fprintf(stderr,"No input stream, function, or string\n");\r
+       /* return eof to get out gracefully */\r
+       return EOF;\r
+}\r
+\r
+ANTLRTokenType DLGLexerBase::\r
+erraction()\r
+{\r
+       errstd("invalid token");\r
+       advance();\r
+       skip();\r
+       return (ANTLRTokenType) 0;      // bogus, but satisfies compiler\r
+}\r
+\r
+_ANTLRTokenPtr DLGLexerBase::\r
+getToken()\r
+{\r
+       if ( token_to_fill==NULL ) panic("NULL token_to_fill");\r
+       ANTLRTokenType tt = nextTokenType();\r
+       _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line);\r
+       return tk;\r
+}\r
+\r
+void DLGLexerBase::\r
+panic(const char *msg)      /* MR20 const */\r
+{\r
+       fprintf(stderr, "DLG panic: %s\n", msg);\r
+//\r
+//  7-Apr-97 133MR1\r
+//\r
+       exit(PCCTS_EXIT_FAILURE);                                       // MR1\r
+}\r
+\r
+ANTLRParser * DLGLexerBase::                                           // MR1\r
+setParser(ANTLRParser *p) {                                            // MR1\r
+  ANTLRParser  *oldValue=parser;                                       // MR1\r
+  parser=p;                                                            // MR1\r
+  return oldValue;                                                     // MR1\r
+}                                                                      // MR1\r
+                                                                       // MR1\r
+ANTLRParser * DLGLexerBase::                                           // MR1\r
+getParser() {                                                          // MR1\r
+  return parser;                                                       // MR1\r
+}                                                                      // MR1\r
+                                                                       // MR1\r
+int DLGLexerBase::                                                     // MR1\r
+debugLexer(int newValue) {                                             // MR1\r
+  int  oldValue=debugLexerFlag;                                        // MR1\r
+  debugLexerFlag=newValue;                                             // MR1\r
+  return oldValue;                                                     // MR1\r
+}                                                                      // MR1\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h
new file mode 100644 (file)
index 0000000..d3f696f
--- /dev/null
@@ -0,0 +1,197 @@
+/* DLGLexerBase.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef DLGX_H\r
+#define DLGX_H\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+class ANTLRParser;              // MR1\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char DLGChar;\r
+\r
+/*  Can have it as a class too: (ack this looks weird; is it right?)\r
+class DllExportPCCTS DLGChar {\r
+private:\r
+  int c;\r
+public:\r
+  DLGChar(int ch) { c = ch; }\r
+  int atom() { return c; }\r
+};\r
+*/\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGInputStream {\r
+public:\r
+  virtual int nextChar() = 0;\r
+};\r
+\r
+/* Predefined char stream: Input from FILE */\r
+class DllExportPCCTS DLGFileInput : public DLGInputStream {\r
+private:\r
+  int found_eof;\r
+  FILE *input;\r
+public:\r
+  DLGFileInput(FILE *f) { input = f; found_eof = 0; }\r
+  int nextChar() {\r
+      int c;\r
+      if ( found_eof ) return EOF;\r
+      else {\r
+        c=getc(input);\r
+        if ( c==EOF ) found_eof = 1;\r
+        return c;\r
+      }\r
+  }\r
+    void DLGFileReset(FILE *f) {input=f; found_eof = 0; };              // MR11\r
+};\r
+\r
+// MR9  Suggested by Bruce Guenter (bruceg@qcc.sk.ca)\r
+// MR9  Make DLGStringInput const correct\r
+\r
+/* Predefined char stream: Input from string */\r
+class DllExportPCCTS DLGStringInput : public DLGInputStream {\r
+private:\r
+  const DLGChar *input;                                           // MR9\r
+  const DLGChar *p;                                               // MR9\r
+public:\r
+  DLGStringInput(const DLGChar *s) { input = s; p = &input[0];}   // MR9\r
+  int nextChar()\r
+    {\r
+      if (*p) return (int) (unsigned char) *p++;              // MR14\r
+      else return EOF;\r
+    }\r
+\r
+    void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16\r
+};\r
+\r
+class DllExportPCCTS DLGState {\r
+public:\r
+  DLGInputStream *input;\r
+  int interactive;\r
+  int track_columns;\r
+  int auto_num;\r
+  int add_erase;\r
+  int lookc;\r
+  int char_full;\r
+  int begcol, endcol;\r
+  int line;\r
+  DLGChar *lextext, *begexpr, *endexpr;\r
+  int bufsize;\r
+  int bufovf;\r
+  DLGChar *nextpos;\r
+  int  class_num;\r
+  int  debugLexerFlag;            // MR1\r
+  ANTLRParser *parser;            // MR1\r
+};\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {\r
+public:\r
+  virtual ANTLRTokenType erraction();\r
+\r
+protected:\r
+  DLGInputStream *input;\r
+  int interactive;\r
+  int track_columns;\r
+  DLGChar  *_lextext;  /* text of most recently matched token */\r
+  DLGChar  *_begexpr;  /* beginning of last reg expr recogn. */\r
+  DLGChar  *_endexpr;  /* beginning of last reg expr recogn. */\r
+  int  _bufsize;    /* number of characters in lextext */\r
+  int  _begcol;    /* column that first character of token is in*/\r
+  int  _endcol;    /* column that last character of token is in */\r
+  int  _line;      /* line current token is on */\r
+  int  ch;        /* character to determine next state */\r
+  int  bufovf;      /* indicates that buffer too small for text */\r
+  int  charfull;\r
+  DLGChar  *nextpos;  /* points to next available position in lextext*/\r
+  int  cl;\r
+  int automaton;\r
+  int  add_erase;\r
+  DLGChar ebuf[70];\r
+  _ANTLRTokenPtr token_to_fill;\r
+\r
+  int  debugLexerFlag;            // MR1\r
+  ANTLRParser  *parser;          // MR1\r
+public:\r
+  virtual _ANTLRTokenPtr getToken();      // MR12 public\r
+  virtual void advance(void) = 0;\r
+  void  skip(void);    /* erase lextext, look for antoher token */\r
+  void  more(void);    /* keep lextext, look for another token */\r
+  void  mode(int k);  /* switch to automaton 'k' */\r
+  void  saveState(DLGState *);\r
+  void  restoreState(DLGState *);\r
+  virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */\r
+  void  replchar(DLGChar c);  /* replace last recognized reg. expr. with\r
+                   a character */\r
+  void  replstr(const DLGChar *s);  /* replace last recognized reg. expr. with\r
+                       a string */ /* MR20 const */\r
+        virtual int err_in();            // MR1\r
+  virtual void errstd(const char *);        // MR1  MR20 const\r
+  int    line()    { return _line; }\r
+  void  set_line(int newValue)  { _line=newValue; };    // MR1\r
+  virtual void newline()  { _line++; }\r
+  DLGChar  *lextext()  { return _lextext; }\r
+\r
+  int    begcol()  { return _begcol; }\r
+  int    endcol()  { return _endcol; }\r
+  void  set_begcol(int a)  { _begcol=a; }\r
+  void  set_endcol(int a)  { _endcol=a; }\r
+  DLGChar  *begexpr()  { return _begexpr; }\r
+  DLGChar  *endexpr()  { return _endexpr; }\r
+  int    bufsize()  { return _bufsize; }\r
+\r
+  void  setToken(ANTLRAbstractToken *t)  { token_to_fill = t; }\r
+\r
+  void  setInputStream(DLGInputStream *);\r
+  DLGLexerBase(DLGInputStream *in,\r
+         unsigned bufsize=2000,\r
+         int interactive=0,\r
+         int track_columns=0);\r
+  void reset();                  // MR19\r
+  virtual ~DLGLexerBase() { delete [] _lextext; }\r
+  virtual void panic(const char *msg);      // MR1  MR20 const\r
+  void  trackColumns() {\r
+        track_columns = 1;\r
+        this->_begcol = 0;\r
+        this->_endcol = 0;\r
+      };\r
+  virtual ANTLRParser *setParser(ANTLRParser *p);      // MR1\r
+  virtual ANTLRParser *getParser();        // MR1\r
+  virtual int debugLexer(int value);        // MR1\r
+    int     lexErrCount;                            // MR12\r
+};\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h
new file mode 100644 (file)
index 0000000..47cc50b
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef PBLACKBOX_H\r
+#define PBLACKBOX_H\r
+\r
+/*\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_iostream.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+//  MR20 Added #include for "DLexerBase.h"\r
+\r
+#include "DLexerBase.h"\r
+\r
+//\r
+//  The default buffer size of the lexer is given by the\r
+//   second argument of the lexer's ctor.  It is optional\r
+//   and defaults to 2000\r
+//\r
+\r
+template<class Lexer, class Parser, class Token>\r
+class DllExportPCCTS ParserBlackBox {\r
+protected:\r
+  DLGFileInput *in;\r
+  Lexer *scan;\r
+  _ANTLRTokenPtr tok;\r
+  ANTLRTokenBuffer *pipe;\r
+  Parser *_parser;\r
+  FILE *file;\r
+    int openByBlackBox;    /* MR21 Don't close what we haven't opened */\r
+public:\r
+  \r
+  ParserBlackBox(FILE *f)\r
+    {\r
+            openByBlackBox = 0;     /* MR21a */\r
+      file = f;\r
+      in = new DLGFileInput(f);\r
+      scan = new Lexer(in);\r
+      pipe = new ANTLRTokenBuffer(scan);\r
+      tok = new Token;\r
+      scan->setToken(tok);\r
+      _parser = new Parser(pipe);\r
+      _parser->init();\r
+    }\r
+  ParserBlackBox(char *fname)\r
+    {\r
+      FILE *f = fopen(fname, "r");\r
+      if ( f==NULL ) {\r
+                openByBlackBox = 0;\r
+                cerr << "cannot open " << fname << "\n"; return;\r
+            }\r
+      else {\r
+                openByBlackBox = 1;\r
+        file = f;\r
+        in = new DLGFileInput(f);\r
+        scan = new Lexer(in);\r
+        pipe = new ANTLRTokenBuffer(scan);\r
+        tok = new Token;\r
+        scan->setToken(tok);\r
+        _parser = new Parser(pipe);\r
+        _parser->init();\r
+      }\r
+    }\r
+  \r
+  ~ParserBlackBox()\r
+    {\r
+      delete in; delete scan; delete pipe; delete _parser; delete tok;\r
+            if (1 == openByBlackBox) {\r
+          fclose(file);\r
+            }\r
+    }\r
+\r
+  Parser *parser()     { return _parser; }\r
+    Lexer  *getLexer()     { return scan; }\r
+};\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp
new file mode 100644 (file)
index 0000000..84a3a09
--- /dev/null
@@ -0,0 +1,662 @@
+/*\r
+ * PCCTSAST.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B14 and ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1998\r
+ */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "PCCTSAST.h"\r
+#include "pccts_stdarg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include <ctype.h>\r
+\r
+//#include "SList.h"\r
+\r
+               /* String Scanning/Parsing Stuff */\r
+\r
+const char *PCCTS_AST::scan_token_tbl[] = {     /* MR20 const */\r
+       "invalid",      /*      0 */\r
+       "LPAREN",       /*      1 */\r
+       "RPAREN",       /*      2 */\r
+       "PERCENT",      /*      3 */\r
+       "INT",          /*      4 */\r
+       "COLON",        /*      5 */\r
+       "POUND",        /*      6 */\r
+       "PERIOD",       /*      7 */\r
+};\r
+\r
+void PCCTS_AST::\r
+addChild(PCCTS_AST *t)\r
+{\r
+       if ( t==NULL ) return;\r
+       PCCTS_AST *s = down();\r
+       if ( s!=NULL )\r
+       {\r
+               while ( s->right()!=NULL ) s = s->right();\r
+               s->setRight(t);\r
+       }\r
+       else\r
+               this->setDown(t);\r
+}\r
+\r
+void PCCTS_AST::\r
+lisp(FILE *f)\r
+{\r
+       if ( down() != NULL ) fprintf(f," (");\r
+       lisp_action(f);\r
+       if ( down()!=NULL ) down()->lisp(f);\r
+       if ( down() != NULL ) fprintf(f," )");\r
+       if ( right()!=NULL ) right()->lisp(f);\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually sibling lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ *\r
+ * The down() and right() down/right pointers are used to make the tree.\r
+ */\r
+PCCTS_AST *PCCTS_AST::\r
+make(PCCTS_AST *rt, ...)\r
+{\r
+       va_list ap;\r
+       register PCCTS_AST *child, *sibling=NULL, *tail, *w;\r
+       PCCTS_AST *root;\r
+\r
+       va_start(ap, rt);\r
+       root = rt;\r
+\r
+       if ( root != NULL )\r
+               if ( root->down() != NULL ) return NULL;\r
+       child = va_arg(ap, PCCTS_AST *);\r
+       while ( child != NULL )\r
+       {\r
+               /* find end of child */\r
+               for (w=child; w->right()!=NULL; w=w->right()) {;}\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->setRight(child); tail = w;}\r
+               child = va_arg(ap, PCCTS_AST *);\r
+       }\r
+       if ( root==NULL ) root = sibling;\r
+       else root->setDown(sibling);\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+/* The following push and pop routines are only used by ast_find_all() */\r
+\r
+void PCCTS_AST::\r
+_push(PCCTS_AST **st, int *sp, PCCTS_AST *e)\r
+{\r
+       (*sp)--;\r
+       require((*sp)>=0, "stack overflow");\r
+       st[(*sp)] = e;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+_pop(PCCTS_AST **st, int *sp)\r
+{\r
+       PCCTS_AST *e = st[*sp];\r
+       (*sp)++;\r
+       require((*sp)<=MaxTreeStackDepth, "stack underflow");\r
+       return e;\r
+}\r
+\r
+/* Find all occurrences of u in t.\r
+ * 'cursor' must be initialized to 't'.  It eventually\r
+ * returns NULL when no more occurrences of 'u' are found.\r
+ */\r
+PCCTS_AST *PCCTS_AST::\r
+ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor)\r
+{\r
+       PCCTS_AST *sib;\r
+       static PCCTS_AST *template_stack[MaxTreeStackDepth];\r
+       static int tsp = MaxTreeStackDepth;\r
+       static int nesting = 0;\r
+\r
+       if ( *cursor == NULL ) return NULL;\r
+       if ( *cursor!=this ) sib = *cursor;\r
+       else {\r
+               /* else, first time--start at top of template 't' */\r
+               tsp = MaxTreeStackDepth;\r
+               sib = this;\r
+               /* bottom of stack is always a NULL--"cookie" indicates "done" */\r
+               _push(template_stack, &tsp, NULL);\r
+       }\r
+\r
+keep_looking:\r
+       if ( sib==NULL )        /* hit end of sibling list */\r
+       {\r
+               sib = _pop(template_stack, &tsp);\r
+               if ( sib == NULL ) { *cursor = NULL; return NULL; }\r
+       }\r
+\r
+       if ( sib->type() != u->type() )\r
+       {\r
+               /* look for another match */\r
+               if ( sib->down()!=NULL )\r
+               {\r
+                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+                       sib=sib->down();\r
+                       goto keep_looking;\r
+               }\r
+               /* nothing below to try, try next sibling */\r
+               sib=sib->right();\r
+               goto keep_looking;\r
+       }\r
+\r
+       /* found a matching root node, try to match what's below */\r
+       if ( match_partial(sib, u) )\r
+       {\r
+               /* record sibling cursor so we can pick up next from there */\r
+               if ( sib->down()!=NULL )\r
+               {\r
+                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+                       *cursor = sib->down();\r
+               }\r
+               else if ( sib->right()!=NULL ) *cursor = sib->right();\r
+               else *cursor = _pop(template_stack, &tsp);\r
+               return sib;\r
+       }\r
+\r
+       /* no match, keep searching */\r
+       if ( sib->down()!=NULL )\r
+       {\r
+               if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+               sib=sib->down();\r
+       }\r
+       else sib = sib->right();        /* else, try to right if zip below */\r
+       goto keep_looking;\r
+}\r
+\r
+/* are two trees exactly alike? */\r
+int PCCTS_AST::\r
+match(PCCTS_AST *u)\r
+{\r
+       PCCTS_AST *t = this;\r
+       PCCTS_AST *sib;\r
+\r
+       if ( u==NULL ) return 0;\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               if ( sib->type() != u->type() ) return 0;\r
+               if ( sib->down()!=NULL )\r
+                       if ( !sib->down()->match(u->down()) ) return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+/* Is 'u' a subtree of 't' beginning at the root? */\r
+int PCCTS_AST::\r
+match_partial(PCCTS_AST *t, PCCTS_AST *u)\r
+{\r
+       PCCTS_AST *sib;\r
+\r
+       if ( u==NULL ) return 1;\r
+       if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               if ( sib->type() != u->type() ) return 0;\r
+               if ( sib->down()!=NULL )\r
+                       if ( !match_partial(sib->down(), u->down()) ) return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+/* Walk the template tree 't' (matching against 'this'), filling in the\r
+ * 'labels' array, and setting 'n' according to how many labels were matched.\r
+ */\r
+int PCCTS_AST::\r
+scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n)\r
+{\r
+       ScanAST *sib;\r
+       PCCTS_AST *u = this;\r
+\r
+       if ( u==NULL ) return 0;\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               /* make sure tokens match; token of '0' means wildcard match */\r
+               if ( sib->type() != u->type() && sib->type()!=0 ) return 0;\r
+               /* we have a matched token here; set label pointers if exists */\r
+               if ( sib->label_num>0 )\r
+               {\r
+                       require(labels!=NULL, "label found in template, but no array of labels");\r
+                       (*n)++;\r
+                       *(labels[sib->label_num-1]) = u;\r
+               }\r
+               /* match what's below if something there and current node is not wildcard */\r
+               if ( sib->down()!=NULL && sib->type()!=0 )\r
+               {\r
+                       if ( sib->down()==NULL ) if ( u->down()!=NULL ) return 0; else return 1;\r
+                       if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0;\r
+               }\r
+       }\r
+       return 1;\r
+}\r
+\r
+void PCCTS_AST::\r
+insert_after(PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end;\r
+       if ( b==NULL ) return;\r
+       /* find end of b's child list */\r
+       for (end=b; end->right()!=NULL; end=end->right()) {;}\r
+       end->setRight(this->right());\r
+       this->setRight(b);\r
+}\r
+\r
+void PCCTS_AST::\r
+append(PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end;\r
+       require(b!=NULL, "append: NULL input tree");\r
+       /* find end of child list */\r
+       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
+       end->setRight(b);\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+tail()\r
+{\r
+       PCCTS_AST *end;\r
+       /* find end of child list */\r
+       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
+       return end;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+bottom()\r
+{\r
+       PCCTS_AST *end;\r
+       /* find end of child list */\r
+       for (end=this; end->down()!=NULL; end=end->down()) {;}\r
+       return end;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+cut_between(PCCTS_AST *a, PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end, *ret;\r
+       if (a==NULL||b==NULL) return NULL;\r
+       /* find node pointing to b */\r
+       for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right())\r
+               {;}\r
+       if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected\r
+       end->setRight(NULL);    /* don't want it point to 'b' anymore */\r
+       ret = a->right();\r
+       a->setRight(b);\r
+       return ret;\r
+}\r
+\r
+#ifdef NOT_YET\r
+SList *PCCTS_AST::\r
+to_slist()\r
+{\r
+       SList *list = new SList;\r
+       PCCTS_AST *p;\r
+\r
+       for (p=this; p!=NULL; p=p->right())\r
+       {\r
+               list->add(p);\r
+       }\r
+       return list;\r
+}\r
+#endif\r
+\r
+void PCCTS_AST::\r
+tfree()\r
+{\r
+       PCCTS_AST *t = this;\r
+    if ( t->down()!=NULL ) t->down()->tfree();\r
+    if ( t->right()!=NULL ) t->right()->tfree();\r
+    delete t;\r
+}\r
+\r
+int PCCTS_AST::\r
+nsiblings()\r
+{\r
+       PCCTS_AST *t = this;\r
+       int n=0;\r
+\r
+       while ( t!=NULL )\r
+       {\r
+               n++;\r
+               t = t->right();\r
+       }\r
+       return n;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+sibling_index(int i)\r
+{\r
+       PCCTS_AST *t = this;\r
+       int j=1;\r
+       require(i>0, "sibling_index: i<=0");\r
+\r
+       while ( t!=NULL )\r
+       {\r
+               if ( j==i ) return t;\r
+               j++;\r
+               t = t->right();\r
+       }\r
+       return NULL;\r
+}\r
+\r
+/* Assume this is a root node of a tree--\r
+ * duplicate that node and what's below; ignore siblings of root node.\r
+ */\r
+\r
+// MR9 23-Sep-97 RJV\r
+// MR9\r
+// MR9 RJV: Original version only duplicated the node and down elements.\r
+// MR9      Made copies of the pointers to sibling.\r
+// MR9      Changed call "down()->deepCopy()" to "down()->deepCopyBushy()"\r
+// MR9\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+deepCopy()\r
+{\r
+       PCCTS_AST *u = this->shallowCopy();\r
+       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
+    u->setRight(NULL);\r
+       return u;\r
+}\r
+\r
+/* Copy all nodes including siblings of root. */\r
+PCCTS_AST *PCCTS_AST::\r
+deepCopyBushy()\r
+{\r
+       PCCTS_AST *u = this->shallowCopy();\r
+       /* copy the rest of the tree */\r
+       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
+       if ( right()!=NULL ) u->setRight(right()->deepCopyBushy());\r
+       return u;\r
+}\r
+\r
+void PCCTS_AST::\r
+scanast_free(ScanAST *t)\r
+{\r
+    if ( t == NULL ) return;\r
+    scanast_free( t->down() );\r
+    scanast_free( t->right() );\r
+    free( (char *) t );                                                        // MR1\r
+}\r
+\r
+/*\r
+ * scan\r
+ *\r
+ * This function is like scanf(): it attempts to match a template\r
+ * against an input tree.  A variable number of tree pointers\r
+ * may be set according to the '%i' labels in the template string.\r
+ * For example:\r
+ *\r
+ *   t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",\r
+ *            &w, &x, &y, &z);\r
+ *\r
+ * Naturally, you'd want this converted from\r
+ *\r
+ *      t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",\r
+ *                       &w, &x, &y, &z);\r
+ *\r
+ * by SORCERER.\r
+ *\r
+ * This function call must be done withing a SORCERER file because SORCERER\r
+ * must convert the token references to the associated token number.\r
+ *\r
+ * This functions parses the template and creates trees which are then\r
+ * matched against the input tree.  The labels are set as they are\r
+ * encountered; hence, partial matches may leave some pointers set\r
+ * and some NULL.  This routines initializes all argument pointers to NULL\r
+ * at the beginning.\r
+ *\r
+ * This function returns the number of labels matched.\r
+ */\r
+int PCCTS_AST::\r
+ast_scan(char *templ, ...)\r
+{\r
+       va_list ap;\r
+       ScanAST *tmpl;\r
+       int n, i, found=0;\r
+       PCCTS_AST ***label_ptrs=NULL;\r
+\r
+       va_start(ap, templ);\r
+\r
+       /* make a ScanAST tree out of the template */\r
+       tmpl = stringparser_parse_scanast(templ, &n);\r
+\r
+       /* make an array out of the labels */\r
+       if ( n>0 )\r
+       {\r
+               label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **));\r
+               require(label_ptrs!=NULL, "scan: out of memory");\r
+               for (i=1; i<=n; i++)\r
+               {\r
+                       label_ptrs[i-1] = va_arg(ap, PCCTS_AST **);\r
+                       *(label_ptrs[i-1]) = NULL;\r
+               }\r
+       }\r
+\r
+       /* match the input tree against the template */\r
+       scanmatch(tmpl, label_ptrs, &found);\r
+\r
+       scanast_free(tmpl);\r
+       free( (char *) label_ptrs);                                     // MR1\r
+\r
+       return found;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+new_scanast(int tok)\r
+{\r
+    ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));\r
+//\r
+//  7-Apr-97 133MR1\r
+//\r
+    if ( p == NULL ) {                                                 // MR1\r
+               fprintf(stderr, "out of mem\n");                        // MR1\r
+               exit(PCCTS_EXIT_FAILURE);                               // MR1\r
+    };                                                                 // MR1\r
+       p->_token = tok;\r
+       return p;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_scanast(char *templ, int *num_labels)\r
+{\r
+       StringLexer lex;\r
+       StringParser parser;\r
+       ScanAST *t;\r
+\r
+       stringlexer_init(&lex, templ);\r
+       stringparser_init(&parser, &lex);\r
+       t = stringparser_parse_tree(&parser);\r
+       *num_labels = parser.num_labels;\r
+       return t;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringparser_match(StringParser *parser, int token)\r
+{\r
+       if ( parser->token != token ) panic("bad tree in scan()");\r
+}\r
+\r
+/*\r
+ * Match a tree of the form:\r
+ *             (root child1 child2 ... childn)\r
+ * or,\r
+ *             node\r
+ *\r
+ * where the elements are integers or labeled integers.\r
+ */\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_tree(StringParser *parser)\r
+{\r
+       ScanAST *t=NULL, *root, *child, *last;\r
+\r
+       if ( parser->token != __POUND )\r
+       {\r
+               return stringparser_parse_element(parser);\r
+       }\r
+       stringparser_match(parser,__POUND);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       stringparser_match(parser,__LPAREN);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       root = stringparser_parse_element(parser);\r
+       while ( parser->token != __RPAREN )\r
+       {\r
+               child = stringparser_parse_element(parser);\r
+               if ( t==NULL ) { t = child; last = t; }\r
+               else { last->_right = child; last = child; }\r
+       }\r
+       stringparser_match(parser,__RPAREN);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       root->_down = t;\r
+       return root;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_element(StringParser *parser)\r
+{\r
+       static char ebuf[100];\r
+       int label = 0;\r
+\r
+       if ( parser->token == __POUND )\r
+       {\r
+               return stringparser_parse_tree(parser);\r
+       }\r
+       if ( parser->token == __PERCENT )\r
+       {\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               stringparser_match(parser,__INT);\r
+               label = atoi(parser->lexer->text);\r
+               parser->num_labels++;\r
+               if ( label==0 ) panic("%%0 is an invalid label");\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               stringparser_match(parser,__COLON);\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               /* can label tokens and wildcards */\r
+               if ( parser->token != __INT && parser->token != __PERIOD )\r
+                       panic("can only label tokens");\r
+       }\r
+       if ( parser->token == __INT )\r
+       {\r
+               ScanAST *p = new_scanast(atoi(parser->lexer->text));\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               p->label_num = label;\r
+               return p;\r
+       }\r
+       if ( parser->token == __PERIOD )\r
+       {\r
+               ScanAST *p = new_scanast(0);    /* token of 0 is wildcard */\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               p->label_num = label;\r
+               return p;\r
+       }\r
+       sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token));\r
+       panic(ebuf);\r
+       return NULL;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringparser_init(StringParser *parser, StringLexer *input)\r
+{\r
+       parser->lexer = input;\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       parser->num_labels = 0;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringlexer_init(StringLexer *scanner, char *input)\r
+{\r
+       scanner->text[0]='\0';\r
+       scanner->input = input;\r
+       scanner->p = input;\r
+       stringscan_advance(scanner);\r
+}\r
+\r
+void PCCTS_AST::\r
+stringscan_advance(StringLexer *scanner)\r
+{\r
+       if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF;\r
+       scanner->c = *(scanner->p)++;\r
+}\r
+\r
+int PCCTS_AST::\r
+stringscan_gettok(StringLexer *scanner)\r
+{\r
+       char *index = &scanner->text[0];\r
+       static char ebuf[100];\r
+\r
+       while ( isspace(scanner->c) ) { stringscan_advance(scanner); }\r
+       if ( isdigit(scanner->c) )\r
+       {\r
+               int tok = __INT;\r
+               while ( isdigit(scanner->c) ) {\r
+                       *index++ = scanner->c;\r
+                       stringscan_advance(scanner);\r
+               }\r
+               *index = '\0';\r
+               return tok;\r
+       }\r
+       switch ( scanner->c )\r
+       {\r
+               case '#' : stringscan_advance(scanner); return __POUND;\r
+               case '(' : stringscan_advance(scanner); return __LPAREN;\r
+               case ')' : stringscan_advance(scanner); return __RPAREN;\r
+               case '%' : stringscan_advance(scanner); return __PERCENT;\r
+               case ':' : stringscan_advance(scanner); return __COLON;\r
+               case '.' : stringscan_advance(scanner); return __PERIOD;\r
+               case '\0' : return __StringScanEOF;\r
+               case __StringScanEOF : return __StringScanEOF;\r
+               default  :\r
+                       sprintf(ebuf, "invalid char in scan: '%c'", scanner->c);\r
+                       panic(ebuf);\r
+       }\r
+       return __StringScanEOF; // never reached\r
+}\r
+\r
+const char *PCCTS_AST:: /* MR20 const */\r
+scan_token_str(int t)\r
+{\r
+       if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];\r
+       else if ( t==__StringScanEOF ) return "<end-of-string>";\r
+       else return "<invalid-token>";\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h
new file mode 100644 (file)
index 0000000..c9fb597
--- /dev/null
@@ -0,0 +1,142 @@
+/* Abstract syntax tree\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef PCCTSAST_H\r
+#define PCCTSAST_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+//class SList;\r
+\r
+#define StringScanMaxText  50\r
+#define MaxTreeStackDepth  400\r
+\r
+//\r
+//  7-Apr-97 133MR1  signed int not accepted by AT&T cfront\r
+//\r
+typedef struct stringlexer {\r
+      int c;            // MR1\r
+      char *input;\r
+      char *p;\r
+      char text[StringScanMaxText];\r
+    } StringLexer;\r
+\r
+/* Define the structures needed for ast_scan() */\r
+typedef struct stringparser {\r
+      int token;\r
+      StringLexer *lexer;\r
+      int num_labels;\r
+    } StringParser;\r
+\r
+typedef struct _scanast {\r
+            struct _scanast *_right, *_down;\r
+            int _token;\r
+      int label_num;\r
+      int type() { return _token; }\r
+      struct _scanast *right() { return _right; }\r
+      struct _scanast *down() { return _down; }\r
+        } ScanAST;\r
+\r
+#define VALID_SCAN_TOKEN(t)    (t>=__LPAREN && t<=__PERIOD)\r
+\r
+class DllExportPCCTS PCCTS_AST {\r
+protected:\r
+  static const char *scan_token_tbl[];    /* MR20 const */\r
+  enum {\r
+  __LPAREN=1,\r
+  __RPAREN=2,\r
+  __PERCENT=3,\r
+  __INT=4,\r
+  __COLON=5,\r
+  __POUND=6,\r
+  __PERIOD=7,\r
+  __StringScanEOF=-1};\r
+\r
+protected:\r
+  const char *scan_token_str(int t);  /* MR20 const */\r
+  void stringlexer_init(StringLexer *scanner, char *input);\r
+  void stringparser_init(StringParser *, StringLexer *);\r
+  ScanAST *stringparser_parse_scanast(char *templ, int *n);\r
+  ScanAST *stringparser_parse_tree(StringParser *parser);\r
+  ScanAST *stringparser_parse_element(StringParser *parser);\r
+  void stringscan_advance(StringLexer *scanner);\r
+  int stringscan_gettok(StringLexer *scanner);\r
+  void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);\r
+  PCCTS_AST *_pop(PCCTS_AST **st, int *sp);\r
+  int match_partial(PCCTS_AST *t, PCCTS_AST *u);\r
+  int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);\r
+  void scanast_free(ScanAST *t);\r
+  ScanAST *new_scanast(int tok);\r
+  void stringparser_match(StringParser *parser, int type);\r
+  virtual PCCTS_AST *deepCopyBushy();\r
+\r
+public:\r
+  PCCTS_AST()  {;}\r
+  virtual ~PCCTS_AST() {;}\r
+\r
+  /* This group must be defined for SORCERER to work correctly */\r
+  virtual PCCTS_AST *right() = 0;\r
+  virtual PCCTS_AST *down() = 0;\r
+  virtual void setRight(PCCTS_AST *t) = 0;\r
+  virtual void setDown(PCCTS_AST *t) = 0;\r
+// we define these so ANTLR doesn't have to\r
+  virtual int type() { return 0; }\r
+  virtual void setType(int t) {;}\r
+  virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}\r
+\r
+  /* These are not needed by ANTLR, but are support functions */\r
+  virtual PCCTS_AST *deepCopy();  // used by SORCERER in transform mode\r
+  virtual void addChild(PCCTS_AST *t);\r
+  virtual void lisp_action(FILE *f) {;}\r
+  virtual void lisp(FILE *f);\r
+  static PCCTS_AST *make(PCCTS_AST *rt, ...);\r
+  virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);\r
+  virtual int match(PCCTS_AST *u);\r
+  virtual void insert_after(PCCTS_AST *b);\r
+  virtual void append(PCCTS_AST *b);\r
+  virtual PCCTS_AST *tail();\r
+  virtual PCCTS_AST *bottom();\r
+  static  PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);\r
+//  virtual SList *to_slist();\r
+  virtual void tfree();\r
+  int ast_scan(char *templ, ...);\r
+  virtual int nsiblings();\r
+  virtual PCCTS_AST *sibling_index(int i);\r
+\r
+  void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */\r
+  virtual void panic(const char *err)     // MR20 const\r
+    { fprintf(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
+};\r
+\r
+#endif /* PCCTSAST_H */\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h
new file mode 100644 (file)
index 0000000..8357878
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef SList_h\r
+#define SList_h\r
+\r
+/*\r
+ * SList.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * PCCTS 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1992-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "PCCTSAST.h"\r
+\r
+class PCCTS_AST;\r
+\r
+class SListNode {\r
+protected:\r
+  void *_elem;      /* pointer to any kind of element */\r
+  SListNode *_next;\r
+public:\r
+  SListNode()        {_elem=_next=NULL;}\r
+  virtual ~SListNode()  {_elem=_next=NULL;}\r
+  void *elem()      { return _elem; }\r
+  void setElem(void *e)  { _elem = e; }\r
+  void setNext(SListNode *t)  { _next = t; }\r
+  SListNode *next()    { return _next; }\r
+};\r
+\r
+class SList {\r
+  SListNode *head, *tail;\r
+public:\r
+  SList() {head=tail=NULL;}\r
+  virtual ~SList() {head=tail=NULL;}\r
+  virtual void *iterate(SListNode **);\r
+  virtual void add(void *e);\r
+  virtual void lfree();\r
+  virtual PCCTS_AST *to_ast(SList list);\r
+  virtual void require(int e,char *err){ if ( !e ) panic(err); }\r
+  virtual void panic(char *err){ fprintf(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
+};\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h
new file mode 100644 (file)
index 0000000..01bda69
--- /dev/null
@@ -0,0 +1,788 @@
+/* antlr.h \r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ANTLR_H\r
+#define ANTLR_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+/* turn off warnings for unreferenced labels */\r
+\r
+#ifdef _MSC_VER\r
+#pragma warning(disable:4102)\r
+#endif\r
+\r
+/*\r
+ * Define all of the stack setup and manipulation of $i, #i variables.\r
+ *\r
+ *  Notes:\r
+ *    The type 'Attrib' must be defined before entry into this .h file.\r
+ */\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+#include "pccts_stdlib.h"\r
+#else\r
+#ifdef VAXC\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#endif\r
+#include "pccts_string.h"\r
+\r
+#if 0\r
+#include "set.h"\r
+#endif\r
+\r
+\r
+typedef int ANTLRTokenType;\r
+typedef unsigned char SetWordType;\r
+\r
+typedef char ANTLRChar;\r
+\r
+            /* G u e s s  S t u f f */\r
+\r
+#ifdef ZZCAN_GUESS\r
+#ifndef ZZINF_LOOK\r
+#define ZZINF_LOOK\r
+#endif\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+typedef struct _zzjmp_buf {\r
+      jmp_buf state;\r
+    } zzjmp_buf;\r
+#endif\r
+\r
+\r
+/* can make this a power of 2 for more efficient lookup */\r
+\r
+#ifndef ZZLEXBUFSIZE\r
+#define ZZLEXBUFSIZE  8000 /* MR22 raise from 2k to 8k */\r
+#endif\r
+\r
+#define zzOvfChk                            \\r
+            if ( zzasp <= 0 )                                           \\r
+            {                                                           \\r
+                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);    \\r
+                exit(PCCTS_EXIT_FAILURE);                                               \\r
+            }\r
+\r
+#ifndef ZZA_STACKSIZE\r
+#define ZZA_STACKSIZE  400\r
+#endif\r
+#ifndef ZZAST_STACKSIZE\r
+#define ZZAST_STACKSIZE  400\r
+#endif\r
+\r
+#ifndef zzfailed_pred\r
+#ifdef ZZCAN_GUESS\r
+#define zzfailed_pred(_p) \\r
+  if (zzguessing) { \\r
+    zzGUESS_FAIL; \\r
+  } else { \\r
+    fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); \\r
+  }\r
+#else\r
+#define zzfailed_pred(_p)  \\r
+  fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p)\r
+#endif\r
+#endif\r
+\r
+/* MR19 zzchar_t additions */\r
+\r
+#ifdef LL_K\r
+#define LOOKAHEAD \\r
+  int zztokenLA[LL_K]; \\r
+  zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \\r
+  int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */\r
+#else\r
+#define LOOKAHEAD                        \\r
+  int zztoken;\r
+#endif\r
+\r
+#ifndef zzcr_ast\r
+#define zzcr_ast(ast,attr,tok,text)\r
+#endif\r
+\r
+#ifdef DEMAND_LOOK\r
+#define DemandLookData  int zzdirty=1;\r
+#else\r
+#define DemandLookData\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_HOOK\r
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_DONE_HOOK\r
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
+#endif\r
+\r
+            /* S t a t e  S t u f f */\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzGUESS_BLOCK    zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen;\r
+\r
+/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */\r
+\r
+#define zzGUESS        zzsave_antlr_state(&zzst); \\r
+              zzguessing = 1; \\r
+                            zzGuessSeqFrozen=++zzGuessSeq; \\r
+              zzrv = setjmp(zzguess_start.state); \\r
+                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
+                            if (zzrv) zzGUESS_DONE;\r
+#ifdef zzTRACE_RULES\r
+#define zzGUESS_FAIL    { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); }\r
+#else\r
+#define zzGUESS_FAIL    longjmp(zzguess_start.state, 1)\r
+#endif\r
+\r
+/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */\r
+\r
+#define zzGUESS_DONE    { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
+#define zzNON_GUESS_MODE  if ( !zzguessing )\r
+#define zzGuessData                                     \\r
+            zzjmp_buf zzguess_start;                    \\r
+            int zzguessing;\r
+#else\r
+#define zzGUESS_BLOCK\r
+#define zzGUESS\r
+#define zzGUESS_FAIL\r
+#define zzGUESS_DONE\r
+#define zzNON_GUESS_MODE\r
+#define zzGuessData\r
+#endif\r
+\r
+typedef struct _zzantlr_state {\r
+#ifdef ZZCAN_GUESS\r
+      zzjmp_buf guess_start;\r
+      int guessing;\r
+#endif\r
+      int asp;\r
+      int ast_sp;\r
+#ifdef ZZINF_LOOK\r
+      int inf_lap;  /* not sure we need to save this one */\r
+      int inf_labase;\r
+      int inf_last;\r
+\r
+/* MR6   Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6    Additional state needs to be saved/restored                       */\r
+/* MR6    Matching changes in err.h                                         */\r
+\r
+      int *inf_tokens;                                       /* MR6 */\r
+      char **inf_text;                                       /* MR6 */\r
+      char *inf_text_buffer;                                 /* MR6 */\r
+      int *inf_line;                                         /* MR6 */\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+      int dirty;\r
+#endif\r
+\r
+#ifdef LL_K\r
+      int tokenLA[LL_K];\r
+      char textLA[LL_K][ZZLEXBUFSIZE];\r
+      int lap;\r
+      int labase;\r
+#else\r
+      int token;\r
+      char text[ZZLEXBUFSIZE];\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+            int     traceOptionValue;       /* MR10 */\r
+            int     traceGuessOptionValue;  /* MR10 */\r
+            char    *traceCurrentRuleName;  /* MR10 */\r
+            int     traceDepth;             /* MR10 */\r
+#endif\r
+\r
+    } zzantlr_state;\r
+\r
+#ifdef zzTRACE_RULES\r
+extern int  zzTraceOptionValueDefault;\r
+extern int  zzTraceOptionValue;\r
+extern int  zzTraceGuessOptionValue;\r
+extern char *zzTraceCurrentRuleName;\r
+extern int  zzTraceDepth;\r
+#endif\r
+\r
+extern int zzGuessSeq;                      /* MR10 */\r
+extern int zzSyntaxErrCount;                /* MR11 */\r
+extern int zzLexErrCount;                   /* MR11 */\r
+\r
+                 /* I n f i n i t e  L o o k a h e a d */\r
+\r
+\r
+#ifdef ZZINF_LOOK\r
+#define InfLookData  \\r
+  int *zzinf_tokens;  \\r
+  char **zzinf_text;  \\r
+  char *zzinf_text_buffer;  \\r
+  int *zzinf_line;        \\r
+  int zzinf_labase;  \\r
+  int zzinf_last;\r
+#else\r
+#define InfLookData\r
+#endif\r
+\r
+#ifdef ZZINF_LOOK\r
+\r
+#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE\r
+#define ZZINF_DEF_TEXT_BUFFER_SIZE      20000\r
+#endif\r
+#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE\r
+#define ZZINF_DEF_TOKEN_BUFFER_SIZE      2000\r
+#endif\r
+/* WARNING!!!!!!\r
+ * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.\r
+ */\r
+#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE  5000\r
+#endif\r
+#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TOKEN_CHUNK_SIZE  1000\r
+#endif\r
+\r
+#if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE  ZZLEXBUFSIZE+5\r
+#endif\r
+\r
+/* make inf_look user-access macros */\r
+#ifdef LL_K\r
+#define ZZINF_LA_VALID(i)  (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last)\r
+#define ZZINF_LA(i)      zzinf_tokens[(zzinf_labase+i-1)-LL_K+1]\r
+#define ZZINF_LATEXT(i)    zzinf_text[(zzinf_labase+i-1)-LL_K+1]\r
+/* MR6  In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out  */\r
+#define ZZINF_LINE(i)       zzinf_line[(zzinf_labase+i-1)-LL_K+1]\r
+#else\r
+#define ZZINF_LA_VALID(i)  (((zzinf_labase+i-1)) <= zzinf_last)\r
+#define ZZINF_LA(i)      zzinf_tokens[(zzinf_labase+i-1)]\r
+#define ZZINF_LATEXT(i)    zzinf_text[(zzinf_labase+i-1)]\r
+#endif\r
+\r
+#define inf_zzgettok _inf_zzgettok()\r
+extern void _inf_zzgettok();\r
+\r
+#endif  /* ZZINF_LOOK */\r
+\r
+\r
+#ifdef LL_K\r
+\r
+#ifdef __USE_PROTOS\r
+#define ANTLR_INFO  \\r
+  Attrib zzempty_attr(void) {static Attrib a; return a;} \\r
+  Attrib zzconstr_attr(int _tok, char *_text) \\r
+    {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \\r
+  int zzasp=ZZA_STACKSIZE; \\r
+  char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \\r
+  Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \\r
+  InfLookData \\r
+    zzGuessData\r
+#else\r
+#define ANTLR_INFO                        \\r
+  Attrib zzempty_attr() {static Attrib a; return a;}        \\r
+  Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;    \\r
+    {Attrib a; zzcr_attr((&a),_tok,_text); return a;}      \\r
+  int zzasp=ZZA_STACKSIZE;              \\r
+  char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";  \\r
+  Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData          \\r
+  InfLookData                                                 \\r
+    zzGuessData\r
+#endif\r
+\r
+#else\r
+\r
+#ifdef __USE_PROTOS\r
+#define ANTLR_INFO                        \\r
+  Attrib zzempty_attr(void) {static Attrib a; return a;}      \\r
+  Attrib zzconstr_attr(int _tok, char *_text)        \\r
+    {Attrib a; zzcr_attr((&a),_tok,_text); return a;}    \\r
+  int zzasp=ZZA_STACKSIZE;            \\r
+  char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
+  Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData        \\r
+  InfLookData                                                             \\r
+    zzGuessData\r
+#else\r
+#define ANTLR_INFO                        \\r
+  Attrib zzempty_attr() {static Attrib a; return a;}      \\r
+  Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;                \\r
+    {Attrib a; zzcr_attr((&a),_tok,_text); return a;}    \\r
+  int zzasp=ZZA_STACKSIZE;            \\r
+  char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
+  Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData        \\r
+  InfLookData                                                             \\r
+    zzGuessData\r
+#endif\r
+  \r
+#endif /* LL_k */\r
+\r
+\r
+#ifdef ZZINF_LOOK\r
+\r
+#ifdef LL_K\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
+#else\r
+#define zzPrimeLookAhead  {zzlap = zzlabase = 0; zzfill_inf_look();\\r
+              {int _i;  for(_i=1;_i<=LL_K; _i++)    \\r
+                    {zzCONSUME;} zzlap = zzlabase = 0;}}\r
+#endif\r
+\r
+#else /* LL_K */\r
+\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  zzfill_inf_look(); zzdirty=1\r
+#else\r
+#define zzPrimeLookAhead  zzfill_inf_look(); inf_zzgettok\r
+\r
+#endif\r
+#endif  /* LL_K */\r
+\r
+#else  /* ZZINF_LOOK */\r
+\r
+#ifdef LL_K\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
+#else\r
+#define zzPrimeLookAhead  {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++)    \\r
+                    {zzCONSUME;} zzlap = 0;}\r
+#endif\r
+\r
+#else\r
+\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  zzdirty=1\r
+#else\r
+#define zzPrimeLookAhead  zzgettok()\r
+#endif\r
+#endif  /* LL_K */\r
+\r
+#endif  /* ZZINF_LOOK */\r
+\r
+\r
+#ifdef LL_K\r
+#define zzenterANTLRs(s)                            \\r
+        zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;\r
+#define zzenterANTLRf(f)              \\r
+    zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;\r
+#define zzenterANTLR(f)              \\r
+    zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;\r
+#ifdef ZZINF_LOOK\r
+#define zzleaveANTLR(f)      free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRf(f)       free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRs(f)    free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#else\r
+#define zzleaveANTLR(f)\r
+#define zzleaveANTLRf(f)\r
+#define zzleaveANTLRs(f)\r
+#endif\r
+\r
+#else\r
+\r
+#define zzenterANTLRs(s)                            \\r
+        {static char zztoktext[ZZLEXBUFSIZE];   \\r
+        zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}\r
+#define zzenterANTLRf(f)              \\r
+    {static char zztoktext[ZZLEXBUFSIZE];  \\r
+    zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}\r
+#define zzenterANTLR(f)              \\r
+    {static char zztoktext[ZZLEXBUFSIZE];  \\r
+    zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}\r
+#ifdef ZZINF_LOOK\r
+#define zzleaveANTLR(f)      free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRf(f)       free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRs(f)    free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#else\r
+#define zzleaveANTLR(f)\r
+#define zzleaveANTLRf(f)\r
+#define zzleaveANTLRs(f)\r
+#endif\r
+\r
+#endif\r
+\r
+/* MR19 Paul D. Smith (psmith@baynetworks.com)\r
+   Need to adjust AST stack pointer at exit.\r
+   Referenced in ANTLRx macros.\r
+*/\r
+\r
+#ifdef GENAST\r
+#define ZZAST_ADJUST ++zzast_sp;\r
+#else\r
+#define ZZAST_ADJUST\r
+#endif\r
+\r
+#define ANTLR(st, f)  zzbufsize = ZZLEXBUFSIZE;  \\r
+            zzenterANTLR(f);      \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+              st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                  /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+            zzleaveANTLR(f);\r
+            \r
+#define ANTLRm(st, f, _m)  zzbufsize = ZZLEXBUFSIZE;  \\r
+            zzmode(_m);        \\r
+            zzenterANTLR(f);      \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+              st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                  /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+            zzleaveANTLR(f);\r
+            \r
+#define ANTLRf(st, f)  zzbufsize = ZZLEXBUFSIZE;  \\r
+            zzenterANTLRf(f);      \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+              st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                  /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+            zzleaveANTLRf(f);\r
+\r
+#define ANTLRs(st, s)   zzbufsize = ZZLEXBUFSIZE;  \\r
+                        zzenterANTLRs(s);           \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+              st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                  /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+                        zzleaveANTLRs(s);\r
+\r
+#ifdef LL_K\r
+#define zztext    (&(zztextLA[zzlap][0]))\r
+#else\r
+#define zztext    zzlextext\r
+#endif\r
+\r
+\r
+          /* A r g u m e n t  A c c e s s */\r
+\r
+#define zzaCur      (zzaStack[zzasp])\r
+#define zzaRet      (*zzaRetPtr)\r
+#define zzaArg(v,n)    zzaStack[v-n]\r
+#define zzMakeAttr    { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}\r
+#ifdef zzdef0\r
+#define zzMake0      { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}\r
+#else\r
+#define zzMake0      { zzOvfChk; --zzasp;}\r
+#endif\r
+#define zzaPush(_v)    { zzOvfChk; zzaStack[--zzasp] = _v;}\r
+#ifndef zzd_attr\r
+#define zzREL(t)    zzasp=(t);    /* Restore state of stack */\r
+#else\r
+#define zzREL(t)    for (; zzasp<(t); zzasp++)        \\r
+            { zzd_attr(&(zzaStack[zzasp])); }\r
+#endif\r
+\r
+\r
+#define zzsetmatch(_es)            \\r
+  if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzsetmatch_wsig(_es, handler)    \\r
+  if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
+#else\r
+#define zzsetmatch_wsig(_es, handler)    \\r
+  if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;}\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **);\r
+extern int _zzsetmatch_wsig(SetWordType *);\r
+#else\r
+extern int _zzsetmatch();\r
+extern int _zzsetmatch_wsig();\r
+#endif\r
+\r
+#define zzmatch(_t)              \\r
+  if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzmatch_wsig(_t,handler)      \\r
+  if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
+#else\r
+#define zzmatch_wsig(_t,handler)      \\r
+  if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;}\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);\r
+extern int _zzmatch_wsig(int);\r
+#else\r
+extern int _zzmatch();\r
+extern int _zzmatch_wsig();\r
+#endif\r
+\r
+#define zzmatch_wdfltsig(_t,_f)      \\r
+  if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken;\r
+#define zzsetmatch_wdfltsig(tw,tt,wf)    \\r
+  if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken;\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzmatch_wdfltsig(int, SetWordType *);\r
+extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
+                int tokenTypeOfSet,\r
+                SetWordType *whatFollows);\r
+#else\r
+extern int _zzmatch_wdfltsig();\r
+extern int _zzsetmatch_wdfltsig();\r
+#endif\r
+\r
+#ifdef GENAST\r
+#define zzRULE    Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);  \\r
+          SetWordType *zzMissSet=NULL; int zzMissTok=0;    \\r
+          int zzBadTok=0; char *zzBadText="";    \\r
+          int zzErrk=1,zzpf=0;          \\r
+                    zzTRACEdata \\r
+          char *zzMissText=""; zzASTVars\r
+#else\r
+#define zzRULE    Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);  \\r
+          int zzBadTok=0; char *zzBadText="";    \\r
+          int zzErrk=1,zzpf=0;                \\r
+                    zzTRACEdata \\r
+          SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText=""\r
+#endif\r
+\r
+#ifdef GENAST\r
+#define zzBLOCK(i)  int i = zzasp - 1; int zztsp = zzast_sp\r
+#define zzEXIT(i)  zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); }\r
+#define zzEXIT_ANTLR(i)  zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */\r
+#define zzLOOP(i)  zzREL(i); zzastREL\r
+#else\r
+#define zzBLOCK(i)  int i = zzasp - 1\r
+#define zzEXIT(i)  zzREL(i)\r
+#define zzEXIT_ANTLR(i)  zzREL(i)           /* [i_a] added as we want this for the ANTLRx() macros */\r
+#define zzLOOP(i)  zzREL(i)\r
+#endif\r
+\r
+#ifdef LL_K\r
+\r
+#ifdef DEMAND_LOOK\r
+#define LOOK(_k)  {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++)  \\r
+          zzCONSUME;}\r
+#define zzCONSUME  {zzgettok(); zzdirty--;              \\r
+          zzlap = (zzlap+1)&(LL_K-1);            \\r
+          zzlextext = &(zztextLA[zzlap][0]);}\r
+#else\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME  {inf_zzgettok;                   \\r
+          zzlap = (zzlap+1)&(LL_K-1);            \\r
+          zzlextext = &(zztextLA[zzlap][0]);        \\r
+          }\r
+#else\r
+#define zzCONSUME  {zzgettok();                   \\r
+          zzlap = (zzlap+1)&(LL_K-1);            \\r
+          zzlextext = &(zztextLA[zzlap][0]);}\r
+#endif /* ZZINF_LOOK */\r
+#endif /* DEMAND_LOOK */\r
+\r
+#else /* LL_K */\r
+\r
+#ifdef DEMAND_LOOK\r
+#define LOOK(_k)  if ( zzdirty) zzCONSUME;\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME  inf_zzgettok; zzdirty=0;\r
+#else\r
+#define zzCONSUME  zzgettok(); zzdirty=0;\r
+#endif /* ZZINF_LOOK */\r
+\r
+#else  /* DEMAND_LOOK */\r
+\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME  inf_zzgettok\r
+#else\r
+#define zzCONSUME  zzgettok();\r
+#endif\r
+\r
+#endif /* DEMAND_LOOK */\r
+\r
+#endif /* LL_K */\r
+\r
+#ifdef LL_K\r
+#define NLA      zztokenLA[zzlap&(LL_K-1)]  /* --> next LA */\r
+#define NLATEXT    zztextLA[zzlap&(LL_K-1)]  /* --> next text of LA */\r
+#ifdef DEMAND_LOOK\r
+#define LA(i)       zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]\r
+#define LATEXT(i)   (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))\r
+#else\r
+#define LA(i)       zztokenLA[(zzlap+(i)-1)&(LL_K-1)]\r
+#define LATEXT(i)   (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))\r
+#endif\r
+#else\r
+#define NLA      zztoken\r
+#define NLATEXT    zztext\r
+#define LA(i)       zztoken\r
+#define LATEXT(i)   zztext\r
+#endif\r
+\r
+\r
+           /* S t a n d a r d  S i g n a l s */\r
+\r
+#define NoSignal      0\r
+#define MismatchedToken    1\r
+#define NoViableAlt      2\r
+#define NoSemViableAlt    3\r
+\r
+/* MR7  Allow more control over signalling                                  */\r
+/*        by adding "Unwind" and "zzsetSignal"                              */\r
+\r
+#define Unwind              4\r
+#define zzsetSignal(newValue) *_retsignal=_signal=(newValue)\r
+#define zzsuppressSignal *_retsignal=_signal=0\r
+#define zzexportSignal    *_retsignal=_signal\r
+\r
+           /* F u n c t i o n  T r a c i n g */\r
+\r
+#ifndef zzTRACE_RULES\r
+#define zzTRACEdata\r
+#else\r
+#ifndef zzTRACEdata\r
+#define zzTRACEdata     ANTLRChar *zzTracePrevRuleName = NULL;\r
+#endif\r
+#endif\r
+\r
+#ifndef zzTRACEIN\r
+#define zzTRACEIN(r)  zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r);\r
+#endif\r
+#ifndef zzTRACEOUT\r
+#define zzTRACEOUT(r)  zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName;\r
+#endif\r
+\r
+/* MR19 zzchar_t additions */\r
+\r
+#ifndef zzchar_t\r
+#ifdef ZZWCHAR_T\r
+#define zzchar_t wchar_t\r
+#else\r
+#define zzchar_t char\r
+#endif\r
+#endif\r
+\r
+        /* E x t e r n  D e f s */\r
+\r
+#ifdef __USE_PROTOS\r
+extern Attrib zzempty_attr(void);\r
+extern Attrib zzconstr_attr(int, char *);\r
+extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);\r
+extern int zzset_el(unsigned, SetWordType *);\r
+extern int zzset_deg(SetWordType *);\r
+extern void zzedecode(SetWordType *);\r
+extern void zzFAIL(int k, ...);\r
+extern void zzresynch(SetWordType *, SetWordType);\r
+extern void zzsave_antlr_state(zzantlr_state *);\r
+extern void zzrestore_antlr_state(zzantlr_state *);\r
+extern void zzfill_inf_look(void);\r
+extern void zzconsumeUntil(SetWordType *st);                         /* MR7 */\r
+extern void zzconsumeUntilToken(int t);                              /* MR7 */\r
+extern void zzTraceIn(char * ruleName);                              /* MR10 */\r
+extern void zzTraceOut(char * ruleName);                             /* MR10 */\r
+extern int  zzTraceOption(int delta);                                /* MR10 */\r
+extern int  zzTraceGuessOption(int delta);                           /* MR10 */\r
+extern void zzTraceReset(void);                                      /* MR10 */\r
+extern void zzTraceGuessFail(void);                                  /* MR10 */\r
+#ifdef EXCEPTION_HANDLING\r
+extern void zzdflthandlers(int, int *);\r
+#endif\r
+#else\r
+extern Attrib zzempty_attr();\r
+extern Attrib zzconstr_attr();\r
+extern void zzsyn();\r
+extern int zzset_el();\r
+extern int zzset_deg();\r
+extern void zzedecode();\r
+extern void zzFAIL();\r
+extern void zzresynch();\r
+extern void zzsave_antlr_state();\r
+extern void zzrestore_antlr_state();\r
+extern void zzfill_inf_look();\r
+extern void zzconsumeUntil();                                        /* MR7 */\r
+extern void zzconsumeUntilToken();                                   /* MR7 */\r
+extern void zzTraceIn();                                             /* MR10 */\r
+extern void zzTraceOut();                                            /* MR10 */\r
+extern int  zzTraceOption();                                         /* MR10 */\r
+extern int  zzTraceGuessOption();                                    /* MR10 */\r
+extern void zzTraceReset();                                          /* MR10 */\r
+extern void zzTraceGuessFail();                                      /* MR10 */\r
+#ifdef EXCEPTION_HANDLING\r
+extern void zzdflthandlers();\r
+#endif\r
+#endif\r
+\r
+        /* G l o b a l  V a r i a b l e s */\r
+\r
+/* Define a parser; user should do a "#parser myname" in their grammar file */\r
+/*extern struct pccts_parser zzparser;*/\r
+\r
+extern char *zztokens[];\r
+#ifdef LL_K\r
+extern int zztokenLA[];\r
+extern zzchar_t zztextLA[][ZZLEXBUFSIZE];\r
+extern int zzlap;\r
+extern int zzlabase;\r
+#else\r
+extern int zztoken;\r
+#endif\r
+\r
+extern char zzStackOvfMsg[];\r
+extern int zzasp;\r
+extern Attrib zzaStack[];\r
+#ifdef ZZINF_LOOK\r
+extern int *zzinf_tokens;\r
+extern char **zzinf_text;\r
+extern char *zzinf_text_buffer;\r
+extern int *zzinf_line;\r
+extern int zzinf_labase;\r
+extern int zzinf_last;\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+extern int zzdirty;\r
+#endif\r
+#ifdef ZZCAN_GUESS\r
+extern int zzguessing;\r
+extern zzjmp_buf zzguess_start;\r
+#endif\r
+\r
+/* Define global veriables that refer to values exported by the scanner.\r
+ * These declarations duplicate those in dlgdef.h, but are needed\r
+ * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.\r
+ */\r
+extern zzchar_t *zzlextext;     /* text of most recently matched token */\r
+extern int      zzbufsize;      /* how long zzlextext is */\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c
new file mode 100644 (file)
index 0000000..58db285
--- /dev/null
@@ -0,0 +1,345 @@
+/* Abstract syntax tree manipulation functions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed. \r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include "pccts_stdarg.h"\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+/* ensure that tree manipulation variables are current after a rule\r
+ * reference\r
+ */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzlink(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzlink(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+  if ( *_sibling == NULL ) return;\r
+  if ( *_root == NULL ) *_root = *_sibling;\r
+  else if ( *_root != *_sibling ) (*_root)->down = *_sibling;\r
+  if ( *_tail==NULL ) *_tail = *_sibling;\r
+  while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right;\r
+}\r
+\r
+AST *\r
+#ifdef __USE_PROTOS\r
+zzastnew(void)\r
+#else\r
+zzastnew()\r
+#endif\r
+{\r
+  AST *p = (AST *) calloc(1, sizeof(AST));\r
+  if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__);\r
+  return p;\r
+}\r
+\r
+/* add a child node to the current sibling list */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsubchild(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzsubchild(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+  AST *n;\r
+  zzNON_GUESS_MODE {\r
+  n = zzastnew();\r
+#ifdef DEMAND_LOOK\r
+  zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
+#else\r
+  zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
+#endif\r
+  zzastPush( n );\r
+  if ( *_tail != NULL ) (*_tail)->right = n;\r
+  else {\r
+    *_sibling = n;\r
+    if ( *_root != NULL ) (*_root)->down = *_sibling;\r
+  }\r
+  *_tail = n;\r
+  if ( *_root == NULL ) *_root = *_sibling;\r
+  }\r
+}\r
+\r
+/* make a new AST node.  Make the newly-created\r
+ * node the root for the current sibling list.  If a root node already\r
+ * exists, make the newly-created node the root of the current root.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsubroot(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzsubroot(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+  AST *n;\r
+  zzNON_GUESS_MODE {\r
+  n = zzastnew();\r
+#ifdef DEMAND_LOOK\r
+  zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
+#else\r
+  zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
+#endif\r
+  zzastPush( n );\r
+  if ( *_root != NULL )\r
+    if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root;\r
+  *_root = n;\r
+  (*_root)->down = *_sibling;\r
+  }\r
+}\r
+\r
+/* Apply function to root then each sibling\r
+ * example: print tree in child-sibling LISP-format (AST has token field)\r
+ *\r
+ *  void show(tree)\r
+ *  AST *tree;\r
+ *  {\r
+ *    if ( tree == NULL ) return;\r
+ *    printf(" %s", zztokens[tree->token]);\r
+ *  }\r
+ *\r
+ *  void before() { printf(" ("); }\r
+ *  void after()  { printf(" )"); }\r
+ *\r
+ *  LISPdump() { zzpre_ast(tree, show, before, after); }\r
+ *\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzpre_ast(\r
+    AST *tree,\r
+    void (*func)(AST *),   /* apply this to each tree node */\r
+    void (*before)(AST *), /* apply this to root of subtree before preordering it */\r
+    void (*after)(AST *))  /* apply this to root of subtree after preordering it */\r
+#else\r
+zzpre_ast(tree, func, before, after)\r
+AST *tree;\r
+void (*func)(),   /* apply this to each tree node */\r
+   (*before)(), /* apply this to root of subtree before preordering it */\r
+   (*after)();  /* apply this to root of subtree after preordering it */\r
+#endif\r
+{\r
+  while ( tree!= NULL )\r
+  {\r
+    if ( tree->down != NULL ) (*before)(tree);\r
+    (*func)(tree);\r
+    zzpre_ast(tree->down, func, before, after);\r
+    if ( tree->down != NULL ) (*after)(tree);\r
+    tree = tree->right;\r
+  }\r
+}\r
+\r
+/* free all AST nodes in tree; apply func to each before freeing */\r
+\r
+#if 0\r
+////void\r
+////#ifdef __USE_PROTOS\r
+////zzfree_ast(AST *tree)\r
+////#else\r
+////zzfree_ast(tree)\r
+////AST *tree;\r
+////#endif\r
+////{\r
+////  if ( tree == NULL ) return;\r
+////  zzfree_ast( tree->down );\r
+////  zzfree_ast( tree->right );\r
+////  zztfree( tree );\r
+////}\r
+#endif\r
+\r
+/*\r
+   MR19 Optimize freeing of the following structure to limit recursion\r
+   SAKAI Kiyotaka (ksakai@isr.co.jp)\r
+*/\r
+\r
+/*\r
+         NULL o\r
+             / \\r
+           NULL o\r
+               / \\r
+            NULL NULL\r
+*/\r
+\r
+/*\r
+   MR21 Another refinement to replace recursion with iteration\r
+   NAKAJIMA Mutsuki (muc@isr.co.jp).\r
+*/\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzfree_ast(AST *tree)\r
+#else\r
+zzfree_ast(tree)\r
+AST *tree;\r
+#endif\r
+{\r
+\r
+    AST *otree;\r
+\r
+    if (tree == NULL) return;\r
+\r
+    while (tree->down == NULL || tree->right == NULL) {\r
+\r
+        if (tree->down == NULL && tree->right == NULL) {\r
+            zztfree(tree);\r
+            return;\r
+        }\r
+\r
+        otree = tree;\r
+        if (tree->down == NULL) {\r
+            tree = tree->right;\r
+        } else {\r
+            tree = tree->down;\r
+        }\r
+        zztfree( otree );\r
+    }\r
+\r
+    while (tree != NULL) {\r
+        zzfree_ast(tree->down);\r
+        otree = tree;\r
+        tree = otree->right;\r
+        zztfree(otree);\r
+    }\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually siblins lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ */\r
+#ifdef PCCTS_USE_STDARG\r
+AST *zztmake(AST *rt, ...)\r
+#else\r
+AST *zztmake(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+  va_list ap;\r
+  register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w;\r
+  AST *root;\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+  va_start(ap, rt);\r
+  root = rt;\r
+#else\r
+  va_start(ap);\r
+  root = va_arg(ap, AST *);\r
+#endif\r
+\r
+  if ( root != NULL )\r
+    if ( root->down != NULL ) return NULL;\r
+  child = va_arg(ap, AST *);\r
+  while ( child != NULL )\r
+  {\r
+    for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */\r
+    if ( sibling == NULL ) {sibling = child; tail = w;}\r
+    else {tail->right = child; tail = w;}\r
+    child = va_arg(ap, AST *);\r
+  }\r
+  if ( root==NULL ) root = sibling;\r
+  else root->down = sibling;\r
+  va_end(ap);\r
+  return root;\r
+}\r
+\r
+/* tree duplicate */\r
+AST *\r
+#ifdef __USE_PROTOS\r
+zzdup_ast(AST *t)\r
+#else\r
+zzdup_ast(t)\r
+AST *t;\r
+#endif\r
+{\r
+  AST *u;\r
+  \r
+  if ( t == NULL ) return NULL;\r
+  u = zzastnew();\r
+  *u = *t;\r
+#ifdef zzAST_DOUBLE\r
+  u->up = NULL;    /* set by calling invocation */\r
+  u->left = NULL;\r
+#endif\r
+  u->right = zzdup_ast(t->right);\r
+  u->down = zzdup_ast(t->down);\r
+#ifdef zzAST_DOUBLE\r
+  if ( u->right!=NULL ) u->right->left = u;\r
+  if ( u->down!=NULL ) u->down->up = u;\r
+#endif\r
+  return u;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zztfree(AST *t)\r
+#else\r
+zztfree(t)\r
+AST *t;\r
+#endif\r
+{\r
+#ifdef zzd_ast\r
+  zzd_ast( t );\r
+#endif\r
+  free( t );\r
+}\r
+\r
+#ifdef zzAST_DOUBLE\r
+/*\r
+ * Set the 'up', and 'left' pointers of all nodes in 't'.\r
+ * Initial call is double_link(your_tree, NULL, NULL).\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzdouble_link(AST *t, AST *left, AST *up)\r
+#else\r
+zzdouble_link(t, left, up)\r
+AST *t, *left, *up;\r
+#endif\r
+{\r
+  if ( t==NULL ) return;\r
+  t->left = left;\r
+  t->up = up;\r
+  zzdouble_link(t->down, NULL, t);\r
+  zzdouble_link(t->right, t, up);\r
+}\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h
new file mode 100644 (file)
index 0000000..dba8be2
--- /dev/null
@@ -0,0 +1,115 @@
+/* Abstract syntax tree\r
+ *\r
+ * Macros, definitions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ZZAST_H\r
+#define ZZAST_H\r
+\r
+#define zzastOvfChk                            \\r
+      if ( zzast_sp <= 0 )                                        \\r
+            {                                                           \\r
+                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);      \\r
+                exit(PCCTS_EXIT_FAILURE);                                               \\r
+            }\r
+\r
+#ifndef USER_DEFINED_AST\r
+#ifndef AST_FIELDS\r
+#define AST_FIELDS\r
+#endif\r
+\r
+typedef struct _ast {\r
+            struct _ast *right, *down;\r
+#ifdef zzAST_DOUBLE\r
+            struct _ast *left, *up;\r
+#endif\r
+            AST_FIELDS\r
+} AST;\r
+\r
+#else\r
+\r
+#ifdef zzAST_DOUBLE\r
+#define AST_REQUIRED_FIELDS   struct _ast *right, *down, *left, *up;\r
+#else\r
+#define AST_REQUIRED_FIELDS   struct _ast *right, *down;\r
+#endif\r
+\r
+#endif\r
+\r
+\r
+/* N o d e  a c c e s s  m a c r o s */\r
+#define zzchild(t)    (((t)==NULL)? (AST *) NULL:(t->down))   /* MR19 */\r
+#define zzsibling(t)  (((t)==NULL)? (AST *) NULL:(t->right))  /* MR19 */\r
+\r
+\r
+/* define global variables needed by #i stack */\r
+#define zzASTgvars                        \\r
+  AST *zzastStack[ZZAST_STACKSIZE];              \\r
+  int zzast_sp = ZZAST_STACKSIZE;\r
+\r
+#define zzASTVars  AST *_ast = NULL, *_sibling = NULL, *_tail = NULL\r
+#define zzSTR    ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )\r
+#define zzastCur  (zzastStack[zzast_sp])\r
+#define zzastArg(i)  (zzastStack[zztsp-i])\r
+#define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;\r
+#define zzastDPush  --zzast_sp\r
+#define zzastMARK  zztsp=zzast_sp;    /* Save state of stack */\r
+#define zzastREL  zzast_sp=zztsp;    /* Return state of stack */\r
+#define zzrm_ast  {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}\r
+\r
+extern int zzast_sp;\r
+extern AST *zzastStack[];\r
+\r
+#ifdef __USE_PROTOS\r
+void zzlink(AST **, AST **, AST **);\r
+void zzsubchild(AST **, AST **, AST **);\r
+void zzsubroot(AST **, AST **, AST **);\r
+void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));\r
+void zzfree_ast(AST *);\r
+AST *zztmake(AST *, ...);\r
+AST *zzdup_ast(AST *);\r
+void zztfree(AST *);\r
+void zzdouble_link(AST *, AST *, AST *);\r
+AST *zzastnew(void);\r
+\r
+#else\r
+\r
+void zzlink();\r
+AST *zzastnew();\r
+void zzsubchild();\r
+void zzsubroot();\r
+void zzpre_ast();\r
+void zzfree_ast();\r
+AST *zztmake();\r
+AST *zzdup_ast();\r
+void zztfree();\r
+void zzdouble_link();\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h
new file mode 100644 (file)
index 0000000..874e37a
--- /dev/null
@@ -0,0 +1,46 @@
+/* ANTLR attribute definition -- constant width text\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ZZCHARBUF_H\r
+#define ZZCHARBUF_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_string.h"\r
+\r
+#ifndef D_TextSize\r
+#define D_TextSize  30\r
+#endif\r
+\r
+typedef struct { char text[D_TextSize]; } Attrib;\r
+\r
+#define zzcr_attr(a,tok,t)  strncpy((a)->text, t, D_TextSize-1); \\r
+              (a)->text[D_TextSize-1] = '\0';\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c
new file mode 100644 (file)
index 0000000..930c5df
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef __STDC__\r
+#include "pccts_stdlib.h"\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#include "pccts_string.h"\r
+\r
+/* 133MR1 include stdio.h for fprintf in charptr.c */\r
+\r
+#include "pccts_stdio.h"\r
+\r
+/* 133MR1 include charptr.h for Attrib in charptr.c */\r
+\r
+#include "charptr.h"\r
+\r
+#ifdef __USE_PROTOS\r
+zzcr_attr(Attrib *a,int token,char *text)\r
+#else\r
+zzcr_attr(a,token,text)\r
+Attrib *a;\r
+int token;\r
+char *text;\r
+#endif\r
+{\r
+  *a = (char *) malloc(strlen(text)+1);      /* MR6 */\r
+  if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}\r
+  strcpy(*a, text);\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h
new file mode 100644 (file)
index 0000000..3e92b05
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+/*\r
+ * WARNING!!!!: charptr.h does NOT make copies and the\r
+ * memory is freed after the attribute scope exits.\r
+ */\r
+\r
+#ifndef ZZCHARPTR_H\r
+#define ZZCHARPTR_H\r
+\r
+typedef char *Attrib;\r
+#define zzdef0(a)    {*(a)=NULL;}\r
+/* MR8  Jens Tingleff (jensting@imaginet.fr)                                */\r
+/*          Set memory pointer to null after free()                         */\r
+#define zzd_attr(a)    {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; }\r
+\r
+#ifdef __STDC__\r
+extern zzcr_attr(Attrib *,int,char *);\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h
new file mode 100644 (file)
index 0000000..8aa50ad
--- /dev/null
@@ -0,0 +1 @@
+#include "pcctscfg.h"\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h
new file mode 100644 (file)
index 0000000..41881e9
--- /dev/null
@@ -0,0 +1,499 @@
+/* dlgauto.h automaton\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Will Cohen and Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ZZDEFAUTO_H\r
+#define ZZDEFAUTO_H\r
+\r
+/*  10-Apr-97 133MR1  Uses __USE_PROTOS show should #include pcctscfg.h */\r
+\r
+#include "pcctscfg.h"\r
+\r
+zzchar_t  *zzlextext;  /* text of most recently matched token */\r
+zzchar_t  *zzbegexpr;  /* beginning of last reg expr recogn. */\r
+zzchar_t  *zzendexpr;  /* beginning of last reg expr recogn. */\r
+int  zzbufsize = 0;  /* number of characters in zzlextext */          /* MR7 */\r
+int  zzbegcol = 0;  /* column that first character of token is in*/\r
+int  zzendcol = 0;  /* column that last character of token is in */\r
+int  zzline = 1;  /* line current token is on */\r
+int  zzreal_line=1;  /* line of 1st portion of token that is not skipped */\r
+int  zzchar;    /* character to determine next state */\r
+int  zzbufovf;  /* indicates that buffer too small for text */\r
+int  zzcharfull = 0;\r
+static zzchar_t  *zznextpos;/* points to next available position in zzlextext*/\r
+static int   zzclass;\r
+\r
+#ifdef __USE_PROTOS\r
+void  zzerrstd(const char *);\r
+void  (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */\r
+extern int  zzerr_in(void);\r
+static int  (*zzfunc_in)(void) = zzerr_in;  /* MR20 */\r
+#else\r
+void  zzerrstd();\r
+void  (*zzerr)()=zzerrstd;  /* pointer to error reporting function */\r
+extern int  zzerr_in();\r
+static int  (*zzfunc_in)() = zzerr_in;      /* MR20 */\r
+#endif\r
+\r
+static FILE  *zzstream_in=0;\r
+static zzchar_t  *zzstr_in=0;\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+int             zzauto = 0;\r
+#else\r
+static int     zzauto = 0;\r
+#endif\r
+static int  zzadd_erase;\r
+static char   zzebuf[70];\r
+\r
+#ifdef ZZCOL\r
+#define ZZINC (++zzendcol)\r
+#else\r
+#define ZZINC\r
+#endif\r
+\r
+\r
+#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}\r
+#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}\r
+#define ZZGETC_STR {       \\r
+  if (*zzstr_in){        \\r
+    zzchar = *zzstr_in;    \\r
+    ++zzstr_in;        \\r
+  }else{            \\r
+    zzchar = EOF;      \\r
+  }              \\r
+  zzclass = ZZSHIFT(zzchar);  \\r
+}\r
+\r
+#define ZZNEWSTATE  (newstate = dfa[state][zzclass])\r
+\r
+#ifndef ZZCOPY\r
+#define ZZCOPY  \\r
+  /* Truncate matching buffer to size (not an error) */  \\r
+  if (zznextpos < lastpos){        \\r
+    *(zznextpos++) = zzchar;      \\r
+  }else{              \\r
+    zzbufovf = 1;          \\r
+  }\r
+#endif\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdstream( FILE *f )\r
+#else\r
+zzrdstream( f )\r
+FILE *f;\r
+#endif\r
+{\r
+  /* make sure that it is really set to something, otherwise just\r
+     leave it be.\r
+  */\r
+  if (f){\r
+    /* make sure that there is always someplace to get input\r
+       before closing zzstream_in\r
+    */\r
+#if 0\r
+    if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+    zzline = 1;\r
+    zzstream_in = f;\r
+    zzfunc_in = NULL;\r
+    zzstr_in = 0;\r
+    zzcharfull = 0;\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdfunc( int (*f)(void) )\r
+#else\r
+zzrdfunc( f )\r
+int (*f)();\r
+#endif\r
+{\r
+  /* make sure that it is really set to something, otherwise just\r
+     leave it be.\r
+  */\r
+  if (f){\r
+    /* make sure that there is always someplace to get input\r
+       before closing zzstream_in\r
+    */\r
+#if 0\r
+    if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+    zzline = 1;\r
+    zzstream_in = NULL;\r
+    zzfunc_in = f;\r
+    zzstr_in = 0;\r
+    zzcharfull = 0;\r
+  }\r
+}\r
+\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdstr( zzchar_t *s )\r
+#else\r
+zzrdstr( s )\r
+zzchar_t *s;\r
+#endif\r
+{\r
+  /* make sure that it is really set to something, otherwise just\r
+     leave it be.\r
+  */\r
+  if (s){\r
+    /* make sure that there is always someplace to get input\r
+       before closing zzstream_in\r
+    */\r
+#if 0\r
+    if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+    zzline = 1;\r
+    zzstream_in = NULL;\r
+    zzfunc_in = 0;\r
+    zzstr_in = s;\r
+    zzcharfull = 0;\r
+  }\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void zzclose_stream(void)\r
+#else\r
+void zzclose_stream()\r
+#endif\r
+{\r
+#if 0\r
+  fclose( zzstream_in );\r
+  zzstream_in = NULL;\r
+  zzfunc_in = NULL;\r
+#endif\r
+}\r
+\r
+/* saves dlg state, but not what feeds dlg (such as file position) */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_dlg_state(struct zzdlg_state *state)\r
+#else\r
+zzsave_dlg_state(state)\r
+struct zzdlg_state *state;\r
+#endif\r
+{\r
+  state->stream = zzstream_in;\r
+  state->func_ptr = zzfunc_in;\r
+  state->str = zzstr_in;\r
+  state->auto_num = zzauto;\r
+  state->add_erase = zzadd_erase;\r
+  state->lookc = zzchar;\r
+  state->char_full = zzcharfull;\r
+  state->begcol = zzbegcol;\r
+  state->endcol = zzendcol;\r
+  state->line = zzline;\r
+  state->lextext = zzlextext;\r
+  state->begexpr = zzbegexpr;\r
+  state->endexpr = zzendexpr;\r
+  state->bufsize = zzbufsize;\r
+  state->bufovf = zzbufovf;\r
+  state->nextpos = zznextpos;\r
+  state->class_num = zzclass;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_dlg_state(struct zzdlg_state *state)\r
+#else\r
+zzrestore_dlg_state(state)\r
+struct zzdlg_state *state;\r
+#endif\r
+{\r
+  zzstream_in = state->stream;\r
+  zzfunc_in = state->func_ptr;\r
+  zzstr_in = state->str;\r
+  zzauto = state->auto_num;\r
+  zzadd_erase = state->add_erase;\r
+  zzchar = state->lookc;\r
+  zzcharfull = state->char_full;\r
+  zzbegcol = state->begcol;\r
+  zzendcol = state->endcol;\r
+  zzline = state->line;\r
+  zzlextext = state->lextext;\r
+  zzbegexpr = state->begexpr;\r
+  zzendexpr = state->endexpr;\r
+  zzbufsize = state->bufsize;\r
+  zzbufovf = state->bufovf;\r
+  zznextpos = state->nextpos;\r
+  zzclass = state->class_num;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmode( int m )\r
+#else\r
+zzmode( m )\r
+int m;\r
+#endif\r
+{\r
+  /* points to base of dfa table */\r
+  if (m<MAX_MODE){\r
+    zzauto = m;\r
+    /* have to redo class since using different compression */\r
+    zzclass = ZZSHIFT(zzchar);\r
+  }else{\r
+    sprintf(zzebuf,"Invalid automaton mode = %d ",m);\r
+    zzerr(zzebuf);\r
+  }\r
+}\r
+\r
+/* erase what is currently in the buffer, and get a new reg. expr */\r
+\r
+#ifdef __USE_PROTOS\r
+void zzskip(void)\r
+#else\r
+void zzskip()\r
+#endif\r
+{\r
+  zzadd_erase = 1;\r
+}\r
+\r
+/* don't erase what is in the zzlextext buffer, add on to it */\r
+#ifdef __USE_PROTOS\r
+void zzmore()\r
+#else\r
+void zzmore()\r
+#endif\r
+{\r
+  zzadd_erase = 2;\r
+}\r
+\r
+/* substitute c for the reg. expr last matched and is in the buffer */\r
+#ifdef __USE_PROTOS\r
+void\r
+zzreplchar(zzchar_t c)\r
+#else\r
+void\r
+zzreplchar(c)\r
+zzchar_t c;\r
+#endif\r
+{\r
+  /* can't allow overwriting null at end of string */\r
+  if (zzbegexpr < &zzlextext[zzbufsize-1]){\r
+    *zzbegexpr = c;\r
+    *(zzbegexpr+1) = '\0';\r
+  }\r
+  zzendexpr = zzbegexpr;\r
+  zznextpos = zzbegexpr + 1;\r
+}\r
+\r
+/* replace the string s for the reg. expr last matched and in the buffer */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzreplstr(register zzchar_t *s)\r
+#else\r
+zzreplstr(s)\r
+register zzchar_t *s;\r
+#endif\r
+{\r
+  register zzchar_t *l= &zzlextext[zzbufsize -1];\r
+\r
+  zznextpos = zzbegexpr;\r
+  if (s){\r
+     while ((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){\r
+      /* empty */\r
+    }\r
+    /* correct for NULL at end of string */\r
+    zznextpos--;\r
+  }\r
+  if ((zznextpos <= l) && (*(--s) == 0)){\r
+    zzbufovf = 0;\r
+  }else{\r
+    zzbufovf = 1;\r
+  }\r
+  *(zznextpos) = '\0';\r
+  zzendexpr = zznextpos - 1;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzgettok(void)\r
+#else\r
+void zzgettok()\r
+#endif\r
+{\r
+  register int state, newstate;\r
+  /* last space reserved for the null char */\r
+  register zzchar_t *lastpos;\r
+\r
+skip:\r
+  zzreal_line = zzline;\r
+  zzbufovf = 0;\r
+  lastpos = &zzlextext[zzbufsize-1];\r
+  zznextpos = zzlextext;\r
+  zzbegcol = zzendcol+1;\r
+more:\r
+  zzbegexpr = zznextpos;\r
+#ifdef ZZINTERACTIVE\r
+  /* interactive version of automaton */\r
+  /* if there is something in zzchar, process it */\r
+  state = newstate = dfa_base[zzauto];\r
+  if (zzcharfull){\r
+    ZZINC;\r
+    ZZCOPY;\r
+    ZZNEWSTATE;\r
+  }\r
+  if (zzstr_in)\r
+    while (zzalternatives[newstate]){\r
+      state = newstate;\r
+      ZZGETC_STR;\r
+      ZZINC;\r
+      ZZCOPY;\r
+      ZZNEWSTATE;\r
+    }\r
+  else if (zzstream_in)\r
+    while (zzalternatives[newstate]){\r
+      state = newstate;\r
+      ZZGETC_STREAM;\r
+      ZZINC;\r
+      ZZCOPY;\r
+      ZZNEWSTATE;\r
+    }\r
+  else if (zzfunc_in)\r
+    while (zzalternatives[newstate]){\r
+      state = newstate;\r
+      ZZGETC_FUNC;\r
+      ZZINC;\r
+      ZZCOPY;\r
+      ZZNEWSTATE;\r
+    }\r
+  /* figure out if last character really part of token */\r
+  if ((state != dfa_base[zzauto]) && (newstate == DfaStates)){\r
+    zzcharfull = 1;\r
+    --zznextpos;\r
+  }else{\r
+    zzcharfull = 0;\r
+    state = newstate;\r
+  }\r
+  *(zznextpos) = '\0';\r
+  /* Able to transition out of start state to some non err state?*/\r
+  if ( state == dfa_base[zzauto] ){\r
+    /* make sure doesn't get stuck */\r
+    zzadvance();\r
+  }\r
+#else\r
+  /* non-interactive version of automaton */\r
+  if (!zzcharfull)\r
+    zzadvance();\r
+  else\r
+    ZZINC;\r
+  state = dfa_base[zzauto];\r
+  if (zzstr_in)\r
+    while (ZZNEWSTATE != DfaStates){\r
+      state = newstate;\r
+      ZZCOPY;\r
+      ZZGETC_STR;\r
+      ZZINC;\r
+    }\r
+  else if (zzstream_in)\r
+    while (ZZNEWSTATE != DfaStates){\r
+      state = newstate;\r
+      ZZCOPY;\r
+      ZZGETC_STREAM;\r
+      ZZINC;\r
+    }\r
+  else if (zzfunc_in)\r
+    while (ZZNEWSTATE != DfaStates){\r
+      state = newstate;\r
+      ZZCOPY;\r
+      ZZGETC_FUNC;\r
+      ZZINC;\r
+    }\r
+  zzcharfull = 1;\r
+  if ( state == dfa_base[zzauto] ){\r
+    if (zznextpos < lastpos){\r
+      *(zznextpos++) = zzchar;\r
+    }else{\r
+      zzbufovf = 1;\r
+    }\r
+    *zznextpos = '\0';\r
+    /* make sure doesn't get stuck */\r
+    zzadvance();\r
+  }else{\r
+    *zznextpos = '\0';\r
+  }\r
+#endif\r
+#ifdef ZZCOL\r
+  zzendcol -= zzcharfull;\r
+#endif\r
+  zzendexpr = zznextpos -1;\r
+  zzadd_erase = 0;\r
+  (*actions[accepts[state]])();\r
+  switch (zzadd_erase) {\r
+    case 1: goto skip;\r
+    case 2: goto more;\r
+  }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzadvance(void)\r
+#else\r
+void zzadvance()\r
+#endif\r
+{\r
+  if (zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}\r
+  if (zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}\r
+  if (zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}\r
+  if (!(zzstream_in || zzfunc_in || zzstr_in)){\r
+    zzerr_in();\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerrstd(const char *s)\r
+#else\r
+zzerrstd(s)\r
+char *s;\r
+#endif\r
+{\r
+        zzLexErrCount++;                /* MR11 */\r
+        fprintf(stderr,\r
+                "%s near line %d (text was '%s')\n",\r
+                ((s == NULL) ? "Lexical error" : s),\r
+                zzline,zzlextext);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzerr_in(void)\r
+#else\r
+int zzerr_in()\r
+#endif\r
+{\r
+  fprintf(stderr,"No input stream, function, or string\n");\r
+  /* return eof to get out gracefully */\r
+  return EOF;\r
+}\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h
new file mode 100644 (file)
index 0000000..d45c627
--- /dev/null
@@ -0,0 +1,128 @@
+/* dlgdef.h\r
+ * Things in scanner produced by dlg that should be visible to the outside\r
+ * world\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ZZDLGDEF_H\r
+#define ZZDLGDEF_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifndef zzchar_t\r
+#ifdef ZZWCHAR_T\r
+#define zzchar_t wchar_t\r
+#else\r
+#define zzchar_t char\r
+#endif\r
+#endif\r
+\r
+struct zzdlg_state {\r
+  FILE *stream;\r
+#ifdef __USE_PROTOS\r
+  int (*func_ptr)(void);\r
+#else\r
+  int (*func_ptr)();\r
+#endif\r
+  zzchar_t *str;\r
+  int auto_num;\r
+  int add_erase;\r
+  int lookc;\r
+  int char_full;\r
+  int begcol, endcol;\r
+  int line;\r
+  zzchar_t *lextext, *begexpr, *endexpr;\r
+  int bufsize;\r
+  int bufovf;\r
+  zzchar_t *nextpos;\r
+  int  class_num;\r
+};\r
+\r
+extern zzchar_t  *zzlextext;    /* text of most recently matched token */\r
+extern zzchar_t  *zzbegexpr;  /* beginning of last reg expr recogn. */\r
+extern zzchar_t  *zzendexpr;  /* beginning of last reg expr recogn. */\r
+extern int  zzbufsize;  /* how long zzlextext is */\r
+extern int  zzbegcol;  /* column that first character of token is in*/\r
+extern int  zzendcol;  /* column that last character of token is in */\r
+extern int  zzline;    /* line current token is on */\r
+extern int  zzreal_line;    /* line of 1st portion of token that is not skipped */\r
+extern int  zzchar;    /* character to determine next state */\r
+extern int  zzbufovf;  /* indicates that buffer too small for text */\r
+#ifdef __USE_PROTOS\r
+extern void  (*zzerr)(const char *);/* pointer to error reporting function */\r
+#else\r
+extern void  (*zzerr)();\r
+#endif\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+extern int     zzauto;\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern void  zzadvance(void);\r
+extern void  zzskip(void);  /* erase zzlextext, look for antoher token */\r
+extern void  zzmore(void);  /* keep zzlextext, look for another token */\r
+extern void  zzmode(int k);  /* switch to automaton 'k' */\r
+extern void  zzrdstream(FILE *);/* what stream to read from */\r
+extern void  zzclose_stream(void);/* close the current input stream */\r
+extern void  zzrdfunc(int (*)(void));/* what function to get char from */\r
+extern void zzrdstr( zzchar_t * );\r
+extern void  zzgettok(void);  /* get next token */\r
+extern void  zzreplchar(zzchar_t c);/* replace last recognized reg. expr. with\r
+          a character */\r
+extern void  zzreplstr(zzchar_t *s);/* replace last recognized reg. expr. with\r
+          a string */\r
+extern void zzsave_dlg_state(struct zzdlg_state *);\r
+extern void zzrestore_dlg_state(struct zzdlg_state *);\r
+extern int zzerr_in(void);\r
+extern void  zzerrstd(const char *);\r
+extern void zzerraction(void);\r
+\r
+#else\r
+\r
+extern void  zzadvance();\r
+extern void  zzskip();  /* erase zzlextext, look for antoher token */\r
+extern void  zzmore();  /* keep zzlextext, look for another token */\r
+extern void  zzmode(/*k*/);  /* switch to automaton 'k' */\r
+extern void  zzrdstream();  /* what stream to read from */\r
+extern void  zzclose_stream();/* close the current input stream */\r
+extern void  zzrdfunc();  /* what function to get char from */\r
+extern void zzrdstr();\r
+extern void  zzgettok();  /* get next token */\r
+extern void  zzreplchar();  /* replace last recognized reg. expr. with\r
+          a character */\r
+extern void  zzreplstr();  /* replace last recognized reg. expr. with\r
+          a string */\r
+extern void zzsave_dlg_state();\r
+extern void zzrestore_dlg_state();\r
+extern int zzerr_in();\r
+extern void  zzerrstd();\r
+extern void zzerraction();\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h
new file mode 100644 (file)
index 0000000..c08dbb4
--- /dev/null
@@ -0,0 +1,1168 @@
+/*\r
+ * err.h\r
+ *\r
+ * Standard error handling mechanism\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ERR_H\r
+#define ERR_H\r
+\r
+#include "pcctscfg.h"\r
+#include <stdlib.h>\r
+#include <assert.h>\r
+\r
+/*                        */\r
+/*  7-Apr-97  133MR1                    */\r
+/*    Proper choice of STDC and cplusplus pre-processor symbols (?) */\r
+/*                        */\r
+#include "pccts_string.h"\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include "pccts_stdarg.h"\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#ifdef DUM\r
+/* Define usable bits per unsigned int word (used for set stuff) */\r
+#ifdef PC\r
+#define BSETWORDSIZE 16\r
+#define BSETLOGWORDSIZE  4\r
+#else\r
+#define  BSETWORDSIZE 32\r
+#define BSETLOGWORDSIZE 5\r
+#endif\r
+#endif\r
+\r
+#define  BSETWORDSIZE 8\r
+#define BSETLOGWORDSIZE 3    /* SetWordType is 8bits */\r
+\r
+#define  BSETMODWORD(x) ((x) & (BSETWORDSIZE-1))    /* x % BSETWORDSIZE */\r
+#define  BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE)    /* x / BSETWORDSIZE */\r
+\r
+/* This is not put into the global pccts_parser structure because it is\r
+ * hidden and does not need to be saved during a "save state" operation\r
+ */\r
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte */\r
+static SetWordType bitmask[] = {\r
+  0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
+  0x00000010, 0x00000020, 0x00000040, 0x00000080\r
+};\r
+\r
+#ifdef zzTRACE_RULES\r
+int  zzTraceOptionValueDefault=1;\r
+int  zzTraceOptionValue=1;\r
+int  zzTraceGuessOptionValue=1;\r
+char *zzTraceCurrentRuleName=NULL;\r
+int  zzTraceDepth=0;\r
+#endif\r
+\r
+int  zzGuessSeq=0;          /* MR10 */\r
+int  zzSyntaxErrCount=0;    /* MR11 */\r
+int  zzLexErrCount=0;       /* MR11 */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzresynch(SetWordType *wd,SetWordType mask)\r
+#else\r
+zzresynch(wd,mask)\r
+SetWordType *wd, mask;\r
+#endif\r
+{\r
+  static int consumed = 1;\r
+\r
+  /* if you enter here without having consumed a token from last resynch\r
+   * force a token consumption.\r
+   */\r
+  if ( !consumed ) {zzCONSUME; consumed=1; return;}   /* MR10 */\r
+\r
+  /* if current token is in resynch set, we've got what we wanted */\r
+  if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}\r
+  \r
+  /* scan until we find something in the resynch set */\r
+  while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}\r
+  consumed=1;\r
+}\r
+\r
+/*                                                                          */\r
+/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
+/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
+/*                                                                          */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzconsumeUntil(SetWordType *st)\r
+#else\r
+zzconsumeUntil(st)\r
+SetWordType *st;\r
+#endif\r
+{\r
+    int     tmp;                                                     /* MR7 */\r
+  while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) {       /* MR7 */\r
+                                                      zzCONSUME; }   /* MR7 */\r
+}\r
+\r
+/*                                                                          */\r
+/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
+/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
+/*                                                                          */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzconsumeUntilToken(int t)\r
+#else\r
+zzconsumeUntilToken(t)\r
+int t;\r
+#endif\r
+{\r
+    int     tmp;                                                     /* MR7 */\r
+  while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; }      /* MR7 */\r
+}\r
+\r
+/* input looks like:\r
+ *    zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)\r
+ * where the zzMiss stuff is set here to the token that did not match\r
+ * (and which set wasn't it a member of).\r
+ */\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+void zzFAIL(int k, ...)\r
+#else\r
+void zzFAIL(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+#ifdef LL_K\r
+  static char text[LL_K*ZZLEXBUFSIZE+1];\r
+  SetWordType *f[LL_K];\r
+#else\r
+  static char text[ZZLEXBUFSIZE+1];\r
+  SetWordType *f[1];\r
+#endif\r
+  SetWordType **miss_set;\r
+  char **miss_text;\r
+  int *bad_tok;\r
+  char **bad_text;\r
+  int *err_k;\r
+  int i;\r
+  va_list ap;\r
+#ifndef PCCTS_USE_STDARG      /* MR20 */\r
+  int k;\r
+#endif\r
+#ifdef PCCTS_USE_STDARG         /* MR20 */\r
+  va_start(ap, k);\r
+#else\r
+  va_start(ap);\r
+  k = va_arg(ap, int);  /* how many lookahead sets? */\r
+#endif\r
+    assert(k <= sizeof(f)/sizeof(f[0]));    /* MR20 G. Hobbelt */\r
+  text[0] = '\0';\r
+  for (i=1; i<=k; i++)  /* collect all lookahead sets */\r
+  {\r
+    f[i-1] = va_arg(ap, SetWordType *);\r
+  }\r
+  for (i=1; i<=k; i++)  /* look for offending token */\r
+  {\r
+    if ( i>1 ) strcat(text, " ");\r
+    strcat(text, LATEXT(i));\r
+    if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;\r
+  }\r
+  miss_set = va_arg(ap, SetWordType **);\r
+  miss_text = va_arg(ap, char **);\r
+  bad_tok = va_arg(ap, int *);\r
+  bad_text = va_arg(ap, char **);\r
+  err_k = va_arg(ap, int *);\r
+  if ( i>k )\r
+  {\r
+    /* bad; lookahead is permutation that cannot be matched,\r
+     * but, the ith token of lookahead is valid at the ith position\r
+     * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
+     */\r
+    *miss_set = NULL;\r
+    *miss_text = zzlextext;\r
+    *bad_tok = LA(1);\r
+    *bad_text = LATEXT(1);\r
+    *err_k = k;\r
+    return;\r
+  }\r
+/*  fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
+  *miss_set = f[i-1];\r
+  *miss_text = text;\r
+  *bad_tok = LA(i);\r
+  *bad_text = LATEXT(i);\r
+  if ( i==1 ) *err_k = 1;\r
+  else *err_k = k;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceGuessDone(zzantlr_state *state)\r
+#else\r
+void zzTraceGuessDone(state)\r
+  zzantlr_state     *state;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+\r
+  int   doIt=0;\r
+\r
+  if (zzTraceCurrentRuleName == NULL) return;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
+        state->traceCurrentRuleName,\r
+        LATEXT(1),\r
+        state->traceDepth);\r
+    if (state->guessing != 0) {\r
+      fprintf(stderr," (guess mode continues - an enclosing guess is still active)");\r
+    } else {\r
+      fprintf(stderr," (guess mode ends)");\r
+    };\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_antlr_state(zzantlr_state *buf)\r
+#else\r
+zzsave_antlr_state(buf)\r
+zzantlr_state *buf;\r
+#endif\r
+{\r
+#ifdef LL_K\r
+  int     i;\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+  buf->guess_start = zzguess_start;\r
+  buf->guessing = zzguessing;\r
+#endif\r
+  buf->asp = zzasp;\r
+#ifdef GENAST\r
+  buf->ast_sp = zzast_sp;\r
+#endif\r
+#ifdef ZZINF_LOOK\r
+  buf->inf_labase = zzinf_labase;\r
+  buf->inf_last = zzinf_last;\r
+\r
+/* MR6   Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6    Additional state needs to be saved/restored                       */\r
+\r
+    buf->inf_tokens = zzinf_tokens;                                  /* MR6 */\r
+  buf->inf_text = zzinf_text;                                      /* MR6 */\r
+  buf->inf_text_buffer = zzinf_text_buffer;                        /* MR6 */\r
+  buf->inf_line = zzinf_line;                                   /* MR6 */\r
+\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+  buf->dirty = zzdirty;\r
+#endif\r
+#ifdef LL_K\r
+  for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];\r
+  for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);\r
+  buf->lap = zzlap;\r
+  buf->labase = zzlabase;\r
+#else\r
+  buf->token = zztoken;\r
+  strcpy(buf->text, zzlextext);\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+\r
+    /* MR10 */\r
+\r
+    buf->traceOptionValue=zzTraceOptionValue;\r
+    buf->traceGuessOptionValue=zzTraceGuessOptionValue;\r
+    buf->traceCurrentRuleName=zzTraceCurrentRuleName;\r
+    buf->traceDepth=zzTraceDepth;\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_antlr_state(zzantlr_state *buf)\r
+#else\r
+zzrestore_antlr_state(buf)\r
+zzantlr_state *buf;\r
+#endif\r
+{\r
+\r
+#ifdef zzTRACE_RULES\r
+    int     prevTraceOptionValue;\r
+#endif\r
+\r
+#ifdef LL_K\r
+  int     i;\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+  zzguess_start = buf->guess_start;\r
+  zzguessing = buf->guessing;\r
+#endif\r
+  zzasp = buf->asp;\r
+#ifdef GENAST\r
+  zzast_sp = buf->ast_sp;\r
+#endif\r
+#ifdef ZZINF_LOOK\r
+  zzinf_labase = buf->inf_labase;\r
+  zzinf_last = buf->inf_last;\r
+\r
+/* MR6   Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6    Additional state needs to be saved/restored                       */\r
+\r
+  zzinf_tokens = buf->inf_tokens;                                  /* MR6 */\r
+  zzinf_text = buf->inf_text;                                      /* MR6 */\r
+  zzinf_text_buffer = buf->inf_text_buffer;                        /* MR6 */\r
+  zzinf_line = buf->inf_line;                                   /* MR6 */\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+  zzdirty = buf->dirty;\r
+#endif\r
+#ifdef LL_K\r
+  for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];\r
+  for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);\r
+  zzlap = buf->lap;\r
+  zzlabase = buf->labase;\r
+#else\r
+  zztoken = buf->token;\r
+  strcpy(zzlextext, buf->text);\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+\r
+    prevTraceOptionValue=zzTraceOptionValue;\r
+    zzTraceOptionValue=buf->traceOptionValue;\r
+    if ( (prevTraceOptionValue > 0) !=\r
+             (zzTraceOptionValue > 0)) {\r
+      if (zzTraceOptionValue > 0) {\r
+        fprintf(stderr,"trace enable restored in rule %s depth %d\n",\r
+                        zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (zzTraceOptionValue <= 0) {\r
+        fprintf(stderr,"trace disable restored in rule %s depth %d\n",\r
+                        zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+\r
+    zzTraceOptionValue=buf->traceOptionValue;            /* MR10 */\r
+    zzTraceGuessOptionValue=buf->traceGuessOptionValue;  /* MR10 */\r
+    zzTraceCurrentRuleName=buf->traceCurrentRuleName;    /* MR10 */\r
+    zzTraceDepth=buf->traceDepth;                        /* MR10 */\r
+    zzTraceGuessDone(buf);                               /* MR10 */\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzedecode(SetWordType *a)\r
+#else\r
+zzedecode(a)\r
+SetWordType *a;\r
+#endif\r
+{\r
+  register SetWordType *p = a;\r
+  register SetWordType *endp = &(p[zzSET_SIZE]);\r
+  register unsigned e = 0;\r
+\r
+  if ( zzset_deg(a)>1 ) fprintf(stderr, " {");\r
+  do {\r
+    register SetWordType t = *p;\r
+    register SetWordType *b = &(bitmask[0]);\r
+    do {\r
+      if ( t & *b ) fprintf(stderr, " %s", zztokens[e]);\r
+      e++;\r
+    } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+  } while (++p < endp);\r
+  if ( zzset_deg(a)>1 ) fprintf(stderr, " }");\r
+}\r
+\r
+#ifndef USER_ZZSYN\r
+/* standard error reporting function */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+  \r
+    zzSyntaxErrCount++;                             /* MR11 */\r
+  fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);\r
+  if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+  if ( k==1 ) fprintf(stderr, " missing");\r
+  else\r
+  {\r
+    fprintf(stderr, "; \"%s\" not", bad_text);\r
+    if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+  }\r
+  if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+  else fprintf(stderr, " %s", zztokens[etok]);\r
+  if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);\r
+  fprintf(stderr, "\n");\r
+}\r
+#endif\r
+\r
+/* is b an element of set p? */\r
+int\r
+#ifdef __USE_PROTOS\r
+zzset_el(unsigned b, SetWordType *p)\r
+#else\r
+zzset_el(b,p)\r
+unsigned b;\r
+SetWordType *p;\r
+#endif\r
+{\r
+  return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+zzset_deg(SetWordType *a)\r
+#else\r
+zzset_deg(a)\r
+SetWordType *a;\r
+#endif\r
+{\r
+  /* Fast compute degree of a set... the number\r
+     of elements present in the set.  Assumes\r
+     that all word bits are used in the set\r
+  */\r
+  register SetWordType *p = a;\r
+  register SetWordType *endp = &(a[zzSET_SIZE]);\r
+  register int degree = 0;\r
+\r
+  if ( a == NULL ) return 0;\r
+  while ( p < endp )\r
+  {\r
+    register SetWordType t = *p;\r
+    register SetWordType *b = &(bitmask[0]);\r
+    do {\r
+      if (t & *b) ++degree;\r
+    } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+    p++;\r
+  }\r
+\r
+  return(degree);\r
+}\r
+\r
+#ifdef DEMAND_LOOK\r
+\r
+#ifdef LL_K\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+    int *zzMissTok, int *zzBadTok,\r
+    SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{\r
+  if ( zzdirty==LL_K ) {\r
+    zzCONSUME;\r
+  }\r
+  if ( LA(1)!=_t ) {\r
+    *zzBadText = *zzMissText=LATEXT(1);  \r
+    *zzMissTok= _t; *zzBadTok=LA(1);\r
+    *zzMissSet=NULL;        \r
+    return 0;\r
+  }\r
+  zzMakeAttr            \r
+  zzdirty++;            \r
+  zzlabase++;            \r
+  return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+  if ( zzdirty==LL_K ) {\r
+    zzCONSUME;\r
+  }\r
+  if ( LA(1)!=_t ) {\r
+    return 0;\r
+  }\r
+  zzMakeAttr            \r
+  zzdirty++;            \r
+  zzlabase++;            \r
+  return 1;\r
+}\r
+\r
+#else\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+     int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{                \r
+  if ( zzdirty ) {zzCONSUME;}    \r
+  if ( LA(1)!=_t ) {\r
+    *zzBadText = *zzMissText=LATEXT(1);  \r
+    *zzMissTok= _t; *zzBadTok=LA(1);\r
+    *zzMissSet=NULL;        \r
+    return 0;\r
+  }                \r
+  zzdirty = 1;          \r
+  zzMakeAttr            \r
+  return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+  if ( zzdirty ) {zzCONSUME;}    \r
+  if ( LA(1)!=_t ) {\r
+    return 0;\r
+  }\r
+  zzdirty = 1;          \r
+  zzMakeAttr            \r
+  return 1;\r
+}\r
+\r
+#endif /*LL_K*/\r
+\r
+#else\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+    int *zzMissTok, int *zzBadTok,\r
+    SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{\r
+  if ( LA(1)!=_t ) {        \r
+    *zzBadText = *zzMissText=LATEXT(1);  \r
+    *zzMissTok= _t; *zzBadTok=LA(1);\r
+    *zzMissSet=NULL;        \r
+    return 0;\r
+  }\r
+  zzMakeAttr\r
+  return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+  if ( LA(1)!=_t ) return 0;\r
+  zzMakeAttr            \r
+  return 1;\r
+}\r
+\r
+#endif /*DEMAND_LOOK*/\r
+\r
+#ifdef ZZINF_LOOK\r
+void\r
+#ifdef __USE_PROTOS\r
+_inf_zzgettok(void)\r
+#else\r
+_inf_zzgettok()\r
+#endif\r
+{\r
+  if ( zzinf_labase >= zzinf_last )          \r
+    {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}  \r
+  else {                      \r
+    NLA = zzinf_tokens[zzinf_labase];\r
+    zzline = zzinf_line[zzinf_labase];  /* wrong in 1.21 */\r
+    strcpy(NLATEXT, zzinf_text[zzinf_labase]);    \r
+    zzinf_labase++;                 \r
+  }                        \r
+}\r
+#endif\r
+\r
+#ifdef ZZINF_LOOK\r
+/* allocate default size text,token and line arrays;\r
+ * then, read all of the input reallocing the arrays as needed.\r
+ * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)\r
+ * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzfill_inf_look(void)\r
+#else\r
+zzfill_inf_look()\r
+#endif\r
+{\r
+  int tok, line;\r
+  int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;\r
+  int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;\r
+  int zzinf_text_buffer_index = 0;\r
+  int zzinf_lap = 0;\r
+\r
+  /* allocate text/token buffers */\r
+  zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);\r
+  if ( zzinf_text_buffer == NULL )\r
+  {\r
+    fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",\r
+    zzinf_text_buffer_size);\r
+    exit(PCCTS_EXIT_FAILURE);                  \r
+  }\r
+  zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
+  if ( zzinf_tokens == NULL )\r
+  {\r
+    fprintf(stderr,  "cannot allocate token buffer (%d tokens)\n",\r
+        zzinf_token_buffer_size);\r
+    exit(PCCTS_EXIT_FAILURE);                  \r
+  }\r
+    zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
+    if ( zzinf_line == NULL )\r
+    {\r
+        fprintf(stderr, "cannot allocate line buffer (%d ints)\n",\r
+                zzinf_token_buffer_size);\r
+        exit(PCCTS_EXIT_FAILURE);\r
+  }\r
+\r
+  /* get tokens, copying text to text buffer */\r
+  zzinf_text_buffer_index = 0;\r
+  do {\r
+    zzgettok();\r
+    line = zzreal_line;\r
+    while ( zzinf_lap>=zzinf_token_buffer_size )\r
+    {\r
+      zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE;\r
+      zzinf_tokens = (int *) realloc(zzinf_tokens,\r
+                         zzinf_token_buffer_size*sizeof(int));\r
+      if ( zzinf_tokens == NULL )\r
+      {\r
+        fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n",\r
+            zzinf_token_buffer_size);\r
+        exit(PCCTS_EXIT_FAILURE);\r
+      }\r
+            zzinf_line = (int *) realloc(zzinf_line,\r
+                                         zzinf_token_buffer_size*sizeof(int));\r
+            if ( zzinf_line == NULL )\r
+            {\r
+                fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",\r
+                        zzinf_token_buffer_size);\r
+                exit(PCCTS_EXIT_FAILURE);\r
+      }\r
+\r
+    }\r
+    while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )\r
+    {\r
+      zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE;\r
+      zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,\r
+                         zzinf_text_buffer_size);\r
+      if ( zzinf_text_buffer == NULL )\r
+      {\r
+        fprintf(stderr,  "cannot allocate lookahead text buffer (%d bytes)\n",\r
+            zzinf_text_buffer_size);\r
+        exit(PCCTS_EXIT_FAILURE);\r
+      }\r
+    }\r
+    /* record token and text and line of input symbol */\r
+    tok = zzinf_tokens[zzinf_lap] = NLA;\r
+    strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);\r
+    zzinf_text_buffer_index += strlen(NLATEXT)+1;\r
+        zzinf_line[zzinf_lap] = line;\r
+    zzinf_lap++;\r
+  } while (tok!=zzEOF_TOKEN);\r
+  zzinf_labase = 0;\r
+  zzinf_last = zzinf_lap-1;\r
+\r
+  /* allocate ptrs to text of ith token */\r
+  zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));\r
+  if ( zzinf_text == NULL )\r
+  {\r
+    fprintf(stderr,  "cannot allocate lookahead text buffer (%d)\n",\r
+        zzinf_text_buffer_size);\r
+    exit(PCCTS_EXIT_FAILURE);                    \r
+  }                          \r
+  zzinf_text_buffer_index = 0;\r
+  zzinf_lap = 0;\r
+  /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */\r
+  while (zzinf_lap<=zzinf_last)\r
+  {\r
+      zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index];\r
+    zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1;\r
+  }\r
+}\r
+#endif\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,\r
+      int *zzMissTok, int *zzBadTok,\r
+      SetWordType **zzMissSet)\r
+#else\r
+_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+SetWordType *e;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+  if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+  if ( !zzset_el((unsigned)LA(1), e) ) {\r
+    *zzBadText = LATEXT(1); *zzMissText=NULL;\r
+    *zzMissTok= 0; *zzBadTok=LA(1);\r
+    *zzMissSet=e;\r
+    return 0;\r
+  }\r
+  zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  zzdirty++;\r
+    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#else\r
+  zzdirty = 1;\r
+#endif\r
+#endif\r
+  return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)\r
+#else\r
+_zzmatch_wdfltsig(tokenWanted, whatFollows)\r
+int tokenWanted;\r
+SetWordType *whatFollows;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  if ( zzdirty==LL_K ) {\r
+      zzCONSUME;\r
+  }\r
+#else\r
+  if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+\r
+  if ( LA(1)!=tokenWanted )\r
+  {\r
+        zzSyntaxErrCount++;     /* MR11 */\r
+    fprintf(stderr,\r
+        "line %d: syntax error at \"%s\" missing %s\n",\r
+        zzline,\r
+        (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
+        zztokens[tokenWanted]);\r
+    zzconsumeUntil( whatFollows );\r
+    return 0;\r
+  }\r
+  else {\r
+    zzMakeAttr            \r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+    zzdirty++;\r
+    zzlabase++;\r
+#else\r
+    zzdirty = 1;\r
+#endif\r
+#else\r
+/*    zzCONSUME;     consume if not demand lookahead */\r
+#endif\r
+    return 1;\r
+  }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
+           int tokenTypeOfSet,\r
+           SetWordType *whatFollows)\r
+#else\r
+_zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)\r
+SetWordType *tokensWanted;\r
+int tokenTypeOfSet;\r
+SetWordType *whatFollows;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+  if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+  if ( !zzset_el((unsigned)LA(1), tokensWanted) )\r
+  {\r
+        zzSyntaxErrCount++;     /* MR11 */\r
+    fprintf(stderr,\r
+        "line %d: syntax error at \"%s\" missing %s\n",\r
+        zzline,\r
+        (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
+        zztokens[tokenTypeOfSet]);\r
+    zzconsumeUntil( whatFollows );\r
+    return 0;\r
+  }\r
+  else {\r
+    zzMakeAttr\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+    zzdirty++;\r
+    zzlabase++;\r
+#else\r
+    zzdirty = 1;\r
+#endif\r
+#else\r
+/*    zzCONSUME;    consume if not demand lookahead */\r
+#endif\r
+    return 1;\r
+  }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch_wsig(SetWordType *e)\r
+#else\r
+_zzsetmatch_wsig(e)\r
+SetWordType *e;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+  if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+  if ( !zzset_el((unsigned)LA(1), e) ) return 0;\r
+  zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+  zzdirty++;\r
+    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#else\r
+  zzdirty = 1;\r
+#endif\r
+#endif\r
+  return 1;\r
+}\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+static int  zzmstk[ZZMAXSTK] = { -1 };\r
+static int  zzmdep = 0;\r
+static char zzmbuf[70];\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmpush( int m )\r
+#else\r
+zzmpush( m )\r
+int m;\r
+#endif\r
+{\r
+   if(zzmdep == ZZMAXSTK - 1) {\r
+     sprintf(zzmbuf, "Mode stack overflow ");\r
+     zzerr(zzmbuf);\r
+   } else {\r
+     zzmstk[zzmdep++] = zzauto;\r
+     zzmode(m);\r
+   }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmpop( void )\r
+#else\r
+zzmpop( )\r
+#endif\r
+{\r
+   if(zzmdep == 0)\r
+   {  sprintf(zzmbuf, "Mode stack underflow ");\r
+      zzerr(zzmbuf);\r
+   }\r
+   else\r
+   {  zzmdep--;\r
+      zzmode(zzmstk[zzmdep]);\r
+   }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_mode_stack( int modeStack[], int *modeLevel )\r
+#else\r
+zzsave_mode_stack( modeStack, modeLevel )\r
+int modeStack[];\r
+int *modeLevel;\r
+#endif\r
+{\r
+  int i;\r
+  memcpy(modeStack, zzmstk, sizeof(zzmstk));\r
+  *modeLevel = zzmdep;\r
+  zzmdep = 0;\r
+\r
+  return;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_mode_stack( int modeStack[], int *modeLevel )\r
+#else\r
+zzrestore_mode_stack( modeStack, modeLevel )\r
+int modeStack[];\r
+int *modeLevel;\r
+#endif\r
+{\r
+  int i;\r
+\r
+  memcpy(zzmstk, modeStack, sizeof(zzmstk));\r
+  zzmdep = *modeLevel;\r
+\r
+  return;\r
+}\r
+#endif /* USER_ZZMODE_STACK */\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceReset(void)\r
+#else\r
+void zzTraceReset()\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+  zzTraceOptionValue=zzTraceOptionValueDefault;\r
+  zzTraceGuessOptionValue=1;\r
+  zzTraceCurrentRuleName=NULL;\r
+  zzTraceDepth=0;\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceGuessFail(void)\r
+#else\r
+void zzTraceGuessFail()\r
+#endif\r
+{\r
+\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+\r
+  int   doIt=0;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess failed\n");\r
+  };\r
+#endif\r
+#endif\r
+}\r
+\r
+/* zzTraceOption:\r
+     zero value turns off trace\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceIn(char * rule)\r
+#else\r
+void zzTraceIn(rule)\r
+  char  *rule;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+\r
+  int           doIt=0;\r
+\r
+  zzTraceDepth++;\r
+  zzTraceCurrentRuleName=rule;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+#ifdef ZZCAN_GUESS\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+#endif\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"enter rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LA(1)==1 ? "@" : (char *) LATEXT(1),    /* MR19 */\r
+            zzTraceDepth);\r
+#ifdef ZZCAN_GUESS\r
+    if (zzguessing) fprintf(stderr," guessing");\r
+#endif\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+  return;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceOut(char * rule)\r
+#else\r
+void zzTraceOut(rule)\r
+  char  *rule;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+  int       doIt=0;\r
+\r
+  zzTraceDepth--;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+#ifdef ZZCAN_GUESS\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+#endif\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"exit rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */\r
+            zzTraceDepth+1);\r
+#ifdef ZZCAN_GUESS\r
+    if (zzguessing) fprintf(stderr," guessing");\r
+#endif\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzTraceOption(int delta)\r
+#else\r
+int zzTraceOption(delta)\r
+  int   delta;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+    int     prevValue=zzTraceOptionValue;\r
+\r
+    zzTraceOptionValue=zzTraceOptionValue+delta;\r
+\r
+    if (zzTraceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && zzTraceOptionValue > 0) {\r
+        fprintf(stderr,"trace enabled in rule %s depth %d\n",\r
+                                            zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (prevValue > 0 && zzTraceOptionValue <= 0) {\r
+        fprintf(stderr,"trace disabled in rule %s depth %d\n",\r
+                                            zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+    return  prevValue;\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzTraceGuessOption(int delta)\r
+#else\r
+int zzTraceGuessOption(delta)\r
+  int   delta;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+    int     prevValue=zzTraceGuessOptionValue;\r
+\r
+    zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta;\r
+\r
+    if (zzTraceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && zzTraceGuessOptionValue > 0) {\r
+        fprintf(stderr,"guess trace enabled in rule %s depth %d\n",\r
+                                                zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (prevValue > 0 && zzTraceGuessOptionValue <= 0) {\r
+        fprintf(stderr,"guess trace disabled in rule %s depth %d\n",\r
+                                                zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+    return prevValue;\r
+#else\r
+    return 0;\r
+#endif\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
+\r
+#endif /* ERR_H */\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h
new file mode 100644 (file)
index 0000000..d6d51a4
--- /dev/null
@@ -0,0 +1,37 @@
+/* ANTLR attribute definition -- long integers\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#ifndef ZZINT_H\r
+#define ZZINT_H\r
+\r
+typedef long Attrib;\r
+\r
+#define zzcr_attr(a,tok,t)  *(a) = atol(t);\r
+\r
+#endif\r
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 (file)
index 0000000..ff0dfb5
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ASSERT_H__\r
+#define __PCCTS_ASSERT_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cassert>\r
+#else\r
+#include <assert.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..8d86018
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h
new file mode 100644 (file)
index 0000000..972b32c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_IOSTREAM_H__\r
+#define __PCCTS_IOSTREAM_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <iostream>\r
+#else\r
+#include <iostream.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..e25cb8c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ISTREAM_H__\r
+#define __PCCTS_ISTREAM_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <istream>\r
+#else\r
+#include <istream.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..b237a09
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h
new file mode 100644 (file)
index 0000000..9ea185c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_SETJMP_H__\r
+#define __PCCTS_SETJMP_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <csetjmp>\r
+#else\r
+#include <setjmp.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..e957430
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDARG_H__\r
+#define __PCCTS_STDARG_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdarg>\r
+#else\r
+#include <stdarg.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..ac34d10
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDIO_H__\r
+#define __PCCTS_STDIO_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdio>\r
+#else\r
+#include <stdio.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..f0b344e
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDLIB_H__\r
+#define __PCCTS_STDLIB_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdlib>\r
+#else\r
+#include <stdlib.h>\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..458a08a
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STRING_H__\r
+#define __PCCTS_STRING_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstring>\r
+#else\r
+#include <string.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h
new file mode 100644 (file)
index 0000000..9255d1e
--- /dev/null
@@ -0,0 +1,350 @@
+#ifndef PCCTS_CONFIG_H\r
+#define PCCTS_CONFIG_H\r
+/*\r
+ * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER)\r
+ *\r
+ * This is a simple configuration file that doesn't have config stuff\r
+ * in it, but it's a start.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * Used by PCCTS 1.33 (SORCERER 1.00B11 and up)\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+/* This file knows about the following ``environments''\r
+  UNIX    (default)\r
+  DOS     (use #define PC)\r
+  MAC     (use #define MPW; has a few things for THINK C, Metrowerks)\r
+    MS/C++  (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER)\r
+\r
+ */\r
+\r
+/* should test __STDC__ for 1, but some compilers don't set value, just def */\r
+\r
+#ifndef __USE_PROTOS\r
+#ifdef __STDC__\r
+#define __USE_PROTOS\r
+#endif\r
+#ifdef __cplusplus\r
+#define __USE_PROTOS\r
+#endif\r
+#endif\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
+#else\r
+#define PCCTS_NAMESPACE_STD\r
+#endif\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+/* largest file name size */\r
+\r
+#ifdef _MAX_PATH\r
+#define MaxFileName    _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */\r
+#else\r
+#define MaxFileName    300\r
+#endif\r
+\r
+/*\r
+*  Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32).\r
+*  The macros tested here are defined by Watcom, Microsoft, Borland,\r
+*  and djgpp, respectively, when they are used as 32-bit compilers.\r
+*  Users of these compilers *must* be sure to define PC in their\r
+*  makefiles for this to work correctly.\r
+*/\r
+#ifdef PC\r
+# if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \\r
+   defined(__GNUC__) || defined(__GNUG__))\r
+#     ifndef PC32\r
+#        define PC32\r
+#     endif\r
+#  endif\r
+#endif\r
+\r
+/* MR1  10-Apr-97  Default for PC is short file names                  */\r
+/* MR1       Default for non-PC is long file names                    */\r
+/* MR1       Can override via command line option LONGFILENAMES           */\r
+\r
+#ifndef LONGFILENAMES\r
+#ifndef PC\r
+#define LONGFILENAMES\r
+#endif\r
+#endif\r
+\r
+#ifndef LONGFILENAMES\r
+#define ATOKEN_H      "AToken.h"\r
+#define ATOKPTR_H      "ATokPtr.h"\r
+#define ATOKPTR_C      "ATokPtr.cpp"\r
+#define ATOKENBUFFER_H    "ATokBuf.h"\r
+#define ATOKENBUFFER_C      "ATokBuf.cpp"\r
+#define ATOKENSTREAM_H    "ATokStr.h"\r
+#define APARSER_H      "AParser.h"\r
+#define APARSER_C           "AParser.cpp"\r
+#define ASTBASE_H      "ASTBase.h"\r
+#define ASTBASE_C           "ASTBase.cpp"\r
+#define PCCTSAST_C          "PCCTSAST.cpp"\r
+#define LIST_C              "List.cpp"\r
+#define DLEXERBASE_H    "DLexBase.h"\r
+#define DLEXERBASE_C        "DLexBase.cpp"\r
+#define DLEXER_C            "DLexer.cpp"\r
+#define STREESUPPORT_C    "STreeSup.C"\r
+#else\r
+#define ATOKEN_H      "AToken.h"\r
+#define ATOKPTR_H      "ATokPtr.h"\r
+#define ATOKPTR_C      "ATokPtr.cpp"\r
+#define ATOKENBUFFER_H    "ATokenBuffer.h"\r
+#define ATOKENBUFFER_C    "ATokenBuffer.cpp"\r
+#define ATOKENSTREAM_H    "ATokenStream.h"\r
+#define APARSER_H      "AParser.h"\r
+#define APARSER_C      "AParser.cpp"\r
+#define ASTBASE_H      "ASTBase.h"\r
+#define ASTBASE_C        "ASTBase.cpp"\r
+#define PCCTSAST_C      "PCCTSAST.cpp"\r
+#define LIST_C        "List.cpp"\r
+#define DLEXERBASE_H    "DLexerBase.h"\r
+#define DLEXERBASE_C    "DLexerBase.cpp"\r
+#define DLEXER_C      "DLexer.cpp"\r
+#define STREESUPPORT_C    "STreeSupport.cpp"\r
+#endif\r
+\r
+/* SORCERER Stuff */\r
+\r
+/* MR8 6-Aug-97     Change from ifdef PC to ifndef LONGFILENAMES            */\r
+\r
+#ifndef LONGFILENAMES\r
+#define STPARSER_H      "STreePar.h"\r
+#define STPARSER_C      "STreePar.C"\r
+#else\r
+#define STPARSER_H      "STreeParser.h"\r
+#define STPARSER_C      "STreeParser.cpp"\r
+#endif\r
+\r
+#ifdef MPW\r
+#define CPP_FILE_SUFFIX    ".cp"\r
+#define CPP_FILE_SUFFIX_NO_DOT  "cp"\r
+#define OBJ_FILE_SUFFIX    ".o"\r
+#else\r
+#ifdef PC\r
+#define CPP_FILE_SUFFIX    ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT  "cpp"\r
+#define OBJ_FILE_SUFFIX    ".obj"\r
+#else\r
+#ifdef __VMS\r
+#define CPP_FILE_SUFFIX    ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT  "cpp"\r
+#define OBJ_FILE_SUFFIX    ".obj"\r
+#else\r
+#define CPP_FILE_SUFFIX    ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT  "cpp"\r
+#define OBJ_FILE_SUFFIX    ".o"\r
+#endif\r
+#endif\r
+#endif\r
+\r
+/* User may redefine how line information looks */     /* make it #line MR7 */\r
+/* MR21 Use #ifndef */\r
+\r
+#ifndef LineInfoFormatStr\r
+#define LineInfoFormatStr "#line %d \"%s\"\n"\r
+#endif\r
+\r
+#ifdef MPW                      /* Macintosh Programmer's Workshop */\r
+#define ErrHdr "File \"%s\"; Line %d #"\r
+#else\r
+#ifdef _MSC_VER                 /* MR14 Microsoft Visual C++ environment */\r
+#define ErrHdr "%s(%d) :"\r
+#else\r
+#define ErrHdr "%s, line %d:"   /* default */\r
+#endif\r
+#endif\r
+\r
+/* must assume old K&R cpp here, can't use #if defined(..)... */\r
+\r
+#ifdef MPW\r
+#define TopDirectory  ":"\r
+#define DirectorySymbol  ":"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\":\")"\r
+#else\r
+#ifdef PC\r
+#define TopDirectory  "."\r
+#define DirectorySymbol  "\\"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
+#else\r
+#ifdef __VMS\r
+#define TopDirectory  "[000000]"\r
+#define DirectorySymbol       "]"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")"\r
+#else\r
+#define TopDirectory  "."\r
+#define DirectorySymbol  "/"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
+#endif\r
+#endif\r
+#endif\r
+\r
+#ifdef MPW\r
+\r
+/* Make sure we have prototypes for all functions under MPW */\r
+\r
+#include "pccts_string.h"\r
+#include "pccts_stdlib.h"\r
+\r
+/* MR6 2-Jun-97  Fixes false dependency caused by VC++ #include scanner  */\r
+/* MR6       Reported by Brad Schick (schick@interaccess.com)  */\r
+#define  MPW_CursorCtl_Header <CursorCtl.h>\r
+#include MPW_CursorCtl_Header\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype);\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+/* File creators for various popular development environments */\r
+\r
+#define MAC_FILE_CREATOR 'MPS '   /* MPW Text files */\r
+#if 0\r
+#define MAC_FILE_CREATOR 'KAHL'   /* THINK C/Symantec C++ Text files */\r
+#endif\r
+#if 0\r
+#define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
+#endif\r
+\r
+#endif\r
+\r
+#ifdef MPW\r
+#define DAWDLE  SpinCursor(1)\r
+#else\r
+#define DAWDLE\r
+#endif\r
+\r
+#ifdef MPW\r
+#define SPECIAL_INITS\r
+#define SPECIAL_FOPEN\r
+#endif\r
+\r
+#ifdef MPW\r
+#ifdef __cplusplus\r
+inline\r
+#else\r
+static\r
+#endif\r
+void special_inits()\r
+{\r
+  InitCursorCtl((acurHandle) 0);\r
+}\r
+#endif\r
+\r
+#ifdef MPW\r
+#ifdef __cplusplus\r
+inline\r
+#else\r
+static\r
+#endif\r
+void special_fopen_actions(char * s)\r
+{\r
+  fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');\r
+}\r
+#endif\r
+\r
+/* Define usable bits for set.c stuff */\r
+#define BytesPerWord  sizeof(unsigned)\r
+#define  WORDSIZE    (sizeof(unsigned)*8)\r
+#define LogWordSize     (WORDSIZE==16?4:5)\r
+\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#endif\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#endif\r
+\r
+#if defined(VAXC) || defined(__VMS)\r
+#include <ssdef.h>\r
+#define PCCTS_EXIT_SUCCESS 1\r
+#define PCCTS_EXIT_FAILURE SS$_ABORT\r
+#define zzDIE    return SS$_ABORT;\r
+#define zzDONE  return 1;\r
+\r
+#else /* !VAXC and !__VMS */\r
+\r
+#define PCCTS_EXIT_SUCCESS 0\r
+#define PCCTS_EXIT_FAILURE 1\r
+#define zzDIE    return 1;\r
+#define zzDONE  return 0;\r
+\r
+#endif\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+# ifndef ZZSTACK_MAX_MODE\r
+#  define  ZZSTACK_MAX_MODE 32\r
+# endif\r
+# define  ZZMAXSTK (ZZSTACK_MAX_MODE * 2)\r
+#endif\r
+\r
+#ifndef DllExportPCCTS\r
+#define DllExportPCCTS\r
+#endif\r
+\r
+#ifdef PC\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef PC32\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef __VMS\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#ifdef __STDC__\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp
new file mode 100644 (file)
index 0000000..26b88c3
--- /dev/null
@@ -0,0 +1,118 @@
+# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 5.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Static Library" 0x0104\r
+\r
+CFG=pcctslib - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "pcctslib50.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "pcctslib50.mak" CFG="pcctslib - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")\r
+!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+\r
+!IF  "$(CFG)" == "pcctslib - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c\r
+# SUBTRACT CPP /YX\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo /out:"pccts_release.lib"\r
+# Begin Special Build Tool\r
+SOURCE=$(InputPath)\r
+PostBuild_Desc=Copy to ..\lib\r
+PostBuild_Cmds=mkdir ..\lib    copy pccts_release.lib ..\lib\pccts_release.lib\r
+# End Special Build Tool\r
+\r
+!ELSEIF  "$(CFG)" == "pcctslib - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c\r
+# SUBTRACT CPP /YX\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo /out:"pccts_debug.lib"\r
+# Begin Special Build Tool\r
+SOURCE=$(InputPath)\r
+PostBuild_Desc=Copy to ..\lib\r
+PostBuild_Cmds=mkdir ..\lib    copy pccts_debug.lib ..\lib\pccts_debug.lib\r
+# End Special Build Tool\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "pcctslib - Win32 Release"\r
+# Name "pcctslib - Win32 Debug"\r
+# Begin Source File\r
+\r
+SOURCE=.\AParser.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ASTBase.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ATokenBuffer.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\BufFileInput.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\DLexerBase.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\PCCTSAST.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\SList.cpp\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw
new file mode 100644 (file)
index 0000000..995e5bf
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00\r
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
+\r
+###############################################################################\r
+\r
+Project: "pcctslib"=.\pcctslib50.dsp - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Global:\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<3>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp
new file mode 100644 (file)
index 0000000..d3e3b0c
--- /dev/null
@@ -0,0 +1,124 @@
+# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Static Library" 0x0104\r
+\r
+CFG=pcctslib - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "pcctslib60.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "pcctslib60.mak" CFG="pcctslib - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library")\r
+!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "pcctslib - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c\r
+# SUBTRACT CPP /YX\r
+# ADD BASE RSC /l 0x409\r
+# ADD RSC /l 0x409\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo /out:"pccts_release.lib"\r
+# Begin Special Build Tool\r
+SOURCE="$(InputPath)"\r
+PostBuild_Desc=Copy to ..\lib\r
+PostBuild_Cmds=mkdir ..\lib    copy pccts_release.lib ..\lib\pccts_release.lib\r
+# End Special Build Tool\r
+\r
+!ELSEIF  "$(CFG)" == "pcctslib - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c\r
+# SUBTRACT CPP /YX\r
+# ADD BASE RSC /l 0x409\r
+# ADD RSC /l 0x409\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo /out:"pccts_debug.lib"\r
+# Begin Special Build Tool\r
+SOURCE="$(InputPath)"\r
+PostBuild_Desc=Copy to ..\lib\r
+PostBuild_Cmds=mkdir ..\lib    copy pccts_debug.lib ..\lib\pccts_debug.lib\r
+# End Special Build Tool\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "pcctslib - Win32 Release"\r
+# Name "pcctslib - Win32 Debug"\r
+# Begin Source File\r
+\r
+SOURCE=.\AParser.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ASTBase.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ATokenBuffer.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\BufFileInput.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\DLexerBase.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\PCCTSAST.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\SList.cpp\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw
new file mode 100644 (file)
index 0000000..3400c44
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00\r
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
+\r
+###############################################################################\r
+\r
+Project: "pcctslib"=.\pcctslib60.dsp - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Global:\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<3>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat
new file mode 100644 (file)
index 0000000..8784aee
--- /dev/null
@@ -0,0 +1,11 @@
+ren aparser.c aparser.cpp\r
+ren astbase.c astbase.cpp\r
+ren atokenbu.c atokbuf.cpp\r
+ren atokenbu.h atokbuf.h\r
+ren atokenst.h atokstr.h\r
+ren dlexerba.c dlexbase.cpp\r
+ren dlexerba.h dlexbase.h\r
+ren dlexer.c dlexer.cpp\r
+ren list.c list.cpp\r
+ren pblackbo.h pblckbox.h\r
+ren pcctsast.c pcctsast.cpp\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp
new file mode 100644 (file)
index 0000000..d6b8bf6
--- /dev/null
@@ -0,0 +1,105 @@
+/*\r
+ * SList.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * PCCTS 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1992-1998\r
+ */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "SList.h"\r
+\r
+/* Iterate over a list of elements; returns ptr to a new element\r
+ * in list upon every call and NULL when no more are left.\r
+ * Very useful like this:\r
+ *\r
+ *             cursor = mylist;\r
+ *             while ( (p=mylist->iterate(&cursor)) ) {\r
+ *                     // place with element p\r
+ *             }\r
+ *\r
+ * The cursor must be initialized to point to the list to iterate over.\r
+ */\r
+void *SList::\r
+iterate(SListNode **cursor)\r
+{\r
+       void *e;\r
+\r
+       if ( cursor == NULL || *cursor==NULL ) return NULL;\r
+       if ( head == *cursor ) { *cursor = (*cursor)->next(); }\r
+       e = (*cursor)->elem();\r
+       (*cursor) = (*cursor)->next();\r
+       return e;\r
+}\r
+\r
+/* add an element to end of list. */\r
+void SList::\r
+add(void *e)\r
+{\r
+       SListNode *p, *tail=NULL;\r
+       require(e!=NULL, "slist_add: attempting to add NULL list element");\r
+\r
+       p = new SListNode;\r
+       require(p!=NULL, "add: cannot alloc new list node");\r
+       p->setElem(e);\r
+       if ( head == NULL )\r
+       {\r
+               head = tail = p;\r
+       }\r
+       else                                                            /* find end of list */\r
+       {\r
+               tail->setNext(p);\r
+               tail = p;\r
+       }\r
+}\r
+\r
+void SList::\r
+lfree()\r
+{\r
+       SListNode *p,*q;\r
+\r
+       if ( head==NULL ) return;       /* empty list */\r
+       for (p = head; p!=NULL; p=q)\r
+       {\r
+               q = p->next();\r
+               free(p);\r
+       }\r
+}\r
+\r
+PCCTS_AST *SList::\r
+to_ast(SList list)\r
+{\r
+       PCCTS_AST *t=NULL, *last=NULL;\r
+       SListNode *p;\r
+\r
+       for (p = head; p!=NULL; p=p->next())\r
+       {\r
+               PCCTS_AST *u = (PCCTS_AST *)p->elem();\r
+               if ( last==NULL ) last = t = u;\r
+               else { last->setRight(u); last = u; }\r
+       }\r
+       return t;\r
+}\r
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 (file)
index 0000000..8d86018
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib
new file mode 100644 (file)
index 0000000..b237a09
Binary files /dev/null and b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib differ
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h
new file mode 100644 (file)
index 0000000..1004147
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef SASTBase_h\r
+#define SASTBase_h\r
+\r
+#include "PCCTSAST.h"\r
+\r
+typedef PCCTS_AST SORASTBase;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h
new file mode 100644 (file)
index 0000000..79f9018
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef SCommonAST_h\r
+#define SCommonAST_h\r
+\r
+#include <stdio.h>\r
+#include "PCCTSAST.h"\r
+#include "SASTBase.h"\r
+\r
+/* If you use SORCERER alone, you can subclass this to get a nice tree def */\r
+\r
+class SORCommonAST : public SORASTBase {\r
+protected:\r
+  SORCommonAST *_right, *_down;\r
+  int _type;\r
+\r
+public:\r
+  SORCommonAST() { _right = _down = NULL; }\r
+  PCCTS_AST *right()  { return _right; }  // define the SORCERER interface\r
+  PCCTS_AST *down()  { return _down; }\r
+  int type()     { return _type; }\r
+  void setRight(PCCTS_AST *t) { _right = (SORCommonAST *)t; }\r
+  void setDown(PCCTS_AST *t)  { _down = (SORCommonAST *)t; }\r
+  void setType(int t)     { _type = t; }\r
+  virtual PCCTS_AST *shallowCopy() {return NULL;}\r
+};\r
+\r
+#endif\r
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 (file)
index 0000000..558f6a5
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef STreeParser_h\r
+#define STreeParser_h\r
+\r
+/*\r
+ * STreeParser.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+/* The programmer should derive a class from SORASTBase; SORASTBase defines\r
+ * the minimum public interface that a tree node must follow for SORCERER to\r
+ * be able to walk the trees.\r
+ */\r
+\r
+/* The @-vars are added by the subclass created by SORCERER; the constructor\r
+ * is used to init the @-vars.\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <setjmp.h>\r
+#include <stdlib.h>\r
+#include "SASTBase.h"\r
+\r
+#define _DOWN        _t=(SORASTBase *)_t->down()\r
+#define _RIGHT        _t=(SORASTBase *)_t->right()\r
+\r
+#define _SAVE        SORASTBase *_save=_t\r
+#define _RESTORE      _t = _save\r
+#define _GUESS_BLOCK    STreeParser _st; int _gv; SORASTBase *_savet=NULL;\r
+#define _GUESS        {save_state(&_st); \\r
+              _savet = _t; \\r
+              guessing = 1; \\r
+              _gv = setjmp(startofguess.state);}\r
+#define _GUESS_FAIL      longjmp(startofguess.state, 1)\r
+#define _GUESS_DONE      {restore_state(&_st); _t = _savet;}\r
+#define _MATCH(tok)      MATCH(_t,tok)\r
+#define _MATCHRANGE(t1,t2)  MATCHRANGE(_t,t1,t2)\r
+#define _WILDCARD      WILDCARD(_t)\r
+\r
+#define ast_return(t)    *_result = (SORASTBase *)t;\r
+\r
+#define STreeTry(r,p,t)     \\r
+      (p)->try_result = NULL;          \\r
+            (p)->sjrv = setjmp((p)->startofguess);  \\r
+            if ( !(p)->sjrv ) {            \\r
+                rule(p,t,&try_result);        \\r
+                (p)->try_ok = 1;          \\r
+      }                    \\r
+            else {                  \\r
+                (p)->try_ok = 0;          \\r
+      }                    \\r
+            if ( (p)->try_ok )\r
+\r
+\r
+/* Used only during TRANSFORM mode */\r
+#define  TREE_CONSTR_PTRS  SORASTBase *_r=NULL,*_s=NULL,*_e=NULL\r
+\r
+typedef struct _Sjmp_buf {\r
+      jmp_buf state;\r
+    } Sjmp_buf;\r
+\r
+class STreeParser {\r
+protected:\r
+  int try_ok, sjrv;    /* used by STreeTry macro */\r
+  SORASTBase *try_result;  /* tree coming back from try */\r
+  int guessing;\r
+  Sjmp_buf startofguess;\r
+//  SORASTBase *t;\r
+\r
+  void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
+  void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
+  virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);\r
+  virtual void missing_wildcard();\r
+  virtual void mismatched_token(int looking_for, SORASTBase *found);\r
+  virtual void no_viable_alt(char *rulename, SORASTBase *root);\r
+  virtual void MATCH(SORASTBase *_t, int tok);\r
+  virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);\r
+  virtual void WILDCARD(SORASTBase *_t);\r
+\r
+public:\r
+  STreeParser() { guessing = 0; }\r
+  virtual void panic(char *err);\r
+  void save_state(STreeParser *);\r
+  void restore_state(STreeParser *);\r
+};\r
+\r
+#endif\r
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 (file)
index 0000000..9c7fd69
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef astlib_h\r
+#define astlib_h\r
+\r
+/*\r
+ * astlib.h -- C ast_* library header\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+#include <setjmp.h>\r
+#include "sorcerer.h"\r
+#include "sorlist.h"\r
+\r
+#define MaxTreeStackDepth  400\r
+\r
+#ifdef __USE_PROTOS\r
+extern SORAST *ast_make(SORAST *rt, ...);\r
+extern SORAST *ast_find_all(SORAST *t, SORAST *u, SORAST **cursor);\r
+extern int ast_match(SORAST *t, SORAST *u);\r
+extern void ast_insert_after(SORAST *a, SORAST *b);\r
+extern void ast_append(SORAST *a, SORAST *b);\r
+extern SORAST *ast_tail(SORAST *a);\r
+extern SORAST *ast_bottom(SORAST *a);\r
+extern SORAST *ast_cut_between(SORAST *a, SORAST *b);\r
+extern SList *ast_to_slist(SORAST *t);\r
+extern SORAST *slist_to_ast(SList *list);\r
+extern void ast_free(SORAST *t);\r
+extern int ast_scan(char *template, SORAST *tree, ...);\r
+extern int ast_nsiblings(SORAST *t);\r
+extern SORAST *ast_sibling_index(SORAST *t, int i);\r
+extern int ast_match_partial(SORAST *t, SORAST *u);\r
+#else\r
+extern SORAST *ast_make();\r
+extern SORAST *ast_find_all();\r
+extern int ast_match();\r
+extern void ast_insert_after();\r
+extern void ast_append();\r
+extern SORAST *ast_tail();\r
+extern SORAST *ast_bottom();\r
+extern SORAST *ast_cut_between();\r
+extern SList *ast_to_slist();\r
+extern SORAST *slist_to_ast();\r
+extern void ast_free();\r
+extern int ast_scan();\r
+extern int ast_nsiblings();\r
+extern SORAST *ast_sibling_index();\r
+extern int ast_match_partial();\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..a8e14bb
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef SINTSTACK_H\r
+#define SINTSTACK_H\r
+\r
+/*\r
+ * SIntStack.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+#include "sorcerer.h"\r
+\r
+typedef struct _istack {\r
+    int *data;\r
+    int sp;\r
+    int  size;\r
+  } SIntStack;\r
+\r
+#ifdef __USE_PROTOS\r
+extern SIntStack *sint_newstack(int size);\r
+extern void sint_freestack(SIntStack *st);\r
+extern void sint_push(SIntStack *st, int i);\r
+extern int sint_pop(SIntStack *st);\r
+extern int sint_stacksize(SIntStack *st);\r
+extern void sint_stackreset(SIntStack *st);\r
+extern int sint_stackempty(SIntStack *st);\r
+extern int sint_top(SIntStack *st);\r
+#else\r
+extern SIntStack *sint_newstack();\r
+extern void sint_freestack();\r
+extern void sint_push();\r
+extern int sint_pop();\r
+extern int sint_stacksize();\r
+extern void sint_stackreset();\r
+extern int sint_stackempty();\r
+extern int sint_top();\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..29f7702
--- /dev/null
@@ -0,0 +1,172 @@
+#ifndef sorcerer_h\r
+#define sorcerer_h\r
+\r
+/*\r
+ * sorcerer.h -- header for all sorcerer files\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef __USE_PROTOS\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+\r
+#include <setjmp.h>\r
+\r
+/* SUPERCLASS SORAST (your tree must look at minimum like this)\r
+typedef struct _node {\r
+            struct _node *right, *down;\r
+            int token;\r
+      -- user-defined stuff goes here\r
+        } SORAST;\r
+*/\r
+\r
+/* Can be used sort of like inheritance to get the desired struct def */\r
+#define AST_REQD_FIELDS \\r
+            struct _node *right, *down; \\r
+            int token;\r
+\r
+/* C MATCH */ /* MR21 Short circuit on null pointer */\r
+#define _MATCH(tok)  if (! _t || _t->token!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)\r
+#define _MATCHRANGE(tok,tok2) \\r
+    if (! _t || _t->token<tok || _t->token>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)\r
+\r
+/* C++ MATCH */\r
+#define _CPPMATCH(tok)  if ( _t->token()!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t)\r
+#define _CPPMATCHRANGE(tok,tok2) \\r
+    if ( _t->token()<tok || _t->token()>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t)\r
+\r
+/* Normal DOWN and RIGHT */\r
+#define _DOWN        _t=_t->down\r
+#define _RIGHT        _t=_t->right\r
+\r
+/* C++ DOWN and RIGHT */\r
+#define _CPPDOWN      _t=(SORAST *) _t->down()\r
+#define _CPPRIGHT      _t=(SORAST *) _t->right()\r
+\r
+#define _SAVE        SORAST *_save=_t\r
+#define _RESTORE      _t = _save\r
+#define  _SETLABEL(u)    u=_t\r
+#define _WILDCARD      if ( _t==NULL ) if ( _parser->guessing ) _GUESS_FAIL; else missing_wildcard(_parser)\r
+#define _GUESS_BLOCK    STreeParser _st; int _gv; SORAST *_savet=NULL;\r
+#define _GUESS        {_st = *_parser; \\r
+              _savet = _t; \\r
+              _parser->guessing = 1; \\r
+              _gv = setjmp(_parser->startofguess.state);}\r
+#define _GUESS_FAIL      longjmp(_parser->startofguess.state, 1)\r
+#define _GUESS_DONE      {*_parser = _st; _t = _savet;}\r
+\r
+/* These are used mainly by the C output */\r
+#ifndef ast_down\r
+#define ast_down    down\r
+#endif\r
+#ifndef ast_right\r
+#define ast_right    right\r
+#endif\r
+\r
+#define STreeTry(r,p,t)     \\r
+      (p)->try_result = NULL;          \\r
+            (p)->sjrv = setjmp((p)->startofguess);  \\r
+            if ( !(p)->sjrv ) {            \\r
+                rule(p,t,&try_result);        \\r
+                (p)->try_ok = 1;          \\r
+      }                    \\r
+            else {                  \\r
+                (p)->try_ok = 0;          \\r
+      }                    \\r
+            if ( (p)->try_ok )\r
+\r
+\r
+/* Used only during TRANSFORM mode */\r
+#define  TREE_CONSTR_PTRS  SORAST *_r=NULL,*_s=NULL,*_e=NULL\r
+\r
+typedef struct _Sjmp_buf {\r
+      jmp_buf state;\r
+    } Sjmp_buf;\r
+\r
+#ifndef _PARSER_VARS\r
+#define _PARSER_VARS\r
+#endif\r
+\r
+#ifndef _REFVARS\r
+#define _REFVARS\r
+#endif\r
+\r
+typedef struct _STreeParser {\r
+      int try_ok, sjrv;  /* used by STreeTry macro */\r
+      SORAST *try_result;  /* tree coming back from try */\r
+      int guessing;\r
+      Sjmp_buf startofguess;\r
+      SORAST *t;\r
+      _REFVARS\r
+      _PARSER_VARS\r
+    } STreeParser;\r
+\r
+#define STreeParserInit(_p) { (_p)->guessing = 0; _refvar_inits(_p); }\r
+\r
+\r
+        /* S a n i t y  C h e c k i n g */\r
+\r
+#ifndef require\r
+#define require(expr, err) {if ( !(expr) ) sorcerer_panic(err);}\r
+#endif\r
+\r
+\r
+               /* T r a n s f o r m  M a c r o s */\r
+#define ast_return(_t)  *_result = _t\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+extern void mismatched_range(STreeParser *_parser, int looking_for, int upper_token, SORAST *found);\r
+extern void missing_wildcard(STreeParser *_parser);\r
+extern void mismatched_token(STreeParser *_parser, int looking_for, SORAST *found);\r
+extern void no_viable_alt(STreeParser *_parser, char *rulename, SORAST *root);\r
+extern void sorcerer_panic(char *err);\r
+extern void _refvar_inits(STreeParser *);    /* MR15 Kevin J. Cummings */\r
+extern void _mkroot(SORAST **, SORAST **, SORAST **, SORAST *);\r
+extern void _mkchild(SORAST **, SORAST **, SORAST **, SORAST *);\r
+extern SORAST *ast_alloc(void);\r
+extern SORAST *ast_dup(SORAST *t);\r
+extern SORAST *ast_dup_node(SORAST *t);\r
+#else\r
+extern void mismatched_range();\r
+extern void missing_wildcard();\r
+extern void mismatched_token();\r
+extern void no_viable_alt();\r
+extern void sorcerer_panic();\r
+extern void _refvar_inits();    /* MR15 Kevin J. Cummings */\r
+extern void _mkroot();\r
+extern void _mkchild();\r
+extern SORAST *ast_alloc();\r
+extern SORAST *ast_dup();\r
+extern SORAST *ast_dup_node();\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..08c1ad0
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef SLIST_H\r
+#define SLIST_H\r
+\r
+/*\r
+ * SList.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+#include "sorcerer.h"\r
+\r
+typedef struct _SList {\r
+      void *elem;      /* pointer to any kind of element */\r
+      struct _SList *next;\r
+    } SList;\r
+\r
+#define newSList  (SList *) calloc(1, sizeof(SList));\r
+\r
+#ifdef __USE_PROTOS\r
+extern void *slist_iterate(SList *list, SList **);\r
+extern void slist_add( SList **list, void *e );\r
+extern void slist_free(SList *list);\r
+#else\r
+extern void *slist_iterate();\r
+extern void slist_add();\r
+extern void slist_free();\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..fe80598
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef SSTACK_H\r
+#define SSTACK_H\r
+\r
+/*\r
+ * SStack.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+#include "sorlist.h"\r
+\r
+typedef SList SStack;\r
+\r
+#define newSStack  (SStack *) calloc(1, sizeof(SStack));\r
+\r
+#ifdef __USE_PROTOS\r
+extern void sstack_push( SStack **st, void *e );\r
+extern void *sstack_pop( SStack **st );\r
+#else\r
+extern void sstack_push();\r
+extern void *sstack_pop();\r
+#endif\r
+\r
+#endif\r
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 (file)
index 0000000..35be33e
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef CASTBase_h\r
+#define CASTBase_h\r
+\r
+/*\r
+ * CASTBase.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+/* ONLY USED TO C COMPILE LIBRARY FUNCTIONS; YOU CAN FORCE THEM TO COMPILE WITH\r
+ * YOUR SORAST DEF IF YOU WANT (THAT WAY, ORDER OF FIELD DEFINITION IS IRRELEVANT)\r
+ */\r
+\r
+/* Typically, this file is not used / seen by the programmer */\r
+\r
+/* Used as "super-class" for compiling C library routines */\r
+typedef struct _nodebase {\r
+            struct _nodebase *right, *down;\r
+            int token;\r
+        } SORAST;\r
+\r
+#endif\r
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 (file)
index 0000000..0d50a33
--- /dev/null
@@ -0,0 +1,151 @@
+#include <stdio.h>\r
+#include "STreeParser.h"\r
+\r
+void STreeParser::\r
+MATCH(SORASTBase *_t,int tok)\r
+{\r
+       if ( _t->type()!=tok )\r
+       {\r
+               if ( guessing ) _GUESS_FAIL;\r
+               else mismatched_token(tok, _t);\r
+       }\r
+}\r
+\r
+void STreeParser::\r
+MATCHRANGE(SORASTBase *_t,int tok,int tok2)\r
+{\r
+       if ( _t->type()<tok || _t->type()>tok2 )\r
+       {\r
+               if ( guessing ) _GUESS_FAIL;\r
+               else mismatched_range(tok, tok2, _t);\r
+       }\r
+}\r
+\r
+void STreeParser::\r
+WILDCARD(SORASTBase *_t)\r
+{\r
+       if ( _t==NULL )\r
+       {\r
+               if ( guessing ) _GUESS_FAIL;\r
+               else missing_wildcard();\r
+       }\r
+}\r
+\r
+void STreeParser::\r
+mismatched_range(int looking_for, int upper_token, SORASTBase *found)\r
+{\r
+       if ( found!=NULL ) {\r
+               fprintf(stderr,\r
+                               "parse error: expected token range %d..%d found token %d\n",\r
+                               looking_for, upper_token,\r
+                               found->type());\r
+       }\r
+       else {\r
+               fprintf(stderr,\r
+                               "parse error: expected token range %d..%d found NULL tree\n",\r
+                               looking_for, upper_token);\r
+       }\r
+}\r
+\r
+void STreeParser::\r
+missing_wildcard()\r
+{\r
+       fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");\r
+}\r
+\r
+void STreeParser::\r
+mismatched_token(int looking_for, SORASTBase *found)\r
+{\r
+       if ( found!=NULL ) {\r
+               fprintf(stderr,\r
+                               "parse error: expected token %d found token %d\n",\r
+                               looking_for,\r
+                               found->type());\r
+       }\r
+       else {\r
+               fprintf(stderr,\r
+                               "parse error: expected token %d found NULL tree\n",\r
+                               looking_for);\r
+       }\r
+}\r
+\r
+void STreeParser::\r
+no_viable_alt(char *rulename, SORASTBase *root)\r
+{\r
+       if ( root==NULL )\r
+               fprintf(stderr,\r
+                               "parse error: in rule %s, no viable alternative for NULL tree\n",\r
+                               rulename);\r
+       else\r
+               fprintf(stderr,\r
+                               "parse error: in rule %s, no viable alternative for tree\n",\r
+                               rulename);\r
+}\r
+\r
+void STreeParser::\r
+panic(char *err)\r
+{\r
+       fprintf(stderr, "panic: %s\n", err);\r
+       exit(-1);\r
+}\r
+\r
+void STreeParser::\r
+save_state(STreeParser *buf)\r
+{\r
+       buf->try_ok = this->try_ok;\r
+       buf->sjrv = this->sjrv;\r
+       buf->guessing = this->guessing;\r
+       buf->startofguess = this->startofguess;\r
+}\r
+\r
+void STreeParser::\r
+restore_state(STreeParser *buf)\r
+{\r
+       this->try_ok = buf->try_ok;\r
+       this->sjrv = buf->sjrv;\r
+       this->guessing = buf->guessing;\r
+       this->startofguess = buf->startofguess;\r
+}\r
+\r
+void STreeParser::\r
+_mkroot(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)\r
+{\r
+       *r = t;\r
+}\r
+\r
+void STreeParser::\r
+_mkchild(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t)\r
+{\r
+#ifdef BEFORE_GARYS_FIX\r
+       /* if no sibling list, must attach to any existing root */\r
+       if ( *s==NULL )\r
+       {\r
+               *s = *e = t;\r
+               /* If r is NULL, then there was no root defined--must be sibling list */\r
+               if ( *r==NULL ) *r = *s;\r
+               else (*r)->setDown(t);\r
+       }\r
+       else { (*e)->setRight(t); *e = t; }\r
+#endif\r
+/*\r
+       should do nothing if asked to add a NULL argument.  NULL's come up\r
+       when a rule wants to return "nothing".\r
+*/\r
+       /* if no sibling list, must attach to any existing root */\r
+       if (*s == NULL)\r
+       {\r
+               *s = *e = t;\r
+               // If r is NULL then there was no root defined--must be sibling list\r
+               if (*r == NULL) *r = *s;\r
+               else (*r)->setDown(t);\r
+       }\r
+       else if (*e != NULL)\r
+       {\r
+               (*e)->setRight(t);\r
+               *e = t;\r
+       }\r
+       if (*e != NULL) {\r
+               while ((*e)->right() != NULL) *e = (SORASTBase *)(*e)->right();\r
+       }\r
+}\r
+\r
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 (file)
index 0000000..8ba1a49
--- /dev/null
@@ -0,0 +1,834 @@
+/*\r
+ * astlib.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include <ctype.h>\r
+\r
+#define SORCERER_TRANSFORM\r
+\r
+#include "CASTBase.h"\r
+#include "astlib.h"\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include <stdarg.h>\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+               /* String Scanning/Parsing Stuff */\r
+\r
+#define StringScanMaxText  50\r
+\r
+typedef struct stringlexer {\r
+#ifdef __USE_PROTOS\r
+      signed int c;\r
+#else\r
+      int c;\r
+#endif\r
+      char *input;\r
+      char *p;\r
+      char text[StringScanMaxText];\r
+    } StringLexer;\r
+\r
+#define LPAREN      1\r
+#define RPAREN      2\r
+#define PERCENT      3\r
+#define INT        4\r
+#define COLON      5\r
+#define POUND      6\r
+#define PERIOD      7\r
+#define StringScanEOF  -1\r
+#define VALID_SCAN_TOKEN(t)    (t>=LPAREN && t<=PERIOD)\r
+\r
+static char *scan_token_tbl[] = {\r
+  "invalid",  /*  0 */\r
+  "LPAREN",  /*  1 */\r
+  "RPAREN",  /*  2 */\r
+  "PERCENT",  /*  3 */\r
+  "INT",    /*  4 */\r
+  "COLON",  /*  5 */\r
+  "POUND",  /*  6 */\r
+  "PERIOD",  /*  7 */\r
+};\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+scan_token_str(int t)\r
+#else\r
+scan_token_str(t)\r
+int t;\r
+#endif\r
+{\r
+  if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];\r
+  else if ( t==StringScanEOF ) return "<end-of-string>";\r
+  else return "<invalid-token>";\r
+}\r
+\r
+typedef struct stringparser {\r
+      int token;\r
+      StringLexer *lexer;\r
+      int num_labels;\r
+    } StringParser;\r
+\r
+          /* This type ONLY USED by ast_scan() */\r
+\r
+typedef struct _scanast {\r
+            struct _scanast *right, *down;\r
+            int token;\r
+      int label_num;\r
+        } ScanAST;\r
+\r
+#ifdef __USE_PROTOS\r
+static void stringlexer_init(StringLexer *scanner, char *input);\r
+static void stringparser_init(StringParser *, StringLexer *);\r
+static ScanAST *stringparser_parse_scanast(char *templ, int *n);\r
+static ScanAST *stringparser_parse_tree(StringParser *parser);\r
+static ScanAST *stringparser_parse_element(StringParser *parser);\r
+static void stringscan_advance(StringLexer *scanner);\r
+static int stringscan_gettok(StringLexer *scanner);\r
+#else\r
+static void stringlexer_init();\r
+static void stringparser_init();\r
+static ScanAST *stringparser_parse_scanast();\r
+static ScanAST *stringparser_parse_tree();\r
+static ScanAST *stringparser_parse_element();\r
+static void stringscan_advance();\r
+static int stringscan_gettok();\r
+#endif\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually sibling lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ *\r
+ * The ast_down and ast_right down/right pointers are used to make the tree.\r
+ */\r
+SORAST *\r
+#ifdef PCCTS_USE_STDARG\r
+ast_make(SORAST *rt, ...)\r
+#else\r
+ast_make(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+  va_list ap;\r
+  register SORAST *child, *sibling=NULL, *tail = NULL, *w;\r
+  SORAST *root;\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+  va_start(ap, rt);\r
+  root = rt;\r
+#else\r
+  va_start(ap);\r
+  root = va_arg(ap, SORAST *);\r
+#endif\r
+\r
+  if ( root != NULL )\r
+    if ( root->ast_down != NULL ) return NULL;\r
+  child = va_arg(ap, SORAST *);\r
+  while ( child != NULL )\r
+  {\r
+    /* find end of child */\r
+    for (w=child; w->ast_right!=NULL; w=w->ast_right) {;}\r
+    if ( sibling == NULL ) {sibling = child; tail = w;}\r
+    else {tail->ast_right = child; tail = w;}\r
+    child = va_arg(ap, SORAST *);\r
+  }\r
+  if ( root==NULL ) root = sibling;\r
+  else root->ast_down = sibling;\r
+  va_end(ap);\r
+  return root;\r
+}\r
+\r
+/* The following push and pop routines are only used by ast_find_all() */\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+_push(SORAST **st, int *sp, SORAST *e)\r
+#else\r
+_push(st, sp, e)\r
+SORAST **st;\r
+int *sp;\r
+SORAST *e;\r
+#endif\r
+{\r
+  (*sp)--;\r
+  require((*sp)>=0, "stack overflow");\r
+  st[(*sp)] = e;\r
+}\r
+\r
+static SORAST *\r
+#ifdef __USE_PROTOS\r
+_pop(SORAST **st, int *sp)\r
+#else\r
+_pop(st, sp)\r
+SORAST **st;\r
+int *sp;\r
+#endif\r
+{\r
+  SORAST *e = st[*sp];\r
+  (*sp)++;\r
+  require((*sp)<=MaxTreeStackDepth, "stack underflow");\r
+  return e;\r
+}\r
+\r
+/* Is 'u' a subtree of 't' beginning at the root? */\r
+int\r
+#ifdef __USE_PROTOS\r
+ast_match_partial(SORAST *t, SORAST *u)\r
+#else\r
+ast_match_partial(t, u)\r
+SORAST *t, *u;\r
+#endif\r
+{\r
+  SORAST *sib;\r
+\r
+  if ( u==NULL ) return 1;\r
+  if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;\r
+\r
+  for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)\r
+  {\r
+    if ( sib->token != u->token ) return 0;\r
+    if ( sib->ast_down!=NULL )\r
+      if ( !ast_match_partial(sib->ast_down, u->ast_down) ) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+/* Find all occurrences of u in t.\r
+ * 'cursor' must be initialized to 't'.  It eventually\r
+ * returns NULL when no more occurrences of 'u' are found.\r
+ */\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_find_all(SORAST *t, SORAST *u, SORAST **cursor)\r
+#else\r
+ast_find_all(t, u, cursor)\r
+SORAST *t, *u, **cursor;\r
+#endif\r
+{\r
+  SORAST *sib;\r
+  static SORAST *template_stack[MaxTreeStackDepth];\r
+  static int tsp = MaxTreeStackDepth;\r
+\r
+  if ( *cursor == NULL ) return NULL;\r
+  if ( *cursor!=t ) sib = *cursor;\r
+  else {\r
+    /* else, first time--start at top of template 't' */\r
+    tsp = MaxTreeStackDepth;\r
+    sib = t;\r
+    /* bottom of stack is always a NULL--"cookie" indicates "done" */\r
+    _push(template_stack, &tsp, NULL);\r
+  }\r
+\r
+keep_looking:\r
+  if ( sib==NULL )  /* hit end of sibling list */\r
+  {\r
+    sib = _pop(template_stack, &tsp);\r
+    if ( sib == NULL ) { *cursor = NULL; return NULL; }\r
+  }\r
+\r
+  if ( sib->token != u->token )\r
+  {\r
+    /* look for another match */\r
+    if ( sib->ast_down!=NULL )\r
+    {\r
+      if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);\r
+      sib=sib->ast_down;\r
+      goto keep_looking;\r
+    }\r
+    /* nothing below to try, try next sibling */\r
+    sib=sib->ast_right;\r
+    goto keep_looking;\r
+  }\r
+\r
+  /* found a matching root node, try to match what's below */\r
+  if ( ast_match_partial(sib, u) )\r
+  {\r
+    /* record sibling cursor so we can pick up next from there */\r
+    if ( sib->ast_down!=NULL )\r
+    {\r
+      if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);\r
+      *cursor = sib->ast_down;\r
+    }\r
+    else if ( sib->ast_right!=NULL ) *cursor = sib->ast_right;\r
+    else *cursor = _pop(template_stack, &tsp);\r
+    return sib;\r
+  }\r
+\r
+  /* no match, keep searching */\r
+  if ( sib->ast_down!=NULL )\r
+  {\r
+    if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right);\r
+    sib=sib->ast_down;\r
+  }\r
+  else sib = sib->ast_right;  /* else, try to right if zip below */\r
+  goto keep_looking;\r
+}\r
+\r
+/* are two trees exactly alike? */\r
+int\r
+#ifdef __USE_PROTOS\r
+ast_match(SORAST *t, SORAST *u)\r
+#else\r
+ast_match(t, u)\r
+SORAST *t, *u;\r
+#endif\r
+{\r
+  SORAST *sib;\r
+\r
+  if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;\r
+  if ( u==NULL ) return 0;\r
+\r
+  for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right)\r
+  {\r
+    if ( sib->token != u->token ) return 0;\r
+    if ( sib->ast_down!=NULL )\r
+      if ( !ast_match(sib->ast_down, u->ast_down) ) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+ast_scanmatch(ScanAST *t, SORAST *u, SORAST **labels[], int *n)\r
+#else\r
+ast_scanmatch(t, u, labels, n)\r
+ScanAST *t;\r
+SORAST *u;\r
+SORAST **labels[];\r
+int *n;\r
+#endif\r
+{\r
+  ScanAST *sib;\r
+\r
+  if ( t==NULL ) if ( u!=NULL ) return 0; else return 1;\r
+  if ( u==NULL ) return 0;\r
+\r
+  for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right, u=u->ast_right)\r
+  {\r
+    /* make sure tokens match; token of '0' means wildcard match */\r
+    if ( sib->token != u->token && sib->token!=0 ) return 0;\r
+    /* we have a matched token here; set label pointers if exists */\r
+    if ( sib->label_num>0 )\r
+    {\r
+      require(labels!=NULL, "label found in template, but no array of labels");\r
+      (*n)++;\r
+      *(labels[sib->label_num-1]) = u;\r
+    }\r
+    /* match what's below if something there and current node is not wildcard */\r
+    if ( sib->down!=NULL && sib->token!=0 )\r
+      if ( !ast_scanmatch(sib->down, u->ast_down, labels, n) ) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ast_insert_after(SORAST *a, SORAST *b)\r
+#else\r
+ast_insert_after(a, b)\r
+SORAST *a,*b;\r
+#endif\r
+{\r
+  SORAST *end;\r
+  require(a!=NULL, "ast_insert_after: NULL input tree");\r
+  if ( b==NULL ) return;\r
+  /* find end of b's child list */\r
+  for (end=b; end->ast_right!=NULL; end=end->ast_right) {;}\r
+  end->ast_right = a->ast_right;\r
+  a->ast_right = b;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ast_append(SORAST *a, SORAST *b)\r
+#else\r
+ast_append(a, b)\r
+SORAST *a,*b;\r
+#endif\r
+{\r
+  SORAST *end;\r
+  require(a!=NULL&&b!=NULL, "ast_append: NULL input tree");\r
+  /* find end of child list */\r
+  for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}\r
+  end->ast_right = b;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_tail(SORAST *a)\r
+#else\r
+ast_tail(a)\r
+SORAST *a;\r
+#endif\r
+{\r
+  SORAST *end;\r
+  require(a!=NULL, "ast_tail: NULL input tree");\r
+  /* find end of child list */\r
+  for (end=a; end->ast_right!=NULL; end=end->ast_right) {;}\r
+  return end;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_bottom(SORAST *a)\r
+#else\r
+ast_bottom(a)\r
+SORAST *a;\r
+#endif\r
+{\r
+  SORAST *end;\r
+  require(a!=NULL, "ast_bottom: NULL input tree");\r
+  /* find end of child list */\r
+  for (end=a; end->ast_down!=NULL; end=end->ast_down) {;}\r
+  return end;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_cut_between(SORAST *a, SORAST *b)\r
+#else\r
+ast_cut_between(a, b)\r
+SORAST *a,*b;\r
+#endif\r
+{\r
+  SORAST *end, *ret;\r
+  require(a!=NULL&&b!=NULL, "ast_cut_between: NULL input tree");\r
+  /* find node pointing to b */\r
+  for (end=a; end->ast_right!=NULL&&end->ast_right!=b; end=end->ast_right)\r
+    {;}\r
+  require(end->ast_right!=NULL, "ast_cut_between: a,b not connected");\r
+  end->ast_right = NULL;  /* don't want it point to 'b' anymore */\r
+  ret = a->ast_right;\r
+  a->ast_right = b;\r
+  return ret;\r
+}\r
+\r
+SList *\r
+#ifdef __USE_PROTOS\r
+ast_to_slist(SORAST *t)\r
+#else\r
+ast_to_slist(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+  SList *list=NULL;\r
+  SORAST *p;\r
+\r
+  for (p=t; p!=NULL; p=p->ast_right)\r
+  {\r
+    slist_add(&list, p);\r
+  }\r
+  return list;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+slist_to_ast(SList *list)\r
+#else\r
+slist_to_ast(list)\r
+SList *list;\r
+#endif\r
+{\r
+  SORAST *t=NULL, *last=NULL;\r
+  SList *p;\r
+\r
+  for (p = list->next; p!=NULL; p=p->next)\r
+  {\r
+    SORAST *u = (SORAST *)p->elem;\r
+    if ( last==NULL ) last = t = u;\r
+    else { last->ast_right = u; last = u; }\r
+  }\r
+  return t;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ast_free(SORAST *t)\r
+#else\r
+ast_free(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+    if ( t == NULL ) return;\r
+    ast_free( t->ast_down );\r
+    ast_free( t->ast_right );\r
+    free( t );\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+ast_nsiblings(SORAST *t)\r
+#else\r
+ast_nsiblings(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+  int n=0;\r
+\r
+  while ( t!=NULL )\r
+  {\r
+    n++;\r
+    t = t->ast_right;\r
+  }\r
+  return n;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_sibling_index(SORAST *t, int i)\r
+#else\r
+ast_sibling_index(t,i)\r
+SORAST *t;\r
+int i;\r
+#endif\r
+{\r
+  int j=1;\r
+  require(i>0, "ast_sibling_index: i<=0");\r
+\r
+  while ( t!=NULL )\r
+  {\r
+    if ( j==i ) return t;\r
+    j++;\r
+    t = t->ast_right;\r
+  }\r
+  return NULL;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+scanast_free(ScanAST *t)\r
+#else\r
+scanast_free(t)\r
+ScanAST *t;\r
+#endif\r
+{\r
+    if ( t == NULL ) return;\r
+    scanast_free( t->down );\r
+    scanast_free( t->right );\r
+    free( t );\r
+}\r
+\r
+/*\r
+ * ast_scan\r
+ *\r
+ * This function is like scanf(): it attempts to match a template\r
+ * against an input tree.  A variable number of tree pointers\r
+ * may be set according to the '%i' labels in the template string.\r
+ * For example:\r
+ *\r
+ *   ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",\r
+ *            t, &w, &x, &y, &z);\r
+ *\r
+ * Naturally, you'd want this converted from\r
+ *\r
+ *   ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",\r
+ *        t, &w, &x, &y, &z);\r
+ *\r
+ * by SORCERER.\r
+ *\r
+ * This function call must be done withing a SORCERER file because SORCERER\r
+ * must convert the token references to the associated token number.\r
+ *\r
+ * This functions parses the template and creates trees which are then\r
+ * matched against the input tree.  The labels are set as they are\r
+ * encountered; hence, partial matches may leave some pointers set\r
+ * and some NULL.  This routines initializes all argument pointers to NULL\r
+ * at the beginning.\r
+ *\r
+ * This function returns the number of labels matched.\r
+ */\r
+int\r
+#ifdef PCCTS_USE_STDARG\r
+ast_scan(char *templ, SORAST *tree, ...)\r
+#else\r
+ast_scan(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+  va_list ap;\r
+  ScanAST *t;\r
+  int n, i, found=0;\r
+  SORAST ***label_ptrs=NULL;\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+  va_start(ap, tree);\r
+#else\r
+  char *templ;\r
+  SORAST *tree;\r
+\r
+  va_start(ap);\r
+  templ = va_arg(ap, char *);\r
+  tree = va_arg(ap, SORAST *);\r
+#endif\r
+\r
+  /* make a ScanAST tree out of the template */\r
+  t = stringparser_parse_scanast(templ, &n);\r
+\r
+  /* make an array out of the labels */\r
+  if ( n>0 )\r
+  {\r
+    label_ptrs = (SORAST ***) calloc(n, sizeof(SORAST **));\r
+    require(label_ptrs!=NULL, "ast_scan: out of memory");\r
+    for (i=1; i<=n; i++)\r
+    {\r
+      label_ptrs[i-1] = va_arg(ap, SORAST **);\r
+      *(label_ptrs[i-1]) = NULL;\r
+    }\r
+  }\r
+\r
+  /* match the input tree against the template */\r
+  ast_scanmatch(t, tree, label_ptrs, &found);\r
+\r
+  scanast_free(t);\r
+  free(label_ptrs);\r
+\r
+  return found;\r
+}\r
+\r
+static ScanAST *\r
+#ifdef __USE_PROTOS\r
+new_scanast(int tok)\r
+#else\r
+new_scanast(tok)\r
+int tok;\r
+#endif\r
+{\r
+    ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));\r
+    if ( p == NULL ) {fprintf(stderr, "out of mem\n"); exit(-1);}\r
+  p->token = tok;\r
+  return p;\r
+}\r
+\r
+static ScanAST *\r
+#ifdef __USE_PROTOS\r
+stringparser_parse_scanast(char *templ, int *num_labels)\r
+#else\r
+stringparser_parse_scanast(templ, num_labels)\r
+char *templ;\r
+int *num_labels;\r
+#endif\r
+{\r
+  StringLexer lex;\r
+  StringParser parser;\r
+  ScanAST *t;\r
+\r
+  stringlexer_init(&lex, templ);\r
+  stringparser_init(&parser, &lex);\r
+  t = stringparser_parse_tree(&parser);\r
+  *num_labels = parser.num_labels;\r
+  return t;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+stringparser_match(StringParser *parser, int token)\r
+#else\r
+stringparser_match(parser, token)\r
+StringParser *parser;\r
+int token;\r
+#endif\r
+{\r
+  if ( parser->token != token ) sorcerer_panic("bad tree in ast_scan()");\r
+}\r
+\r
+/*\r
+ * Match a tree of the form:\r
+ *    (root child1 child2 ... childn)\r
+ * or,\r
+ *    node\r
+ *\r
+ * where the elements are integers or labeled integers.\r
+ */\r
+static ScanAST *\r
+#ifdef __USE_PROTOS\r
+stringparser_parse_tree(StringParser *parser)\r
+#else\r
+stringparser_parse_tree(parser)\r
+StringParser *parser;\r
+#endif\r
+{\r
+  ScanAST *t=NULL, *root, *child, *last = NULL;\r
+\r
+  if ( parser->token != POUND )\r
+  {\r
+    return stringparser_parse_element(parser);\r
+  }\r
+  stringparser_match(parser,POUND);\r
+  parser->token = stringscan_gettok(parser->lexer);\r
+  stringparser_match(parser,LPAREN);\r
+  parser->token = stringscan_gettok(parser->lexer);\r
+  root = stringparser_parse_element(parser);\r
+  while ( parser->token != RPAREN )\r
+  {\r
+    child = stringparser_parse_element(parser);\r
+    if ( t==NULL ) { t = child; last = t; }\r
+    else { last->right = child; last = child; }\r
+  }\r
+  stringparser_match(parser,RPAREN);\r
+  parser->token = stringscan_gettok(parser->lexer);\r
+  root->down = t;\r
+  return root;\r
+}\r
+\r
+static ScanAST *\r
+#ifdef __USE_PROTOS\r
+stringparser_parse_element(StringParser *parser)\r
+#else\r
+stringparser_parse_element(parser)\r
+StringParser *parser;\r
+#endif\r
+{\r
+  static char ebuf[100];\r
+  int label = 0;\r
+\r
+  if ( parser->token == POUND )\r
+  {\r
+    return stringparser_parse_tree(parser);\r
+  }\r
+  if ( parser->token == PERCENT )\r
+  {\r
+    parser->token = stringscan_gettok(parser->lexer);\r
+    stringparser_match(parser,INT);\r
+    label = atoi(parser->lexer->text);\r
+    parser->num_labels++;\r
+    if ( label==0 ) sorcerer_panic("%%0 is an invalid label");\r
+    parser->token = stringscan_gettok(parser->lexer);\r
+    stringparser_match(parser,COLON);\r
+    parser->token = stringscan_gettok(parser->lexer);\r
+    /* can label tokens and wildcards */\r
+    if ( parser->token != INT && parser->token != PERIOD )\r
+      sorcerer_panic("can only label tokens");\r
+  }\r
+  if ( parser->token == INT )\r
+  {\r
+    ScanAST *p = new_scanast(atoi(parser->lexer->text));\r
+    parser->token = stringscan_gettok(parser->lexer);\r
+    p->label_num = label;\r
+    return p;\r
+  }\r
+  if ( parser->token == PERIOD )\r
+  {\r
+    ScanAST *p = new_scanast(0);  /* token of 0 is wildcard */\r
+    parser->token = stringscan_gettok(parser->lexer);\r
+    p->label_num = label;\r
+    return p;\r
+  }\r
+  sprintf(ebuf, "mismatch token in ast_scan(): %s", scan_token_str(parser->token));\r
+  sorcerer_panic(ebuf);\r
+    return NULL; /* MR20 make -Wall happy */\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+stringparser_init(StringParser *parser, StringLexer *input)\r
+#else\r
+stringparser_init(parser, input)\r
+StringParser *parser;\r
+StringLexer *input;\r
+#endif\r
+{\r
+  parser->lexer = input;\r
+  parser->token = stringscan_gettok(parser->lexer);\r
+  parser->num_labels = 0;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+stringlexer_init(StringLexer *scanner, char *input)\r
+#else\r
+stringlexer_init(scanner, input)\r
+StringLexer *scanner;\r
+char *input;\r
+#endif\r
+{\r
+  scanner->text[0]='\0';\r
+  scanner->input = input;\r
+  scanner->p = input;\r
+  stringscan_advance(scanner);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+stringscan_advance(StringLexer *scanner)\r
+#else\r
+stringscan_advance(scanner)\r
+StringLexer *scanner;\r
+#endif\r
+{\r
+  if ( *(scanner->p) == '\0' ) scanner->c = StringScanEOF;\r
+  scanner->c = *(scanner->p)++;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+stringscan_gettok(StringLexer *scanner)\r
+#else\r
+stringscan_gettok(scanner)\r
+StringLexer *scanner;\r
+#endif\r
+{\r
+  char *index = &scanner->text[0];\r
+  static char ebuf[100];\r
+\r
+  while ( isspace(scanner->c) ) { stringscan_advance(scanner); }\r
+  if ( isdigit(scanner->c) )\r
+  {\r
+    int tok = INT;\r
+    while ( isdigit(scanner->c) ) {\r
+      *index++ = scanner->c;\r
+      stringscan_advance(scanner);\r
+    }\r
+    *index = '\0';\r
+    return tok;\r
+  }\r
+  switch ( scanner->c )\r
+  {\r
+    case '#' : stringscan_advance(scanner); return POUND;\r
+    case '(' : stringscan_advance(scanner); return LPAREN;\r
+    case ')' : stringscan_advance(scanner); return RPAREN;\r
+    case '%' : stringscan_advance(scanner); return PERCENT;\r
+    case ':' : stringscan_advance(scanner); return COLON;\r
+    case '.' : stringscan_advance(scanner); return PERIOD;\r
+    case '\0' : return StringScanEOF;\r
+    case StringScanEOF : return StringScanEOF;\r
+    default  :\r
+      sprintf(ebuf, "invalid char in ast_scan: '%c'", scanner->c);\r
+      sorcerer_panic(ebuf);\r
+            return 0; /* MR20 Make -Wall happy */\r
+  }\r
+}\r
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 (file)
index 0000000..4048ba5
--- /dev/null
@@ -0,0 +1,100 @@
+/*\r
+ * errsupport.c -- error support code for SORCERER output\r
+ *\r
+ * Define your own or compile and link this in.\r
+ *\r
+ * Terence Parr\r
+ * U of MN, AHPCRC\r
+ * February 1994\r
+ */\r
+#include "sorcerer.h"\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found )\r
+#else\r
+mismatched_range( _parser, looking_for, upper_token, found )\r
+int looking_for;\r
+int upper_token;\r
+SORAST *found;\r
+STreeParser *_parser;\r
+#endif\r
+{\r
+  if ( found!=NULL ) {\r
+    fprintf(stderr,\r
+        "parse error: expected token range %d..%d found token %d\n",\r
+        looking_for, upper_token,\r
+        found->token);\r
+  }\r
+  else {\r
+    fprintf(stderr,\r
+        "parse error: expected token range %d..%d found NULL tree\n",\r
+        looking_for, upper_token);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+missing_wildcard(STreeParser *_parser)\r
+#else\r
+missing_wildcard(_parser)\r
+STreeParser *_parser;\r
+#endif\r
+{\r
+  fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+mismatched_token( STreeParser *_parser, int looking_for, SORAST *found )\r
+#else\r
+mismatched_token( _parser, looking_for, found )\r
+int looking_for;\r
+SORAST *found;\r
+STreeParser *_parser;\r
+#endif\r
+{\r
+  if ( found!=NULL ) {\r
+    fprintf(stderr,\r
+        "parse error: expected token %d found token %d\n",\r
+        looking_for,\r
+        found->token);\r
+  }\r
+  else {\r
+    fprintf(stderr,\r
+        "parse error: expected token %d found NULL tree\n",\r
+        looking_for);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root )\r
+#else\r
+no_viable_alt( _parser, rulename, root )\r
+char *rulename;\r
+SORAST *root;\r
+STreeParser *_parser;\r
+#endif\r
+{\r
+  if ( root==NULL )\r
+    fprintf(stderr,\r
+        "parse error: in rule %s, no viable alternative for NULL tree\n",\r
+        rulename);\r
+  else\r
+    fprintf(stderr,\r
+        "parse error: in rule %s, no viable alternative for tree\n",\r
+        rulename);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+sorcerer_panic(char *err)\r
+#else\r
+sorcerer_panic(err)\r
+char *err;\r
+#endif\r
+{\r
+  fprintf(stderr, "panic: %s\n", err);\r
+  exit(-1);\r
+}\r
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile
new file mode 100644 (file)
index 0000000..c4e9bca
--- /dev/null
@@ -0,0 +1,21 @@
+#\r
+# Makefile for SORCERER libraries\r
+#\r
+SRC = astlib.c sstack.c sorlist.c sintstack.c\r
+OBJ = astlib.o sstack.o sorlist.o sintstack.o\r
+CFLAGS=-g -I../../h -I../h\r
+CC=cc\r
+\r
+libs : $(OBJ) $(SRC)\r
+\r
+clean:\r
+       rm -f *.o core\r
+\r
+scrub:\r
+       rm -f *.o core\r
+\r
+ci:\r
+       ci -u $(SRC) *.h makefile\r
+\r
+co:\r
+       co -l $(SRC) *.h makefile\r
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 (file)
index 0000000..390d34f
--- /dev/null
@@ -0,0 +1,130 @@
+# Microsoft Developer Studio Project File - Name="lib" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 5.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Static Library" 0x0104\r
+\r
+CFG=lib - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "lib.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "lib.mak" CFG="lib - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "lib - Win32 Release" (based on "Win32 (x86) Static Library")\r
+!MESSAGE "lib - Win32 Debug" (based on "Win32 (x86) Static Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP Scc_ProjName ""$/pccts/Sorcerer/lib", EPABAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+\r
+!IF  "$(CFG)" == "lib - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /O2 /I "h" /I "..\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo\r
+\r
+!ELSEIF  "$(CFG)" == "lib - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "h" /I "..\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "lib - Win32 Release"\r
+# Name "lib - Win32 Debug"\r
+# Begin Group "Header files"\r
+\r
+# PROP Default_Filter "h"\r
+# Begin Source File\r
+\r
+SOURCE=.\CASTBase.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Source files"\r
+\r
+# PROP Default_Filter "c,cpp"\r
+# Begin Source File\r
+\r
+SOURCE=.\astlib.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\errsupport.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\PCCTSAST.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\sintstack.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\SList.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\sorcerer.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\sorlist.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\sstack.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\STreeParser.cpp\r
+# End Source File\r
+# End Group\r
+# End Target\r
+# End Project\r
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 (file)
index 0000000..a3708c9
--- /dev/null
@@ -0,0 +1,140 @@
+/*\r
+ * sint.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+#include <stdio.h>\r
+#include <setjmp.h>\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include <stdarg.h>\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#include "CASTBase.h"\r
+#include "sintstack.h"\r
+\r
+SIntStack *\r
+#ifdef __USE_PROTOS\r
+sint_newstack(int size)\r
+#else\r
+sint_newstack(size)\r
+int size;\r
+#endif\r
+{\r
+  SIntStack *p = (SIntStack *) calloc(1, sizeof(SIntStack));\r
+  require(p!=NULL, "sint_newstack: out of memory");\r
+  p->data = (int *) calloc(size, sizeof(int));\r
+  require(p!=NULL, "sint_newstack: out of memory");\r
+  p->size = size;\r
+  p->sp = size;\r
+  return p;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+sint_freestack(SIntStack *st)\r
+#else\r
+sint_freestack(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  if ( st==NULL ) return;\r
+  if ( st->data==NULL ) return;\r
+  free(st->data);\r
+  free(st);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+sint_push(SIntStack *st,int i)\r
+#else\r
+sint_push(st,i)\r
+SIntStack *st;\r
+int i;\r
+#endif\r
+{\r
+  require(st->sp>0, "sint_push: stack overflow");\r
+  st->data[--(st->sp)] = i;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+sint_pop(SIntStack *st)\r
+#else\r
+sint_pop(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  require(st->sp<st->size, "sint_pop: stack underflow");\r
+  return st->data[st->sp++];\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+sint_stacksize(SIntStack *st)\r
+#else\r
+sint_stacksize(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  return st->size - st->sp;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+sint_stackreset(SIntStack *st)\r
+#else\r
+sint_stackreset(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  st->sp = st->size;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+sint_stackempty(SIntStack *st)\r
+#else\r
+sint_stackempty(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  return st->sp==st->size;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+sint_top(SIntStack *st)\r
+#else\r
+sint_top(st)\r
+SIntStack *st;\r
+#endif\r
+{\r
+  require(st->sp<st->size, "sint_top: stack underflow");\r
+  return st->data[st->sp];\r
+}\r
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 (file)
index 0000000..ad4c3a7
--- /dev/null
@@ -0,0 +1,169 @@
+/*\r
+ * sorcerer.c -- support code for SORCERER output\r
+ *\r
+ * Define your own or compile and link this in.\r
+ *\r
+ * Terence Parr\r
+ * U of MN, AHPCRC\r
+ * February 1994\r
+ */\r
+\r
+/***********************************************************************\r
+  2-Oct-97  The routine ast_dup() appeared to have a bug in it.  Instead\r
+            of providing a deep copy of its argument it made a bushy copy\r
+            of its argument - by duplicating the nodes pointed to by\r
+            its right link.  This is certainly not deliberate and does\r
+            not match code in PCCTSAST.cpp (which had its own bug).  This\r
+            has been changed to do a deep copy in the traditional sense.\r
+***********************************************************************/\r
+\r
+#ifdef OLD\r
+/* Given a result pointer, return the same one if *t is NULL,\r
+ * else find the end of the sibling list and return the address\r
+ * the 'next[write]' field in that last node.\r
+ */\r
+AST **\r
+#ifdef __USE_PROTOS\r
+_nextresult(STreeParser *_parser, AST **t)\r
+#else\r
+_nextresult(_parser, t)\r
+AST **t;\r
+STreeParser *_parser;\r
+#endif\r
+{\r
+  AST *p = *t;\r
+\r
+  if ( p==NULL ) return t;\r
+  while ( p->ast_right(_parser->write) != NULL )\r
+  {\r
+    p = p->ast_right(_parser->write);\r
+  }\r
+  return &(p->ast_right(_parser->write));\r
+}\r
+\r
+/*\r
+ * Copy the read pointers to the write pointers for a node or entire subtree\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+_copy_wildcard(STreeParser *_parser, AST *t, int root)\r
+#else\r
+_copy_wildcard(_parser, t, root)\r
+STreeParser *_parser;\r
+AST *t;\r
+int root;\r
+#endif\r
+{\r
+  while ( t!=NULL )\r
+  {\r
+    if ( !root ) t->ast_right(_parser->write) = t->ast_right(_parser->read);\r
+    t->ast_down(_parser->write) = t->ast_down(_parser->read);\r
+    if ( t->ast_down(_parser->read)!=NULL )\r
+      _copy_wildcard(_parser, t->ast_down(_parser->read), 0);\r
+    if ( root ) return;\r
+    else root=0;\r
+    t = t->ast_right(_parser->read);\r
+  }\r
+}\r
+#endif\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+_mkroot(SORAST **r, SORAST **s, SORAST **e, SORAST *t)\r
+#else\r
+_mkroot(r,s,e,t)\r
+SORAST **r, **s, **e, *t;\r
+#endif\r
+{\r
+  *r = t;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+_mkchild(SORAST **r, SORAST **s, SORAST **e, SORAST *t)\r
+#else\r
+_mkchild(r,s,e,t)\r
+SORAST **r, **s, **e, *t;\r
+#endif\r
+{\r
+  /* if no sibling list, must attach to any existing root */\r
+  if ( *s==NULL )\r
+  {\r
+    *s = *e = t;\r
+    /* If r is NULL, then there was no root defined--must be sibling list */\r
+    if ( *r==NULL ) *r = *s;\r
+    else (*r)->ast_down = t;\r
+  }\r
+  else { (*e)->ast_right = t; *e = t; }\r
+}\r
+\r
+/* THESE FUNCS HAVE TO GO HERE BECAUSE THEY ARE SENSITIVE TO USER'S SORAST DEF */\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_alloc(void)\r
+#else\r
+ast_alloc()\r
+#endif\r
+{\r
+  SORAST *t = (SORAST *)calloc(1, sizeof(SORAST));\r
+  if ( t==NULL ) sorcerer_panic("out of memory");\r
+  return t;\r
+}\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_dup_bushy(SORAST *t)\r
+#else\r
+ast_dup_bushy(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+  SORAST *u;\r
+  \r
+  if ( t == NULL ) return NULL;\r
+  u = ast_alloc();\r
+  *u = *t;  /* copy contents */\r
+  u->ast_down = ast_dup_bushy(t->ast_down);    /* copy the rest of the tree */\r
+  u->ast_right = ast_dup_bushy(t->ast_right);\r
+  return u;\r
+}\r
+\r
+\r
+/* Assume t is a root node of a tree--duplicate that node and what's below */\r
+\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_dup(SORAST *t)\r
+#else\r
+ast_dup(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+  SORAST *u;\r
+  \r
+  if ( t == NULL ) return NULL;\r
+  u = ast_alloc();\r
+  *u = *t;  /* copy contents */\r
+  u->ast_down = ast_dup_bushy(t->ast_down);    /* copy the rest of the tree */\r
+  u->ast_right = NULL;\r
+  return u;\r
+}\r
+\r
+/* Assume t is a root node of a tree--duplicate that node and what's below */\r
+SORAST *\r
+#ifdef __USE_PROTOS\r
+ast_dup_node(SORAST *t)\r
+#else\r
+ast_dup_node(t)\r
+SORAST *t;\r
+#endif\r
+{\r
+  SORAST *u;\r
+  \r
+  if ( t == NULL ) return NULL;\r
+  u = ast_alloc();\r
+  *u = *t;  /* copy contents */\r
+  u->down = NULL;\r
+  u->right = NULL;\r
+  return u;\r
+}\r
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 (file)
index 0000000..6872974
--- /dev/null
@@ -0,0 +1,123 @@
+/*\r
+ * slist.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+#include <stdio.h>\r
+#include <setjmp.h>\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include <stdarg.h>\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#include "CASTBase.h"\r
+#include "sorlist.h"\r
+\r
+/* Iterate over a list of elements; returns ptr to a new element\r
+ * in list upon every call and NULL when no more are left.\r
+ * Very useful like this:\r
+ *\r
+ *    cursor = mylist;\r
+ *    while ( (p=slist_iterate(mylist,&cursor)) ) {\r
+ *      / * place with element p * /\r
+ *    }\r
+ *\r
+ * The cursor must be initialized to point to the list to iterate over.\r
+ */\r
+void *\r
+#ifdef __USE_PROTOS\r
+slist_iterate(SList *list, SList **cursor)\r
+#else\r
+slist_iterate(list, cursor)\r
+SList *list, **cursor;\r
+#endif\r
+{\r
+  void *e;\r
+\r
+  if ( list==NULL || cursor == NULL || *cursor==NULL ) return NULL;\r
+  if ( list== *cursor ) { *cursor = (*cursor)->next; }\r
+  e = (*cursor)->elem;\r
+  (*cursor) = (*cursor)->next;\r
+  return e;\r
+}\r
+\r
+/*\r
+ * add an element to a list.\r
+ *\r
+ * Any non-empty list has a sentinel node whose 'elem' pointer is really\r
+ * a pointer to the last element.  (i.e. length(list) = #elemIn(list)+1).\r
+ * Elements are appended to the list.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+slist_add( SList **list, void *e )\r
+#else\r
+slist_add( list, e )\r
+SList **list;\r
+void *e;\r
+#endif\r
+{\r
+  SList *p, *tail;\r
+  require(e!=NULL, "slist_add: attempting to add NULL list element");\r
+\r
+  p = newSList;\r
+  require(p!=NULL, "slist_add: cannot alloc new list node");\r
+  p->elem = e;\r
+  if ( *list == NULL )\r
+  {\r
+    SList *sentinel = newSList;\r
+    require(sentinel!=NULL, "slist_add: cannot alloc sentinel node");\r
+    *list=sentinel;\r
+    sentinel->next = p;\r
+    sentinel->elem = (char *)p;    /* set tail pointer */\r
+  }\r
+  else                /* find end of list */\r
+  {\r
+    tail = (SList *) (*list)->elem;  /* get tail pointer */\r
+    tail->next = p;\r
+    (*list)->elem = (char *) p;    /* reset tail */\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+slist_free(SList *list)\r
+#else\r
+slist_free(list)\r
+SList *list;\r
+#endif\r
+{\r
+  SList *p,*q;\r
+\r
+  if ( list==NULL ) return;  /* empty list */\r
+  for (p = list->next; p!=NULL; p=q)\r
+  {\r
+    q = p->next;\r
+    free(p);\r
+  }\r
+}\r
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 (file)
index 0000000..c8a97b0
--- /dev/null
@@ -0,0 +1,78 @@
+/*\r
+ * sstack.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B\r
+ * Terence Parr\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-1994\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+#include <stdio.h>\r
+#include <setjmp.h>\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include <stdarg.h>\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#include "CASTBase.h"\r
+#include "sstack.h"\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+sstack_push( SStack **st, void *e )\r
+#else\r
+sstack_push( st, e )\r
+SStack **st;\r
+void *e;\r
+#endif\r
+{\r
+  SStack *p;\r
+  require(e!=NULL, "sstack_push: attempting to add NULL list element");\r
+\r
+  p = newSStack;\r
+  require(p!=NULL, "sstack_push: cannot alloc new list node");\r
+  p->elem = e;\r
+  p->next = *st;\r
+  *st = p;\r
+}\r
+\r
+void *\r
+#ifdef __USE_PROTOS\r
+sstack_pop( SStack **st )\r
+#else\r
+sstack_pop( st )\r
+SStack **st;\r
+#endif\r
+{\r
+  SStack *p = *st;\r
+  void *r;\r
+\r
+  *st = (*st)->next;\r
+  r = p->elem;\r
+  free(p);\r
+  return r;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/CommonTools.env b/EdkCompatibilityPkg/Sample/CommonTools.env
new file mode 100644 (file)
index 0000000..2d97156
--- /dev/null
@@ -0,0 +1,672 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    CommonTools.env \r
+#  \r
+#  Abstract:\r
+#  \r
+#    This file should not need to be customized. Customizations should\r
+#    be done in LocalTools.env if at all possible.\r
+#\r
+#    This file can be included by other makefiles. \r
+#   \r
+#    It defines variables used by the different toolchains. It first includes\r
+#    the user-customized LocalTools.env, and then uses those defines to \r
+#    define other variables.\r
+#\r
+#    It basically has sections for different toolchains which define variables\r
+#    used to build.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Everything depends on EDK_SOURCE. Make sure it's defined\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Tools depend on BUILD_DIR. Make sure it's defined\r
+#\r
+!IFNDEF BUILD_DIR\r
+!ERROR BUILD_DIR environmental variable not set.  Should be set in PlatformTools.env\r
+!ENDIF\r
+\r
+#\r
+# This include file gets customized by the developer. Get the customizations.\r
+#\r
+!INCLUDE $(EDK_SOURCE)\Sample\LocalTools.env\r
+\r
+################################################################################\r
+#\r
+# Define paths for EFI build tools\r
+#\r
+################################################################################\r
+!IFNDEF EDK_TOOLS_PATH\r
+EDK_TOOLS_BIN     = $(EDK_SOURCE)\Tools\Bin\r
+!ELSE\r
+EDK_TOOLS_BIN     = $(EDK_TOOLS_PATH)\Bin\r
+!ENDIF\r
+EDK_TOOLS_DIR     = $(EDK_SOURCE)\Sample\Tools\r
+EDK_TOOLS_SOURCE  = $(EDK_TOOLS_DIR)\Source\r
+EDK_TOOLS_COMMON  = $(EDK_TOOLS_DIR)\Source\Common\r
+EDK_TOOLS_OUTPUT  = $(BUILD_DIR)\Tools\r
+PCCTS_DIR         = $(EDK_SOURCE)\Other\Maintained\Tools\Pccts\r
+\r
+#\r
+# This include file gets some version info.\r
+#\r
+!INCLUDE $(EDK_SOURCE)\Sample\Version.env\r
+\r
+#\r
+# Macros to define the build tools\r
+#\r
+ANTLR           = $(PCCTS_DIR)\bin\antlr\r
+DLG             = $(PCCTS_DIR)\bin\dlg\r
+FWIMAGE         = $(EDK_TOOLS_OUTPUT)\FwImage\r
+GENDEPEX        = $(EDK_TOOLS_OUTPUT)\GenDepex\r
+GENFDIMAGE      = $(EDK_TOOLS_OUTPUT)\GenFdImage\r
+GENFFSFILE      = $(EDK_TOOLS_OUTPUT)\GenFfsFile\r
+GENFVIMAGE      = $(EDK_TOOLS_OUTPUT)\GenFvImage\r
+GENSECTION      = $(EDK_TOOLS_OUTPUT)\GenSection\r
+GUIDCHK         = $(EDK_TOOLS_OUTPUT)\GuidChk\r
+MAKEDEPS        = $(EDK_TOOLS_OUTPUT)\MakeDeps\r
+PROCESSDSC      = $(EDK_TOOLS_OUTPUT)\ProcessDsc\r
+STRGATHER       = $(EDK_TOOLS_OUTPUT)\StrGather\r
+SETSTAMP        = $(EDK_TOOLS_OUTPUT)\SetStamp\r
+VFRCOMPILE      = $(EDK_TOOLS_OUTPUT)\VfrCompile\r
+GENAPRIORI      = $(EDK_TOOLS_OUTPUT)\GenAprioriFile\r
+MODIFYINF       = $(EDK_TOOLS_OUTPUT)\ModifyInf\r
+\r
+MAKE            = nmake -nologo\r
+\r
+#\r
+# Everything else requires that TOOLCHAIN be defined. This should be defined\r
+# by the calling makefile. \r
+#\r
+!IFNDEF TOOLCHAIN\r
+!ERROR TOOLCHAIN not defined for $(EDK_SOURCE)\Sample\CommonTools.env\r
+!ENDIF\r
+\r
+###############################################################################\r
+#\r
+# Specify the path and macros for ASL tools\r
+#\r
+###############################################################################\r
+!IF "$(EFI_ASL_LOCAL)" == "YES"\r
+ASL               = $(ASLPATH)\Iasl\r
+!ELSE\r
+ASL               = $(EDK_TOOLS_BIN)\Iasl\r
+!ENDIF\r
+\r
+ASL_FLAGS         =\r
+C_FLAGS_ASL       = /nologo /EP /C\r
+\r
+###############################################################################\r
+#\r
+# Specify the path and macros for IA32 tools\r
+#\r
+###############################################################################\r
+\r
+!IF "$(TOOLCHAIN)" == "TOOLCHAIN_IA32"\r
+\r
+#\r
+# Globally relevant flags. Options not appropriate for all builds may be \r
+# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or\r
+# in the platform specific macros (xxx_PROJ_FLAGS)\r
+#\r
+C_STD_INCLUDE       = /X\r
+!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"\r
+!IF "$(USE_VC8)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ENDIF\r
+!ELSE\r
+!IF "$(USE_VC8)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /D USE_VC8 /c /Fo$@ $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC)\r
+!ENDIF\r
+!ENDIF\r
+ASM_STD_FLAGS       = /nologo $(INC) \r
+LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\IA32\CompilerStub.lib\r
+LIB_STD_FLAGS       = /nologo \r
+\r
+#\r
+# Build type specific flags.  Globally relevant flags belong in the standard \r
+# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the\r
+# PlatformTools.env file in macros named xxx_PROJ_FLAGS.\r
+#\r
+C_ARCH_FLAGS          = /D EFI32\r
+ASM_ARCH_FLAGS        = /W3 /WX /c /coff /Fo$@ /DEFI32\r
+LINK_ARCH_FLAGS       = /MACHINE:I386\r
+LIB_ARCH_FLAGS        =\r
+\r
+ASM16_FLAGS           = /nologo /c /omf /Fo$@\r
+ASMLINK16_FLAGS       =\r
+\r
+#\r
+# Build tools\r
+#\r
+CC                = cl\r
+LINK              = link\r
+LIB               = lib\r
+#\r
+# When using VS ml to compile 16bit code, please add /omf compiler option \r
+#\r
+ASM               = ml\r
+\r
+!IF "$(EFI_ASSEMBLER_NAME)" == ""\r
+ASM16             = $(MASMPATH)\bin\ml\r
+ASMLINK16         = $(MASMPATH)\binr\link\r
+ASMLINK           = $(MASMPATH)\binr\link\r
+!ELSE\r
+ASM16             = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml\r
+ASMLINK16         = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link\r
+ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link\r
+!ENDIF\r
+\r
+BSCMAKE           = bscmake\r
+\r
+!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
+ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG\r
+C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj\r
+LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG\r
+!ENDIF\r
+\r
+# END OF TOOLCHAIN_IA32\r
+###############################################################################\r
+\r
+###############################################################################\r
+#\r
+# Specify the path and macros for the X64 (also called x86-64, EM64T, AMD64) tools\r
+#\r
+###############################################################################\r
+\r
+!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_X64"\r
+\r
+#\r
+# Globally relevant flags. Options not appropriate for all builds may be \r
+# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or\r
+# in the platform specific macros (xxx_PROJ_FLAGS)\r
+#\r
+C_STD_INCLUDE       = /X\r
+!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /Gy /c /GS- /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) \r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /Gy /c /GS- /Fo$@ $(INC) \r
+!ENDIF\r
+ASM_STD_FLAGS       = /nologo $(INC)\r
+LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\X64\CompilerStub.lib\r
+LIB_STD_FLAGS       = /nologo \r
+\r
+#\r
+# Build type specific flags.  Globally relevant flags belong in the standard \r
+# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the\r
+# PlatformTools.env file in macros named xxx_PROJ_FLAGS.\r
+#\r
+C_ARCH_FLAGS          = /D EFIX64\r
+ASM_ARCH_FLAGS        = /W3 /WX /c /Fo$@ /DEFIX64\r
+LINK_ARCH_FLAGS       = /Machine:AMD64\r
+LIB_ARCH_FLAGS        =\r
+\r
+ASM16_FLAGS           = /nologo /c /omf /Fo$@\r
+ASMLINK16_FLAGS       =\r
+\r
+#\r
+# Build tools\r
+#\r
+!IF "$(EFI_COMPILER_X64_NAME)" == ""\r
+!IF "$(USE_VC8_X64)" == "YES"\r
+#\r
+# Use VC8 as X64 compiler\r
+#\r
+CC                = "$(VC8_X64_PATH)\cl"\r
+LINK              = "$(VC8_X64_PATH)\link"\r
+LIB               = "$(VC8_X64_PATH)\lib"\r
+ASM               = "$(VC8_X64_PATH)\ml64"\r
+!ELSE\r
+#\r
+# Use DDK as X64 compiler\r
+#\r
+CC                = $(WIN_DDK_X64_PATH)\cl\r
+LINK              = $(WIN_DDK_X64_PATH)\link\r
+LIB               = $(WIN_DDK_X64_PATH)\lib\r
+ASM               = $(WIN_DDK_X64_PATH)\ml64\r
+!ENDIF\r
+!ELSE\r
+CC                = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\cl\r
+LINK              = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\link\r
+LIB               = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\lib\r
+ASM               = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\ml64\r
+!ENDIF\r
+\r
+!IF "$(EFI_ASSEMBLER_NAME)" == ""\r
+ASM16             = $(MASMPATH)\bin\ml\r
+ASMLINK16         = $(MASMPATH)\binr\link\r
+ASMLINK           = $(MASMPATH)\binr\link\r
+!ELSE\r
+ASM16             = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml\r
+ASMLINK16         = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link\r
+ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link\r
+!ENDIF\r
+\r
+BSCMAKE           = bscmake\r
+\r
+!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
+ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG\r
+C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj\r
+LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG\r
+!ENDIF\r
+\r
+# END OF TOOLCHAIN_X64\r
+###############################################################################\r
+\r
+###############################################################################\r
+#\r
+# Specify the path and macros for the IPF tools\r
+#\r
+###############################################################################\r
+\r
+!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_IPF"\r
+\r
+#\r
+# Globally relevant flags. Options not appropriate for all builds may be \r
+# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or\r
+# in the platform specific macros (xxx_PROJ_FLAGS)\r
+#\r
+C_STD_INCLUDE       = /X\r
+!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"\r
+!IF "$(USE_VC8_IPF)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ELSE\r
+!IF "$(USE_NEWDDK)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ENDIF\r
+!ENDIF\r
+!ELSE\r
+!IF "$(USE_VC8_IPF)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fo$@ $(INC)\r
+!ELSE\r
+!IF "$(USE_NEWDDK)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fo$@ $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC)\r
+!ENDIF\r
+!ENDIF\r
+!ENDIF\r
+\r
+ASM_STD_FLAGS       = $(INC) \r
+LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108\r
+LIB_STD_FLAGS       = /nologo \r
+\r
+#\r
+# Build type specific flags.  Globally relevant flags belong in the standard \r
+# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the\r
+# PlatformTools.env file in macros named xxx_PROJ_FLAGS.\r
+#\r
+C_ARCH_FLAGS          = /D EFI64\r
+ASM_ARCH_FLAGS        = -N us -X explicit -M ilp64 -N so -W4 -o $@\r
+LINK_ARCH_FLAGS       = /MACHINE:IA64\r
+LIB_ARCH_FLAGS        =\r
+\r
+#\r
+# This is used for preprocessing IPF Assembly files\r
+#\r
+C_FLAGS_PRO       = /nologo /EP /C $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE)\r
+\r
+!IF "$(EFI_DEBUG)" == "YES"\r
+ASM_ARCH_FLAGS   = $(ASM_ARCH_FLAGS) -d debug\r
+!ENDIF\r
+\r
+#\r
+# Build tools\r
+#\r
+!IF "$(EFI_COMPILER_NAME)" == ""\r
+!IF "$(USE_VC8_IPF)" == "YES"\r
+CC                = "$(VC8_IPF_PATH)\cl"\r
+LINK              = "$(VC8_IPF_PATH)\link"\r
+LIB               = "$(VC8_IPF_PATH)\lib"\r
+!ELSE\r
+CC                = $(EFI_IA64TOOLPATH)\cl\r
+LINK              = $(EFI_IA64TOOLPATH)\link\r
+LIB               = $(EFI_IA64TOOLPATH)\lib\r
+!ENDIF\r
+!ELSE\r
+CC                = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\cl\r
+LINK              = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\link\r
+LIB               = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\lib\r
+!ENDIF\r
+\r
+!IF "$(EFI_ASSEMBLER_NAME)" == ""\r
+!IF "$(USE_VC8_IPF)" == "YES"\r
+ASM               = "$(VC8_IPF_PATH)\ias"\r
+ASMLINK           = "$(VC8_IPF_PATH)\link"\r
+!ELSE\r
+ASM               = $(EFI_IA64ASMPATH)\ias\r
+ASMLINK           = $(EFI_IA64ASMPATH)\link\r
+!ENDIF\r
+!ELSE\r
+ASM               = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\ias\r
+ASMLINK           = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link\r
+!ENDIF\r
+\r
+BSCMAKE           = bscmake\r
+\r
+!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
+C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj\r
+LINK_STD_FLAGS      = $(LINK_STD_FLAGS) /DEBUG\r
+!ENDIF\r
+\r
+# END TOOLCHAIN_IPF\r
+###############################################################################\r
+\r
+###############################################################################\r
+#\r
+# Define toolchain for building the EFI tools on an IA32 system.\r
+#\r
+###############################################################################\r
+\r
+!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_MSVC"\r
+\r
+#\r
+# Globally relevant flags. Options not appropriate for all builds may be \r
+# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or\r
+# in the platform specific macros (xxx_PROJ_FLAGS)\r
+#\r
+!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"\r
+!IF "$(USE_VC8)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC)\r
+!ENDIF\r
+!ELSE\r
+!IF "$(USE_VC8)" == "YES"\r
+C_STD_FLAGS         = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fo$@ $(INC)\r
+!ELSE\r
+C_STD_FLAGS         = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC)\r
+!ENDIF\r
+!ENDIF\r
+ASM_STD_FLAGS       = /nologo $(INC)\r
+LINK_STD_FLAGS      = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF\r
+LIB_STD_FLAGS       = /nologo \r
+\r
+MSVS_LINK_LIBPATHS = \r
+\r
+#\r
+# Build type specific flags.  Globally relevant flags belong in the standard \r
+# macros, xxx_STD_FLAGS defined above.  Platform specific macros belong in the\r
+# PlatformTools.env file in macros named xxx_PROJ_FLAGS.\r
+#\r
+\r
+#\r
+# Add a define to skip inclusion of Microsoft include file rpcasync.h, which\r
+# results in a compile warning at W4.\r
+#\r
+C_ARCH_FLAGS          = /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D __RPCASYNC_H__ \r
+ASM_ARCH_FLAGS        =\r
+LINK_ARCH_FLAGS       = /MACHINE:i386\r
+LIB_ARCH_FLAGS        =\r
+\r
+#\r
+# Always turn on debug for the build tools so that we can debug problems \r
+# quickly.\r
+# NOTE: Ideally all the tools makefiles should be updated to use LINK_FLAGS_EXE\r
+#       instead of L_FLAGS for linking. When this happens we can get rid of\r
+#       the L_FLAGS definition here.\r
+#\r
+\r
+#!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
+C_STD_FLAGS       = $(C_STD_FLAGS) /Zi /Gm /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj\r
+LINK_ARCH_FLAGS   = $(LINK_ARCH_FLAGS) /DEBUG\r
+L_FLAGS           = $(L_FLAGS) /DEBUG\r
+#!ENDIF\r
+\r
+#\r
+# Clear any project flags when building tools\r
+#\r
+C_PROJ_FLAGS          =\r
+ASM_PROJ_FLAGS        =\r
+LINK_PROJ_FLAGS       =\r
+LIB_PROJ_FLAGS        =\r
+EBC_C_PROJ_FLAGS      =\r
+EBC_LINK_PROJ_FLAGS   =\r
+EBC_LIB_PROJ_FLAGS    =\r
+\r
+#\r
+# Build tools\r
+#\r
+CC                = cl\r
+LINK              = link\r
+BSCMAKE           = bscmake\r
+ASM               = ml\r
+ASMLINK           = link\r
+#\r
+# Use a different macro name for tools build to avoid conflict with environment\r
+# variable LIB\r
+#\r
+LIB_EXE           = lib\r
+\r
+INC = -I $(EDK_SOURCE)\Foundation                          \\r
+      -I $(EDK_SOURCE)\Foundation\Efi                      \\r
+      -I $(EDK_SOURCE)\Foundation\Framework                \\r
+      -I $(EDK_SOURCE)\Sample\Platform\Nt32                \\r
+      -I $(EDK_SOURCE)\Foundation\Core\Dxe                 \\r
+      -I $(EDK_SOURCE)\Foundation\Include                  \\r
+      -I $(EDK_SOURCE)\Foundation\Efi\Include              \\r
+      -I $(EDK_SOURCE)\Foundation\Framework\Include        \\r
+      -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard \\r
+      -I $(EDK_SOURCE)\Foundation\Include\Ia32             \\r
+      -I $(EDK_SOURCE)\Foundation\Include\Pei              \\r
+      -I $(EDK_SOURCE)\Foundation\Library\Pei\Include      \\r
+      -I $(EDK_SOURCE)\Sample\Include                      \\r
+      -I "$(EDK_TOOLS_COMMON)"\r
+\r
+# END TOOLCHAIN_MSVC\r
+###############################################################################\r
+\r
+###############################################################################\r
+#\r
+# Specify the path and macros for the EBC tools\r
+#\r
+###############################################################################\r
+\r
+!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_EBC"\r
+\r
+!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES"\r
+EBC_C_STD_FLAGS     = /nologo /W3 /WX /c /Fa$* /FAsc /Fo$@ $(INC) /X\r
+!ELSE\r
+EBC_C_STD_FLAGS     = /nologo /W3 /WX /c /Fo$@ $(INC) /X\r
+!ENDIF\r
+\r
+#\r
+# All EBC entry point functions must be called EfiMain. Redefine it.\r
+#\r
+!IF "$(IMAGE_ENTRY_POINT)" == ""\r
+IMAGE_ENTRY_POINT   = EfiMain\r
+!ENDIF\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /D $(IMAGE_ENTRY_POINT)=EfiMain\r
+EBC_LINK_STD_FLAGS  = /nologo /MACHINE:EBC /BASE:0 /OPT:REF /NODEFAULTLIB\r
+EBC_LIB_STD_FLAGS   = /nologo /MACHINE:EBC \r
+\r
+#\r
+# EBC tools path should be defined in LocalTools.env.\r
+#\r
+EBC_CC            = $(EBC_TOOLS_PATH)\Bin\Iec\r
+EBC_LINK          = $(EBC_TOOLS_PATH)\Bin\Link\r
+EBC_LIB           = $(EBC_TOOLS_PATH)\Bin\Link /lib\r
+\r
+!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /Zd /Zi\r
+EBC_LINK_STD_FLAGS  = $(EBC_LINK_STD_FLAGS) /DEBUG\r
+!ENDIF\r
+\r
+#  END TOOLCHAIN_EBC\r
+\r
+###############################################################################\r
+#\r
+# Let the caller define a NULL toolchain if they don't care. This way you can\r
+# pick up at least some defines.\r
+#\r
+###############################################################################\r
+\r
+!ELSEIF "$(TOOLCHAIN)" == ""\r
+\r
+###############################################################################\r
+#\r
+# You get this if the calling makefile did not define TOOLCHAIN_xxx before\r
+# including this file.\r
+#\r
+###############################################################################\r
+\r
+!ELSE\r
+!ERROR Unknown toolchain $(TOOLCHAIN) defined for $(EDK_SOURCE)\Sample\CommonTools.env use\r
+!ENDIF\r
+\r
+\r
+###############################################################################\r
+#\r
+# These are standard settings for all tool chains\r
+#\r
+###############################################################################\r
+\r
+#\r
+# These are standard build options\r
+#\r
+VERSION_FLAGS       = /D EFI_SPECIFICATION_VERSION=$(EFI_SPECIFICATION_VERSION) \\r
+                      /D PI_SPECIFICATION_VERSION=$(PI_SPECIFICATION_VERSION) \\r
+                      /D TIANO_RELEASE_VERSION=$(TIANO_RELEASE_VERSION)\r
+C_STD_FLAGS         = $(C_STD_FLAGS) $(VERSION_FLAGS)\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) $(VERSION_FLAGS)\r
+VFRCOMPILE_FLAGS    = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)"\r
+\r
+!IF "$(EFI_DEBUG)" == "YES"\r
+C_STD_FLAGS         = $(C_STD_FLAGS) /D EFI_DEBUG\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /D EFI_DEBUG\r
+VFRCOMPILE_FLAGS    = $(VFRCOMPILE_FLAGS) -ppflag "/D EFI_DEBUG"\r
+!ENDIF\r
+\r
+!IF "$(EFI_DEBUG_CLEAR_MEMORY)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_DEBUG_CLEAR_MEMORY\r
+!ENDIF\r
+\r
+!IF "$(EFI_PEI_PERFORMANCE)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_PEI_PERFORMANCE /D EFI_DXE_PERFORMANCE\r
+!ENDIF\r
+\r
+!IF "$(EFI_ADDTIONAL_DRIVERS)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_ADDTIONAL_DRIVERS\r
+!ENDIF\r
+\r
+!IF "$(EFI_USE_CUSTOM_COMPRESS)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_USE_CUSTOM_COMPRESS\r
+!ENDIF\r
+\r
+!IF "$(EFI_UNLOCK_FWH)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_UNLOCK_FWH\r
+!ENDIF\r
+\r
+!IF "$(EFI_DXE_PERFORMANCE)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_DXE_PERFORMANCE\r
+!ENDIF\r
+\r
+!IF "$(EFI_DEBUG_SERIAL_PRINT)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_DEBUG_SERIAL_PRINT\r
+!ENDIF\r
+\r
+!IF "$(EFI_S3_RESUME)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_S3_RESUME\r
+!ENDIF\r
+\r
+!IF "$(EFI_PEI_REPORT_STATUS_CODE)" == "YES"\r
+C_STD_FLAGS     = $(C_STD_FLAGS) /D EFI_PEI_REPORT_STATUS_CODE_ON\r
+!ENDIF\r
+\r
+###############################################################################\r
+\r
+###############################################################################\r
+#\r
+# Collect final build flags for components.  These flags are used to build\r
+# any standard component and some non-standard components.\r
+#\r
+###############################################################################\r
+C_FLAGS           = $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE)\r
+ASM_FLAGS         = $(ASM_STD_FLAGS) $(ASM_ARCH_FLAGS) $(ASM_PROJ_FLAGS)\r
+LINK_FLAGS_DLL    = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) /DLL \r
+LINK_FLAGS_EXE    = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) \r
+LIB_FLAGS         = $(LIB_STD_FLAGS) $(LIB_ARCH_FLAGS) $(LIB_PROJ_FLAGS)\r
+EBC_C_FLAGS       = $(EBC_C_STD_FLAGS) $(EBC_C_ARCH_FLAGS) $(EBC_C_PROJ_FLAGS)\r
+EBC_LINK_FLAGS    = $(EBC_LINK_STD_FLAGS) $(EBC_LINK_ARCH_FLAGS) $(EBC_LINK_PROJ_FLAGS)\r
+EBC_LIB_FLAGS     = $(EBC_LIB_STD_FLAGS) $(EBC_LIB_ARCH_FLAGS) $(EBC_LIB_PROJ_FLAGS)\r
+\r
+###############################################################################\r
+#\r
+# define X64 denpendant driver files\r
+#\r
+###############################################################################\r
+!IF "$(EFI_BUILD_TARGET_X64)" == "YES"\r
+BUILD_TARGET_PROCESSOR = X64\r
+DXE_IPL                = DxeIplX64\r
+!ELSE\r
+BUILD_TARGET_PROCESSOR = IA32\r
+DXE_IPL                = DxeIpl\r
+!ENDIF                                                                                        \r
+###############################################################################\r
+#\r
+# define EFI specification denpendant driver files\r
+#\r
+###############################################################################\r
+!IF "$(UEFI_MODE)" == "YES"\r
+UEFI_PREFIX = Uefi\r
+ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiExtPassThru\Dxe\AtapiExtPassThru.inf\r
+!IF "$(CAPSULE_INF)" == ""\r
+CAPSULE_INF = Sample\Universal\Capsule\RuntimeDxe\Capsule.inf \r
+!ENDIF\r
+DEVPATH_INF = Sample\Universal\DevicePath\Dxe\DevicePath.inf\r
+!ELSE\r
+UEFI_PREFIX =\r
+CAPSULE_INF =\r
+DEVPATH_INF =\r
+ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiPassThru\Dxe\AtapiPassThru.inf\r
+!ENDIF\r
+###############################################################################\r
+#\r
+# define PIWG specification denpendant driver files\r
+#\r
+###############################################################################\r
+!IF "$(PI_MODE)" == "YES"\r
+PI_PREFIX = Pi\r
+!ELSE\r
+PI_PREFIX =\r
+!ENDIF\r
+###############################################################################\r
+#\r
+# define customized compress makefile\r
+#\r
+###############################################################################\r
+CUSTOMIZEDCOMPRESS_MAKEFILE   = $(EDK_TOOLS_SOURCE)\CustomizedCompress\Makefile \r
+COMPRESS_METHOD               = Dummy                                                 \r
+###############################################################################         \r
+#                                                                                       \r
+# define EFI_BINARY default path\r
+#                                                                                       \r
+###############################################################################  \r
+!IFNDEF EFI_BINARY\r
+EFI_BINARY=$(EDK_TOOLS_OUTPUT)\Bin\r
+!ENDIF\r
+\r
+EFI_PLATFORM_BIN=$(EFI_BINARY)\$(PROJECT_NAME)$(BUILD_TARGET_DIRECTORY)\r
diff --git a/EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h b/EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h
new file mode 100644 (file)
index 0000000..031a1d9
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Efi2WinNT.h\r
+\r
+Abstract:\r
+\r
+  Tiano mechanism to create WIN32 EFI code.\r
+\r
+  Only used for NT emulation environment. This file replaces the Tiano.h\r
+  when you need to access Win32 stuff in EFI.\r
+\r
+  Don't access Win32 APIs directly allways go WinNtThunk protocol.\r
+\r
+  In most envirnments gWinNt is a pointer to a EFI_WIN_NT_THUNK_PROTOCOL.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_WIN_NT_H_\r
+#define _EFI_WIN_NT_H_\r
+\r
+//\r
+// Win32 include files do not compile clean with /W4, so we use the warning\r
+// pragma to suppress the warnings for Win32 only. This way our code can stil\r
+// compile at /W4 (highest warning level) with /WX (warnings cause build\r
+// errors).\r
+//\r
+#pragma warning(disable : 4115)\r
+#pragma warning(disable : 4201)\r
+#pragma warning(disable : 4214)\r
+#pragma warning(disable : 4028)\r
+#pragma warning(disable : 4133)\r
+\r
+#include "windows.h"\r
+\r
+//\r
+// Set the warnings back on so the EFI code must be /W4.\r
+//\r
+#pragma warning(default : 4115)\r
+#pragma warning(default : 4201)\r
+#pragma warning(default : 4214)\r
+//\r
+// We replaced Tiano.h so we must include it.\r
+//\r
+#include "Tiano.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (WinNtThunk)\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h b/EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h
new file mode 100644 (file)
index 0000000..7159588
--- /dev/null
@@ -0,0 +1,58 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompNameSupport.h\r
+\r
+Abstract:\r
+\r
+  Private data structures for the Console Splitter driver\r
+\r
+--*/\r
+\r
+#ifndef EFI_COMPONENT_NAME_SUPPORT_H\r
+#define EFI_COMPONENT_NAME_SUPPORT_H\r
+\r
+#include "Tiano.h"\r
+\r
+#ifndef EFI_SIZE_REDUCTION_APPLIED\r
+\r
+#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle,               \\r
+                                     SystemTable,               \\r
+                                     DriverBinding,             \\r
+                                     DriverBindingHandle,       \\r
+                                     ComponentName,             \\r
+                                     DriverConfiguration,       \\r
+                                     DriverDiagnostics)         \\r
+        EfiLibInstallAllDriverProtocols ((ImageHandle),         \\r
+                                         (SystemTable),         \\r
+                                         (DriverBinding),       \\r
+                                         (DriverBindingHandle), \\r
+                                         (ComponentName),       \\r
+                                         (DriverConfiguration), \\r
+                                         (DriverDiagnostics))\r
+#else\r
+\r
+#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle,             \\r
+                                     SystemTable,             \\r
+                                     DriverBinding,           \\r
+                                     DriverBindingHandle,     \\r
+                                     ComponentName,           \\r
+                                     DriverConfiguration,     \\r
+                                     DriverDiagnostics)       \\r
+        EfiLibInstallDriverBinding ((ImageHandle),            \\r
+                                    (SystemTable),            \\r
+                                    (DriverBinding),          \\r
+                                    (DriverBindingHandle))\r
+#endif\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Include/EfiWinNt.h b/EdkCompatibilityPkg/Sample/Include/EfiWinNt.h
new file mode 100644 (file)
index 0000000..7722e6a
--- /dev/null
@@ -0,0 +1,46 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiWinNt.h\r
+\r
+Abstract:\r
+\r
+  EFI master include file for WinNt components.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_WIN_NT_H_\r
+\r
+#ifdef EFI_NT_EMULATOR\r
+\r
+#define _EFI_WIN_NT_H_\r
+\r
+#pragma warning(disable : 4115)\r
+#pragma warning(disable : 4201)\r
+#pragma warning(disable : 4214)\r
+\r
+#include "windows.h"\r
+#include "stdio.h"\r
+\r
+//\r
+// Set the warnings back on so the EFI code must be /W4.\r
+//\r
+#pragma warning(default : 4115)\r
+#pragma warning(default : 4201)\r
+#pragma warning(default : 4214)\r
+\r
+#endif\r
+\r
+#include "Tiano.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c
new file mode 100644 (file)
index 0000000..f883a9c
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WinNtLib.c\r
+\r
+Abstract:\r
+\r
+  Setup gWinNt global \r
+\r
+--*/\r
+\r
+#include "Efi2WinNT.h"\r
+#include "EfiWinNtLib.h"\r
+#include "EfiDriverLib.h"\r
+#include "EfiHobLib.h"\r
+#include EFI_GUID_DEFINITION (Hob)\r
+\r
+EFI_WIN_NT_THUNK_PROTOCOL *gWinNt;\r
+\r
+EFI_GUID                  mEfiHobListGuid = EFI_HOB_LIST_GUID;\r
+\r
+EFI_STATUS\r
+EfiInitializeWinNtDriverLib (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Intialize gWinNt and initialize debug console. \r
+\r
+Arguments:\r
+\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    ImageHandle - add argument and description to function comment\r
+// TODO:    SystemTable - add argument and description to function comment\r
+// TODO:    EFI_NOT_FOUND - add return value to function comment\r
+// TODO:    EFI_NOT_FOUND - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  VOID        *HobList;\r
+  VOID        *Pointer;\r
+\r
+  Status = EfiLibGetSystemConfigurationTable (&mEfiHobListGuid, &HobList);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  ASSERT (NULL != HobList);\r
+  Status = GetNextGuidHob (&HobList, &gEfiWinNtThunkProtocolGuid, &Pointer, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  gWinNt = (VOID *) (*(UINTN *) (Pointer));\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf
new file mode 100644 (file)
index 0000000..bbadcb9
--- /dev/null
@@ -0,0 +1,49 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    WinNtLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME         = WinNtLib\r
+COMPONENT_TYPE    = LIBRARY\r
+\r
+[sources.common]\r
+  WinNtLib.c\r
+  \r
+[libraries.common]\r
+  HobLib\r
+  EdkNt32ProtocolLib\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Sample\Platform\Nt32\r
+  $(EDK_SOURCE)\Foundation\Framework\r
+  $(EDK_SOURCE)\Foundation\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  .\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Sample\Include\r
+\r
+\r
+[nmake.common]\r
+C_STD_INCLUDE=\r
diff --git a/EdkCompatibilityPkg/Sample/LocalTools.env b/EdkCompatibilityPkg/Sample/LocalTools.env
new file mode 100644 (file)
index 0000000..e5fe750
--- /dev/null
@@ -0,0 +1,95 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#\r
+#    LocalTools.env\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is included by CommonTools.env, which is included by \r
+#    makefiles when building.\r
+#   \r
+#    It can be customized to identify the locations of the tools \r
+#    necessary to build the EFI source code for different systems. \r
+#   \r
+#--*/\r
+\r
+# \r
+# Customize to define the base path to MASM for IA32\r
+#\r
+!IFNDEF MASMPATH\r
+MASMPATH   = c:\masm611\r
+!ENDIF\r
+\r
+# \r
+# Customize to define the base path to iASL\r
+#\r
+!IFNDEF ASLPATH\r
+ASLPATH   = c:\Asl\r
+!ENDIF\r
+\r
+#\r
+# Customize to define the base path to the tools for IPF\r
+#\r
+!IFNDEF EFI_IA64TOOLPATH\r
+!IF "$(USE_NEWDDK)" == "YES"\r
+EFI_IA64TOOLPATH  = C:\WINDDK\3790.1830\bin\win64\x86\r
+!ELSE\r
+EFI_IA64TOOLPATH  = C:\DDK3790\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IFNDEF EFI_IA64ASMPATH\r
+!IF "$(USE_NEWDDK)" == "YES"\r
+EFI_IA64ASMPATH   = C:\WINDDK\3790.1830\bin\win64\x86\r
+!ELSE\r
+EFI_IA64ASMPATH   = C:\DDK3790\r
+!ENDIF\r
+!ENDIF\r
+\r
+# \r
+# Customize to define the base path to the EBC tools\r
+#\r
+!IFNDEF EBC_TOOLS_PATH\r
+EBC_TOOLS_PATH  = c:\progra~1\intel\ebc\r
+!ENDIF\r
+\r
+#\r
+# Customize to define the base path to WINDDK for X64\r
+#\r
+!IFNDEF WIN_DDK_PATH\r
+WIN_DDK_X64_PATH = C:\WINDDK\3790.1830\bin\win64\x86\amd64\r
+!ELSE\r
+WIN_DDK_X64_PATH = $(WIN_DDK_PATH)\bin\win64\x86\amd64\r
+!ENDIF\r
+\r
+#\r
+# Customize to define the base path to VC8 for X64\r
+#\r
+!IF "$(USE_VC8_X64)" == "YES"\r
+!IFNDEF VCINSTALLDIR\r
+VC8_X64_PATH = c:\Program Files\Microsoft Visual Studio 8\VC\bin\x86_amd64\r
+!ELSE\r
+VC8_X64_PATH = $(VCINSTALLDIR)\bin\x86_amd64\r
+!ENDIF\r
+!ENDIF\r
+\r
+#\r
+# Customize to define the base path to VC8 for IPF\r
+#\r
+!IF "$(USE_VC8_IPF)" == "YES"\r
+!IFNDEF VCINSTALLDIR\r
+VC8_IPF_PATH = c:\Program Files\Microsoft Visual Studio 8\VC\bin\x86_ia64\r
+!ELSE\r
+VC8_IPF_PATH = $(VCINSTALLDIR)\bin\x86_ia64\r
+!ENDIF\r
+!ENDIF\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Common.dsc b/EdkCompatibilityPkg/Sample/Platform/Common.dsc
new file mode 100644 (file)
index 0000000..c40c4e7
--- /dev/null
@@ -0,0 +1,1522 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    Common.dsc\r
+#\r
+#  Abstract:\r
+#\r
+#    This is the build description file containing the platform\r
+#    independent build instructions.  Platform specific instructions will\r
+#    be prepended to produce the final build DSC file.\r
+#\r
+#\r
+#  Notes:\r
+#    \r
+#    The info in this file is broken down into sections. The start of a section\r
+#    is designated by a "[" in the first column. So the [=====] separater ends\r
+#    a section.\r
+#    \r
+#--*/\r
+\r
+[=============================================================================]\r
+#\r
+# These get emitted at the top of the generated master makefile. \r
+#\r
+[=============================================================================]\r
+[Makefile.out]\r
+#\r
+# From the [makefile.out] section of the DSC file\r
+#\r
+TOOLCHAIN = \r
+MAKE      = nmake -nologo\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+all : libraries fvs\r
+\r
+[=============================================================================]\r
+#\r
+# These get expanded and dumped out to each component makefile after the\r
+# component INF [defines] section gets parsed.\r
+#\r
+[=============================================================================]\r
+[Makefile.Common]\r
+#\r
+# From the [Makefile.Common] section of the description file.\r
+#\r
+PROCESSOR        = $(PROCESSOR)\r
+BASE_NAME        = $(BASE_NAME)\r
+BUILD_NUMBER     = $(BUILD_NUMBER)\r
+VERSION_STRING   = $(VERSION_STRING)\r
+TOOLCHAIN        = TOOLCHAIN_$(PROCESSOR)\r
+FILE_GUID        = $(FILE_GUID)\r
+COMPONENT_TYPE   = $(COMPONENT_TYPE)\r
+FV_DIR           = $(BUILD_DIR)\FV\r
+PLATFORM         = $(PROJECT_NAME) \r
+\r
+#\r
+# Define the global dependency files\r
+#\r
+!IF EXIST ($(DEST_DIR)\$(BASE_NAME)StrDefs.h)\r
+INC_DEPS         = $(INC_DEPS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+!ENDIF\r
+#ENV_DEPS         = $(ENV_DEPS) $(EDK_SOURCE)\Sample\CommonTools.env\r
+#ENV_DEPS         = $(ENV_DEPS) $(BUILD_DIR)\PlatformTools.env\r
+#ENV_DEPS         = $(ENV_DEPS) $(BUILD_DIR)\Config.env\r
+ALL_DEPS         = $(INC_DEPS) $(ENV_DEPS)\r
+\r
+!IF "$(LANGUAGE)" != ""\r
+LANGUAGE_FLAGS    = -lang $(LANGUAGE)\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" || "$(COMPONENT_TYPE)" == "PE32_PEIM" || "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" || "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"\r
+DEPEX_TYPE = EFI_SECTION_PEI_DEPEX\r
+!ELSE\r
+DEPEX_TYPE = EFI_SECTION_DXE_DEPEX\r
+!ENDIF\r
+\r
+#\r
+# Command flags for MAKEDEPS tool\r
+#\r
+DEP_FLAGS = -target $** -o $(DEP_FILE) $(INC) -ignorenotfound -q\r
+\r
+[=============================================================================]\r
+#\r
+# These are the commands to compile source files. One of these blocks gets \r
+# emitted to the component's makefile for each source file. The section\r
+# name is encoded as [Compile.$(PROCESSOR).source_filename_extension], where\r
+# the source filename comes from the sources section of the component INF file.\r
+#\r
+# If the dependency list file already exists, then include it for this \r
+# source file. If it doesn't exist, then this is a clean build and the\r
+# dependency file will get created below and the source file will get \r
+# compiled. \r
+#\r
+# Current behavior is that the first clean build will not create dep files. \r
+# But the following second build has to create dep files before build source files.\r
+# CREATEDEPS flag is used to judge whether current build is the second build or not.\r
+#\r
+#\r
+[=============================================================================]\r
+[Compile.Ia32.asm,Compile.x64.asm]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Asm.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Asm.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) -asm\r
+\r
+#\r
+# Compile the file\r
+#\r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(ASM) $(ASM_FLAGS) $(SOURCE_FILE_NAME)\r
+\r
+[=============================================================================]\r
+[Compile.Ipf.s]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)S.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).pro)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)S.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).pro\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+#\r
+# Compile the file\r
+#\r
+$(DEST_DIR)\$(FILE).pro : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(CC) $(C_FLAGS_PRO) $(SOURCE_FILE_NAME) > $@\r
+\r
+$(DEST_DIR)\$(FILE).obj : $(DEST_DIR)\$(FILE).pro\r
+  $(ASM) $(ASM_FLAGS) $(DEST_DIR)\$(FILE).pro\r
+\r
+[=============================================================================]\r
+[Compile.Ia32.c,Compile.Ipf.c,Compile.x64.c]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE).dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+#\r
+# Compile the file\r
+#\r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(CC) $(C_FLAGS) $(SOURCE_FILE_NAME)\r
+\r
+[=============================================================================]\r
+[Compile.Ebc.c]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE).dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+#\r
+# Compile the file\r
+#\r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(EBC_CC) $(EBC_C_FLAGS) $(SOURCE_FILE_NAME)\r
+\r
+[=============================================================================]\r
+#\r
+# Commands for compiling a ".apr" Apriori source file.\r
+#\r
+[=============================================================================]\r
+[Compile.Ia32.Apr,Compile.Ipf.Apr,Compile.Ebc.Apr,Compile.x64.Apr]\r
+#\r
+# Create the raw binary file. If you get an error on the build saying it doesn't\r
+# know how to create the .apr file, then you're missing (or mispelled) the\r
+# "APRIORI=" on the component lines in components section in the DSC file.\r
+#\r
+$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)\r
+  $(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin\r
+\r
+$(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin\r
+  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW\r
+\r
+[=============================================================================]\r
+[Build.Ia32.Apriori,Build.Ipf.Apriori,Build.Ebc.Apriori,Build.x64.Apriori]\r
+\r
+all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS\r
+\r
+#\r
+# Run GenFfsFile on the package file and .raw file to create the firmware file\r
+#\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS : $(DEST_DIR)\$(BASE_NAME).sec $(PACKAGE_FILENAME)\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+[Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile]\r
+\r
+#\r
+# Copy the makefile directly from the source directory, then make it\r
+# writable so we can copy over it later if we try to.\r
+#\r
+$(DEST_DIR)\makefile.new : $(SOURCE_DIR)\makefile.new\r
+  copy $(SOURCE_DIR)\makefile.new $(DEST_DIR)\makefile.new\r
+  attrib -r $(DEST_DIR)\makefile.new\r
+\r
+#\r
+# Make the all target, set some required macros.\r
+#\r
+call_makefile :\r
+  $(MAKE) -f $(DEST_DIR)\makefile.new all   \\r
+          SOURCE_DIR=$(SOURCE_DIR)          \\r
+          BUILD_DIR=$(BUILD_DIR)            \\r
+          FILE_GUID=$(FILE_GUID)            \\r
+          DEST_DIR=$(DEST_DIR)              \\r
+          PROCESSOR=$(PROCESSOR)            \\r
+          TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)  \\r
+          BASE_NAME=$(BASE_NAME)            \\r
+          PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
+\r
+all : $(DEST_DIR)\makefile.new call_makefile\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+  @- $(MAKE) -f $(DEST_DIR)\makefile.new clean > NUL 2>&1\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# Instructions for building a component that uses a custom makefile. Encoding \r
+# is [build.$(PROCESSOR).$(BUILD_TYPE)].\r
+#\r
+# To build these components, simply call the makefile from the source \r
+# directory.\r
+#\r
+[=============================================================================]\r
+[Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile]\r
+\r
+#\r
+# Just call the makefile from the source directory, passing in some\r
+# useful info.\r
+#\r
+all : \r
+  $(MAKE) -f $(SOURCE_DIR)\makefile all    \\r
+          SOURCE_DIR=$(SOURCE_DIR)         \\r
+          BUILD_DIR=$(BUILD_DIR)           \\r
+          DEST_DIR=$(DEST_DIR)             \\r
+          FILE_GUID=$(FILE_GUID)           \\r
+          PROCESSOR=$(PROCESSOR)           \\r
+          TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \\r
+          BASE_NAME=$(BASE_NAME)           \\r
+          PLATFORM=$(PLATFORM)             \\r
+          SOURCE_FV=$(SOURCE_FV)           \\r
+          PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+  @- $(MAKE) -f $(SOURCE_DIR)\makefile clean > NUL 2>&1\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# These commands are used to build libraries\r
+#\r
+[=============================================================================]\r
+[Build.Ia32.LIBRARY,Build.Ipf.LIBRARY,Build.x64.LIBRARY]\r
+#\r
+# LIB all the object files into to our target lib file. Put\r
+# a dependency on the component's INF file in case it changes.\r
+#\r
+LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib\r
+\r
+$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)\r
+  $(LIB) $(LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@\r
+\r
+!IF "$(CREATEDEPS)"=="YES"\r
+all : $(DEP_TARGETS)\r
+  $(MAKE) -f $(MAKEFILE_NAME) all\r
+!ELSE\r
+all : $(LIB_NAME) $(DEP_TARGETS)\r
+!ENDIF\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+[Build.Ebc.LIBRARY]\r
+#\r
+# LIB all the object files into to our target lib file. Put\r
+# a dependency on the component's INF file in case it changes.\r
+#\r
+LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib\r
+\r
+$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)\r
+   $(EBC_LIB) $(EBC_LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@\r
+\r
+!IF "$(CREATEDEPS)"=="YES"\r
+all : $(DEP_TARGETS)\r
+  $(MAKE) -f $(MAKEFILE_NAME) all\r
+!ELSE\r
+all : $(LIB_NAME) $(DEP_TARGETS)\r
+!ENDIF\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# This is the Build.$(PROCESSOR).$(COMPONENT_TYPE) section that tells how to\r
+# convert a firmware volume into an FV FFS file. Simply run it through\r
+# GenFfsFile with the appropriate package file. SOURCE_FV must be defined\r
+# in the component INF file Defines section.\r
+#\r
+[=============================================================================]\r
+[Build.Ia32.FvImageFile,Build.x64.FvImageFile,Build.Ipf.FvImageFile]\r
+\r
+all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi\r
+\r
+#\r
+# Run GenFfsFile on the package file and FV file to create the firmware \r
+# volume FFS file. This FFS file maybe contain one pad section for alignment requirement.\r
+#\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi : $(DEST_DIR)\$(SOURCE_FV)Fv.sec $(PACKAGE_FILENAME) $(PAD_SECTION) \r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# Since many of the steps are the same for the different component types, we \r
+# share this section for BS_DRIVER, RT_DRIVER, .... and IFDEF the parts that \r
+# differ.  The entire section gets dumped to the output makefile.\r
+#\r
+[=============================================================================]\r
+[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]\r
+\r
+!IF "$(LOCALIZE)" == "YES"\r
+\r
+!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"\r
+STRGATHER_FLAGS   = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+\r
+#\r
+# There will be one HII pack containing all the strings. Add that file\r
+# to the list of HII pack files we'll use to create our final HII export file.\r
+#\r
+HII_PACK_FILES    = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii\r
+!ENDIF\r
+\r
+$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)\r
+  $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -skipext .uni -skipext .h $(SOURCE_FILES)\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -oc $(DEST_DIR)\$(BASE_NAME)Strings.c\r
+\r
+$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+\r
+OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)\r
+  $(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c\r
+\r
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+\r
+!ENDIF\r
+\r
+#\r
+# If we have any objects associated with this component, then we're\r
+# going to build a local library from them.\r
+#\r
+!IFNDEF OBJECTS\r
+!ERROR No source files to build were defined in the INF file\r
+!ENDIF\r
+\r
+TARGET_LOCAL_LIB  = $(DEST_DIR)\$(BASE_NAME)Local.lib\r
+\r
+#\r
+# LIB all the object files into our (local) target lib file. Put\r
+# a dependency on the component's INF file in case it changes.\r
+#\r
+$(TARGET_LOCAL_LIB) : $(OBJECTS)  $(INF_FILENAME) $(ENV_DEPS)\r
+  $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@\r
+\r
+#\r
+# Defines for standard intermediate files and build targets\r
+#\r
+TARGET_DLL      = $(BIN_DIR)\$(BASE_NAME).dll\r
+TARGET_EFI      = $(BIN_DIR)\$(BASE_NAME).efi\r
+TARGET_DPX      = $(DEST_DIR)\$(BASE_NAME).dpx\r
+TARGET_UI       = $(DEST_DIR)\$(BASE_NAME).ui\r
+TARGET_VER      = $(DEST_DIR)\$(BASE_NAME).ver\r
+TARGET_MAP      = $(BIN_DIR)\$(BASE_NAME).map\r
+TARGET_PDB      = $(BIN_DIR)\$(BASE_NAME).pdb\r
+TARGET_SYM      = $(BIN_DIR)\$(BASE_NAME).sym\r
+\r
+#\r
+# Target executable section extension depends on the component type.\r
+# Only define "TARGET_DXE_DPX" if it's a combined peim driver.\r
+#\r
+!IF "$(COMPONENT_TYPE)" == "PIC_PEIM"\r
+TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pic\r
+!ELSE\r
+TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32\r
+!ENDIF\r
+\r
+#\r
+# Target FFS file extension depends on the component type\r
+# Also define "TARGET_DXE_DPX" if it's a combined PEIM driver.\r
+#\r
+SUBSYSTEM = EFI_BOOT_SERVICE_DRIVER\r
+\r
+!IF "$(COMPONENT_TYPE)" == "APPLICATION"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app\r
+SUBSYSTEM       = EFI_APPLICATION\r
+!ELSE IF "$(COMPONENT_TYPE)" == "PEI_CORE"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+!ELSE IF "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+!ELSE IF "$(COMPONENT_TYPE)" == "PIC_PEIM"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+!ELSE IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+TARGET_DXE_DPX  = $(DEST_DIR)\$(BASE_NAME).dpxd\r
+!ELSE\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe\r
+!ENDIF\r
+\r
+#\r
+# Different methods to build section based on if PIC_PEIM\r
+#\r
+!IF "$(COMPONENT_TYPE)" == "PIC_PEIM"\r
+\r
+$(TARGET_PE32) : $(TARGET_DLL)\r
+  $(PE2BIN) $(TARGET_DLL) $(DEST_DIR)\$(BASE_NAME).TMP\r
+#\r
+# BUGBUG: Build PEIM header, needs to go away with new PEI.\r
+#\r
+  $(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\r
+  $(GENSECTION) -I $(TARGET_PIC_PEI).tmp -O $(TARGET_PE32) -S EFI_SECTION_PIC\r
+  del $(DEST_DIR)\$(BASE_NAME).TMP\r
+\r
+!ELSE\r
+\r
+$(TARGET_PE32) : $(TARGET_EFI)\r
+  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32\r
+\r
+#\r
+# Run FWImage on the DLL to set it as an EFI image type.\r
+#\r
+$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)\r
+  $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)\r
+\r
+!ENDIF\r
+\r
+#\r
+# Link all objects and libs to create the executable\r
+#\r
+$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)\r
+  $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \\r
+     $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \\r
+     /PDB:$(TARGET_PDB) \r
+  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt\r
+!IF "$(EFI_GENERATE_SYM_FILE)" == "YES"\r
+  if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM)\r
+!ENDIF\r
+\r
+!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"\r
+  $(ZERODEBUGDATA) $(TARGET_DLL)\r
+!ENDIF\r
+\r
+#\r
+# Create the user interface section\r
+#\r
+$(TARGET_UI) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"\r
+\r
+#\r
+# Create the version section\r
+#\r
+!IF "$(BUILD_NUMBER)" != ""\r
+!IF "$(VERSION_STRING)" != ""\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"\r
+!ELSE\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_VER) : \r
+  echo.>$(TARGET_VER)\r
+  type $(TARGET_VER)>$(TARGET_VER)\r
+!ENDIF\r
+\r
+#\r
+# Makefile entries to create the dependency expression section.\r
+# Use the DPX file from the source directory unless an override file\r
+# was specified.\r
+# If no DPX source file was specified, then create an empty file to\r
+# be used.\r
+#\r
+!IF "$(DPX_SOURCE)" != ""\r
+DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_OVERRIDE)" != ""\r
+DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_FILE)" != ""\r
+!IF EXIST ($(DPX_SOURCE_FILE))\r
+#\r
+# Add dependency check for dxs file, because dxs file depends on PPI or \r
+# PROTOCOL guid defintions.\r
+#\r
+DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+\r
+!IF EXIST($(TARGET_DPX))\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(TARGET_DPX)\r
+  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)\r
+\r
+$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)\r
+  $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1\r
+  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2\r
+  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)\r
+  del $*.tmp1 > NUL\r
+  del $*.tmp2 > NUL\r
+!ELSE\r
+!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_DPX) : \r
+  echo. > $(TARGET_DPX)\r
+  type $(TARGET_DPX) > $(TARGET_DPX)\r
+!ENDIF\r
+\r
+#\r
+# Makefile entries for DXE DPX for combined PEIM drivers.\r
+# If a DXE_DPX_SOURCE file was specified in the INF file, use it. Otherwise \r
+# create an empty file and use it as a DPX file.\r
+#\r
+!IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER"\r
+!IF "$(DXE_DPX_SOURCE)" != ""\r
+!IF EXIST ($(SOURCE_DIR)\$(DXE_DPX_SOURCE))\r
+$(TARGET_DXE_DPX) : $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(INF_FILENAME)\r
+  $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(SOURCE_DIR)\$(DXE_DPX_SOURCE) > $*.tmp1\r
+  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2\r
+  $(GENSECTION) -I $*.tmp2 -O $@ -S EFI_SECTION_DXE_DEPEX\r
+  del $*.tmp1 > NUL\r
+  del $*.tmp2 > NUL\r
+!ELSE\r
+!ERROR Dependency expression source file "$(SOURCE_DIR)\$(DXE_DPX_SOURCE)" does not exist.\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_DXE_DPX) : \r
+  echo. > $(TARGET_DXE_DPX)\r
+  type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX)\r
+!ENDIF\r
+!ENDIF\r
+\r
+#\r
+# Describe how to build the HII export file from all the input HII pack files.\r
+# Use the FFS file GUID for the package GUID in the export file. Only used\r
+# when multiple VFR share strings.\r
+#\r
+$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES)\r
+  $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii\r
+\r
+#\r
+# If the build calls for creating an FFS file with the IFR included as\r
+# a separate binary (not compiled into the driver), then build the binary\r
+# section now. Note that the PACKAGE must be set correctly to actually get\r
+# this IFR section pulled into the FFS file.\r
+#\r
+!IF ("$(HII_IFR_PACK_FILES)" != "")\r
+\r
+$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES)\r
+  $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii\r
+  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW\r
+\r
+BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec\r
+\r
+!ENDIF\r
+\r
+#\r
+# Build a FFS file from the sections and package\r
+#\r
+$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(TARGET_DXE_DPX) $(PACKAGE_FILENAME)\r
+#\r
+# Some of our components require padding to align code\r
+#\r
+!IF "$(PROCESSOR)" == "IPF"\r
+!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"\r
+  copy $(BIN_DIR)\Blank.pad $(DEST_DIR)\r
+!ENDIF\r
+!ENDIF\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+!IF "$(CREATEDEPS)"=="YES"\r
+all : $(DEP_TARGETS)\r
+  $(MAKE) -f $(MAKEFILE_NAME) all\r
+!ELSE\r
+all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS)\r
+!ENDIF\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+[Build.Ia32.TE_PEIM,Build.Ipf.TE_PEIM,Build.x64.TE_PEIM]\r
+#\r
+# Define the library file we'll build if we have any objects defined.\r
+#\r
+!IFDEF OBJECTS\r
+TARGET_LOCAL_LIB  = $(DEST_DIR)\$(BASE_NAME)Local.lib\r
+#\r
+# LIB all the object files into our (local) target lib file. Put\r
+# a dependency on the component's INF file in case it changes.\r
+#\r
+$(TARGET_LOCAL_LIB) : $(OBJECTS)  $(INF_FILENAME) $(ENV_DEPS)\r
+  $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@\r
+\r
+!ELSE\r
+!ERROR No source files to build were defined in the INF file\r
+!ENDIF\r
+\r
+#\r
+# Defines for standard intermediate files and build targets\r
+#\r
+TARGET_DLL        = $(BIN_DIR)\$(BASE_NAME).dll\r
+TARGET_EFI        = $(BIN_DIR)\$(BASE_NAME).efi\r
+TARGET_DPX        = $(DEST_DIR)\$(BASE_NAME).dpx\r
+TARGET_UI         = $(DEST_DIR)\$(BASE_NAME).ui\r
+TARGET_VER        = $(DEST_DIR)\$(BASE_NAME).ver\r
+TARGET_MAP        = $(BIN_DIR)\$(BASE_NAME).map\r
+TARGET_PDB        = $(BIN_DIR)\$(BASE_NAME).pdb\r
+TARGET_SYM        = $(BIN_DIR)\$(BASE_NAME).sym\r
+TARGET_TE         = $(BIN_DIR)\$(BASE_NAME).te\r
+TARGET_PE32       = $(DEST_DIR)\$(BASE_NAME).pe32\r
+TARGET_TES        = $(DEST_DIR)\$(BASE_NAME).tes\r
+TARGET_FFS_FILE   = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
+\r
+#\r
+# Create our TE section from our TE file\r
+#\r
+$(TARGET_TES) : $(TARGET_TE)\r
+  $(GENSECTION) -I $(TARGET_TE) -O $(TARGET_TES) -S EFI_SECTION_TE\r
+\r
+#\r
+# Run FWImage on the DLL to set it as an EFI image type.\r
+#\r
+$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)\r
+  $(FWIMAGE) $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)\r
+\r
+#\r
+# Run GenTEImage on the built .efi file to create our TE file.\r
+#\r
+$(TARGET_TE) : $(TARGET_EFI) \r
+  $(GENTEIMAGE) -o $(TARGET_TE) $(TARGET_EFI)\r
+\r
+#\r
+# Link all objects and libs to create the executable\r
+#\r
+$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)\r
+  $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \\r
+     $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \\r
+     /PDB:$(TARGET_PDB)\r
+  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt\r
+!IF "$(EFI_GENERATE_SYM_FILE)" == "YES"\r
+  if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM)\r
+!ENDIF\r
+\r
+!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"\r
+  $(ZERODEBUGDATA) $(TARGET_DLL)\r
+!ENDIF\r
+\r
+#\r
+# Create the user interface section\r
+#\r
+$(TARGET_UI) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"\r
+\r
+#\r
+# Create the version section\r
+#\r
+!IF "$(BUILD_NUMBER)" != ""\r
+!IF "$(VERSION_STRING)" != ""\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"\r
+!ELSE\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_VER) : \r
+  echo.>$(TARGET_VER)\r
+  type $(TARGET_VER)>$(TARGET_VER)\r
+!ENDIF\r
+\r
+#\r
+# Makefile entries to create the dependency expression section.\r
+# Use the DPX file from the source directory unless an override file\r
+# was specified.\r
+# If no DPX source file was specified, then create an empty file to\r
+# be used.\r
+#\r
+!IF "$(DPX_SOURCE)" != ""\r
+DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_OVERRIDE)" != ""\r
+DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_FILE)" != ""\r
+!IF EXIST ($(DPX_SOURCE_FILE))\r
+#\r
+# Add dependency check for dxs file, because dxs file depends on PPI or \r
+# PROTOCOL guid defintions.\r
+#\r
+DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+\r
+!IF EXIST($(TARGET_DPX))\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(TARGET_DPX)\r
+  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)\r
+\r
+$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)\r
+  $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1\r
+  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2\r
+  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)\r
+  del $*.tmp1 > NUL\r
+  del $*.tmp2 > NUL\r
+!ELSE\r
+!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_DPX) : \r
+  echo. > $(TARGET_DPX)\r
+  type $(TARGET_DPX) > $(TARGET_DPX)\r
+!ENDIF\r
+\r
+#\r
+# Build an FFS file from the sections and package\r
+#\r
+$(TARGET_FFS_FILE) : $(TARGET_TES) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+!IF "$(CREATEDEPS)"=="YES"\r
+all : $(DEP_TARGETS)\r
+  $(MAKE) -f $(MAKEFILE_NAME) all\r
+!ELSE\r
+all : $(TARGET_FFS_FILE) $(DEP_TARGETS)\r
+!ENDIF\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# These are the commands to build EBC EFI targets\r
+#\r
+[=============================================================================]\r
+[Build.Ebc.BS_DRIVER|RT_DRIVER|APPLICATION]\r
+\r
+#\r
+# Add the EBC library to our list of libs\r
+#\r
+LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib \r
+\r
+!IF "$(LOCALIZE)" == "YES"\r
+\r
+!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"\r
+STRGATHER_FLAGS   = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+\r
+#\r
+# There will be one HII pack containing all the strings. Add that file\r
+# to the list of HII pack files we'll use to create our final HII export file.\r
+#\r
+HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+\r
+LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii\r
+!ENDIF\r
+\r
+$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)\r
+  $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -skipext .uni -skipext .h $(SOURCE_FILES)\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -oc $(DEST_DIR)\$(BASE_NAME)Strings.c\r
+\r
+$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb\r
+  $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \\r
+    -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+\r
+OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj\r
+\r
+$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)\r
+  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c\r
+\r
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+\r
+!ENDIF\r
+\r
+#\r
+# If building an application, then the target is a .app, not .dxe\r
+#\r
+!IF "$(COMPONENT_TYPE)" == "APPLICATION"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app\r
+SUBSYSTEM       = EFI_APPLICATION\r
+!ELSE\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe\r
+SUBSYSTEM       = EFI_BOOT_SERVICE_DRIVER\r
+!ENDIF\r
+\r
+#\r
+# Defines for standard intermediate files and build targets\r
+#\r
+TARGET_EFI  = $(BIN_DIR)\$(BASE_NAME).efi\r
+TARGET_DPX  = $(DEST_DIR)\$(BASE_NAME).dpx\r
+TARGET_UI   = $(DEST_DIR)\$(BASE_NAME).ui\r
+TARGET_VER  = $(DEST_DIR)\$(BASE_NAME).ver\r
+TARGET_MAP  = $(BIN_DIR)\$(BASE_NAME).map\r
+TARGET_PDB  = $(BIN_DIR)\$(BASE_NAME).pdb\r
+TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32\r
+TARGET_DLL  = $(BIN_DIR)\$(BASE_NAME).dll\r
+\r
+#\r
+# First link all the objects and libs together to make a .dll file\r
+#\r
+$(TARGET_DLL) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS)\r
+  $(EBC_LINK) $(EBC_LINK_FLAGS) /SUBSYSTEM:$(SUBSYSTEM) /ENTRY:EfiStart \\r
+    $(OBJECTS) $(LIBS) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP)\r
+  $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt\r
+!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES"\r
+  $(ZERODEBUGDATA) $(TARGET_DLL)\r
+!ENDIF\r
+\r
+#\r
+# Now take the .dll file and make a .efi file\r
+#\r
+$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME)\r
+  $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI)\r
+\r
+#\r
+# Now take the .efi file and make a .pe32 section\r
+#\r
+$(TARGET_PE32) : $(TARGET_EFI) \r
+  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32\r
+\r
+#\r
+# Create the user interface section\r
+#\r
+$(TARGET_UI) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"\r
+\r
+#\r
+# Create the version section\r
+#\r
+!IF "$(BUILD_NUMBER)" != ""\r
+!IF "$(VERSION_STRING)" != ""\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"\r
+!ELSE\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_VER) : \r
+  echo. > $(TARGET_VER)\r
+  type $(TARGET_VER) > $(TARGET_VER)\r
+!ENDIF\r
+\r
+#\r
+# Makefile entries to create the dependency expression section.\r
+# Use the DPX file from the source directory unless an override file\r
+# was specified.\r
+# If no DPX source file was specified, then create an empty file to\r
+# be used.\r
+#\r
+!IF "$(DPX_SOURCE)" != ""\r
+DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_OVERRIDE)" != ""\r
+DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_FILE)" != ""\r
+!IF EXIST ($(DPX_SOURCE_FILE))\r
+#\r
+# Add dependency check for dxs file, because dxs file depends on PPI or \r
+# PROTOCOL guid defintions.\r
+#\r
+DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+\r
+!IF EXIST($(TARGET_DPX))\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(TARGET_DPX)\r
+  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)\r
+\r
+$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)\r
+  $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1\r
+  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2\r
+  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)\r
+  del $*.tmp1 > NUL\r
+  del $*.tmp2 > NUL\r
+!ELSE\r
+!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_DPX) : \r
+  echo. > $(TARGET_DPX)\r
+  type $(TARGET_DPX) > $(TARGET_DPX)\r
+!ENDIF\r
+\r
+#\r
+# Describe how to build the HII export file from all the input HII pack files.\r
+# Use the FFS file GUID for the package GUID in the export file. Only used\r
+# when multiple VFR share strings.\r
+#\r
+$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES)\r
+  $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii\r
+\r
+#\r
+# If the build calls for creating an FFS file with the IFR included as\r
+# a separate binary (not compiled into the driver), then build the binary\r
+# section now. Note that the PACKAGE must be set correctly to actually get\r
+# this IFR section pulled into the FFS file.\r
+#\r
+!IF ("$(HII_IFR_PACK_FILES)" != "")\r
+\r
+$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES)\r
+  $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii\r
+  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW\r
+\r
+BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec\r
+\r
+!ENDIF\r
+\r
+#\r
+# Build an FFS file from the sections and package\r
+#\r
+$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+!IF "$(CREATEDEPS)"=="YES"\r
+all : $(DEP_TARGETS)\r
+  $(MAKE) -f $(MAKEFILE_NAME) all\r
+!ELSE\r
+all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS)\r
+!ENDIF\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+#\r
+# These are the commands to build vendor-provided *.EFI files into an FV.\r
+# To use them, create an INF file with BUILD_TYPE=BS_DRIVER_EFI.\r
+# This section, as it now exists, only supports boot service drivers.\r
+#\r
+[=============================================================================]\r
+[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]\r
+#\r
+# Defines for standard intermediate files and build targets. For the source\r
+# .efi file, take the one in the source directory if it exists. If there's not\r
+# one there, look for one in the processor-specfic subdirectory.\r
+#\r
+!IF EXIST ("$(SOURCE_DIR)\$(BASE_NAME).efi")\r
+TARGET_EFI        = $(SOURCE_DIR)\$(BASE_NAME).efi\r
+!ELSEIF EXIST ("$(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi")\r
+TARGET_EFI        = $(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi\r
+!ELSE\r
+!ERROR Pre-existing $(BASE_NAME).efi file not found in $(SOURCE_DIR) nor $(SOURCE_DIR)\$(PROCESSOR)\r
+!ENDIF\r
+\r
+TARGET_DPX        = $(DEST_DIR)\$(BASE_NAME).dpx\r
+TARGET_UI         = $(DEST_DIR)\$(BASE_NAME).ui\r
+TARGET_VER        = $(DEST_DIR)\$(BASE_NAME).ver\r
+TARGET_MAP        = $(BIN_DIR)\$(BASE_NAME).map\r
+TARGET_PDB        = $(BIN_DIR)\$(BASE_NAME).pdb\r
+TARGET_PE32       = $(DEST_DIR)\$(BASE_NAME).pe32\r
+TARGET_DLL        = $(BIN_DIR)\$(BASE_NAME).dll\r
+\r
+#\r
+# If building an application, then the target is a .app, not .dxe\r
+#\r
+!IF "$(COMPONENT_TYPE)" == "APPLICATION"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app\r
+!ELSE\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe\r
+!ENDIF\r
+\r
+#\r
+# Take the .efi file and make a .pe32 file\r
+#\r
+$(TARGET_PE32) : $(TARGET_EFI) \r
+  $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32\r
+\r
+#\r
+# Create the user interface section\r
+#\r
+$(TARGET_UI) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)"\r
+\r
+#\r
+# Create the version section\r
+#\r
+!IF "$(BUILD_NUMBER)" != ""\r
+!IF "$(VERSION_STRING)" != ""\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)"\r
+!ELSE\r
+$(TARGET_VER) : $(INF_FILENAME)\r
+  $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_VER) : \r
+  echo. > $(TARGET_VER)\r
+  type $(TARGET_VER) > $(TARGET_VER)\r
+!ENDIF\r
+\r
+#\r
+# Makefile entries to create the dependency expression section.\r
+# Use the DPX file from the source directory unless an override file\r
+# was specified.\r
+# If no DPX source file was specified, then create an empty file to\r
+# be used.\r
+#\r
+!IF "$(DPX_SOURCE)" != ""\r
+DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_OVERRIDE)" != ""\r
+DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE)\r
+!ENDIF\r
+\r
+!IF "$(DPX_SOURCE_FILE)" != ""\r
+!IF EXIST ($(DPX_SOURCE_FILE))\r
+#\r
+# Add dependency check for dxs file, because dxs file depends on PPI or \r
+# PROTOCOL guid defintions.\r
+#\r
+DEP_FILE    = $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+\r
+!IF EXIST($(TARGET_DPX))\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(TARGET_DPX)\r
+  $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS)\r
+\r
+$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)\r
+  $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1\r
+  $(GENDEPEX) -I $*.tmp1 -O $*.tmp2\r
+  $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE)\r
+  del $*.tmp1 > NUL\r
+  del $*.tmp2 > NUL\r
+!ELSE\r
+!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
+!ENDIF\r
+!ELSE\r
+$(TARGET_DPX) : \r
+  echo. > $(TARGET_DPX)\r
+  type $(TARGET_DPX) > $(TARGET_DPX)\r
+!ENDIF\r
+\r
+#\r
+# Build a FFS file from the sections and package\r
+#\r
+$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME)\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+all : $(TARGET_FFS_FILE)\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+[Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp]\r
+#\r
+# We simply copy the binary file from the source directory to the destination directory\r
+#\r
+$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)\r
+  copy $** $@\r
+\r
+[=============================================================================]\r
+[Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo]\r
+#\r
+# Use GenFfsFile to convert it to an FFS file\r
+#\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)\r
+  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+[Build.Ia32.RAWFILE|CONFIG,Build.Ipf.RAWFILE|CONFIG,Build.x64.RAWFILE|CONFIG]\r
+#\r
+# Use GenFfsFile to convert it to an raw FFS file\r
+#\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)\r
+  $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
+\r
+all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw\r
+\r
+#\r
+# Remove the generated temp and final files for this modules.\r
+#\r
+clean :\r
+!IF ("$(FILE_GUID)" != "")\r
+  @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
+!ENDIF\r
+  @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).*\r
+  @del /q $(DEST_OUTPUT_DIRS) \r
+\r
+[=============================================================================]\r
+# \r
+# These are commands to compile unicode .uni files.\r
+#\r
+[=============================================================================]\r
+[Compile.Ia32.Uni,Compile.Ipf.Uni,Compile.Ebc.Uni,Compile.x64.Uni]\r
+#\r
+# Emit an error message if the file's base name is the same as the\r
+# component base name. This causes build issues.\r
+#\r
+!IF "$(FILE)" == "$(BASE_NAME)"\r
+!ERROR Component Unicode string file name cannot be the same as the component BASE_NAME.\r
+!ENDIF\r
+\r
+#\r
+# Always create dep file for uni file as it can be created at the same time when \r
+# strgather is parsing uni file.\r
+#\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Uni.dep\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+$(DEST_DIR)\$(FILE).sdb : $(SOURCE_FILE_NAME) $(INF_FILENAME)\r
+  $(STRGATHER) -parse -newdb -db $(DEST_DIR)\$(FILE).sdb -dep $(DEP_FILE) $(INC) $(SOURCE_FILE_NAME)\r
+\r
+SDB_FILES       = $(SDB_FILES) $(DEST_DIR)\$(FILE).sdb\r
+STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb\r
+LOCALIZE        = YES\r
+\r
+[=============================================================================]\r
+[Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+#\r
+# Add a dummy command for building the HII pack file. In reality, it's built \r
+# below, but the C_FLAGS macro reference the target as $@, so you can't specify\r
+# the obj and hpk files as dual targets of the same command.\r
+#\r
+$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj\r
+  \r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \\r
+    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)\r
+  $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c\r
+\r
+[=============================================================================]\r
+[Compile.Ebc.Vfr]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+#\r
+# Add a dummy command for building the HII pack file. In reality, it's built \r
+# below, but the C_FLAGS macro reference the target as $@, so you can't specify\r
+# the obj and hpk files as dual targets of the same command.\r
+#\r
+$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj\r
+  \r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \\r
+    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)\r
+  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c\r
+\r
+[=============================================================================]\r
+#\r
+# Commands for building IFR as uncompressed binary into the FFS file. To \r
+# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file.\r
+#\r
+[=============================================================================]\r
+[Compile.Ia32.Ifr_Bin,Compile.Ipf.Ifr_Bin,Compile.x64.Ifr_Bin]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+#\r
+# Add a dummy command for building the HII pack file. In reality, it's built \r
+# below, but the C_FLAGS macro reference the target as $@, so you can't specify\r
+# the obj and hpk files as dual targets of the same command.\r
+#\r
+$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj\r
+  \r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \\r
+    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)\r
+  $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c\r
+\r
+#\r
+# Add to the variable that contains the list of VFR binary files we're going\r
+# to merge together at the end of the build. \r
+#\r
+HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+[=============================================================================]\r
+#\r
+# Commands for building IFR as uncompressed binary into the FFS file. To \r
+# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file.\r
+#\r
+[=============================================================================]\r
+[Compile.Ebc.Ifr_Bin]\r
+\r
+DEP_FILE    = $(DEST_DIR)\$(FILE)Vfr.dep\r
+\r
+!IF EXIST($(DEST_DIR)\$(FILE).obj)\r
+DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep\r
+!IF !EXIST($(DEP_FILE))\r
+CREATEDEPS = YES\r
+!ENDIF\r
+!ENDIF\r
+\r
+!IF EXIST($(DEP_FILE))\r
+!INCLUDE $(DEP_FILE)\r
+!ENDIF\r
+\r
+#\r
+# Update dep file for next round incremental build\r
+#\r
+$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj\r
+  $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS)\r
+\r
+HII_PACK_FILES  = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+#\r
+# Add a dummy command for building the HII pack file. In reality, it's built \r
+# below, but the C_FLAGS macro reference the target as $@, so you can't specify\r
+# the obj and hpk files as dual targets of the same command.\r
+#\r
+$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj\r
+  \r
+$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)\r
+  $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \\r
+    -l $(VFR_FLAGS) $(SOURCE_FILE_NAME)\r
+  $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c\r
+\r
+#\r
+# Add to the variable that contains the list of VFR binary files we're going\r
+# to merge together at the end of the build. \r
+#\r
+HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk\r
+\r
+[=============================================================================]\r
+[Compile.Ia32.Fv,Compile.Ipf.Fv,Compile.x64.Fv]\r
+#\r
+# Run GenSection on the firmware volume image.\r
+#\r
+$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME)\r
+  $(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE\r
+\r
+[=============================================================================]\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc
new file mode 100644 (file)
index 0000000..f9fae29
--- /dev/null
@@ -0,0 +1,558 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+# \r
+#   CommonIa32.dsc\r
+#\r
+#  Abstract:\r
+#\r
+#    This is the build description file containing the processor architecture\r
+#    dependent build instructions.\r
+#\r
+#  Notes:\r
+#    \r
+#    The info in this file is broken down into sections. The start of a section\r
+#    is designated by a "[" in the first column. So the [=====] separater ends\r
+#    a section.\r
+#    \r
+#--*/\r
+\r
+\r
+[=============================================================================]\r
+#\r
+# These are the package descriptions. They are tagged as\r
+# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically\r
+# defined in the component INF file, and PACKAGE is typically specified\r
+# in the components section in the main DSC file. Main DSC file can also define\r
+# platform specific package descriptions. \r
+#\r
+\r
+[=============================================================================]\r
+[Package.APPLICATION.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_APPLICATION\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.Apriori.Default|DefaultStripped,Package.FILE.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).sec \r
+}\r
+\r
+[=============================================================================]\r
+[Package.RAWFILE.Default|DefaultStripped,Package.Config.Default|DefaultStripped|Config,Package.Microcode.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_RAW\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).Bin\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool ( $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec\r
+             -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition for TE files\r
+#\r
+[Package.PE32_PEIM.TE_PEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  $(BASE_NAME).tes\r
+  $(BASE_NAME).ui \r
+  $(BASE_NAME).ver \r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition to put the IFR data in a separate section in the\r
+# FFS file.\r
+#\r
+[Package.BS_DRIVER.Ifr_Bin]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+               $(DEST_DIR)\$(BASE_NAME)IfrBin.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.TE_PEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).tes \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.Relocatable]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.CompressPEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui \r
+    $(BASE_NAME).ver\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.COMBINED_PEIM_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).dpxd \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DxeMain]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DXE_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui\r
+    $(BASE_NAME).ver\r
+  }    \r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Define a package that "signs" our capsule cargo FV\r
+#\r
+[Package.FvImageFile.SignedFVPackage]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.FvMainCompact]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Blank.pad\r
+    $(SOURCE_FV)Fv.sec\r
+  }\r
+}\r
+[=============================================================================]\r
+#\r
+# Stripped package descriptions for size reduction.\r
+#\r
+[=============================================================================]\r
+[Package.APPLICATION.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_APPLICATION\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BINARY.DefaultStripped,Package.Legacy16.DefaultStripped,Package.Logo.DefaultStripped|LogoStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).sec\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.TE_PEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).tes\r
+}\r
+[=============================================================================]\r
+[Package.PE32_PEIM.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.CompressPEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).dpx\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition for TE files\r
+#\r
+[Package.PE32_PEIM.TE_PEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).dpx\r
+  $(BASE_NAME).tes\r
+}\r
+\r
+[=============================================================================]\r
+[Package.COMBINED_PEIM_DRIVER.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).dpxd \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DxeMainStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DXE_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DefaultStripped,Package.RT_DRIVER.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).dpx\r
+    $(DEST_DIR)\$(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.SECURITY_CORE.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_SECURITY_CORE\r
+FFS_ATTRIB_CHECKSUM         = FALSE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  Blank1.pad \\r
+  $(BASE_NAME).tes \\r
+  ResetVec.raw \\r
+}\r
+\r
+[=============================================================================]\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc
new file mode 100644 (file)
index 0000000..13bfe91
--- /dev/null
@@ -0,0 +1,391 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+# \r
+#   CommonIpf.dsc\r
+#\r
+#  Abstract:\r
+#\r
+#    This is the build description file containing the processor architecture\r
+#    dependent build instructions.\r
+#\r
+#  Notes:\r
+#    \r
+#    The info in this file is broken down into sections. The start of a section\r
+#    is designated by a "[" in the first column. So the [=====] separater ends\r
+#    a section.\r
+#    \r
+#--*/\r
+\r
+\r
+[=============================================================================]\r
+#\r
+# These are the package descriptions. They are tagged as\r
+# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically\r
+# defined in the component INF file, and PACKAGE is typically specified\r
+# in the components section in the main DSC file. Main DSC file can also define\r
+# platform specific package descriptions. \r
+#\r
+\r
+[=============================================================================]\r
+[Package.APPLICATION.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_APPLICATION\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.Apriori.Default,Package.FILE.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).sec \r
+}\r
+\r
+[=============================================================================]\r
+[Package.RAWFILE.Default,Package.Config.Default|Config]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_RAW\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).Bin\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool ( $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec\r
+             -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition for TE files\r
+#\r
+[Package.PE32_PEIM.TE_PEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  $(BASE_NAME).tes\r
+  $(BASE_NAME).ui \r
+  $(BASE_NAME).ver \r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition to put the IFR data in a separate section in the\r
+# FFS file.\r
+#\r
+[Package.BS_DRIVER.Ifr_Bin]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+               $(DEST_DIR)\$(BASE_NAME)IfrBin.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.SECURITY_CORE.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_SECURITY_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x1\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  Blank.pad \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x1\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  Blank.pad \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x1\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  Blank.pad \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.CompressPEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui \r
+    $(BASE_NAME).ver\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.COMBINED_PEIM_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x1\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  Blank.pad \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).dpxd \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PIC_PEIM.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x1\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  Blank.pad \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pic \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.DxeIplPad.Default]\r
+PACKAGE.INF \r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_RAW\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+FFS_ALIGNMENT               = 0x7\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).pad \\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DxeMain]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DXE_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui\r
+    $(BASE_NAME).ver\r
+  }\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default,Package.SAL_RT_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool ( \r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Define a package that "signs" our capsule cargo FV\r
+#\r
+[Package.FvImageFile.SignedFVPackage]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.FvMainCompact]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Blank.pad\r
+    $(SOURCE_FV)Fv.sec\r
+  }\r
+}\r
+[=============================================================================]\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc
new file mode 100644 (file)
index 0000000..4314049
--- /dev/null
@@ -0,0 +1,558 @@
+#/*++\r
+#\r
+# Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+# \r
+#   CommonX64.dsc\r
+#\r
+#  Abstract:\r
+#\r
+#    This is the build description file containing the processor architecture\r
+#    dependent build instructions.\r
+#\r
+#  Notes:\r
+#    \r
+#    The info in this file is broken down into sections. The start of a section\r
+#    is designated by a "[" in the first column. So the [=====] separater ends\r
+#    a section.\r
+#    \r
+#--*/\r
+\r
+\r
+[=============================================================================]\r
+#\r
+# These are the package descriptions. They are tagged as\r
+# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically\r
+# defined in the component INF file, and PACKAGE is typically specified\r
+# in the components section in the main DSC file. Main DSC file can also define\r
+# platform specific package descriptions. \r
+#\r
+\r
+[=============================================================================]\r
+[Package.APPLICATION.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_APPLICATION\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.Apriori.Default|DefaultStripped,Package.FILE.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).sec \r
+}\r
+\r
+[=============================================================================]\r
+[Package.RAWFILE.Default|DefaultStripped,Package.Config.Default|DefaultStripped|Config,Package.Microcode.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_RAW\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).Bin\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool ( $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec\r
+             -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition for TE files\r
+#\r
+[Package.PE32_PEIM.TE_PEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  $(BASE_NAME).tes\r
+  $(BASE_NAME).ui \r
+  $(BASE_NAME).ver \r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition to put the IFR data in a separate section in the\r
+# FFS file.\r
+#\r
+[Package.BS_DRIVER.Ifr_Bin]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+               $(DEST_DIR)\$(BASE_NAME)IfrBin.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.TE_PEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).tes \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.Relocatable]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.CompressPEIM]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \r
+  $(BASE_NAME).dpx \r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui \r
+    $(BASE_NAME).ver\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.COMBINED_PEIM_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).dpxd \\r
+  $(BASE_NAME).pe32 \\r
+  $(BASE_NAME).ui \\r
+  $(BASE_NAME).ver \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DxeMain]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DXE_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+    $(BASE_NAME).ui\r
+    $(BASE_NAME).ver\r
+  }    \r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default,Package.SAL_RT_DRIVER.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx\r
+               $(DEST_DIR)\$(BASE_NAME).pe32\r
+               $(DEST_DIR)\$(BASE_NAME).ui\r
+               $(DEST_DIR)\$(BASE_NAME).ver\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.Default]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32\r
+    )\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Define a package that "signs" our capsule cargo FV\r
+#\r
+[Package.FvImageFile.SignedFVPackage]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+    Tool (\r
+      $(OEMTOOLPATH)\GenCRC32Section\r
+      ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+            -o $(DEST_DIR)\$(BASE_NAME).crc32\r
+      OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32\r
+    )\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Stripped package descriptions for size reduction.\r
+#\r
+[=============================================================================]\r
+[Package.APPLICATION.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_APPLICATION\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BINARY.DefaultStripped,Package.Legacy16.DefaultStripped,Package.Logo.DefaultStripped|LogoStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FREEFORM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).sec\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PEI_CORE.TE_PEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEI_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).tes\r
+}\r
+[=============================================================================]\r
+[Package.PE32_PEIM.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.PE32_PEIM.CompressPEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).dpx\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+#\r
+# Package definition for TE files\r
+#\r
+[Package.PE32_PEIM.TE_PEIMStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_PEIM\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  $(BASE_NAME).dpx\r
+  $(BASE_NAME).tes\r
+}\r
+\r
+[=============================================================================]\r
+[Package.COMBINED_PEIM_DRIVER.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{ \\r
+  $(BASE_NAME).dpx \\r
+  $(BASE_NAME).dpxd \\r
+  $(BASE_NAME).pe32 \\r
+}\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DxeMainStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DXE_CORE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.BS_DRIVER.DefaultStripped,Package.RT_DRIVER.DefaultStripped,Package.SAL_RT_DRIVER.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_DRIVER\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(BASE_NAME).dpx\r
+    $(DEST_DIR)\$(BASE_NAME).pe32\r
+  }\r
+}\r
+\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    $(DEST_DIR)\$(SOURCE_FV)Fv.sec\r
+  }\r
+}\r
+\r
+[=============================================================================]\r
+[Package.FvImageFile.FvMainCompact]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\r
+FFS_ATTRIB_CHECKSUM         = TRUE\r
+\r
+IMAGE_SCRIPT =\r
+{\r
+  Compress ($(COMPRESS_METHOD)) {\r
+    Blank.pad\r
+    $(SOURCE_FV)Fv.sec\r
+  }\r
+}\r
+[=============================================================================]\r
+[Package.SECURITY_CORE.Default|DefaultStripped]\r
+PACKAGE.INF\r
+\[.]\r
+BASE_NAME                   = $(BASE_NAME)\r
+FFS_FILEGUID                = $(FILE_GUID)\r
+FFS_FILETYPE                = EFI_FV_FILETYPE_SECURITY_CORE\r
+FFS_ATTRIB_CHECKSUM         = FALSE\r
+\r
+IMAGE_SCRIPT =\r
+{          \\r
+  Blank1.pad \\r
+  $(BASE_NAME).tes \\r
+  ResetVec.raw \\r
+}\r
+\r
+[=============================================================================]\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc
new file mode 100644 (file)
index 0000000..5c71f41
--- /dev/null
@@ -0,0 +1,39 @@
+#/*++\r
+#  Copyright (c) 2006, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.      \r
+#--*/\r
+#\r
+# EdkII Glue Library for PEI usage (32bit)\r
+#\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseLib\BaseLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\BaseMemoryLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePrintLib\BasePrintLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull\BaseDebugLibNull.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80\BasePostCodeLibPort80.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug\BasePostCodeLibDebug.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib\BaseCacheMaintenanceLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib\BasePciCf8Lib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib\BasePciExpressLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8\BasePciLibCf8.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress\BasePciLibPciExpress.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib\BasePeCoffGetEntryPointLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib\BasePeCoffLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic\BaseTimerLibLocalApic.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib\BaseUefiDecompressLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxeDebugLibReportStatusCode\PeiDxeDebugLibReportStatusCode.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode\PeiDxePostCodeLibReportStatusCode.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7\PeiServicesTablePointerLibMm7.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib\PeiServicesTablePointerLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib\PeiMemoryAllocationLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib\PeiServicesLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiHobLib\PeiHobLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib\PeiResourcePublicationLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
new file mode 100644 (file)
index 0000000..8879bf3
--- /dev/null
@@ -0,0 +1,54 @@
+#/*++\r
+#  Copyright (c) 2006, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.      \r
+#--*/\r
+#\r
+#  EdkII Glue Library\r
+#\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseLib\BaseLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\BaseMemoryLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePrintLib\BasePrintLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull\BaseDebugLibNull.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiBootServicesTableLib\UefiBootServicesTableLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeIoLibCpuIo\DxeIoLibCpuIo.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80\BasePostCodeLibPort80.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug\BasePostCodeLibDebug.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib\BaseCacheMaintenanceLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib\BasePciCf8Lib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib\BasePciExpressLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8\BasePciLibCf8.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress\BasePciLibPciExpress.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib\BasePeCoffGetEntryPointLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib\BasePeCoffLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic\BaseTimerLibLocalApic.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib\BaseUefiDecompressLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxeDebugLibReportStatusCode\PeiDxeDebugLibReportStatusCode.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode\PeiDxePostCodeLibReportStatusCode.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeMemoryAllocationLib\DxeMemoryAllocationLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiLib\UefiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeHobLib\DxeHobLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiRuntimeServicesTableLib\UefiRuntimeServicesTableLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\HiiLib\HiiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7\PeiServicesTablePointerLibMm7.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibKr1\PeiServicesTablePointerLibKr1.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib\PeiServicesTablePointerLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib\PeiMemoryAllocationLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib\PeiServicesLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiHobLib\PeiHobLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib\PeiResourcePublicationLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiDevicePathLib\UefiDevicePathLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiDriverModelLib\UefiDriverModelLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeServicesTableLib\DxeServicesTableLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\EdkDxeSalLib\EdkDxeSalLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\EdkDxeRuntimeDriverLib\EdkDxeRuntimeDriverLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib\DxeSmbusLib.inf\r
+$(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 (file)
index 0000000..7be8ebb
--- /dev/null
@@ -0,0 +1,36 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#--*/\r
+#\r
+# EDK Common Library for PEI usage (32bit)\r
+#\r
+\r
+#\r
+# Libraries common to PEI and DXE\r
+#\r
+$(EDK_PREFIX)Foundation\Efi\Guid\EfiGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Framework\Guid\EdkFrameworkGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Guid\EdkGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EfiCommonLib\EfiCommonLib.inf\r
+$(EDK_PREFIX)Foundation\Cpu\Pentium\CpuIA32Lib\CpuIA32Lib.inf\r
+$(EDK_PREFIX)Foundation\Cpu\Itanium\CpuIA64Lib\CpuIA64Lib.inf\r
+$(EDK_PREFIX)Foundation\Library\CustomizedDecompress\CustomizedDecompress.inf\r
+$(EDK_PREFIX)Foundation\Library\CompilerStub\CompilerStubLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\Hob\HobLib.inf\r
+\r
+#\r
+# PEI libraries\r
+#\r
+$(EDK_PREFIX)Foundation\Framework\Ppi\EdkFrameworkPpiLib.inf\r
+$(EDK_PREFIX)Foundation\Ppi\EdkPpiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Pei\PeiLib\PeiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Pei\Hob\PeiHobLib.inf\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc
new file mode 100644 (file)
index 0000000..346946f
--- /dev/null
@@ -0,0 +1,63 @@
+#/*++\r
+#\r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#--*/\r
+#\r
+# EDK Common Library\r
+#\r
+\r
+#\r
+# Libraries common to PEI and DXE\r
+#\r
+$(EDK_PREFIX)Foundation\Efi\Guid\EfiGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Framework\Guid\EdkFrameworkGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Guid\EdkGuidLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EfiCommonLib\EfiCommonLib.inf\r
+$(EDK_PREFIX)Foundation\Cpu\Pentium\CpuIA32Lib\CpuIA32Lib.inf\r
+$(EDK_PREFIX)Foundation\Cpu\Itanium\CpuIA64Lib\CpuIA64Lib.inf\r
+$(EDK_PREFIX)Foundation\Library\CustomizedDecompress\CustomizedDecompress.inf\r
+$(EDK_PREFIX)Foundation\Library\CompilerStub\CompilerStubLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\Hob\HobLib.inf\r
+\r
+#\r
+# PEI libraries\r
+#\r
+$(EDK_PREFIX)Foundation\Framework\Ppi\EdkFrameworkPpiLib.inf\r
+$(EDK_PREFIX)Foundation\Ppi\EdkPpiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Pei\PeiLib\PeiLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Pei\Hob\PeiHobLib.inf\r
+\r
+#\r
+# DXE libraries\r
+#\r
+$(EDK_PREFIX)Foundation\Core\Dxe\ArchProtocol\ArchProtocolLib.inf\r
+$(EDK_PREFIX)Foundation\Efi\Protocol\EfiProtocolLib.inf\r
+$(EDK_PREFIX)Foundation\Framework\Protocol\EdkFrameworkProtocolLib.inf\r
+$(EDK_PREFIX)Foundation\Protocol\EdkProtocolLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\EfiDriverLib\EfiDriverLib.inf\r
+$(EDK_PREFIX)Foundation\Library\RuntimeDxe\EfiRuntimeLib\EfiRuntimeLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\Graphics\Graphics.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\EfiIfrSupportLib\EfiIfrSupportLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\Print\PrintLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\EfiScriptLib\EfiScriptLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\EfiUiLib\EfiUiLib.inf\r
+\r
+#\r
+# Print/Graphics Library consume SetupBrowser Print Protocol\r
+#\r
+$(EDK_PREFIX)Foundation\Library\Dxe\PrintLite\PrintLib.inf\r
+$(EDK_PREFIX)Foundation\Library\Dxe\GraphicsLite\Graphics.inf\r
+\r
+#\r
+# Module Libraries\r
+#\r
+$(EDK_PREFIX)Sample\Platform\Generic\Dxe\GenericBds\GenericBds.inf\r
+$(EDK_PREFIX)Sample\Bus\Usb\UsbLib\Dxe\UsbDxeLib.inf\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf
new file mode 100644 (file)
index 0000000..1abff26
--- /dev/null
@@ -0,0 +1,46 @@
+#/*++\r
+#\r
+# Copyright (c) 2004, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:\r
+#\r
+#    EdkNt32ProtocolLib.inf\r
+#\r
+#  Abstract:\r
+#\r
+#    Component description file.\r
+#\r
+#--*/\r
+\r
+[defines]\r
+BASE_NAME=   EdkNt32ProtocolLib\r
+COMPONENT_TYPE=   LIBRARY\r
+\r
+[includes.common]\r
+  $(EDK_SOURCE)\Sample\Platform\Nt32\r
+  $(EDK_SOURCE)\Foundation\Efi\r
+  $(EDK_SOURCE)\Foundation\Include\r
+  $(EDK_SOURCE)\Foundation\Efi\Include\r
+  $(EDK_SOURCE)\Foundation\Framework\Include\r
+  $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+  $(EDK_SOURCE)\Foundation\Include\Pei\r
+  $(EDK_SOURCE)\Foundation\Library\Pei\Include\r
+  $(EDK_SOURCE)\Foundation\Core\Dxe\r
+  $(EDK_SOURCE)\Foundation\Library\Dxe\Include\r
+  $(EDK_SOURCE)\Sample\Include\r
+\r
+[nmake.common]\r
+C_STD_INCLUDE=\r
+\r
+[sources.common]\r
+    WinNtIo\WinNtIo.h\r
+    WinNtIo\WinNtIo.c\r
+    WinNtThunk\WinNtThunk.h\r
+    WinNtThunk\WinNtThunk.c\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c
new file mode 100644 (file)
index 0000000..318ff33
--- /dev/null
@@ -0,0 +1,40 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WinNtIo.c\r
+\r
+Abstract:\r
+\r
+  This protocol allows an EFI driver (DLL) in the NT emulation envirnment\r
+  to make Win32 API calls.\r
+\r
+--*/\r
+\r
+#include "EfiWinNt.h"\r
+#include EFI_PROTOCOL_DEFINITION (WinNtIo)\r
+\r
+EFI_GUID  gEfiWinNtIoProtocolGuid = EFI_WIN_NT_IO_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiWinNtIoProtocolGuid, "EFI Win NT I/O Protocol", "Win32 API I/O protocol");\r
+\r
+EFI_GUID  gEfiWinNtVirtualDisksGuid   = EFI_WIN_NT_VIRTUAL_DISKS_GUID;\r
+EFI_GUID  gEfiWinNtPhysicalDisksGuid  = EFI_WIN_NT_PHYSICAL_DISKS_GUID;\r
+EFI_GUID  gEfiWinNtFileSystemGuid     = EFI_WIN_NT_FILE_SYSTEM_GUID;\r
+EFI_GUID  gEfiWinNtSerialPortGuid     = EFI_WIN_NT_SERIAL_PORT_GUID;\r
+EFI_GUID  gEfiWinNtUgaGuid            = EFI_WIN_NT_UGA_GUID;\r
+EFI_GUID  gEfiWinNtGopGuid            = EFI_WIN_NT_GOP_GUID;\r
+EFI_GUID  gEfiWinNtConsoleGuid        = EFI_WIN_NT_CONSOLE_GUID;\r
+EFI_GUID  gEfiWinNtMemoryGuid         = EFI_WIN_NT_MEMORY_GUID;\r
+EFI_GUID  gEfiWinNtCPUModelGuid       = EFI_WIN_NT_CPU_MODEL_GUID;\r
+EFI_GUID  gEfiWinNtCPUSpeedGuid       = EFI_WIN_NT_CPU_SPEED_GUID;\r
+EFI_GUID  gEfiWinNtPassThroughGuid    = EFI_WIN_NT_PASS_THROUGH_GUID;\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h
new file mode 100644 (file)
index 0000000..7da6099
--- /dev/null
@@ -0,0 +1,163 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WinNtIo.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _WIN_NT_IO_H_\r
+#define _WIN_NT_IO_H_\r
+\r
+#define EFI_WIN_NT_IO_PROTOCOL_GUID \\r
+  { \\r
+    0x96eb4ad6, 0xa32a, 0x11d4, 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+//\r
+// The following APIs require EfiWinNT.h. In some environmnets the GUID\r
+// definitions are needed but the EfiWinNT.h is not included.\r
+// EfiWinNT.h is needed to support WINDOWS API requirements.\r
+//\r
+#ifdef _EFI_WIN_NT_H_\r
+\r
+#include EFI_PROTOCOL_DEFINITION (WinNtThunk)\r
+\r
+typedef struct {\r
+  EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;\r
+  EFI_GUID                  *TypeGuid;\r
+  CHAR16                    *EnvString;\r
+  UINT16                    InstanceNumber;\r
+} EFI_WIN_NT_IO_PROTOCOL;\r
+\r
+#endif\r
+\r
+extern EFI_GUID gEfiWinNtIoProtocolGuid;\r
+\r
+//\r
+// The following GUIDs are used in EFI_WIN_NT_IO_PROTOCOL_GUID\r
+// Device paths. They map 1:1 with NT envirnment variables. The variables\r
+// define what virtual hardware the emulator/WinNtBusDriver will produce.\r
+//\r
+//\r
+// EFI_WIN_NT_VIRTUAL_DISKS\r
+//\r
+#define EFI_WIN_NT_VIRTUAL_DISKS_GUID \\r
+  { \\r
+    0xc95a928, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtVirtualDisksGuid;\r
+\r
+//\r
+// EFI_WIN_NT_PHYSICAL_DISKS\r
+//\r
+#define EFI_WIN_NT_PHYSICAL_DISKS_GUID \\r
+  { \\r
+    0xc95a92f, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtPhysicalDisksGuid;\r
+\r
+//\r
+// EFI_WIN_NT_FILE_SYSTEM\r
+//\r
+#define EFI_WIN_NT_FILE_SYSTEM_GUID \\r
+  { \\r
+    0xc95a935, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtFileSystemGuid;\r
+\r
+//\r
+// EFI_WIN_NT_SERIAL_PORT\r
+//\r
+#define EFI_WIN_NT_SERIAL_PORT_GUID \\r
+  { \\r
+    0xc95a93d, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtSerialPortGuid;\r
+\r
+//\r
+// EFI_WIN_NT_UGA\r
+//\r
+#define EFI_WIN_NT_UGA_GUID \\r
+  { \\r
+    0xab248e99, 0xabe1, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtUgaGuid;\r
+\r
+//\r
+// EFI_WIN_NT_GOP\r
+//\r
+#define EFI_WIN_NT_GOP_GUID \\r
+  { \\r
+    0x4e11e955, 0xccca, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtGopGuid;\r
+\r
+//\r
+// EFI_WIN_NT_CONSOLE\r
+//\r
+#define EFI_WIN_NT_CONSOLE_GUID \\r
+  { \\r
+    0xba73672c, 0xa5d3, 0x11d4, 0xbd, 0x0, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtConsoleGuid;\r
+\r
+//\r
+// EFI_WIN_NT_MEMORY\r
+//\r
+#define EFI_WIN_NT_MEMORY_GUID \\r
+  { \\r
+    0x99042912, 0x122a, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtMemoryGuid;\r
+\r
+//\r
+// EFI_WIN_NT_CPU_MODEL\r
+//\r
+#define EFI_WIN_NT_CPU_MODEL_GUID \\r
+  { \\r
+    0xbee9b6ce, 0x2f8a, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtCPUModelGuid;\r
+\r
+//\r
+// EFI_WIN_NT_CPU_SPEED\r
+//\r
+#define EFI_WIN_NT_CPU_SPEED_GUID \\r
+  { \\r
+    0xd4f29055, 0xe1fb, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtCPUSpeedGuid;\r
+\r
+//\r
+// EFI_WIN_NT_PASS_THROUGH\r
+//\r
+#define EFI_WIN_NT_PASS_THROUGH_GUID \\r
+  { \\r
+    0xcc664eb8, 0x3c24, 0x4086, 0xb6, 0xf6, 0x34, 0xe8, 0x56, 0xbc, 0xe3, 0x6e \\r
+  }\r
+\r
+extern EFI_GUID gEfiWinNtPassThroughGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c
new file mode 100644 (file)
index 0000000..f0e827b
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WinNtThunk.c\r
+\r
+Abstract:\r
+\r
+  This protocol allows an EFI driver (DLL) in the NT emulation envirnment\r
+  to make Win32 API calls.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include EFI_PROTOCOL_DEFINITION (WinNtThunk)\r
+\r
+EFI_GUID  gEfiWinNtThunkProtocolGuid = EFI_WIN_NT_THUNK_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiWinNtThunkProtocolGuid, "EFI Win NT Thunk", "Win32 API thunk protocol");\r
diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h
new file mode 100644 (file)
index 0000000..5ad6245
--- /dev/null
@@ -0,0 +1,1276 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  WinNtThunk.h\r
+\r
+Abstract:\r
+\r
+  This protocol allows an EFI driver (DLL) in the NT emulation envirnment\r
+  to make Win32 API calls.\r
+\r
+  NEVER make a Win32 call directly, always make the call via this protocol.\r
+\r
+  There are no This pointers on the protocol member functions as they map\r
+  exactly into Win32 system calls.\r
+\r
+  YOU MUST include EfiWinNT.h in place of Efi.h to make this file compile.\r
+\r
+--*/\r
+\r
+#ifndef _WIN_NT_THUNK_H_\r
+#define _WIN_NT_THUNK_H_\r
+\r
+#define EFI_WIN_NT_THUNK_PROTOCOL_GUID \\r
+  { \\r
+    0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \\r
+  }\r
+\r
+//\r
+// The following APIs require EfiWinNT.h. In some environmnets the GUID\r
+// definitions are needed but the EfiWinNT.h is not included.\r
+// EfiWinNT.h is needed to support WINDOWS API requirements.\r
+//\r
+#ifdef _EFI_WIN_NT_H_\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtSleep) (\r
+  DWORD Milliseconds\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtSuspendThread) (\r
+  HANDLE hThread\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtGetCurrentThread) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetCurrentThreadId) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtGetCurrentProcess) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtCreateThread) (\r
+  LPSECURITY_ATTRIBUTES   lpThreadAttributes,\r
+  DWORD                   dwStackSize,\r
+  LPTHREAD_START_ROUTINE  lpStartAddress,\r
+  LPVOID                  lpParameter,\r
+  DWORD                   dwCreationFlags,\r
+  LPDWORD                 lpThreadId\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtTerminateThread) (\r
+  HANDLE hThread,\r
+  DWORD  dwExitCode\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSendMessage) (\r
+  HWND    hWnd,\r
+  UINT    Msg,\r
+  WPARAM  wParam,\r
+  LPARAM  lParam\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtExitThread) (\r
+  DWORD   dwExitCode\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtResumeThread) (\r
+  HANDLE hThread\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetThreadPriority) (\r
+  HANDLE    hThread,\r
+  INTN      nPriority\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtInitializeCriticalSection) (\r
+  LPCRITICAL_SECTION lpCriticalSection\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtDeleteCriticalSection) (\r
+  LPCRITICAL_SECTION lpCriticalSection\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtEnterCriticalSection) (\r
+  LPCRITICAL_SECTION lpCriticalSection\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtLeaveCriticalSection) (\r
+  LPCRITICAL_SECTION lpCriticalSection\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtTlsAlloc) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+LPVOID\r
+(WINAPI *WinNtTlsGetValue) (\r
+  DWORD dwTlsIndex\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtTlsSetValue) (\r
+  DWORD  dwTlsIndex,\r
+  LPVOID lpTlsValue\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtTlsFree) (\r
+  DWORD dwTlsIndex\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtCreateSemaphore) (\r
+  LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,\r
+  LONG                  lInitialCount,\r
+  LONG                  lMaximumCount,\r
+  LPCWSTR               lpName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtWaitForSingleObject) (\r
+  HANDLE  hHandle,\r
+  DWORD   dwMilliseconds\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtReleaseSemaphore) (\r
+  HANDLE  hSemaphore,\r
+  LONG    lReleaseCount,\r
+  LPLONG  lpPreviousCount\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtDuplicateHandle) (\r
+  HANDLE   hSourceProcessHandle,\r
+  HANDLE   hSourceHandle,\r
+  HANDLE   hTargetProcessHandle,\r
+  LPHANDLE lpTargetHandle,\r
+  DWORD    dwDesiredAccess,\r
+  BOOL     bInheritHandle,\r
+  DWORD    dwOptions\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtCreateConsoleScreenBuffer) (\r
+  DWORD                       DesiredAccess,\r
+  DWORD                       ShareMode,\r
+  CONST SECURITY_ATTRIBUTES   *SecurityAttributes,\r
+  DWORD                       Flags,\r
+  LPVOID                      ScreenBufferData\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetConsoleScreenBufferSize) (\r
+  HANDLE  ConsoleOutput,\r
+  COORD   Size\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetConsoleActiveScreenBuffer) (\r
+  HANDLE  ConsoleOutput\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFillConsoleOutputAttribute) (\r
+  HANDLE  ConsoleOutput,\r
+  WORD    Attribute,\r
+  DWORD   Length,\r
+  COORD   WriteCoord,\r
+  LPDWORD NumberOfAttrsWritten\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFillConsoleOutputCharacter) (\r
+  HANDLE  ConsoleOutput,\r
+  TCHAR   Character,\r
+  DWORD   Length,\r
+  COORD   WriteCoord,\r
+  LPDWORD NumberOfCharsWritten\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtWriteConsoleOutput) (\r
+  HANDLE          ConsoleOutput,\r
+  CONST CHAR_INFO *Buffer,\r
+  COORD           BufferSize,\r
+  COORD           BufferCoord,\r
+  PSMALL_RECT     WriteRegion\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtScrollConsoleScreenBuffer) (\r
+  HANDLE            ConsoleOutput,\r
+  CONST SMALL_RECT  *ScrollRectangle,\r
+  CONST SMALL_RECT  *ClipRectangle,\r
+  COORD             DestinationOrigin,\r
+  CONST CHAR_INFO   *Fill\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetConsoleTitleW) (\r
+  LPCTSTR   ConsoleTitle\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetConsoleCursorInfo) (\r
+  HANDLE                ConsoleOutput,\r
+  PCONSOLE_CURSOR_INFO  ConsoleCursorInfo\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetConsoleCursorInfo) (\r
+  HANDLE                      ConsoleOutput,\r
+  CONST CONSOLE_CURSOR_INFO   *ConsoleCursorInfo\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetPriorityClass) (\r
+  HANDLE  Process,\r
+  DWORD   PriorityClass\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtWriteConsoleInput) (\r
+  HANDLE              ConsoleInput,\r
+  CONST INPUT_RECORD  *Buffer,\r
+  DWORD               Legnth,\r
+  LPDWORD             NumberOfEventsWritten\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetNumberOfConsoleInputEvents) (\r
+  HANDLE              ConsoleInput,\r
+  LPDWORD             NumberOfEvents\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtGetStdHandle) (\r
+  DWORD   StdHandle\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtReadConsoleInput) (\r
+  HANDLE              ConsoleInput,\r
+  PINPUT_RECORD       Buffer,\r
+  DWORD               Length,\r
+  LPDWORD             NumberOfEventsRead\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtPeekConsoleInput) (\r
+  HANDLE              ConsoleInput,\r
+  PINPUT_RECORD       Buffer,\r
+  DWORD               Length,\r
+  LPDWORD             NumberOfEventsRead\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetConsoleCursorPosition) (\r
+  HANDLE              ConsoleInput,\r
+  COORD               CursorPosition\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtCreateFile) (\r
+  LPCWSTR               FileName,\r
+  DWORD                 DesiredAccess,\r
+  DWORD                 SharedMode,\r
+  LPSECURITY_ATTRIBUTES SecurityAttributes,\r
+  DWORD                 CreationDisposition,\r
+  DWORD                 FlagsAndAttributes,\r
+  HANDLE                TemplateFile\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtDeviceIoControl) (\r
+  HANDLE                DeviceHandle,\r
+  DWORD                 IoControlCode,\r
+  LPVOID                InBuffer,\r
+  DWORD                 InBufferSize,\r
+  LPVOID                OutBuffer,\r
+  DWORD                 OutBufferSize,\r
+  LPDWORD               BytesReturned,\r
+  LPOVERLAPPED          Overlapped\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtCreateDirectory) (\r
+  LPCWSTR               PathName,\r
+  LPSECURITY_ATTRIBUTES SecurityAttributes\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtRemoveDirectory) (\r
+  LPCWSTR               PathName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetFileAttributes) (\r
+  LPCWSTR               FileName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetFileAttributes) (\r
+  LPCWSTR               FileName,\r
+  DWORD                 FileAttributes\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtCreateFileMapping) (\r
+  HANDLE                  FileHandle,\r
+  LPSECURITY_ATTRIBUTES   Attributes,\r
+  DWORD                   Protect,\r
+  DWORD                   MaximumSizeHigh,\r
+  DWORD                   MaximumSizeLow,\r
+  LPCTSTR                 Name\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+LPVOID\r
+(WINAPI *WinNtMapViewOfFileEx) (\r
+  HANDLE                  FileHandle,\r
+  DWORD                   DesiredAccess,\r
+  DWORD                   FileOffsetHigh,\r
+  DWORD                   FileOffsetLow,\r
+  DWORD                   NumberOfBytesToMap,\r
+  LPVOID                  BaseAddress\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetEnvironmentVariable) (\r
+  LPCTSTR Name,\r
+  LPTSTR  Buffer,\r
+  DWORD   Size\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtCloseHandle) (\r
+  HANDLE    Object\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtSetFilePointer) (\r
+  HANDLE    FileHandle,\r
+  LONG      DistanceToMove,\r
+  PLONG     DistanceToHoveHigh,\r
+  DWORD     MoveMethod\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetEndOfFile) (\r
+  HANDLE    FileHandle\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtReadFile) (\r
+  HANDLE        FileHandle,\r
+  LPVOID        Buffer,\r
+  DWORD         NumberOfBytesToRead,\r
+  LPDWORD       NumberOfBytesRead,\r
+  LPOVERLAPPED  Overlapped\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtWriteFile) (\r
+  HANDLE        FileHandle,\r
+  LPCVOID       Buffer,\r
+  DWORD         NumberOfBytesToWrite,\r
+  LPDWORD       NumberOfBytesWritten,\r
+  LPOVERLAPPED  Overlapped\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetFileInformationByHandle) (\r
+  HANDLE                      FileHandle,\r
+  BY_HANDLE_FILE_INFORMATION  *FileInfo\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetDiskFreeSpace) (\r
+  LPCTSTR     RootPathName,\r
+  LPDWORD     SectorsPerCluster,\r
+  LPDWORD     BytesPerSector,\r
+  LPDWORD     NumberOfFreeClusters,\r
+  LPDWORD     TotalNumberOfClusters\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetDiskFreeSpaceEx) (\r
+  LPCTSTR             DirectoryName,\r
+  PULARGE_INTEGER     FreeBytesAvailable,\r
+  PULARGE_INTEGER     TotalNumberOfBytes,\r
+  PULARGE_INTEGER     TotoalNumberOfFreeBytes\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtMoveFile) (\r
+  LPCTSTR     ExistingFileName,\r
+  LPCTSTR     NewFileName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetFileTime) (\r
+  HANDLE      FileHandle,\r
+  FILETIME    *CreationTime,\r
+  FILETIME    *LastAccessTime,\r
+  FILETIME    *LastWriteTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSystemTimeToFileTime) (\r
+  SYSTEMTIME  * SystemTime,\r
+  FILETIME    * FileTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtDeleteFile) (\r
+  LPCTSTR   FileName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFlushFileBuffers) (\r
+  HANDLE\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetLastError) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+UINT\r
+(WINAPI *WinNtSetErrorMode) (\r
+  UINT  Mode\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetTickCount) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HMODULE\r
+(WINAPI *WinNtLoadLibraryEx) (\r
+  LPCTSTR LibFileName,\r
+  HANDLE  FileHandle,\r
+  DWORD   Flags\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+FARPROC\r
+(WINAPI *WinNtGetProcAddress) (\r
+  HMODULE Module,\r
+  LPCSTR  ProcName\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtGetTimeZoneInformation) (\r
+  LPTIME_ZONE_INFORMATION timeZoneInformation\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+MMRESULT\r
+(WINAPI *WinNttimeSetEvent) (\r
+  UINT           uDelay,\r
+  UINT           uResolution,\r
+  LPTIMECALLBACK lpTimeProc,\r
+  DWORD_PTR      dwUser,\r
+  UINT           fuEvent\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+MMRESULT\r
+(WINAPI *WinNttimeKillEvent) (\r
+  UINT           uTimerID\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+DWORD\r
+(WINAPI *WinNtSetTimeZoneInformation) (\r
+  LPTIME_ZONE_INFORMATION timeZoneInformation\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtGetSystemTime) (\r
+  LPSYSTEMTIME        SystemTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetSystemTime) (\r
+  CONST SYSTEMTIME    *SystemTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtGetLocalTime) (\r
+  LPSYSTEMTIME        SystemTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetLocalTime) (\r
+  CONST SYSTEMTIME    *SystemTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFileTimeToLocalFileTime) (\r
+  CONST FILETIME  *FileTime,\r
+  LPFILETIME      LocalFileTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFileTimeToSystemTime) (\r
+  CONST FILETIME  *FileTime,\r
+  LPSYSTEMTIME    SystemTime\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+HANDLE\r
+(WINAPI *WinNtFindFirstFile) (\r
+  LPCTSTR           FileName,\r
+  LPWIN32_FIND_DATA FindFileData\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFindNextFile) (\r
+  HANDLE            FindFile,\r
+  LPWIN32_FIND_DATA FindFileData\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFindClose) (\r
+  HANDLE            FindFile\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetCommState) (\r
+  HANDLE  FileHandle,\r
+  LPDCB   DCB\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetCommState) (\r
+  HANDLE  FileHandle,\r
+  LPDCB   DCB\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetCommState) (\r
+  HANDLE  FileHandle,\r
+  LPDCB   DCB\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtSetCommTimeouts) (\r
+  HANDLE          FileHandle,\r
+  LPCOMMTIMEOUTS  CommTimeouts\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+VOID\r
+(WINAPI *WinNtExitProcess) (\r
+  UINT uExitCode  // exit code for all threads\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtPurgeComm) (\r
+  HANDLE  FileHandle,\r
+  DWORD   Flags\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtEscapeCommFunction) (\r
+  HANDLE  FileHandle,\r
+  DWORD   Func\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtGetCommModemStatus) (\r
+  HANDLE  FileHandle,\r
+  LPDWORD ModemStat\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtClearCommError) (\r
+  HANDLE    FileHandle,\r
+  LPDWORD   Errors,\r
+  LPCOMSTAT Stat\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+INT32\r
+(WINAPIV *WinNtSprintf) (\r
+  LPWSTR    Buffer,\r
+  LPCWSTR   String,\r
+  ...\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HWND\r
+(WINAPI *WinNtGetDesktopWindow) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HWND\r
+(WINAPI *WinNtGetForegroundWindow) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HWND\r
+(WINAPI *WinNtCreateWindowEx) (\r
+  DWORD     dwExStyle,\r
+  LPCTSTR   lpClassName,\r
+  LPCTSTR   lpWindowName,\r
+  DWORD     dwStyle,\r
+  INT32     x,\r
+  INT32     y,\r
+  INT32     nWidth,\r
+  INT32     nHeight,\r
+  HWND      hWndParent,\r
+  HMENU     hMenu,\r
+  HINSTANCE hInstance,\r
+  LPVOID    *lpParam\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtUpdateWindow) (\r
+  HWND      hWnd\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtShowWindow) (\r
+  HWND        hWnd,\r
+  INT32       nCmdShow\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtDestroyWindow) (\r
+  HWND    hWnd\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HDC\r
+(WINAPI *WinNtGetWindowDC) (\r
+  HWND    hWnd\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtGetClientRect) (\r
+  HWND    hWnd,\r
+  LPRECT  lpRect\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtAdjustWindowRect) (\r
+  LPRECT  lpRect,\r
+  DWORD   dwStyle,\r
+  BOOL    bMenu\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+INT32\r
+(WINAPI *WinNtSetDIBitsToDevice) (\r
+  HDC,\r
+  INT32,\r
+  INT32,\r
+  DWORD,\r
+  DWORD,\r
+  INT32,\r
+  INT32,\r
+  UINT,\r
+  UINT,\r
+  CONST VOID       *,\r
+  CONST BITMAPINFO *,\r
+  UINT\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtBitBlt) (\r
+  HDC,\r
+  INT32,\r
+  INT32,\r
+  INT32,\r
+  INT32,\r
+  HDC,\r
+  INT32,\r
+  INT32,\r
+  DWORD\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtInvalidateRect) (\r
+  HWND        hWnd,\r
+  CONST RECT  *lpRect,\r
+  BOOL        bErase\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HDC\r
+(WINAPI *WinNtGetDC) (\r
+  HWND    hWnd\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+INT32\r
+(WINAPI *WinNtReleaseDC) (\r
+  HWND    hWnd,\r
+  HDC     hDC\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+ATOM\r
+(WINAPI *WinNtRegisterClassEx) (\r
+  CONST   WNDCLASSEX *\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtUnregisterClass) (\r
+  LPCTSTR   lpClassName,\r
+  HINSTANCE hInstance\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HDC\r
+(WINAPI *WinNtBeginPaint) (\r
+  HWND          hWnd,\r
+  LPPAINTSTRUCT lpPaint\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtEndPaint) (\r
+  HWND                hWnd,\r
+  CONST PAINTSTRUCT   *lpPaint\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+VOID\r
+(WINAPI *WinNtPostQuitMessage) (\r
+  INT32   nExitCode\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+LRESULT\r
+(WINAPI *WinNtDefWindowProc) (\r
+  HWND    hWnd,\r
+  UINT    Msg,\r
+  WPARAM  wParam,\r
+  LPARAM  lParam\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HICON\r
+(WINAPI *WinNtLoadIcon) (\r
+  HINSTANCE hInstance,\r
+  LPCTSTR   lpIconName\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HCURSOR\r
+(WINAPI *WinNtLoadCursor) (\r
+  HINSTANCE   hInstance,\r
+  LPCTSTR     lpCursorName\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+HGDIOBJ\r
+(WINAPI *WinNtGetStockObject) (\r
+  INT32\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtSetViewportOrgEx) (\r
+  HDC,\r
+  INT32,\r
+  INT32,\r
+  LPPOINT\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtSetWindowOrgEx) (\r
+  HDC,\r
+  INT32,\r
+  INT32,\r
+  LPPOINT\r
+  );\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtMoveWindow) (\r
+  HWND,\r
+  INT32,\r
+  INT32,\r
+  INT32,\r
+  INT32,\r
+  BOOL\r
+  );\r
+\r
+typedef\r
+WINGDIAPI\r
+BOOL\r
+(WINAPI *WinNtGetWindowRect) (\r
+  HWND,\r
+  LPRECT\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtGetMessage) (\r
+  LPMSG     lpMsg,\r
+  HWND      hWnd,\r
+  UINT      wMsgFilterMin,\r
+  UINT      wMsgFilterMax\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtTranslateMessage) (\r
+  CONST MSG *lpMsg\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtDispatchMessage) (\r
+  CONST MSG *lpMsg\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+HANDLE\r
+(WINAPI *WinNtGetProcessHeap) ();\r
+\r
+typedef\r
+WINUSERAPI\r
+LPVOID\r
+(WINAPI *WinNtHeapAlloc) (\r
+  HANDLE  hHeap,\r
+  DWORD   dwFlags,\r
+  SIZE_T  dwBytes\r
+  );\r
+\r
+typedef\r
+WINUSERAPI\r
+BOOL\r
+(WINAPI *WinNtHeapFree) (\r
+  HANDLE  hHeap,\r
+  DWORD   dwFlags,\r
+  LPVOID  lpMem\r
+  );\r
+\r
+typedef\r
+WINBASEAPI\r
+BOOL\r
+(WINAPI *WinNtFreeLibrary) (\r
+  HANDLE  ModHandle\r
+  );\r
+//\r
+//\r
+//\r
+EFI_FORWARD_DECLARATION (EFI_WIN_NT_THUNK_PROTOCOL);\r
+\r
+#define EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'T', 'T')\r
+\r
+typedef struct _EFI_WIN_NT_THUNK_PROTOCOL {\r
+  UINT64                              Signature;\r
+\r
+  //\r
+  // Win32 Process APIs\r
+  //\r
+  WinNtGetProcAddress                 GetProcAddress;\r
+  WinNtGetTickCount                   GetTickCount;\r
+  WinNtLoadLibraryEx                  LoadLibraryEx;\r
+  WinNtFreeLibrary                    FreeLibrary;\r
+\r
+  WinNtSetPriorityClass               SetPriorityClass;\r
+  WinNtSetThreadPriority              SetThreadPriority;\r
+  WinNtSleep                          Sleep;\r
+\r
+  WinNtSuspendThread                  SuspendThread;\r
+  WinNtGetCurrentThread               GetCurrentThread;\r
+  WinNtGetCurrentThreadId             GetCurrentThreadId;\r
+  WinNtGetCurrentProcess              GetCurrentProcess;\r
+  WinNtCreateThread                   CreateThread;\r
+  WinNtTerminateThread                TerminateThread;\r
+  WinNtSendMessage                    SendMessage;\r
+  WinNtExitThread                     ExitThread;\r
+  WinNtResumeThread                   ResumeThread;\r
+  WinNtDuplicateHandle                DuplicateHandle;\r
+\r
+  //\r
+  // Wint32 Mutex primitive\r
+  //\r
+  WinNtInitializeCriticalSection      InitializeCriticalSection;\r
+  WinNtEnterCriticalSection           EnterCriticalSection;\r
+  WinNtLeaveCriticalSection           LeaveCriticalSection;\r
+  WinNtDeleteCriticalSection          DeleteCriticalSection;\r
+  WinNtTlsAlloc                       TlsAlloc;\r
+  WinNtTlsFree                        TlsFree;\r
+  WinNtTlsSetValue                    TlsSetValue;\r
+  WinNtTlsGetValue                    TlsGetValue;\r
+  WinNtCreateSemaphore                CreateSemaphore;\r
+  WinNtWaitForSingleObject            WaitForSingleObject;\r
+  WinNtReleaseSemaphore               ReleaseSemaphore;\r
+\r
+  //\r
+  // Win32 Console APIs\r
+  //\r
+  WinNtCreateConsoleScreenBuffer      CreateConsoleScreenBuffer;\r
+  WinNtFillConsoleOutputAttribute     FillConsoleOutputAttribute;\r
+  WinNtFillConsoleOutputCharacter     FillConsoleOutputCharacter;\r
+  WinNtGetConsoleCursorInfo           GetConsoleCursorInfo;\r
+  WinNtGetNumberOfConsoleInputEvents  GetNumberOfConsoleInputEvents;\r
+  WinNtPeekConsoleInput               PeekConsoleInput;\r
+  WinNtScrollConsoleScreenBuffer      ScrollConsoleScreenBuffer;\r
+  WinNtReadConsoleInput               ReadConsoleInput;\r
+\r
+  WinNtSetConsoleActiveScreenBuffer   SetConsoleActiveScreenBuffer;\r
+  WinNtSetConsoleCursorInfo           SetConsoleCursorInfo;\r
+  WinNtSetConsoleCursorPosition       SetConsoleCursorPosition;\r
+  WinNtSetConsoleScreenBufferSize     SetConsoleScreenBufferSize;\r
+  WinNtSetConsoleTitleW               SetConsoleTitleW;\r
+  WinNtWriteConsoleInput              WriteConsoleInput;\r
+  WinNtWriteConsoleOutput             WriteConsoleOutput;\r
+\r
+  //\r
+  // Win32 File APIs\r
+  //\r
+  WinNtCreateFile                     CreateFile;\r
+  WinNtDeviceIoControl                DeviceIoControl;\r
+  WinNtCreateDirectory                CreateDirectory;\r
+  WinNtRemoveDirectory                RemoveDirectory;\r
+  WinNtGetFileAttributes              GetFileAttributes;\r
+  WinNtSetFileAttributes              SetFileAttributes;\r
+  WinNtCreateFileMapping              CreateFileMapping;\r
+  WinNtCloseHandle                    CloseHandle;\r
+  WinNtDeleteFile                     DeleteFile;\r
+  WinNtFindFirstFile                  FindFirstFile;\r
+  WinNtFindNextFile                   FindNextFile;\r
+  WinNtFindClose                      FindClose;\r
+  WinNtFlushFileBuffers               FlushFileBuffers;\r
+  WinNtGetEnvironmentVariable         GetEnvironmentVariable;\r
+  WinNtGetLastError                   GetLastError;\r
+  WinNtSetErrorMode                   SetErrorMode;\r
+  WinNtGetStdHandle                   GetStdHandle;\r
+  WinNtMapViewOfFileEx                MapViewOfFileEx;\r
+  WinNtReadFile                       ReadFile;\r
+  WinNtSetEndOfFile                   SetEndOfFile;\r
+  WinNtSetFilePointer                 SetFilePointer;\r
+  WinNtWriteFile                      WriteFile;\r
+  WinNtGetFileInformationByHandle     GetFileInformationByHandle;\r
+  WinNtGetDiskFreeSpace               GetDiskFreeSpace;\r
+  WinNtGetDiskFreeSpaceEx             GetDiskFreeSpaceEx;\r
+  WinNtMoveFile                       MoveFile;\r
+  WinNtSetFileTime                    SetFileTime;\r
+  WinNtSystemTimeToFileTime           SystemTimeToFileTime;\r
+\r
+  //\r
+  // Win32 Time APIs\r
+  //\r
+  WinNtFileTimeToLocalFileTime        FileTimeToLocalFileTime;\r
+  WinNtFileTimeToSystemTime           FileTimeToSystemTime;\r
+  WinNtGetSystemTime                  GetSystemTime;\r
+  WinNtSetSystemTime                  SetSystemTime;\r
+  WinNtGetLocalTime                   GetLocalTime;\r
+  WinNtSetLocalTime                   SetLocalTime;\r
+  WinNtGetTimeZoneInformation         GetTimeZoneInformation;\r
+  WinNtSetTimeZoneInformation         SetTimeZoneInformation;\r
+  WinNttimeSetEvent                   timeSetEvent;\r
+  WinNttimeKillEvent                  timeKillEvent;\r
+\r
+  //\r
+  // Win32 Serial APIs\r
+  //\r
+  WinNtClearCommError                 ClearCommError;\r
+  WinNtEscapeCommFunction             EscapeCommFunction;\r
+  WinNtGetCommModemStatus             GetCommModemStatus;\r
+  WinNtGetCommState                   GetCommState;\r
+  WinNtSetCommState                   SetCommState;\r
+  WinNtPurgeComm                      PurgeComm;\r
+  WinNtSetCommTimeouts                SetCommTimeouts;\r
+\r
+  WinNtExitProcess                    ExitProcess;\r
+\r
+  WinNtSprintf                        SPrintf;\r
+\r
+  WinNtGetDesktopWindow               GetDesktopWindow;\r
+  WinNtGetForegroundWindow            GetForegroundWindow;\r
+  WinNtCreateWindowEx                 CreateWindowEx;\r
+  WinNtShowWindow                     ShowWindow;\r
+  WinNtUpdateWindow                   UpdateWindow;\r
+  WinNtDestroyWindow                  DestroyWindow;\r
+  WinNtInvalidateRect                 InvalidateRect;\r
+  WinNtGetWindowDC                    GetWindowDC;\r
+  WinNtGetClientRect                  GetClientRect;\r
+  WinNtAdjustWindowRect               AdjustWindowRect;\r
+  WinNtSetDIBitsToDevice              SetDIBitsToDevice;\r
+  WinNtBitBlt                         BitBlt;\r
+  WinNtGetDC                          GetDC;\r
+  WinNtReleaseDC                      ReleaseDC;\r
+  WinNtRegisterClassEx                RegisterClassEx;\r
+  WinNtUnregisterClass                UnregisterClass;\r
+\r
+  WinNtBeginPaint                     BeginPaint;\r
+  WinNtEndPaint                       EndPaint;\r
+  WinNtPostQuitMessage                PostQuitMessage;\r
+  WinNtDefWindowProc                  DefWindowProc;\r
+  WinNtLoadIcon                       LoadIcon;\r
+  WinNtLoadCursor                     LoadCursor;\r
+  WinNtGetStockObject                 GetStockObject;\r
+  WinNtSetViewportOrgEx               SetViewportOrgEx;\r
+  WinNtSetWindowOrgEx                 SetWindowOrgEx;\r
+  WinNtMoveWindow                     MoveWindow;\r
+  WinNtGetWindowRect                  GetWindowRect;\r
+\r
+  WinNtGetMessage                     GetMessage;\r
+  WinNtTranslateMessage               TranslateMessage;\r
+  WinNtDispatchMessage                DispatchMessage;\r
+\r
+  WinNtGetProcessHeap                 GetProcessHeap;\r
+  WinNtHeapAlloc                      HeapAlloc;\r
+  WinNtHeapFree                       HeapFree;\r
+\r
+} EFI_WIN_NT_THUNK_PROTOCOL;\r
+\r
+#endif\r
+\r
+extern EFI_GUID gEfiWinNtThunkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile
new file mode 100644 (file)
index 0000000..b067e85
--- /dev/null
@@ -0,0 +1,97 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the BootsectImage utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=BootsectImage\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\BootsectImage.c"\r
+TARGET_EXE_INCLUDE = "$(TARGET_SOURCE_DIR)\fat.h"  \\r
+                     "$(TARGET_SOURCE_DIR)\mbr.h"  \\r
+\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\Common.lib\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(EDK_TOOLS_OUTPUT)\Common.lib $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj \r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c
new file mode 100644 (file)
index 0000000..d71a03d
--- /dev/null
@@ -0,0 +1,881 @@
+/*++\r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  bootsectimage.c\r
+    \r
+Abstract:\r
+  Patch the BPB information in boot sector image file.\r
+  Patch the MBR code in MBR image file.\r
+\r
+--*/\r
+\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include "fat.h"\r
+#include "mbr.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define DEBUG_WARN  0x1\r
+#define DEBUG_ERROR 0x2\r
+int WriteToFile (\r
+  void *BootSector, \r
+  char *FileName\r
+  )\r
+/*++\r
+Routine Description:\r
+  Write 512 bytes boot sector to file.\r
+\r
+Arguments:\r
+  BootSector - point to a buffer containing 512 bytes boot sector to write\r
+  FileName   - file to write to\r
+\r
+Return:\r
+  int        - number of bytes wrote,\r
+                 512 indicates write successful\r
+                 0 indicates write failure\r
+--*/\r
+{\r
+  FILE *FileHandle;\r
+  int  result;\r
+\r
+  FileHandle = fopen (FileName, "r+b");\r
+  if (FileHandle == NULL) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Open file: %s", FileName);\r
+    return 0;\r
+  }\r
+  fseek (FileHandle, 0, SEEK_SET);\r
+\r
+  result = fwrite (BootSector, 1, 512, FileHandle);\r
+  if (result != 512) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Write file: %s", FileName);\r
+    result = 0;\r
+  }\r
+\r
+  fclose (FileHandle);\r
+  return result;\r
+}\r
+\r
+int ReadFromFile (\r
+  void *BootSector, \r
+  char *FileName\r
+  )\r
+/*++\r
+Routine Description:\r
+  Read first 512 bytes from file.\r
+\r
+Arguments:\r
+  BootSector - point to a buffer receiving the first 512 bytes data from file\r
+  FileName   - file to read from\r
+\r
+Return:\r
+  int        - number of bytes read,\r
+                 512 indicates read successful\r
+                 0 indicates read failure\r
+--*/\r
+{\r
+  FILE *FileHandle;\r
+  int  result;\r
+\r
+  FileHandle = fopen (FileName, "rb");\r
+  if (FileHandle == NULL) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Open file: %s", FileName);\r
+    return 0;\r
+  }\r
+\r
+  result = fread (BootSector, 1, 512, FileHandle);\r
+  if (result != 512) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Read file: %s", FileName);\r
+    result = 0;\r
+  }\r
+\r
+  fclose (FileHandle);\r
+  return result;\r
+}\r
+\r
+char *\r
+FatTypeToString (\r
+  IN FAT_TYPE        FatType\r
+  )\r
+/*++\r
+Routine Description:\r
+  Convert enum type of FatType to string\r
+--*/\r
+{\r
+  switch (FatType) {\r
+  case FatTypeFat12:\r
+    return "FAT12";\r
+  case FatTypeFat16:\r
+    return "FAT16";\r
+  case FatTypeFat32:\r
+    return "FAT32";\r
+  default:\r
+    break;\r
+  }\r
+  return "FAT Unknown";\r
+}\r
+\r
+FAT_TYPE\r
+GetFatType (\r
+  IN FAT_BPB_STRUCT  *FatBpb\r
+  )\r
+/*++\r
+Routine Description:\r
+  Determine the FAT type according to BIOS Paramater Block (BPB) data\r
+\r
+Arguments:\r
+  FatBpb - BIOS Parameter Block (BPB) data, 512 Bytes\r
+\r
+Return:\r
+  FatTypeUnknown - Cannot determine the FAT type\r
+  FatTypeFat12   - FAT12\r
+  FatTypeFat16   - FAT16\r
+  FatTypeFat32   - FAT32\r
+--*/\r
+{\r
+  FAT_TYPE FatType;\r
+  UINTN    RootDirSectors;\r
+  UINTN    FATSz;\r
+  UINTN    TotSec;\r
+  UINTN    DataSec;\r
+  UINTN    CountOfClusters;\r
+  CHAR8    FilSysType[9];\r
+\r
+  FatType = FatTypeUnknown;\r
+\r
+  //\r
+  // Simple check\r
+  //\r
+  if (FatBpb->Fat12_16.Signature != FAT_BS_SIGNATURE) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: Signature Invalid - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.Signature, FAT_BS_SIGNATURE);\r
+    return FatTypeUnknown;\r
+  }\r
+\r
+  //\r
+  // Check according to FAT spec\r
+  //\r
+  if ((FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP1) &&\r
+      (FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP2)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BS_jmpBoot - %02x, expected - %02x or %02x",\r
+        FatBpb->Fat12_16.BS_jmpBoot[0], FAT_BS_JMP1, FAT_BS_JMP2);\r
+    return FatTypeUnknown;\r
+  }\r
+\r
+  if ((FatBpb->Fat12_16.BPB_BytsPerSec != 512) &&\r
+      (FatBpb->Fat12_16.BPB_BytsPerSec != 1024) &&\r
+      (FatBpb->Fat12_16.BPB_BytsPerSec != 2048) &&\r
+      (FatBpb->Fat12_16.BPB_BytsPerSec != 4096)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_BytsPerSec - %04x, expected - %04x, %04x, %04x, or %04x",\r
+        FatBpb->Fat12_16.BPB_BytsPerSec, 512, 1024, 2048, 4096);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (FatBpb->Fat12_16.BPB_BytsPerSec != 512) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT: BPB_BytsPerSec - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_BytsPerSec, 512);\r
+  }\r
+  if ((FatBpb->Fat12_16.BPB_SecPerClus != 1) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 2) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 4) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 8) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 16) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 32) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 64) &&\r
+      (FatBpb->Fat12_16.BPB_SecPerClus != 128)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_SecPerClus - %02x, expected - %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x",\r
+        FatBpb->Fat12_16.BPB_BytsPerSec, 1, 2, 4, 8, 16, 32, 64, 128);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus > 32 * 1024) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_BytsPerSec * BPB_SecPerClus - %08x, expected <= %08x",\r
+        FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus, 32 * 1024);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (FatBpb->Fat12_16.BPB_RsvdSecCnt == 0) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_RsvdSecCnt - %04x, expected - Non-Zero",\r
+        FatBpb->Fat12_16.BPB_RsvdSecCnt);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (FatBpb->Fat12_16.BPB_NumFATs != 2) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT: BPB_NumFATs - %02x, expected - %02x",\r
+        FatBpb->Fat12_16.BPB_NumFATs, 2);\r
+  }\r
+  if ((FatBpb->Fat12_16.BPB_Media != 0xF0) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xF8) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xF9) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFA) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFB) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFC) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFD) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFE) &&\r
+      (FatBpb->Fat12_16.BPB_Media != 0xFF)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_Media - %02x, expected - %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x",\r
+        FatBpb->Fat12_16.BPB_Media, 0xF0, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF);\r
+    return FatTypeUnknown;\r
+  }\r
+\r
+  //\r
+  // Algo in FAT spec\r
+  //\r
+  RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) +\r
+                    (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) /\r
+                   FatBpb->Fat12_16.BPB_BytsPerSec;\r
+\r
+  if (FatBpb->Fat12_16.BPB_FATSz16 != 0) {\r
+    FATSz = FatBpb->Fat12_16.BPB_FATSz16;\r
+  } else {\r
+    FATSz = FatBpb->Fat32.BPB_FATSz32;\r
+  }\r
+  if (FATSz == 0) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_FATSz16, BPB_FATSz32 - 0, expected - Non-Zero");\r
+    return FatTypeUnknown;\r
+  }\r
+\r
+  if (FatBpb->Fat12_16.BPB_TotSec16 != 0) {\r
+    TotSec = FatBpb->Fat12_16.BPB_TotSec16;\r
+  } else {\r
+    TotSec = FatBpb->Fat12_16.BPB_TotSec32;\r
+  }\r
+  if (TotSec == 0) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_TotSec16, BPB_TotSec32 - 0, expected - Non-Zero");\r
+    return FatTypeUnknown;\r
+  }\r
+\r
+  DataSec = TotSec - (\r
+                      FatBpb->Fat12_16.BPB_RsvdSecCnt +\r
+                      FatBpb->Fat12_16.BPB_NumFATs * FATSz +\r
+                      RootDirSectors\r
+                     );\r
+\r
+  CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus;\r
+\r
+  if (CountOfClusters < FAT_MAX_FAT12_CLUSTER) {\r
+    FatType = FatTypeFat12;\r
+  } else if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) {\r
+    FatType = FatTypeFat16;\r
+  } else {\r
+    FatType = FatTypeFat32;\r
+  }\r
+  //\r
+  // Check according to FAT spec\r
+  //\r
+  if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&\r
+       (FatBpb->Fat12_16.BPB_RsvdSecCnt != 1)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT12_16: BPB_RsvdSecCnt - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_RsvdSecCnt, 1);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+       (FatBpb->Fat12_16.BPB_RsvdSecCnt != 32)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_RsvdSecCnt - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_RsvdSecCnt, 32);\r
+  }\r
+  if ((FatType == FatTypeFat16) &&\r
+      (FatBpb->Fat12_16.BPB_RootEntCnt != 512)) {\r
+    printf ("WARNING: FAT16: BPB_RootEntCnt - %04x, expected - %04x\n",\r
+        FatBpb->Fat12_16.BPB_RootEntCnt, 512);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat12_16.BPB_RootEntCnt != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_RootEntCnt - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_RootEntCnt, 0);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat12_16.BPB_TotSec16 != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_TotSec16 - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_TotSec16, 0);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat12_16.BPB_FATSz16 != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_FATSz16 - %04x, expected - %04x",\r
+        FatBpb->Fat12_16.BPB_FATSz16, 0);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat12_16.BPB_TotSec32 == 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_TotSec32 - %04x, expected - Non-Zero",\r
+        FatBpb->Fat12_16.BPB_TotSec32);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BPB_FATSz32 == 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_FATSz32 - %08x, expected - Non-Zero",\r
+        FatBpb->Fat32.BPB_FATSz32);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BPB_FSVer != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_FSVer - %08x, expected - %04x",\r
+        FatBpb->Fat32.BPB_FSVer, 0);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BPB_RootClus != 2)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_RootClus - %08x, expected - %04x",\r
+        FatBpb->Fat32.BPB_RootClus, 2);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BPB_FSInfo != 1)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_FSInfo - %08x, expected - %04x",\r
+        FatBpb->Fat32.BPB_FSInfo, 1);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BPB_BkBootSec != 6)) {\r
+    DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_BkBootSec - %08x, expected - %04x",\r
+        FatBpb->Fat32.BPB_BkBootSec, 6);\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      ((*(UINT32 *)FatBpb->Fat32.BPB_Reserved != 0) ||\r
+       (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 1) != 0) ||\r
+       (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 2) != 0))) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_Reserved - %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x, expected - 0",\r
+        FatBpb->Fat32.BPB_Reserved[0],\r
+        FatBpb->Fat32.BPB_Reserved[1],\r
+        FatBpb->Fat32.BPB_Reserved[2],\r
+        FatBpb->Fat32.BPB_Reserved[3],\r
+        FatBpb->Fat32.BPB_Reserved[4],\r
+        FatBpb->Fat32.BPB_Reserved[5],\r
+        FatBpb->Fat32.BPB_Reserved[6],\r
+        FatBpb->Fat32.BPB_Reserved[7],\r
+        FatBpb->Fat32.BPB_Reserved[8],\r
+        FatBpb->Fat32.BPB_Reserved[9],\r
+        FatBpb->Fat32.BPB_Reserved[10],\r
+        FatBpb->Fat32.BPB_Reserved[11]);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&\r
+       (FatBpb->Fat12_16.BS_Reserved1 != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT12_16: BS_Reserved1 - %02x, expected - 0\n",\r
+        FatBpb->Fat12_16.BS_Reserved1);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BS_Reserved1 != 0)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BS_Reserved1 - %02x, expected - 0\n",\r
+        FatBpb->Fat32.BS_Reserved1);\r
+    return FatTypeUnknown;\r
+  }\r
+  if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&\r
+       (FatBpb->Fat12_16.BS_BootSig != FAT_BS_BOOTSIG)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT12_16: BS_BootSig - %02x, expected - %02x\n",\r
+        FatBpb->Fat12_16.BS_BootSig, FAT_BS_BOOTSIG);\r
+    return FatTypeUnknown;\r
+  }\r
+  if ((FatType == FatTypeFat32) &&\r
+      (FatBpb->Fat32.BS_BootSig != FAT_BS_BOOTSIG)) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BS_BootSig - %02x, expected - %02x\n",\r
+        FatBpb->Fat32.BS_BootSig, FAT_BS_BOOTSIG);\r
+    return FatTypeUnknown;\r
+  }\r
+  \r
+  if ((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) {\r
+    memcpy (FilSysType, FatBpb->Fat12_16.BS_FilSysType, 8);\r
+    FilSysType[8] = 0;\r
+    if ((FatType == FatTypeFat12) && \r
+        (strcmp (FilSysType, FAT12_FILSYSTYPE) != 0) &&\r
+        (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) {\r
+      DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT12: BS_FilSysType - %s, expected - %s, or %s\n",\r
+          FilSysType, FAT12_FILSYSTYPE, FAT_FILSYSTYPE);\r
+    }\r
+    if ((FatType == FatTypeFat16) && \r
+        (strcmp (FilSysType, FAT16_FILSYSTYPE) != 0) &&\r
+        (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) {\r
+      DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT16: BS_FilSysType - %s, expected - %s, or %s\n",\r
+          FilSysType, FAT16_FILSYSTYPE, FAT_FILSYSTYPE);\r
+    }\r
+  }\r
+  if (FatType == FatTypeFat32) {\r
+    memcpy (FilSysType, FatBpb->Fat32.BS_FilSysType, 8);\r
+    FilSysType[8] = 0;\r
+    if (strcmp (FilSysType, FAT32_FILSYSTYPE) != 0) {\r
+      DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BS_FilSysType - %s, expected - %s\n",\r
+          FilSysType, FAT32_FILSYSTYPE);\r
+    }\r
+  }\r
+\r
+  //\r
+  // pass all check, get FAT type\r
+  //\r
+  return FatType;\r
+}\r
+\r
+\r
+void\r
+ParseBootSector (\r
+  char *FileName\r
+  )\r
+{\r
+  FAT_BPB_STRUCT  FatBpb;\r
+  FAT_TYPE        FatType;\r
+  \r
+  if (ReadFromFile ((void *)&FatBpb, FileName) == 0) {\r
+    return ;\r
+  }\r
+  \r
+  FatType = GetFatType (&FatBpb);\r
+  if (FatType <= FatTypeUnknown || FatType >= FatTypeMax) {\r
+    printf ("ERROR: Unknown Fat Type!\n");\r
+    return;\r
+  }\r
+\r
+  printf ("\nBoot Sector %s:\n", FatTypeToString (FatType));\r
+  printf ("\n");\r
+  printf ("  Offset Title                        Data\n");\r
+  printf ("==================================================================\n");\r
+  printf ("  0      JMP instruction              %02x %02x %02x\n",\r
+                                                 FatBpb.Fat12_16.BS_jmpBoot[0],\r
+                                                 FatBpb.Fat12_16.BS_jmpBoot[1],\r
+                                                 FatBpb.Fat12_16.BS_jmpBoot[2]);\r
+  printf ("  3      OEM                          %c%c%c%c%c%c%c%c\n",\r
+                                                 FatBpb.Fat12_16.BS_OEMName[0],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[1],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[2],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[3],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[4],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[5],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[6],\r
+                                                 FatBpb.Fat12_16.BS_OEMName[7]);\r
+  printf ("\n");\r
+  printf ("BIOS Parameter Block\n");\r
+  printf ("  B      Bytes per sector             %04x\n", FatBpb.Fat12_16.BPB_BytsPerSec);\r
+  printf ("  D      Sectors per cluster          %02x\n", FatBpb.Fat12_16.BPB_SecPerClus);\r
+  printf ("  E      Reserved sectors             %04x\n", FatBpb.Fat12_16.BPB_RsvdSecCnt);\r
+  printf ("  10     Number of FATs               %02x\n", FatBpb.Fat12_16.BPB_NumFATs);\r
+  printf ("  11     Root entries                 %04x\n", FatBpb.Fat12_16.BPB_RootEntCnt);\r
+  printf ("  13     Sectors (under 32MB)         %04x\n", FatBpb.Fat12_16.BPB_TotSec16);\r
+  printf ("  15     Media descriptor             %02x\n", FatBpb.Fat12_16.BPB_Media);\r
+  printf ("  16     Sectors per FAT (small vol.) %04x\n", FatBpb.Fat12_16.BPB_FATSz16);\r
+  printf ("  18     Sectors per track            %04x\n", FatBpb.Fat12_16.BPB_SecPerTrk);\r
+  printf ("  1A     Heads                        %04x\n", FatBpb.Fat12_16.BPB_NumHeads);\r
+  printf ("  1C     Hidden sectors               %08x\n", FatBpb.Fat12_16.BPB_HiddSec);\r
+  printf ("  20     Sectors (over 32MB)          %08x\n", FatBpb.Fat12_16.BPB_TotSec32);\r
+  printf ("\n");\r
+  if (FatType != FatTypeFat32) {\r
+    printf ("  24     BIOS drive                   %02x\n", FatBpb.Fat12_16.BS_DrvNum);\r
+    printf ("  25     (Unused)                     %02x\n", FatBpb.Fat12_16.BS_Reserved1);\r
+    printf ("  26     Ext. boot signature          %02x\n", FatBpb.Fat12_16.BS_BootSig);\r
+    printf ("  27     Volume serial number         %08x\n", FatBpb.Fat12_16.BS_VolID);\r
+    printf ("  2B     Volume lable                 %c%c%c%c%c%c%c%c%c%c%c\n",\r
+                                                   FatBpb.Fat12_16.BS_VolLab[0],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[1],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[2],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[3],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[4],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[5],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[6],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[7],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[8],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[9],\r
+                                                   FatBpb.Fat12_16.BS_VolLab[10]);\r
+    printf ("  36     File system                  %c%c%c%c%c%c%c%c\n",\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[0],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[1],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[2],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[3],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[4],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[5],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[6],\r
+                                                   FatBpb.Fat12_16.BS_FilSysType[7]);\r
+    printf ("\n");\r
+  } else {\r
+    printf ("FAT32 Section\n");\r
+    printf ("  24     Sectors per FAT (large vol.) %08x\n", FatBpb.Fat32.BPB_FATSz32);\r
+    printf ("  28     Flags                        %04x\n", FatBpb.Fat32.BPB_ExtFlags);\r
+    printf ("  2A     Version                      %04x\n", FatBpb.Fat32.BPB_FSVer);\r
+    printf ("  2C     Root dir 1st cluster         %08x\n", FatBpb.Fat32.BPB_RootClus);\r
+    printf ("  30     FSInfo sector                %04x\n", FatBpb.Fat32.BPB_FSInfo);\r
+    printf ("  32     Backup boot sector           %04x\n", FatBpb.Fat32.BPB_BkBootSec);\r
+    printf ("  34     (Reserved)                   %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",\r
+                                                   FatBpb.Fat32.BPB_Reserved[0],\r
+                                                   FatBpb.Fat32.BPB_Reserved[1],\r
+                                                   FatBpb.Fat32.BPB_Reserved[2],\r
+                                                   FatBpb.Fat32.BPB_Reserved[3],\r
+                                                   FatBpb.Fat32.BPB_Reserved[4],\r
+                                                   FatBpb.Fat32.BPB_Reserved[5],\r
+                                                   FatBpb.Fat32.BPB_Reserved[6],\r
+                                                   FatBpb.Fat32.BPB_Reserved[7],\r
+                                                   FatBpb.Fat32.BPB_Reserved[8],\r
+                                                   FatBpb.Fat32.BPB_Reserved[9],\r
+                                                   FatBpb.Fat32.BPB_Reserved[10],\r
+                                                   FatBpb.Fat32.BPB_Reserved[11]);\r
+    printf ("\n");\r
+    printf ("  40     BIOS drive                   %02x\n", FatBpb.Fat32.BS_DrvNum);\r
+    printf ("  41     (Unused)                     %02x\n", FatBpb.Fat32.BS_Reserved1);\r
+    printf ("  42     Ext. boot signature          %02x\n", FatBpb.Fat32.BS_BootSig);\r
+    printf ("  43     Volume serial number         %08x\n", FatBpb.Fat32.BS_VolID);\r
+    printf ("  47     Volume lable                 %c%c%c%c%c%c%c%c%c%c%c\n",\r
+                                                   FatBpb.Fat32.BS_VolLab[0],\r
+                                                   FatBpb.Fat32.BS_VolLab[1],\r
+                                                   FatBpb.Fat32.BS_VolLab[2],\r
+                                                   FatBpb.Fat32.BS_VolLab[3],\r
+                                                   FatBpb.Fat32.BS_VolLab[4],\r
+                                                   FatBpb.Fat32.BS_VolLab[5],\r
+                                                   FatBpb.Fat32.BS_VolLab[6],\r
+                                                   FatBpb.Fat32.BS_VolLab[7],\r
+                                                   FatBpb.Fat32.BS_VolLab[8],\r
+                                                   FatBpb.Fat32.BS_VolLab[9],\r
+                                                   FatBpb.Fat32.BS_VolLab[10]);\r
+    printf ("  52     File system                  %c%c%c%c%c%c%c%c\n",\r
+                                                   FatBpb.Fat32.BS_FilSysType[0],\r
+                                                   FatBpb.Fat32.BS_FilSysType[1],\r
+                                                   FatBpb.Fat32.BS_FilSysType[2],\r
+                                                   FatBpb.Fat32.BS_FilSysType[3],\r
+                                                   FatBpb.Fat32.BS_FilSysType[4],\r
+                                                   FatBpb.Fat32.BS_FilSysType[5],\r
+                                                   FatBpb.Fat32.BS_FilSysType[6],\r
+                                                   FatBpb.Fat32.BS_FilSysType[7]);\r
+    printf ("\n");\r
+  }\r
+  printf ("  1FE    Signature                    %04x\n", FatBpb.Fat12_16.Signature);\r
+  printf ("\n");\r
+\r
+  \r
+  return ;\r
+}\r
+\r
+void\r
+PatchBootSector (\r
+  char *DestFileName,\r
+  char *SourceFileName,\r
+  BOOL ForcePatch\r
+  )\r
+/*++\r
+Routine Description:\r
+  Patch destination file according to the information from source file.\r
+  Only patch BPB data but leave boot code un-touched.\r
+\r
+Arguments:\r
+  DestFileName   - Destination file to patch\r
+  SourceFileName - Source file where patch from\r
+--*/\r
+{\r
+  FAT_BPB_STRUCT  DestFatBpb;\r
+  FAT_BPB_STRUCT  SourceFatBpb;\r
+  FAT_TYPE        DestFatType;\r
+  FAT_TYPE        SourceFatType;\r
+  CHAR8           VolLab[11];\r
+  CHAR8           FilSysType[8];\r
+  \r
+  if (ReadFromFile ((void *)&DestFatBpb, DestFileName) == 0) {\r
+    return ;\r
+  }\r
+  if (ReadFromFile ((void *)&SourceFatBpb, SourceFileName) == 0) {\r
+    return ;\r
+  }\r
+  \r
+  DestFatType = GetFatType (&DestFatBpb);\r
+  SourceFatType = GetFatType (&SourceFatBpb);\r
+\r
+  if (DestFatType != SourceFatType) {\r
+    //\r
+    // FAT type mismatch\r
+    //\r
+    if (ForcePatch) {\r
+      DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT type mismatch: Dest - %s, Source - %s", \r
+          FatTypeToString(DestFatType), FatTypeToString(SourceFatType));\r
+    } else {\r
+      DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT type mismatch: Dest - %s, Source - %s", \r
+          FatTypeToString(DestFatType), FatTypeToString(SourceFatType));\r
+      return ;\r
+    }\r
+  }\r
+\r
+  if (SourceFatType <= FatTypeUnknown || SourceFatType >= FatTypeMax) {\r
+    DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Unknown Fat Type!\n");\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Copy BPB/boot data (excluding BS_jmpBoot, BS_OEMName, BootCode and Signature) from SourceFatBpb to DestFatBpb\r
+  //\r
+  printf ("Patching %s BPB: ", FatTypeToString (SourceFatType));\r
+  if (SourceFatType != FatTypeFat32) {\r
+    memcpy (\r
+      &DestFatBpb.Fat12_16.BPB_BytsPerSec,\r
+      &SourceFatBpb.Fat12_16.BPB_BytsPerSec,\r
+      ((UINTN)&DestFatBpb.Fat12_16.Reserved - (UINTN)&DestFatBpb.Fat12_16.BPB_BytsPerSec)\r
+      );\r
+  } else {\r
+    memcpy (\r
+      &DestFatBpb.Fat32.BPB_BytsPerSec,\r
+      &SourceFatBpb.Fat32.BPB_BytsPerSec,\r
+      ((UINTN)&DestFatBpb.Fat32.Reserved - (UINTN)&DestFatBpb.Fat32.BPB_BytsPerSec)\r
+      );\r
+  }\r
+\r
+  //\r
+  // Set BS_VolLab and BS_FilSysType of DestFatBpb\r
+  //\r
+  //        BS_VolLab     BS_FilSysType\r
+  // FAT12: EFI FAT12     FAT12\r
+  // FAT16: EFI FAT16     FAT16\r
+  // FAT32: EFI FAT32     FAT32\r
+  //\r
+  if (SourceFatType == FatTypeFat32) {\r
+    memcpy (VolLab, "EFI FAT32  ", sizeof(VolLab));\r
+    memcpy (FilSysType, FAT32_FILSYSTYPE, sizeof(FilSysType));\r
+  } else if (SourceFatType == FatTypeFat16) {\r
+    memcpy (VolLab, "EFI FAT16  ", sizeof(VolLab));\r
+    memcpy (FilSysType, FAT16_FILSYSTYPE, sizeof(FilSysType));\r
+  } else {\r
+    memcpy (VolLab, "EFI FAT12  ", sizeof(VolLab));\r
+    memcpy (FilSysType, FAT12_FILSYSTYPE, sizeof(FilSysType));\r
+  }\r
+  if (SourceFatType != FatTypeFat32) {\r
+    memcpy (DestFatBpb.Fat12_16.BS_VolLab, VolLab, sizeof(VolLab));\r
+    memcpy (DestFatBpb.Fat12_16.BS_FilSysType, FilSysType, sizeof(FilSysType));\r
+  } else {\r
+    memcpy (DestFatBpb.Fat32.BS_VolLab, VolLab, sizeof(VolLab));\r
+    memcpy (DestFatBpb.Fat32.BS_FilSysType, FilSysType, sizeof(FilSysType));\r
+  }\r
+  \r
+  //\r
+  // Set Signature of DestFatBpb to 55AA\r
+  //\r
+  DestFatBpb.Fat12_16.Signature = FAT_BS_SIGNATURE;\r
+\r
+  //\r
+  // Write DestFatBpb\r
+  //\r
+  if (WriteToFile ((void *)&DestFatBpb, DestFileName)) {\r
+    printf ("successfully!\n");\r
+  } else {\r
+    printf ("failed!\n");\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+void\r
+ParseMbr (\r
+  char *FileName\r
+  )\r
+{\r
+  MASTER_BOOT_RECORD  Mbr;\r
+  \r
+  if (ReadFromFile ((void *)&Mbr, FileName) == 0) {\r
+    return ;\r
+  }\r
\r
+  printf ("\nMaster Boot Record:\n");\r
+  printf ("\n");\r
+  printf ("  Offset Title                        Value\n");\r
+  printf ("==================================================================\n");\r
+  printf ("  0      Master bootstrap loader code (not list)\n");\r
+  printf ("  1B8    Windows disk signature       %08x\n", Mbr.UniqueMbrSignature);\r
+  printf ("\n");\r
+  printf ("Partition Table Entry #1\n");\r
+  printf ("  1BE    80 = active partition        %02x\n", Mbr.PartitionRecord[0].BootIndicator);\r
+  printf ("  1BF    Start head                   %02x\n", Mbr.PartitionRecord[0].StartHead);\r
+  printf ("  1C0    Start sector                 %02x\n", Mbr.PartitionRecord[0].StartSector);\r
+  printf ("  1C1    Start cylinder               %02x\n", Mbr.PartitionRecord[0].StartTrack);\r
+  printf ("  1C2    Partition type indicator     %02x\n", Mbr.PartitionRecord[0].OSType);\r
+  printf ("  1C3    End head                     %02x\n", Mbr.PartitionRecord[0].EndHead);\r
+  printf ("  1C4    End sector                   %02x\n", Mbr.PartitionRecord[0].EndSector);\r
+  printf ("  1C5    End cylinder                 %02x\n", Mbr.PartitionRecord[0].EndTrack);\r
+  printf ("  1C6    Sectors preceding partition  %08x\n", Mbr.PartitionRecord[0].StartingLBA);\r
+  printf ("  1CA    Sectors in partition         %08x\n", Mbr.PartitionRecord[0].SizeInLBA);\r
+  printf ("\n");\r
+  printf ("Partition Table Entry #2\n");\r
+  printf ("  1CE    80 = active partition        %02x\n", Mbr.PartitionRecord[1].BootIndicator);\r
+  printf ("  1CF    Start head                   %02x\n", Mbr.PartitionRecord[1].StartHead);\r
+  printf ("  1D0    Start sector                 %02x\n", Mbr.PartitionRecord[1].StartSector);\r
+  printf ("  1D1    Start cylinder               %02x\n", Mbr.PartitionRecord[1].StartTrack);\r
+  printf ("  1D2    Partition type indicator     %02x\n", Mbr.PartitionRecord[1].OSType);\r
+  printf ("  1D3    End head                     %02x\n", Mbr.PartitionRecord[1].EndHead);\r
+  printf ("  1D4    End sector                   %02x\n", Mbr.PartitionRecord[1].EndSector);\r
+  printf ("  1D5    End cylinder                 %02x\n", Mbr.PartitionRecord[1].EndTrack);\r
+  printf ("  1D6    Sectors preceding partition  %08x\n", Mbr.PartitionRecord[1].StartingLBA);\r
+  printf ("  1DA    Sectors in partition         %08x\n", Mbr.PartitionRecord[1].SizeInLBA);\r
+  printf ("\n");\r
+  printf ("Partition Table Entry #3\n");\r
+  printf ("  1DE    80 = active partition        %02x\n", Mbr.PartitionRecord[2].BootIndicator);\r
+  printf ("  1DF    Start head                   %02x\n", Mbr.PartitionRecord[2].StartHead);\r
+  printf ("  1E0    Start sector                 %02x\n", Mbr.PartitionRecord[2].StartSector);\r
+  printf ("  1E1    Start cylinder               %02x\n", Mbr.PartitionRecord[2].StartTrack);\r
+  printf ("  1E2    Partition type indicator     %02x\n", Mbr.PartitionRecord[2].OSType);\r
+  printf ("  1E3    End head                     %02x\n", Mbr.PartitionRecord[2].EndHead);\r
+  printf ("  1E4    End sector                   %02x\n", Mbr.PartitionRecord[2].EndSector);\r
+  printf ("  1E5    End cylinder                 %02x\n", Mbr.PartitionRecord[2].EndTrack);\r
+  printf ("  1E6    Sectors preceding partition  %08x\n", Mbr.PartitionRecord[2].StartingLBA);\r
+  printf ("  1EA    Sectors in partition         %08x\n", Mbr.PartitionRecord[2].SizeInLBA);\r
+  printf ("\n");\r
+  printf ("Partition Table Entry #4\n");\r
+  printf ("  1EE    80 = active partition        %02x\n", Mbr.PartitionRecord[3].BootIndicator);\r
+  printf ("  1EF    Start head                   %02x\n", Mbr.PartitionRecord[3].StartHead);\r
+  printf ("  1F0    Start sector                 %02x\n", Mbr.PartitionRecord[3].StartSector);\r
+  printf ("  1F1    Start cylinder               %02x\n", Mbr.PartitionRecord[3].StartTrack);\r
+  printf ("  1F2    Partition type indicator     %02x\n", Mbr.PartitionRecord[3].OSType);\r
+  printf ("  1F3    End head                     %02x\n", Mbr.PartitionRecord[3].EndHead);\r
+  printf ("  1F4    End sector                   %02x\n", Mbr.PartitionRecord[3].EndSector);\r
+  printf ("  1F5    End cylinder                 %02x\n", Mbr.PartitionRecord[3].EndTrack);\r
+  printf ("  1F6    Sectors preceding partition  %08x\n", Mbr.PartitionRecord[3].StartingLBA);\r
+  printf ("  1FA    Sectors in partition         %08x\n", Mbr.PartitionRecord[3].SizeInLBA);\r
+  printf ("\n");\r
+  printf ("  1FE    Signature                    %04x\n", Mbr.Signature);\r
+  printf ("\n");\r
+\r
+  return ;\r
+}\r
+\r
+void\r
+PatchMbr (\r
+  char *DestFileName,\r
+  char *SourceFileName\r
+  )\r
+{\r
+  MASTER_BOOT_RECORD  DestMbr;\r
+  MASTER_BOOT_RECORD  SourceMbr;\r
+  \r
+  if (ReadFromFile ((void *)&DestMbr, DestFileName) == 0) {\r
+    return ;\r
+  }\r
+  if (ReadFromFile ((void *)&SourceMbr, SourceFileName) == 0) {\r
+    return ;\r
+  }\r
+  \r
+  if (SourceMbr.Signature != MBR_SIGNATURE) {\r
+    printf ("ERROR: Invalid MBR!\n");\r
+    return;\r
+  }\r
+\r
+  printf ("Patching MBR:\n");\r
+  memcpy (\r
+    &DestMbr.PartitionRecord[0],\r
+    &SourceMbr.PartitionRecord[0],\r
+    sizeof(DestMbr.PartitionRecord)\r
+    );\r
+\r
+  DestMbr.Signature = MBR_SIGNATURE;\r
+\r
+\r
+  if (WriteToFile ((void *)&DestMbr, DestFileName)) {\r
+    printf ("\tsuccessfully!\n");\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+{\r
+  printf (\r
+    "Usage:\n"\r
+    "bootsectimage [-m] [-v] -p SrcImage\n"\r
+    "bootsectimage [-m] [-v] [-f] -g SrcImage DstImage\n"\r
+    "where\n"\r
+    "  -p: parse SrcImage\n"\r
+    "  -g: get info from SrcImage, and patch to DstImage\n"\r
+    "  -f: force patch even FAT type of SrcImage and DstImage mismatch\n"\r
+    "  -m: process MBR instead of boot sector\n"\r
+    "  -v: verbose\n"\r
+    );\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char *argv[]\r
+  )\r
+{\r
+  char *SrcImage;\r
+  char *DstImage;\r
+  BOOL ForcePatch;    // -f\r
+  BOOL ProcessMbr;    // -m\r
+  BOOL DoParse;       // -p SrcImage or -g SrcImage DstImage\r
+  BOOL Verbose;       // -v\r
+  \r
+  SrcImage = DstImage = NULL;\r
+  ForcePatch = FALSE;\r
+  ProcessMbr = FALSE;\r
+  DoParse    = TRUE;\r
+  Verbose    = FALSE;\r
+\r
+  SetUtilityName ("bootsectimage");\r
+\r
+  argc--; argv++;\r
+\r
+  if (argc == 0) {\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+\r
+  while (argc != 0) {\r
+    if (strcmp (*argv, "-f") == 0) {\r
+      ForcePatch = TRUE;\r
+    } else if (strcmp (*argv, "-p") == 0) {\r
+      DoParse    = TRUE;\r
+      argc--; argv++;\r
+      if (argc < 1) {\r
+        PrintUsage ();\r
+        return -1;\r
+      }\r
+      SrcImage   = *argv;\r
+    } else if (strcmp (*argv, "-g") == 0) {\r
+      DoParse    = FALSE;\r
+      argc--; argv++;\r
+      if (argc < 2) {\r
+        PrintUsage ();\r
+        return -1;\r
+      }\r
+      SrcImage   = *argv;\r
+      argc--; argv++;\r
+      DstImage   = *argv;\r
+    } else if (strcmp (*argv, "-m") == 0) {\r
+      ProcessMbr = TRUE;\r
+    } else if (strcmp (*argv, "-v") == 0) {\r
+      Verbose    = TRUE;\r
+    } else {\r
+      PrintUsage ();\r
+      return -1;\r
+    }\r
+\r
+    argc--; argv++;\r
+  }\r
+\r
+  if (ForcePatch && DoParse) {\r
+    printf ("Cannot apply force(-f) to parse(-p)!\n");\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+  if (ForcePatch && !DoParse && ProcessMbr) {\r
+    printf ("Cannot apply force(-f) to processing MBR (-g -m)!\n");\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+\r
+  if (Verbose) {\r
+    SetDebugMsgMask (DEBUG_WARN | DEBUG_ERROR);\r
+  } else {\r
+    SetDebugMsgMask (0);\r
+  }\r
+\r
+  if (DoParse) {\r
+    if (ProcessMbr) {\r
+      ParseMbr (SrcImage);\r
+    } else {\r
+      ParseBootSector (SrcImage);\r
+    }\r
+  } else {\r
+    if (ProcessMbr) {\r
+      PatchMbr (DstImage, SrcImage);\r
+    } else {\r
+      PatchBootSector (DstImage, SrcImage, ForcePatch);\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h
new file mode 100644 (file)
index 0000000..3303126
--- /dev/null
@@ -0,0 +1,158 @@
+/*++\r
+\r
+Copyright 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    fat.h\r
+    \r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _FAT_BPB_H_\r
+#define _FAT_BPB_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  //\r
+  // Fat common field\r
+  //\r
+  UINT8              BS_jmpBoot[3];\r
+  CHAR8              BS_OEMName[8];\r
+  UINT16             BPB_BytsPerSec;\r
+  UINT8              BPB_SecPerClus;\r
+  UINT16             BPB_RsvdSecCnt;\r
+  UINT8              BPB_NumFATs;\r
+  UINT16             BPB_RootEntCnt;\r
+  UINT16             BPB_TotSec16;\r
+  UINT8              BPB_Media;\r
+  UINT16             BPB_FATSz16;\r
+  UINT16             BPB_SecPerTrk;\r
+  UINT16             BPB_NumHeads;\r
+  UINT32             BPB_HiddSec;\r
+  UINT32             BPB_TotSec32;\r
+\r
+  //\r
+  // Fat12/16 specific field\r
+  //\r
+  UINT8              BS_DrvNum;\r
+  UINT8              BS_Reserved1;\r
+  UINT8              BS_BootSig;\r
+  UINT32             BS_VolID;\r
+  CHAR8              BS_VolLab[11];\r
+  CHAR8              BS_FilSysType[8];\r
+\r
+  //\r
+  // Boot Code and Data\r
+  //\r
+  UINT8              Reserved[448];\r
+\r
+  //\r
+  // Fat common signature - 0xAA55\r
+  //\r
+  UINT16             Signature;\r
+} FAT12_16_BPB_STRUCT;\r
+\r
+typedef struct {\r
+  //\r
+  // Fat common field\r
+  //\r
+  UINT8              BS_jmpBoot[3];\r
+  CHAR8              BS_OEMName[8];\r
+  UINT16             BPB_BytsPerSec;\r
+  UINT8              BPB_SecPerClus;\r
+  UINT16             BPB_RsvdSecCnt;\r
+  UINT8              BPB_NumFATs;\r
+  UINT16             BPB_RootEntCnt;\r
+  UINT16             BPB_TotSec16;\r
+  UINT8              BPB_Media;\r
+  UINT16             BPB_FATSz16;\r
+  UINT16             BPB_SecPerTrk;\r
+  UINT16             BPB_NumHeads;\r
+  UINT32             BPB_HiddSec;\r
+  UINT32             BPB_TotSec32;\r
+\r
+  //\r
+  // Fat32 specific field\r
+  //\r
+  UINT32             BPB_FATSz32;\r
+  UINT16             BPB_ExtFlags;\r
+  UINT16             BPB_FSVer;\r
+  UINT32             BPB_RootClus;\r
+  UINT16             BPB_FSInfo;\r
+  UINT16             BPB_BkBootSec;\r
+  UINT8              BPB_Reserved[12];\r
+  UINT8              BS_DrvNum;\r
+  UINT8              BS_Reserved1;\r
+  UINT8              BS_BootSig;\r
+  UINT32             BS_VolID;\r
+  CHAR8              BS_VolLab[11];\r
+  CHAR8              BS_FilSysType[8];\r
+\r
+  //\r
+  // Boot Code and Data\r
+  //\r
+  UINT8              Reserved[420];\r
+\r
+  //\r
+  // Fat common signature - 0xAA55\r
+  //\r
+  UINT16             Signature;\r
+} FAT32_BPB_STRUCT;\r
+\r
+typedef union {\r
+  FAT12_16_BPB_STRUCT   Fat12_16;\r
+  FAT32_BPB_STRUCT      Fat32;\r
+} FAT_BPB_STRUCT;\r
+\r
+typedef enum {\r
+  FatTypeUnknown,\r
+  FatTypeFat12,\r
+  FatTypeFat16,\r
+  FatTypeFat32,\r
+  FatTypeMax\r
+} FAT_TYPE;\r
+\r
+typedef struct {\r
+  CHAR8              DIR_Name[11];\r
+  UINT8              DIR_Attr;\r
+  UINT8              DIR_NTRes;\r
+  UINT8              DIR_CrtTimeTenth;\r
+  UINT16             DIR_CrtTime;\r
+  UINT16             DIR_CrtDate;\r
+  UINT16             DIR_LstAccDate;\r
+  UINT16             DIR_FstClusHI;\r
+  UINT16             DIR_WrtTime;\r
+  UINT16             DIR_WrtDate;\r
+  UINT16             DIR_FstClusLO;\r
+  UINT32             DIR_FileSize;\r
+} FAT_DIRECTORY_ENTRY;\r
+\r
+#pragma pack()\r
+\r
+#define FAT_MAX_FAT12_CLUSTER         0xFF5\r
+#define FAT_MAX_FAT16_CLUSTER         0xFFF5\r
+\r
+#define FAT_BS_SIGNATURE      0xAA55\r
+#define FAT_BS_BOOTSIG        0x29\r
+#define FAT_BS_JMP1           0xEB\r
+#define FAT_BS_JMP2           0xE9\r
+#define FAT_FILSYSTYPE        "FAT     "\r
+#define FAT12_FILSYSTYPE      "FAT12   "\r
+#define FAT16_FILSYSTYPE      "FAT16   "\r
+#define FAT32_FILSYSTYPE      "FAT32   "\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h
new file mode 100644 (file)
index 0000000..5a95097
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    mbr.h\r
+    \r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _MBR_H_\r
+#define _MBR_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+#define MAX_MBR_PARTITIONS          4\r
+\r
+//\r
+// MBR Partition Entry\r
+//\r
+typedef struct {\r
+  UINT8  BootIndicator;\r
+  UINT8  StartHead;\r
+  UINT8  StartSector;\r
+  UINT8  StartTrack;\r
+  UINT8  OSType;\r
+  UINT8  EndHead;\r
+  UINT8  EndSector;\r
+  UINT8  EndTrack;\r
+  UINT32 StartingLBA;\r
+  UINT32 SizeInLBA;\r
+} MBR_PARTITION_RECORD;\r
+\r
+//\r
+// MBR Partition table\r
+//\r
+typedef struct {\r
+  UINT8                 BootCode[440];\r
+  UINT32                UniqueMbrSignature;\r
+  UINT16                Unknown;\r
+  MBR_PARTITION_RECORD  PartitionRecord[MAX_MBR_PARTITIONS];\r
+  UINT16                Signature;\r
+} MASTER_BOOT_RECORD;\r
+\r
+#pragma pack()\r
+\r
+#define MBR_SIGNATURE               0xAA55\r
+#define EXTENDED_DOS_PARTITION      0x05\r
+#define EXTENDED_WINDOWS_PARTITION  0x0F\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c
new file mode 100644 (file)
index 0000000..aa2a22e
--- /dev/null
@@ -0,0 +1,497 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CommonLib.c\r
+\r
+Abstract:\r
+\r
+  Common Library Functions\r
\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "PeiHob.h"\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "CommonLib.h"\r
+\r
+VOID\r
+PeiZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to zero for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT8  *Ptr;\r
+\r
+  Ptr = Buffer;\r
+  while (Size--) {\r
+    *(Ptr++) = 0;\r
+  }\r
+}\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+\r
+  Destination8  = Destination;\r
+  Source8       = Source;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+}\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+{\r
+  PeiZeroMem (Buffer, Size);\r
+}\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  PeiCopyMem (Destination, Source, Length);\r
+}\r
+\r
+INTN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares to GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  =  0  if Guid1 == Guid2\r
+  != 0  if Guid1 != Guid2 \r
+\r
+--*/\r
+{\r
+  INT32 *g1;\r
+  INT32 *g2;\r
+  INT32 r;\r
+\r
+  //\r
+  // Compare 32 bits at a time\r
+  //\r
+  g1  = (INT32 *) Guid1;\r
+  g2  = (INT32 *) Guid2;\r
+\r
+  r   = g1[0] - g2[0];\r
+  r |= g1[1] - g2[1];\r
+  r |= g1[2] - g2[2];\r
+  r |= g1[3] - g2[3];\r
+\r
+  return r;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileImage (\r
+  IN CHAR8    *InputFileName,\r
+  OUT CHAR8   **InputFileImage,\r
+  OUT UINT32  *BytesRead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function opens a file and reads it into a memory buffer.  The function \r
+  will allocate the memory buffer and returns the size of the buffer.\r
+\r
+Arguments:\r
+\r
+  InputFileName     The name of the file to read.\r
+  InputFileImage    A pointer to the memory buffer.\r
+  BytesRead         The size of the memory buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     No resource to complete operations.\r
+\r
+--*/\r
+{\r
+  FILE    *InputFile;\r
+  UINT32  FileSize;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (InputFileName == NULL || strlen (InputFileName) == 0 || InputFileImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Open the file and copy contents into a memory buffer.\r
+  //\r
+  //\r
+  // Open the file\r
+  //\r
+  InputFile = fopen (InputFileName, "rb");\r
+  if (InputFile == NULL) {\r
+    printf ("ERROR: Could not open input file \"%s\".\n", InputFileName);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Go to the end so that we can determine the file size\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_END)) {\r
+    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the file size\r
+  //\r
+  FileSize = ftell (InputFile);\r
+  if (FileSize == -1) {\r
+    printf ("ERROR: System error parsing input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Allocate a buffer\r
+  //\r
+  *InputFileImage = malloc (FileSize);\r
+  if (*InputFileImage == NULL) {\r
+    fclose (InputFile);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Reset to the beginning of the file\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_SET)) {\r
+    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    free (*InputFileImage);\r
+    *InputFileImage = NULL;\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read all of the file contents.\r
+  //\r
+  *BytesRead = fread (*InputFileImage, sizeof (UINT8), FileSize, InputFile);\r
+  if (*BytesRead != sizeof (UINT8) * FileSize) {\r
+    printf ("ERROR: Reading file \"%s\"%i.\n", InputFileName);\r
+    fclose (InputFile);\r
+    free (*InputFileImage);\r
+    *InputFileImage = NULL;\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Close the file\r
+  //\r
+  fclose (InputFile);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT8\r
+CalculateChecksum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description:\r
+\r
+  This function calculates the value needed for a valid UINT8 checksum\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 8 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  return (UINT8) (0x100 - CalculateSum8 (Buffer, Size));\r
+}\r
+\r
+UINT8\r
+CalculateSum8 (\r
+  IN UINT8  *Buffer,\r
+  IN UINT32 Size\r
+  )\r
+/*++\r
+  \r
+Routine Description::\r
+\r
+  This function calculates the UINT8 sum for the requested region.\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 8 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINT8 Sum;\r
+\r
+  Sum = 0;\r
+\r
+  //\r
+  // Perform the byte sum for buffer\r
+  //\r
+  for (Index = 0; Index < Size; Index++) {\r
+    Sum = (UINT8) (Sum + Buffer[Index]);\r
+  }\r
+\r
+  return Sum;\r
+}\r
+\r
+UINT16\r
+CalculateChecksum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description::\r
+\r
+  This function calculates the value needed for a valid UINT16 checksum\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 16 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  return (UINT16) (0x10000 - CalculateSum16 (Buffer, Size));\r
+}\r
+\r
+UINT16\r
+CalculateSum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description:\r
+\r
+  This function calculates the UINT16 sum for the requested region.\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 16 bit checksum\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  UINT16  Sum;\r
+\r
+  Sum = 0;\r
+\r
+  //\r
+  // Perform the word sum for buffer\r
+  //\r
+  for (Index = 0; Index < Size; Index++) {\r
+    Sum = (UINT16) (Sum + Buffer[Index]);\r
+  }\r
+\r
+  return (UINT16) Sum;\r
+}\r
+\r
+EFI_STATUS\r
+PrintGuid (\r
+  IN EFI_GUID *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a GUID to STDOUT.\r
+\r
+Arguments:\r
+\r
+  Guid    Pointer to a GUID to print.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The GUID was printed.\r
+  EFI_INVALID_PARAMETER   The input was NULL.\r
+\r
+--*/\r
+{\r
+  if (Guid == NULL) {\r
+    printf ("ERROR: PrintGuid called with a NULL value.\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  printf (\r
+    "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",\r
+    Guid->Data1,\r
+    Guid->Data2,\r
+    Guid->Data3,\r
+    Guid->Data4[0],\r
+    Guid->Data4[1],\r
+    Guid->Data4[2],\r
+    Guid->Data4[3],\r
+    Guid->Data4[4],\r
+    Guid->Data4[5],\r
+    Guid->Data4[6],\r
+    Guid->Data4[7]\r
+    );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PrintGuidToBuffer (\r
+  IN EFI_GUID     *Guid,\r
+  IN OUT UINT8    *Buffer,\r
+  IN UINT32       BufferLen,\r
+  IN BOOLEAN      Uppercase\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a GUID to a buffer\r
+\r
+Arguments:\r
+\r
+  Guid      - Pointer to a GUID to print.\r
+  Buffer    - Pointer to a user-provided buffer to print to\r
+  BufferLen - Size of the Buffer\r
+  Uppercase - If use upper case.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The GUID was printed.\r
+  EFI_INVALID_PARAMETER   The input was NULL.\r
+  EFI_BUFFER_TOO_SMALL    The input buffer was not big enough\r
+  \r
+--*/\r
+{\r
+  if (Guid == NULL) {\r
+    printf ("ERROR: PrintGuidToBuffer() called with a NULL value\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (BufferLen < PRINTED_GUID_BUFFER_SIZE) {\r
+    printf ("ERORR: PrintGuidToBuffer() called with invalid buffer size\n");\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  if (Uppercase) {\r
+    sprintf (\r
+      Buffer,\r
+      "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
+      Guid->Data1,\r
+      Guid->Data2,\r
+      Guid->Data3,\r
+      Guid->Data4[0],\r
+      Guid->Data4[1],\r
+      Guid->Data4[2],\r
+      Guid->Data4[3],\r
+      Guid->Data4[4],\r
+      Guid->Data4[5],\r
+      Guid->Data4[6],\r
+      Guid->Data4[7]\r
+      );\r
+  } else {\r
+    sprintf (\r
+      Buffer,\r
+      "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
+      Guid->Data1,\r
+      Guid->Data2,\r
+      Guid->Data3,\r
+      Guid->Data4[0],\r
+      Guid->Data4[1],\r
+      Guid->Data4[2],\r
+      Guid->Data4[3],\r
+      Guid->Data4[4],\r
+      Guid->Data4[5],\r
+      Guid->Data4[6],\r
+      Guid->Data4[7]\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h
new file mode 100644 (file)
index 0000000..f36856e
--- /dev/null
@@ -0,0 +1,120 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CommonLib.h\r
+\r
+Abstract:\r
+\r
+  Common library assistance routines.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMMON_LIB_H\r
+#define _EFI_COMMON_LIB_H\r
+\r
+#include "TianoCommon.h"\r
+\r
+#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
+//\r
+// Function declarations\r
+//\r
+VOID\r
+PeiZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+;\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+;\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+;\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+;\r
+\r
+INTN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileImage (\r
+  IN CHAR8    *InputFileName,\r
+  OUT CHAR8   **InputFileImage,\r
+  OUT UINT32  *BytesRead\r
+  )\r
+;\r
+\r
+UINT8\r
+CalculateChecksum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT8\r
+CalculateSum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT16\r
+CalculateChecksum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT16\r
+CalculateSum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PrintGuid (\r
+  IN EFI_GUID                     *Guid\r
+  )\r
+;\r
+\r
+#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
+EFI_STATUS\r
+PrintGuidToBuffer (\r
+  IN EFI_GUID     *Guid,\r
+  IN OUT UINT8    *Buffer,\r
+  IN UINT32       BufferLen,\r
+  IN BOOLEAN      Uppercase\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h
new file mode 100644 (file)
index 0000000..4353593
--- /dev/null
@@ -0,0 +1,90 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                              \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Compress.h\r
+\r
+Abstract:\r
+\r
+  Header file for compression routine.\r
+  Providing both EFI and Tiano Compress algorithms.\r
+  \r
+--*/\r
+\r
+#ifndef _COMPRESS_H_\r
+#define _COMPRESS_H_\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Tiano compression routine.\r
+\r
+--*/\r
+EFI_STATUS\r
+TianoCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Efi compression routine.\r
+\r
+--*/\r
+EFI_STATUS\r
+EfiCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+  EFI_OUT_OF_RESOURCES  - No resource to complete function.\r
+  EFI_INVALID_PARAMETER - Parameter supplied is wrong.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(*COMPRESS_FUNCTION) (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c
new file mode 100644 (file)
index 0000000..6239ccc
--- /dev/null
@@ -0,0 +1,327 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  crc32.c\r
+\r
+Abstract:\r
+\r
+  CalcuateCrc32 routine.\r
+  \r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include "TianoCommon.h"\r
+#include "crc32.h"\r
+\r
+UINT32  mCrcTable[256] = {\r
+  0x00000000,\r
+  0x77073096,\r
+  0xEE0E612C,\r
+  0x990951BA,\r
+  0x076DC419,\r
+  0x706AF48F,\r
+  0xE963A535,\r
+  0x9E6495A3,\r
+  0x0EDB8832,\r
+  0x79DCB8A4,\r
+  0xE0D5E91E,\r
+  0x97D2D988,\r
+  0x09B64C2B,\r
+  0x7EB17CBD,\r
+  0xE7B82D07,\r
+  0x90BF1D91,\r
+  0x1DB71064,\r
+  0x6AB020F2,\r
+  0xF3B97148,\r
+  0x84BE41DE,\r
+  0x1ADAD47D,\r
+  0x6DDDE4EB,\r
+  0xF4D4B551,\r
+  0x83D385C7,\r
+  0x136C9856,\r
+  0x646BA8C0,\r
+  0xFD62F97A,\r
+  0x8A65C9EC,\r
+  0x14015C4F,\r
+  0x63066CD9,\r
+  0xFA0F3D63,\r
+  0x8D080DF5,\r
+  0x3B6E20C8,\r
+  0x4C69105E,\r
+  0xD56041E4,\r
+  0xA2677172,\r
+  0x3C03E4D1,\r
+  0x4B04D447,\r
+  0xD20D85FD,\r
+  0xA50AB56B,\r
+  0x35B5A8FA,\r
+  0x42B2986C,\r
+  0xDBBBC9D6,\r
+  0xACBCF940,\r
+  0x32D86CE3,\r
+  0x45DF5C75,\r
+  0xDCD60DCF,\r
+  0xABD13D59,\r
+  0x26D930AC,\r
+  0x51DE003A,\r
+  0xC8D75180,\r
+  0xBFD06116,\r
+  0x21B4F4B5,\r
+  0x56B3C423,\r
+  0xCFBA9599,\r
+  0xB8BDA50F,\r
+  0x2802B89E,\r
+  0x5F058808,\r
+  0xC60CD9B2,\r
+  0xB10BE924,\r
+  0x2F6F7C87,\r
+  0x58684C11,\r
+  0xC1611DAB,\r
+  0xB6662D3D,\r
+  0x76DC4190,\r
+  0x01DB7106,\r
+  0x98D220BC,\r
+  0xEFD5102A,\r
+  0x71B18589,\r
+  0x06B6B51F,\r
+  0x9FBFE4A5,\r
+  0xE8B8D433,\r
+  0x7807C9A2,\r
+  0x0F00F934,\r
+  0x9609A88E,\r
+  0xE10E9818,\r
+  0x7F6A0DBB,\r
+  0x086D3D2D,\r
+  0x91646C97,\r
+  0xE6635C01,\r
+  0x6B6B51F4,\r
+  0x1C6C6162,\r
+  0x856530D8,\r
+  0xF262004E,\r
+  0x6C0695ED,\r
+  0x1B01A57B,\r
+  0x8208F4C1,\r
+  0xF50FC457,\r
+  0x65B0D9C6,\r
+  0x12B7E950,\r
+  0x8BBEB8EA,\r
+  0xFCB9887C,\r
+  0x62DD1DDF,\r
+  0x15DA2D49,\r
+  0x8CD37CF3,\r
+  0xFBD44C65,\r
+  0x4DB26158,\r
+  0x3AB551CE,\r
+  0xA3BC0074,\r
+  0xD4BB30E2,\r
+  0x4ADFA541,\r
+  0x3DD895D7,\r
+  0xA4D1C46D,\r
+  0xD3D6F4FB,\r
+  0x4369E96A,\r
+  0x346ED9FC,\r
+  0xAD678846,\r
+  0xDA60B8D0,\r
+  0x44042D73,\r
+  0x33031DE5,\r
+  0xAA0A4C5F,\r
+  0xDD0D7CC9,\r
+  0x5005713C,\r
+  0x270241AA,\r
+  0xBE0B1010,\r
+  0xC90C2086,\r
+  0x5768B525,\r
+  0x206F85B3,\r
+  0xB966D409,\r
+  0xCE61E49F,\r
+  0x5EDEF90E,\r
+  0x29D9C998,\r
+  0xB0D09822,\r
+  0xC7D7A8B4,\r
+  0x59B33D17,\r
+  0x2EB40D81,\r
+  0xB7BD5C3B,\r
+  0xC0BA6CAD,\r
+  0xEDB88320,\r
+  0x9ABFB3B6,\r
+  0x03B6E20C,\r
+  0x74B1D29A,\r
+  0xEAD54739,\r
+  0x9DD277AF,\r
+  0x04DB2615,\r
+  0x73DC1683,\r
+  0xE3630B12,\r
+  0x94643B84,\r
+  0x0D6D6A3E,\r
+  0x7A6A5AA8,\r
+  0xE40ECF0B,\r
+  0x9309FF9D,\r
+  0x0A00AE27,\r
+  0x7D079EB1,\r
+  0xF00F9344,\r
+  0x8708A3D2,\r
+  0x1E01F268,\r
+  0x6906C2FE,\r
+  0xF762575D,\r
+  0x806567CB,\r
+  0x196C3671,\r
+  0x6E6B06E7,\r
+  0xFED41B76,\r
+  0x89D32BE0,\r
+  0x10DA7A5A,\r
+  0x67DD4ACC,\r
+  0xF9B9DF6F,\r
+  0x8EBEEFF9,\r
+  0x17B7BE43,\r
+  0x60B08ED5,\r
+  0xD6D6A3E8,\r
+  0xA1D1937E,\r
+  0x38D8C2C4,\r
+  0x4FDFF252,\r
+  0xD1BB67F1,\r
+  0xA6BC5767,\r
+  0x3FB506DD,\r
+  0x48B2364B,\r
+  0xD80D2BDA,\r
+  0xAF0A1B4C,\r
+  0x36034AF6,\r
+  0x41047A60,\r
+  0xDF60EFC3,\r
+  0xA867DF55,\r
+  0x316E8EEF,\r
+  0x4669BE79,\r
+  0xCB61B38C,\r
+  0xBC66831A,\r
+  0x256FD2A0,\r
+  0x5268E236,\r
+  0xCC0C7795,\r
+  0xBB0B4703,\r
+  0x220216B9,\r
+  0x5505262F,\r
+  0xC5BA3BBE,\r
+  0xB2BD0B28,\r
+  0x2BB45A92,\r
+  0x5CB36A04,\r
+  0xC2D7FFA7,\r
+  0xB5D0CF31,\r
+  0x2CD99E8B,\r
+  0x5BDEAE1D,\r
+  0x9B64C2B0,\r
+  0xEC63F226,\r
+  0x756AA39C,\r
+  0x026D930A,\r
+  0x9C0906A9,\r
+  0xEB0E363F,\r
+  0x72076785,\r
+  0x05005713,\r
+  0x95BF4A82,\r
+  0xE2B87A14,\r
+  0x7BB12BAE,\r
+  0x0CB61B38,\r
+  0x92D28E9B,\r
+  0xE5D5BE0D,\r
+  0x7CDCEFB7,\r
+  0x0BDBDF21,\r
+  0x86D3D2D4,\r
+  0xF1D4E242,\r
+  0x68DDB3F8,\r
+  0x1FDA836E,\r
+  0x81BE16CD,\r
+  0xF6B9265B,\r
+  0x6FB077E1,\r
+  0x18B74777,\r
+  0x88085AE6,\r
+  0xFF0F6A70,\r
+  0x66063BCA,\r
+  0x11010B5C,\r
+  0x8F659EFF,\r
+  0xF862AE69,\r
+  0x616BFFD3,\r
+  0x166CCF45,\r
+  0xA00AE278,\r
+  0xD70DD2EE,\r
+  0x4E048354,\r
+  0x3903B3C2,\r
+  0xA7672661,\r
+  0xD06016F7,\r
+  0x4969474D,\r
+  0x3E6E77DB,\r
+  0xAED16A4A,\r
+  0xD9D65ADC,\r
+  0x40DF0B66,\r
+  0x37D83BF0,\r
+  0xA9BCAE53,\r
+  0xDEBB9EC5,\r
+  0x47B2CF7F,\r
+  0x30B5FFE9,\r
+  0xBDBDF21C,\r
+  0xCABAC28A,\r
+  0x53B39330,\r
+  0x24B4A3A6,\r
+  0xBAD03605,\r
+  0xCDD70693,\r
+  0x54DE5729,\r
+  0x23D967BF,\r
+  0xB3667A2E,\r
+  0xC4614AB8,\r
+  0x5D681B02,\r
+  0x2A6F2B94,\r
+  0xB40BBE37,\r
+  0xC30C8EA1,\r
+  0x5A05DF1B,\r
+  0x2D02EF8D\r
+};\r
+\r
+EFI_STATUS\r
+CalculateCrc32 (\r
+  IN  UINT8                             *Data,\r
+  IN  UINTN                             DataSize,\r
+  IN OUT UINT32                         *CrcOut\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The CalculateCrc32 routine.\r
+\r
+Arguments:\r
+\r
+  Data        - The buffer contaning the data to be processed\r
+  DataSize    - The size of data to be processed\r
+  CrcOut      - A pointer to the caller allocated UINT32 that on\r
+                contains the CRC32 checksum of Data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Calculation is successful.\r
+  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
+\r
+--*/\r
+{\r
+  UINT32  Crc;\r
+  UINTN   Index;\r
+  UINT8   *Ptr;\r
+\r
+  if ((DataSize == 0) || (Data == NULL) || (CrcOut == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Crc = 0xffffffff;\r
+  for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {\r
+    Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];\r
+  }\r
+\r
+  *CrcOut = Crc ^ 0xffffffff;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h
new file mode 100644 (file)
index 0000000..51e9875
--- /dev/null
@@ -0,0 +1,51 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  crc32.h\r
+\r
+Abstract:\r
+\r
+  Header file for CalcuateCrc32 routine\r
+  \r
+--*/\r
+\r
+#ifndef _CRC32_H\r
+#define _CRC32_H\r
+EFI_STATUS\r
+CalculateCrc32 (\r
+  IN  UINT8                             *Data,\r
+  IN  UINTN                             DataSize,\r
+  IN OUT UINT32                         *CrcOut\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The CalculateCrc32 routine.\r
+\r
+Arguments:\r
+\r
+  Data        - The buffer contaning the data to be processed\r
+  DataSize    - The size of data to be processed\r
+  CrcOut      - A pointer to the caller allocated UINT32 that on\r
+                contains the CRC32 checksum of Data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Calculation is successful.\r
+  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
+\r
+--*/\r
+#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 (file)
index 0000000..8afabae
--- /dev/null
@@ -0,0 +1,995 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.c\r
+\r
+Abstract:\r
+\r
+  Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
+  \r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+\r
+\r
+//\r
+// Decompression algorithm begins here\r
+//\r
+#define BITBUFSIZ 32\r
+#define MAXMATCH  256\r
+#define THRESHOLD 3\r
+#define CODE_BIT  16\r
+#define UINT8_MAX 0xff\r
+#define BAD_TABLE - 1\r
+\r
+//\r
+// C: Char&Len Set; P: Position Set; T: exTra Set\r
+//\r
+#define NC      (0xff + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT    9\r
+#define MAXPBIT 5\r
+#define TBIT    5\r
+#define MAXNP   ((1U << MAXPBIT) - 1)\r
+#define NT      (CODE_BIT + 3)\r
+#if NT > MAXNP\r
+#define NPT NT\r
+#else\r
+#define NPT MAXNP\r
+#endif\r
+\r
+typedef struct {\r
+  UINT8   *mSrcBase;  // Starting address of compressed data\r
+  UINT8   *mDstBase;  // Starting address of decompressed data\r
+  UINT32  mOutBuf;\r
+  UINT32  mInBuf;\r
+\r
+  UINT16  mBitCount;\r
+  UINT32  mBitBuf;\r
+  UINT32  mSubBitBuf;\r
+  UINT16  mBlockSize;\r
+  UINT32  mCompSize;\r
+  UINT32  mOrigSize;\r
+\r
+  UINT16  mBadTableFlag;\r
+\r
+  UINT16  mLeft[2 * NC - 1];\r
+  UINT16  mRight[2 * NC - 1];\r
+  UINT8   mCLen[NC];\r
+  UINT8   mPTLen[NPT];\r
+  UINT16  mCTable[4096];\r
+  UINT16  mPTTable[256];\r
+\r
+  //\r
+  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  // For EFI 1.1 de/compression algorithm, mPBit = 4\r
+  // For Tiano de/compression algorithm, mPBit = 5\r
+  //\r
+  UINT8   mPBit;\r
+} SCRATCH_DATA;\r
+\r
+STATIC\r
+VOID\r
+FillBuf (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfBits  - The number of bits to shift and read.\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
+\r
+  while (NumOfBits > Sd->mBitCount) {\r
+\r
+    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
+\r
+    if (Sd->mCompSize > 0) {\r
+      //\r
+      // Get 1 byte into SubBitBuf\r
+      //\r
+      Sd->mCompSize--;\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
+      Sd->mBitCount   = 8;\r
+\r
+    } else {\r
+      //\r
+      // No more bits from the source, just pad zero bit.\r
+      //\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mBitCount   = 8;\r
+\r
+    }\r
+  }\r
+\r
+  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
+  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+GetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  popped out.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data.\r
+  NumOfBits     - The number of bits to pop and read.\r
+\r
+Returns:\r
+\r
+  The bits that are popped out.\r
+\r
+--*/\r
+{\r
+  UINT32  OutBits;\r
+\r
+  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
+\r
+  FillBuf (Sd, NumOfBits);\r
+\r
+  return OutBits;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+MakeTable (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfChar,\r
+  IN  UINT8         *BitLen,\r
+  IN  UINT16        TableBits,\r
+  OUT UINT16        *Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Creates Huffman Code mapping table according to code length array.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfChar - Number of symbols in the symbol set\r
+  BitLen    - Code length array\r
+  TableBits - The width of the mapping table\r
+  Table     - The table\r
+  \r
+Returns:\r
+  \r
+  0         - OK.\r
+  BAD_TABLE - The table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Count[17];\r
+  UINT16  Weight[17];\r
+  UINT16  Start[18];\r
+  UINT16  *Pointer;\r
+  UINT16  Index3;\r
+  UINT16  Index;\r
+  UINT16  Len;\r
+  UINT16  Char;\r
+  UINT16  JuBits;\r
+  UINT16  Avail;\r
+  UINT16  NextCode;\r
+  UINT16  Mask;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Count[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NumOfChar; Index++) {\r
+    Count[BitLen[Index]]++;\r
+  }\r
+\r
+  Start[1] = 0;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));\r
+  }\r
+\r
+  if (Start[17] != 0) {\r
+    /*(1U << 16)*/\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
+  JuBits = (UINT16) (16 - TableBits);\r
+\r
+  for (Index = 1; Index <= TableBits; Index++) {\r
+    Start[Index] >>= JuBits;\r
+    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
+  }\r
+\r
+  while (Index <= 16) {\r
+    Weight[Index++] = (UINT16) (1U << (16 - Index));\r
+  }\r
+\r
+  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
+\r
+  if (Index != 0) {\r
+    Index3 = (UINT16) (1U << TableBits);\r
+    while (Index != Index3) {\r
+      Table[Index++] = 0;\r
+    }\r
+  }\r
+\r
+  Avail = NumOfChar;\r
+  Mask  = (UINT16) (1U << (15 - TableBits));\r
+\r
+  for (Char = 0; Char < NumOfChar; Char++) {\r
+\r
+    Len = BitLen[Char];\r
+    if (Len == 0) {\r
+      continue;\r
+    }\r
+\r
+    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
+\r
+    if (Len <= TableBits) {\r
+\r
+      for (Index = Start[Len]; Index < NextCode; Index++) {\r
+        Table[Index] = Char;\r
+      }\r
+\r
+    } else {\r
+\r
+      Index3  = Start[Len];\r
+      Pointer = &Table[Index3 >> JuBits];\r
+      Index   = (UINT16) (Len - TableBits);\r
+\r
+      while (Index != 0) {\r
+        if (*Pointer == 0) {\r
+          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
+          *Pointer = Avail++;\r
+        }\r
+\r
+        if (Index3 & Mask) {\r
+          Pointer = &Sd->mRight[*Pointer];\r
+        } else {\r
+          Pointer = &Sd->mLeft[*Pointer];\r
+        }\r
+\r
+        Index3 <<= 1;\r
+        Index--;\r
+      }\r
+\r
+      *Pointer = Char;\r
+\r
+    }\r
+\r
+    Start[Len] = NextCode;\r
+  }\r
+  //\r
+  // Succeeds\r
+  //\r
+  return 0;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+DecodeP (\r
+  IN  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decodes a position value.\r
+\r
+Arguments:\r
+\r
+  Sd      - the global scratch data\r
+\r
+Returns:\r
+\r
+  The position value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Val;\r
+  UINT32  Mask;\r
+  UINT32  Pos;\r
+\r
+  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+\r
+  if (Val >= MAXNP) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+    do {\r
+\r
+      if (Sd->mBitBuf & Mask) {\r
+        Val = Sd->mRight[Val];\r
+      } else {\r
+        Val = Sd->mLeft[Val];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Val >= MAXNP);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mPTLen[Val]);\r
+\r
+  Pos = Val;\r
+  if (Val > 1) {\r
+    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
+  }\r
+\r
+  return Pos;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+ReadPTLen (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        nn,\r
+  IN  UINT16        nbit,\r
+  IN  UINT16        Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for the Extra Set or the Position Set\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  nn        - Number of symbols\r
+  nbit      - Number of bits needed to represent nn\r
+  Special   - The special symbol that needs to be taken care of \r
+\r
+Returns:\r
+\r
+  0         - OK.\r
+  BAD_TABLE - Table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, nbit);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, nbit);\r
+\r
+    for (Index = 0; Index < 256; Index++) {\r
+      Sd->mPTTable[Index] = CharC;\r
+    }\r
+\r
+    for (Index = 0; Index < nn; Index++) {\r
+      Sd->mPTLen[Index] = 0;\r
+    }\r
+\r
+    return 0;\r
+  }\r
+\r
+  Index = 0;\r
+\r
+  while (Index < Number) {\r
+\r
+    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
+\r
+    if (CharC == 7) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
+      while (Mask & Sd->mBitBuf) {\r
+        Mask >>= 1;\r
+        CharC += 1;\r
+      }\r
+    }\r
+\r
+    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
+\r
+    Sd->mPTLen[Index++] = (UINT8) CharC;\r
+\r
+    if (Index == Special) {\r
+      CharC = (UINT16) GetBits (Sd, 2);\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mPTLen[Index++] = 0;\r
+      }\r
+    }\r
+  }\r
+\r
+  while (Index < nn) {\r
+    Sd->mPTLen[Index++] = 0;\r
+  }\r
+\r
+  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
+}\r
+\r
+STATIC\r
+VOID\r
+ReadCLen (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for Char&Len Set.\r
+\r
+Arguments:\r
+\r
+  Sd    - the global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, CBIT);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, CBIT);\r
+\r
+    for (Index = 0; Index < NC; Index++) {\r
+      Sd->mCLen[Index] = 0;\r
+    }\r
+\r
+    for (Index = 0; Index < 4096; Index++) {\r
+      Sd->mCTable[Index] = CharC;\r
+    }\r
+\r
+    return ;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+\r
+    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+    if (CharC >= NT) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+      do {\r
+\r
+        if (Mask & Sd->mBitBuf) {\r
+          CharC = Sd->mRight[CharC];\r
+        } else {\r
+          CharC = Sd->mLeft[CharC];\r
+        }\r
+\r
+        Mask >>= 1;\r
+\r
+      } while (CharC >= NT);\r
+    }\r
+    //\r
+    // Advance what we have read\r
+    //\r
+    FillBuf (Sd, Sd->mPTLen[CharC]);\r
+\r
+    if (CharC <= 2) {\r
+\r
+      if (CharC == 0) {\r
+        CharC = 1;\r
+      } else if (CharC == 1) {\r
+        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
+      } else if (CharC == 2) {\r
+        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
+      }\r
+\r
+      while ((INT16) (--CharC) >= 0) {\r
+        Sd->mCLen[Index++] = 0;\r
+      }\r
+\r
+    } else {\r
+\r
+      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
+\r
+    }\r
+  }\r
+\r
+  while (Index < NC) {\r
+    Sd->mCLen[Index++] = 0;\r
+  }\r
+\r
+  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+DecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode a character/length value.\r
+\r
+Arguments:\r
+\r
+  Sd    - The global scratch data.\r
+\r
+Returns:\r
+\r
+  The value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Index2;\r
+  UINT32  Mask;\r
+\r
+  if (Sd->mBlockSize == 0) {\r
+    //\r
+    // Starting a new block\r
+    //\r
+    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+\r
+    ReadCLen (Sd);\r
+\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  Sd->mBlockSize--;\r
+  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
+\r
+  if (Index2 >= NC) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
+\r
+    do {\r
+      if (Sd->mBitBuf & Mask) {\r
+        Index2 = Sd->mRight[Index2];\r
+      } else {\r
+        Index2 = Sd->mLeft[Index2];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Index2 >= NC);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mCLen[Index2]);\r
+\r
+  return Index2;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Decode (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+ --*/\r
+{\r
+  UINT16  BytesRemain;\r
+  UINT32  DataIdx;\r
+  UINT16  CharC;\r
+\r
+  BytesRemain = (UINT16) (-1);\r
+\r
+  DataIdx     = 0;\r
+\r
+  for (;;) {\r
+    CharC = DecodeC (Sd);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return ;\r
+    }\r
+\r
+    if (CharC < 256) {\r
+      //\r
+      // Process an Original character\r
+      //\r
+      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+        return ;\r
+      } else {\r
+        Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
+      }\r
+\r
+    } else {\r
+      //\r
+      // Process a Pointer\r
+      //\r
+      CharC       = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
+\r
+      BytesRemain = CharC;\r
+\r
+      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
+\r
+      BytesRemain--;\r
+      while ((INT16) (BytesRemain) >= 0) {\r
+        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
+        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+          return ;\r
+        }\r
+\r
+        BytesRemain--;\r
+      }\r
+    }\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+EFI_STATUS\r
+GetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT8 *Src;\r
+\r
+  *ScratchSize  = sizeof (SCRATCH_DATA);\r
+\r
+  Src           = Source;\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Decompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize,\r
+  IN      UINT8   Version\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+  Version     - The version of de/compression algorithm.\r
+                Version 1 for EFI 1.1 de/compression algorithm.\r
+                Version 2 for Tiano de/compression algorithm.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT32        Index;\r
+  UINT32        CompSize;\r
+  UINT32        OrigSize;\r
+  EFI_STATUS    Status;\r
+  SCRATCH_DATA  *Sd;\r
+  UINT8         *Src;\r
+  UINT8         *Dst;\r
+\r
+  Status  = EFI_SUCCESS;\r
+  Src     = Source;\r
+  Dst     = Destination;\r
+\r
+  if (ScratchSize < sizeof (SCRATCH_DATA)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sd = (SCRATCH_DATA *) Scratch;\r
+\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
+  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+\r
+  //\r
+  // If compressed file size is 0, return\r
+  //\r
+  if (OrigSize == 0) {\r
+    return Status;\r
+  }\r
+\r
+  if (SrcSize < CompSize + 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (DstSize != OrigSize) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Src = Src + 8;\r
+\r
+  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
+    ((UINT8 *) Sd)[Index] = 0;\r
+  }\r
+  //\r
+  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
+  // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4\r
+  // For Tiano de/compression algorithm(Version 2), mPBit = 5\r
+  //\r
+  switch (Version) {\r
+  case 1:\r
+    Sd->mPBit = 4;\r
+    break;\r
+\r
+  case 2:\r
+    Sd->mPBit = 5;\r
+    break;\r
+\r
+  default:\r
+    //\r
+    // Currently, only have 2 versions\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sd->mSrcBase  = Src;\r
+  Sd->mDstBase  = Dst;\r
+  Sd->mCompSize = CompSize;\r
+  Sd->mOrigSize = OrigSize;\r
+\r
+  //\r
+  // Fill the first BITBUFSIZ bits\r
+  //\r
+  FillBuf (Sd, BITBUFSIZ);\r
+\r
+  //\r
+  // Decompress it\r
+  //\r
+  Decode (Sd);\r
+\r
+  if (Sd->mBadTableFlag != 0) {\r
+    //\r
+    // Something wrong with the source\r
+    //\r
+    Status = EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetInfo (\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  OUT     UINT32                  *DstSize,\r
+  OUT     UINT32                  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that  of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  return GetInfo (\r
+          Source,\r
+          SrcSize,\r
+          DstSize,\r
+          ScratchSize\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiDecompress (\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  IN OUT  VOID                    *Destination,\r
+  IN      UINT32                  DstSize,\r
+  IN OUT  VOID                    *Scratch,\r
+  IN      UINT32                  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  //\r
+  // For EFI 1.1 de/compression algorithm, the version is 1.\r
+  //\r
+  return Decompress (\r
+          Source,\r
+          SrcSize,\r
+          Destination,\r
+          DstSize,\r
+          Scratch,\r
+          ScratchSize,\r
+          1\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoGetInfo (\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  OUT     UINT32                        *DstSize,\r
+  OUT     UINT32                        *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  return GetInfo (\r
+          Source,\r
+          SrcSize,\r
+          DstSize,\r
+          ScratchSize\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoDecompress (\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  IN OUT  VOID                          *Destination,\r
+  IN      UINT32                        DstSize,\r
+  IN OUT  VOID                          *Scratch,\r
+  IN      UINT32                        ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that  of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  //\r
+  // For Tiano de/compression algorithm, the version is 2.\r
+  //\r
+  return Decompress (\r
+          Source,\r
+          SrcSize,\r
+          Destination,\r
+          DstSize,\r
+          Scratch,\r
+          ScratchSize,\r
+          2\r
+          );\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h
new file mode 100644 (file)
index 0000000..515e7fd
--- /dev/null
@@ -0,0 +1,174 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                              \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Decompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for decompression routine.\r
+  Providing both EFI and Tiano decompress algorithms.\r
+  \r
+--*/\r
+\r
+#ifndef _DECOMPRESS_H_\r
+#define _DECOMPRESS_H_\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiGetInfo (\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  OUT     UINT32                  *DstSize,\r
+  OUT     UINT32                  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that  of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiDecompress (\r
+  IN      VOID                    *Source,\r
+  IN      UINT32                  SrcSize,\r
+  IN OUT  VOID                    *Destination,\r
+  IN      UINT32                  DstSize,\r
+  IN OUT  VOID                    *Scratch,\r
+  IN      UINT32                  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoGetInfo (\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  OUT     UINT32                        *DstSize,\r
+  OUT     UINT32                        *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+TianoDecompress (\r
+  IN      VOID                          *Source,\r
+  IN      UINT32                        SrcSize,\r
+  IN OUT  VOID                          *Destination,\r
+  IN      UINT32                        DstSize,\r
+  IN OUT  VOID                          *Scratch,\r
+  IN      UINT32                        ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation is same as that  of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+;\r
+\r
+typedef\r
+EFI_STATUS\r
+(*GETINFO_FUNCTION) (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(*DECOMPRESS_FUNCTION) (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  );\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c
new file mode 100644 (file)
index 0000000..6f2922e
--- /dev/null
@@ -0,0 +1,1600 @@
+/*\r
+\r
+Copyright (c) 2006, Intel Corporation                                              \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompress.c\r
+\r
+Abstract:\r
+\r
+  Compression routine. The compression algorithm is a mixture of\r
+  LZ77 and Huffman coding. LZ77 transforms the source data into a\r
+  sequence of Original Characters and Pointers to repeated strings.\r
+  This sequence is further divided into Blocks and Huffman codings\r
+  are applied to each Block.\r
+\r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include "TianoCommon.h"\r
+#include "Compress.h"\r
+\r
+\r
+//\r
+// Macro Definitions\r
+//\r
+\r
+typedef INT16             NODE;\r
+#define UINT8_MAX         0xff\r
+#define UINT8_BIT         8\r
+#define THRESHOLD         3\r
+#define INIT_CRC          0\r
+#define WNDBIT            13\r
+#define WNDSIZ            (1U << WNDBIT)\r
+#define MAXMATCH          256\r
+#define PERC_FLAG         0x8000U\r
+#define CODE_BIT          16\r
+#define NIL               0\r
+#define MAX_HASH_VAL      (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)\r
+#define HASH(p, c)        ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)\r
+#define CRCPOLY           0xA001\r
+#define UPDATE_CRC(c)     mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)\r
+\r
+//\r
+// C: the Char&Len Set; P: the Position Set; T: the exTra Set\r
+//\r
+\r
+#define NC                (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT              9\r
+#define NP                (WNDBIT + 1)\r
+#define PBIT              4\r
+#define NT                (CODE_BIT + 3)\r
+#define TBIT              5\r
+#if NT > NP\r
+  #define                 NPT NT\r
+#else\r
+  #define                 NPT NP\r
+#endif\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+\r
+STATIC\r
+VOID \r
+PutDword(\r
+  IN UINT32 Data\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS \r
+AllocateMemory (\r
+  );\r
+\r
+STATIC\r
+VOID\r
+FreeMemory (\r
+  );\r
+\r
+STATIC \r
+VOID \r
+InitSlide (\r
+  );\r
+\r
+STATIC \r
+NODE \r
+Child (\r
+  IN NODE q, \r
+  IN UINT8 c\r
+  );\r
+\r
+STATIC \r
+VOID \r
+MakeChild (\r
+  IN NODE q, \r
+  IN UINT8 c, \r
+  IN NODE r\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+Split (\r
+  IN NODE Old\r
+  );\r
+\r
+STATIC \r
+VOID \r
+InsertNode (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+DeleteNode (\r
+  );\r
+\r
+STATIC \r
+VOID \r
+GetNextMatch (\r
+  );\r
+  \r
+STATIC \r
+EFI_STATUS \r
+Encode (\r
+  );\r
+\r
+STATIC \r
+VOID \r
+CountTFreq (\r
+  );\r
+\r
+STATIC \r
+VOID \r
+WritePTLen (\r
+  IN INT32 n, \r
+  IN INT32 nbit, \r
+  IN INT32 Special\r
+  );\r
+\r
+STATIC \r
+VOID \r
+WriteCLen (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+EncodeC (\r
+  IN INT32 c\r
+  );\r
+\r
+STATIC \r
+VOID \r
+EncodeP (\r
+  IN UINT32 p\r
+  );\r
+\r
+STATIC \r
+VOID \r
+SendBlock (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+Output (\r
+  IN UINT32 c, \r
+  IN UINT32 p\r
+  );\r
+\r
+STATIC \r
+VOID \r
+HufEncodeStart (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+HufEncodeEnd (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+MakeCrcTable (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+PutBits (\r
+  IN INT32 n, \r
+  IN UINT32 x\r
+  );\r
+  \r
+STATIC \r
+INT32 \r
+FreadCrc (\r
+  OUT UINT8 *p, \r
+  IN  INT32 n\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+InitPutBits (\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+CountLen (\r
+  IN INT32 i\r
+  );\r
+\r
+STATIC \r
+VOID \r
+MakeLen (\r
+  IN INT32 Root\r
+  );\r
+  \r
+STATIC \r
+VOID \r
+DownHeap (\r
+  IN INT32 i\r
+  );\r
+\r
+STATIC \r
+VOID \r
+MakeCode (\r
+  IN  INT32 n, \r
+  IN  UINT8 Len[], \r
+  OUT UINT16 Code[]\r
+  );\r
+  \r
+STATIC \r
+INT32 \r
+MakeTree (\r
+  IN  INT32   NParm, \r
+  IN  UINT16  FreqParm[], \r
+  OUT UINT8   LenParm[], \r
+  OUT UINT16  CodeParm[]\r
+  );\r
+\r
+\r
+//\r
+//  Global Variables\r
+//\r
+\r
+STATIC UINT8  *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;\r
+\r
+STATIC UINT8  *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;\r
+STATIC INT16  mHeap[NC + 1];\r
+STATIC INT32  mRemainder, mMatchLen, mBitCount, mHeapSize, mN;\r
+STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;\r
+STATIC UINT32 mCompSize, mOrigSize;\r
+\r
+STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1],\r
+              mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC],\r
+              mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];\r
+\r
+STATIC NODE   mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;\r
+\r
+\r
+//\r
+// functions\r
+//\r
+\r
+EFI_STATUS\r
+EfiCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The main compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS Status = EFI_SUCCESS;\r
+  \r
+  //\r
+  // Initializations\r
+  //\r
+  mBufSiz = 0;\r
+  mBuf = NULL;\r
+  mText       = NULL;\r
+  mLevel      = NULL;\r
+  mChildCount = NULL;\r
+  mPosition   = NULL;\r
+  mParent     = NULL;\r
+  mPrev       = NULL;\r
+  mNext       = NULL;\r
+\r
+  \r
+  mSrc = SrcBuffer;\r
+  mSrcUpperLimit = mSrc + SrcSize;\r
+  mDst = DstBuffer;\r
+  mDstUpperLimit = mDst + *DstSize;\r
+\r
+  PutDword(0L);\r
+  PutDword(0L);\r
+  \r
+  MakeCrcTable ();\r
+\r
+  mOrigSize = mCompSize = 0;\r
+  mCrc = INIT_CRC;\r
+  \r
+  //\r
+  // Compress it\r
+  //\r
+  \r
+  Status = Encode();\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  //\r
+  // Null terminate the compressed data\r
+  //\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = 0;\r
+  }\r
+  \r
+  //\r
+  // Fill in compressed size and original size\r
+  //\r
+  mDst = DstBuffer;\r
+  PutDword(mCompSize+1);\r
+  PutDword(mOrigSize);\r
+\r
+  //\r
+  // Return\r
+  //\r
+  \r
+  if (mCompSize + 1 + 8 > *DstSize) {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+}\r
+\r
+STATIC \r
+VOID \r
+PutDword(\r
+  IN UINT32 Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Put a dword to output stream\r
+  \r
+Arguments:\r
+\r
+  Data    - the dword to put\r
+  \r
+Returns: (VOID)\r
+  \r
+--*/\r
+{\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8)(((UINT8)(Data        )) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8)(((UINT8)(Data >> 0x08)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8)(((UINT8)(Data >> 0x10)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8)(((UINT8)(Data >> 0x18)) & 0xff);\r
+  }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+AllocateMemory ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate memory spaces for data structures used in compression process\r
+  \r
+Argements: (VOID)\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Memory is allocated successfully\r
+  EFI_OUT_OF_RESOURCES  - Allocation fails\r
+\r
+--*/\r
+{\r
+  UINT32      i;\r
+  \r
+  mText       = malloc (WNDSIZ * 2 + MAXMATCH);\r
+  for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {\r
+    mText[i] = 0;\r
+  }\r
+\r
+  mLevel      = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mLevel));\r
+  mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mChildCount));\r
+  mPosition   = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mPosition));\r
+  mParent     = malloc (WNDSIZ * 2 * sizeof(*mParent));\r
+  mPrev       = malloc (WNDSIZ * 2 * sizeof(*mPrev));\r
+  mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof(*mNext));\r
+  \r
+  mBufSiz = 16 * 1024U;\r
+  while ((mBuf = malloc(mBufSiz)) == NULL) {\r
+    mBufSiz = (mBufSiz / 10U) * 9U;\r
+    if (mBufSiz < 4 * 1024U) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  }\r
+  mBuf[0] = 0;\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+FreeMemory ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Called when compression is completed to free memory previously allocated.\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  if (mText) {\r
+    free (mText);\r
+  }\r
+  \r
+  if (mLevel) {\r
+    free (mLevel);\r
+  }\r
+  \r
+  if (mChildCount) {\r
+    free (mChildCount);\r
+  }\r
+  \r
+  if (mPosition) {\r
+    free (mPosition);\r
+  }\r
+  \r
+  if (mParent) {\r
+    free (mParent);\r
+  }\r
+  \r
+  if (mPrev) {\r
+    free (mPrev);\r
+  }\r
+  \r
+  if (mNext) {\r
+    free (mNext);\r
+  }\r
+  \r
+  if (mBuf) {\r
+    free (mBuf);\r
+  }  \r
+\r
+  return;\r
+}\r
+\r
+\r
+STATIC \r
+VOID \r
+InitSlide ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize String Info Log data structures\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE i;\r
+\r
+  for (i = WNDSIZ; i <= WNDSIZ + UINT8_MAX; i++) {\r
+    mLevel[i] = 1;\r
+    mPosition[i] = NIL;  /* sentinel */\r
+  }\r
+  for (i = WNDSIZ; i < WNDSIZ * 2; i++) {\r
+    mParent[i] = NIL;\r
+  }  \r
+  mAvail = 1;\r
+  for (i = 1; i < WNDSIZ - 1; i++) {\r
+    mNext[i] = (NODE)(i + 1);\r
+  }\r
+  \r
+  mNext[WNDSIZ - 1] = NIL;\r
+  for (i = WNDSIZ * 2; i <= MAX_HASH_VAL; i++) {\r
+    mNext[i] = NIL;\r
+  }  \r
+}\r
+\r
+\r
+STATIC \r
+NODE \r
+Child (\r
+  IN NODE q, \r
+  IN UINT8 c\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find child node given the parent node and the edge character\r
+  \r
+Arguments:\r
+\r
+  q       - the parent node\r
+  c       - the edge character\r
+  \r
+Returns:\r
+\r
+  The child node (NIL if not found)  \r
+  \r
+--*/\r
+{\r
+  NODE r;\r
+  \r
+  r = mNext[HASH(q, c)];\r
+  mParent[NIL] = q;  /* sentinel */\r
+  while (mParent[r] != q) {\r
+    r = mNext[r];\r
+  }\r
+  \r
+  return r;\r
+}\r
+\r
+STATIC \r
+VOID \r
+MakeChild (\r
+  IN NODE q, \r
+  IN UINT8 c, \r
+  IN NODE r\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a new child for a given parent node.\r
+  \r
+Arguments:\r
+\r
+  q       - the parent node\r
+  c       - the edge character\r
+  r       - the child node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE h, t;\r
+  \r
+  h = (NODE)HASH(q, c);\r
+  t = mNext[h];\r
+  mNext[h] = r;\r
+  mNext[r] = t;\r
+  mPrev[t] = r;\r
+  mPrev[r] = h;\r
+  mParent[r] = q;\r
+  mChildCount[q]++;\r
+}\r
+\r
+STATIC \r
+VOID \r
+Split (\r
+  NODE Old\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Split a node.\r
+  \r
+Arguments:\r
+\r
+  Old     - the node to split\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE New, t;\r
+\r
+  New = mAvail;\r
+  mAvail = mNext[New];\r
+  mChildCount[New] = 0;\r
+  t = mPrev[Old];\r
+  mPrev[New] = t;\r
+  mNext[t] = New;\r
+  t = mNext[Old];\r
+  mNext[New] = t;\r
+  mPrev[t] = New;\r
+  mParent[New] = mParent[Old];\r
+  mLevel[New] = (UINT8)mMatchLen;\r
+  mPosition[New] = mPos;\r
+  MakeChild(New, mText[mMatchPos + mMatchLen], Old);\r
+  MakeChild(New, mText[mPos + mMatchLen], mPos);\r
+}\r
+\r
+STATIC \r
+VOID \r
+InsertNode ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert string info for current position into the String Info Log\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE q, r, j, t;\r
+  UINT8 c, *t1, *t2;\r
+\r
+  if (mMatchLen >= 4) {\r
+    \r
+    //\r
+    // We have just got a long match, the target tree\r
+    // can be located by MatchPos + 1. Travese the tree\r
+    // from bottom up to get to a proper starting point.\r
+    // The usage of PERC_FLAG ensures proper node deletion\r
+    // in DeleteNode() later.\r
+    //\r
+    \r
+    mMatchLen--;\r
+    r = (INT16)((mMatchPos + 1) | WNDSIZ);\r
+    while ((q = mParent[r]) == NIL) {\r
+      r = mNext[r];\r
+    }\r
+    while (mLevel[q] >= mMatchLen) {\r
+      r = q;  q = mParent[q];\r
+    }\r
+    t = q;\r
+    while (mPosition[t] < 0) {\r
+      mPosition[t] = mPos;\r
+      t = mParent[t];\r
+    }\r
+    if (t < WNDSIZ) {\r
+      mPosition[t] = (NODE)(mPos | PERC_FLAG);\r
+    }    \r
+  } else {\r
+    \r
+    //\r
+    // Locate the target tree\r
+    //\r
+    \r
+    q = (INT16)(mText[mPos] + WNDSIZ);\r
+    c = mText[mPos + 1];\r
+    if ((r = Child(q, c)) == NIL) {\r
+      MakeChild(q, c, mPos);\r
+      mMatchLen = 1;\r
+      return;\r
+    }\r
+    mMatchLen = 2;\r
+  }\r
+  \r
+  //\r
+  // Traverse down the tree to find a match.\r
+  // Update Position value along the route.\r
+  // Node split or creation is involved.\r
+  //\r
+  \r
+  for ( ; ; ) {\r
+    if (r >= WNDSIZ) {\r
+      j = MAXMATCH;\r
+      mMatchPos = r;\r
+    } else {\r
+      j = mLevel[r];\r
+      mMatchPos = (NODE)(mPosition[r] & ~PERC_FLAG);\r
+    }\r
+    if (mMatchPos >= mPos) {\r
+      mMatchPos -= WNDSIZ;\r
+    }    \r
+    t1 = &mText[mPos + mMatchLen];\r
+    t2 = &mText[mMatchPos + mMatchLen];\r
+    while (mMatchLen < j) {\r
+      if (*t1 != *t2) {\r
+        Split(r);\r
+        return;\r
+      }\r
+      mMatchLen++;\r
+      t1++;\r
+      t2++;\r
+    }\r
+    if (mMatchLen >= MAXMATCH) {\r
+      break;\r
+    }\r
+    mPosition[r] = mPos;\r
+    q = r;\r
+    if ((r = Child(q, *t1)) == NIL) {\r
+      MakeChild(q, *t1, mPos);\r
+      return;\r
+    }\r
+    mMatchLen++;\r
+  }\r
+  t = mPrev[r];\r
+  mPrev[mPos] = t;\r
+  mNext[t] = mPos;\r
+  t = mNext[r];\r
+  mNext[mPos] = t;\r
+  mPrev[t] = mPos;\r
+  mParent[mPos] = q;\r
+  mParent[r] = NIL;\r
+  \r
+  //\r
+  // Special usage of 'next'\r
+  //\r
+  mNext[r] = mPos;\r
+  \r
+}\r
+\r
+STATIC \r
+VOID \r
+DeleteNode ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Delete outdated string info. (The Usage of PERC_FLAG\r
+  ensures a clean deletion)\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE q, r, s, t, u;\r
+\r
+  if (mParent[mPos] == NIL) {\r
+    return;\r
+  }\r
+  \r
+  r = mPrev[mPos];\r
+  s = mNext[mPos];\r
+  mNext[r] = s;\r
+  mPrev[s] = r;\r
+  r = mParent[mPos];\r
+  mParent[mPos] = NIL;\r
+  if (r >= WNDSIZ || --mChildCount[r] > 1) {\r
+    return;\r
+  }\r
+  t = (NODE)(mPosition[r] & ~PERC_FLAG);\r
+  if (t >= mPos) {\r
+    t -= WNDSIZ;\r
+  }\r
+  s = t;\r
+  q = mParent[r];\r
+  while ((u = mPosition[q]) & PERC_FLAG) {\r
+    u &= ~PERC_FLAG;\r
+    if (u >= mPos) {\r
+      u -= WNDSIZ;\r
+    }\r
+    if (u > s) {\r
+      s = u;\r
+    }\r
+    mPosition[q] = (INT16)(s | WNDSIZ);\r
+    q = mParent[q];\r
+  }\r
+  if (q < WNDSIZ) {\r
+    if (u >= mPos) {\r
+      u -= WNDSIZ;\r
+    }\r
+    if (u > s) {\r
+      s = u;\r
+    }\r
+    mPosition[q] = (INT16)(s | WNDSIZ | PERC_FLAG);\r
+  }\r
+  s = Child(r, mText[t + mLevel[r]]);\r
+  t = mPrev[s];\r
+  u = mNext[s];\r
+  mNext[t] = u;\r
+  mPrev[u] = t;\r
+  t = mPrev[r];\r
+  mNext[t] = s;\r
+  mPrev[s] = t;\r
+  t = mNext[r];\r
+  mPrev[t] = s;\r
+  mNext[s] = t;\r
+  mParent[s] = mParent[r];\r
+  mParent[r] = NIL;\r
+  mNext[r] = mAvail;\r
+  mAvail = r;\r
+}\r
+\r
+STATIC \r
+VOID \r
+GetNextMatch ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Advance the current position (read in new data if needed).\r
+  Delete outdated string info. Find a match string for current position.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 n;\r
+\r
+  mRemainder--;\r
+  if (++mPos == WNDSIZ * 2) {\r
+    memmove(&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+    n = FreadCrc(&mText[WNDSIZ + MAXMATCH], WNDSIZ);\r
+    mRemainder += n;\r
+    mPos = WNDSIZ;\r
+  }\r
+  DeleteNode();\r
+  InsertNode();\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+Encode ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The main controlling routine for compression process.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns:\r
+  \r
+  EFI_SUCCESS           - The compression is successful\r
+  EFI_OUT_0F_RESOURCES  - Not enough memory for compression process\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  INT32       LastMatchLen;\r
+  NODE        LastMatchPos;\r
+\r
+  Status = AllocateMemory();\r
+  if (EFI_ERROR(Status)) {\r
+    FreeMemory();\r
+    return Status;\r
+  }\r
+\r
+  InitSlide();\r
+  \r
+  HufEncodeStart();\r
+\r
+  mRemainder = FreadCrc(&mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+  \r
+  mMatchLen = 0;\r
+  mPos = WNDSIZ;\r
+  InsertNode();\r
+  if (mMatchLen > mRemainder) {\r
+    mMatchLen = mRemainder;\r
+  }\r
+  while (mRemainder > 0) {\r
+    LastMatchLen = mMatchLen;\r
+    LastMatchPos = mMatchPos;\r
+    GetNextMatch();\r
+    if (mMatchLen > mRemainder) {\r
+      mMatchLen = mRemainder;\r
+    }\r
+    \r
+    if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {\r
+      \r
+      //\r
+      // Not enough benefits are gained by outputting a pointer,\r
+      // so just output the original character\r
+      //\r
+      \r
+      Output(mText[mPos - 1], 0);\r
+    } else {\r
+      \r
+      //\r
+      // Outputting a pointer is beneficial enough, do it.\r
+      //\r
+      \r
+      Output(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),\r
+             (mPos - LastMatchPos - 2) & (WNDSIZ - 1));\r
+      while (--LastMatchLen > 0) {\r
+        GetNextMatch();\r
+      }\r
+      if (mMatchLen > mRemainder) {\r
+        mMatchLen = mRemainder;\r
+      }\r
+    }\r
+  }\r
+  \r
+  HufEncodeEnd();\r
+  FreeMemory();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC \r
+VOID \r
+CountTFreq ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the frequencies for the Extra Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 i, k, n, Count;\r
+\r
+  for (i = 0; i < NT; i++) {\r
+    mTFreq[i] = 0;\r
+  }\r
+  n = NC;\r
+  while (n > 0 && mCLen[n - 1] == 0) {\r
+    n--;\r
+  }\r
+  i = 0;\r
+  while (i < n) {\r
+    k = mCLen[i++];\r
+    if (k == 0) {\r
+      Count = 1;\r
+      while (i < n && mCLen[i] == 0) {\r
+        i++;\r
+        Count++;\r
+      }\r
+      if (Count <= 2) {\r
+        mTFreq[0] = (UINT16)(mTFreq[0] + Count);\r
+      } else if (Count <= 18) {\r
+        mTFreq[1]++;\r
+      } else if (Count == 19) {\r
+        mTFreq[0]++;\r
+        mTFreq[1]++;\r
+      } else {\r
+        mTFreq[2]++;\r
+      }\r
+    } else {\r
+      mTFreq[k + 2]++;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+WritePTLen (\r
+  IN INT32 n, \r
+  IN INT32 nbit, \r
+  IN INT32 Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for the Extra Set or the Position Set.\r
+  \r
+Arguments:\r
+\r
+  n       - the number of symbols\r
+  nbit    - the number of bits needed to represent 'n'\r
+  Special - the special symbol that needs to be take care of\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 i, k;\r
+\r
+  while (n > 0 && mPTLen[n - 1] == 0) {\r
+    n--;\r
+  }\r
+  PutBits(nbit, n);\r
+  i = 0;\r
+  while (i < n) {\r
+    k = mPTLen[i++];\r
+    if (k <= 6) {\r
+      PutBits(3, k);\r
+    } else {\r
+      PutBits(k - 3, (1U << (k - 3)) - 2);\r
+    }\r
+    if (i == Special) {\r
+      while (i < 6 && mPTLen[i] == 0) {\r
+        i++;\r
+      }\r
+      PutBits(2, (i - 3) & 3);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+WriteCLen ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for Char&Length Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 i, k, n, Count;\r
+\r
+  n = NC;\r
+  while (n > 0 && mCLen[n - 1] == 0) {\r
+    n--;\r
+  }\r
+  PutBits(CBIT, n);\r
+  i = 0;\r
+  while (i < n) {\r
+    k = mCLen[i++];\r
+    if (k == 0) {\r
+      Count = 1;\r
+      while (i < n && mCLen[i] == 0) {\r
+        i++;\r
+        Count++;\r
+      }\r
+      if (Count <= 2) {\r
+        for (k = 0; k < Count; k++) {\r
+          PutBits(mPTLen[0], mPTCode[0]);\r
+        }\r
+      } else if (Count <= 18) {\r
+        PutBits(mPTLen[1], mPTCode[1]);\r
+        PutBits(4, Count - 3);\r
+      } else if (Count == 19) {\r
+        PutBits(mPTLen[0], mPTCode[0]);\r
+        PutBits(mPTLen[1], mPTCode[1]);\r
+        PutBits(4, 15);\r
+      } else {\r
+        PutBits(mPTLen[2], mPTCode[2]);\r
+        PutBits(CBIT, Count - 20);\r
+      }\r
+    } else {\r
+      PutBits(mPTLen[k + 2], mPTCode[k + 2]);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+EncodeC (\r
+  IN INT32 c\r
+  )\r
+{\r
+  PutBits(mCLen[c], mCCode[c]);\r
+}\r
+\r
+STATIC \r
+VOID \r
+EncodeP (\r
+  IN UINT32 p\r
+  )\r
+{\r
+  UINT32 c, q;\r
+\r
+  c = 0;\r
+  q = p;\r
+  while (q) {\r
+    q >>= 1;\r
+    c++;\r
+  }\r
+  PutBits(mPTLen[c], mPTCode[c]);\r
+  if (c > 1) {\r
+    PutBits(c - 1, p & (0xFFFFU >> (17 - c)));\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+SendBlock ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Huffman code the block and output it.\r
+  \r
+Argument: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT32 i, k, Flags, Root, Pos, Size;\r
+  Flags = 0;\r
+\r
+  Root = MakeTree(NC, mCFreq, mCLen, mCCode);\r
+  Size = mCFreq[Root];\r
+  PutBits(16, Size);\r
+  if (Root >= NC) {\r
+    CountTFreq();\r
+    Root = MakeTree(NT, mTFreq, mPTLen, mPTCode);\r
+    if (Root >= NT) {\r
+      WritePTLen(NT, TBIT, 3);\r
+    } else {\r
+      PutBits(TBIT, 0);\r
+      PutBits(TBIT, Root);\r
+    }\r
+    WriteCLen();\r
+  } else {\r
+    PutBits(TBIT, 0);\r
+    PutBits(TBIT, 0);\r
+    PutBits(CBIT, 0);\r
+    PutBits(CBIT, Root);\r
+  }\r
+  Root = MakeTree(NP, mPFreq, mPTLen, mPTCode);\r
+  if (Root >= NP) {\r
+    WritePTLen(NP, PBIT, -1);\r
+  } else {\r
+    PutBits(PBIT, 0);\r
+    PutBits(PBIT, Root);\r
+  }\r
+  Pos = 0;\r
+  for (i = 0; i < Size; i++) {\r
+    if (i % UINT8_BIT == 0) {\r
+      Flags = mBuf[Pos++];\r
+    } else {\r
+      Flags <<= 1;\r
+    }\r
+    if (Flags & (1U << (UINT8_BIT - 1))) {\r
+      EncodeC(mBuf[Pos++] + (1U << UINT8_BIT));\r
+      k = mBuf[Pos++] << UINT8_BIT;\r
+      k += mBuf[Pos++];\r
+      EncodeP(k);\r
+    } else {\r
+      EncodeC(mBuf[Pos++]);\r
+    }\r
+  }\r
+  for (i = 0; i < NC; i++) {\r
+    mCFreq[i] = 0;\r
+  }\r
+  for (i = 0; i < NP; i++) {\r
+    mPFreq[i] = 0;\r
+  }\r
+}\r
+\r
+\r
+STATIC \r
+VOID \r
+Output (\r
+  IN UINT32 c, \r
+  IN UINT32 p\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs an Original Character or a Pointer\r
+\r
+Arguments:\r
+\r
+  c     - The original character or the 'String Length' element of a Pointer\r
+  p     - The 'Position' field of a Pointer\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  STATIC UINT32 CPos;\r
+\r
+  if ((mOutputMask >>= 1) == 0) {\r
+    mOutputMask = 1U << (UINT8_BIT - 1);\r
+    if (mOutputPos >= mBufSiz - 3 * UINT8_BIT) {\r
+      SendBlock();\r
+      mOutputPos = 0;\r
+    }\r
+    CPos = mOutputPos++;  \r
+    mBuf[CPos] = 0;\r
+  }\r
+  mBuf[mOutputPos++] = (UINT8) c;\r
+  mCFreq[c]++;\r
+  if (c >= (1U << UINT8_BIT)) {\r
+    mBuf[CPos] |= mOutputMask;\r
+    mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT);\r
+    mBuf[mOutputPos++] = (UINT8) p;\r
+    c = 0;\r
+    while (p) {\r
+      p >>= 1;\r
+      c++;\r
+    }\r
+    mPFreq[c]++;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+HufEncodeStart ()\r
+{\r
+  INT32 i;\r
+\r
+  for (i = 0; i < NC; i++) {\r
+    mCFreq[i] = 0;\r
+  }\r
+  for (i = 0; i < NP; i++) {\r
+    mPFreq[i] = 0;\r
+  }\r
+  mOutputPos = mOutputMask = 0;\r
+  InitPutBits();\r
+  return;\r
+}\r
+\r
+STATIC \r
+VOID \r
+HufEncodeEnd ()\r
+{\r
+  SendBlock();\r
+  \r
+  //\r
+  // Flush remaining bits\r
+  //\r
+  PutBits(UINT8_BIT - 1, 0);\r
+  \r
+  return;\r
+}\r
+\r
+\r
+STATIC \r
+VOID \r
+MakeCrcTable ()\r
+{\r
+  UINT32 i, j, r;\r
+\r
+  for (i = 0; i <= UINT8_MAX; i++) {\r
+    r = i;\r
+    for (j = 0; j < UINT8_BIT; j++) {\r
+      if (r & 1) {\r
+        r = (r >> 1) ^ CRCPOLY;\r
+      } else {\r
+        r >>= 1;\r
+      }\r
+    }\r
+    mCrcTable[i] = (UINT16)r;    \r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+PutBits (\r
+  IN INT32 n, \r
+  IN UINT32 x\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs rightmost n bits of x\r
+\r
+Argments:\r
+\r
+  n   - the rightmost n bits of the data is used\r
+  x   - the data \r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT8 Temp;  \r
+  \r
+  if (n < mBitCount) {\r
+    mSubBitBuf |= x << (mBitCount -= n);\r
+  } else {\r
+      \r
+    Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount)));\r
+    if (mDst < mDstUpperLimit) {\r
+      *mDst++ = Temp;\r
+    }\r
+    mCompSize++;\r
+\r
+    if (n < UINT8_BIT) {\r
+      mSubBitBuf = x << (mBitCount = UINT8_BIT - n);\r
+    } else {\r
+        \r
+      Temp = (UINT8)(x >> (n - UINT8_BIT));\r
+      if (mDst < mDstUpperLimit) {\r
+        *mDst++ = Temp;\r
+      }\r
+      mCompSize++;\r
+      \r
+      mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - n);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC \r
+INT32 \r
+FreadCrc (\r
+  OUT UINT8 *p, \r
+  IN  INT32 n\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read in source data\r
+  \r
+Arguments:\r
+\r
+  p   - the buffer to hold the data\r
+  n   - number of bytes to read\r
+\r
+Returns:\r
+\r
+  number of bytes actually read\r
+  \r
+--*/\r
+{\r
+  INT32 i;\r
+\r
+  for (i = 0; mSrc < mSrcUpperLimit && i < n; i++) {\r
+    *p++ = *mSrc++;\r
+  }\r
+  n = i;\r
+\r
+  p -= n;\r
+  mOrigSize += n;\r
+  while (--i >= 0) {\r
+    UPDATE_CRC(*p++);\r
+  }\r
+  return n;\r
+}\r
+\r
+\r
+STATIC \r
+VOID \r
+InitPutBits ()\r
+{\r
+  mBitCount = UINT8_BIT;  \r
+  mSubBitBuf = 0;\r
+}\r
+\r
+STATIC \r
+VOID \r
+CountLen (\r
+  IN INT32 i\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the number of each code length for a Huffman tree.\r
+  \r
+Arguments:\r
+\r
+  i   - the top node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  STATIC INT32 Depth = 0;\r
+\r
+  if (i < mN) {\r
+    mLenCnt[(Depth < 16) ? Depth : 16]++;\r
+  } else {\r
+    Depth++;\r
+    CountLen(mLeft [i]);\r
+    CountLen(mRight[i]);\r
+    Depth--;\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+MakeLen (\r
+  IN INT32 Root\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create code length array for a Huffman tree\r
+  \r
+Arguments:\r
+\r
+  Root   - the root of the tree\r
+\r
+--*/\r
+{\r
+  INT32 i, k;\r
+  UINT32 Cum;\r
+\r
+  for (i = 0; i <= 16; i++) {\r
+    mLenCnt[i] = 0;\r
+  }\r
+  CountLen(Root);\r
+  \r
+  //\r
+  // Adjust the length count array so that\r
+  // no code will be generated longer than its designated length\r
+  //\r
+  \r
+  Cum = 0;\r
+  for (i = 16; i > 0; i--) {\r
+    Cum += mLenCnt[i] << (16 - i);\r
+  }\r
+  while (Cum != (1U << 16)) {\r
+    mLenCnt[16]--;\r
+    for (i = 15; i > 0; i--) {\r
+      if (mLenCnt[i] != 0) {\r
+        mLenCnt[i]--;\r
+        mLenCnt[i+1] += 2;\r
+        break;\r
+      }\r
+    }\r
+    Cum--;\r
+  }\r
+  for (i = 16; i > 0; i--) {\r
+    k = mLenCnt[i];\r
+    while (--k >= 0) {\r
+      mLen[*mSortPtr++] = (UINT8)i;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC \r
+VOID \r
+DownHeap (\r
+  IN INT32 i\r
+  )\r
+{\r
+  INT32 j, k;\r
+\r
+  //\r
+  // priority queue: send i-th entry down heap\r
+  //\r
+  \r
+  k = mHeap[i];\r
+  while ((j = 2 * i) <= mHeapSize) {\r
+    if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) {\r
+      j++;\r
+    }\r
+    if (mFreq[k] <= mFreq[mHeap[j]]) {\r
+      break;\r
+    }\r
+    mHeap[i] = mHeap[j];\r
+    i = j;\r
+  }\r
+  mHeap[i] = (INT16)k;\r
+}\r
+\r
+STATIC \r
+VOID \r
+MakeCode (\r
+  IN  INT32 n, \r
+  IN  UINT8 Len[], \r
+  OUT UINT16 Code[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Assign code to each symbol based on the code length array\r
+  \r
+Arguments:\r
+\r
+  n     - number of symbols\r
+  Len   - the code length array\r
+  Code  - stores codes for each symbol\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32    i;\r
+  UINT16   Start[18];\r
+\r
+  Start[1] = 0;\r
+  for (i = 1; i <= 16; i++) {\r
+    Start[i + 1] = (UINT16)((Start[i] + mLenCnt[i]) << 1);\r
+  }\r
+  for (i = 0; i < n; i++) {\r
+    Code[i] = Start[Len[i]]++;\r
+  }\r
+}\r
+\r
+STATIC \r
+INT32 \r
+MakeTree (\r
+  IN  INT32   NParm, \r
+  IN  UINT16  FreqParm[], \r
+  OUT UINT8   LenParm[], \r
+  OUT UINT16  CodeParm[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Generates Huffman codes given a frequency distribution of symbols\r
+  \r
+Arguments:\r
+\r
+  NParm    - number of symbols\r
+  FreqParm - frequency of each symbol\r
+  LenParm  - code length for each symbol\r
+  CodeParm - code for each symbol\r
+  \r
+Returns:\r
+\r
+  Root of the Huffman tree.\r
+  \r
+--*/\r
+{\r
+  INT32 i, j, k, Avail;\r
+  \r
+  //\r
+  // make tree, calculate len[], return root\r
+  //\r
+\r
+  mN = NParm;\r
+  mFreq = FreqParm;\r
+  mLen = LenParm;\r
+  Avail = mN;\r
+  mHeapSize = 0;\r
+  mHeap[1] = 0;\r
+  for (i = 0; i < mN; i++) {\r
+    mLen[i] = 0;\r
+    if (mFreq[i]) {\r
+      mHeap[++mHeapSize] = (INT16)i;\r
+    }    \r
+  }\r
+  if (mHeapSize < 2) {\r
+    CodeParm[mHeap[1]] = 0;\r
+    return mHeap[1];\r
+  }\r
+  for (i = mHeapSize / 2; i >= 1; i--) {\r
+    \r
+    //\r
+    // make priority queue \r
+    //\r
+    DownHeap(i);\r
+  }\r
+  mSortPtr = CodeParm;\r
+  do {\r
+    i = mHeap[1];\r
+    if (i < mN) {\r
+      *mSortPtr++ = (UINT16)i;\r
+    }\r
+    mHeap[1] = mHeap[mHeapSize--];\r
+    DownHeap(1);\r
+    j = mHeap[1];\r
+    if (j < mN) {\r
+      *mSortPtr++ = (UINT16)j;\r
+    }\r
+    k = Avail++;\r
+    mFreq[k] = (UINT16)(mFreq[i] + mFreq[j]);\r
+    mHeap[1] = (INT16)k;\r
+    DownHeap(1);\r
+    mLeft[k] = (UINT16)i;\r
+    mRight[k] = (UINT16)j;\r
+  } while (mHeapSize > 1);\r
+  \r
+  mSortPtr = CodeParm;\r
+  MakeLen(k);\r
+  MakeCode(NParm, LenParm, CodeParm);\r
+  \r
+  //\r
+  // return root\r
+  //\r
+  return k;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h
new file mode 100644 (file)
index 0000000..b01f538
--- /dev/null
@@ -0,0 +1,138 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiCustomizedCompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for Customized compression routine\r
+  \r
+--*/\r
+\r
+#ifndef _EFICUSTOMIZEDCOMPRESS_H\r
+#define _EFICUSTOMIZEDCOMPRESS_H\r
+EFI_STATUS\r
+SetCustomizedCompressionType (\r
+  IN  CHAR8   *Type\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized SetCompressionType().\r
+\r
+Arguments:\r
+  Type        - The type if compression.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The type has been set.\r
+  EFI_UNSUPPORTED       - This type is unsupported.\r
+\r
+    \r
+--*/\r
+EFI_STATUS\r
+CustomizedGetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+EFI_STATUS\r
+CustomizedDecompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+EFI_STATUS\r
+CustomizedCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Customized compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                          DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+--*/\r
+\r
+#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 (file)
index 0000000..37705a8
--- /dev/null
@@ -0,0 +1,756 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  EfiUtilityMsgs.c\r
+  \r
+Abstract:\r
+\r
+  EFI tools utility functions to display warning, error, and informational\r
+  messages.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  200\r
+\r
+//\r
+// Declare module globals for keeping track of the the utility's\r
+// name and other settings.\r
+//\r
+static STATUS mStatus                 = STATUS_SUCCESS;\r
+static INT8   mUtilityName[50]        = { 0 };\r
+static UINT32 mDebugMsgMask           = 0;\r
+static INT8   *mSourceFileName        = NULL;\r
+static UINT32 mSourceFileLineNum      = 0;\r
+static UINT32 mErrorCount             = 0;\r
+static UINT32 mWarningCount           = 0;\r
+static UINT32 mMaxErrors              = 0;\r
+static UINT32 mMaxWarnings            = 0;\r
+static UINT32 mMaxWarningsPlusErrors  = 0;\r
+static INT8   mPrintLimitsSet         = 0;\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  );\r
+\r
+static\r
+void\r
+PrintLimitExceeded (\r
+  VOID\r
+  );\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Prints an error message.\r
+  \r
+Arguments:\r
+  All arguments are optional, though the printed message may be useless if\r
+  at least something valid is not specified.\r
+  \r
+  FileName - name of the file or application. If not specified, then the\r
+             utilty name (as set by the utility calling SetUtilityName()\r
+             earlier) is used. Otherwise "Unknown utility" is used.\r
+  \r
+  LineNumber - the line number of error, typically used by parsers. If the\r
+               utility is not a parser, then 0 should be specified. Otherwise\r
+               the FileName and LineNumber info can be used to cause\r
+               MS Visual Studio to jump to the error.\r
+               \r
+  MessageCode - an application-specific error code that can be referenced in\r
+              other documentation. \r
+\r
+  Text        - the text in question, typically used by parsers.\r
+  \r
+  MsgFmt - the format string for the error message. Can contain formatting\r
+           controls for use with the varargs.\r
+           \r
+Returns:\r
+  None.\r
+  \r
+Notes:\r
+  We print the following (similar to the Warn() and Debug() \r
+  W\r
+  Typical error/warning message format:\r
+\r
+  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
+\r
+  BUGBUG -- these three utility functions are almost identical, and\r
+  should be modified to share code.\r
+\r
+  Visual Studio does not find error messages with:\r
+  \r
+     " error :"\r
+     " error 1:"\r
+     " error c1:"\r
+     " error 1000:"\r
+     " error c100:"\r
+\r
+  It does find:\r
+     " error c1000:"     \r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check that we have not exceeded them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our error count\r
+    //\r
+    if (mMaxErrors != 0) {\r
+      if (mErrorCount > mMaxErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserError (\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser error, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  MessageCode   - application-specific error code\r
+  Text          - text to print in the error message\r
+  MsgFmt        - format string to print at the end of the error message\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our error count\r
+    //\r
+    if (mMaxErrors != 0) {\r
+      if (mErrorCount > mMaxErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser warning, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  ErrorCode     - application-specific error code\r
+  OffendingText - text to print in the warning message\r
+  MsgFmt        - format string to print at the end of the warning message\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our warning count\r
+    //\r
+    if (mMaxWarnings != 0) {\r
+      if (mWarningCount > mMaxWarnings) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the warning message. Can contain formatting\r
+                controls for use with varargs.\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our warning count\r
+    //\r
+    if (mMaxWarnings != 0) {\r
+      if (mWarningCount > mMaxWarnings) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgMask,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - typically the name of the utility printing the debug message, but\r
+                can be the name of a file being parsed.\r
+  \r
+  LineNumber  - the line number in FileName (parsers) \r
+               \r
+  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
+                determines if the debug message gets printed.\r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the debug message. Can contain formatting\r
+                controls for use with varargs.\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If the debug mask is not applicable, then do nothing.\r
+  //\r
+  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
+    return ;\r
+  }\r
+\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
+  va_end (List);\r
+}\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Worker routine for all the utility printing services. Prints the message in\r
+  a format that Visual Studio will find when scanning build outputs for\r
+  errors or warnings.\r
+\r
+Arguments:\r
+  Type        - "warning" or "error" string to insert into the message to be\r
+                printed. The first character of this string (converted to uppercase)\r
+                is used to preceed the MessageCode value in the output string.\r
+\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - part of the message to print\r
+  \r
+  MsgFmt      - the format string for the message. Can contain formatting\r
+                controls for use with varargs.\r
+  List        - the variable list.\r
+           \r
+Returns:\r
+  None.\r
+\r
+Notes:\r
+  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
+  \r
+  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
+  file being parsed.\r
+\r
+  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
+  them both NULL.\r
+\r
+  Output will typically be of the form:\r
+    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
+\r
+    Parser (LineNumber != 0)\r
+      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
+    Generic utility (LineNumber == 0) \r
+      UtilityName : error E1234 : Text string : MsgFmt string and args\r
+\r
+--*/\r
+{\r
+  INT8  Line[MAX_LINE_LEN];\r
+  INT8  Line2[MAX_LINE_LEN];\r
+  INT8  *Cptr;\r
+  //\r
+  // If given a filename, then add it (and the line number) to the string.\r
+  // If there's no filename, then use the program name if provided.\r
+  //\r
+  if (FileName != NULL) {\r
+    Cptr = FileName;\r
+  } else if (mUtilityName[0] != 0) {\r
+    Cptr = mUtilityName;\r
+  } else {\r
+    Cptr = "Unknown utility";\r
+  }\r
+\r
+  strcpy (Line, Cptr);\r
+  if (LineNumber != 0) {\r
+    sprintf (Line2, "(%d)", LineNumber);\r
+    strcat (Line, Line2);\r
+  }\r
+  //\r
+  // Have to print an error code or Visual Studio won't find the\r
+  // message for you. It has to be decimal digits too.\r
+  //\r
+  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
+  strcat (Line, Line2);\r
+  fprintf (stdout, "%s", Line);\r
+  //\r
+  // If offending text was provided, then print it\r
+  //\r
+  if (Text != NULL) {\r
+    fprintf (stdout, ": %s ", Text);\r
+  }\r
+  //\r
+  // Print formatted message if provided\r
+  //\r
+  if (MsgFmt != NULL) {\r
+    vsprintf (Line2, MsgFmt, List);\r
+    fprintf (stdout, ": %s", Line2);\r
+  }\r
+\r
+  fprintf (stdout, "\n");\r
+}\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the position in a file being parsed. This can be used to \r
+  print error messages deeper down in a parser.\r
+\r
+Arguments:\r
+  SourceFileName - name of the source file being parsed\r
+  LineNum        - line number of the source file being parsed\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mSourceFileName     = SourceFileName;\r
+  mSourceFileLineNum  = LineNum;\r
+}\r
+\r
+void\r
+SetUtilityName (\r
+  INT8    *UtilityName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  All printed error/warning/debug messages follow the same format, and\r
+  typically will print a filename or utility name followed by the error\r
+  text. However if a filename is not passed to the print routines, then\r
+  they'll print the utility name if you call this function early in your\r
+  app to set the utility name.\r
+  \r
+Arguments:\r
+  UtilityName  -  name of the utility, which will be printed with all\r
+                  error/warning/debug messags.\r
+\r
+Returns:\r
+  NA\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Save the name of the utility in our local variable. Make sure its\r
+  // length does not exceed our buffer.\r
+  //\r
+  if (UtilityName != NULL) {\r
+    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
+      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
+      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
+      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
+      return ;\r
+    } else {\r
+      strcpy (mUtilityName, UtilityName);\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
+  }\r
+}\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  When you call Error() or Warning(), this module keeps track of it and\r
+  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
+  exits, it can call this function to get the status and use it as a return\r
+  value.\r
+  \r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Worst-case status reported, as defined by which print function was called.\r
+  \r
+--*/\r
+{\r
+  return mStatus;\r
+}\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32  DebugMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the debug printing mask. This is used by the DebugMsg() function\r
+  to determine when/if a debug message should be printed.\r
+\r
+Arguments:\r
+  DebugMask  - bitmask, specific to the calling application\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mDebugMsgMask = DebugMask;\r
+}\r
+\r
+void\r
+SetPrintLimits (\r
+  UINT32  MaxErrors,\r
+  UINT32  MaxWarnings,\r
+  UINT32  MaxWarningsPlusErrors\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the limits of how many errors, warnings, and errors+warnings\r
+  we will print.\r
+\r
+Arguments:\r
+  MaxErrors       - maximum number of error messages to print\r
+  MaxWarnings     - maximum number of warning messages to print\r
+  MaxWarningsPlusErrors \r
+                  - maximum number of errors+warnings to print\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mMaxErrors              = MaxErrors;\r
+  mMaxWarnings            = MaxWarnings;\r
+  mMaxWarningsPlusErrors  = MaxWarningsPlusErrors;\r
+  mPrintLimitsSet         = 1;\r
+}\r
+\r
+static\r
+void\r
+PrintLimitExceeded (\r
+  VOID\r
+  )\r
+{\r
+  static INT8 mPrintLimitExceeded = 0;\r
+  //\r
+  // If we've already printed the message, do nothing. Otherwise\r
+  // temporarily increase our print limits so we can pass one\r
+  // more message through.\r
+  //\r
+  if (mPrintLimitExceeded == 0) {\r
+    mPrintLimitExceeded++;\r
+    mMaxErrors++;\r
+    mMaxWarnings++;\r
+    mMaxWarningsPlusErrors++;\r
+    Error (NULL, 0, 0, "error/warning print limit exceeded", NULL);\r
+    mMaxErrors--;\r
+    mMaxWarnings--;\r
+    mMaxWarningsPlusErrors--;\r
+  }\r
+}\r
+\r
+#if 0\r
+void\r
+TestUtilityMessages (\r
+  VOID\r
+  )\r
+{\r
+  char *ArgStr = "ArgString";\r
+  int  ArgInt;\r
+\r
+  ArgInt  = 0x12345678;\r
+  //\r
+  // Test without setting utility name\r
+  //\r
+  fprintf (stdout, "* Testing without setting utility name\n");\r
+  fprintf (stdout, "** Test debug message not printed\n");\r
+  DebugMsg (NULL, 0, 0x00000001, NULL, NULL);\r
+  fprintf (stdout, "** Test warning with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  fprintf (stdout, "** Test error with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  fprintf (stdout, "** Test parser warning with nothing\n");\r
+  ParserWarning (0, NULL, NULL);\r
+  fprintf (stdout, "** Test parser error with nothing\n");\r
+  ParserError (0, NULL, NULL);\r
+  //\r
+  // Test with utility name set now\r
+  //\r
+  fprintf (stdout, "** Testingin with utility name set\n");\r
+  SetUtilityName ("MyUtilityName");\r
+  //\r
+  // Test debug prints\r
+  //\r
+  SetDebugMsgMask (2);\r
+  fprintf (stdout, "** Test debug message with one string\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", NULL);\r
+  fprintf (stdout, "** Test debug message with one string\n");\r
+  DebugMsg (NULL, 0, 0x00000002, NULL, "Text2");\r
+  fprintf (stdout, "** Test debug message with two strings\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2");\r
+  fprintf (stdout, "** Test debug message with two strings and two args\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test warning prints\r
+  //\r
+  fprintf (stdout, "** Test warning with no strings\n");\r
+  Warning (NULL, 0, 1234, NULL, NULL);\r
+  fprintf (stdout, "** Test warning with one string\n");\r
+  Warning (NULL, 0, 1234, "Text1", NULL);\r
+  fprintf (stdout, "** Test warning with one string\n");\r
+  Warning (NULL, 0, 1234, NULL, "Text2");\r
+  fprintf (stdout, "** Test warning with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test error prints\r
+  //\r
+  fprintf (stdout, "** Test error with no strings\n");\r
+  Error (NULL, 0, 1234, NULL, NULL);\r
+  fprintf (stdout, "** Test error with one string\n");\r
+  Error (NULL, 0, 1234, "Text1", NULL);\r
+  fprintf (stdout, "** Test error with one string\n");\r
+  Error (NULL, 0, 1234, NULL, "Text2");\r
+  fprintf (stdout, "** Test error with two strings and two args\n");\r
+  Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test parser prints\r
+  //\r
+  fprintf (stdout, "** Test parser errors\n");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, NULL, NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, NULL, "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+\r
+  fprintf (stdout, "** Test parser warnings\n");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, NULL, NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, NULL, "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+}\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h
new file mode 100644 (file)
index 0000000..2da1fe5
--- /dev/null
@@ -0,0 +1,135 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiUtilityMsgs.h\r
+\r
+Abstract:\r
+\r
+  Defines and prototypes for common EFI utility error and debug messages.\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_UTILITY_MSGS_H_\r
+#define _EFI_UTILITY_MSGS_H_\r
+\r
+//\r
+// Status codes returned by EFI utility programs and functions\r
+//\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+#define VOID void \r
+\r
+typedef int STATUS;\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+//\r
+// When we call Error() or Warning(), the module keeps track of the worst\r
+// case reported. GetUtilityStatus() will get the worst-case results, which\r
+// can be used as the return value from the app.\r
+//\r
+STATUS\r
+GetUtilityStatus (\r
+  void\r
+  );\r
+\r
+//\r
+// If someone prints an error message and didn't specify a source file name,\r
+// then we print the utility name instead. However they must tell us the\r
+// utility name early on via this function.\r
+//\r
+void\r
+SetUtilityName (\r
+  INT8 *ProgramName\r
+  )\r
+;\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgLevel,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32    MsgMask\r
+  )\r
+;\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+;\r
+\r
+void\r
+ParserError (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetPrintLimits (\r
+  UINT32  NumErrors,\r
+  UINT32  NumWarnings,\r
+  UINT32  NumWarningsPlusErrors\r
+  )\r
+;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif // #ifndef _EFI_UTILITY_MSGS_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
new file mode 100644 (file)
index 0000000..4b2bf81
--- /dev/null
@@ -0,0 +1,786 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FvLib.c\r
+\r
+Abstract:\r
+\r
+  These functions assist in parsing and manipulating a Firmware Volume.\r
+\r
+--*/\r
+\r
+//\r
+// Include files\r
+//\r
+#include "FvLib.h"\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+//\r
+// Module global variables\r
+//\r
+EFI_FIRMWARE_VOLUME_HEADER  *mFvHeader  = NULL;\r
+UINT32                      mFvLength   = 0;\r
+\r
+//\r
+// External function implementations\r
+//\r
+EFI_STATUS\r
+InitializeFvLib (\r
+  IN VOID                         *Fv,\r
+  IN UINT32                       FvLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This initializes the FV lib with a pointer to the FV and length.  It does not\r
+  verify the FV in any way.\r
+\r
+Arguments:\r
+\r
+  Fv            Buffer containing the FV.\r
+  FvLength      Length of the FV\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (Fv == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  mFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Fv;\r
+  mFvLength = FvLength;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFvHeader (\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
+  OUT UINT32                      *FvLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a pointer to the current FV and the size.\r
+\r
+Arguments:\r
+\r
+  FvHeader      Pointer to the FV buffer.\r
+  FvLength      Length of the FV\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_ABORTED             The library needs to be initialized.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (FvHeader == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *FvHeader = mFvHeader;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetNextFile (\r
+  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
+  OUT EFI_FFS_FILE_HEADER         **NextFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the next file.  If the current file is NULL, it returns\r
+  the first file in the FV.  If the function returns EFI_SUCCESS and the file \r
+  pointer is NULL, then there are no more files in the FV.\r
+\r
+Arguments:\r
+\r
+  CurrentFile   Pointer to the current file, must be within the current FV.\r
+  NextFile      Pointer to the next file in the FV.\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL or is out of range.\r
+  EFI_ABORTED             The library needs to be initialized.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (NextFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get first file\r
+  //\r
+  if (CurrentFile == NULL) {\r
+    CurrentFile = (EFI_FFS_FILE_HEADER *) ((UINTN) mFvHeader + mFvHeader->HeaderLength);\r
+\r
+    //\r
+    // Verify file is valid\r
+    //\r
+    Status = VerifyFfsFile (CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // no files in this FV\r
+      //\r
+      *NextFile = NULL;\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      //\r
+      // Verify file is in this FV.\r
+      //\r
+      if ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) {\r
+        *NextFile = NULL;\r
+        return EFI_SUCCESS;\r
+      }\r
+\r
+      *NextFile = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // Verify current file is in range\r
+  //\r
+  if (((UINTN) CurrentFile < (UINTN) mFvHeader + mFvHeader->HeaderLength) ||\r
+      ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength)\r
+     ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Get next file, compensate for 8 byte alignment if necessary.\r
+  //\r
+  *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3));\r
+\r
+  //\r
+  // Verify file is in this FV.\r
+  //\r
+  if (((UINTN) *NextFile + sizeof (EFI_FFS_FILE_HEADER) >= (UINTN) mFvHeader + mFvLength) ||\r
+      ((UINTN) *NextFile + GetLength ((*NextFile)->Size) > (UINTN) mFvHeader + mFvLength)\r
+     ) {\r
+    *NextFile = NULL;\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Verify file is valid\r
+  //\r
+  Status = VerifyFfsFile (*NextFile);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // no more files in this FV\r
+    //\r
+    *NextFile = NULL;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileByName (\r
+  IN EFI_GUID                     *FileName,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a file by name.  The function will return NULL if the file is not found.\r
+\r
+Arguments:\r
+\r
+  FileName    The GUID file name of the file to search for.\r
+  File        Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *CurrentFile;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FileName == NULL || File == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the first file\r
+  //\r
+  Status = GetNextFile (NULL, &CurrentFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while (CurrentFile) {\r
+    if (!CompareGuid (&CurrentFile->Name, FileName)) {\r
+      *File = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    Status = GetNextFile (CurrentFile, &CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // File not found in this FV.\r
+  //\r
+  *File = NULL;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileByType (\r
+  IN EFI_FV_FILETYPE              FileType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a file by type and instance.  An instance of 1 is the first instance.\r
+  The function will return NULL if a matching file cannot be found.\r
+  File type EFI_FV_FILETYPE_ALL means any file type is valid.\r
+\r
+Arguments:\r
+\r
+  FileType    Type of file to search for.\r
+  Instance    Instace of the file type to return.\r
+  File        Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *CurrentFile;\r
+  EFI_STATUS          Status;\r
+  UINTN               FileCount;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (File == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Initialize the number of matching files found.\r
+  //\r
+  FileCount = 0;\r
+\r
+  //\r
+  // Get the first file\r
+  //\r
+  Status = GetNextFile (NULL, &CurrentFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "error parsing FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while (CurrentFile) {\r
+    if (FileType == EFI_FV_FILETYPE_ALL || CurrentFile->Type == FileType) {\r
+      FileCount++;\r
+    }\r
+\r
+    if (FileCount == Instance) {\r
+      *File = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    Status = GetNextFile (CurrentFile, &CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+\r
+  *File = NULL;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetSectionByType (\r
+  IN EFI_FFS_FILE_HEADER          *File,\r
+  IN EFI_SECTION_TYPE             SectionType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FILE_SECTION_POINTER    *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a section in a file by type and instance.  An instance of 1 is the first \r
+  instance.  The function will return NULL if a matching section cannot be found.\r
+  The function will not handle encapsulating sections.\r
+\r
+Arguments:\r
+\r
+  File        The file to search.\r
+  SectionType Type of file to search for.\r
+  Instance    Instace of the section to return.\r
+  Section     Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+  EFI_NOT_FOUND           No found.\r
+--*/\r
+{\r
+  EFI_FILE_SECTION_POINTER  CurrentSection;\r
+  EFI_STATUS                Status;\r
+  UINTN                     SectionCount;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (File == NULL || Instance == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FFS header\r
+  //\r
+  Status = VerifyFfsFile (File);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "invalid FFS file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Initialize the number of matching sections found.\r
+  //\r
+  SectionCount = 0;\r
+\r
+  //\r
+  // Get the first section\r
+  //\r
+  CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER));\r
+\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while ((UINTN) CurrentSection.CommonHeader < (UINTN) File + GetLength (File->Size)) {\r
+    if (CurrentSection.CommonHeader->Type == SectionType) {\r
+      SectionCount++;\r
+    }\r
+\r
+    if (SectionCount == Instance) {\r
+      *Section = CurrentSection;\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // Find next section (including compensating for alignment issues.\r
+    //\r
+    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2));\r
+  }\r
+  //\r
+  // Section not found\r
+  //\r
+  (*Section).Code16Section = NULL;\r
+  return EFI_NOT_FOUND;\r
+}\r
+//\r
+// will not parse compressed sections\r
+//\r
+EFI_STATUS\r
+VerifyFv (\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a valid FV header.\r
+\r
+Arguments:\r
+\r
+  FvHeader     Pointer to an alleged FV file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The FV header is valid.\r
+  EFI_VOLUME_CORRUPTED    The FV header is not valid.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_ABORTED             Operation aborted.\r
+\r
+--*/\r
+{\r
+  UINT16  Checksum;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FvHeader == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (FvHeader->Signature != EFI_FVH_SIGNATURE) {\r
+    Error (NULL, 0, 0, "invalid FV header signature", NULL);\r
+    return EFI_VOLUME_CORRUPTED;\r
+  }\r
+  //\r
+  // Verify header checksum\r
+  //\r
+  Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+\r
+  if (Checksum != 0) {\r
+    Error (NULL, 0, 0, "invalid FV header checksum", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+VerifyFfsFile (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a FFS file header.\r
+\r
+Arguments:\r
+\r
+  FfsHeader     Pointer to an alleged FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           The Ffs header is valid.\r
+  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
+  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
+  EFI_ABORTED           The erase polarity is not known.\r
+\r
+--*/\r
+{\r
+  BOOLEAN             ErasePolarity;\r
+  EFI_STATUS          Status;\r
+  EFI_FFS_FILE_HEADER BlankHeader;\r
+  UINT8               Checksum;\r
+  UINT32              FileLength;\r
+  UINT32              OccupiedFileLength;\r
+  UINT8               SavedChecksum;\r
+  UINT8               SavedState;\r
+  UINT8               FileGuidString[80];\r
+  UINT32              TailSize;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
+  EFI_FFS_FILE_TAIL   *Tail;\r
+#endif\r
+  \r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the erase polarity.\r
+  //\r
+  Status = GetErasePolarity (&ErasePolarity);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Check if we have free space\r
+  //\r
+  if (ErasePolarity) {\r
+    memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER));\r
+  } else {\r
+    memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  }\r
+\r
+  if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Convert the GUID to a string so we can at least report which file\r
+  // if we find an error.\r
+  //\r
+  PrintGuidToBuffer (&FfsHeader->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+  } else {\r
+    TailSize = 0;\r
+  }\r
+  //\r
+  // Verify file header checksum\r
+  //\r
+  SavedState = FfsHeader->State;\r
+  FfsHeader->State = 0;\r
+  SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File;\r
+  FfsHeader->IntegrityCheck.Checksum.File = 0;\r
+  Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));\r
+  FfsHeader->State = SavedState;\r
+  FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum;\r
+  if (Checksum != 0) {\r
+    Error (NULL, 0, 0, FileGuidString, "invalid FFS file header checksum");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify file checksum\r
+  //\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    //\r
+    // Verify file data checksum\r
+    //\r
+    FileLength          = GetLength (FfsHeader->Size);\r
+    OccupiedFileLength  = (FileLength + 0x07) & (-1 << 3);\r
+    Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);\r
+    Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
+    if (Checksum != 0) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    //\r
+    // File does not have a checksum\r
+    // Verify contents are 0x5A as spec'd\r
+    //\r
+    if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
+  //\r
+  // Check if the tail is present and verify it if it is.\r
+  //\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    //\r
+    // Verify tail is complement of integrity check field in the header.\r
+    //\r
+    Tail = (EFI_FFS_FILE_TAIL *) ((UINTN) FfsHeader + GetLength (FfsHeader->Size) - sizeof (EFI_FFS_FILE_TAIL));\r
+    if (FfsHeader->IntegrityCheck.TailReference != (EFI_FFS_FILE_TAIL)~(*Tail)) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid FFS file tail");\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+#endif\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT32\r
+GetLength (\r
+  UINT8     *ThreeByteLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a three byte length value into a UINT32.\r
+\r
+Arguments:\r
+\r
+  ThreeByteLength   Pointer to the first of the 3 byte length.\r
+\r
+Returns:\r
+\r
+  UINT32      Size of the section\r
+\r
+--*/\r
+{\r
+  UINT32  Length;\r
+\r
+  if (ThreeByteLength == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  Length  = *((UINT32 *) ThreeByteLength);\r
+  Length  = Length & 0x00FFFFFF;\r
+\r
+  return Length;\r
+}\r
+\r
+EFI_STATUS\r
+GetErasePolarity (\r
+  OUT BOOLEAN   *ErasePolarity\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns with the FV erase polarity.  If the erase polarity\r
+  for a bit is 1, the function return TRUE.\r
+\r
+Arguments:\r
+\r
+  ErasePolarity   A pointer to the erase polarity.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              Operation aborted.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (ErasePolarity == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (mFvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    *ErasePolarity = TRUE;\r
+  } else {\r
+    *ErasePolarity = FALSE;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT8\r
+GetFileState (\r
+  IN BOOLEAN              ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a the highest state bit in the FFS that is set.\r
+  It in no way validate the FFS file.\r
+\r
+Arguments:\r
+  \r
+  ErasePolarity The erase polarity for the file state bits.\r
+  FfsHeader     Pointer to a FFS file.\r
+\r
+Returns:\r
+\r
+  UINT8   The hightest set state of the file.\r
+\r
+--*/\r
+{\r
+  UINT8 FileState;\r
+  UINT8 HighestBit;\r
+\r
+  FileState = FfsHeader->State;\r
+\r
+  if (ErasePolarity) {\r
+    FileState = (UINT8)~FileState;\r
+  }\r
+\r
+  HighestBit = 0x80;\r
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
+    HighestBit >>= 1;\r
+  }\r
+\r
+  return HighestBit;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h
new file mode 100644 (file)
index 0000000..4b7ef0a
--- /dev/null
@@ -0,0 +1,177 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FvLib.h\r
+\r
+Abstract:\r
+\r
+  These functions assist in parsing and manipulating a Firmware Volume.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_FV_LIB_H\r
+#define _EFI_FV_LIB_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include "TianoCommon.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include <string.h>\r
+\r
+EFI_STATUS\r
+InitializeFvLib (\r
+  IN VOID                         *Fv,\r
+  IN UINT32                       FvLength\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFvHeader (\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
+  OUT UINT32                      *FvLength\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetNextFile (\r
+  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
+  OUT EFI_FFS_FILE_HEADER         **NextFile\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileByName (\r
+  IN EFI_GUID                     *FileName,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileByType (\r
+  IN EFI_FV_FILETYPE              FileType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetSectionByType (\r
+  IN EFI_FFS_FILE_HEADER          *File,\r
+  IN EFI_SECTION_TYPE             SectionType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FILE_SECTION_POINTER    *Section\r
+  )\r
+;\r
+//\r
+// will not parse compressed sections\r
+//\r
+EFI_STATUS\r
+VerifyFv (\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+VerifyFfsFile (\r
+  IN EFI_FFS_FILE_HEADER          *FfsHeader\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a FFS file header.\r
+\r
+Arguments:\r
+\r
+  FfsHeader     Pointer to an alleged FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           The Ffs header is valid.\r
+  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
+  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
+\r
+--*/\r
+UINT32\r
+GetLength (\r
+  UINT8                           *ThreeByteLength\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a three byte length value into a UINT32.\r
+\r
+Arguments:\r
+\r
+  ThreeByteLength   Pointer to the first of the 3 byte length.\r
+\r
+Returns:\r
+\r
+  UINT32      Size of the section\r
+\r
+--*/\r
+EFI_STATUS\r
+GetErasePolarity (\r
+  OUT BOOLEAN   *ErasePolarity\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns with the FV erase polarity.  If the erase polarity\r
+  for a bit is 1, the function return TRUE.\r
+\r
+Arguments:\r
+\r
+  ErasePolarity   A pointer to the erase polarity.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+\r
+--*/\r
+UINT8\r
+GetFileState (\r
+  IN BOOLEAN              ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a the highest state bit in the FFS that is set.\r
+  It in no way validate the FFS file.\r
+\r
+Arguments:\r
+  \r
+  ErasePolarity The erase polarity for the file state bits.\r
+  FfsHeader     Pointer to a FFS file.\r
+\r
+Returns:\r
+\r
+  UINT8   The hightest set state of the file.\r
+\r
+--*/\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile
new file mode 100644 (file)
index 0000000..464d0e9
--- /dev/null
@@ -0,0 +1,145 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+TARGET_NAME        = Common\r
+TARGET_SRC_DIR     = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+TARGET_LIB = $(EDK_TOOLS_OUTPUT)\Common.lib\r
+TARGET_SOURCE_DIR = $(COMMON_SOURCE)\r
+\r
+OBJECTS = "$(EDK_TOOLS_OUTPUT)\ParseInf.obj"      \\r
+          "$(EDK_TOOLS_OUTPUT)\EfiCompress.obj"   \\r
+          "$(EDK_TOOLS_OUTPUT)\TianoCompress.obj"   \\r
+          "$(EDK_TOOLS_OUTPUT)\Decompress.obj"   \\r
+          "$(EDK_TOOLS_OUTPUT)\crc32.obj"   \\r
+          "$(EDK_TOOLS_OUTPUT)\CommonLib.obj"     \\r
+          "$(EDK_TOOLS_OUTPUT)\PeCoffLoader.obj"  \\r
+          "$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj" \\r
+          "$(EDK_TOOLS_OUTPUT)\FvLib.obj"  \\r
+          "$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj" \\r
+          "$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj" \\r
+          "$(EDK_TOOLS_OUTPUT)\MyAlloc.obj"\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_LIB)\r
+\r
+#\r
+# Object targets\r
+#\r
\r
+"$(EDK_TOOLS_OUTPUT)\ParseInf.obj": "$(TARGET_SOURCE_DIR)\ParseInf.c" "$(TARGET_SOURCE_DIR)\ParseInf.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\ParseInf.c" /Fo"$(EDK_TOOLS_OUTPUT)\ParseInf.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\MyAlloc.obj": "$(TARGET_SOURCE_DIR)\MyAlloc.c" "$(TARGET_SOURCE_DIR)\MyAlloc.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\MyAlloc.c" /Fo"$(EDK_TOOLS_OUTPUT)\MyAlloc.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\EfiCompress.obj": "$(TARGET_SOURCE_DIR)\EfiCompress.c" "$(TARGET_SOURCE_DIR)\Compress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\EfiCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\EfiCompress.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\TianoCompress.obj": "$(TARGET_SOURCE_DIR)\TianoCompress.c" "$(TARGET_SOURCE_DIR)\Compress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\TianoCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\TianoCompress.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\Decompress.obj": "$(TARGET_SOURCE_DIR)\Decompress.c" "$(TARGET_SOURCE_DIR)\Decompress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\Decompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\Decompress.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\crc32.obj": "$(TARGET_SOURCE_DIR)\crc32.c" "$(TARGET_SOURCE_DIR)\crc32.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\crc32.c" /Fo"$(EDK_TOOLS_OUTPUT)\crc32.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\CommonLib.obj": "$(TARGET_SOURCE_DIR)\CommonLib.c" "$(TARGET_SOURCE_DIR)\CommonLib.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\CommonLib.c" /Fo"$(EDK_TOOLS_OUTPUT)\CommonLib.obj"\r
+\r
+"$(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"\r
+#\r
+# This tool is built differently based on the target processor architecture.\r
+# PE32/PE32+ headers are different for IA32 and IPF, so copy the correct file\r
+# to the tools directory and include it in the build.\r
+# Also copy PeCoffLoaderEx.h because it contains the checks for valid image \r
+# type.\r
+#\r
+  @copy "$(EDK_SOURCE)\Foundation\Include\$(PROCESSOR)\EfiPeOptionalHeader.h" $(EDK_TOOLS_OUTPUT)\r
+  @copy "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.h" $(EDK_TOOLS_OUTPUT)\r
+  $(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"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj": "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.c"\r
+  $(CC) $(C_FLAGS) "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.c" /Fo"$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj"\r
+\r
+"$(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"\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\FvLib.c" /Fo"$(EDK_TOOLS_OUTPUT)\FvLib.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj": "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.c" "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.h"\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.c" /Fo"$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj"\r
+\r
+"$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj" : "$(TARGET_SOURCE_DIR)\SimpleFileParsing.c" "$(TARGET_SOURCE_DIR)\SimpleFileParsing.h"\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\SimpleFileParsing.c" /Fo"$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj"\r
+\r
+#\r
+# Build LIB\r
+#\r
+\r
+#\r
+# Add Binary Build description for this lib.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib))\r
+$(TARGET_LIB): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib $(TARGET_LIB) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb /Y\r
+!ELSE\r
+$(TARGET_LIB): $(OBJECTS)\r
+  $(LIB_EXE) $(LIB_FLAGS) $(OBJECTS) /OUT:$(TARGET_LIB)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_LIB) copy $(TARGET_LIB) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).lib /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\ParseInf.* del /q $(EDK_TOOLS_OUTPUT)\ParseInf.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\ParsePeim.* del /q $(EDK_TOOLS_OUTPUT)\ParsePeim.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\EfiCompress.* del /q $(EDK_TOOLS_OUTPUT)\EfiCompress.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\TianoCompress.* del /q $(EDK_TOOLS_OUTPUT)\TianoCompress.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\Decompress.* del /q $(EDK_TOOLS_OUTPUT)\Decompress.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\crc32.* del /q $(EDK_TOOLS_OUTPUT)\crc32.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\CommonLib.* del /q $(EDK_TOOLS_OUTPUT)\CommonLib.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\PeCoffLoader.* del /q $(EDK_TOOLS_OUTPUT)\PeCoffLoader.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.* del /q $(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\FvLib.* del /q $(EDK_TOOLS_OUTPUT)\FvLib.* > NUL\r
+  @if exist $(TARGET_LIB) del $(TARGET_LIB)\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c
new file mode 100644 (file)
index 0000000..39fddf7
--- /dev/null
@@ -0,0 +1,516 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MyAlloc.c\r
+\r
+Abstract:\r
+\r
+  File for memory allocation tracking functions.\r
+\r
+--*/\r
+\r
+#include "MyAlloc.h"\r
+\r
+#if USE_MYALLOC\r
+//\r
+// Get back to original alloc/free calls.\r
+//\r
+#undef malloc\r
+#undef calloc\r
+#undef realloc\r
+#undef free\r
+//\r
+// Start of allocation list.\r
+//\r
+static MY_ALLOC_STRUCT  *MyAllocData = NULL;\r
+\r
+//\r
+//\r
+//\r
+static UINT32           MyAllocHeadMagik  = MYALLOC_HEAD_MAGIK;\r
+static UINT32           MyAllocTailMagik  = MYALLOC_TAIL_MAGIK;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID\r
+MyCheck (\r
+  BOOLEAN      Final,\r
+  UINT8        File[],\r
+  UINTN        Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Check for corruptions in the allocated memory chain.  If a corruption\r
+//  is detection program operation stops w/ an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
+//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
+//           are no un-freed allocations.  If there are un-freed allocations,\r
+//           they are displayed and exit(1) is called.\r
+//\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+\r
+  //\r
+  // Check parameters.\r
+  //\r
+  if (File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%xh, Line=%u)"\r
+      "Invalid parameter(s).\n",\r
+      Final,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
+      "Invalid parameter.\n",\r
+      Final,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check structure contents.\r
+  //\r
+  for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
+    if (memcmp(Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik) ||\r
+        memcmp(&Tmp->Buffer[Tmp->Size + sizeof(UINT32)], &MyAllocTailMagik, sizeof MyAllocTailMagik)) {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // If Tmp is not NULL, the structure is corrupt.\r
+  //\r
+  if (Tmp != NULL) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%s, Line=%u)""\nStructure corrupted!"\r
+      "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
+      Final,\r
+      File,\r
+      Line,\r
+      Tmp->File,\r
+      Tmp->Line,\r
+      Tmp->Size,\r
+      *(UINT32 *) (Tmp->Buffer),\r
+      *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // If Final is TRUE, display the state of the structure chain.\r
+  //\r
+  if (Final) {\r
+    if (MyAllocData != NULL) {\r
+      printf (\r
+        "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
+        "\nSome allocated items have not been freed.\n",\r
+        Final,\r
+        File,\r
+        Line\r
+        );\r
+\r
+      for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
+        printf (\r
+          "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
+          Tmp->File,\r
+          Tmp->Line,\r
+          Tmp->Size,\r
+          *(UINT32 *) (Tmp->Buffer),\r
+          *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+          );\r
+      }\r
+    }\r
+  }\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID *\r
+MyAlloc (\r
+  UINTN      Size,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Allocate a new link in the allocation chain along with enough storage\r
+//  for the File[] string, requested Size and alignment overhead.  If\r
+//  memory cannot be allocated or the allocation chain has been corrupted,\r
+//  exit(1) will be called.\r
+//\r
+// Parameters:\r
+//\r
+//  Size := Number of bytes (UINT8) requested by the called.\r
+//          Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to the caller's buffer.\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  UINTN           Len;\r
+\r
+  //\r
+  // Check for invalid parameters.\r
+  //\r
+  if (Size == 0 || File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  Len = strlen (File);\r
+  if (Len == 0) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check the allocation list for corruption.\r
+  //\r
+  MyCheck (0, __FILE__, __LINE__);\r
+\r
+  //\r
+  // Allocate a new entry.\r
+  //\r
+  Tmp = calloc (\r
+          1,\r
+          sizeof (MY_ALLOC_STRUCT) + Len + 1 + sizeof (UINT64) + Size + (sizeof MyAllocHeadMagik) + (sizeof MyAllocTailMagik)\r
+          );\r
+\r
+  if (Tmp == NULL) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
+      "\nOut of memory.\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Fill in the new entry.\r
+  //\r
+  Tmp->File = ((UINT8 *) Tmp) + sizeof (MY_ALLOC_STRUCT);\r
+  strcpy (Tmp->File, File);\r
+  Tmp->Line   = Line;\r
+  Tmp->Size   = Size;\r
+  Tmp->Buffer = (UINT8 *) (((UINTN) Tmp + Len + 9) &~7);\r
+\r
+  memcpy (Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik);\r
+\r
+  memcpy (\r
+    &Tmp->Buffer[Size + sizeof (UINT32)],\r
+    &MyAllocTailMagik,\r
+    sizeof MyAllocTailMagik\r
+    );\r
+\r
+  Tmp->Next   = MyAllocData;\r
+  Tmp->Cksum  = (UINTN) Tmp + (UINTN) (Tmp->Next) + Tmp->Line + Tmp->Size + (UINTN) (Tmp->File) + (UINTN) (Tmp->Buffer);\r
+\r
+  MyAllocData = Tmp;\r
+\r
+  return Tmp->Buffer + sizeof (UINT32);\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID *\r
+MyRealloc (\r
+  VOID       *Ptr,\r
+  UINTN      Size,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
+//  for shrinking or expanding buffers.  An invalid parameter will cause\r
+//  MyRealloc() to fail with a call to exit(1).\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
+//\r
+//  Size := Size of new buffer.  Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to new caller's buffer.\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  VOID            *Buffer;\r
+\r
+  //\r
+  // Check for invalid parameter(s).\r
+  //\r
+  if (Size == 0 || File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyRealloc(Ptr=%xh, Size=%u, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Ptr,\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Find existing buffer in allocation list.\r
+  //\r
+  if (Ptr == NULL) {\r
+    Tmp = NULL;\r
+  } else if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
+    Tmp = MyAllocData;\r
+  } else {\r
+    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
+      if (Tmp->Next == NULL) {\r
+        printf (\r
+          "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
+          "\nCould not find buffer.\n",\r
+          Ptr,\r
+          Size,\r
+          File,\r
+          Line\r
+          );\r
+\r
+        exit (1);\r
+      }\r
+\r
+      Tmp = Tmp->Next;\r
+    }\r
+  }\r
+  //\r
+  // Allocate new buffer, copy old data, free old buffer.\r
+  //\r
+  Buffer = MyAlloc (Size, File, Line);\r
+\r
+  if (Buffer != NULL && Tmp != NULL) {\r
+    memcpy (\r
+      Buffer,\r
+      &Tmp->Buffer[sizeof (UINT32)],\r
+      ((Size <= Tmp->Size) ? Size : Tmp->Size)\r
+      );\r
+\r
+    MyFree (Ptr, __FILE__, __LINE__);\r
+  }\r
+\r
+  return Buffer;\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID\r
+MyFree (\r
+  VOID       *Ptr,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Release a previously allocated buffer.  Invalid parameters will cause\r
+//  MyFree() to fail with an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be freed.\r
+//         A NULL pointer will be ignored.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  MY_ALLOC_STRUCT *Tmp2;\r
+\r
+  //\r
+  // Check for invalid parameter(s).\r
+  //\r
+  if (File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Freeing NULL is always valid.\r
+  //\r
+  if (Ptr == NULL) {\r
+    return ;\r
+  }\r
+  //\r
+  // Fail if nothing is allocated.\r
+  //\r
+  if (MyAllocData == NULL) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
+      "\nCalled before memory allocated.\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check for corrupted allocation list.\r
+  //\r
+  MyCheck (0, __FILE__, __LINE__);\r
+\r
+  //\r
+  // Need special check for first item in list.\r
+  //\r
+  if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
+    //\r
+    // Unlink first item in list.\r
+    //\r
+    Tmp         = MyAllocData;\r
+    MyAllocData = MyAllocData->Next;\r
+  } else {\r
+    //\r
+    // Walk list looking for matching item.\r
+    //\r
+    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
+      //\r
+      // Fail if end of list is reached.\r
+      //\r
+      if (Tmp->Next == NULL) {\r
+        printf (\r
+          "\nMyFree(Ptr=%xh, File=%s, Line=%u)\n"\r
+          "\nNot found.\n",\r
+          Ptr,\r
+          File,\r
+          Line\r
+          );\r
+\r
+        exit (1);\r
+      }\r
+      //\r
+      // Leave loop when match is found.\r
+      //\r
+      if (&Tmp->Next->Buffer[sizeof (UINT32)] == Ptr) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Unlink item from list.\r
+    //\r
+    Tmp2      = Tmp->Next;\r
+    Tmp->Next = Tmp->Next->Next;\r
+    Tmp       = Tmp2;\r
+  }\r
+  //\r
+  // Release item.\r
+  //\r
+  free (Tmp);\r
+}\r
+\r
+#endif /* USE_MYALLOC */\r
+\r
+/* eof - MyAlloc.c */\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h
new file mode 100644 (file)
index 0000000..2d195c2
--- /dev/null
@@ -0,0 +1,222 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MyAlloc.h\r
+\r
+Abstract:\r
+\r
+  Header file for memory allocation tracking functions.\r
+\r
+--*/\r
+\r
+#ifndef _MYALLOC_H_\r
+#define _MYALLOC_H_\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include "Tiano.h"\r
+\r
+//\r
+// Default operation is to use the memory allocation tracking functions.\r
+// To over-ride add "#define USE_MYALLOC 0" to your program header and/or\r
+// source files as needed.  Or, just do not include this header file in\r
+// your project.\r
+//\r
+#ifndef USE_MYALLOC\r
+#define USE_MYALLOC 1\r
+#endif\r
+\r
+#if USE_MYALLOC\r
+//\r
+// Replace C library allocation routines with MyAlloc routines.\r
+//\r
+#define malloc(size)        MyAlloc ((size), __FILE__, __LINE__)\r
+#define calloc(count, size) MyAlloc ((count) * (size), __FILE__, __LINE__)\r
+#define realloc(ptr, size)  MyRealloc ((ptr), (size), __FILE__, __LINE__)\r
+#define free(ptr)           MyFree ((ptr), __FILE__, __LINE__)\r
+#define alloc_check(final)  MyCheck ((final), __FILE__, __LINE__)\r
+\r
+//\r
+// Structure for checking/tracking memory allocations.\r
+//\r
+typedef struct MyAllocStruct {\r
+  UINTN                 Cksum;\r
+  struct MyAllocStruct  *Next;\r
+  UINTN                 Line;\r
+  UINTN                 Size;\r
+  UINT8                 *File;\r
+  UINT8                 *Buffer;\r
+} MY_ALLOC_STRUCT;\r
+//\r
+// Cksum := (UINTN)This + (UINTN)Next + Line + Size + (UINTN)File +\r
+//          (UINTN)Buffer;\r
+//\r
+// Next := Pointer to next allocation structure in the list.\r
+//\r
+// Line := __LINE__\r
+//\r
+// Size := Size of allocation request.\r
+//\r
+// File := Pointer to __FILE__ string stored immediately following\r
+//         MY_ALLOC_STRUCT in memory.\r
+//\r
+// Buffer := Pointer to UINT32 aligned storage immediately following\r
+//           the NULL terminated __FILE__ string.  This is UINT32\r
+//           aligned because the underflow signature is 32-bits and\r
+//           this will place the first caller address on a 64-bit\r
+//           boundary.\r
+//\r
+//\r
+// Signatures used to check for buffer overflow/underflow conditions.\r
+//\r
+#define MYALLOC_HEAD_MAGIK  0xBADFACED\r
+#define MYALLOC_TAIL_MAGIK  0xDEADBEEF\r
+\r
+VOID\r
+MyCheck (\r
+  BOOLEAN      Final,\r
+  UINT8        File[],\r
+  UINTN        Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Check for corruptions in the allocated memory chain.  If a corruption\r
+//  is detection program operation stops w/ an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
+//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
+//           are no un-freed allocations.  If there are un-freed allocations,\r
+//           they are displayed and exit(1) is called.\r
+//\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+VOID  *\r
+MyAlloc (\r
+  UINTN      Size,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Allocate a new link in the allocation chain along with enough storage\r
+//  for the File[] string, requested Size and alignment overhead.  If\r
+//  memory cannot be allocated or the allocation chain has been corrupted,\r
+//  exit(1) will be called.\r
+//\r
+// Parameters:\r
+//\r
+//  Size := Number of bytes (UINT8) requested by the called.\r
+//          Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to the caller's buffer.\r
+//\r
+// --*/\r
+//\r
+VOID  *\r
+MyRealloc (\r
+  VOID       *Ptr,\r
+  UINTN      Size,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
+//  for shrinking or expanding buffers.  An invalid parameter will cause\r
+//  MyRealloc() to fail with a call to exit(1).\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
+//         Ptr cannot be NULL.\r
+//\r
+//  Size := Size of new buffer.  Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to new caller's buffer.\r
+//\r
+// --*/\r
+//\r
+VOID\r
+MyFree (\r
+  VOID       *Ptr,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Release a previously allocated buffer.  Invalid parameters will cause\r
+//  MyFree() to fail with an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be freed.\r
+//         A NULL pointer will be ignored.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+#else /* USE_MYALLOC */\r
+\r
+//\r
+// Nothing to do when USE_MYALLOC is zero.\r
+//\r
+#define alloc_check(final)\r
+\r
+#endif /* USE_MYALLOC */\r
+#endif /* _MYALLOC_H_ */\r
+\r
+/* eof - MyAlloc.h */\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
new file mode 100644 (file)
index 0000000..159d81b
--- /dev/null
@@ -0,0 +1,625 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ParseInf.c\r
+\r
+Abstract:\r
+\r
+  This contains some useful functions for parsing INF files.\r
+\r
+--*/\r
+\r
+#include "ParseInf.h"\r
+#include <assert.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+\r
+CHAR8 *\r
+ReadLine (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN OUT CHAR8      *InputBuffer,\r
+  IN UINTN          MaxLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  The function reads a string from the input stream argument and stores it in \r
+  the input string. ReadLine reads characters from the current file position \r
+  to and including the first newline character, to the end of the stream, or \r
+  until the number of characters read is equal to MaxLength - 1, whichever \r
+  comes first.  The newline character, if read, is replaced with a \0. \r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+  MaxLength     The maximum size of the input buffer.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+{\r
+  CHAR8 *CharPtr;\r
+  CHAR8 *EndOfLine;\r
+  UINTN CharsToCopy;\r
+\r
+  //\r
+  // Verify input parameters are not null\r
+  //\r
+  assert (InputBuffer);\r
+  assert (InputFile->FileImage);\r
+  assert (InputFile->Eof);\r
+  assert (InputFile->CurrentFilePointer);\r
+\r
+  //\r
+  // Check for end of file condition\r
+  //\r
+  if (InputFile->CurrentFilePointer >= InputFile->Eof) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Find the next newline char\r
+  //\r
+  EndOfLine = strchr (InputFile->CurrentFilePointer, '\n');\r
+\r
+  //\r
+  // Determine the number of characters to copy.\r
+  //\r
+  if (EndOfLine == 0) {\r
+    //\r
+    // If no newline found, copy to the end of the file.\r
+    //\r
+    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
+  } else if (EndOfLine >= InputFile->Eof) {\r
+    //\r
+    // If the newline found was beyond the end of file, copy to the eof.\r
+    //\r
+    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
+  } else {\r
+    //\r
+    // Newline found in the file.\r
+    //\r
+    CharsToCopy = EndOfLine - InputFile->CurrentFilePointer;\r
+  }\r
+  //\r
+  // If the end of line is too big for the current buffer, set it to the max\r
+  // size of the buffer (leaving room for the \0.\r
+  //\r
+  if (CharsToCopy > MaxLength - 1) {\r
+    CharsToCopy = MaxLength - 1;\r
+  }\r
+  //\r
+  // Copy the line.\r
+  //\r
+  memcpy (InputBuffer, InputFile->CurrentFilePointer, CharsToCopy);\r
+\r
+  //\r
+  // Add the null termination over the 0x0D\r
+  //\r
+  InputBuffer[CharsToCopy - 1] = '\0';\r
+\r
+  //\r
+  // Increment the current file pointer (include the 0x0A)\r
+  //\r
+  InputFile->CurrentFilePointer += CharsToCopy + 1;\r
+\r
+  //\r
+  // Strip any comments\r
+  //\r
+  CharPtr = strstr (InputBuffer, "//");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+  //\r
+  // Return the string\r
+  //\r
+  return InputBuffer;\r
+}\r
+\r
+BOOLEAN\r
+FindSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+{\r
+  CHAR8 InputBuffer[_MAX_PATH];\r
+  CHAR8 *CurrentToken;\r
+\r
+  //\r
+  // Verify input is not NULL\r
+  //\r
+  assert (InputFile->FileImage);\r
+  assert (InputFile->Eof);\r
+  assert (InputFile->CurrentFilePointer);\r
+  assert (Section);\r
+\r
+  //\r
+  // Rewind to beginning of file\r
+  //\r
+  InputFile->CurrentFilePointer = InputFile->FileImage;\r
+\r
+  //\r
+  // Read lines until the section is found\r
+  //\r
+  while (InputFile->CurrentFilePointer < InputFile->Eof) {\r
+    //\r
+    // Read a line\r
+    //\r
+    ReadLine (InputFile, InputBuffer, _MAX_PATH);\r
+\r
+    //\r
+    // Check if the section is found\r
+    //\r
+    CurrentToken = strstr (InputBuffer, Section);\r
+    if (CurrentToken != NULL) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+FindToken (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN CHAR8          *Token,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a token value given the section and token to search for.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
+  Instance  The instance of the token to search for.  Zero is the first instance.\r
+  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+{\r
+  CHAR8   InputBuffer[_MAX_PATH];\r
+  CHAR8   *CurrentToken;\r
+  BOOLEAN ParseError;\r
+  BOOLEAN ReadError;\r
+  UINTN   Occurrance;\r
+\r
+  //\r
+  // Check input parameters\r
+  //\r
+  if (InputFile->FileImage == NULL ||\r
+      InputFile->Eof == NULL ||\r
+      InputFile->CurrentFilePointer == NULL ||\r
+      Section == NULL ||\r
+      strlen (Section) == 0 ||\r
+      Token == NULL ||\r
+      strlen (Token) == 0 ||\r
+      Value == NULL\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize error codes\r
+  //\r
+  ParseError  = FALSE;\r
+  ReadError   = FALSE;\r
+\r
+  //\r
+  // Initialize our instance counter for the search token\r
+  //\r
+  Occurrance = 0;\r
+\r
+  if (FindSection (InputFile, Section)) {\r
+    //\r
+    // Found the desired section, find and read the desired token\r
+    //\r
+    do {\r
+      //\r
+      // Read a line from the file\r
+      //\r
+      if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {\r
+        //\r
+        // Error reading from input file\r
+        //\r
+        ReadError = TRUE;\r
+        break;\r
+      }\r
+      //\r
+      // Get the first non-whitespace string\r
+      //\r
+      CurrentToken = strtok (InputBuffer, " \t\n");\r
+      if (CurrentToken == NULL) {\r
+        //\r
+        // Whitespace line found (or comment) so continue\r
+        //\r
+        CurrentToken = InputBuffer;\r
+        continue;\r
+      }\r
+      //\r
+      // Make sure we have not reached the end of the current section\r
+      //\r
+      if (CurrentToken[0] == '[') {\r
+        break;\r
+      }\r
+      //\r
+      // Compare the current token with the desired token\r
+      //\r
+      if (strcmp (CurrentToken, Token) == 0) {\r
+        //\r
+        // Found it\r
+        //\r
+        //\r
+        // Check if it is the correct instance\r
+        //\r
+        if (Instance == Occurrance) {\r
+          //\r
+          // Copy the contents following the =\r
+          //\r
+          CurrentToken = strtok (NULL, "= \t\n");\r
+          if (CurrentToken == NULL) {\r
+            //\r
+            // Nothing found, parsing error\r
+            //\r
+            ParseError = TRUE;\r
+          } else {\r
+            //\r
+            // Copy the current token to the output value\r
+            //\r
+            strcpy (Value, CurrentToken);\r
+            return EFI_SUCCESS;\r
+          }\r
+        } else {\r
+          //\r
+          // Increment the occurrance found\r
+          //\r
+          Occurrance++;\r
+        }\r
+      }\r
+    } while (\r
+      !ParseError &&\r
+      !ReadError &&\r
+      InputFile->CurrentFilePointer < InputFile->Eof &&\r
+      CurrentToken[0] != '[' &&\r
+      Occurrance <= Instance\r
+    );\r
+  }\r
+  //\r
+  // Distinguish between read errors and INF file format errors.\r
+  //\r
+  if (ReadError) {\r
+    return EFI_LOAD_ERROR;\r
+  }\r
+\r
+  if (ParseError) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+StringToGuid (\r
+  IN CHAR8      *AsciiGuidBuffer,\r
+  OUT EFI_GUID  *GuidBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description: \r
+\r
+  Converts a string to an EFI_GUID.  The string must be in the \r
+  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
+\r
+Arguments:  \r
+\r
+  AsciiGuidBuffer - pointer to ascii string\r
+  GuidBuffer      - pointer to destination Guid\r
+\r
+Returns:  \r
+\r
+  EFI_ABORTED             Could not convert the string\r
+  EFI_SUCCESS             The string was successfully converted\r
+  EFI_INVALID_PARAMETER   Input parameter is invalid.\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  UINTN Data1;\r
+  UINTN Data2;\r
+  UINTN Data3;\r
+  UINTN Data4[8];\r
+\r
+  if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Scan the guid string into the buffer\r
+  //\r
+  Index = sscanf (\r
+            AsciiGuidBuffer,\r
+            "%08x-%04x-%04x-%02x%02x-%02hx%02hx%02hx%02hx%02hx%02hx",\r
+            &Data1,\r
+            &Data2,\r
+            &Data3,\r
+            &Data4[0],\r
+            &Data4[1],\r
+            &Data4[2],\r
+            &Data4[3],\r
+            &Data4[4],\r
+            &Data4[5],\r
+            &Data4[6],\r
+            &Data4[7]\r
+            );\r
+\r
+  //\r
+  // Verify the correct number of items were scanned.\r
+  //\r
+  if (Index != 11) {\r
+    printf ("ERROR: Malformed GUID \"%s\".\n\n", AsciiGuidBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Copy the data into our GUID.\r
+  //\r
+  GuidBuffer->Data1     = (UINT32) Data1;\r
+  GuidBuffer->Data2     = (UINT16) Data2;\r
+  GuidBuffer->Data3     = (UINT16) Data3;\r
+  GuidBuffer->Data4[0]  = (UINT8) Data4[0];\r
+  GuidBuffer->Data4[1]  = (UINT8) Data4[1];\r
+  GuidBuffer->Data4[2]  = (UINT8) Data4[2];\r
+  GuidBuffer->Data4[3]  = (UINT8) Data4[3];\r
+  GuidBuffer->Data4[4]  = (UINT8) Data4[4];\r
+  GuidBuffer->Data4[5]  = (UINT8) Data4[5];\r
+  GuidBuffer->Data4[6]  = (UINT8) Data4[6];\r
+  GuidBuffer->Data4[7]  = (UINT8) Data4[7];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AsciiStringToUint64 (\r
+  IN CONST CHAR8  *AsciiString,\r
+  IN BOOLEAN      IsHex,\r
+  OUT UINT64      *ReturnValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a null terminated ascii string that represents a number into a \r
+  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
+  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
+  unless the IsHex input is true.\r
+\r
+Arguments:\r
+\r
+  AsciiString   The string to convert.\r
+  IsHex         Force the string to be treated as a hex number.\r
+  ReturnValue   The return value.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   Number successfully converted.\r
+  EFI_ABORTED   Invalid character encountered.\r
+\r
+--*/\r
+{\r
+  UINT8   Index;\r
+  UINT64  HexNumber;\r
+  CHAR8   CurrentChar;\r
+\r
+  //\r
+  // Initialize the result\r
+  //\r
+  HexNumber = 0;\r
+\r
+  //\r
+  // Add each character to the result\r
+  //\r
+  if (IsHex || (AsciiString[0] == '0' && (AsciiString[1] == 'x' || AsciiString[1] == 'X'))) {\r
+    //\r
+    // Verify string is a hex number\r
+    //\r
+    for (Index = 2; Index < strlen (AsciiString); Index++) {\r
+      if (isxdigit (AsciiString[Index]) == 0) {\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+    //\r
+    // Convert the hex string.\r
+    //\r
+    for (Index = 2; AsciiString[Index] != '\0'; Index++) {\r
+      CurrentChar = AsciiString[Index];\r
+      HexNumber *= 16;\r
+      if (CurrentChar >= '0' && CurrentChar <= '9') {\r
+        HexNumber += CurrentChar - '0';\r
+      } else if (CurrentChar >= 'a' && CurrentChar <= 'f') {\r
+        HexNumber += CurrentChar - 'a' + 10;\r
+      } else if (CurrentChar >= 'A' && CurrentChar <= 'F') {\r
+        HexNumber += CurrentChar - 'A' + 10;\r
+      } else {\r
+        //\r
+        // Unrecognized character\r
+        //\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    *ReturnValue = HexNumber;\r
+  } else {\r
+    //\r
+    // Verify string is a number\r
+    //\r
+    for (Index = 0; Index < strlen (AsciiString); Index++) {\r
+      if (isdigit (AsciiString[Index]) == 0) {\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    *ReturnValue = atol (AsciiString);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+};\r
+\r
+CHAR8 *\r
+ReadLineInStream (\r
+  IN FILE       *InputFile,\r
+  IN OUT CHAR8  *InputBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  // BUGBUG:  This is obsolete once genmake goes away...\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+{\r
+  CHAR8 *CharPtr;\r
+\r
+  //\r
+  // Verify input parameters are not null\r
+  //\r
+  assert (InputFile);\r
+  assert (InputBuffer);\r
+\r
+  //\r
+  // Read a line\r
+  //\r
+  if (fgets (InputBuffer, _MAX_PATH, InputFile) == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Strip any comments\r
+  //\r
+  CharPtr = strstr (InputBuffer, "//");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+\r
+  CharPtr = strstr (InputBuffer, "#");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+  //\r
+  // Return the string\r
+  //\r
+  return InputBuffer;\r
+}\r
+\r
+BOOLEAN\r
+FindSectionInStream (\r
+  IN FILE       *InputFile,\r
+  IN CHAR8      *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a stream file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+  // BUGBUG:  This is obsolete once genmake goes away...\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+{\r
+  CHAR8 InputBuffer[_MAX_PATH];\r
+  CHAR8 *CurrentToken;\r
+\r
+  //\r
+  // Verify input is not NULL\r
+  //\r
+  assert (InputFile);\r
+  assert (Section);\r
+\r
+  //\r
+  // Rewind to beginning of file\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_SET) != 0) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Read lines until the section is found\r
+  //\r
+  while (feof (InputFile) == 0) {\r
+    //\r
+    // Read a line\r
+    //\r
+    ReadLineInStream (InputFile, InputBuffer);\r
+\r
+    //\r
+    // Check if the section is found\r
+    //\r
+    CurrentToken = strstr (InputBuffer, Section);\r
+    if (CurrentToken != NULL) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
new file mode 100644 (file)
index 0000000..0b4fec7
--- /dev/null
@@ -0,0 +1,233 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ParseInf.h\r
+\r
+Abstract:\r
+\r
+  Header file for helper functions useful for parsing INF files.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PARSE_INF_H\r
+#define _EFI_PARSE_INF_H\r
+\r
+#include "TianoCommon.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+//\r
+// Common data structures\r
+//\r
+typedef struct {\r
+  CHAR8 *FileImage;\r
+  CHAR8 *Eof;\r
+  CHAR8 *CurrentFilePointer;\r
+} MEMORY_FILE;\r
+\r
+//\r
+// Functions declarations\r
+//\r
+CHAR8 *\r
+ReadLine (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN OUT CHAR8      *InputBuffer,\r
+  IN UINT32         MaxLength\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  The function reads a string from the input stream argument and stores it in \r
+  the input string. ReadLine reads characters from the current file position \r
+  to and including the first newline character, to the end of the stream, or \r
+  until the number of characters read is equal to MaxLength - 1, whichever \r
+  comes first.  The newline character, if read, is replaced with a \0. \r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+  MaxLength     The maximum size of the input buffer.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+BOOLEAN\r
+FindSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+EFI_STATUS\r
+FindToken (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN CHAR8          *Token,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Value\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a token value given the section and token to search for.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
+  Instance  The instance of the token to search for.  Zero is the first instance.\r
+  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+EFI_STATUS\r
+StringToGuid (\r
+  IN CHAR8        *AsciiGuidBuffer,\r
+  OUT EFI_GUID    *GuidBuffer\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description: \r
+\r
+  Converts a string to an EFI_GUID.  The string must be in the \r
+  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
+\r
+Arguments:  \r
+\r
+  GuidBuffer      - pointer to destination Guid\r
+  AsciiGuidBuffer - pointer to ascii string\r
+\r
+Returns:  \r
+\r
+  EFI_ABORTED    Could not convert the string\r
+  EFI_SUCCESS    The string was successfully converted\r
+\r
+--*/\r
+EFI_STATUS\r
+AsciiStringToUint64 (\r
+  IN CONST CHAR8  *AsciiString,\r
+  IN BOOLEAN      IsHex,\r
+  OUT UINT64      *ReturnValue\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a null terminated ascii string that represents a number into a \r
+  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
+  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
+  unless the IsHex input is true.\r
+\r
+Arguments:\r
+\r
+  AsciiString   The string to convert.\r
+  IsHex         Force the string to be treated as a hex number.\r
+  ReturnValue   The return value.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   Number successfully converted.\r
+  EFI_ABORTED   Invalid character encountered.\r
+\r
+--*/\r
+CHAR8 *\r
+ReadLineInStream (\r
+  IN FILE       *InputFile,\r
+  IN OUT CHAR8  *InputBuffer\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+BOOLEAN\r
+FindSectionInStream (\r
+  IN FILE       *InputFile,\r
+  IN CHAR8      *Section\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a stream file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c
new file mode 100644 (file)
index 0000000..2a2fbe6
--- /dev/null
@@ -0,0 +1,1456 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileParsing.c  \r
+\r
+Abstract:\r
+\r
+  Generic but simple file parsing routines.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "SimpleFileParsing.h"\r
+\r
+#define MAX_PATH  255\r
+//\r
+// just in case we get in an endless loop.\r
+//\r
+#define MAX_NEST_DEPTH  20\r
+//\r
+// number of wchars\r
+//\r
+#define MAX_STRING_IDENTIFIER_NAME  100\r
+\r
+#define MAX_LINE_LEN                400\r
+\r
+#define T_CHAR_SPACE                ' '\r
+#define T_CHAR_NULL                 0\r
+#define T_CHAR_CR                   '\r'\r
+#define T_CHAR_TAB                  '\t'\r
+#define T_CHAR_LF                   '\n'\r
+#define T_CHAR_SLASH                '/'\r
+#define T_CHAR_BACKSLASH            '\\'\r
+#define T_CHAR_DOUBLE_QUOTE         '"'\r
+#define T_CHAR_LC_X                 'x'\r
+#define T_CHAR_0                    '0'\r
+#define T_CHAR_STAR                 '*'\r
+\r
+//\r
+// We keep a linked list of these for the source files we process\r
+//\r
+typedef struct _SOURCE_FILE {\r
+  FILE                *Fptr;\r
+  T_CHAR              *FileBuffer;\r
+  T_CHAR              *FileBufferPtr;\r
+  unsigned int        FileSize;\r
+  char                FileName[MAX_PATH];\r
+  unsigned int        LineNum;\r
+  BOOLEAN             EndOfFile;\r
+  BOOLEAN             SkipToHash;\r
+  struct _SOURCE_FILE *Previous;\r
+  struct _SOURCE_FILE *Next;\r
+  T_CHAR              ControlCharacter;\r
+} SOURCE_FILE;\r
+\r
+typedef struct {\r
+  T_CHAR  *FileBufferPtr;\r
+} FILE_POSITION;\r
+\r
+//\r
+// Keep all our module globals in this structure\r
+//\r
+static struct {\r
+  SOURCE_FILE SourceFile;\r
+  BOOLEAN     VerboseFile;\r
+  BOOLEAN     VerboseToken;\r
+} mGlobals;\r
+\r
+static\r
+unsigned int\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+unsigned int\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  int    Len\r
+  );\r
+\r
+static\r
+unsigned int\r
+t_strlen (\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+unsigned int\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+T_CHAR  *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+FILE    *\r
+FindFile (\r
+  char          *FileName,\r
+  char          *FoundFileName,\r
+  unsigned int  FoundFileNameLen\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+GetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  );\r
+\r
+static\r
+STATUS\r
+SetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  );\r
+\r
+STATUS\r
+SFPInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS always\r
+\r
+--*/\r
+{\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+unsigned\r
+int\r
+SFPGetLineNumber (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the line number of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  The line number, or 0 if no file is being processed\r
+\r
+--*/\r
+{\r
+  return mGlobals.SourceFile.LineNum;\r
+}\r
+\r
+T_CHAR *\r
+SFPGetFileName (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the name of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  A pointer to the file name. Null if no file is being\r
+  processed.\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileName[0]) {\r
+    return mGlobals.SourceFile.FileName;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATUS\r
+SFPOpenFile (\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Open a file for parsing.\r
+\r
+Arguments:\r
+  FileName  - name of the file to parse\r
+\r
+Returns:\r
+  \r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  t_strcpy (mGlobals.SourceFile.FileName, FileName);\r
+  Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsToken (\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check to see if the specified token is found at\r
+  the current position in the input file.\r
+\r
+Arguments:\r
+  Str - the token to look for\r
+\r
+Returns:\r
+  TRUE - the token is next\r
+  FALSE - the token is not next\r
+\r
+Notes:\r
+  We do a simple string comparison on this function. It is\r
+  the responsibility of the caller to ensure that the token\r
+  is not a subset of some other token.\r
+\r
+  The file pointer is advanced past the token in the input file.\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
+    mGlobals.SourceFile.FileBufferPtr += Len;\r
+    if (mGlobals.VerboseToken) {\r
+      printf ("Token: '%s'\n", Str);\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsKeyword (\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check to see if the specified keyword is found at\r
+  the current position in the input file.\r
+\r
+Arguments:\r
+  Str - keyword to look for\r
+\r
+Returns:\r
+  TRUE - the keyword is next\r
+  FALSE - the keyword is not next\r
+\r
+Notes:\r
+  A keyword is defined as a "special" string that has a non-alphanumeric\r
+  character following it.\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
+    if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) {\r
+      return FALSE;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr += Len;\r
+    if (mGlobals.VerboseToken) {\r
+      printf ("Token: '%s'\n", Str);\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNextToken (\r
+  T_CHAR        *Str,\r
+  unsigned int  Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the next token from the input stream. \r
+\r
+Arguments:\r
+  Str - pointer to a copy of the next token\r
+  Len - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE  - next token successfully returned\r
+  FALSE - otherwise\r
+\r
+Notes:\r
+  Preceeding white space is ignored. \r
+  The parser's buffer pointer is advanced past the end of the\r
+  token.\r
+\r
+--*/\r
+{\r
+  unsigned int  Index;\r
+  T_CHAR        TempChar;\r
+\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Have to have enough string for at least one char and a null-terminator\r
+  //\r
+  if (Len < 2) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Look at the first character. If it's an identifier, then treat it\r
+  // as such\r
+  //\r
+  TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
+  if (((TempChar >= 'a') && (TempChar <= 'z')) || ((TempChar >= 'A') && (TempChar <= 'Z')) || (TempChar == '_')) {\r
+    Str[0] = TempChar;\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Index = 1;\r
+    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+      TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
+      if (((TempChar >= 'a') && (TempChar <= 'z')) ||\r
+          ((TempChar >= 'A') && (TempChar <= 'Z')) ||\r
+          ((TempChar >= '0') && (TempChar <= '9')) ||\r
+          (TempChar == '_')\r
+          ) {\r
+        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        Index++;\r
+      } else {\r
+        //\r
+        // Invalid character for symbol name, so break out\r
+        //\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Null terminate and return success\r
+    //\r
+    Str[Index] = 0;\r
+    return TRUE;\r
+  } else if ((TempChar == ')') || (TempChar == '(') || (TempChar == '*')) {\r
+    Str[0] = mGlobals.SourceFile.FileBufferPtr[0];\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Str[1] = 0;\r
+    return TRUE;\r
+  } else {\r
+    //\r
+    // Everything else is white-space (or EOF) separated\r
+    //\r
+    Index = 0;\r
+    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+      if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
+        if (Index > 0) {\r
+          Str[Index] = 0;\r
+          return TRUE;\r
+        }\r
+\r
+        return FALSE;\r
+      } else {\r
+        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        Index++;\r
+      }\r
+    }\r
+    //\r
+    // See if we just ran out of file contents, but did find a token\r
+    //\r
+    if ((Index > 0) && EndOfFile (&mGlobals.SourceFile)) {\r
+      Str[Index] = 0;\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetGuidToken (\r
+  T_CHAR *Str,\r
+  UINT32 Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a GUID from the input stream. Stop when you discover white space.\r
+\r
+Arguments:\r
+  Str - pointer to a copy of the next token\r
+  Len - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE  - GUID string returned successfully\r
+  FALSE - otherwise\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Index = 0;\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+    if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
+      if (Index > 0) {\r
+        Str[Index] = 0;\r
+        return TRUE;\r
+      }\r
+\r
+      return FALSE;\r
+    } else {\r
+      Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPSkipToToken (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  unsigned int  Len;\r
+  T_CHAR        *SavePos;\r
+  Len     = t_strlen (Str);\r
+  SavePos = mGlobals.SourceFile.FileBufferPtr;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  while (!EndOfFile (&mGlobals.SourceFile)) {\r
+    if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {\r
+      mGlobals.SourceFile.FileBufferPtr += Len;\r
+      return TRUE;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    SkipWhiteSpace (&mGlobals.SourceFile);\r
+  }\r
+\r
+  mGlobals.SourceFile.FileBufferPtr = SavePos;\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNumber (\r
+  unsigned int *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check the token at the current file position for a numeric value.\r
+  May be either decimal or hex.\r
+\r
+Arguments:\r
+  Value  - pointer where to store the value\r
+\r
+Returns:\r
+  FALSE    - current token is not a number\r
+  TRUE     - current token is a number\r
+\r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+    //\r
+    // Check for hex value\r
+    //\r
+    if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
+      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
+        return FALSE;\r
+      }\r
+\r
+      mGlobals.SourceFile.FileBufferPtr += 2;\r
+      sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value);\r
+      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    } else {\r
+      *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
+      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+STATUS\r
+SFPCloseFile (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Close the file being parsed.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - the file was closed \r
+  STATUS_ERROR   - no file is currently open\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileBuffer != NULL) {\r
+    free (mGlobals.SourceFile.FileBuffer);\r
+    memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));\r
+    return STATUS_SUCCESS;\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file, open the file and parse it\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - name of file to parse\r
+  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  static unsigned int NestDepth = 0;\r
+  char                FoundFileName[MAX_PATH];\r
+  STATUS              Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  NestDepth++;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.VerboseFile) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
+    fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile);\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Try to open the file locally, and if that fails try along our include paths.\r
+  //\r
+  strcpy (FoundFileName, SourceFile->FileName);\r
+  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process the file found\r
+  //\r
+  ProcessFile (SourceFile);\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (SourceFile->Fptr != NULL) {\r
+    fclose (SourceFile->Fptr);\r
+    SourceFile->Fptr = NULL;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file that's been opened, read the contents into an internal\r
+  buffer and pre-process it to remove comments.\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - structure containing info on the file to process\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Get the file size, and then read the entire thing into memory.\r
+  // Allocate extra space for a terminator character.\r
+  //\r
+  fseek (SourceFile->Fptr, 0, SEEK_END);\r
+  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
+  if (mGlobals.VerboseFile) {\r
+    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
+  }\r
+\r
+  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
+  SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR));\r
+  if (SourceFile->FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fread ((void *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
+  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL;\r
+  //\r
+  // Pre-process the file to replace comments with spaces\r
+  //\r
+  PreprocessFile (SourceFile);\r
+  SourceFile->LineNum = 1;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Preprocess a file to replace all carriage returns with NULLs so\r
+  we can print lines (as part of error messages) from the file to the screen.\r
+  \r
+Arguments:\r
+  SourceFile - structure that we use to keep track of an input file.\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  BOOLEAN InComment;\r
+  BOOLEAN SlashSlashComment;\r
+  int     LineNum;\r
+\r
+  RewindFile (SourceFile);\r
+  InComment         = FALSE;\r
+  SlashSlashComment = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // If a line-feed, then no longer in a comment if we're in a // comment\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (InComment && SlashSlashComment) {\r
+        InComment         = FALSE;\r
+        SlashSlashComment = FALSE;\r
+      }\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      //\r
+      // Replace all carriage returns with a NULL so we can print stuff\r
+      //\r
+      SourceFile->FileBufferPtr[0] = 0;\r
+      SourceFile->FileBufferPtr++;\r
+      //\r
+      // Check for */ comment end\r
+      //\r
+    } else if (InComment &&\r
+             !SlashSlashComment &&\r
+             (SourceFile->FileBufferPtr[0] == T_CHAR_STAR) &&\r
+             (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)\r
+            ) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      InComment = FALSE;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      //\r
+      // Check for // comments\r
+      //\r
+    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {\r
+      InComment         = TRUE;\r
+      SlashSlashComment = TRUE;\r
+      //\r
+      // Check for /* comment start\r
+      //\r
+    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_STAR)) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SlashSlashComment = FALSE;\r
+      InComment         = TRUE;\r
+    } else {\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // Could check for end-of-file and still in a comment, but\r
+  // should not be necessary. So just restore the file pointers.\r
+  //\r
+  RewindFile (SourceFile);\r
+  //\r
+  // Dump the reformatted file if verbose mode\r
+  //\r
+  if (mGlobals.VerboseFile) {\r
+    LineNum = 1;\r
+    printf ("%04d: ", LineNum);\r
+    while (!EndOfFile (SourceFile)) {\r
+      if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+        printf ("'\n%04d: '", ++LineNum);\r
+      } else {\r
+        printf ("%c", SourceFile->FileBufferPtr[0]);\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+\r
+    printf ("'\n");\r
+    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
+    RewindFile (SourceFile);\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+SFPGetQuotedString (\r
+  T_CHAR      *Str,\r
+  int         Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve a quoted-string from the input file. \r
+  \r
+Arguments:\r
+  Str    - pointer to a copy of the quoted string parsed\r
+  Length - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE    - next token in input stream was a quoted string, and\r
+            the string value was returned in Str\r
+  FALSE   - otherwise\r
+  \r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    while (Length > 0) {\r
+      if (EndOfFile (&mGlobals.SourceFile)) {\r
+        return FALSE;\r
+      }\r
+      //\r
+      // Check for closing quote\r
+      //\r
+      if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        *Str = 0;\r
+        return TRUE;\r
+      }\r
+\r
+      *Str = mGlobals.SourceFile.FileBufferPtr[0];\r
+      Str++;\r
+      Length--;\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // First character was not a quote, or the input string length was\r
+  // insufficient to contain the quoted string, so return failure code.\r
+  //\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsEOF (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE of FALSE to indicate whether or not we've reached the end of the\r
+  file we're parsing.\r
+  \r
+Arguments:\r
+  NA\r
+\r
+Returns:\r
+  TRUE    - EOF reached\r
+  FALSE   - otherwise\r
+  \r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  return EndOfFile (&mGlobals.SourceFile);\r
+}\r
+\r
+#if 0\r
+static\r
+T_CHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  )\r
+{\r
+  T_CHAR        *String;\r
+  T_CHAR        *Start;\r
+  T_CHAR        *Ptr;\r
+  unsigned int  Len;\r
+  BOOLEAN       PreviousBackslash;\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    if (Optional == FALSE) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start             = Ptr = SourceFile->FileBufferPtr;\r
+  PreviousBackslash = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (PreviousBackslash == FALSE)) {\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      PreviousBackslash = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {\r
+      PreviousBackslash = TRUE;\r
+    } else {\r
+      PreviousBackslash = FALSE;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return String;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
+  // source file structure, so check it first.\r
+  //\r
+  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) {\r
+    SourceFile->EndOfFile = TRUE;\r
+    return TRUE;\r
+  }\r
+\r
+  if (SourceFile->EndOfFile) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+#if 0\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  char          IncludeFileName[MAX_PATH];\r
+  char          *To;\r
+  unsigned int  Len;\r
+  BOOLEAN       ReportedError;\r
+  SOURCE_FILE   IncludedSourceFile;\r
+\r
+  ReportedError = FALSE;\r
+  if (SkipWhiteSpace (SourceFile) == 0) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
+  }\r
+  //\r
+  // Should be quoted file name\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  //\r
+  // Copy the filename as ascii to our local string\r
+  //\r
+  To  = IncludeFileName;\r
+  Len = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
+      goto FailDone;\r
+    }\r
+\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+    }\r
+    //\r
+    // If too long, then report the error once and process until the closing quote\r
+    //\r
+    Len++;\r
+    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
+      ReportedError = TRUE;\r
+    }\r
+\r
+    if (!ReportedError) {\r
+      *To = (T_CHAR) SourceFile->FileBufferPtr[0];\r
+      To++;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+\r
+  if (!ReportedError) {\r
+    *To = 0;\r
+    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
+    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
+    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
+  }\r
+\r
+  return ;\r
+FailDone:\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  switch (*SourceFile->FileBufferPtr) {\r
+  case T_CHAR_NULL:\r
+  case T_CHAR_CR:\r
+  case T_CHAR_SPACE:\r
+  case T_CHAR_TAB:\r
+  case T_CHAR_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+unsigned int\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  unsigned int  Count;\r
+\r
+  Count = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    Count++;\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case T_CHAR_NULL:\r
+    case T_CHAR_CR:\r
+    case T_CHAR_SPACE:\r
+    case T_CHAR_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case T_CHAR_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      break;\r
+\r
+    default:\r
+      return Count - 1;\r
+    }\r
+  }\r
+  //\r
+  // Some tokens require trailing whitespace. If we're at the end of the\r
+  // file, then we count that as well.\r
+  //\r
+  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
+    Count++;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare two strings for equality. The string pointed to by 'Buffer' may or may not be null-terminated,\r
+  so only compare up to the length of Str.\r
+\r
+Arguments:\r
+  Buffer  - pointer to first (possibly not null-terminated) string\r
+  Str     - pointer to null-terminated string to compare to Buffer\r
+\r
+Returns:\r
+  Number of bytes matched if exact match\r
+  0 if Buffer does not start with Str\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+\r
+  Len = 0;\r
+  while (*Str && (*Str == *Buffer)) {\r
+    Buffer++;\r
+    Str++;\r
+    Len++;\r
+  }\r
+\r
+  if (*Str) {\r
+    return 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strlen (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  unsigned int  Len;\r
+  Len = 0;\r
+  while (*Str) {\r
+    Len++;\r
+    Str++;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  int    Len\r
+  )\r
+{\r
+  while (Len > 0) {\r
+    if (*Str1 != *Str2) {\r
+      return Len;\r
+    }\r
+\r
+    Len--;\r
+    Str1++;\r
+    Str2++;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+T_CHAR *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  )\r
+{\r
+  T_CHAR  *SaveDest;\r
+  SaveDest = Dest;\r
+  while (*Src) {\r
+    *Dest = *Src;\r
+    Dest++;\r
+    Src++;\r
+  }\r
+\r
+  *Dest = 0;\r
+  return SaveDest;\r
+}\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  SourceFile->LineNum       = 1;\r
+  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
+  SourceFile->EndOfFile     = 0;\r
+}\r
+\r
+static\r
+UINT32\r
+GetHexChars (\r
+  T_CHAR      *Buffer,\r
+  UINT32      BufferLen\r
+  )\r
+{\r
+  UINT32  Len;\r
+  Len = 0;\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
+    if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+      *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
+      Buffer++;\r
+      Len++;\r
+      BufferLen--;\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Null terminate if we can\r
+  //\r
+  if ((Len > 0) && (BufferLen > 0)) {\r
+    *Buffer = 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetGuid (\r
+  int         GuidStyle,\r
+  EFI_GUID    *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a GUID from the input stream. Stop when you discover white space.\r
+\r
+Arguments:\r
+  GuidStyle - Style of the following GUID token\r
+  Value     - pointer to EFI_GUID struct for output\r
+\r
+Returns:\r
+  TRUE  - GUID string parsed successfully\r
+  FALSE - otherwise\r
+\r
+  GUID styles\r
+    Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
+\r
+--*/\r
+{\r
+  UINT32        Value32;\r
+  UINT32        Index;\r
+  FILE_POSITION FPos;\r
+  T_CHAR        TempString[20];\r
+  T_CHAR        TempString2[3];\r
+  T_CHAR        *From;\r
+  T_CHAR        *To;\r
+  UINT32        Len;\r
+  BOOLEAN       Status;\r
+\r
+  Status = FALSE;\r
+  //\r
+  // Skip white space, then start parsing\r
+  //\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  GetFilePosition (&FPos);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (GuidStyle == PARSE_GUID_STYLE_5_FIELDS) {\r
+    //\r
+    // Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
+    //\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 8)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data1 = Value32;\r
+    //\r
+    // Next two UINT16 fields\r
+    //\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data2 = (UINT16) Value32;\r
+\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data3 = (UINT16) Value32;\r
+    //\r
+    // Parse the "AAAA" as two bytes\r
+    //\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data4[0] = (UINT8) (Value32 >> 8);\r
+    Value->Data4[1] = (UINT8) Value32;\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    //\r
+    // Read the last 6 bytes of the GUID\r
+    //\r
+    //\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 12)) {\r
+      goto Done;\r
+    }\r
+    //\r
+    // Insert leading 0's to make life easier\r
+    //\r
+    if (Len != 12) {\r
+      From            = TempString + Len - 1;\r
+      To              = TempString + 11;\r
+      TempString[12]  = 0;\r
+      while (From >= TempString) {\r
+        *To = *From;\r
+        To--;\r
+        From--;\r
+      }\r
+\r
+      while (To >= TempString) {\r
+        *To = '0';\r
+        To--;\r
+      }\r
+    }\r
+    //\r
+    // Now parse each byte\r
+    //\r
+    TempString2[2] = 0;\r
+    for (Index = 0; Index < 6; Index++) {\r
+      //\r
+      // Copy the two characters from the input string to something\r
+      // we can parse.\r
+      //\r
+      TempString2[0]  = TempString[Index * 2];\r
+      TempString2[1]  = TempString[Index * 2 + 1];\r
+      sscanf (TempString2, "%x", &Value32);\r
+      Value->Data4[Index + 2] = (UINT8) Value32;\r
+    }\r
+\r
+    Status = TRUE;\r
+  } else {\r
+    //\r
+    // Unsupported GUID style\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+Done:\r
+  if (Status == FALSE) {\r
+    SetFilePosition (&FPos);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+GetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  )\r
+{\r
+  Fpos->FileBufferPtr = mGlobals.SourceFile.FileBufferPtr;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+SetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  )\r
+{\r
+  //\r
+  // Should check range of pointer\r
+  //\r
+  mGlobals.SourceFile.FileBufferPtr = Fpos->FileBufferPtr;\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h
new file mode 100644 (file)
index 0000000..ee59a6d
--- /dev/null
@@ -0,0 +1,118 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileParsing.h\r
+\r
+Abstract:\r
+\r
+  Function prototypes and defines for the simple file parsing routines.\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_FILE_PARSING_H_\r
+#define _SIMPLE_FILE_PARSING_H_\r
+\r
+#define T_CHAR  char\r
+\r
+STATUS\r
+SFPInit (\r
+  VOID\r
+  )\r
+;\r
+\r
+STATUS\r
+SFPOpenFile (\r
+  char    *FileName\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsKeyword (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsToken (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetNextToken (\r
+  T_CHAR        *Str,\r
+  unsigned int  Len\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetGuidToken (\r
+  T_CHAR *Str,\r
+  UINT32 Len\r
+  )\r
+;\r
+\r
+#define PARSE_GUID_STYLE_5_FIELDS 0\r
+\r
+BOOLEAN\r
+SFPGetGuid (\r
+  int         GuidStyle,\r
+  EFI_GUID    *Value\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPSkipToToken (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetNumber (\r
+  unsigned int   *Value\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetQuotedString (\r
+  T_CHAR      *Str,\r
+  int         Length\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsEOF (\r
+  VOID\r
+  )\r
+;\r
+\r
+STATUS\r
+SFPCloseFile (\r
+  VOID\r
+  )\r
+;\r
+\r
+unsigned\r
+int\r
+SFPGetLineNumber (\r
+  VOID\r
+  )\r
+;\r
+\r
+T_CHAR  *\r
+SFPGetFileName (\r
+  VOID\r
+  )\r
+;\r
+\r
+#endif // #ifndef _SIMPLE_FILE_PARSING_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c
new file mode 100644 (file)
index 0000000..5cb13b2
--- /dev/null
@@ -0,0 +1,1765 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                              \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  TianoCompress.c\r
+\r
+Abstract:\r
+\r
+  Compression routine. The compression algorithm is a mixture of\r
+  LZ77 and Huffman coding. LZ77 transforms the source data into a\r
+  sequence of Original Characters and Pointers to repeated strings.\r
+  This sequence is further divided into Blocks and Huffman codings\r
+  are applied to each Block.\r
+\r
+--*/\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "TianoCommon.h"\r
+#include "Compress.h"\r
+\r
+//\r
+// Macro Definitions\r
+//\r
+typedef INT32 NODE;\r
+#define UINT8_MAX     0xff\r
+#define UINT8_BIT     8\r
+#define THRESHOLD     3\r
+#define INIT_CRC      0\r
+#define WNDBIT        19\r
+#define WNDSIZ        (1U << WNDBIT)\r
+#define MAXMATCH      256\r
+#define BLKSIZ        (1U << 14)  // 16 * 1024U\r
+#define PERC_FLAG     0x80000000U\r
+#define CODE_BIT      16\r
+#define NIL           0\r
+#define MAX_HASH_VAL  (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)\r
+#define HASH(p, c)    ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)\r
+#define CRCPOLY       0xA001\r
+#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)\r
+\r
+//\r
+// C: the Char&Len Set; P: the Position Set; T: the exTra Set\r
+//\r
+#define NC    (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT  9\r
+#define NP    (WNDBIT + 1)\r
+#define PBIT  5\r
+#define NT    (CODE_BIT + 3)\r
+#define TBIT  5\r
+#if NT > NP\r
+#define NPT   NT\r
+#else\r
+#define NPT   NP\r
+#endif\r
+//\r
+// Function Prototypes\r
+//\r
+STATIC\r
+EFI_STATUS\r
+Compress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize,\r
+  IN      UINT8   Version\r
+  );\r
+\r
+STATIC\r
+VOID\r
+PutDword(\r
+  IN UINT32 Data\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+AllocateMemory (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+FreeMemory (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InitSlide (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+NODE\r
+Child (\r
+  IN NODE   NodeQ,\r
+  IN UINT8  CharC\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeChild (\r
+  IN NODE  NodeQ,\r
+  IN UINT8 CharC,\r
+  IN NODE  NodeR\r
+  );\r
+\r
+STATIC\r
+VOID\r
+Split (\r
+  IN NODE Old\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InsertNode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+DeleteNode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+GetNextMatch (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+Encode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+CountTFreq (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+WritePTLen (\r
+  IN INT32 Number,\r
+  IN INT32 nbit,\r
+  IN INT32 Special\r
+  );\r
+\r
+STATIC\r
+VOID\r
+WriteCLen (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EncodeC (\r
+  IN INT32 Value\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EncodeP (\r
+  IN UINT32 Value\r
+  );\r
+\r
+STATIC\r
+VOID\r
+SendBlock (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+Output (\r
+  IN UINT32 c,\r
+  IN UINT32 p\r
+  );\r
+\r
+STATIC\r
+VOID\r
+HufEncodeStart (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+HufEncodeEnd (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeCrcTable (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+PutBits (\r
+  IN INT32  Number,\r
+  IN UINT32 Value\r
+  );\r
+\r
+STATIC\r
+INT32\r
+FreadCrc (\r
+  OUT UINT8 *Pointer,\r
+  IN  INT32 Number\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InitPutBits (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+CountLen (\r
+  IN INT32 Index\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeLen (\r
+  IN INT32 Root\r
+  );\r
+\r
+STATIC\r
+VOID\r
+DownHeap (\r
+  IN INT32 Index\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeCode (\r
+  IN  INT32       Number,\r
+  IN  UINT8 Len[  ],\r
+  OUT UINT16 Code[]\r
+  );\r
+\r
+STATIC\r
+INT32\r
+MakeTree (\r
+  IN  INT32            NParm,\r
+  IN  UINT16  FreqParm[],\r
+  OUT UINT8   LenParm[ ],\r
+  OUT UINT16  CodeParm[]\r
+  );\r
+\r
+//\r
+//  Global Variables\r
+//\r
+STATIC UINT8  *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;\r
+\r
+STATIC UINT8  *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;\r
+STATIC INT16  mHeap[NC + 1];\r
+STATIC INT32  mRemainder, mMatchLen, mBitCount, mHeapSize, mN;\r
+STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;\r
+STATIC UINT32 mCompSize, mOrigSize;\r
+\r
+STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], mCrcTable[UINT8_MAX + 1],\r
+  mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];\r
+\r
+STATIC NODE   mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;\r
+\r
+//\r
+// functions\r
+//\r
+\r
+EFI_STATUS\r
+TianoCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The internal implementation of [Efi/Tiano]Compress().\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+  Version     - The version of de/compression algorithm.\r
+                Version 1 for EFI 1.1 de/compression algorithm.\r
+                Version 2 for Tiano de/compression algorithm.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+  EFI_OUT_OF_RESOURCES  - No resource to complete function.\r
+  EFI_INVALID_PARAMETER - Parameter supplied is wrong.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initializations\r
+  //\r
+  mBufSiz         = 0;\r
+  mBuf            = NULL;\r
+  mText           = NULL;\r
+  mLevel          = NULL;\r
+  mChildCount     = NULL;\r
+  mPosition       = NULL;\r
+  mParent         = NULL;\r
+  mPrev           = NULL;\r
+  mNext           = NULL;\r
+\r
+  mSrc            = SrcBuffer;\r
+  mSrcUpperLimit  = mSrc + SrcSize;\r
+  mDst            = DstBuffer;\r
+  mDstUpperLimit  = mDst + *DstSize;\r
+\r
+  PutDword (0L);\r
+  PutDword (0L);\r
+\r
+  MakeCrcTable ();\r
+\r
+  mOrigSize             = mCompSize = 0;\r
+  mCrc                  = INIT_CRC;\r
+\r
+  //\r
+  // Compress it\r
+  //\r
+  Status = Encode ();\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Null terminate the compressed data\r
+  //\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = 0;\r
+  }\r
+  //\r
+  // Fill in compressed size and original size\r
+  //\r
+  mDst = DstBuffer;\r
+  PutDword (mCompSize + 1);\r
+  PutDword (mOrigSize);\r
+\r
+  //\r
+  // Return\r
+  //\r
+  if (mCompSize + 1 + 8 > *DstSize) {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+}\r
+\r
+STATIC\r
+VOID\r
+PutDword (\r
+  IN UINT32 Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Put a dword to output stream\r
+  \r
+Arguments:\r
+\r
+  Data    - the dword to put\r
+  \r
+Returns: (VOID)\r
+  \r
+--*/\r
+{\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff);\r
+  }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+AllocateMemory (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate memory spaces for data structures used in compression process\r
+  \r
+Argements: \r
+  VOID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Memory is allocated successfully\r
+  EFI_OUT_OF_RESOURCES  - Allocation fails\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+\r
+  mText = malloc (WNDSIZ * 2 + MAXMATCH);\r
+  for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {\r
+    mText[Index] = 0;\r
+  }\r
+\r
+  mLevel      = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));\r
+  mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));\r
+  mPosition   = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));\r
+  mParent     = malloc (WNDSIZ * 2 * sizeof (*mParent));\r
+  mPrev       = malloc (WNDSIZ * 2 * sizeof (*mPrev));\r
+  mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));\r
+\r
+  mBufSiz     = BLKSIZ;\r
+  mBuf        = malloc (mBufSiz);\r
+  while (mBuf == NULL) {\r
+    mBufSiz = (mBufSiz / 10U) * 9U;\r
+    if (mBufSiz < 4 * 1024U) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    mBuf = malloc (mBufSiz);\r
+  }\r
+\r
+  mBuf[0] = 0;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+FreeMemory (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Called when compression is completed to free memory previously allocated.\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  if (mText != NULL) {\r
+    free (mText);\r
+  }\r
+\r
+  if (mLevel != NULL) {\r
+    free (mLevel);\r
+  }\r
+\r
+  if (mChildCount != NULL) {\r
+    free (mChildCount);\r
+  }\r
+\r
+  if (mPosition != NULL) {\r
+    free (mPosition);\r
+  }\r
+\r
+  if (mParent != NULL) {\r
+    free (mParent);\r
+  }\r
+\r
+  if (mPrev != NULL) {\r
+    free (mPrev);\r
+  }\r
+\r
+  if (mNext != NULL) {\r
+    free (mNext);\r
+  }\r
+\r
+  if (mBuf != NULL) {\r
+    free (mBuf);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+InitSlide (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize String Info Log data structures\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  Index;\r
+\r
+  for (Index = WNDSIZ; Index <= WNDSIZ + UINT8_MAX; Index++) {\r
+    mLevel[Index]     = 1;\r
+    mPosition[Index]  = NIL;  /* sentinel */\r
+  }\r
+\r
+  for (Index = WNDSIZ; Index < WNDSIZ * 2; Index++) {\r
+    mParent[Index] = NIL;\r
+  }\r
+\r
+  mAvail = 1;\r
+  for (Index = 1; Index < WNDSIZ - 1; Index++) {\r
+    mNext[Index] = (NODE) (Index + 1);\r
+  }\r
+\r
+  mNext[WNDSIZ - 1] = NIL;\r
+  for (Index = WNDSIZ * 2; Index <= MAX_HASH_VAL; Index++) {\r
+    mNext[Index] = NIL;\r
+  }\r
+}\r
+\r
+STATIC\r
+NODE\r
+Child (\r
+  IN NODE  NodeQ,\r
+  IN UINT8 CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find child node given the parent node and the edge character\r
+  \r
+Arguments:\r
+\r
+  NodeQ       - the parent node\r
+  CharC       - the edge character\r
+  \r
+Returns:\r
+\r
+  The child node (NIL if not found)  \r
+  \r
+--*/\r
+{\r
+  NODE  NodeR;\r
+\r
+  NodeR = mNext[HASH (NodeQ, CharC)];\r
+  //\r
+  // sentinel\r
+  //\r
+  mParent[NIL] = NodeQ;\r
+  while (mParent[NodeR] != NodeQ) {\r
+    NodeR = mNext[NodeR];\r
+  }\r
+\r
+  return NodeR;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeChild (\r
+  IN NODE  Parent,\r
+  IN UINT8 CharC,\r
+  IN NODE  Child\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a new child for a given parent node.\r
+  \r
+Arguments:\r
+\r
+  Parent       - the parent node\r
+  CharC   - the edge character\r
+  Child       - the child node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  Node1;\r
+  NODE  Node2;\r
+\r
+  Node1           = (NODE) HASH (Parent, CharC);\r
+  Node2           = mNext[Node1];\r
+  mNext[Node1]    = Child;\r
+  mNext[Child]    = Node2;\r
+  mPrev[Node2]    = Child;\r
+  mPrev[Child]    = Node1;\r
+  mParent[Child]  = Parent;\r
+  mChildCount[Parent]++;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Split (\r
+  NODE Old\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Split a node.\r
+  \r
+Arguments:\r
+\r
+  Old     - the node to split\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  New;\r
+  NODE  TempNode;\r
+\r
+  New               = mAvail;\r
+  mAvail            = mNext[New];\r
+  mChildCount[New]  = 0;\r
+  TempNode          = mPrev[Old];\r
+  mPrev[New]        = TempNode;\r
+  mNext[TempNode]   = New;\r
+  TempNode          = mNext[Old];\r
+  mNext[New]        = TempNode;\r
+  mPrev[TempNode]   = New;\r
+  mParent[New]      = mParent[Old];\r
+  mLevel[New]       = (UINT8) mMatchLen;\r
+  mPosition[New]    = mPos;\r
+  MakeChild (New, mText[mMatchPos + mMatchLen], Old);\r
+  MakeChild (New, mText[mPos + mMatchLen], mPos);\r
+}\r
+\r
+STATIC\r
+VOID\r
+InsertNode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert string info for current position into the String Info Log\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  NodeQ;\r
+  NODE  NodeR;\r
+  NODE  Index2;\r
+  NODE  NodeT;\r
+  UINT8 CharC;\r
+  UINT8 *t1;\r
+  UINT8 *t2;\r
+\r
+  if (mMatchLen >= 4) {\r
+    //\r
+    // We have just got a long match, the target tree\r
+    // can be located by MatchPos + 1. Travese the tree\r
+    // from bottom up to get to a proper starting point.\r
+    // The usage of PERC_FLAG ensures proper node deletion\r
+    // in DeleteNode() later.\r
+    //\r
+    mMatchLen--;\r
+    NodeR = (NODE) ((mMatchPos + 1) | WNDSIZ);\r
+    NodeQ = mParent[NodeR];\r
+    while (NodeQ == NIL) {\r
+      NodeR = mNext[NodeR];\r
+      NodeQ = mParent[NodeR];\r
+    }\r
+\r
+    while (mLevel[NodeQ] >= mMatchLen) {\r
+      NodeR = NodeQ;\r
+      NodeQ = mParent[NodeQ];\r
+    }\r
+\r
+    NodeT = NodeQ;\r
+    while (mPosition[NodeT] < 0) {\r
+      mPosition[NodeT]  = mPos;\r
+      NodeT             = mParent[NodeT];\r
+    }\r
+\r
+    if (NodeT < WNDSIZ) {\r
+      mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG);\r
+    }\r
+  } else {\r
+    //\r
+    // Locate the target tree\r
+    //\r
+    NodeQ = (NODE) (mText[mPos] + WNDSIZ);\r
+    CharC = mText[mPos + 1];\r
+    NodeR = Child (NodeQ, CharC);\r
+    if (NodeR == NIL) {\r
+      MakeChild (NodeQ, CharC, mPos);\r
+      mMatchLen = 1;\r
+      return ;\r
+    }\r
+\r
+    mMatchLen = 2;\r
+  }\r
+  //\r
+  // Traverse down the tree to find a match.\r
+  // Update Position value along the route.\r
+  // Node split or creation is involved.\r
+  //\r
+  for (;;) {\r
+    if (NodeR >= WNDSIZ) {\r
+      Index2    = MAXMATCH;\r
+      mMatchPos = NodeR;\r
+    } else {\r
+      Index2    = mLevel[NodeR];\r
+      mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
+    }\r
+\r
+    if (mMatchPos >= mPos) {\r
+      mMatchPos -= WNDSIZ;\r
+    }\r
+\r
+    t1  = &mText[mPos + mMatchLen];\r
+    t2  = &mText[mMatchPos + mMatchLen];\r
+    while (mMatchLen < Index2) {\r
+      if (*t1 != *t2) {\r
+        Split (NodeR);\r
+        return ;\r
+      }\r
+\r
+      mMatchLen++;\r
+      t1++;\r
+      t2++;\r
+    }\r
+\r
+    if (mMatchLen >= MAXMATCH) {\r
+      break;\r
+    }\r
+\r
+    mPosition[NodeR]  = mPos;\r
+    NodeQ             = NodeR;\r
+    NodeR             = Child (NodeQ, *t1);\r
+    if (NodeR == NIL) {\r
+      MakeChild (NodeQ, *t1, mPos);\r
+      return ;\r
+    }\r
+\r
+    mMatchLen++;\r
+  }\r
+\r
+  NodeT           = mPrev[NodeR];\r
+  mPrev[mPos]     = NodeT;\r
+  mNext[NodeT]    = mPos;\r
+  NodeT           = mNext[NodeR];\r
+  mNext[mPos]     = NodeT;\r
+  mPrev[NodeT]    = mPos;\r
+  mParent[mPos]   = NodeQ;\r
+  mParent[NodeR]  = NIL;\r
+\r
+  //\r
+  // Special usage of 'next'\r
+  //\r
+  mNext[NodeR] = mPos;\r
+\r
+}\r
+\r
+STATIC\r
+VOID\r
+DeleteNode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Delete outdated string info. (The Usage of PERC_FLAG\r
+  ensures a clean deletion)\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  NodeQ;\r
+  NODE  NodeR;\r
+  NODE  NodeS;\r
+  NODE  NodeT;\r
+  NODE  NodeU;\r
+\r
+  if (mParent[mPos] == NIL) {\r
+    return ;\r
+  }\r
+\r
+  NodeR         = mPrev[mPos];\r
+  NodeS         = mNext[mPos];\r
+  mNext[NodeR]  = NodeS;\r
+  mPrev[NodeS]  = NodeR;\r
+  NodeR         = mParent[mPos];\r
+  mParent[mPos] = NIL;\r
+  if (NodeR >= WNDSIZ) {\r
+    return ;\r
+  }\r
+\r
+  mChildCount[NodeR]--;\r
+  if (mChildCount[NodeR] > 1) {\r
+    return ;\r
+  }\r
+\r
+  NodeT = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
+  if (NodeT >= mPos) {\r
+    NodeT -= WNDSIZ;\r
+  }\r
+\r
+  NodeS = NodeT;\r
+  NodeQ = mParent[NodeR];\r
+  NodeU = mPosition[NodeQ];\r
+  while (NodeU & (UINT32) PERC_FLAG) {\r
+    NodeU &= (UINT32)~PERC_FLAG;\r
+    if (NodeU >= mPos) {\r
+      NodeU -= WNDSIZ;\r
+    }\r
+\r
+    if (NodeU > NodeS) {\r
+      NodeS = NodeU;\r
+    }\r
+\r
+    mPosition[NodeQ]  = (NODE) (NodeS | WNDSIZ);\r
+    NodeQ             = mParent[NodeQ];\r
+    NodeU             = mPosition[NodeQ];\r
+  }\r
+\r
+  if (NodeQ < WNDSIZ) {\r
+    if (NodeU >= mPos) {\r
+      NodeU -= WNDSIZ;\r
+    }\r
+\r
+    if (NodeU > NodeS) {\r
+      NodeS = NodeU;\r
+    }\r
+\r
+    mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ | (UINT32) PERC_FLAG);\r
+  }\r
+\r
+  NodeS           = Child (NodeR, mText[NodeT + mLevel[NodeR]]);\r
+  NodeT           = mPrev[NodeS];\r
+  NodeU           = mNext[NodeS];\r
+  mNext[NodeT]    = NodeU;\r
+  mPrev[NodeU]    = NodeT;\r
+  NodeT           = mPrev[NodeR];\r
+  mNext[NodeT]    = NodeS;\r
+  mPrev[NodeS]    = NodeT;\r
+  NodeT           = mNext[NodeR];\r
+  mPrev[NodeT]    = NodeS;\r
+  mNext[NodeS]    = NodeT;\r
+  mParent[NodeS]  = mParent[NodeR];\r
+  mParent[NodeR]  = NIL;\r
+  mNext[NodeR]    = mAvail;\r
+  mAvail          = NodeR;\r
+}\r
+\r
+STATIC\r
+VOID\r
+GetNextMatch (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Advance the current position (read in new data if needed).\r
+  Delete outdated string info. Find a match string for current position.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Number;\r
+\r
+  mRemainder--;\r
+  mPos++;\r
+  if (mPos == WNDSIZ * 2) {\r
+    memmove (&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+    Number = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ);\r
+    mRemainder += Number;\r
+    mPos = WNDSIZ;\r
+  }\r
+\r
+  DeleteNode ();\r
+  InsertNode ();\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+Encode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The main controlling routine for compression process.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns:\r
+  \r
+  EFI_SUCCESS           - The compression is successful\r
+  EFI_OUT_0F_RESOURCES  - Not enough memory for compression process\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  INT32       LastMatchLen;\r
+  NODE        LastMatchPos;\r
+\r
+  Status = AllocateMemory ();\r
+  if (EFI_ERROR (Status)) {\r
+    FreeMemory ();\r
+    return Status;\r
+  }\r
+\r
+  InitSlide ();\r
+\r
+  HufEncodeStart ();\r
+\r
+  mRemainder  = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+\r
+  mMatchLen   = 0;\r
+  mPos        = WNDSIZ;\r
+  InsertNode ();\r
+  if (mMatchLen > mRemainder) {\r
+    mMatchLen = mRemainder;\r
+  }\r
+\r
+  while (mRemainder > 0) {\r
+    LastMatchLen  = mMatchLen;\r
+    LastMatchPos  = mMatchPos;\r
+    GetNextMatch ();\r
+    if (mMatchLen > mRemainder) {\r
+      mMatchLen = mRemainder;\r
+    }\r
+\r
+    if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {\r
+      //\r
+      // Not enough benefits are gained by outputting a pointer,\r
+      // so just output the original character\r
+      //\r
+      Output (mText[mPos - 1], 0);\r
+\r
+    } else {\r
+\r
+      if (LastMatchLen == THRESHOLD) {\r
+        if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) {\r
+          Output (mText[mPos - 1], 0);\r
+          continue;\r
+        }\r
+      }\r
+      //\r
+      // Outputting a pointer is beneficial enough, do it.\r
+      //\r
+      Output (\r
+        LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),\r
+        (mPos - LastMatchPos - 2) & (WNDSIZ - 1)\r
+        );\r
+      LastMatchLen--;\r
+      while (LastMatchLen > 0) {\r
+        GetNextMatch ();\r
+        LastMatchLen--;\r
+      }\r
+\r
+      if (mMatchLen > mRemainder) {\r
+        mMatchLen = mRemainder;\r
+      }\r
+    }\r
+  }\r
+\r
+  HufEncodeEnd ();\r
+  FreeMemory ();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+CountTFreq (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the frequencies for the Extra Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+  INT32 Number;\r
+  INT32 Count;\r
+\r
+  for (Index = 0; Index < NT; Index++) {\r
+    mTFreq[Index] = 0;\r
+  }\r
+\r
+  Number = NC;\r
+  while (Number > 0 && mCLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mCLen[Index++];\r
+    if (Index3 == 0) {\r
+      Count = 1;\r
+      while (Index < Number && mCLen[Index] == 0) {\r
+        Index++;\r
+        Count++;\r
+      }\r
+\r
+      if (Count <= 2) {\r
+        mTFreq[0] = (UINT16) (mTFreq[0] + Count);\r
+      } else if (Count <= 18) {\r
+        mTFreq[1]++;\r
+      } else if (Count == 19) {\r
+        mTFreq[0]++;\r
+        mTFreq[1]++;\r
+      } else {\r
+        mTFreq[2]++;\r
+      }\r
+    } else {\r
+      mTFreq[Index3 + 2]++;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+WritePTLen (\r
+  IN INT32 Number,\r
+  IN INT32 nbit,\r
+  IN INT32 Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for the Extra Set or the Position Set.\r
+  \r
+Arguments:\r
+\r
+  Number       - the number of symbols\r
+  nbit    - the number of bits needed to represent 'n'\r
+  Special - the special symbol that needs to be take care of\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+\r
+  while (Number > 0 && mPTLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  PutBits (nbit, Number);\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mPTLen[Index++];\r
+    if (Index3 <= 6) {\r
+      PutBits (3, Index3);\r
+    } else {\r
+      PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);\r
+    }\r
+\r
+    if (Index == Special) {\r
+      while (Index < 6 && mPTLen[Index] == 0) {\r
+        Index++;\r
+      }\r
+\r
+      PutBits (2, (Index - 3) & 3);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+WriteCLen (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for Char&Length Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+  INT32 Number;\r
+  INT32 Count;\r
+\r
+  Number = NC;\r
+  while (Number > 0 && mCLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  PutBits (CBIT, Number);\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mCLen[Index++];\r
+    if (Index3 == 0) {\r
+      Count = 1;\r
+      while (Index < Number && mCLen[Index] == 0) {\r
+        Index++;\r
+        Count++;\r
+      }\r
+\r
+      if (Count <= 2) {\r
+        for (Index3 = 0; Index3 < Count; Index3++) {\r
+          PutBits (mPTLen[0], mPTCode[0]);\r
+        }\r
+      } else if (Count <= 18) {\r
+        PutBits (mPTLen[1], mPTCode[1]);\r
+        PutBits (4, Count - 3);\r
+      } else if (Count == 19) {\r
+        PutBits (mPTLen[0], mPTCode[0]);\r
+        PutBits (mPTLen[1], mPTCode[1]);\r
+        PutBits (4, 15);\r
+      } else {\r
+        PutBits (mPTLen[2], mPTCode[2]);\r
+        PutBits (CBIT, Count - 20);\r
+      }\r
+    } else {\r
+      PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+EncodeC (\r
+  IN INT32 Value\r
+  )\r
+{\r
+  PutBits (mCLen[Value], mCCode[Value]);\r
+}\r
+\r
+STATIC\r
+VOID\r
+EncodeP (\r
+  IN UINT32 Value\r
+  )\r
+{\r
+  UINT32  Index;\r
+  UINT32  NodeQ;\r
+\r
+  Index = 0;\r
+  NodeQ = Value;\r
+  while (NodeQ) {\r
+    NodeQ >>= 1;\r
+    Index++;\r
+  }\r
+\r
+  PutBits (mPTLen[Index], mPTCode[Index]);\r
+  if (Index > 1) {\r
+    PutBits (Index - 1, Value & (0xFFFFFFFFU >> (32 - Index + 1)));\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+SendBlock (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Huffman code the block and output it.\r
+  \r
+Arguments: \r
+  (VOID)\r
+\r
+Returns: \r
+  (VOID)\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  Index3;\r
+  UINT32  Flags;\r
+  UINT32  Root;\r
+  UINT32  Pos;\r
+  UINT32  Size;\r
+  Flags = 0;\r
+\r
+  Root  = MakeTree (NC, mCFreq, mCLen, mCCode);\r
+  Size  = mCFreq[Root];\r
+  PutBits (16, Size);\r
+  if (Root >= NC) {\r
+    CountTFreq ();\r
+    Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);\r
+    if (Root >= NT) {\r
+      WritePTLen (NT, TBIT, 3);\r
+    } else {\r
+      PutBits (TBIT, 0);\r
+      PutBits (TBIT, Root);\r
+    }\r
+\r
+    WriteCLen ();\r
+  } else {\r
+    PutBits (TBIT, 0);\r
+    PutBits (TBIT, 0);\r
+    PutBits (CBIT, 0);\r
+    PutBits (CBIT, Root);\r
+  }\r
+\r
+  Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);\r
+  if (Root >= NP) {\r
+    WritePTLen (NP, PBIT, -1);\r
+  } else {\r
+    PutBits (PBIT, 0);\r
+    PutBits (PBIT, Root);\r
+  }\r
+\r
+  Pos = 0;\r
+  for (Index = 0; Index < Size; Index++) {\r
+    if (Index % UINT8_BIT == 0) {\r
+      Flags = mBuf[Pos++];\r
+    } else {\r
+      Flags <<= 1;\r
+    }\r
+\r
+    if (Flags & (1U << (UINT8_BIT - 1))) {\r
+      EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));\r
+      Index3 = mBuf[Pos++];\r
+      for (Index2 = 0; Index2 < 3; Index2++) {\r
+        Index3 <<= UINT8_BIT;\r
+        Index3 += mBuf[Pos++];\r
+      }\r
+\r
+      EncodeP (Index3);\r
+    } else {\r
+      EncodeC (mBuf[Pos++]);\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < NC; Index++) {\r
+    mCFreq[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NP; Index++) {\r
+    mPFreq[Index] = 0;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+Output (\r
+  IN UINT32 CharC,\r
+  IN UINT32 Pos\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs an Original Character or a Pointer\r
+\r
+Arguments:\r
+\r
+  CharC     - The original character or the 'String Length' element of a Pointer\r
+  Pos     - The 'Position' field of a Pointer\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  STATIC UINT32 CPos;\r
+\r
+  if ((mOutputMask >>= 1) == 0) {\r
+    mOutputMask = 1U << (UINT8_BIT - 1);\r
+    //\r
+    // Check the buffer overflow per outputing UINT8_BIT symbols\r
+    // which is an Original Character or a Pointer. The biggest\r
+    // symbol is a Pointer which occupies 5 bytes.\r
+    //\r
+    if (mOutputPos >= mBufSiz - 5 * UINT8_BIT) {\r
+      SendBlock ();\r
+      mOutputPos = 0;\r
+    }\r
+\r
+    CPos        = mOutputPos++;\r
+    mBuf[CPos]  = 0;\r
+  }\r
+\r
+  mBuf[mOutputPos++] = (UINT8) CharC;\r
+  mCFreq[CharC]++;\r
+  if (CharC >= (1U << UINT8_BIT)) {\r
+    mBuf[CPos] |= mOutputMask;\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> 24);\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> 16);\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> (UINT8_BIT));\r
+    mBuf[mOutputPos++]  = (UINT8) Pos;\r
+    CharC               = 0;\r
+    while (Pos) {\r
+      Pos >>= 1;\r
+      CharC++;\r
+    }\r
+\r
+    mPFreq[CharC]++;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+HufEncodeStart (\r
+  VOID\r
+  )\r
+{\r
+  INT32 Index;\r
+\r
+  for (Index = 0; Index < NC; Index++) {\r
+    mCFreq[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NP; Index++) {\r
+    mPFreq[Index] = 0;\r
+  }\r
+\r
+  mOutputPos = mOutputMask = 0;\r
+  InitPutBits ();\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+HufEncodeEnd (\r
+  VOID\r
+  )\r
+{\r
+  SendBlock ();\r
+\r
+  //\r
+  // Flush remaining bits\r
+  //\r
+  PutBits (UINT8_BIT - 1, 0);\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeCrcTable (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  Temp;\r
+\r
+  for (Index = 0; Index <= UINT8_MAX; Index++) {\r
+    Temp = Index;\r
+    for (Index2 = 0; Index2 < UINT8_BIT; Index2++) {\r
+      if (Temp & 1) {\r
+        Temp = (Temp >> 1) ^ CRCPOLY;\r
+      } else {\r
+        Temp >>= 1;\r
+      }\r
+    }\r
+\r
+    mCrcTable[Index] = (UINT16) Temp;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+PutBits (\r
+  IN INT32  Number,\r
+  IN UINT32 Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs rightmost n bits of x\r
+\r
+Arguments:\r
+\r
+  Number   - the rightmost n bits of the data is used\r
+  x   - the data \r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT8 Temp;\r
+\r
+  while (Number >= mBitCount) {\r
+    //\r
+    // Number -= mBitCount should never equal to 32\r
+    //\r
+    Temp = (UINT8) (mSubBitBuf | (Value >> (Number -= mBitCount)));\r
+    if (mDst < mDstUpperLimit) {\r
+      *mDst++ = Temp;\r
+    }\r
+\r
+    mCompSize++;\r
+    mSubBitBuf  = 0;\r
+    mBitCount   = UINT8_BIT;\r
+  }\r
+\r
+  mSubBitBuf |= Value << (mBitCount -= Number);\r
+}\r
+\r
+STATIC\r
+INT32\r
+FreadCrc (\r
+  OUT UINT8 *Pointer,\r
+  IN  INT32 Number\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read in source data\r
+  \r
+Arguments:\r
+\r
+  Pointer   - the buffer to hold the data\r
+  Number   - number of bytes to read\r
+\r
+Returns:\r
+\r
+  number of bytes actually read\r
+  \r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  for (Index = 0; mSrc < mSrcUpperLimit && Index < Number; Index++) {\r
+    *Pointer++ = *mSrc++;\r
+  }\r
+\r
+  Number = Index;\r
+\r
+  Pointer -= Number;\r
+  mOrigSize += Number;\r
+  Index--;\r
+  while (Index >= 0) {\r
+    UPDATE_CRC (*Pointer++);\r
+    Index--;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+STATIC\r
+VOID\r
+InitPutBits (\r
+  VOID\r
+  )\r
+{\r
+  mBitCount   = UINT8_BIT;\r
+  mSubBitBuf  = 0;\r
+}\r
+\r
+STATIC\r
+VOID\r
+CountLen (\r
+  IN INT32 Index\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the number of each code length for a Huffman tree.\r
+  \r
+Arguments:\r
+\r
+  Index   - the top node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  STATIC INT32  Depth = 0;\r
+\r
+  if (Index < mN) {\r
+    mLenCnt[(Depth < 16) ? Depth : 16]++;\r
+  } else {\r
+    Depth++;\r
+    CountLen (mLeft[Index]);\r
+    CountLen (mRight[Index]);\r
+    Depth--;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeLen (\r
+  IN INT32 Root\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create code length array for a Huffman tree\r
+  \r
+Arguments:\r
+\r
+  Root   - the root of the tree\r
+  \r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  INT32   Index;\r
+  INT32   Index3;\r
+  UINT32  Cum;\r
+\r
+  for (Index = 0; Index <= 16; Index++) {\r
+    mLenCnt[Index] = 0;\r
+  }\r
+\r
+  CountLen (Root);\r
+\r
+  //\r
+  // Adjust the length count array so that\r
+  // no code will be generated longer than its designated length\r
+  //\r
+  Cum = 0;\r
+  for (Index = 16; Index > 0; Index--) {\r
+    Cum += mLenCnt[Index] << (16 - Index);\r
+  }\r
+\r
+  while (Cum != (1U << 16)) {\r
+    mLenCnt[16]--;\r
+    for (Index = 15; Index > 0; Index--) {\r
+      if (mLenCnt[Index] != 0) {\r
+        mLenCnt[Index]--;\r
+        mLenCnt[Index + 1] += 2;\r
+        break;\r
+      }\r
+    }\r
+\r
+    Cum--;\r
+  }\r
+\r
+  for (Index = 16; Index > 0; Index--) {\r
+    Index3 = mLenCnt[Index];\r
+    Index3--;\r
+    while (Index3 >= 0) {\r
+      mLen[*mSortPtr++] = (UINT8) Index;\r
+      Index3--;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+DownHeap (\r
+  IN INT32 Index\r
+  )\r
+{\r
+  INT32 Index2;\r
+  INT32 Index3;\r
+\r
+  //\r
+  // priority queue: send Index-th entry down heap\r
+  //\r
+  Index3  = mHeap[Index];\r
+  Index2  = 2 * Index;\r
+  while (Index2 <= mHeapSize) {\r
+    if (Index2 < mHeapSize && mFreq[mHeap[Index2]] > mFreq[mHeap[Index2 + 1]]) {\r
+      Index2++;\r
+    }\r
+\r
+    if (mFreq[Index3] <= mFreq[mHeap[Index2]]) {\r
+      break;\r
+    }\r
+\r
+    mHeap[Index]  = mHeap[Index2];\r
+    Index         = Index2;\r
+    Index2        = 2 * Index;\r
+  }\r
+\r
+  mHeap[Index] = (INT16) Index3;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeCode (\r
+  IN  INT32       Number,\r
+  IN  UINT8 Len[  ],\r
+  OUT UINT16 Code[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Assign code to each symbol based on the code length array\r
+  \r
+Arguments:\r
+\r
+  Number     - number of symbols\r
+  Len   - the code length array\r
+  Code  - stores codes for each symbol\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32   Index;\r
+  UINT16  Start[18];\r
+\r
+  Start[1] = 0;\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1);\r
+  }\r
+\r
+  for (Index = 0; Index < Number; Index++) {\r
+    Code[Index] = Start[Len[Index]]++;\r
+  }\r
+}\r
+\r
+STATIC\r
+INT32\r
+MakeTree (\r
+  IN  INT32            NParm,\r
+  IN  UINT16  FreqParm[],\r
+  OUT UINT8   LenParm[ ],\r
+  OUT UINT16  CodeParm[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Generates Huffman codes given a frequency distribution of symbols\r
+  \r
+Arguments:\r
+\r
+  NParm    - number of symbols\r
+  FreqParm - frequency of each symbol\r
+  LenParm  - code length for each symbol\r
+  CodeParm - code for each symbol\r
+  \r
+Returns:\r
+\r
+  Root of the Huffman tree.\r
+  \r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index2;\r
+  INT32 Index3;\r
+  INT32 Avail;\r
+\r
+  //\r
+  // make tree, calculate len[], return root\r
+  //\r
+  mN        = NParm;\r
+  mFreq     = FreqParm;\r
+  mLen      = LenParm;\r
+  Avail     = mN;\r
+  mHeapSize = 0;\r
+  mHeap[1]  = 0;\r
+  for (Index = 0; Index < mN; Index++) {\r
+    mLen[Index] = 0;\r
+    if (mFreq[Index]) {\r
+      mHeapSize++;\r
+      mHeap[mHeapSize] = (INT16) Index;\r
+    }\r
+  }\r
+\r
+  if (mHeapSize < 2) {\r
+    CodeParm[mHeap[1]] = 0;\r
+    return mHeap[1];\r
+  }\r
+\r
+  for (Index = mHeapSize / 2; Index >= 1; Index--) {\r
+    //\r
+    // make priority queue\r
+    //\r
+    DownHeap (Index);\r
+  }\r
+\r
+  mSortPtr = CodeParm;\r
+  do {\r
+    Index = mHeap[1];\r
+    if (Index < mN) {\r
+      *mSortPtr++ = (UINT16) Index;\r
+    }\r
+\r
+    mHeap[1] = mHeap[mHeapSize--];\r
+    DownHeap (1);\r
+    Index2 = mHeap[1];\r
+    if (Index2 < mN) {\r
+      *mSortPtr++ = (UINT16) Index2;\r
+    }\r
+\r
+    Index3        = Avail++;\r
+    mFreq[Index3] = (UINT16) (mFreq[Index] + mFreq[Index2]);\r
+    mHeap[1]      = (INT16) Index3;\r
+    DownHeap (1);\r
+    mLeft[Index3]   = (UINT16) Index;\r
+    mRight[Index3]  = (UINT16) Index2;\r
+  } while (mHeapSize > 1);\r
+\r
+  mSortPtr = CodeParm;\r
+  MakeLen (Index3);\r
+  MakeCode (NParm, LenParm, CodeParm);\r
+\r
+  //\r
+  // return root\r
+  //\r
+  return Index3;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c
new file mode 100644 (file)
index 0000000..a4af74a
--- /dev/null
@@ -0,0 +1,146 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  CustomizedCompress.c\r
+\r
+Abstract:\r
+\r
+  Header file for Customized compression routine\r
+  \r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+\r
+EFI_STATUS\r
+SetCustomizedCompressionType (\r
+  IN  CHAR8   *Type\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized SetCompressionType().\r
+\r
+Arguments:\r
+  Type        - The type if compression.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The type has been set.\r
+  EFI_UNSUPPORTED       - This type is unsupported.\r
+\r
+    \r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedGetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+\r
+    \r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedDecompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Customized compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile
new file mode 100644 (file)
index 0000000..4e36514
--- /dev/null
@@ -0,0 +1,82 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+TARGET_NAME        = CustomizedCompress\r
+TARGET_SOURCE_DIR  = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+TARGET_LIB = $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib\r
+\r
+OBJECTS = "$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj" \r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_LIB)\r
+\r
+#\r
+# Object targets\r
+#\r
\r
+"$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj": "$(TARGET_SOURCE_DIR)\CustomizedCompress.c" $(EDK_SOURCE)\Foundation\Include\EfiCommon.h\r
+  $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\CustomizedCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj"\r
+\r
+#\r
+# Build LIB\r
+#\r
+\r
+#\r
+# Add Binary Build description for this lib.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib))\r
+$(TARGET_LIB): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib $(TARGET_LIB) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb /Y\r
+!ELSE\r
+$(TARGET_LIB): $(OBJECTS)\r
+  $(LIB_EXE) $(LIB_FLAGS) $(OBJECTS) /OUT:$(TARGET_LIB)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_LIB) copy $(TARGET_LIB) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).lib /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\CustomizedCompress.* del /q $(EDK_TOOLS_OUTPUT)\CustomizedCompress.* > NUL\r
+  @if exist $(TARGET_LIB) del $(TARGET_LIB)\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
new file mode 100644 (file)
index 0000000..180422c
--- /dev/null
@@ -0,0 +1,386 @@
+/*++ \r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  EfiCompressMain.c\r
+  \r
+Abstract:\r
+\r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <assert.h>\r
+#include <stdarg.h>\r
+#include <stdio.h>\r
+#include "TianoCommon.h"\r
+#include "Compress.h"\r
+\r
+typedef enum {\r
+  EFI_COMPRESS   = 1,\r
+  TIANO_COMPRESS = 2\r
+} COMPRESS_TYPE;\r
+\r
+typedef struct _COMPRESS_ACTION_LIST {\r
+  struct _COMPRESS_ACTION_LIST   *NextAction;\r
+  INT32                          CompressType;\r
+  CHAR8                          *InFileName;\r
+  CHAR8                          *OutFileName;\r
+} COMPRESS_ACTION_LIST;\r
+\r
+\r
+STATIC\r
+BOOLEAN\r
+ParseCommandLine (\r
+  INT32                 argc,\r
+  CHAR8                 *argv[],\r
+  COMPRESS_ACTION_LIST  **ActionListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse command line options\r
+\r
+Arguments:\r
+  \r
+  argc    - number of arguments passed into the command line.\r
+  argv[]  - files to compress and files to output compressed data to.\r
+  Options - Point to COMMAND_LINE_OPTIONS, receiving command line options.\r
+\r
+Returns:\r
+  \r
+  BOOLEAN: TRUE for a successful parse.\r
+--*/\r
+;\r
+\r
+STATIC\r
+VOID\r
+Usage (\r
+  CHAR8 *ExeName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage.\r
+\r
+Arguments:\r
+  \r
+  ExeName  - Application's full path\r
+\r
+--*/\r
+;\r
+\r
+\r
+STATIC\r
+BOOLEAN\r
+ProcessFile (\r
+  CHAR8         *InFileName,\r
+  CHAR8         *OutFileName,\r
+  COMPRESS_TYPE CompressType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Compress InFileName to OutFileName using algorithm specified by CompressType.\r
+\r
+Arguments:\r
+  \r
+  InFileName    - Input file to compress\r
+  OutFileName   - Output file compress to\r
+  CompressType  - Compress algorithm, can be EFI_COMPRESS or TIANO_COMPRESS\r
+\r
+Returns:\r
+  \r
+  BOOLEAN: TRUE for compress file successfully\r
+\r
+--*/\r
+;\r
+\r
+int\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compresses the input files\r
+\r
+Arguments:\r
+\r
+  argc   - number of arguments passed into the command line.\r
+  argv[] - files to compress and files to output compressed data to.\r
+\r
+Returns:\r
+\r
+  int: 0 for successful execution of the function.\r
+\r
+--*/\r
+{\r
+  COMPRESS_ACTION_LIST *ActionList;\r
+  COMPRESS_ACTION_LIST *NextAction;\r
+  UINT32               ActionCount;\r
+  UINT32               SuccessCount;\r
+\r
+  ActionList            = NULL;\r
+  ActionCount          = SuccessCount = 0;\r
+\r
+  if (!ParseCommandLine (argc, argv, &ActionList)) {\r
+    Usage (*argv);\r
+    return 1;\r
+  }\r
+\r
+  while (ActionList != NULL) {\r
+    ++ActionCount;\r
+    if (ProcessFile (\r
+          ActionList->InFileName, \r
+          ActionList->OutFileName, \r
+          ActionList->CompressType)\r
+        ) {\r
+      ++SuccessCount;\r
+    }\r
+    NextAction = ActionList;\r
+    ActionList = ActionList->NextAction;\r
+    free (NextAction);\r
+  }\r
+\r
+  fprintf (stdout, "\nCompressed %d files, %d succeed!\n", ActionCount, SuccessCount);\r
+  if (SuccessCount < ActionCount) {\r
+    return 1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+STATIC\r
+BOOLEAN\r
+ParseCommandLine (\r
+  INT32                 argc,\r
+  CHAR8                 *argv[],\r
+  COMPRESS_ACTION_LIST  **ActionListHead\r
+  )\r
+{\r
+  COMPRESS_TYPE         CurrentType;\r
+\r
+  COMPRESS_ACTION_LIST  **Action;\r
+  \r
+  Action           =    ActionListHead;\r
+  CurrentType      =    EFI_COMPRESS;     // default compress algorithm\r
+\r
+  // Skip Exe Name\r
+  --argc;\r
+  ++argv;\r
+\r
+  while (argc > 0) {\r
+    if (strcmp (*argv, "-h") == 0 || strcmp (*argv, "-?") == 0) {\r
+      //\r
+      // 1. Directly return, help message will be printed.\r
+      //\r
+      return FALSE;\r
+    \r
+    } else if (strncmp (*argv, "-t", 2) == 0) {\r
+      //\r
+      // 2. Specifying CompressType\r
+      //\r
+      if (_stricmp ((*argv)+2, "EFI") == 0) {\r
+        CurrentType = EFI_COMPRESS;\r
+      } else if (_stricmp ((*argv)+2, "Tiano") == 0) {\r
+        CurrentType = TIANO_COMPRESS;\r
+      } else {\r
+        fprintf (stdout, "  ERROR: CompressType %s not supported!\n", (*argv)+2);\r
+        return FALSE;\r
+      }\r
+    } else {\r
+      //\r
+      // 3. Current parameter is *FileName\r
+      //\r
+      if (*Action == NULL) { \r
+        //\r
+        // need to create a new action item\r
+        //\r
+        *Action = (COMPRESS_ACTION_LIST*) malloc (sizeof **Action);\r
+        if (*Action == NULL) {\r
+          fprintf (stdout, "  ERROR: malloc failed!\n");\r
+          return FALSE;\r
+        }\r
+        memset (*Action, 0, sizeof **Action);\r
+        (*Action)->CompressType = CurrentType;\r
+      }\r
+\r
+      //\r
+      // Assignment to InFileName and OutFileName in order\r
+      // \r
+      if ((*Action)->InFileName == NULL) {\r
+        (*Action)->InFileName  = *argv;\r
+      } else {\r
+        (*Action)->OutFileName = *argv;\r
+        Action                 = &(*Action)->NextAction;\r
+      }\r
+    }\r
+\r
+    --argc;\r
+    ++argv;\r
+\r
+  }\r
+  \r
+  if (*Action != NULL) {\r
+    assert ((*Action)->InFileName != NULL);\r
+    fprintf (stdout, "  ERROR: Compress OutFileName not specified with InFileName: %s!\n", (*Action)->InFileName);\r
+    return FALSE;\r
+  }\r
+\r
+  if (*ActionListHead == NULL) {\r
+    return FALSE;\r
+  }\r
+  return TRUE;\r
+}\r
+\r
+STATIC\r
+BOOLEAN\r
+ProcessFile (\r
+  CHAR8         *InFileName,\r
+  CHAR8         *OutFileName,\r
+  COMPRESS_TYPE CompressType\r
+  )\r
+{\r
+  EFI_STATUS          Status;\r
+  FILE                *InFileP;\r
+  FILE                *OutFileP;\r
+  UINT32              SrcSize;\r
+  UINT32              DstSize;\r
+  UINT8               *SrcBuffer;\r
+  UINT8               *DstBuffer;\r
+  COMPRESS_FUNCTION   CompressFunc;\r
+\r
+  SrcBuffer     =     DstBuffer = NULL;\r
+  InFileP       =     OutFileP  = NULL;\r
+\r
+  fprintf (stdout, "%s --> %s\n", InFileName, OutFileName);\r
+\r
+  if ((OutFileP = fopen (OutFileName, "wb")) == NULL) {\r
+    fprintf (stdout, "  ERROR: Can't open output file %s for write!\n", OutFileName);\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  if ((InFileP = fopen (InFileName, "rb")) == NULL) {\r
+    fprintf (stdout, "  ERROR: Can't open input file %s for read!\n", InFileName);\r
+    goto ErrorHandle;\r
+  }\r
+  \r
+  //\r
+  // Get the size of source file\r
+  //\r
+  fseek (InFileP, 0, SEEK_END);\r
+  SrcSize = ftell (InFileP);\r
+  rewind (InFileP);\r
+  //\r
+  // Read in the source data\r
+  //\r
+  if ((SrcBuffer = malloc (SrcSize)) == NULL) {\r
+    fprintf (stdout, "  ERROR: Can't allocate memory!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  if (fread (SrcBuffer, 1, SrcSize, InFileP) != SrcSize) {\r
+    fprintf (stdout, "  ERROR: Can't read from source!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  //\r
+  // Choose the right compress algorithm\r
+  //\r
+  CompressFunc = (CompressType == EFI_COMPRESS) ? EfiCompress : TianoCompress;\r
+\r
+  //\r
+  // Get destination data size and do the compression\r
+  //\r
+  DstSize = 0;\r
+  Status = CompressFunc (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
+  if (Status != EFI_BUFFER_TOO_SMALL) {\r
+    fprintf (stdout, "  Error: Compress failed: %x!\n", Status);\r
+    goto ErrorHandle;\r
+  }\r
+  if ((DstBuffer = malloc (DstSize)) == NULL) {\r
+    fprintf (stdout, "  ERROR: Can't allocate memory!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  Status = CompressFunc (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
+  if (EFI_ERROR (Status)) {\r
+    fprintf (stdout, "  ERROR: Compress Error!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  fprintf (stdout, "  Orig Size = %ld\tComp Size = %ld\n", SrcSize, DstSize);\r
+\r
+  if (DstBuffer == NULL) {\r
+    fprintf (stdout, "  ERROR: No destination to write to!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  //\r
+  // Write out the result\r
+  //\r
+  if (fwrite (DstBuffer, 1, DstSize, OutFileP) != DstSize) {\r
+    fprintf (stdout, "  ERROR: Can't write to destination file!\n");\r
+    goto ErrorHandle;\r
+  }\r
+\r
+  return TRUE;\r
+\r
+ErrorHandle:\r
+  if (SrcBuffer) {\r
+    free (SrcBuffer);\r
+  }\r
+\r
+  if (DstBuffer) {\r
+    free (DstBuffer);\r
+  }\r
+\r
+  if (InFileP) {\r
+    fclose (InFileP);\r
+  }\r
+\r
+  if (OutFileP) {\r
+    fclose (OutFileP);\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+VOID\r
+Usage (\r
+  CHAR8 *ExeName\r
+  )\r
+{\r
+  fprintf (\r
+      stdout, \r
+      "\n"\r
+      "Usage: %s [-tCompressType] InFileName OutFileName\n"\r
+      "       %*c [[-tCompressType] InFileName OutFileName ...]\n"\r
+      "\n"\r
+      "where:\n"\r
+      "  CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n"\r
+      "                 If ommitted, compress type specified ahead is used, \n"\r
+      "                 default is EFI\n"\r
+      "                 e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n"\r
+      "                                     c.in c.out -tEFI d.in d.out\n"\r
+      "                 a.in and d.in are compressed using EFI compress algorithm\n"\r
+      "                 b.in and c.in are compressed using Tiano compress algorithm\n"\r
+      "  InFileName   - input file path\n"\r
+      "  OutFileName  - output file path\n",\r
+      ExeName, strlen(ExeName), ' '\r
+      );\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile
new file mode 100644 (file)
index 0000000..3f03428
--- /dev/null
@@ -0,0 +1,89 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#   \r
+#  Module Name:\r
+#\r
+#    makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=EfiCompress\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\EfiCompressMain.c"\r
+TARGET_EXE_INCLUDE = "$(COMMON_SOURCE)\Compress.h"\r
+TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_EXE_LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_EXE_LIBS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
new file mode 100644 (file)
index 0000000..06a8581
--- /dev/null
@@ -0,0 +1,1545 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  EfiRom.c\r
+  \r
+Abstract:\r
+\r
+  Utility program to create an EFI option ROM image from binary and \r
+  EFI PE32 files.\r
+\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+//\r
+// Includes for EFI 1.1 build\r
+//\r
+// #include "Tiano.h"        // required defines for Compress.h\r
+// #include "EfiImage.h"   // for PE32 structure definitions\r
+// #include "Compress.h"   // for compression function\r
+// Includes for Tiano build\r
+//\r
+#include "TianoCommon.h"\r
+#include "EfiImage.h" // for PE32 structure definitions\r
+#include "Compress.h"\r
+\r
+//\r
+// END include differences\r
+//\r
+#include "Pci22.h"  // for option ROM header structures\r
+//\r
+// Version of this utility\r
+//\r
+#define UTILITY_VERSION "v2.5"\r
+\r
+//\r
+// Define some status return values\r
+//\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+\r
+//\r
+// Define the max length of a filename\r
+//\r
+#define MAX_PATH                  200\r
+\r
+#define DEFAULT_OUTPUT_EXTENSION  ".rom"\r
+\r
+//\r
+// Max size for an option ROM image\r
+//\r
+#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16)  // 16MB\r
+//\r
+// Values for the indicator field in the PCI data structure\r
+//\r
+#define INDICATOR_LAST  0x80  // last file in series of files\r
+//\r
+// Masks for the FILE_LIST.FileFlags field\r
+//\r
+#define FILE_FLAG_BINARY    0x01\r
+#define FILE_FLAG_EFI       0x02\r
+#define FILE_FLAG_COMPRESS  0x04\r
+\r
+//\r
+// Use this linked list structure to keep track of all the filenames\r
+// specified on the command line.\r
+//\r
+typedef struct _FILE_LIST {\r
+  struct _FILE_LIST *Next;\r
+  INT8              *FileName;\r
+  UINT32            FileFlags;\r
+  UINT32            ClassCode;\r
+  UINT16            CodeRevision;\r
+} FILE_LIST;\r
+\r
+//\r
+// Use this to track our command-line options\r
+//\r
+typedef struct {\r
+  INT8      OutFileName[MAX_PATH];\r
+  INT8      NoLast;\r
+  INT8      Verbose;\r
+  INT8      DumpOption;\r
+  UINT8     DevIdValid;\r
+  UINT8     VendIdValid;\r
+  UINT16    VendId;\r
+  UINT16    DevId;\r
+  FILE_LIST *FileList;\r
+} OPTIONS;\r
+\r
+//\r
+// Make a global structure to keep track of command-line options\r
+//\r
+static OPTIONS  mOptions;\r
+\r
+//\r
+// Use these to convert from machine type value to a named type\r
+//\r
+typedef struct {\r
+  UINT16  Value;\r
+  char    *Name;\r
+} STRING_LOOKUP;\r
+\r
+static STRING_LOOKUP  mMachineTypes[] = {\r
+  EFI_IMAGE_MACHINE_IA32,\r
+  "IA32",\r
+  EFI_IMAGE_MACHINE_IA64,\r
+  "IA64",\r
+  EFI_IMAGE_MACHINE_EBC,\r
+  "EBC",\r
+  0,\r
+  NULL\r
+};\r
+\r
+static STRING_LOOKUP  mSubsystemTypes[] = {\r
+  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
+  "EFI application",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
+  "EFI boot service driver",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
+  "EFI runtime driver",\r
+  0,\r
+  NULL\r
+};\r
+//\r
+//  Function prototypes\r
+//\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int       Argc,\r
+  char      *Argv[],\r
+  OPTIONS   *Options\r
+  );\r
+\r
+static\r
+int\r
+CheckPE32File (\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  );\r
+\r
+static\r
+int\r
+ProcessEfiFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT16    VendId,\r
+  UINT16    DevId,\r
+  UINT32    *Size\r
+  );\r
+\r
+static\r
+int\r
+ProcessBinFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT32    *Size\r
+  );\r
+\r
+static\r
+void\r
+DumpImage (\r
+  FILE_LIST *InFile\r
+  );\r
+\r
+char                  *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  );\r
+\r
+static\r
+char                  *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given an EFI image filename, create a ROM-able image by creating an option \r
+  ROM header and PCI data structure, filling them in, and then writing the\r
+  option ROM header + PCI data structure + EFI image out to the output file.\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  INT8      *Ext;\r
+  FILE      *FptrOut;\r
+  UINT32    Status;\r
+  FILE_LIST *FList;\r
+  UINT32    TotalSize;\r
+  UINT32    Size;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  FptrOut = NULL;\r
+\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  if (ParseCommandLine (Argc, Argv, &mOptions)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If dumping an image, then do that and quit\r
+  //\r
+  if (mOptions.DumpOption) {\r
+    DumpImage (mOptions.FileList);\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Determine the output filename. Either what they specified on\r
+  // the command line, or the first input filename with a different extension.\r
+  //\r
+  if (!mOptions.OutFileName[0]) {\r
+    strcpy (mOptions.OutFileName, mOptions.FileList->FileName);\r
+    //\r
+    // Find the last . on the line and replace the filename extension with\r
+    // the default\r
+    //\r
+    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
+         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
+         Ext--\r
+        )\r
+      ;\r
+    //\r
+    // If dot here, then insert extension here, otherwise append\r
+    //\r
+    if (*Ext != '.') {\r
+      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
+    }\r
+\r
+    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
+  }\r
+  //\r
+  // Make sure we don't have the same filename for input and output files\r
+  //\r
+  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
+    if (_stricmp (mOptions.OutFileName, FList->FileName) == 0) {\r
+      Status = STATUS_ERROR;\r
+      fprintf (\r
+        stdout,\r
+        "ERROR: Input and output file names must be different - %s = %s\n",\r
+        FList->FileName,\r
+        mOptions.OutFileName\r
+        );\r
+      goto BailOut;\r
+    }\r
+  }\r
+  //\r
+  // Now open our output file\r
+  //\r
+  if ((FptrOut = fopen (mOptions.OutFileName, "w+b")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open output file %s\n", mOptions.OutFileName);\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Process all our files\r
+  //\r
+  TotalSize = 0;\r
+  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
+    Size = 0;\r
+    if (FList->FileFlags & FILE_FLAG_EFI) {\r
+      if (mOptions.Verbose) {\r
+        fprintf (stdout, "Processing EFI file    %s\n", FList->FileName);\r
+      }\r
+\r
+      Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size);\r
+    } else if (FList->FileFlags & FILE_FLAG_BINARY) {\r
+      if (mOptions.Verbose) {\r
+        fprintf (stdout, "Processing binary file %s\n", FList->FileName);\r
+      }\r
+\r
+      Status = ProcessBinFile (FptrOut, FList, &Size);\r
+    } else {\r
+      fprintf (stdout, "ERROR: File not specified as EFI or binary: %s\n", FList->FileName);\r
+      Status = STATUS_ERROR;\r
+    }\r
+\r
+    if (mOptions.Verbose) {\r
+      fprintf (stdout, "  Output size = 0x%X\n", Size);\r
+    }\r
+\r
+    if (Status != STATUS_SUCCESS) {\r
+      break;\r
+    }\r
+\r
+    TotalSize += Size;\r
+  }\r
+  //\r
+  // Check total size\r
+  //\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image size exceeds limit 0x%X bytes\n",\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+  }\r
+\r
+BailOut:\r
+  if (FptrOut != NULL) {\r
+    fclose (FptrOut);\r
+  }\r
+  //\r
+  // Clean up our file list\r
+  //\r
+  while (mOptions.FileList != NULL) {\r
+    FList = mOptions.FileList->Next;\r
+    free (mOptions.FileList);\r
+    mOptions.FileList = FList;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ProcessBinFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT32    *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a binary input file.\r
+\r
+Arguments:\r
+\r
+  OutFptr     - file pointer to output binary ROM image file we're creating\r
+  InFile      - structure contains information on the binary file to process\r
+  Size        - pointer to where to return the size added to the output file\r
+\r
+Returns:\r
+\r
+  0 - successful\r
+\r
+--*/\r
+{\r
+  FILE                      *InFptr;\r
+  UINT32                    TotalSize;\r
+  UINT32                    FileSize;\r
+  UINT8                     *Buffer;\r
+  UINT32                    Status;\r
+  PCI_EXPANSION_ROM_HEADER  *RomHdr;\r
+  PCI_DATA_STRUCTURE        *PciDs;\r
+  UINT32                    Index;\r
+  UINT8                     ByteCheckSum;\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Seek to the end of the input file and get the file size. Then allocate\r
+  // a buffer to read it in to.\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
+  }\r
+\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  Buffer = (INT8 *) malloc (FileSize);\r
+  if (Buffer == NULL) {\r
+    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Total size must be an even multiple of 512 bytes, and can't exceed\r
+  // the option ROM image size.\r
+  //\r
+  TotalSize = FileSize;\r
+  if (TotalSize & 0x1FF) {\r
+    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
+  }\r
+\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
+      InFile->FileName,\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Return the size to the caller so they can keep track of the running total.\r
+  //\r
+  *Size = TotalSize;\r
+\r
+  //\r
+  // Crude check to make sure it's a legitimate ROM image\r
+  //\r
+  RomHdr = (PCI_EXPANSION_ROM_HEADER *) Buffer;\r
+  if (RomHdr->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: ROM image file has invalid ROM signature\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Make sure the pointer to the PCI data structure is within the size of the image.\r
+  // Then check it for valid signature.\r
+  //\r
+  if ((RomHdr->PcirOffset > FileSize) || (RomHdr->PcirOffset == 0)) {\r
+    fprintf (stdout, "ERROR: Invalid PCI data structure offset\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  PciDs = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);\r
+  if (PciDs->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: PCI data structure has invalid signature\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // If this is the last image, then set the LAST bit unless requested not\r
+  // to via the command-line -l argument. Otherwise, make sure you clear it.\r
+  //\r
+  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
+    PciDs->Indicator = INDICATOR_LAST;\r
+  } else {\r
+    PciDs->Indicator = 0;\r
+  }\r
+\r
+  ByteCheckSum = 0;\r
+  for (Index = 0; Index < FileSize - 1; Index++) {\r
+    ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);\r
+  }\r
+\r
+  Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);\r
+  fprintf (stdout, "CheckSUm = %02x\n", (UINT32) Buffer[FileSize - 1]);\r
+\r
+  //\r
+  // Now copy the input file contents out to the output file\r
+  //\r
+  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  TotalSize -= FileSize;\r
+  //\r
+  // Pad the rest of the image to make it a multiple of 512 bytes\r
+  //\r
+  while (TotalSize > 0) {\r
+    putc (~0, OutFptr);\r
+    TotalSize--;\r
+  }\r
+\r
+BailOut:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+  //\r
+  // Print the file name if errors occurred\r
+  //\r
+  if (Status != STATUS_SUCCESS) {\r
+    fprintf (stdout, "Error processing binary file %s\n", InFile->FileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ProcessEfiFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT16    VendId,\r
+  UINT16    DevId,\r
+  UINT32    *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a PE32 EFI file.\r
+\r
+Arguments:\r
+\r
+  OutFptr     - file pointer to output binary ROM image file we're creating\r
+  InFile      - structure contains information on the PE32 file to process\r
+  VendId      - vendor ID as required in the option ROM header\r
+  DevId       - device ID as required in the option ROM header\r
+  Size        - pointer to where to return the size added to the output file\r
+\r
+Returns:\r
+\r
+  0 - successful\r
+\r
+--*/\r
+{\r
+  UINT32                        Status;\r
+  FILE                          *InFptr;\r
+  EFI_PCI_EXPANSION_ROM_HEADER  RomHdr;\r
+  PCI_DATA_STRUCTURE            PciDs;\r
+  UINT32                        FileSize;\r
+  UINT32                        CompressedFileSize;\r
+  UINT8                         *Buffer;\r
+  UINT8                         *CompressedBuffer;\r
+  UINT8                         *TempBufferPtr;\r
+  UINT32                        TotalSize;\r
+  UINT32                        HeaderSize;\r
+  UINT16                        MachineType;\r
+  UINT16                        SubSystem;\r
+  UINT32                        HeaderPadBytes;\r
+\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Initialize our buffer pointers to null.\r
+  //\r
+  Buffer            = NULL;\r
+  CompressedBuffer  = NULL;\r
+\r
+  //\r
+  // Double-check the file to make sure it's what we expect it to be\r
+  //\r
+  Status = CheckPE32File (InFptr, &MachineType, &SubSystem);\r
+  if (Status != STATUS_SUCCESS) {\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Seek to the end of the input file and get the file size\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+\r
+  //\r
+  // Get the size of the headers we're going to put in front of the image. The\r
+  // EFI header must be aligned on a 4-byte boundary, so pad accordingly.\r
+  //\r
+  if (sizeof (RomHdr) & 0x03) {\r
+    HeaderPadBytes = 4 - (sizeof (RomHdr) & 0x03);\r
+  } else {\r
+    HeaderPadBytes = 0;\r
+  }\r
+\r
+  HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
+  }\r
+  //\r
+  // Allocate memory for the entire file (in case we have to compress), then\r
+  // seek back to the beginning of the file and read it into our buffer.\r
+  //\r
+  Buffer = (INT8 *) malloc (FileSize);\r
+  if (Buffer == NULL) {\r
+    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Now determine the size of the final output file. It's either the header size\r
+  // plus the file's size, or the header size plus the compressed file size.\r
+  //\r
+  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
+    //\r
+    // Allocate a buffer into which we can compress the image, compress it,\r
+    // and use that size as the new size.\r
+    //\r
+    CompressedBuffer = (INT8 *) malloc (FileSize);\r
+    if (CompressedBuffer == NULL) {\r
+      fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    CompressedFileSize  = FileSize;\r
+    Status              = EfiCompress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize);\r
+    if (Status != STATUS_SUCCESS) {\r
+      fprintf (stdout, "ERROR: Compression failed\n");\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Now compute the size, then swap buffer pointers.\r
+    //\r
+    if (mOptions.Verbose) {\r
+      fprintf (stdout, "  Comp size   = 0x%X\n", CompressedFileSize);\r
+    }\r
+\r
+    TotalSize         = CompressedFileSize + HeaderSize;\r
+    FileSize          = CompressedFileSize;\r
+    TempBufferPtr     = Buffer;\r
+    Buffer            = CompressedBuffer;\r
+    CompressedBuffer  = TempBufferPtr;\r
+  } else {\r
+    TotalSize = FileSize + HeaderSize;\r
+  }\r
+  //\r
+  // Total size must be an even multiple of 512 bytes\r
+  //\r
+  if (TotalSize & 0x1FF) {\r
+    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
+  }\r
+  //\r
+  // Check size\r
+  //\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
+      InFile->FileName,\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Return the size to the caller so they can keep track of the running total.\r
+  //\r
+  *Size = TotalSize;\r
+\r
+  //\r
+  // Now fill in the ROM header. These values come from chapter 18 of the\r
+  // EFI 1.02 specification.\r
+  //\r
+  memset (&RomHdr, 0, sizeof (RomHdr));\r
+  RomHdr.Signature            = PCI_EXPANSION_ROM_HEADER_SIGNATURE;\r
+  RomHdr.InitializationSize   = (UINT16) (TotalSize / 512);\r
+  RomHdr.EfiSignature         = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;\r
+  RomHdr.EfiSubsystem         = SubSystem;\r
+  RomHdr.EfiMachineType       = MachineType;\r
+  RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize;\r
+  RomHdr.PcirOffset           = (UINT16) (sizeof (RomHdr) + HeaderPadBytes);\r
+  //\r
+  // Set image as compressed or not\r
+  //\r
+  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
+    RomHdr.CompressionType = EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED;\r
+  }\r
+  //\r
+  // Fill in the PCI data structure\r
+  //\r
+  memset (&PciDs, 0, sizeof (PCI_DATA_STRUCTURE));\r
+\r
+  PciDs.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
+  PciDs.VendorId  = VendId;\r
+  PciDs.DeviceId  = DevId;\r
+  PciDs.Length    = (UINT16) sizeof (PCI_DATA_STRUCTURE);\r
+  PciDs.Revision  = 0;\r
+  //\r
+  // Class code and code revision from the command line (optional)\r
+  //\r
+  PciDs.ClassCode[0]  = (UINT8) InFile->ClassCode;\r
+  PciDs.ClassCode[1]  = (UINT8) (InFile->ClassCode >> 8);\r
+  PciDs.ClassCode[2]  = (UINT8) (InFile->ClassCode >> 16);\r
+  PciDs.ImageLength   = RomHdr.InitializationSize;\r
+  PciDs.CodeRevision  = InFile->CodeRevision;\r
+  PciDs.CodeType      = PCI_CODE_TYPE_EFI_IMAGE;\r
+\r
+  //\r
+  // If this is the last image, then set the LAST bit unless requested not\r
+  // to via the command-line -l argument.\r
+  //\r
+  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
+    PciDs.Indicator = INDICATOR_LAST;\r
+  }\r
+  //\r
+  // Write the ROM header to the output file\r
+  //\r
+  if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write ROM header to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  //\r
+  // Write pad bytes to align the PciDs\r
+  //\r
+  while (HeaderPadBytes > 0) {\r
+    if (putc (0, OutFptr) == EOF) {\r
+      fprintf (stdout, "ERROR: Failed to write ROM header pad bytes to output file\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    HeaderPadBytes--;\r
+  }\r
+  //\r
+  // Write the PCI data structure header to the output file\r
+  //\r
+  if (fwrite (&PciDs, sizeof (PciDs), 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write PCI ROM header to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Keep track of how many bytes left to write\r
+  //\r
+  TotalSize -= HeaderSize;\r
+\r
+  //\r
+  // Now dump the input file's contents to the output file\r
+  //\r
+  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  TotalSize -= FileSize;\r
+  //\r
+  // Pad the rest of the image to make it a multiple of 512 bytes\r
+  //\r
+  while (TotalSize > 0) {\r
+    if (putc (~0, OutFptr) == EOF) {\r
+      fprintf (stdout, "ERROR: Failed to write trailing pad bytes output file\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    TotalSize--;\r
+  }\r
+\r
+BailOut:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  //\r
+  // Free up our buffers\r
+  //\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (CompressedBuffer != NULL) {\r
+    free (CompressedBuffer);\r
+  }\r
+  //\r
+  // Print the file name if errors occurred\r
+  //\r
+  if (Status != STATUS_SUCCESS) {\r
+    fprintf (stdout, "Error processing EFI file %s\n", InFile->FileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+CheckPE32File (\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Fptr        - GC_TODO: add argument description\r
+  MachineType - GC_TODO: add argument description\r
+  SubSystem   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  /*++\r
+\r
+Routine Description:\r
+  \r
+  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
+  PE32 image file, and then return the machine type in the supplied pointer.\r
+\r
+Arguments:\r
+\r
+  Fptr          File pointer to the already-opened PE32 file\r
+  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
+                because the image may be Itanium-based, IA32, or EBC.\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+  EFI_IMAGE_DOS_HEADER      DosHeader;\r
+  EFI_IMAGE_FILE_HEADER     FileHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
+  UINT32                    PESig;\r
+\r
+  //\r
+  // Position to the start of the file\r
+  //\r
+  fseek (Fptr, 0, SEEK_SET);\r
+\r
+  //\r
+  // Read the DOS header\r
+  //\r
+  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read the DOS stub from the input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Check the magic number (0x5A4D)\r
+  //\r
+  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (magic number)\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Position into the file and check the PE signature\r
+  //\r
+  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
+  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read PE signature bytes from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Check the PE signature in the header "PE\0\0"\r
+  //\r
+  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (signature)\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read the file header and stuff their MachineType\r
+  //\r
+  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read PE file header from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memcpy ((char *) MachineType, &FileHdr.Machine, 2);\r
+\r
+  //\r
+  // Read the optional header so we can get the subsystem\r
+  //\r
+  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read COFF optional header from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  *SubSystem = OptionalHdr.Subsystem;\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
+  }\r
+  //\r
+  // Good to go\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int         Argc,\r
+  char        *Argv[],\r
+  OPTIONS     *Options\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
+  parse the command-line options and check their validity.\r
+\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+  Argv[]          - standard C main() argument list\r
+  Options         - pointer to a structure to store the options in\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    success\r
+  non-zero          otherwise\r
+\r
+--*/\r
+//\r
+{\r
+  FILE_LIST *FileList;\r
+\r
+  FILE_LIST *PrevFileList;\r
+  UINT32    FileFlags;\r
+  UINT32    ClassCode;\r
+  UINT32    CodeRevision;\r
+\r
+  FileFlags = 0;\r
+\r
+  //\r
+  // Clear out the options\r
+  //\r
+  memset ((char *) Options, 0, sizeof (OPTIONS));\r
+\r
+  //\r
+  // To avoid compile warnings\r
+  //\r
+  FileList                = PrevFileList = NULL;\r
+\r
+  ClassCode               = 0;\r
+  CodeRevision            = 0;\r
+  //\r
+  // Skip over the program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  //\r
+  // If no arguments, assume they want usage info\r
+  //\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process until no more arguments\r
+  //\r
+  while (Argc > 0) {\r
+    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
+      //\r
+      // To simplify string comparisons, replace slashes with dashes\r
+      //\r
+      Argv[0][0] = '-';\r
+\r
+      //\r
+      // Vendor ID specified with -v\r
+      //\r
+      if (_stricmp (Argv[0], "-v") == 0) {\r
+        //\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          Options->VendId       = (UINT16) strtol (Argv[1], NULL, 16);\r
+          Options->VendIdValid  = 1;\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing Vendor ID with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (_stricmp (Argv[0], "-d") == 0) {\r
+        //\r
+        // Device ID specified with -d\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          Options->DevId      = (UINT16) strtol (Argv[1], NULL, 16);\r
+          Options->DevIdValid = 1;\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing Device ID with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (_stricmp (Argv[0], "-o") == 0) {\r
+        //\r
+        // Output filename specified with -o\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          strcpy (Options->OutFileName, Argv[1]);\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing output file name with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+        //\r
+        // Help option\r
+        //\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      } else if (_stricmp (Argv[0], "-b") == 0) {\r
+        //\r
+        // Specify binary files with -b\r
+        //\r
+        FileFlags = (FileFlags &~FILE_FLAG_EFI) | FILE_FLAG_BINARY;\r
+      } else if ((_stricmp (Argv[0], "-e") == 0) || (_stricmp (Argv[0], "-ec") == 0)) {\r
+        //\r
+        // Specify EFI files with -e. Specify EFI-compressed with -ec.\r
+        //\r
+        FileFlags = (FileFlags &~FILE_FLAG_BINARY) | FILE_FLAG_EFI;\r
+        if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) {\r
+          FileFlags |= FILE_FLAG_COMPRESS;\r
+        }\r
+        //\r
+        // Specify not to set the LAST bit in the last file with -l\r
+        //\r
+      } else if (_stricmp (Argv[0], "-l") == 0) {\r
+        Options->NoLast = 1;\r
+      } else if (_stricmp (Argv[0], "-p") == 0) {\r
+        //\r
+        // -v for verbose would have been nicer, but it's already used. Let's use\r
+        // -p for prolix (wordy) output\r
+        //\r
+        Options->Verbose = 1;\r
+      } else if (_stricmp (Argv[0], "-dump") == 0) {\r
+        //\r
+        // -dump for dumping a ROM image. In this case, say that the device id\r
+        // and vendor id are valid so we don't have to specify bogus ones on the\r
+        // command line.\r
+        //\r
+        Options->DumpOption   = 1;\r
+\r
+        Options->VendIdValid  = 1;\r
+        Options->DevIdValid   = 1;\r
+        FileFlags             = FILE_FLAG_BINARY;\r
+      } else if (_stricmp (Argv[0], "-cc") == 0) {\r
+        //\r
+        // Class code value for the next file in the list.\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          //\r
+          // No error checking on the return value. Could check for LONG_MAX,\r
+          // LONG_MIN, or 0 class code value if desired. Check range (3 bytes)\r
+          // at least.\r
+          //\r
+          ClassCode = (UINT32) strtol (Argv[1], NULL, 16);\r
+          if (ClassCode & 0xFF000000) {\r
+            fprintf (stdout, "ERROR: Class code %s out of range\n", Argv[1]);\r
+            return STATUS_ERROR;\r
+          }\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing class code value with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (_stricmp (Argv[0], "-rev") == 0) {\r
+        //\r
+        // Code revision in the PCI data structure. The value is for the next\r
+        // file in the list.\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          //\r
+          // No error checking on the return value. Could check for LONG_MAX,\r
+          // LONG_MIN, or 0 value if desired. Check range (2 bytes)\r
+          // at least.\r
+          //\r
+          CodeRevision = (UINT32) strtol (Argv[1], NULL, 16);\r
+          if (CodeRevision & 0xFFFF0000) {\r
+            fprintf (stdout, "ERROR: Code revision %s out of range\n", Argv[1]);\r
+            return STATUS_ERROR;\r
+          }\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing code revision value with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else {\r
+        fprintf (stdout, "ERROR: Invalid option specified: %s\n\n", Argv[0]);\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+    } else {\r
+      //\r
+      // Not a slash-option argument. Must be a file name. Make sure they've specified\r
+      // -e or -b already.\r
+      //\r
+      if ((FileFlags & (FILE_FLAG_BINARY | FILE_FLAG_EFI)) == 0) {\r
+        fprintf (stdout, "ERROR: Missing -e or -b with input file %s\n", Argv[0]);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Create a new file structure\r
+      //\r
+      FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
+      if (FileList == NULL) {\r
+        fprintf (stdout, "ERROR: Memory allocation failure\n");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) FileList, 0, sizeof (FILE_LIST));\r
+      FileList->FileName  = Argv[0];\r
+      FileList->FileFlags = FileFlags;\r
+      if (Options->FileList == NULL) {\r
+        Options->FileList = FileList;\r
+      } else {\r
+        if (PrevFileList == NULL) {\r
+          PrevFileList = FileList;\r
+        } else {          \r
+          PrevFileList->Next = FileList;\r
+        }\r
+      }\r
+\r
+      PrevFileList = FileList;\r
+      //\r
+      // Set the class code and code revision for this file, then reset the values.\r
+      //\r
+      FileList->ClassCode     = ClassCode;\r
+      FileList->CodeRevision  = (UINT16) CodeRevision;\r
+      ClassCode               = 0;\r
+      CodeRevision            = 0;\r
+    }\r
+    //\r
+    // Next argument\r
+    //\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Make sure they specified a device ID and vendor ID\r
+  //\r
+  if (!Options->VendIdValid) {\r
+    fprintf (stdout, "ERROR: Missing Vendor ID on command line\n\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (!Options->DevIdValid) {\r
+    fprintf (stdout, "ERROR: Missing Device ID on command line\n\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Must have specified some files\r
+  //\r
+  if (Options->FileList == NULL) {\r
+    fprintf (stdout, "ERROR: Missing input file name\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Print usage information for this utility.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Msg[] = {\r
+    "EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility",\r
+    "  Copyright (C), 1999 - 2002 Intel Coproration\n",\r
+    "  Create an option ROM image from a list of input files",\r
+    "  Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",\r
+    "                [-e|-b] [FileName(s)]",\r
+    "    where:",\r
+    "      VendorId       - required hex PCI Vendor ID for the device",\r
+    "      DeviceId       - required hex PCI Device ID for the device",\r
+    "      OutFileName    - optional output file name. Default is the first input",\r
+    "                       file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",\r
+    "      FileNames      - input PE32 or binary file name(s)",\r
+    "      BinFileName    - input binary file name(s)",\r
+    "      -p             - for verbose output",\r
+    "      -l             - to not automatically set the LAST bit on the last file",\r
+    "      -b             - following FileNames are binary files",\r
+    "      -e             - following FileNames are EFI PE32 image files",\r
+    "      -ec            - following FileNames are EFI PE32 image files, and should",\r
+    "                       be compressed by this utility",\r
+    "      -cc ClassCode  - to use hex ClassCode in the PCI data structure header for",\r
+    "                       the following FileName",\r
+    "      -rev Revision  - to use hex Revision in the PCI data structure header for",\r
+    "                       the following FileName",\r
+    "      -dump          - to dump the headers of an existing option ROM image",\r
+    "",\r
+    "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi ",\r
+    "",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Msg[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Msg[Index]);\r
+  }\r
+}\r
+\r
+static\r
+void\r
+DumpImage (\r
+  FILE_LIST *InFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  InFile  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  PCI_EXPANSION_ROM_HEADER      PciRomHdr;\r
+  FILE                          *InFptr;\r
+  UINT32                        ImageStart;\r
+  UINT32                        ImageCount;\r
+  EFI_PCI_EXPANSION_ROM_HEADER  EfiRomHdr;\r
+  PCI_DATA_STRUCTURE            PciDs;\r
+\r
+  //\r
+  // Open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Could not open input file %s\n",\r
+      InFile->FileName\r
+      );\r
+    return ;\r
+  }\r
+  //\r
+  // Go through the image and dump the header stuff for each\r
+  //\r
+  ImageCount = 0;\r
+  for (;;) {\r
+    //\r
+    // Save our postition in the file, since offsets in the headers\r
+    // are relative to the particular image.\r
+    //\r
+    ImageStart = ftell (InFptr);\r
+    ImageCount++;\r
+\r
+    //\r
+    // Read the option ROM header. Have to assume a raw binary image for now.\r
+    //\r
+    if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) {\r
+      fprintf (stdout, "ERROR: Failed to read PCI ROM header from file\n");\r
+      goto BailOut;\r
+    }\r
+\r
+    //\r
+    // Dump the contents of the header\r
+    //\r
+    fprintf (stdout, "Image %d -- Offset 0x%X\n", ImageCount, ImageStart);\r
+    fprintf (stdout, "  ROM header contents\n");\r
+    fprintf (stdout, "    Signature              0x%04X\n", (UINT32) PciRomHdr.Signature);\r
+    fprintf (stdout, "    PCIR offset            0x%04X\n", (UINT32) PciRomHdr.PcirOffset);\r
+    //\r
+    // Find PCI data structure\r
+    //\r
+    if (fseek (InFptr, ImageStart + PciRomHdr.PcirOffset, SEEK_SET)) {\r
+      fprintf (stdout, "ERROR: Failed to seek to PCI data structure\n");\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Read and dump the PCI data structure\r
+    //\r
+    if (fread (&PciDs, sizeof (PciDs), 1, InFptr) != 1) {\r
+      fprintf (stdout, "ERROR: Failed to read PCI data structure from file\n");\r
+      goto BailOut;\r
+    }\r
+\r
+    fprintf (stdout, "  PCI Data Structure\n");\r
+    fprintf (\r
+      stdout,\r
+      "    Signature              %c%c%c%c\n",\r
+      (char) PciDs.Signature,\r
+      (char) (PciDs.Signature >> 8),\r
+      (char) (PciDs.Signature >> 16),\r
+      (char) (PciDs.Signature >> 24)\r
+      );\r
+    fprintf (stdout, "    Vendor ID              0x%04X\n", PciDs.VendorId);\r
+    fprintf (stdout, "    Device ID              0x%04X\n", PciDs.DeviceId);\r
+    fprintf (\r
+      stdout,\r
+      "    Class Code             0x%06X\n",\r
+      (UINT32) (PciDs.ClassCode[0] | (PciDs.ClassCode[1] << 8) | (PciDs.ClassCode[2] << 16))\r
+      );\r
+    fprintf (stdout, "    Image size             0x%X\n", PciDs.ImageLength * 512);\r
+    fprintf (stdout, "    Code revision:         0x%04X\n", PciDs.CodeRevision);\r
+    fprintf (stdout, "    Indicator              0x%02X", (UINT32) PciDs.Indicator);\r
+    //\r
+    // Print the indicator, used to flag the last image\r
+    //\r
+    if (PciDs.Indicator == INDICATOR_LAST) {\r
+      fprintf (stdout, "   (last image)\n");\r
+    } else {\r
+      fprintf (stdout, "\n");\r
+    }\r
+    //\r
+    // Print the code type. If EFI code, then we can provide more info.\r
+    //\r
+    fprintf (stdout, "    Code type              0x%02X", (UINT32) PciDs.CodeType);\r
+    if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
+      fprintf (stdout, "   (EFI image)\n");\r
+      //\r
+      // Re-read the header as an EFI ROM header, then dump more info\r
+      //\r
+      fprintf (stdout, "  EFI ROM header contents\n");\r
+      if (fseek (InFptr, ImageStart, SEEK_SET)) {\r
+        fprintf (stdout, "ERROR: Failed to re-seek to ROM header structure\n");\r
+        goto BailOut;\r
+      }\r
+\r
+      if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) {\r
+        fprintf (stdout, "ERROR: Failed to read EFI PCI ROM header from file\n");\r
+        goto BailOut;\r
+      }\r
+      //\r
+      // Now dump more info\r
+      //\r
+      fprintf (stdout, "    EFI Signature          0x%04X\n", EfiRomHdr.EfiSignature);\r
+      fprintf (\r
+        stdout,\r
+        "    Compression Type       0x%04X ",\r
+        (UINT32) EfiRomHdr.CompressionType\r
+        );\r
+      if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
+        fprintf (stdout, "(compressed)\n");\r
+      } else {\r
+        fprintf (stdout, "(not compressed)\n");\r
+      }\r
+\r
+      fprintf (\r
+        stdout,\r
+        "    Machine type           0x%04X (%s)\n",\r
+        EfiRomHdr.EfiMachineType,\r
+        GetMachineTypeStr (EfiRomHdr.EfiMachineType)\r
+        );\r
+      fprintf (\r
+        stdout,\r
+        "    Subsystem              0x%04X (%s)\n",\r
+        EfiRomHdr.EfiSubsystem,\r
+        GetSubsystemTypeStr (EfiRomHdr.EfiSubsystem)\r
+        );\r
+      fprintf (\r
+        stdout,\r
+        "    EFI image offset       0x%04X (@0x%X)\n",\r
+        (UINT32) EfiRomHdr.EfiImageHeaderOffset,\r
+        (UINT32) (EfiRomHdr.EfiImageHeaderOffset + ImageStart)\r
+        );\r
+\r
+    } else {\r
+      //\r
+      // Not an EFI image\r
+      //\r
+      fprintf (stdout, "\n");\r
+    }\r
+    //\r
+    // If code type is EFI image, then dump it as well?\r
+    //\r
+    // if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
+    // }\r
+    //\r
+    // If last image, then we're done\r
+    //\r
+    if (PciDs.Indicator == INDICATOR_LAST) {\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Seek to the start of the next image\r
+    //\r
+    if (fseek (InFptr, ImageStart + (PciDs.ImageLength * 512), SEEK_SET)) {\r
+      fprintf (stdout, "ERROR: Failed to seek to next image\n");\r
+      goto BailOut;\r
+    }\r
+  }\r
+\r
+BailOut:\r
+  fclose (InFptr);\r
+}\r
+\r
+char *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  MachineType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {\r
+    if (mMachineTypes[Index].Value == MachineType) {\r
+      return mMachineTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
+\r
+static\r
+char *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SubsystemType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {\r
+    if (mSubsystemTypes[Index].Value == SubsystemType) {\r
+      return mSubsystemTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile
new file mode 100644 (file)
index 0000000..2832154
--- /dev/null
@@ -0,0 +1,85 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the EfiRom utility.\r
+#  \r
+#--*/\r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME       = EfiRom\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE        = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\EfiRom.obj \\r
+            $(EDK_TOOLS_OUTPUT)\EfiCompress.obj\r
+            \r
+#\r
+# Build the EXE by compiling the source files, then linking the resultant\r
+# object files together.\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\EfiRom.obj : $(TARGET_SOURCE_DIR)\EfiRom.c\r
+  $(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\EfiRom.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\EfiCompress.obj : $(EDK_TOOLS_SOURCE)\Common\EfiCompress.c\r
+  $(CC) $(C_FLAGS) $(EDK_TOOLS_SOURCE)\Common\EfiCompress.c /Fo$@\r
+  \r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile
new file mode 100644 (file)
index 0000000..1556801
--- /dev/null
@@ -0,0 +1,96 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the EfildrImage utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=EfildrImage\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\EfildrImage.c"\r
+TARGET_EXE_INCLUDE = \r
+\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c
new file mode 100644 (file)
index 0000000..c072dd7
--- /dev/null
@@ -0,0 +1,188 @@
+/*++\r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  efildrimage.c\r
+\r
+Abstract:\r
+\r
+  Creates and EFILDR image.\r
+  This tool combines several PE Image files together using following format denoted as EBNF:\r
+  FILE := EFILDR_HEADER\r
+          EFILDR_IMAGE +\r
+          <PeImageFileContent> +\r
+  The order of EFILDR_IMAGE is same as the order of placing PeImageFileContent.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include "Tiano.h"\r
+\r
+#define MAX_PE_IMAGES                  63\r
+#define FILE_TYPE_FIXED_LOADER         0\r
+#define FILE_TYPE_RELOCATABLE_PE_IMAGE 1\r
+\r
+typedef struct {\r
+  UINT32 CheckSum;\r
+  UINT32 Offset;\r
+  UINT32 Length;\r
+  UINT8  FileName[52];\r
+} EFILDR_IMAGE;\r
+\r
+typedef struct {          \r
+  UINT32       Signature;     \r
+  UINT32       HeaderCheckSum;\r
+  UINT32       FileLength;\r
+  UINT32       NumberOfImages;\r
+} EFILDR_HEADER;\r
+\r
+\r
+\r
+VOID\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  printf ("Usage: EfiLdrImage OutImage LoaderImage PeImage1 PeImage2 ... PeImageN");\r
+  exit (1);\r
+}\r
+\r
+ULONG\r
+FCopyFile (\r
+  FILE    *in,\r
+  FILE    *out\r
+  )\r
+/*++\r
+Routine Description:\r
+  Write all the content of input file to output file.\r
+\r
+Arguments:\r
+  in  - input file pointer\r
+  out - output file pointer\r
+\r
+Return:\r
+  ULONG : file size of input file\r
+--*/\r
+{\r
+  ULONG           filesize, offset, length;\r
+  UCHAR           Buffer[8*1024];\r
+\r
+  fseek (in, 0, SEEK_END);\r
+  filesize = ftell(in);\r
+\r
+  fseek (in, 0, SEEK_SET);\r
+\r
+  offset = 0;\r
+  while (offset < filesize)  {\r
+    length = sizeof(Buffer);\r
+    if (filesize-offset < length) {\r
+      length = filesize-offset;\r
+    }\r
+\r
+    fread (Buffer, length, 1, in);\r
+    fwrite (Buffer, length, 1, out);\r
+    offset += length;\r
+  }\r
+\r
+  return filesize;\r
+}\r
+\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+\r
+\r
+Returns:\r
+\r
+\r
+--*/\r
+{\r
+  ULONG         i;\r
+  ULONG         filesize;\r
+  FILE          *fpIn, *fpOut;\r
+  EFILDR_HEADER EfiLdrHeader;\r
+  EFILDR_IMAGE  EfiLdrImage[MAX_PE_IMAGES];\r
+\r
+  if (argc < 4) {\r
+    Usage();\r
+  }\r
+\r
+  //\r
+  // Open output file for write\r
+  //\r
+  fpOut = fopen(argv[1], "w+b");\r
+  if (!fpOut) {\r
+    printf ("efildrimage: Could not open output file %s\n", argv[1]);\r
+    exit(1);\r
+  }\r
+\r
+  memset (&EfiLdrHeader, 0, sizeof (EfiLdrHeader));\r
+  memset (&EfiLdrImage, 0, sizeof (EFILDR_IMAGE) * (argc - 2));\r
+\r
+  memcpy (&EfiLdrHeader.Signature, "EFIL", 4);\r
+  EfiLdrHeader.FileLength = sizeof(EFILDR_HEADER) + sizeof(EFILDR_IMAGE)*(argc-2);\r
+\r
+  //\r
+  // Skip the file header first\r
+  //\r
+  fseek (fpOut, EfiLdrHeader.FileLength, SEEK_SET);\r
+\r
+  //\r
+  // copy all the input files to the output file\r
+  //\r
+  for(i=2;i<(ULONG)argc;i++) {\r
+    //\r
+    // Copy the content of PeImage file to output file\r
+    //\r
+    fpIn = fopen (argv[i], "rb");\r
+    if (!fpIn) {\r
+      printf ("efildrimage: Could not open input file %s\n", argv[i-2]);\r
+      exit(1);\r
+    }\r
+    filesize = FCopyFile (fpIn, fpOut);\r
+    fclose(fpIn);\r
+\r
+    //\r
+    //  And in the same time update the EfiLdrHeader and EfiLdrImage array\r
+    //\r
+    EfiLdrImage[i-2].Offset = EfiLdrHeader.FileLength;\r
+    EfiLdrImage[i-2].Length = filesize;\r
+    strncpy (EfiLdrImage[i-2].FileName, argv[i], sizeof (EfiLdrImage[i-2].FileName) - 1);\r
+    EfiLdrHeader.FileLength += filesize;\r
+    EfiLdrHeader.NumberOfImages++;\r
+  }\r
+\r
+  //\r
+  // Write the image header to the output file finally\r
+  //\r
+  fseek (fpOut, 0, SEEK_SET);\r
+  fwrite (&EfiLdrHeader, sizeof(EFILDR_HEADER)        , 1, fpOut);\r
+  fwrite (&EfiLdrImage , sizeof(EFILDR_IMAGE)*(argc-2), 1, fpOut);\r
+\r
+  fclose (fpOut);\r
+  printf ("Created %s\n", argv[1]);\r
+  return 0;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile
new file mode 100644 (file)
index 0000000..216ac97
--- /dev/null
@@ -0,0 +1,86 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=FwImage\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\FwImage.c"\r
+TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \\r
+                     "$(EDK_SOURCE)\Foundation\Efi\Include\EfiImage.h"\r
+OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
new file mode 100644 (file)
index 0000000..8a9274d
--- /dev/null
@@ -0,0 +1,587 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  fwimage.c\r
+\r
+Abstract:\r
+\r
+  Converts a pe32/pe32+ image to an FW image type\r
+\r
+--*/\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <time.h>\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiImage.h"\r
+#include "EfiUtilityMsgs.c"\r
+\r
+#define UTILITY_NAME  "FwImage"\r
+\r
+typedef union {\r
+  IMAGE_NT_HEADERS32 PeHeader32;\r
+  IMAGE_NT_HEADERS64 PeHeader64;\r
+} PE_HEADER;\r
+\r
+VOID\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  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");\r
+  printf ("  -t: Add Time Stamp for output image\n");\r
+  printf ("  -e: Not clear ExceptionTable for output image\n");\r
+  printf ("  -r: Not strip zero pending of .reloc for output image\n");\r
+}\r
+\r
+static\r
+STATUS\r
+FReadFile (\r
+  FILE    *in,\r
+  VOID    **Buffer,\r
+  UINTN   *Length\r
+  )\r
+{\r
+  fseek (in, 0, SEEK_END);\r
+  *Length = ftell (in);\r
+  *Buffer = malloc (*Length);\r
+  fseek (in, 0, SEEK_SET);\r
+  fread (*Buffer, *Length, 1, in);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+FWriteFile (\r
+  FILE    *out,\r
+  VOID    *Buffer,\r
+  UINTN   Length\r
+  )\r
+{\r
+  fseek (out, 0, SEEK_SET);\r
+  fwrite (Buffer, Length, 1, out);\r
+  if ((ULONG) ftell (out) != Length) {\r
+    Error (NULL, 0, 0, "write error", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  free (Buffer);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+VOID\r
+ZeroExceptionTable (\r
+  IN UINT8                 *FileBuffer,\r
+  IN EFI_IMAGE_DOS_HEADER  *DosHdr,\r
+  IN PE_HEADER             *PeHdr\r
+  )\r
+{\r
+  UINT32                   PdataSize;\r
+  UINT32                   PdataOffset;\r
+  UINT32                   PdataRVASize;\r
+  UINT32                   PdataRVA;\r
+  UINT32                   SectionOffset;\r
+  UINT16                   SectionNumber;\r
+  UINT32                   SectionNameSize;\r
+  EFI_IMAGE_SECTION_HEADER *Section;\r
+\r
+  PdataSize     = 0;\r
+  PdataOffset   = 0;\r
+  PdataRVASize  = 0;\r
+  PdataRVA      = 0;\r
+  SectionOffset = 0;\r
+\r
+  //\r
+  // Search .pdata section\r
+  //\r
+  if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    if ((PeHdr->PeHeader32.OptionalHeader.NumberOfRvaAndSizes > IMAGE_DIRECTORY_ENTRY_EXCEPTION) &&\r
+        (PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress != 0) &&\r
+        (PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size != 0)) {\r
+\r
+      PdataRVA     = PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress;\r
+      PdataRVASize = PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size;\r
+\r
+      PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = 0;\r
+      PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = 0;\r
+\r
+      SectionOffset = sizeof(PeHdr->PeHeader32);\r
+    }\r
+  } else {\r
+    if ((PeHdr->PeHeader64.OptionalHeader.NumberOfRvaAndSizes > IMAGE_DIRECTORY_ENTRY_EXCEPTION) &&\r
+        (PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress != 0) &&\r
+        (PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size != 0)) {\r
+\r
+      PdataRVA     = PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress;\r
+      PdataRVASize = PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size;\r
+\r
+      PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = 0;\r
+      PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = 0;\r
+\r
+      SectionOffset = sizeof(PeHdr->PeHeader64);\r
+    }\r
+  }\r
+\r
+  if ((PdataRVASize != 0) && (PdataRVA != 0)) {\r
+\r
+    SectionNumber = PeHdr->PeHeader32.FileHeader.NumberOfSections;\r
+    SectionNameSize = sizeof(Section->Name);\r
+    while (SectionNumber > 0) {\r
+      Section = (EFI_IMAGE_SECTION_HEADER *) &FileBuffer[DosHdr->e_lfanew + SectionOffset];\r
+      if (strcmp (Section->Name, ".pdata") == 0) {\r
+        //\r
+        // Zero .pdata Section Header Name\r
+        //\r
+        memset (\r
+          FileBuffer + DosHdr->e_lfanew + SectionOffset,\r
+          0,\r
+          SectionNameSize);\r
+\r
+        //\r
+        // Zero .pdata Secton raw data\r
+        //\r
+        PdataOffset = Section->PointerToRawData;\r
+        PdataSize   = Section->SizeOfRawData;\r
+        memset (FileBuffer + PdataOffset, 0, PdataSize);\r
+        break;\r
+      }\r
+      SectionNumber--;\r
+      SectionOffset += sizeof(EFI_IMAGE_SECTION_HEADER);\r
+    }\r
+  }\r
+  \r
+  return ;\r
+}\r
+\r
+VOID\r
+StripZeroPendingReloc (\r
+  IN UINT8                 *FileBuffer,\r
+  IN OUT UINTN             *FileLength,\r
+  IN EFI_IMAGE_DOS_HEADER  *DosHdr,\r
+  IN PE_HEADER             *PeHdr\r
+  )\r
+{\r
+  EFI_IMAGE_OPTIONAL_HEADER32  *Optional32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64  *Optional64;\r
+  EFI_IMAGE_SECTION_HEADER     *SectionHeader;\r
+  UINTN                        AllignedRelocSize;\r
+  UINTN                        Index;\r
+\r
+  if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->PeHeader32.OptionalHeader;\r
+    if ((Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) &&\r
+        (Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)) {\r
+      SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->PeHeader32.FileHeader.SizeOfOptionalHeader);\r
+      for (Index = 0; Index < PeHdr->PeHeader32.FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
+        //\r
+        // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
+        //\r
+        if (strcmp (SectionHeader->Name, ".reloc") == 0) {\r
+          SectionHeader->Misc.VirtualSize = Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
+\r
+          AllignedRelocSize = (Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size +\r
+                               Optional32->FileAlignment - 1) & (~(Optional32->FileAlignment - 1));\r
+          //\r
+          // Check to see if there is zero padding at the end of the base relocations\r
+          //\r
+          if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
+            //\r
+            // Check to see if the base relocations are at the end of the file\r
+            //\r
+            if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional32->SizeOfImage) {\r
+              //\r
+              // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
+              //\r
+              Optional32->SizeOfImage           -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+              Optional32->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+              SectionHeader->SizeOfRawData       = AllignedRelocSize;\r
+              *FileLength                        = Optional32->SizeOfImage;\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+    Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->PeHeader64.OptionalHeader;\r
+    if ((Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) &&\r
+        (Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)) {\r
+      SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->PeHeader64.FileHeader.SizeOfOptionalHeader);\r
+      for (Index = 0; Index < PeHdr->PeHeader64.FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
+        //\r
+        // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
+        //\r
+        if (strcmp (SectionHeader->Name, ".reloc") == 0) {\r
+          SectionHeader->Misc.VirtualSize = Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
+\r
+          AllignedRelocSize = (Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size +\r
+                               Optional64->FileAlignment - 1) & (~(Optional64->FileAlignment - 1));\r
+          //\r
+          // Check to see if there is zero padding at the end of the base relocations\r
+          //\r
+          if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
+            //\r
+            // Check to see if the base relocations are at the end of the file\r
+            //\r
+            if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional64->SizeOfImage) {\r
+              //\r
+              // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
+              //\r
+              Optional64->SizeOfImage           -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+              Optional64->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+              SectionHeader->SizeOfRawData       = AllignedRelocSize;\r
+              *FileLength                        = Optional64->SizeOfImage;\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to command line parameter strings.\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  ULONG                        Type;\r
+  PUCHAR                       Ext;\r
+  PUCHAR                       p;\r
+  PUCHAR                       pe;\r
+  PUCHAR                       OutImageName;\r
+  UCHAR                        outname[500];\r
+  FILE                         *fpIn;\r
+  FILE                         *fpOut;\r
+  EFI_IMAGE_DOS_HEADER         *DosHdr;\r
+  PE_HEADER                    *PeHdr;\r
+  time_t                       TimeStamp;\r
+  struct tm                    TimeStruct;\r
+  EFI_IMAGE_DOS_HEADER         BackupDosHdr;\r
+  ULONG                        Index;\r
+  BOOLEAN                      TimeStampPresent;\r
+  BOOLEAN                      NeedClearExceptionTable;\r
+  BOOLEAN                      NeedStripZeroPendingReloc;\r
+  UINT8                        *FileBuffer;\r
+  UINTN                        FileLength;\r
+  EFI_IMAGE_OPTIONAL_HEADER32  *Optional32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64  *Optional64;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Assign to fix compile warning\r
+  //\r
+  OutImageName      = NULL;\r
+  Type              = 0;\r
+  Ext               = 0;\r
+  TimeStamp         = 0;\r
+  TimeStampPresent  = FALSE;\r
+\r
+  NeedClearExceptionTable   = TRUE;\r
+  NeedStripZeroPendingReloc = TRUE;\r
+\r
+  //\r
+  // Look for -t time-date option first. If the time is "0", then\r
+  // skip it.\r
+  //\r
+  if ((argc > 2) && !strcmp (argv[1], "-t")) {\r
+    TimeStampPresent = TRUE;\r
+    if (strcmp (argv[2], "0") != 0) {\r
+      //\r
+      // Convert the string to a value\r
+      //\r
+      memset ((char *) &TimeStruct, 0, sizeof (TimeStruct));\r
+      if (sscanf(\r
+          argv[2], "%d/%d/%d,%d:%d:%d",\r
+          &TimeStruct.tm_mon,   /* months since January - [0,11] */\r
+          &TimeStruct.tm_mday,  /* day of the month - [1,31] */\r
+          &TimeStruct.tm_year,  /* years since 1900 */\r
+          &TimeStruct.tm_hour,  /* hours since midnight - [0,23] */\r
+          &TimeStruct.tm_min,   /* minutes after the hour - [0,59] */\r
+          &TimeStruct.tm_sec    /* seconds after the minute - [0,59] */\r
+            ) != 6) {\r
+        Error (NULL, 0, 0, argv[2], "failed to convert to mm/dd/yyyy,hh:mm:ss format");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Now fixup some of the fields\r
+      //\r
+      TimeStruct.tm_mon--;\r
+      TimeStruct.tm_year -= 1900;\r
+      //\r
+      // Sanity-check values?\r
+      // Convert\r
+      //\r
+      TimeStamp = mktime (&TimeStruct);\r
+      if (TimeStamp == (time_t) - 1) {\r
+        Error (NULL, 0, 0, argv[2], "failed to convert time");\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+    //\r
+    // Skip over the args\r
+    //\r
+    argc -= 2;\r
+    argv += 2;\r
+  }\r
+\r
+  //\r
+  // Look for -e option.\r
+  //\r
+  if ((argc > 1) && !strcmp (argv[1], "-e")) {\r
+    NeedClearExceptionTable = FALSE;\r
+    //\r
+    // Skip over the args\r
+    //\r
+    argc -= 1;\r
+    argv += 1;\r
+  }\r
+\r
+  //\r
+  // Look for -r option\r
+  //\r
+  if ((argc > 1) && !strcmp (argv[1], "-r")) {\r
+    NeedStripZeroPendingReloc = FALSE;\r
+    //\r
+    // Skip over the args\r
+    //\r
+    argc -= 1;\r
+    argv += 1;\r
+  }\r
+\r
+  //\r
+  // Check for enough args\r
+  //\r
+  if (argc < 3) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (argc == 4) {\r
+    OutImageName = argv[3];\r
+  }\r
+  //\r
+  // Get new image type\r
+  //\r
+  p = argv[1];\r
+  if (*p == '/' || *p == '\\') {\r
+    p += 1;\r
+  }\r
+\r
+  if (_stricmp (p, "app") == 0 || _stricmp (p, "APPLICATION") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION;\r
+    Ext   = ".efi";\r
+\r
+  } else if (_stricmp (p, "bsdrv") == 0 || _stricmp (p, "BS_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".efi";\r
+\r
+  } else if (_stricmp (p, "rtdrv") == 0 || _stricmp (p, "RT_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;\r
+    Ext   = ".efi";\r
+\r
+  } else if (_stricmp (p, "rtdrv") == 0 || _stricmp (p, "SAL_RT_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER;\r
+    Ext   = ".efi";\r
+  } else if (_stricmp (p, "SECURITY_CORE") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".sec";\r
+  } else if (_stricmp (p, "peim") == 0 ||\r
+           _stricmp (p, "PEI_CORE") == 0 ||\r
+           _stricmp (p, "PE32_PEIM") == 0 ||\r
+           _stricmp (p, "RELOCATABLE_PEIM") == 0 ||\r
+           _stricmp (p, "combined_peim_driver") == 0\r
+          ) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".pei";\r
+  } else {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // open source file\r
+  //\r
+  fpIn = fopen (argv[2], "rb");\r
+  if (!fpIn) {\r
+    Error (NULL, 0, 0, argv[2], "failed to open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  FReadFile (fpIn, (VOID **)&FileBuffer, &FileLength);\r
+  //\r
+  // Read the dos & pe hdrs of the image\r
+  //\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *) FileBuffer;\r
+  if (DosHdr->e_magic != IMAGE_DOS_SIGNATURE) {\r
+    Error (NULL, 0, 0, argv[2], "DOS header signature not found in source image");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  PeHdr = (PE_HEADER *)(FileBuffer + DosHdr->e_lfanew);\r
+  if (PeHdr->PeHeader32.Signature != IMAGE_NT_SIGNATURE) {\r
+    Error (NULL, 0, 0, argv[2], "PE header signature not found in source image");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // open output file\r
+  //\r
+  strcpy (outname, argv[2]);\r
+  pe = NULL;\r
+  for (p = outname; *p; p++) {\r
+    if (*p == '.') {\r
+      pe = p;\r
+    }\r
+  }\r
+\r
+  if (!pe) {\r
+    pe = p;\r
+  }\r
+\r
+  strcpy (pe, Ext);\r
+\r
+  if (!OutImageName) {\r
+    OutImageName = outname;\r
+  }\r
+\r
+  fpOut = fopen (OutImageName, "w+b");\r
+  if (!fpOut) {\r
+    Error (NULL, 0, 0, OutImageName, "could not open output file for writing");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Zero all unused fields of the DOS header\r
+  //\r
+  memcpy (&BackupDosHdr, DosHdr, sizeof (EFI_IMAGE_DOS_HEADER));\r
+  memset (DosHdr, 0, sizeof (EFI_IMAGE_DOS_HEADER));\r
+  DosHdr->e_magic  = BackupDosHdr.e_magic;\r
+  DosHdr->e_lfanew = BackupDosHdr.e_lfanew;\r
+\r
+  for (Index = sizeof (EFI_IMAGE_DOS_HEADER); Index < (ULONG) DosHdr->e_lfanew; Index++) {\r
+    FileBuffer[Index] = (UINT8) DosHdr->e_cp;\r
+  }\r
+  \r
+  //\r
+  // Modify some fields in the PE header\r
+  //\r
+\r
+  //\r
+  // TimeDateStamp's offset is fixed for PE32/32+\r
+  //\r
+  if (TimeStampPresent) {\r
+    PeHdr->PeHeader32.FileHeader.TimeDateStamp = (UINT32) TimeStamp;\r
+  }\r
+\r
+  //\r
+  // PE32/32+ has different optional header layout\r
+  // Determine format is PE32 or PE32+ before modification\r
+  //\r
+  if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    //\r
+    // PE32 image\r
+    //\r
+    Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->PeHeader32.OptionalHeader;\r
+\r
+    Optional32->MajorLinkerVersion          = 0;\r
+    Optional32->MinorLinkerVersion          = 0;\r
+    Optional32->MajorOperatingSystemVersion = 0;\r
+    Optional32->MinorOperatingSystemVersion = 0;\r
+    Optional32->MajorImageVersion           = 0;\r
+    Optional32->MinorImageVersion           = 0;\r
+    Optional32->MajorSubsystemVersion       = 0;\r
+    Optional32->MinorSubsystemVersion       = 0;\r
+    Optional32->Win32VersionValue           = 0;\r
+    Optional32->CheckSum                    = 0;\r
+    Optional32->SizeOfStackReserve          = 0;\r
+    Optional32->SizeOfStackCommit           = 0;\r
+    Optional32->SizeOfHeapReserve           = 0;\r
+    Optional32->SizeOfHeapCommit            = 0;\r
+    Optional32->Subsystem                   = (USHORT) Type;\r
+\r
+    //\r
+    // Strip zero padding at the end of the .reloc section \r
+    //\r
+    if (NeedStripZeroPendingReloc) {\r
+      StripZeroPendingReloc (FileBuffer, &FileLength, DosHdr, PeHdr);\r
+    }\r
+  } else if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+    //\r
+    // PE32+ image\r
+    //\r
+    Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->PeHeader64.OptionalHeader;\r
+\r
+    Optional64->MajorLinkerVersion          = 0;\r
+    Optional64->MinorLinkerVersion          = 0;\r
+    Optional64->MajorOperatingSystemVersion = 0;\r
+    Optional64->MinorOperatingSystemVersion = 0;\r
+    Optional64->MajorImageVersion           = 0;\r
+    Optional64->MinorImageVersion           = 0;\r
+    Optional64->MajorSubsystemVersion       = 0;\r
+    Optional64->MinorSubsystemVersion       = 0;\r
+    Optional64->Win32VersionValue           = 0;\r
+    Optional64->CheckSum                    = 0;\r
+    Optional64->SizeOfStackReserve          = 0;\r
+    Optional64->SizeOfStackCommit           = 0;\r
+    Optional64->SizeOfHeapReserve           = 0;\r
+    Optional64->SizeOfHeapCommit            = 0;\r
+    Optional64->Subsystem                   = (USHORT) Type;\r
+\r
+    //\r
+    // Strip zero padding at the end of the .reloc section \r
+    //\r
+    if (NeedStripZeroPendingReloc) {\r
+      StripZeroPendingReloc (FileBuffer, &FileLength, DosHdr, PeHdr);\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, argv[2], "Unsupported PE image");\r
+    fclose (fpIn);\r
+    fclose (fpOut);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Zero PDATA section for smaller binary size after compression\r
+  //\r
+  if (NeedClearExceptionTable) {\r
+    ZeroExceptionTable (FileBuffer, DosHdr, PeHdr);\r
+  }\r
+\r
+  FWriteFile (fpOut, FileBuffer, FileLength);\r
+\r
+  //\r
+  // Done\r
+  //\r
+  fclose (fpIn);\r
+  fclose (fpOut);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
new file mode 100644 (file)
index 0000000..98cbb07
--- /dev/null
@@ -0,0 +1,467 @@
+/*++\r
+\r
+ Copyright (c) 2006, Intel Corporation                                                         \r
+ All rights reserved. This program and the accompanying materials                          \r
+ are licensed and made available under the terms and conditions of the BSD License         \r
+ which accompanies this distribution.  The full text of the license may be found at        \r
+ http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  GenAprioriFile.c  \r
+\r
+Abstract:\r
+\r
+  Given an input file containing a list of GUIDs (or Guided file names),\r
+  convert the file to an Apriori file consumable by the dispatcher.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+\r
+#include "EfiCommon.h"\r
+#include "ParseInf.h"\r
+#include "CommonLib.h"  // for compare guid\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  200\r
+#define MAX_PATH      200\r
+\r
+//\r
+// typedef unsigned int          STATUS;\r
+// #define STATUS_SUCCESS        0\r
+// #define STATUS_WARNING        1\r
+// #define STATUS_ERROR          2\r
+//\r
+#define UTILITY_NAME  "GenAprioriFile"\r
+//\r
+// Here's all our globals.\r
+//\r
+static struct {\r
+  FILE    *BinFptr; // output dependencies to this file\r
+  INT8    *AprioriFileName;\r
+  INT8    *OutputFileName;\r
+  BOOLEAN Intelligent;\r
+  BOOLEAN Verbose;\r
+  BOOLEAN NullTerminate;\r
+} mGlobals;\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsCommentLine (\r
+  INT8    *Line\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process the\r
+  Apriori list file and generate the GUID file.\r
+  \r
+Arguments:\r
+\r
+  Standard C main() argc and argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+// GC_TODO:    Argc - add argument and description to function comment\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  STATUS    Status;\r
+  FILE      *AprioriFptr;\r
+  FILE      *BinFptr;\r
+  INT8      Line[MAX_LINE_LEN];\r
+  EFI_GUID  Guid;\r
+  EFI_GUID  GuidIn;\r
+  EFI_GUID  ZeroGuid;\r
+  UINT32    LineCounter;\r
+  //\r
+  // Initialize the error printing routines\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
+  memset ((char *) &ZeroGuid, 0, sizeof (ZeroGuid));\r
+  AprioriFptr = NULL;\r
+  BinFptr     = NULL;\r
+\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // If arguments were ok, then open the Apriori file and process it.\r
+  //\r
+  if ((AprioriFptr = fopen (mGlobals.AprioriFileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, mGlobals.AprioriFileName, "failed to open file for reading");\r
+    goto FinishUp;\r
+  }\r
+  //\r
+  // If -i intelligent option specified, then attempt to read and\r
+  // existing output file and see if we'd be creating an identical file.\r
+  //\r
+  if (mGlobals.Intelligent) {\r
+    if ((BinFptr = fopen (mGlobals.OutputFileName, "rb")) == NULL) {\r
+      if (mGlobals.Verbose) {\r
+        DebugMsg (NULL, 0, 0, "Creating new apriori file -- no existing file", NULL);\r
+      }\r
+\r
+      goto CreateFile;\r
+    }\r
+    //\r
+    // Read lines from the input file until done. Convert each to a guid, then\r
+    // read a guid from the input file and compare them.\r
+    //\r
+    while (fgets (Line, sizeof (Line), AprioriFptr) != NULL) {\r
+\r
+      if (IsCommentLine (Line)) {\r
+        continue;\r
+      }\r
+      //\r
+      // Convert to a guid\r
+      //\r
+      if (StringToGuid (Line, &Guid) != EFI_SUCCESS) {\r
+        if (mGlobals.Verbose) {\r
+          DebugMsg (NULL, 0, 0, "failed to read GUID from input text file -- creating new file", NULL);\r
+        }\r
+\r
+        goto CreateFile;\r
+      }\r
+      //\r
+      // Read guid from input file, then compare\r
+      //\r
+      if (fread (&GuidIn, sizeof (GuidIn), 1, BinFptr) != 1) {\r
+        if (mGlobals.Verbose) {\r
+          DebugMsg (NULL, 0, 0, "failed to read GUID from input binary file -- creating new file", NULL);\r
+        }\r
+\r
+        goto CreateFile;\r
+      }\r
+\r
+      if (CompareGuid (&Guid, &GuidIn) != 0) {\r
+        if (mGlobals.Verbose) {\r
+          DebugMsg (NULL, 0, 0, "GUID comparison failed -- creating new file", NULL);\r
+        }\r
+\r
+        goto CreateFile;\r
+      }\r
+    }\r
+    //\r
+    // May be one more NULL guid in the binary file\r
+    //\r
+    if (mGlobals.NullTerminate) {\r
+      if (fread (&GuidIn, sizeof (GuidIn), 1, BinFptr) != 1) {\r
+        if (mGlobals.Verbose) {\r
+          DebugMsg (NULL, 0, 0, "failed to read NULL GUID from input binary file -- creating new file", NULL);\r
+        }\r
+\r
+        goto CreateFile;\r
+      }\r
+\r
+      if (CompareGuid (&GuidIn, &ZeroGuid) != 0) {\r
+        if (mGlobals.Verbose) {\r
+          DebugMsg (NULL, 0, 0, "NULL GUID comparison failed -- creating new file", NULL);\r
+        }\r
+\r
+        goto CreateFile;\r
+      }\r
+    }\r
+    //\r
+    // Make sure we're at the end of both files.\r
+    //\r
+    if ((fgets (Line, sizeof (Line), AprioriFptr) != NULL) || (fread (&GuidIn, 1, 1, BinFptr) != 0)) {\r
+      if (mGlobals.Verbose) {\r
+        DebugMsg (NULL, 0, 0, "file sizes different, -i test failed -- creating new file", NULL);\r
+      }\r
+\r
+      goto CreateFile;\r
+    }\r
+\r
+    if (mGlobals.Verbose) {\r
+      DebugMsg (NULL, 0, 0, "existing file would be unchanged -- keeping existing apriori file", NULL);\r
+    }\r
+\r
+    goto FinishUp;\r
+  }\r
+\r
+CreateFile:\r
+  //\r
+  // Rewind the Apriori file in case -i was specified. Also\r
+  // try to close the output file for the case where we prescanned\r
+  // it (again, because of -i).\r
+  //\r
+  rewind (AprioriFptr);\r
+  if (BinFptr != NULL) {\r
+    fclose (BinFptr);\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((BinFptr = fopen (mGlobals.OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, mGlobals.OutputFileName, "could not open input file");\r
+    goto FinishUp;\r
+  }\r
+  //\r
+  // Read lines until we're done\r
+  //\r
+  LineCounter = 0;\r
+  while (fgets (Line, sizeof (Line), AprioriFptr) != NULL) {\r
+    LineCounter++;\r
+    if (IsCommentLine (Line)) {\r
+      continue;\r
+    }\r
+    //\r
+    // Convert to a GUID\r
+    //\r
+    if (StringToGuid (Line, &Guid) != EFI_SUCCESS) {\r
+      Error (mGlobals.AprioriFileName, LineCounter, 0, "failed to convert GUID", NULL);\r
+      goto FinishUp;\r
+    }\r
+    //\r
+    // Write the guid to the output file\r
+    //\r
+    if (fwrite (&Guid, sizeof (Guid), 1, BinFptr) != 1) {\r
+      Error (NULL, 0, 0, mGlobals.OutputFileName, "failed to write GUID to output file");\r
+      goto FinishUp;\r
+    }\r
+  }\r
+  //\r
+  // Write a null guid out to terminate the list\r
+  //\r
+  if (mGlobals.NullTerminate) {\r
+    memset ((void *) &Guid, 0, sizeof (Guid));\r
+    if (fwrite (&Guid, sizeof (Guid), 1, BinFptr) != 1) {\r
+      Error (NULL, 0, 0, mGlobals.OutputFileName, "failed to write NULL termination GUID to output file");\r
+    }\r
+  }\r
+\r
+FinishUp:\r
+\r
+  if (AprioriFptr != NULL) {\r
+    fclose (AprioriFptr);\r
+  }\r
+\r
+  if (BinFptr != NULL) {\r
+    fclose (BinFptr);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsCommentLine (\r
+  INT8    *Line\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Line  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  for (; isspace (*Line) && *Line; Line++)\r
+    ;\r
+\r
+  //\r
+  // Allow # or // comments\r
+  //\r
+  if ((*Line == '#') || ((*Line == '/') && (*(Line + 1) == '/')) || (*Line == '\n') || (*Line == 0)) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Argc  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  //\r
+  // Process until no more args\r
+  //\r
+  while (Argc) {\r
+    //\r
+    // -f AprioriFile\r
+    //\r
+    if (_stricmp (Argv[0], "-f") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        mGlobals.AprioriFileName = Argv[1];\r
+      } else {\r
+        Error (NULL, 0, 0, NULL, "missing filename with %s", Argv[0]);\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-i") == 0) {\r
+      //\r
+      // intelligent creation of output file. That is to say, if\r
+      // there's already a file there, and it's the same as what\r
+      // we'd create, then don't re-create. This is to support\r
+      // incremental builds (that is to say, running nmake a second time\r
+      // does nothing).\r
+      //\r
+      mGlobals.Intelligent = TRUE;\r
+    } else if (_stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = TRUE;\r
+    } else if (_stricmp (Argv[0], "-null") == 0) {\r
+      mGlobals.NullTerminate = TRUE;\r
+    } else if (_stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // -o OutputFileName\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        mGlobals.OutputFileName = Argv[1];\r
+      } else {\r
+        Error (NULL, 0, 0, NULL, "missing filename argument with %s", Argv[0]);\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Had to specify the apriori input file and output file names\r
+  //\r
+  if (mGlobals.AprioriFileName == NULL) {\r
+    Error (NULL, 0, 0, "must specify -f AprioriFile", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (mGlobals.OutputFileName == NULL) {\r
+    Error (NULL, 0, 0, "must specify -o OutputFile", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher",\r
+    "  Usage: "UTILITY_NAME " [Options]",\r
+    "  Options include:",\r
+    "    -h or -?         for this help information",\r
+    "    -f AprioriFile   parse the GUID'ed files in AprioriFile (required)",\r
+    "    -o OutputFile    write output to OutputFile (required)",\r
+    "    -i               for intelligent re-creation of OutputFile",\r
+    "    -null            to terminate the output file with a NULL GUID",\r
+    "    -v               verbose option",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile
new file mode 100644 (file)
index 0000000..887da4f
--- /dev/null
@@ -0,0 +1,78 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  \r
+#\r
+#     makefile\r
+#    \r
+#  Abstract:\r
+#  \r
+#    makefile for building the GenAproriFile utility.\r
+#  \r
+#  Revision History\r
+#  \r
+#--*/\r
+\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = GenAprioriFile\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\GenAprioriFile.exe\r
+LIBS                                                           = $(EDK_TOOLS_OUTPUT)\Common.lib\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\GenAprioriFile.obj  \r
+\r
+#\r
+# Compile each source file\r
+#\r
+$(EDK_TOOLS_OUTPUT)\GenAprioriFile.obj : $(TARGET_SRC_DIR)\GenAprioriFile.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\GenAprioriFile.c /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tools.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c
new file mode 100644 (file)
index 0000000..d16358b
--- /dev/null
@@ -0,0 +1,58 @@
+#include "fat.h"\r
+#include <stdio.h>\r
+\r
+INTN\r
+GetDrvNumOffset (\r
+  IN VOID *BootSector\r
+  )\r
+{\r
+  FAT_BPB_STRUCT  *FatBpb;\r
+  UINTN           RootDirSectors;\r
+  UINTN           FATSz;\r
+  UINTN           TotSec;\r
+  UINTN           DataSec;\r
+  UINTN           CountOfClusters;\r
+\r
+  FatBpb  = (FAT_BPB_STRUCT *) BootSector;\r
+\r
+  //\r
+  // Check FAT type algorithm from FAT spec\r
+  //\r
+  RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) +\r
+                    (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) / FatBpb->Fat12_16.BPB_BytsPerSec;\r
+\r
+  if (FatBpb->Fat12_16.BPB_FATSz16 != 0) {\r
+    FATSz = FatBpb->Fat12_16.BPB_FATSz16;\r
+  } else {\r
+    FATSz = FatBpb->Fat32.BPB_FATSz32;\r
+  }\r
+  if (FATSz == 0) {\r
+    fprintf (stderr, "ERROR: FAT: BPB_FATSz16, BPB_FATSz32 - 0, expected - Non-Zero\n");\r
+    return -1;\r
+  }\r
+\r
+  if (FatBpb->Fat12_16.BPB_TotSec16 != 0) {\r
+    TotSec = FatBpb->Fat12_16.BPB_TotSec16;\r
+  } else {\r
+    TotSec = FatBpb->Fat12_16.BPB_TotSec32;\r
+  }\r
+  if (TotSec == 0) {\r
+    fprintf (stderr, "ERROR: FAT: BPB_TotSec16, BPB_TotSec32 - 0, expected - Non-Zero\n");\r
+    return -1;\r
+  }\r
+\r
+  DataSec = TotSec - (\r
+                      FatBpb->Fat12_16.BPB_RsvdSecCnt +\r
+                      FatBpb->Fat12_16.BPB_NumFATs * FATSz +\r
+                      RootDirSectors\r
+                     );\r
+\r
+  CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus;\r
+\r
+  if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) {\r
+    return (INTN) ((UINTN) &FatBpb->Fat12_16.BS_DrvNum - (UINTN) FatBpb);\r
+  } else {\r
+    return (INTN) ((UINTN) &FatBpb->Fat32.BS_DrvNum - (UINTN) FatBpb);\r
+  }\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h
new file mode 100644 (file)
index 0000000..3303126
--- /dev/null
@@ -0,0 +1,158 @@
+/*++\r
+\r
+Copyright 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    fat.h\r
+    \r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _FAT_BPB_H_\r
+#define _FAT_BPB_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  //\r
+  // Fat common field\r
+  //\r
+  UINT8              BS_jmpBoot[3];\r
+  CHAR8              BS_OEMName[8];\r
+  UINT16             BPB_BytsPerSec;\r
+  UINT8              BPB_SecPerClus;\r
+  UINT16             BPB_RsvdSecCnt;\r
+  UINT8              BPB_NumFATs;\r
+  UINT16             BPB_RootEntCnt;\r
+  UINT16             BPB_TotSec16;\r
+  UINT8              BPB_Media;\r
+  UINT16             BPB_FATSz16;\r
+  UINT16             BPB_SecPerTrk;\r
+  UINT16             BPB_NumHeads;\r
+  UINT32             BPB_HiddSec;\r
+  UINT32             BPB_TotSec32;\r
+\r
+  //\r
+  // Fat12/16 specific field\r
+  //\r
+  UINT8              BS_DrvNum;\r
+  UINT8              BS_Reserved1;\r
+  UINT8              BS_BootSig;\r
+  UINT32             BS_VolID;\r
+  CHAR8              BS_VolLab[11];\r
+  CHAR8              BS_FilSysType[8];\r
+\r
+  //\r
+  // Boot Code and Data\r
+  //\r
+  UINT8              Reserved[448];\r
+\r
+  //\r
+  // Fat common signature - 0xAA55\r
+  //\r
+  UINT16             Signature;\r
+} FAT12_16_BPB_STRUCT;\r
+\r
+typedef struct {\r
+  //\r
+  // Fat common field\r
+  //\r
+  UINT8              BS_jmpBoot[3];\r
+  CHAR8              BS_OEMName[8];\r
+  UINT16             BPB_BytsPerSec;\r
+  UINT8              BPB_SecPerClus;\r
+  UINT16             BPB_RsvdSecCnt;\r
+  UINT8              BPB_NumFATs;\r
+  UINT16             BPB_RootEntCnt;\r
+  UINT16             BPB_TotSec16;\r
+  UINT8              BPB_Media;\r
+  UINT16             BPB_FATSz16;\r
+  UINT16             BPB_SecPerTrk;\r
+  UINT16             BPB_NumHeads;\r
+  UINT32             BPB_HiddSec;\r
+  UINT32             BPB_TotSec32;\r
+\r
+  //\r
+  // Fat32 specific field\r
+  //\r
+  UINT32             BPB_FATSz32;\r
+  UINT16             BPB_ExtFlags;\r
+  UINT16             BPB_FSVer;\r
+  UINT32             BPB_RootClus;\r
+  UINT16             BPB_FSInfo;\r
+  UINT16             BPB_BkBootSec;\r
+  UINT8              BPB_Reserved[12];\r
+  UINT8              BS_DrvNum;\r
+  UINT8              BS_Reserved1;\r
+  UINT8              BS_BootSig;\r
+  UINT32             BS_VolID;\r
+  CHAR8              BS_VolLab[11];\r
+  CHAR8              BS_FilSysType[8];\r
+\r
+  //\r
+  // Boot Code and Data\r
+  //\r
+  UINT8              Reserved[420];\r
+\r
+  //\r
+  // Fat common signature - 0xAA55\r
+  //\r
+  UINT16             Signature;\r
+} FAT32_BPB_STRUCT;\r
+\r
+typedef union {\r
+  FAT12_16_BPB_STRUCT   Fat12_16;\r
+  FAT32_BPB_STRUCT      Fat32;\r
+} FAT_BPB_STRUCT;\r
+\r
+typedef enum {\r
+  FatTypeUnknown,\r
+  FatTypeFat12,\r
+  FatTypeFat16,\r
+  FatTypeFat32,\r
+  FatTypeMax\r
+} FAT_TYPE;\r
+\r
+typedef struct {\r
+  CHAR8              DIR_Name[11];\r
+  UINT8              DIR_Attr;\r
+  UINT8              DIR_NTRes;\r
+  UINT8              DIR_CrtTimeTenth;\r
+  UINT16             DIR_CrtTime;\r
+  UINT16             DIR_CrtDate;\r
+  UINT16             DIR_LstAccDate;\r
+  UINT16             DIR_FstClusHI;\r
+  UINT16             DIR_WrtTime;\r
+  UINT16             DIR_WrtDate;\r
+  UINT16             DIR_FstClusLO;\r
+  UINT32             DIR_FileSize;\r
+} FAT_DIRECTORY_ENTRY;\r
+\r
+#pragma pack()\r
+\r
+#define FAT_MAX_FAT12_CLUSTER         0xFF5\r
+#define FAT_MAX_FAT16_CLUSTER         0xFFF5\r
+\r
+#define FAT_BS_SIGNATURE      0xAA55\r
+#define FAT_BS_BOOTSIG        0x29\r
+#define FAT_BS_JMP1           0xEB\r
+#define FAT_BS_JMP2           0xE9\r
+#define FAT_FILSYSTYPE        "FAT     "\r
+#define FAT12_FILSYSTYPE      "FAT12   "\r
+#define FAT16_FILSYSTYPE      "FAT16   "\r
+#define FAT32_FILSYSTYPE      "FAT32   "\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c
new file mode 100644 (file)
index 0000000..8438502
--- /dev/null
@@ -0,0 +1,652 @@
+/*++\r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  genbootsector.c\r
+  \r
+Abstract:\r
+  Reading/writing MBR/DBR.\r
+  NOTE:\r
+    If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.\r
+    If we process DBR, we will patch MBR to set first partition active if no active partition exists.\r
+\r
+--*/\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#define MAX_DRIVE                             26\r
+#define PARTITION_TABLE_OFFSET                0x1BE\r
+\r
+#define SIZE_OF_PARTITION_ENTRY               0x10\r
+\r
+#define PARTITION_ENTRY_STARTLBA_OFFSET       8\r
+\r
+#define PARTITION_ENTRY_NUM                   4\r
+\r
+INT\r
+GetDrvNumOffset (\r
+  IN VOID *BootSector\r
+  );\r
+\r
+typedef enum {\r
+  PatchTypeUnknown,\r
+  PatchTypeFloppy,\r
+  PatchTypeIde,\r
+  PatchTypeUsb,\r
+} PATCH_TYPE;\r
+\r
+typedef enum {\r
+  ErrorSuccess,\r
+  ErrorFileCreate,\r
+  ErrorFileReadWrite,\r
+  ErrorNoMbr,\r
+  ErrorFatType\r
+} ERROR_STATUS;\r
+\r
+CHAR *ErrorStatusDesc[] = {\r
+  "Success",\r
+  "Failed to create files",\r
+  "Failed to read/write files",\r
+  "No MBR exists",\r
+  "Failed to detect Fat type"\r
+};\r
+\r
+typedef struct _DRIVE_TYPE_DESC {\r
+  UINT  Type;\r
+  CHAR  *Description;\r
+} DRIVE_TYPE_DESC;\r
+\r
+#define DRIVE_TYPE_ITEM(x) {x, #x}\r
+DRIVE_TYPE_DESC DriveTypeDesc[] = {\r
+  DRIVE_TYPE_ITEM (DRIVE_UNKNOWN),\r
+  DRIVE_TYPE_ITEM (DRIVE_NO_ROOT_DIR),\r
+  DRIVE_TYPE_ITEM (DRIVE_REMOVABLE),\r
+  DRIVE_TYPE_ITEM (DRIVE_FIXED),\r
+  DRIVE_TYPE_ITEM (DRIVE_REMOTE),\r
+  DRIVE_TYPE_ITEM (DRIVE_CDROM),\r
+  DRIVE_TYPE_ITEM (DRIVE_RAMDISK),\r
+  (UINT) -1, NULL\r
+};\r
+\r
+typedef struct _DRIVE_INFO {\r
+  CHAR              VolumeLetter;\r
+  DRIVE_TYPE_DESC   *DriveType;\r
+  UINT              DiskNumber;\r
+} DRIVE_INFO;\r
+\r
+#define BOOT_SECTOR_LBA_OFFSET 0x1FA\r
+\r
+#define IsLetter(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))\r
+\r
+BOOL\r
+GetDriveInfo (\r
+  CHAR       VolumeLetter,\r
+  DRIVE_INFO *DriveInfo\r
+  )\r
+/*++\r
+Routine Description:\r
+  Get drive information including disk number and drive type,\r
+  where disknumber is useful for reading/writing disk raw data.\r
+  NOTE: Floppy disk doesn't have disk number but it doesn't matter because\r
+        we can reading/writing floppy disk without disk number.\r
+\r
+Arguments:\r
+  VolumeLetter : volume letter, e.g.: C for C:, A for A:\r
+  DriveInfo    : pointer to DRIVE_INFO structure receiving drive information.\r
+\r
+Return:\r
+  TRUE  : successful\r
+  FALSE : failed\r
+--*/\r
+{\r
+  HANDLE                  VolumeHandle;\r
+  STORAGE_DEVICE_NUMBER   StorageDeviceNumber;\r
+  DWORD                   BytesReturned;\r
+  BOOL                    Success;\r
+  UINT                    DriveType;\r
+  UINT                    Index;\r
+\r
+  CHAR RootPath[]         = "X:\\";       // "X:\"  -> for GetDriveType\r
+  CHAR VolumeAccessPath[] = "\\\\.\\X:";  // "\\.\X:"  -> to open the volume\r
+\r
+  RootPath[0] = VolumeAccessPath[4] = VolumeLetter;\r
+  DriveType = GetDriveType(RootPath);\r
+  if (DriveType != DRIVE_REMOVABLE && DriveType != DRIVE_FIXED) {\r
+    return FALSE;\r
+  }\r
+\r
+  DriveInfo->VolumeLetter = VolumeLetter;\r
+  VolumeHandle = CreateFile (\r
+                   VolumeAccessPath,\r
+                   0,\r
+                   FILE_SHARE_READ | FILE_SHARE_WRITE,\r
+                   NULL,\r
+                   OPEN_EXISTING,\r
+                   0,\r
+                   NULL\r
+                   );\r
+  if (VolumeHandle == INVALID_HANDLE_VALUE) {\r
+    fprintf (\r
+      stderr, \r
+      "ERROR: CreateFile failed: Volume = %s, LastError = 0x%x\n", \r
+      VolumeAccessPath, \r
+      GetLastError ()\r
+      );\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Get Disk Number. It should fail when operating on floppy. That's ok \r
+  //  because Disk Number is only needed when operating on Hard or USB disk.\r
+  //\r
+  // To direct write to disk:\r
+  //   for USB and HD: use path = \\.\PHYSICALDRIVEx, where x is Disk Number\r
+  //   for floppy:     use path = \\.\X:, where X can be A or B\r
+  //\r
+  Success = DeviceIoControl(\r
+              VolumeHandle, \r
+              IOCTL_STORAGE_GET_DEVICE_NUMBER,\r
+              NULL, \r
+              0, \r
+              &StorageDeviceNumber, \r
+              sizeof(StorageDeviceNumber),\r
+              &BytesReturned, \r
+              NULL\r
+              );\r
+  //\r
+  // DeviceIoControl should fail if Volume is floppy or network drive.\r
+  //\r
+  if (!Success) {\r
+    DriveInfo->DiskNumber = (UINT) -1;\r
+  } else if (StorageDeviceNumber.DeviceType != FILE_DEVICE_DISK) {\r
+    //\r
+    // Only care about the disk.\r
+    //\r
+    return FALSE;\r
+  } else{\r
+    DriveInfo->DiskNumber = StorageDeviceNumber.DeviceNumber;\r
+  }\r
+  CloseHandle(VolumeHandle);\r
+  \r
+  //\r
+  // Fill in the type string\r
+  //\r
+  DriveInfo->DriveType = NULL;\r
+  for (Index = 0; DriveTypeDesc[Index].Description != NULL; Index ++) {\r
+    if (DriveType == DriveTypeDesc[Index].Type) {\r
+      DriveInfo->DriveType = &DriveTypeDesc[Index];\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (DriveInfo->DriveType == NULL) {\r
+    //\r
+    // Should have a type.\r
+    //\r
+    fprintf (stderr, "ERROR: fetal error!!!\n");\r
+    return FALSE;\r
+  }\r
+  return TRUE;\r
+}\r
+\r
+VOID\r
+ListDrive (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+  List every drive in current system and their information.\r
+\r
+--*/\r
+{\r
+  UINT       Index;\r
+  DRIVE_INFO DriveInfo;\r
+  \r
+  UINT Mask =  GetLogicalDrives();\r
+\r
+  for (Index = 0; Index < MAX_DRIVE; Index++) {\r
+    if (((Mask >> Index) & 0x1) == 1) {\r
+      if (GetDriveInfo ('A' + (CHAR) Index, &DriveInfo)) {\r
+        if (Index < 2) {\r
+          // Floppy will occupy 'A' and 'B'\r
+          fprintf (\r
+            stdout,\r
+            "%c: - Type: %s\n",\r
+            DriveInfo.VolumeLetter,\r
+            DriveInfo.DriveType->Description\r
+            );\r
+        }\r
+        else {\r
+          fprintf (\r
+            stdout,\r
+            "%c: - DiskNum: %d, Type: %s\n", \r
+            DriveInfo.VolumeLetter,\r
+            DriveInfo.DiskNumber, \r
+            DriveInfo.DriveType->Description\r
+            );\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+}\r
+\r
+INT\r
+GetBootSectorOffset (\r
+  HANDLE     DiskHandle,\r
+  BOOL       WriteToDisk,\r
+  PATCH_TYPE PatchType\r
+  )\r
+/*++\r
+Description:\r
+  Get the offset of boot sector.\r
+  For non-MBR disk, offset is just 0\r
+  for disk with MBR, offset needs to be caculated by parsing MBR\r
+\r
+  NOTE: if no one is active, we will patch MBR to select first partition as active.\r
+\r
+Arguments:\r
+  DiskHandle  : HANDLE of disk\r
+  WriteToDisk : TRUE indicates writing\r
+  PatchType   : PatchTypeFloppy, PatchTypeIde, PatchTypeUsb\r
+\r
+Return:\r
+  -1   : failed\r
+  o.w. : Offset to boot sector\r
+--*/\r
+{\r
+  BYTE    DiskPartition[0x200];\r
+  DWORD   BytesReturn;\r
+  DWORD   DbrOffset;\r
+  DWORD   Index;\r
+  BOOL    HasMbr;\r
+\r
+  DbrOffset = 0;\r
+  HasMbr    = FALSE;\r
+  \r
+  SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN);\r
+  if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {\r
+    return -1;\r
+  }\r
+\r
+  //\r
+  // Check Signature, Jmp, and Boot Indicator.\r
+  // if all pass, we assume MBR found.\r
+  //\r
+\r
+  // Check Signature: 55AA\r
+  if ((DiskPartition[0x1FE] == 0x55) && (DiskPartition[0x1FF] == 0xAA)) {\r
+    // Check Jmp: (EB ?? 90) or (E9 ?? ??)\r
+    if (((DiskPartition[0] != 0xEB) || (DiskPartition[2] != 0x90)) &&\r
+        (DiskPartition[0] != 0xE9)) {\r
+      // Check Boot Indicator: 0x00 or 0x80\r
+      // Boot Indicator is the first byte of Partition Entry\r
+      HasMbr = TRUE;\r
+      for (Index = 0; Index < PARTITION_ENTRY_NUM; ++Index) {\r
+        if ((DiskPartition[PARTITION_TABLE_OFFSET + Index * SIZE_OF_PARTITION_ENTRY] & 0x7F) != 0) {\r
+          HasMbr = FALSE;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (HasMbr) {\r
+    //\r
+    // Skip MBR\r
+    //\r
+    for (Index = 0; Index < PARTITION_ENTRY_NUM; Index++) {\r
+      //\r
+      // Found Boot Indicator.\r
+      //\r
+      if (DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY)] == 0x80) {\r
+        DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY) + PARTITION_ENTRY_STARTLBA_OFFSET];\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If no boot indicator, we manually select 1st partition, and patch MBR.\r
+    //\r
+    if (Index == PARTITION_ENTRY_NUM) {\r
+      DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + PARTITION_ENTRY_STARTLBA_OFFSET];\r
+      if (WriteToDisk && (PatchType == PatchTypeUsb)) {\r
+        SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN);\r
+        DiskPartition[PARTITION_TABLE_OFFSET] = 0x80;\r
+        WriteFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL);\r
+      }\r
+    }\r
+  }\r
+\r
+  return DbrOffset;\r
+}\r
+\r
+ERROR_STATUS\r
+ProcessBsOrMbr (\r
+  CHAR        *DiskName,\r
+  CHAR        *FileName,\r
+  BOOL        WriteToDisk,\r
+  PATCH_TYPE  PatchType,\r
+  BOOL        ProcessMbr\r
+  )\r
+/*++\r
+Routine Description:\r
+  Writing or reading boot sector or MBR according to the argument.\r
+\r
+Arguments:\r
+  DiskName    : Win32 API recognized string name of disk\r
+  FileName    : file name\r
+  WriteToDisk : TRUE is to write content of file to disk, otherwise, reading content of disk to file\r
+  PatchType   : PatchTypeFloppy, PatchTypeIde, PatchTypeUsb\r
+  ProcessMbr  : TRUE is to process MBR, otherwise, processing boot sector\r
+\r
+Return:\r
+  ErrorSuccess\r
+  ErrorFileCreate\r
+  ErrorFileReadWrite\r
+  ErrorNoMbr\r
+  ErrorFatType\r
+--*/\r
+{\r
+  BYTE    DiskPartition[0x200];\r
+  BYTE    DiskPartitionBackup[0x200];\r
+  HANDLE  DiskHandle;\r
+  HANDLE  FileHandle;\r
+  DWORD   BytesReturn;\r
+  DWORD   DbrOffset;\r
+  INT     DrvNumOffset;\r
+\r
+  DiskHandle = CreateFile (\r
+                 DiskName, \r
+                 GENERIC_READ | GENERIC_WRITE, \r
+                 FILE_SHARE_READ, \r
+                 NULL, \r
+                 OPEN_EXISTING, \r
+                 FILE_ATTRIBUTE_NORMAL, \r
+                 NULL\r
+                 );\r
+  if (DiskHandle == INVALID_HANDLE_VALUE) {\r
+    return ErrorFileCreate;\r
+  }\r
+\r
+  FileHandle = CreateFile (\r
+                 FileName,\r
+                 GENERIC_READ | GENERIC_WRITE,\r
+                 0,\r
+                 NULL,\r
+                 OPEN_ALWAYS,\r
+                 FILE_ATTRIBUTE_NORMAL,\r
+                 NULL\r
+                 );\r
+  if (FileHandle == INVALID_HANDLE_VALUE) {\r
+    return ErrorFileCreate;\r
+  }\r
+\r
+  DbrOffset = 0;\r
+  //\r
+  // Skip potential MBR for Ide & USB disk\r
+  //\r
+  if ((PatchType == PatchTypeIde) || (PatchType == PatchTypeUsb)) {\r
+    //\r
+    // Even user just wants to process MBR, we get offset of boot sector here to validate the disk\r
+    //  if disk have MBR, DbrOffset should be greater than 0\r
+    //\r
+    DbrOffset = GetBootSectorOffset (DiskHandle, WriteToDisk, PatchType);\r
+\r
+    if (!ProcessMbr) {\r
+      //\r
+      // 1. Process boot sector, set file pointer to the beginning of boot sector\r
+      //\r
+      SetFilePointer (DiskHandle, DbrOffset * 0x200, NULL, FILE_BEGIN);\r
+    } else if(DbrOffset == 0) {\r
+      //\r
+      // If user want to process Mbr, but no Mbr exists, simply return FALSE\r
+      //\r
+      return ErrorNoMbr;\r
+    } else {\r
+      //\r
+      // 2. Process MBR, set file pointer to 0\r
+      //\r
+      SetFilePointer (DiskHandle, 0, NULL, FILE_BEGIN);\r
+    }\r
+  }\r
+\r
+  //\r
+  // [File Pointer is pointed to beginning of Mbr or Dbr]\r
+  //\r
+  if (WriteToDisk) {\r
+    //\r
+    // Write\r
+    //\r
+    if (!ReadFile (FileHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {\r
+      return ErrorFileReadWrite;\r
+    }\r
+    if (ProcessMbr) {\r
+      //\r
+      // Use original partition table\r
+      //\r
+      if (!ReadFile (DiskHandle, DiskPartitionBackup, 0x200, &BytesReturn, NULL)) {\r
+        return ErrorFileReadWrite;\r
+      }\r
+      memcpy (DiskPartition + 0x1BE, DiskPartitionBackup + 0x1BE, 0x40);\r
+      SetFilePointer (DiskHandle, 0, NULL, FILE_BEGIN);\r
+    }\r
+\r
+    if (!WriteFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {\r
+      return ErrorFileReadWrite;\r
+    }\r
+\r
+  } else {\r
+    //\r
+    // Read\r
+    //\r
+    if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {\r
+      return ErrorFileReadWrite;\r
+    }\r
+\r
+    if (PatchType == PatchTypeUsb) {\r
+      // Manually set BS_DrvNum to 0x80 as window's format.exe has a bug which will clear this field discarding USB disk's MBR. \r
+      // offset of BS_DrvNum is 0x24 for FAT12/16\r
+      //                        0x40 for FAT32\r
+      //\r
+      DrvNumOffset = GetDrvNumOffset (DiskPartition);\r
+      if (DrvNumOffset == -1) {\r
+        return ErrorFatType;\r
+      }\r
+      //\r
+      // Some legacy BIOS require 0x80 discarding MBR.\r
+      // Question left here: is it needed to check Mbr before set 0x80?\r
+      //\r
+      DiskPartition[DrvNumOffset] = ((DbrOffset > 0) ? 0x80 : 0);\r
+  }\r
+\r
+\r
+    if (PatchType == PatchTypeIde) {\r
+      //\r
+      // Patch LBAOffsetForBootSector\r
+      //\r
+      *(DWORD *)&DiskPartition [BOOT_SECTOR_LBA_OFFSET] = DbrOffset;\r
+    }\r
+    if (!WriteFile (FileHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {\r
+      return ErrorFileReadWrite;\r
+    }\r
+  }\r
+  CloseHandle (FileHandle);\r
+  CloseHandle (DiskHandle);\r
+  return ErrorSuccess;\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  CHAR* AppName\r
+  )\r
+{\r
+  fprintf (\r
+    stdout,\r
+    "Usage: %s [OPTIONS]...\n"\r
+    "Copy file content from/to bootsector.\n"\r
+    "\n"\r
+    "  -l        list disks\n"\r
+    "  -if=FILE  specified an input, can be files or disks\n"\r
+    "  -of=FILE  specified an output, can be files or disks\n"\r
+    "  -mbr      process MBR also\n"\r
+    "  -h        print this message\n"\r
+    "\n"\r
+    "FILE providing a volume plus a colon (X:), indicates a disk\n"\r
+    "FILE providing other format, indicates a file\n",\r
+    AppName\r
+    );\r
+}\r
\r
+INT\r
+main (\r
+  INT  argc,\r
+  CHAR *argv[]\r
+  )\r
+{\r
+  CHAR          *AppName;\r
+  INT           Index;\r
+  BOOL          ProcessMbr;\r
+  CHAR          VolumeLetter;\r
+  CHAR          *FilePath;\r
+  BOOL          WriteToDisk;\r
+  DRIVE_INFO    DriveInfo;\r
+  PATCH_TYPE    PatchType;\r
+  ERROR_STATUS  Status;\r
+\r
+  CHAR        FloppyPathTemplate[] = "\\\\.\\%c:";\r
+  CHAR        DiskPathTemplate[]   = "\\\\.\\PHYSICALDRIVE%u";\r
+  CHAR        DiskPath[MAX_PATH];\r
+\r
+  AppName = *argv;\r
+  argv ++;\r
+  argc --;\r
+  \r
+  ProcessMbr    = FALSE;\r
+  WriteToDisk   = TRUE;\r
+  FilePath      = NULL;\r
+  VolumeLetter  = 0;\r
+\r
+  //\r
+  // Parse command line\r
+  //\r
+  for (Index = 0; Index < argc; Index ++) {\r
+    if (_stricmp (argv[Index], "-l") == 0) {\r
+      ListDrive ();\r
+      return 0;\r
+    }\r
+    else if (_stricmp (argv[Index], "-mbr") == 0) {\r
+      ProcessMbr = TRUE;\r
+    }\r
+    else if ((_strnicmp (argv[Index], "-if=", 4) == 0) ||\r
+             (_strnicmp (argv[Index], "-of=", 4) == 0)\r
+             ) {\r
+      if (argv[Index][6] == '\0' && argv[Index][5] == ':' && IsLetter (argv[Index][4])) {\r
+        VolumeLetter = argv[Index][4];\r
+        if (_strnicmp (argv[Index], "-if=", 4) == 0) {\r
+          WriteToDisk = FALSE;\r
+        }\r
+      }\r
+      else {\r
+        FilePath = &argv[Index][4];\r
+      }\r
+    }\r
+    else {\r
+      PrintUsage (AppName);\r
+      return 1;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Check parameter\r
+  //\r
+  if (VolumeLetter == 0) {\r
+    fprintf (stderr, "ERROR: Volume isn't provided!\n");\r
+    PrintUsage (AppName);\r
+    return 1;\r
+  }\r
+  \r
+  if (FilePath == NULL) {\r
+    fprintf (stderr, "ERROR: File isn't pvovided!\n");\r
+    PrintUsage (AppName);\r
+    return 1;\r
+  }\r
+    \r
+  PatchType = PatchTypeUnknown;\r
+\r
+  if ((VolumeLetter == 'A') || (VolumeLetter == 'a') || \r
+      (VolumeLetter == 'B') || (VolumeLetter == 'b') \r
+      ) {\r
+    //\r
+    // Floppy\r
+    //\r
+    sprintf (DiskPath, FloppyPathTemplate, VolumeLetter);\r
+    PatchType = PatchTypeFloppy;\r
+  }\r
+  else {\r
+    //\r
+    // Hard/USB disk\r
+    //\r
+    if (!GetDriveInfo (VolumeLetter, &DriveInfo)) {\r
+      fprintf (stderr, "ERROR: GetDriveInfo - 0x%x\n", GetLastError ());\r
+      return 1;\r
+    }\r
+\r
+    //\r
+    // Shouldn't patch my own hard disk, but can read it.\r
+    // very safe then:)\r
+    //\r
+    if (DriveInfo.DriveType->Type == DRIVE_FIXED && WriteToDisk) {\r
+      fprintf (stderr, "ERROR: Write to local harddisk - permission denied!\n");\r
+      return 1;\r
+    }\r
+    \r
+    sprintf (DiskPath, DiskPathTemplate, DriveInfo.DiskNumber);\r
+    if (DriveInfo.DriveType->Type == DRIVE_REMOVABLE) {\r
+      PatchType = PatchTypeUsb;\r
+    }\r
+    else if (DriveInfo.DriveType->Type == DRIVE_FIXED) {\r
+      PatchType = PatchTypeIde;\r
+    }\r
+  }\r
+\r
+  if (PatchType == PatchTypeUnknown) {\r
+    fprintf (stderr, "ERROR: PatchType unknown!\n");\r
+    return 1;\r
+  }\r
+\r
+  //\r
+  // Process DBR (Patch or Read)\r
+  //\r
+  Status = ProcessBsOrMbr (DiskPath, FilePath, WriteToDisk, PatchType, ProcessMbr);\r
+  if (Status == ErrorSuccess) {\r
+    fprintf (\r
+      stdout, \r
+      "%s %s: successfully!\n", \r
+      WriteToDisk ? "Write" : "Read", \r
+      ProcessMbr ? "MBR" : "DBR"\r
+      );\r
+    return 0;\r
+  } else {\r
+    fprintf (\r
+      stderr, \r
+      "%s: %s %s: failed - %s (LastError: 0x%x)!\n",\r
+      (Status == ErrorNoMbr) ? "WARNING" : "ERROR",\r
+      WriteToDisk ? "Write" : "Read", \r
+      ProcessMbr ? "MBR" : "DBR", \r
+      ErrorStatusDesc[Status],\r
+      GetLastError ()\r
+      );\r
+    return 1;\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile
new file mode 100644 (file)
index 0000000..359f126
--- /dev/null
@@ -0,0 +1,99 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the GenBootsector utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=GenBootsector\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenBootsector.c"\r
+TARGET_EXE_INCLUDE = \r
+\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+$(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj: $(TARGET_SOURCE_DIR)\GenBootsector.c $(TARGET_SOURCE_DIR)\fat.h\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SOURCE_DIR)\GetDrvNumOffset.c /Fo$(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) user32.lib advapi32.lib /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.* del $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
new file mode 100644 (file)
index 0000000..27a02a4
--- /dev/null
@@ -0,0 +1,299 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GenCRC32Section.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware File System \r
+  file. The code is compliant with the Tiano C Coding standards.\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include "ParseInf.h"\r
+#include "crc32.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "GenCRC32Section.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <assert.h>\r
+#include "CommonLib.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
+\r
+#define TOOLVERSION   "0.2"\r
+\r
+#define UTILITY_NAME  "GenCrc32Section"\r
+\r
+EFI_GUID  gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+EFI_STATUS\r
+SignSectionWithCrc32 (\r
+  IN OUT UINT8  *FileBuffer,\r
+  IN OUT UINT32 *BufferSize,\r
+  IN UINT32     DataSize\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Signs the section with CRC32 and add GUIDed section header for the \r
+  signed data. data stays in same location (overwrites source data).\r
+            \r
+Arguments:\r
+               \r
+  FileBuffer  - Buffer containing data to sign\r
+                \r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of \r
+                actual section data (including added section header).              \r
+\r
+  DataSize    - Length of data to Sign\r
+\r
+  Key         - Key to use when signing. Currently only CRC32 is supported.\r
+                                       \r
+Returns:\r
+                       \r
+  EFI_SUCCESS           - Successful\r
+  EFI_OUT_OF_RESOURCES  - Not enough resource to complete the operation.\r
+                        \r
+--*/\r
+{\r
+\r
+  UINT32                Crc32Checksum;\r
+  EFI_STATUS            Status;\r
+  UINT32                TotalSize;\r
+  CRC32_SECTION_HEADER  Crc32Header;\r
+  UINT8                 *SwapBuffer;\r
+\r
+  Crc32Checksum = 0;\r
+  SwapBuffer    = NULL;\r
+\r
+  if (DataSize == 0) {\r
+    *BufferSize = 0;\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Status = CalculateCrc32 (FileBuffer, DataSize, &Crc32Checksum);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  TotalSize = DataSize + CRC32_SECTION_HEADER_SIZE;\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  memcpy (&(Crc32Header.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
+  Crc32Header.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+  Crc32Header.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
+  Crc32Header.CRC32Checksum                 = Crc32Checksum;\r
+\r
+  SwapBuffer = (UINT8 *) malloc (DataSize);\r
+  if (SwapBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  memcpy (SwapBuffer, FileBuffer, DataSize);\r
+  memcpy (FileBuffer, &Crc32Header, CRC32_SECTION_HEADER_SIZE);\r
+  memcpy (FileBuffer + CRC32_SECTION_HEADER_SIZE, SwapBuffer, DataSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (SwapBuffer != NULL) {\r
+    free (SwapBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+{\r
+  printf ("Usage:\n");\r
+  printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");\r
+  printf ("   -i \"inputfile\":\n ");\r
+  printf ("       specifies the input files that would be signed to CRC32 Guided section.\n");\r
+  printf ("   -o \"outputfile\":\n");\r
+  printf ("       specifies the output file that is a CRC32 Guided section.\n");\r
+}\r
+\r
+INT32\r
+ReadFilesContentsIntoBuffer (\r
+  IN      CHAR8   *argv[],\r
+  IN      INT32   Start,\r
+  IN OUT  UINT8   **FileBuffer,\r
+  IN OUT  UINT32  *BufferSize,\r
+  OUT     UINT32  *ContentSize,\r
+  IN      INT32   MaximumArguments\r
+  )\r
+{\r
+  INT32   Index;\r
+  CHAR8   *FileName;\r
+  FILE    *InputFile;\r
+  UINT8   Temp;\r
+  UINT32  Size;\r
+\r
+  FileName  = NULL;\r
+  InputFile = NULL;\r
+  Size      = 0;\r
+  Index     = 0;\r
+\r
+  //\r
+  // read all input files into one file buffer\r
+  //\r
+  while (argv[Start + Index][0] != '-') {\r
+\r
+    FileName  = argv[Start + Index];\r
+    InputFile = fopen (FileName, "rb");\r
+    if (InputFile == NULL) {\r
+      Error (NULL, 0, 0, FileName, "failed to open input binary file");\r
+      return -1;\r
+    }\r
+\r
+    fread (&Temp, sizeof (UINT8), 1, InputFile);\r
+    while (!feof (InputFile)) {\r
+      (*FileBuffer)[Size++] = Temp;\r
+      fread (&Temp, sizeof (UINT8), 1, InputFile);\r
+    }\r
+\r
+    fclose (InputFile);\r
+    InputFile = NULL;\r
+\r
+    //\r
+    // Make sure section ends on a DWORD boundary\r
+    //\r
+    while ((Size & 0x03) != 0) {\r
+      (*FileBuffer)[Size] = 0;\r
+      Size++;\r
+    }\r
+\r
+    Index++;\r
+    if (Index == MaximumArguments) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *ContentSize = Size;\r
+  return Index;\r
+}\r
+\r
+INT32\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+{\r
+  FILE        *OutputFile;\r
+  UINT8       *FileBuffer;\r
+  UINT32      BufferSize;\r
+  EFI_STATUS  Status;\r
+  UINT32      ContentSize;\r
+  CHAR8       *OutputFileName;\r
+  INT32       ReturnValue;\r
+  INT32       Index;\r
+\r
+  OutputFile      = NULL;\r
+  FileBuffer      = NULL;\r
+  ContentSize     = 0;\r
+  OutputFileName  = NULL;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+\r
+  if (argc == 1) {\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+\r
+  BufferSize  = 1024 * 1024 * 16;\r
+  FileBuffer  = (UINT8 *) malloc (BufferSize * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return -1;\r
+  }\r
+\r
+  ZeroMem (FileBuffer, BufferSize);\r
+\r
+  for (Index = 0; Index < argc; Index++) {\r
+    if (_strcmpi (argv[Index], "-i") == 0) {\r
+      ReturnValue = ReadFilesContentsIntoBuffer (\r
+                      argv,\r
+                      (Index + 1),\r
+                      &FileBuffer,\r
+                      &BufferSize,\r
+                      &ContentSize,\r
+                      (argc - (Index + 1))\r
+                      );\r
+      if (ReturnValue == -1) {\r
+        Error (NULL, 0, 0, "failed to read file contents", NULL);\r
+        return -1;\r
+      }\r
+\r
+      Index += ReturnValue;\r
+    }\r
+\r
+    if (_strcmpi (argv[Index], "-o") == 0) {\r
+      OutputFileName = argv[Index + 1];\r
+    }\r
+  }\r
+\r
+  OutputFile = fopen (OutputFileName, "wb");\r
+  if (OutputFile == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output binary file");\r
+    free (FileBuffer);\r
+    return -1;\r
+  }\r
+\r
+  /*  \r
+  //\r
+  // make sure section ends on a DWORD boundary ??\r
+  //\r
+  while ( (Size & 0x03) != 0 ) {\r
+    FileBuffer[Size] = 0;\r
+    Size ++;\r
+  }\r
+*/\r
+  Status = SignSectionWithCrc32 (FileBuffer, &BufferSize, ContentSize);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "failed to sign section", NULL);\r
+    free (FileBuffer);\r
+    fclose (OutputFile);\r
+    return -1;\r
+  }\r
+\r
+  ContentSize = fwrite (FileBuffer, sizeof (UINT8), BufferSize, OutputFile);\r
+  if (ContentSize != BufferSize) {\r
+    Error (NULL, 0, 0, "failed to write output buffer", NULL);\r
+    ReturnValue = -1;\r
+  } else {\r
+    ReturnValue = 0;\r
+  }\r
+\r
+  free (FileBuffer);\r
+  fclose (OutputFile);\r
+  return ReturnValue;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h
new file mode 100644 (file)
index 0000000..7f88be2
--- /dev/null
@@ -0,0 +1,43 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenCRC32Section.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenFfsFile. Mainly defines the header of section\r
+  header for CRC32 GUID defined sections. Share with GenSection.c\r
+\r
+--*/\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_CRC32_SECTION_H\r
+#define _EFI_GEN_CRC32_SECTION_H\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+#include "TianoCommon.h"\r
+#include "EfiImageFormat.h"\r
+\r
+typedef struct {\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT32                    CRC32Checksum;\r
+} CRC32_SECTION_HEADER;\r
+\r
+#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
+#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile
new file mode 100644 (file)
index 0000000..f6c07f7
--- /dev/null
@@ -0,0 +1,85 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=GenCRC32Section\r
+\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenCRC32Section.c"\r
+TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \\r
+                     "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \\r
+                     "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \\r
+                     "$(EDK_TOOLS_COMMON)\ParseInf.h"\r
+TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS) $(TARGET_DLL)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB)  $(TARGET_EXE_LIBS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c
new file mode 100644 (file)
index 0000000..5cd1533
--- /dev/null
@@ -0,0 +1,890 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DepexParser.c\r
+\r
+Abstract:\r
+\r
+  Validate Dependency Expression syntax\r
+  recursive descent Algorithm\r
+\r
+  The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification \r
+  draft review 0.9") is thus:\r
+       <depex>    ::= BEFORE <guid> END\r
+                    | AFTER <guid> END\r
+                    | SOR <bool> END\r
+                    | <bool> END    \r
+       <bool>     ::= <bool> AND <term> \r
+                    | <bool> OR <term>  \r
+                    | <term>            \r
+       <term>     ::= NOT <factor>      \r
+                    | <factor>          \r
+       <factor>   ::= <bool>            \r
+                    | TRUE \r
+                    | FALSE \r
+                    | GUID\r
+\r
+       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
+       <hex32>    ::= <hexprefix> <hexvalue>\r
+       <hex16>    ::= <hexprefix> <hexvalue>\r
+       <hex8>     ::= <hexprefix> <hexvalue>\r
+       <hexprefix>::= '0' 'x'\r
+                    | '0' 'X'\r
+       <hexvalue> ::= <hexdigit> <hexvalue>\r
+                    | <hexdigit>\r
+       <hexdigit> ::= [0-9]\r
+                    | [a-f]\r
+                    | [A-F]\r
+\r
+  After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus:\r
+       <depex>    ::= BEFORE <guid>\r
+                    | AFTER <guid>\r
+                    | SOR <bool>\r
+                    | <bool>\r
+       <bool>     ::= <term><rightbool>\r
+       <rightbool>::= AND <term><rightbool>\r
+                    | OR <term><rightbool>\r
+                    | ''\r
+       <term>     ::= NOT <factor>\r
+                    | <factor>\r
+       <factor>   ::= '('<bool>')'<rightfactor>\r
+                    | NOT <factor> <rightbool> <rightfactor>\r
+                    | TRUE <rightfactor>\r
+                    | FALSE <rightfactor>\r
+                    | END <rightfactor>\r
+                    | <guid> <rightfactor>                    \r
+       <rightfactor> ::=AND <term><rightbool> <rightfactor>   \r
+                    | OR <term><rightbool> <rightfactor>                 \r
+                    | ''\r
+       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
+       <hex32>    ::= <hexprefix> <hexvalue>\r
+       <hex16>    ::= <hexprefix> <hexvalue>\r
+       <hex8>     ::= <hexprefix> <hexvalue>\r
+       <hexprefix>::= '0' 'x'\r
+                    | '0' 'X'\r
+       <hexvalue> ::= <hexdigit> <hexvalue>\r
+                    | <hexdigit>\r
+       <hexdigit> ::= [0-9]\r
+                    | [a-f]\r
+                    | [A-F]\r
\r
+  Note: 1. There's no precedence in operators except parentheses;\r
+        2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid.\r
+           Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit.\r
+        3. "<factor>   ::= '('<bool>')'<rightfactor>" is added to support parentheses;\r
+        4. "<factor>   ::= GUID" is changed to "<factor>   ::= <guid>";\r
+        5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller. \r
+           During parsing, "DEPENDENCY_END" will be treated as illegal factor;\r
+    \r
+  This code should build in any environment that supports a standard C-library w/ string\r
+  operations and File I/O services.\r
+\r
+  As an example of usage, consider the following:\r
+\r
+  The input string could be something like: \r
+    \r
+      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
+        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
+        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
+        0x3f, 0xc1, 0x4d } AND\r
+\r
+  It's invalid for an extra "AND" in the end.\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001.\r
+\r
+--*/\r
+\r
+#include "DepexParser.h"\r
+\r
+BOOLEAN\r
+ParseBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseTerm (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseRightBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+VOID\r
+LeftTrim (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Left trim the space, '\n' and '\r' character in string.\r
+  The space at the end does not need trim.\r
+\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+\r
+--*/\r
+{\r
+  while\r
+  (\r
+    ((*Pindex) < (Pbegin + length)) &&\r
+    ((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0))\r
+  ) {\r
+    (*Pindex)++;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHexdigit (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex bit in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex bit, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  //\r
+  // <hexdigit> ::= [0-9] | [a-f] | [A-F]\r
+  //\r
+  if (((**Pindex) >= '0' && (**Pindex) <= '9') ||\r
+      ((**Pindex) >= 'a' && (**Pindex) <= 'f') ||\r
+      ((**Pindex) >= 'A' && (**Pindex) <= 'F')\r
+      ) {\r
+    (*Pindex)++;\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex32 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex32 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of point to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex32, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 8) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex16 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex16 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex16, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  int   Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 4) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex8 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex8 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex8, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  int   Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 2) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseGuid (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse guid in dependency expression.\r
+  There can be any number of spaces between '{' and hexword, ',' and hexword, \r
+  hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid guid, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT8  *Pin;\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "{", 1) != 0) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex)++;\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (!ParseHex32 (Pbegin, length, Pindex)) {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, ",", 1) != 0) {\r
+    return FALSE;\r
+  } else {\r
+    (*Pindex)++;\r
+  }\r
+\r
+  for (Index = 0; Index < 2; Index++) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (!ParseHex16 (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (strncmp (*Pindex, ",", 1) != 0) {\r
+      return FALSE;\r
+    } else {\r
+      (*Pindex)++;\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < 7; Index++) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (!ParseHex8 (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (strncmp (*Pindex, ",", 1) != 0) {\r
+      return FALSE;\r
+    } else {\r
+      (*Pindex)++;\r
+    }\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (!ParseHex8 (Pbegin, length, Pindex)) {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "}", 1) != 0) {\r
+    return FALSE;\r
+  } else {\r
+    (*Pindex)++;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseRightFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse rightfactor in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid rightfactor expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <rightfactor> ::=AND <term> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+    *Pindex += strlen (OPERATOR_AND);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightfactor> ::=OR <term> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+    *Pindex += strlen (OPERATOR_OR);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightfactor> ::= ''\r
+  //\r
+  *Pindex = Pin;\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseRightBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse rightbool in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid rightbool expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <rightbool>::= AND <term><rightbool>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+    *Pindex += strlen (OPERATOR_AND);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        return TRUE;\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightbool>::=  OR <term><rightbool>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+    *Pindex += strlen (OPERATOR_OR);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        return TRUE;\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightbool>::= ''\r
+  //\r
+  *Pindex = Pin;\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse factor in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid factor, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <factor>   ::= '('<bool>')'<rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
+    *Pindex += strlen (OPERATOR_LEFT_PARENTHESIS);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseBool (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+    } else {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
+        *Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
+        LeftTrim (Pbegin, length, Pindex);\r
+\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= NOT <factor> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+    *Pindex += strlen (OPERATOR_NOT);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseFactor (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= TRUE <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
+    *Pindex += strlen (OPERATOR_TRUE);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= FALSE <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
+    *Pindex += strlen (OPERATOR_FALSE);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= <guid> <rightfactor>\r
+  //\r
+  if (ParseGuid (Pbegin, length, Pindex)) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseTerm (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse term in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid term, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <term>     ::= NOT <factor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+    *Pindex += strlen (OPERATOR_NOT);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseFactor (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  }\r
+  //\r
+  // <term>     ::=<factor>\r
+  //\r
+  if (ParseFactor (Pbegin, length, Pindex)) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid bool expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if (ParseTerm (Pbegin, length, Pindex)) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseRightBool (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseDepex (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse whole dependency expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid dependency expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  BOOLEAN Result;\r
+  INT8    **Pindex;\r
+  INT8    *temp;\r
+\r
+  Result  = FALSE;\r
+  temp    = Pbegin;\r
+  Pindex  = &temp;\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_BEFORE);\r
+    Result = ParseGuid (Pbegin, length, Pindex);\r
+\r
+  } else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_AFTER);\r
+    Result = ParseGuid (Pbegin, length, Pindex);\r
+\r
+  } else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_SOR);\r
+    Result = ParseBool (Pbegin, length, Pindex);\r
+\r
+  } else {\r
+    Result = ParseBool (Pbegin, length, Pindex);\r
+\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length));\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h
new file mode 100644 (file)
index 0000000..29e0884
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  \r
+          GenDepex.h\r
+\r
+  Abstract:\r
+          This file contains the relevant declarations required\r
+          to generate a binary Dependency File\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+// TODO: fix comment to set correct module name: DepexParser.h\r
+#ifndef _EFI_DEPEX_PARSER_H_\r
+#define _EFI_DEPEX_PARSER_H_\r
+#include "GenDepex.h"\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
new file mode 100644 (file)
index 0000000..cebcc01
--- /dev/null
@@ -0,0 +1,912 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenDepex.c\r
+\r
+Abstract:\r
+\r
+  Generate Dependency Expression ("GenDepex")\r
+\r
+  Infix to Postfix Algorithm\r
+\r
+  This code has been scrubbed to be free of having any EFI core tree dependencies.\r
+  It should build in any environment that supports a standard C-library w/ string\r
+  operations and File I/O services.\r
+\r
+  As an example of usage, consider the following:\r
+\r
+  The input user file could be something like "Sample.DXS" whose contents are\r
+\r
+    #include "Tiano.h"\r
+\r
+    DEPENDENCY_START\r
+      NOT (DISK_IO_PROTOCOL AND SIMPLE_FILE_SYSTEM_PROTOCOL) \r
+        OR EFI_PXE_BASE_CODE_PROTOCOL\r
+    DEPENDENCY_END\r
+\r
+  This file is then washed through the C-preprocessor, viz.,\r
+\r
+    cl /EP Sample.DXS > Sample.TMP1\r
+\r
+  This yields the following file "Sample.TMP1" whose contents are\r
+\r
+    DEPENDENCY_START\r
+      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
+        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
+        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
+        0x3f, 0xc1, 0x4d }\r
+    DEPENDENCY_END\r
+\r
+  This file, in turn, will be fed into the utility, viz.,\r
+\r
+    GenDepex Sample.TMP1 Sample.TMP2\r
+\r
+  With a file that is 55 bytes long:\r
+\r
+     55 bytes for the grammar binary\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        AND opcode          - 1  byte\r
+        NOT opcode          - 1  byte\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        OR opcode           - 1  byte\r
+        END opcode          - 1  byte\r
+\r
+  The file "Sample.TMP2" could be fed via a Section-builder utility \r
+  (GenSection) that would be used for the creation of a dependency\r
+  section file (.DPX) which in turn would be used by a generate FFS\r
+  utility (GenFfsFile) to produce a DXE driver/core (.DXE) or \r
+  a DXE application (.APP) file.\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+#include "GenDepex.h"\r
+\r
+#define TOOL_NAME "GenDepex"\r
+\r
+extern\r
+BOOLEAN\r
+ParseDepex (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length\r
+  );\r
+\r
+VOID\r
+PrintGenDepexUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+  printf ("Copyright (C) 1996-2002 Intel Corporation.  All rights reserved.\n\n");\r
+}\r
+\r
+VOID\r
+PrintGenDepexUsageInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",\r
+    UTILITY_NAME\r
+    );\r
+  printf (" Where:\n");\r
+  printf ("  <INFILE> is the input pre-processed dependency text files name.\n");\r
+  printf ("  <OUTFILE> is the output binary dependency files name.\n");\r
+  printf ("  <Optional Boundary for padding up> is the padding integer value.\n");\r
+  printf ("    This is the boundary to align the output file size to.\n");\r
+}\r
+\r
+DEPENDENCY_OPCODE\r
+PopOpCode (\r
+  IN OUT VOID **Stack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pop an element from the Opcode stack.\r
+\r
+Arguments:\r
+\r
+  Stack               Current top of the OpCode stack location\r
+\r
+Returns:\r
+\r
+  DEPENDENCY_OPCODE   OpCode at the top of the OpCode stack.\r
+  Stack               New top of the OpCode stack location\r
+\r
+\r
+--*/\r
+{\r
+  DEPENDENCY_OPCODE *OpCodePtr;\r
+\r
+  OpCodePtr = *Stack;\r
+  OpCodePtr--;\r
+  *Stack = OpCodePtr;\r
+  return *OpCodePtr;\r
+}\r
+\r
+VOID\r
+PushOpCode (\r
+  IN OUT  VOID                **Stack,\r
+  IN      DEPENDENCY_OPCODE   OpCode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Push an element onto the Opcode Stack\r
+\r
+Arguments:\r
+\r
+  Stack     Current top of the OpCode stack location\r
+  OpCode    OpCode to push onto the stack\r
+\r
+Returns:\r
+\r
+  Stack     New top of the OpCode stack location\r
+\r
+--*/\r
+{\r
+  DEPENDENCY_OPCODE *OpCodePtr;\r
+\r
+  OpCodePtr   = *Stack;\r
+  *OpCodePtr  = OpCode;\r
+  OpCodePtr++;\r
+  *Stack = OpCodePtr;\r
+}\r
+\r
+EFI_STATUS\r
+GenerateDependencyExpression (\r
+  IN     FILE           *InFile,\r
+  IN OUT FILE           *OutFile,\r
+  IN     UINT8          Padding  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This takes the pre-compiled dependency text file and \r
+  converts it into a binary dependency file.\r
+\r
+  The BNF for the dependency expression is as follows \r
+  (from the DXE 1.0 Draft specification).\r
+\r
+  The inputted BNF grammar is thus:\r
+    <depex> ::= sor <dep> | \r
+                before GUID <dep> | \r
+                after GUID <dep> | \r
+                <bool>\r
+\r
+    <dep> ::=   <bool> |\r
+\r
+    <bool> ::=  <bool> and <term> | \r
+                <bool> or <term> | \r
+                <term>\r
+\r
+    <term> ::=  not <factor> | \r
+                <factor>\r
+\r
+    <factor> ::= ( <bool> ) | \r
+                 <term> <term> | \r
+                 GUID | \r
+                 <boolval>\r
+\r
+    <boolval> ::= true | \r
+                  false\r
+\r
+  The outputed binary grammer is thus:\r
+    <depex> ::= sor <dep> | \r
+                before <depinst> <dep> | \r
+                after <depinst> <dep> | \r
+                <bool>\r
+\r
+    <dep> ::=   <bool> |\r
+\r
+    <bool> ::=  <bool> and <term> | \r
+                <bool> or <term> | <term>\r
+\r
+    <term> ::=  not <factor> | \r
+                <factor>\r
+\r
+    <factor> ::= ( <bool> ) | \r
+                 <term> <term> | \r
+                 <boolval> | \r
+                 <depinst> | \r
+                 <termval>\r
+\r
+    <boolval> ::= true | \r
+                  false\r
+\r
+    <depinst> ::= push GUID\r
+\r
+    <termval> ::= end\r
+\r
+  BugBug: A correct grammer is parsed correctly. A file that violates the\r
+          grammer may parse when it should generate an error. There is some\r
+          error checking and it covers most of the case when it's an include\r
+          of definition issue. An ill formed expresion may not be detected.\r
+\r
+Arguments:\r
+\r
+  InFile -  Input pre-compiled text file of the dependency expression.\r
+            This needs to be in ASCII.\r
+            The file pointer can not be NULL.\r
+\r
+  OutFile - Binary dependency file.\r
+            The file pointer can not be NULL.\r
+\r
+  Padding - OPTIONAL integer value to pad the output file to.\r
+\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the parameters in the text file was invalid.\r
+  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
+  EFI_ABORTED             An misc error occurred.\r
+\r
+--*/\r
+{\r
+  INT8              *Ptrx;\r
+  INT8              *Pend;\r
+  INT8              *EvaluationStack;\r
+  INT8              *StackPtr;\r
+  INT8              *Buffer;\r
+  INT8              Line[LINESIZE];\r
+  UINTN             Index;\r
+  UINTN             OutFileSize;\r
+  UINTN             FileSize;\r
+  UINTN             Results;\r
+  BOOLEAN           NotDone;\r
+  BOOLEAN           Before_Flag;\r
+  BOOLEAN           After_Flag;\r
+  BOOLEAN           Dep_Flag;\r
+  BOOLEAN           SOR_Flag;\r
+  EFI_GUID          Guid;\r
+  UINTN             ArgCountParsed;\r
+  DEPENDENCY_OPCODE Opcode;\r
+\r
+  Before_Flag = FALSE;\r
+  After_Flag  = FALSE;\r
+  Dep_Flag    = FALSE;\r
+  SOR_Flag    = FALSE;\r
+\r
+  memset (Line, 0, LINESIZE);\r
+\r
+  OutFileSize     = 0;\r
+\r
+  EvaluationStack = (INT8 *) malloc (EVAL_STACK_SIZE);\r
+\r
+  if (EvaluationStack != NULL) {\r
+    StackPtr = EvaluationStack;\r
+  } else {\r
+    printf ("Unable to allocate memory to EvaluationStack - Out of resources\n");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Results = (UINTN) fseek (InFile, 0, SEEK_END);\r
+\r
+  if (Results != 0) {\r
+    printf ("FSEEK failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  FileSize = ftell (InFile);\r
+\r
+  if (FileSize == -1L) {\r
+    printf ("FTELL failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Buffer = (INT8 *) malloc (FileSize + BUFFER_SIZE);\r
+\r
+  if (Buffer == NULL) {\r
+    printf ("Unable to allocate memory to Buffer - Out of resources\n");\r
+    free (EvaluationStack);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Results = (UINTN) fseek (InFile, 0, SEEK_SET);\r
+\r
+  if (Results != 0) {\r
+    printf ("FSEEK failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  fread (Buffer, FileSize, 1, InFile);\r
+\r
+  Ptrx    = Buffer;\r
+  Pend    = Ptrx + FileSize - strlen (DEPENDENCY_END);\r
+  Index   = FileSize;\r
+\r
+  NotDone = TRUE;\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (strncmp (Pend, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
+      NotDone = FALSE;\r
+    } else {\r
+      Pend--;\r
+    }\r
+  }\r
+\r
+  if (NotDone) {\r
+    printf ("Couldn't find end string %s\n", DEPENDENCY_END);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Index   = FileSize;\r
+\r
+  NotDone = TRUE;\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (strncmp (Ptrx, DEPENDENCY_START, strlen (DEPENDENCY_START)) == 0) {\r
+      Ptrx += strlen (DEPENDENCY_START);\r
+      NotDone = FALSE;\r
+      //\r
+      // BUGBUG -- should Index be decremented by sizeof(DEPENDENCY_START)?\r
+      //\r
+    } else {\r
+      Ptrx++;\r
+    }\r
+  }\r
+\r
+  if (NotDone) {\r
+    printf ("Couldn't find start string %s\n", DEPENDENCY_START);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  //  validate the syntax of expression\r
+  //\r
+  if (!ParseDepex (Ptrx, Pend - Ptrx - 1)) {\r
+    printf ("The syntax of expression is wrong\n");\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  NotDone = TRUE;\r
+\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (*Ptrx == ' ') {\r
+      Ptrx++;\r
+    } else if (*Ptrx == '\n' || *Ptrx == '\r') {\r
+      Ptrx++;\r
+    } else if (strncmp (Ptrx, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("A BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("An AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("Another SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The Schedule On Request - SOR operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        //\r
+        //  BUGBUG - This was not in the spec but is in the CORE code\r
+        //  An OPERATOR_SOR has to be first - following the DEPENDENCY_START\r
+        //\r
+        fputc (EFI_DEP_SOR, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += strlen (OPERATOR_SOR);\r
+        SOR_Flag = TRUE;\r
+\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("Another BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("An AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("A SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The BEFORE operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        fputc (EFI_DEP_BEFORE, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += strlen (OPERATOR_BEFORE);\r
+        Before_Flag = TRUE;\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("A BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("Another AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("A SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The AFTER operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        fputc (EFI_DEP_AFTER, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += strlen (OPERATOR_AFTER);\r
+        Dep_Flag    = TRUE;\r
+        After_Flag  = TRUE;\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_AND);\r
+      Ptrx += strlen (OPERATOR_AND);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_OR);\r
+      Ptrx += strlen (OPERATOR_OR);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_NOT);\r
+      Ptrx += strlen (OPERATOR_NOT);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (*Ptrx == '\t') {\r
+\r
+      printf ("File contains tabs. This violates the coding standard\n");\r
+      return EFI_INVALID_PARAMETER;\r
+\r
+    } else if (*Ptrx == '\n') {\r
+      //\r
+      // Skip the newline character in the file\r
+      //\r
+      Ptrx++;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
+      PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+\r
+      Ptrx += strlen (OPERATOR_LEFT_PARENTHESIS);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          break;\r
+        }\r
+      }\r
+\r
+      Ptrx += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
+\r
+      fputc (EFI_DEP_TRUE, OutFile);\r
+\r
+      OutFileSize++;\r
+\r
+      //\r
+      // OutFileSize += sizeof (EFI_DEP_TRUE);\r
+      //\r
+      Dep_Flag = TRUE;\r
+\r
+      Ptrx += strlen (OPERATOR_TRUE);\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
+\r
+      fputc (EFI_DEP_FALSE, OutFile);\r
+\r
+      OutFileSize++;\r
+\r
+      //\r
+      // OutFileSize += sizeof (EFI_DEP_FALSE);\r
+      //\r
+      Dep_Flag = TRUE;\r
+\r
+      Ptrx += strlen (OPERATOR_FALSE);\r
+\r
+    } else if (*Ptrx == '{') {\r
+      Ptrx++;\r
+\r
+      if (*Ptrx == ' ') {\r
+        Ptrx++;\r
+      }\r
+\r
+      ArgCountParsed = sscanf (\r
+                        Ptrx,\r
+                        "%x, %x, %x, %x, %x, %x, %x, %x, %x, %x, %x",\r
+                        &Guid.Data1,\r
+                        &Guid.Data2,\r
+                        &Guid.Data3,\r
+                        &Guid.Data4[0],\r
+                        &Guid.Data4[1],\r
+                        &Guid.Data4[2],\r
+                        &Guid.Data4[3],\r
+                        &Guid.Data4[4],\r
+                        &Guid.Data4[5],\r
+                        &Guid.Data4[6],\r
+                        &Guid.Data4[7]\r
+                        );\r
+\r
+      if (ArgCountParsed != 11) {\r
+        printf ("We have found an illegal GUID\n");\r
+        printf ("Fix your depex\n");\r
+        exit (-1);\r
+      }\r
+\r
+      while (*Ptrx != '}') {\r
+        Ptrx++;\r
+      }\r
+      //\r
+      // Absorb the closing }\r
+      //\r
+      Ptrx++;\r
+\r
+      //\r
+      // Don't provide a PUSH Opcode for the Before and After case\r
+      //\r
+      if ((!Before_Flag) && (!After_Flag)) {\r
+        fputc (EFI_DEP_PUSH, OutFile);\r
+        OutFileSize++;\r
+      }\r
+\r
+      fwrite (&Guid, sizeof (EFI_GUID), 1, OutFile);\r
+\r
+      OutFileSize += sizeof (EFI_GUID);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
+      NotDone = FALSE;\r
+    } else {\r
+      //\r
+      // Not a valid construct. Null terminate somewhere out there and\r
+      // print an error message.\r
+      //\r
+      *(Ptrx + 20) = 0;\r
+      printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  //  DRAIN();\r
+  //\r
+  while (StackPtr != EvaluationStack) {\r
+    fputc (PopOpCode ((VOID **) &StackPtr), OutFile);\r
+    OutFileSize++;\r
+  }\r
+\r
+  if (OutFileSize == 0) {\r
+    printf ("Grammer contains no operators or constants\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  fputc (EFI_DEP_END, OutFile);\r
+\r
+  OutFileSize++;\r
+\r
+  //\r
+  //  Checks for invalid padding values\r
+  //\r
+  if (Padding < 0) {\r
+\r
+    printf ("The inputted padding value was %d\n", Padding);\r
+    printf ("The optional padding value can not be less than ZERO\n");\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  } else if (Padding > 0) {\r
+\r
+    while ((OutFileSize % Padding) != 0) {\r
+\r
+      fputc (' ', OutFile);\r
+      OutFileSize++;\r
+    }\r
+  }\r
+\r
+  Results = (UINTN) fclose (InFile);\r
+  if (Results != 0) {\r
+    printf ("FCLOSE failed\n");\r
+  }\r
+\r
+  Results = (UINTN) fclose (OutFile);\r
+  if (Results != 0) {\r
+    printf ("FCLOSE failed\n");\r
+  }\r
+\r
+  free (Buffer);\r
+  free (EvaluationStack);\r
+\r
+  return EFI_SUCCESS;\r
+} // End GenerateDependencyExpression function\r
+\r
+EFI_STATUS\r
+main (\r
+  IN UINTN argc,\r
+  IN CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse user entries.  Print some rudimentary help\r
+\r
+Arguments:\r
+\r
+  argc    The count of input arguments\r
+  argv    The input arguments string array\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the input parameters was invalid or one of the parameters in the text file was invalid.\r
+  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
+  EFI_ABORTED             Unable to open/create a file or a misc error.\r
+\r
+--*/\r
+// TODO:    ] - add argument and description to function comment\r
+{\r
+  FILE    *OutFile;\r
+  FILE    *InFile;\r
+  UINT8   Padding;\r
+  UINTN   Index;\r
+  BOOLEAN Input_Flag;\r
+  BOOLEAN Output_Flag;\r
+  BOOLEAN Pad_Flag;\r
+\r
+  InFile      = NULL;\r
+  OutFile     = NULL;\r
+  Padding     = 0;\r
+  Input_Flag  = FALSE;\r
+  Output_Flag = FALSE;\r
+  Pad_Flag    = FALSE;\r
+\r
+  //\r
+  //  Output the calling arguments\r
+  //\r
+  printf ("\n\n");\r
+  for (Index = 0; Index < argc; Index++) {\r
+    printf ("%s ", argv[Index]);\r
+  }\r
+\r
+  printf ("\n\n");\r
+\r
+  if (argc < 5) {\r
+    printf ("Not enough arguments\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Index = 1; Index < argc - 1; Index++) {\r
+\r
+    if ((strcmp (argv[Index], "-I") == 0) || (strcmp (argv[Index], "-i") == 0)) {\r
+\r
+      if (!Input_Flag) {\r
+\r
+        InFile      = fopen (argv[Index + 1], "rb");\r
+        Input_Flag  = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one INPUT (-I) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+\r
+    } else if ((strcmp (argv[Index], "-O") == 0) || (strcmp (argv[Index], "-o") == 0)) {\r
+\r
+      if (!Output_Flag) {\r
+\r
+        OutFile     = fopen (argv[Index + 1], "wb");\r
+        Output_Flag = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one OUTPUT (-O) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+\r
+    } else if ((strcmp (argv[Index], "-P") == 0) || (strcmp (argv[Index], "-p") == 0)) {\r
+\r
+      if (!Pad_Flag) {\r
+\r
+        Padding   = (UINT8) atoi (argv[Index + 1]);\r
+        Pad_Flag  = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one PADDING (-P) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+    }\r
+  }\r
+\r
+  PrintGenDepexUtilityInfo ();\r
+\r
+  if (InFile == NULL) {\r
+    printf ("Can not open <INFILE> for reading.\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  if (OutFile == NULL) {\r
+    printf ("Can not open <OUTFILE> for writting.\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return GenerateDependencyExpression (InFile, OutFile, Padding);\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
new file mode 100644 (file)
index 0000000..d9df5fa
--- /dev/null
@@ -0,0 +1,67 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  \r
+          GenDepex.h\r
+\r
+  Abstract:\r
+          This file contains the relevant declarations required\r
+          to generate a binary Dependency File\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_DEPEX_H\r
+#define _EFI_GEN_DEPEX_H\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiDependency.h"\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <memory.h>\r
+#include <string.h>\r
+#include <malloc.h>\r
+\r
+#define DEPENDENCY_START            "DEPENDENCY_START"\r
+#define OPERATOR_BEFORE             "BEFORE"\r
+#define OPERATOR_AFTER              "AFTER"\r
+#define OPERATOR_AND                "AND"\r
+#define OPERATOR_OR                 "OR"\r
+#define OPERATOR_NOT                "NOT"\r
+#define OPERATOR_TRUE               "TRUE"\r
+#define OPERATOR_FALSE              "FALSE"\r
+#define OPERATOR_SOR                "SOR"\r
+#define OPERATOR_END                "END"\r
+#define OPERATOR_LEFT_PARENTHESIS   "("\r
+#define OPERATOR_RIGHT_PARENTHESIS  ")"\r
+#define DEPENDENCY_END              "DEPENDENCY_END"\r
+\r
+#define DXE_DEP_LEFT_PARENTHESIS    0x0a\r
+#define DXE_DEP_RIGHT_PARENTHESIS   0x0b\r
+\r
+#define LINESIZE                    320\r
+#define SIZE_A_SYMBOL               60\r
+#define DEPENDENCY_OPCODE           UINT8\r
+#define EVAL_STACK_SIZE             0x1024\r
+#define BUFFER_SIZE                 0x100\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "GenDepex"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 4\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile
new file mode 100644 (file)
index 0000000..4faceb1
--- /dev/null
@@ -0,0 +1,100 @@
+#/*++\r
+#   \r
+# Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=GenDepex\r
+TARGET_LIB_NAME=DepexParser\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_LIB = $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).lib\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_LIB_SOURCE = "$(TARGET_SOURCE_DIR)\DepexParser.c"\r
+TARGET_LIB_INCLUDE = "$(TARGET_SOURCE_DIR)\DepexParser.h"\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenDepex.c"\r
+TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h"\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+#\r
+# Build LIB\r
+#\r
+\r
+$(TARGET_LIB): $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj \r
+  $(LIB_EXE) $(LIB_FLAGS) $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj /OUT:$(TARGET_LIB)\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj:  $(TARGET_LIB_SOURCE) $(TARGET_LIB_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_LIB_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
new file mode 100644 (file)
index 0000000..188ca77
--- /dev/null
@@ -0,0 +1,2681 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFfsFile.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware File System\r
+  file.\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "EfiFirmwareVolumeHeader.h"\r
+#include "EfiImageFormat.h"\r
+#include "ParseInf.h"\r
+#include "Compress.h"\r
+#include "EfiCustomizedCompress.h"\r
+#include "crc32.h"\r
+#include "GenFfsFile.h"\r
+#include <stdio.h>\r
+#include <ctype.h>  // for isalpha()\r
+//\r
+// include file for _spawnv\r
+//\r
+#include <process.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "SimpleFileParsing.h"\r
+\r
+#define UTILITY_NAME    "GenFfsFile"\r
+#define TOOLVERSION     "0.32"\r
+#define MAX_ARRAY_SIZE  100\r
+\r
+static\r
+INT32\r
+GetNextLine (\r
+  OUT CHAR8       *Destination,\r
+  IN FILE         *Package,\r
+  IN OUT UINT32   *LineNumber\r
+  );\r
+\r
+static\r
+void\r
+CheckSlash (\r
+  IN OUT CHAR8  *String,\r
+  IN FILE       *In,\r
+  IN OUT UINT32 *LineNumber\r
+  );\r
+\r
+static\r
+INT32\r
+FindSectionInPackage (\r
+  IN CHAR8        *BuildDirectory,\r
+  IN FILE         *OverridePackage,\r
+  IN OUT UINT32   *LineNumber\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCommandLineArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+PrintUsage (\r
+  void\r
+  );\r
+\r
+//\r
+// Keep globals in this structure\r
+//\r
+static struct {\r
+  UINT8   BuildDirectory[_MAX_PATH];\r
+  UINT8   PrimaryPackagePath[_MAX_PATH];\r
+  UINT8   OverridePackagePath[_MAX_PATH];\r
+  BOOLEAN Verbose;\r
+} mGlobals;\r
+\r
+static EFI_GUID mZeroGuid = { 0 };\r
+\r
+static\r
+void\r
+StripQuotes (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes quotes and/or whitespace from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove quotes from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index2;\r
+  UINTN StrLen;\r
+\r
+  Index2  = strspn (String, "\" \t\n");\r
+  StrLen  = strlen (String);\r
+\r
+  for (Index = Index2; String[Index] != '\"', Index < StrLen; Index++) {\r
+    String[Index - Index2] = String[Index];\r
+  }\r
+\r
+  String[Index - Index2] = 0;\r
+}\r
+\r
+static\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print Error / Help message.\r
+\r
+Arguments:\r
+\r
+  void\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage:\n");\r
+  printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n");\r
+  printf ("   -b \"build directory\":\n ");\r
+  printf ("       specifies the full path to the component build directory.\n");\r
+  printf ("   -p1 \"P1_path\":\n");\r
+  printf ("       specifies fully qualified file name to the primary package file.\n");\r
+  printf ("       This file will normally exist in the same directory as the makefile\n");\r
+  printf ("       for the component. Required.\n");\r
+  printf ("   -p2 \"P2_path\":\n");\r
+  printf ("       specifies fully qualified file name to the override package file.\n");\r
+  printf ("       This file will normally exist in the build tip. Optional.\n");\r
+}\r
+\r
+static\r
+INT32\r
+TestComment (\r
+  IN CHAR8  *String,\r
+  IN FILE   *In\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  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\r
+\r
+Arguments:\r
+\r
+  String      - String to test\r
+\r
+  In          - Open file to move pointer within\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Not a comment\r
+   1          - Comment bypassed\r
+\r
+--*/\r
+{\r
+  CHAR8 CharBuffer;\r
+\r
+  CharBuffer = 0;\r
+  if ((String[0] == '/') && (String[1] == '/')) {\r
+    while (CharBuffer != '\n') {\r
+      fscanf (In, "%c", &CharBuffer);\r
+      if (feof (In)) {\r
+        return -1;\r
+      }\r
+    }\r
+  } else {\r
+    return 0;\r
+  }\r
+\r
+  return 1;\r
+}\r
+\r
+static\r
+void\r
+BreakString (\r
+  IN CONST CHAR8 *Source,\r
+  OUT CHAR8      *Destination,\r
+  IN INTN        Direction\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Takes an input string and returns either the part before the =, or the part after the =, depending on direction\r
+\r
+Arguments:\r
+\r
+  Source      - String to break\r
+\r
+  Destination - Buffer to place new string in\r
+\r
+  Direction   - 0 to return all of source string before =\r
+                1 to return all of source string after =\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index2;\r
+\r
+  Index   = 0;\r
+  Index2  = 0;\r
+\r
+  if (strchr (Source, '=') == NULL) {\r
+    strcpy (Destination, Source);\r
+\r
+    return ;\r
+  }\r
+\r
+  if (Direction == 0) {\r
+    //\r
+    // return part of string before =\r
+    //\r
+    while (Source[Index] != '=') {\r
+      Destination[Index] = Source[Index++];\r
+    }\r
+\r
+    Destination[Index] = 0;\r
+  } else {\r
+    //\r
+    // return part of string after =\r
+    //\r
+    strcpy (Destination, strchr (Source, '=') + 1);\r
+  }\r
+}\r
+\r
+static\r
+INT32\r
+GetNextLine (\r
+  OUT CHAR8       *Destination,\r
+  IN FILE         *Package,\r
+  IN OUT UINT32   *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Gets the next non-commented line from the file\r
+\r
+Arguments:\r
+\r
+  Destination - Where to put string\r
+\r
+  Package     - Package to get string from\r
+  \r
+  LineNumber  - The actual line number.\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Success\r
+\r
+--*/\r
+{\r
+  CHAR8 String[_MAX_PATH];\r
+  fscanf (Package, "%s", &String);\r
+  if (feof (Package)) {\r
+    return -1;\r
+  }\r
+\r
+  while (TestComment (String, Package) == 1) {\r
+    fscanf (Package, "%s", &String);\r
+    if (feof (Package)) {\r
+      return -1;\r
+    }\r
+  }\r
+\r
+  strcpy (Destination, String);\r
+  return 0;\r
+}\r
+\r
+static\r
+VOID\r
+CheckSlash (\r
+  IN OUT CHAR8  *String,\r
+  IN FILE       *In,\r
+  IN OUT UINT32 *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Checks to see if string is line continuation character, if so goes to next valid line\r
+\r
+Arguments:\r
+\r
+  String      - String to test\r
+\r
+  In          - Open file to move pointer within\r
+  \r
+  LineNumber  - The line number.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 ByteBuffer;\r
+  ByteBuffer = 0;\r
+\r
+  switch (String[0]) {\r
+\r
+  case '\\':\r
+    while (String[0] == '\\') {\r
+      while (ByteBuffer != '\n') {\r
+        fscanf (In, "%c", &ByteBuffer);\r
+      }\r
+      (*LineNumber)++;\r
+      if (GetNextLine (String, In, LineNumber) == -1) {\r
+        return ;\r
+      }\r
+    }\r
+    break;\r
+\r
+  case '\n':\r
+    (*LineNumber)++;\r
+    while (String[0] == '\n') {\r
+      if (GetNextLine (String, In, LineNumber) == -1) {\r
+        return ;\r
+      }\r
+    }\r
+    break;\r
+\r
+  default:\r
+    break;\r
+\r
+  }\r
+\r
+}\r
+\r
+static\r
+INT32\r
+FindSectionInPackage (\r
+  IN CHAR8        *BuildDirectory,\r
+  IN FILE         *OverridePackage,\r
+  IN OUT UINT32   *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds the matching section within the package\r
+\r
+Arguments:\r
+\r
+  BuildDirectory  - name of section to find\r
+\r
+  OverridePackage - Package file to search within\r
+  \r
+  LineNumber      - The line number.\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Success\r
+\r
+--*/\r
+{\r
+  CHAR8 String[_MAX_PATH];\r
+  CHAR8 NewString[_MAX_PATH];\r
+  String[0] = 0;\r
+\r
+  while (strcmp (BuildDirectory, String) != 0) {\r
+    if (GetNextLine (NewString, OverridePackage, LineNumber) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (NewString[0] == '[') {\r
+      if (NewString[strlen (NewString) - 1] != ']') {\r
+        //\r
+        // have to construct string.\r
+        //\r
+        strcpy (String, NewString + 1);\r
+\r
+        while (1) {\r
+          fscanf (OverridePackage, "%s", &NewString);\r
+          if (feof (OverridePackage)) {\r
+            return -1;\r
+          }\r
+\r
+          if (NewString[0] != ']') {\r
+            if (strlen (String) != 0) {\r
+              strcat (String, " ");\r
+            }\r
+\r
+            strcat (String, NewString);\r
+            if (String[strlen (String) - 1] == ']') {\r
+              String[strlen (String) - 1] = 0;\r
+              break;\r
+            }\r
+          } else {\r
+            break;\r
+          }\r
+        }\r
+      } else {\r
+        NewString[strlen (NewString) - 1] = 0;\r
+        strcpy (String, NewString + 1);\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+EFI_STATUS\r
+GenSimpleGuidSection (\r
+  IN OUT UINT8  *FileBuffer,\r
+  IN OUT UINT32 *BufferSize,\r
+  IN UINT32     DataSize,\r
+  IN EFI_GUID   SignGuid,\r
+  IN UINT16     GuidedSectionAttributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  add GUIDed section header for the data buffer.\r
+  data stays in same location (overwrites source data).\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Buffer containing data to sign\r
+\r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
+                actual section data (including added section header).\r
+\r
+  DataSize    - Length of data to Sign\r
+\r
+  SignGuid    - Guid to be add.\r
+  \r
+  GuidedSectionAttributes - The section attribute.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Successful\r
+  EFI_OUT_OF_RESOURCES  - Not enough resource.\r
+\r
+--*/\r
+{\r
+  UINT32                    TotalSize;\r
+\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT8                     *SwapBuffer;\r
+\r
+  SwapBuffer = NULL;\r
+\r
+  if (DataSize == 0) {\r
+    *BufferSize = 0;\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  TotalSize = DataSize + sizeof (EFI_GUID_DEFINED_SECTION);\r
+  GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
+  GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
+  GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  memcpy (&(GuidSectionHeader.SectionDefinitionGuid), &SignGuid, sizeof (EFI_GUID));\r
+  GuidSectionHeader.Attributes  = GuidedSectionAttributes;\r
+  GuidSectionHeader.DataOffset  = sizeof (EFI_GUID_DEFINED_SECTION);\r
+\r
+  SwapBuffer                    = (UINT8 *) malloc (DataSize);\r
+  if (SwapBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  memcpy (SwapBuffer, FileBuffer, DataSize);\r
+  memcpy (FileBuffer, &GuidSectionHeader, sizeof (EFI_GUID_DEFINED_SECTION));\r
+  memcpy (FileBuffer + sizeof (EFI_GUID_DEFINED_SECTION), SwapBuffer, DataSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (SwapBuffer != NULL) {\r
+    free (SwapBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+static\r
+EFI_STATUS\r
+CompressSection (\r
+  UINT8  *FileBuffer,\r
+  UINT32 *BufferSize,\r
+  UINT32 DataSize,\r
+  CHAR8  *Type\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compress the data and add section header for the compressed data.\r
+  Compressed data (with section header) stays in same location as the source\r
+  (overwrites source data).\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Buffer containing data to Compress\r
+\r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
+                actual compressed data (including added section header).\r
+                When buffer is too small, this value indicates the size needed.\r
+\r
+  DataSize    - The size of data to compress\r
+\r
+  Type        - The compression type (not used currently).\r
+                Assume EFI_HEAVY_COMPRESSION.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL - Buffer size is too small.\r
+  EFI_UNSUPPORTED      - Compress type can not be supported.\r
+  EFI_SUCCESS          - Successful\r
+  EFI_OUT_OF_RESOURCES - Not enough resource.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  UINT8                   *CompData;\r
+  UINT32                  CompSize;\r
+  UINT32                  TotalSize;\r
+  EFI_COMPRESSION_SECTION CompressionSet;\r
+  UINT8                   CompressionType;\r
+  COMPRESS_FUNCTION       CompressFunction;\r
+\r
+  Status            = EFI_SUCCESS;\r
+  CompData          = NULL;\r
+  CompSize          = 0;\r
+  TotalSize         = 0;\r
+  CompressFunction  = NULL;\r
+\r
+  //\r
+  // Get the compress type\r
+  //\r
+  if (_strcmpi (Type, "Dummy") == 0) {\r
+    //\r
+    // Added "Dummy" to keep backward compatibility.\r
+    //\r
+    CompressionType   = EFI_STANDARD_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) TianoCompress;\r
+\r
+  } else if (_strcmpi (Type, "LZH") == 0) {\r
+    //\r
+    // EFI stardard compression (LZH)\r
+    //\r
+    CompressionType   = EFI_STANDARD_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) TianoCompress;\r
+\r
+  } else {\r
+    //\r
+    // Customized compression\r
+    //\r
+    Status = SetCustomizedCompressionType (Type);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    CompressionType   = EFI_CUSTOMIZED_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) CustomizedCompress;\r
+  }\r
+  //\r
+  // Compress the raw data\r
+  //\r
+  Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    CompData = malloc (CompSize);\r
+    if (!CompData) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    if (CompData != NULL) {\r
+      free (CompData);\r
+    }\r
+\r
+    return Status;\r
+  }\r
+\r
+  TotalSize = CompSize + sizeof (EFI_COMPRESSION_SECTION);\r
+\r
+  //\r
+  // Buffer too small?\r
+  //\r
+  if (TotalSize > *BufferSize) {\r
+    *BufferSize = TotalSize;\r
+    if (CompData != NULL) {\r
+      free (CompData);\r
+    }\r
+\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+  //\r
+  // Add the section header for the compressed data\r
+  //\r
+  CompressionSet.CommonHeader.Type    = EFI_SECTION_COMPRESSION;\r
+  CompressionSet.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff);\r
+  CompressionSet.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  CompressionSet.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  CompressionSet.CompressionType      = CompressionType;\r
+  CompressionSet.UncompressedLength   = DataSize;\r
+\r
+  //\r
+  // Copy header and data to the buffer\r
+  //\r
+  memcpy (FileBuffer, &CompressionSet, sizeof (EFI_COMPRESSION_SECTION));\r
+  memcpy (FileBuffer + sizeof (CompressionSet), CompData, CompSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (CompData != NULL) {\r
+    free (CompData);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+StripParens (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes Parenthesis from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove parens from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  if (String[0] != '(') {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 1; String[Index] != ')'; Index++) {\r
+    String[Index - 1] = String[Index];\r
+    if (String[Index] == 0) {\r
+      return ;\r
+    }\r
+  }\r
+\r
+  String[Index - 1] = 0;\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+void\r
+StripEqualMark (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes Equal Mark from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove equal mark from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  if (String[0] != '=' && String[strlen (String) - 1] != '=') {\r
+    return ;\r
+  }\r
+\r
+  if (String[0] == '=') {\r
+\r
+    for (Index = 1; String[Index] != 0; Index++) {\r
+      String[Index - 1] = String[Index];\r
+    }\r
+\r
+    String[Index - 1] = 0;\r
+  }\r
+\r
+  if (String[strlen (String) - 1] == '=') {\r
+    String[strlen (String) - 1] = 0;\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+INT32\r
+ProcessEnvironmentVariable (\r
+  IN CHAR8  *Buffer,\r
+  OUT CHAR8 *NewBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts environment variables to values\r
+\r
+Arguments:\r
+\r
+  Buffer      - Buffer containing Environment Variable String\r
+\r
+  NewBuffer   - Buffer containing value of environment variable\r
+\r
+\r
+Returns:\r
+\r
+  Number of characters from Buffer used\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index2;\r
+  CHAR8 VariableBuffer[_MAX_PATH];\r
+\r
+  Index   = 2;\r
+  Index2  = 0;\r
+\r
+  while (Buffer[Index] != ')') {\r
+    VariableBuffer[Index - 2] = Buffer[Index++];\r
+  }\r
+\r
+  VariableBuffer[Index - 2] = 0;\r
+  Index++;\r
+\r
+  if (getenv (VariableBuffer) != NULL) {\r
+    strcpy (NewBuffer, getenv (VariableBuffer));\r
+  } else {\r
+    printf ("Environment variable %s not found!\n", VariableBuffer);\r
+  }\r
+\r
+  return Index;\r
+}\r
+\r
+static\r
+void\r
+SplitAttributesField (\r
+  IN CHAR8       *Buffer,\r
+  IN CHAR8       *AttributesArray[],\r
+  IN OUT UINT32  *NumberOfAttributes\r
+  )\r
+/*\r
+  NumberOfAttributes: on input, it specifies the current number of attributes\r
+                      stored in AttributeArray.\r
+                      on output, it is updated to the latest number of attributes\r
+                      stored in AttributesArray.\r
+*/\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  z;\r
+  CHAR8   *CharBuffer;\r
+\r
+  CharBuffer  = NULL;\r
+  CharBuffer  = (CHAR8 *) malloc (_MAX_PATH);\r
+  ZeroMem (CharBuffer, _MAX_PATH);\r
+\r
+  for (Index = 0, z = 0, Index2 = 0; Index < strlen (Buffer); Index++) {\r
+\r
+    if (Buffer[Index] != '|') {\r
+      CharBuffer[z] = Buffer[Index];\r
+      z++;\r
+    } else {\r
+\r
+      CharBuffer[z] = 0;\r
+      AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
+      Index2++;\r
+\r
+      //\r
+      // allocate new char buffer for the next attributes string\r
+      //\r
+      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
+      ZeroMem (CharBuffer, _MAX_PATH);\r
+      z = 0;\r
+    }\r
+  }\r
+\r
+  CharBuffer[z] = 0;\r
+  //\r
+  // record the last attributes string in the Buffer\r
+  //\r
+  AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
+  Index2++;\r
+\r
+  *NumberOfAttributes += Index2;\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+INT32\r
+GetToolArguments (\r
+  CHAR8       *ToolArgumentsArray[],\r
+  FILE        *Package,\r
+  CHAR8       **PtrInputFileName,\r
+  CHAR8       **PtrOutputFileName,\r
+  EFI_GUID    *Guid,\r
+  UINT16      *GuidedSectionAttributes\r
+  )\r
+{\r
+  CHAR8       Buffer[_MAX_PATH];\r
+  BOOLEAN     ArgumentsFlag;\r
+  BOOLEAN     InputFlag;\r
+  BOOLEAN     OutputFlag;\r
+  BOOLEAN     GuidFlag;\r
+  BOOLEAN     AttributesFlag;\r
+  UINT32      argc;\r
+  UINT32      Index2;\r
+  UINT32      z;\r
+  CHAR8       *CharBuffer;\r
+  INT32       Index;\r
+  INT32       ReturnValue;\r
+  EFI_STATUS  Status;\r
+\r
+  CHAR8       *AttributesArray[MAX_ARRAY_SIZE];\r
+  UINT32      NumberOfAttributes;\r
+  CHAR8       *InputFileName;\r
+  CHAR8       *OutputFileName;\r
+  UINT32      LineNumber;\r
+  Buffer[_MAX_PATH];\r
+\r
+  ArgumentsFlag   = FALSE;\r
+  InputFlag       = FALSE;\r
+  OutputFlag      = FALSE;\r
+  GuidFlag        = FALSE;\r
+  AttributesFlag  = FALSE;\r
+  //\r
+  // Start at 1, since ToolArgumentsArray[0]\r
+  // is the program name.\r
+  //\r
+  argc            = 1;\r
+  Index2              = 0;\r
+\r
+  z                   = 0;\r
+  ReturnValue         = 0;\r
+  NumberOfAttributes  = 0;\r
+  InputFileName       = NULL;\r
+  OutputFileName      = NULL;\r
+\r
+  ZeroMem (Buffer, _MAX_PATH);\r
+  ZeroMem (AttributesArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
+  LineNumber = 0;\r
+  while (Buffer[0] != ')') {\r
+\r
+    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+      CheckSlash (Buffer, Package, &LineNumber);\r
+      StripEqualMark (Buffer);\r
+    } else {\r
+      Error (NULL, 0, 0, "failed to get next line from package file", NULL);\r
+      return -1;\r
+    }\r
+\r
+    if (Buffer[0] == ')') {\r
+      break;\r
+    } else if (_strcmpi (Buffer, "ARGS") == 0) {\r
+\r
+      ArgumentsFlag   = TRUE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (_strcmpi (Buffer, "INPUT") == 0) {\r
+\r
+      InputFlag       = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (_strcmpi (Buffer, "OUTPUT") == 0) {\r
+\r
+      OutputFlag      = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (_strcmpi (Buffer, "GUID") == 0) {\r
+\r
+      GuidFlag        = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      //\r
+      // fetch the GUID for the section\r
+      //\r
+      continue;\r
+\r
+    } else if (_strcmpi (Buffer, "ATTRIBUTES") == 0) {\r
+\r
+      AttributesFlag  = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      //\r
+      // fetch the GUIDed Section's Attributes\r
+      //\r
+      continue;\r
+\r
+    } else if (_strcmpi (Buffer, "") == 0) {\r
+      continue;\r
+    }\r
+    //\r
+    // get all command arguments into ToolArgumentsArray\r
+    //\r
+    if (ArgumentsFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (CharBuffer == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (CharBuffer, sizeof (_MAX_PATH));\r
+\r
+      ToolArgumentsArray[argc] = CharBuffer;\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], ToolArgumentsArray[argc]);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (ToolArgumentsArray[argc], &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (ToolArgumentsArray[argc], Buffer);\r
+      }\r
+\r
+      argc += 1;\r
+      ToolArgumentsArray[argc] = NULL;\r
+      continue;\r
+    }\r
+\r
+    if (InputFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      InputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (InputFileName == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (InputFileName, sizeof (_MAX_PATH));\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], InputFileName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (InputFileName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (InputFileName, Buffer);\r
+      }\r
+\r
+      InputFlag = FALSE;\r
+      continue;\r
+    }\r
+\r
+    if (OutputFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      OutputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (OutputFileName == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (OutputFileName, sizeof (_MAX_PATH));\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], OutputFileName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (OutputFileName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (OutputFileName, Buffer);\r
+      }\r
+\r
+      OutputFlag = FALSE;\r
+      continue;\r
+    }\r
+\r
+    if (GuidFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      Status = StringToGuid (Buffer, Guid);\r
+      if (EFI_ERROR (Status)) {\r
+        ReturnValue = -1;\r
+        goto ErrorExit;\r
+      }\r
+\r
+      GuidFlag = FALSE;\r
+    }\r
+\r
+    if (AttributesFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      //\r
+      // there might be no space between each attribute in the statement,\r
+      // split them aside and return each attribute string\r
+      // in the AttributesArray\r
+      //\r
+      SplitAttributesField (Buffer, AttributesArray, &NumberOfAttributes);\r
+    }\r
+  }\r
+  //\r
+  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"INPUT",InputVariable,j);\r
+  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"OUTPUT",&TargetFileName,1);\r
+  //\r
+  for (z = 0; z < NumberOfAttributes; z++) {\r
+    if (_strcmpi (AttributesArray[z], "PROCESSING_REQUIRED") == 0) {\r
+      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED;\r
+    } else if (_strcmpi (AttributesArray[z], "AUTH_STATUS_VALID") == 0) {\r
+      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+    }\r
+  }\r
+\r
+ErrorExit:\r
+\r
+  for (Index2 = 0; Index2 < MAX_ARRAY_SIZE; Index2++) {\r
+    if (AttributesArray[Index2] == NULL) {\r
+      break;\r
+    }\r
+\r
+    free (AttributesArray[Index2]);\r
+  }\r
+\r
+  *PtrInputFileName   = InputFileName;\r
+  *PtrOutputFileName  = OutputFileName;\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+static\r
+INT32\r
+ProcessScript (\r
+  IN OUT UINT8   *FileBuffer,\r
+  IN FILE        *Package,\r
+  IN CHAR8       *BuildDirectory,\r
+  IN BOOLEAN     ForceUncompress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Signs the section, data stays in same location\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Data Buffer\r
+\r
+  Package     - Points to curly brace in Image Script\r
+\r
+  BuildDirectory     - Name of the source directory parameter\r
+  \r
+  ForceUncompress   - Whether to force uncompress.\r
+\r
+Returns:\r
+\r
+  Number of bytes added to file buffer\r
+  -1 on error\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      Size;\r
+  CHAR8       Buffer[_MAX_PATH];\r
+  CHAR8       Type[_MAX_PATH];\r
+  CHAR8       FileName[_MAX_PATH];\r
+  CHAR8       NewBuffer[_MAX_PATH];\r
+  INT32       Index3;\r
+  INT32       Index2;\r
+  UINT32      ReturnValue;\r
+  UINT8       ByteBuffer;\r
+  FILE        *InFile;\r
+  UINT32      SourceDataSize;\r
+  CHAR8       *ToolArgumentsArray[MAX_ARRAY_SIZE];\r
+  CHAR8       *OutputFileName;\r
+  CHAR8       *InputFileName;\r
+  CHAR8       ToolName[_MAX_PATH];\r
+  FILE        *OutputFile;\r
+  FILE        *InputFile;\r
+  UINT8       Temp;\r
+  int         returnint;\r
+  INT32       Index;\r
+  UINT32      LineNumber;\r
+  BOOLEAN     IsError;\r
+  EFI_GUID    SignGuid;\r
+  UINT16      GuidedSectionAttributes;\r
+  UINT8       *TargetFileBuffer;\r
+\r
+  OutputFileName          = NULL;\r
+  InputFileName           = NULL;\r
+  OutputFile              = NULL;\r
+  InputFile               = NULL;\r
+  IsError                 = FALSE;\r
+  GuidedSectionAttributes = 0;\r
+  TargetFileBuffer        = NULL;\r
+\r
+  Size                    = 0;\r
+  LineNumber              = 0;\r
+  Buffer[0]               = 0;\r
+  for (Index3 = 0; Index3 < MAX_ARRAY_SIZE; ++Index3) {\r
+    ToolArgumentsArray[Index3] = NULL;\r
+  }\r
+\r
+  while (Buffer[0] != '}') {\r
+    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+      CheckSlash (Buffer, Package, &LineNumber);\r
+    } else {\r
+      printf ("ERROR in IMAGE SCRIPT!\n");\r
+      IsError = TRUE;\r
+      goto Done;\r
+    }\r
+\r
+    if (_strcmpi (Buffer, "Compress") == 0) {\r
+      //\r
+      // Handle compress\r
+      //\r
+      //\r
+      // read compression type\r
+      //\r
+      if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+        CheckSlash (Buffer, Package, &LineNumber);\r
+      }\r
+\r
+      StripParens (Buffer);\r
+      if (Buffer[0] == '$') {\r
+        ProcessEnvironmentVariable (&Buffer[0], Type);\r
+      } else {\r
+        strcpy (Type, Buffer);\r
+      }\r
+      //\r
+      // build buffer\r
+      //\r
+      while (Buffer[0] != '{') {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      ReturnValue = ProcessScript (&FileBuffer[Size], Package, BuildDirectory, ForceUncompress);\r
+      if (ReturnValue == -1) {\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // Call compress routine on buffer.\r
+      // Occasionally, compressed data + section header would\r
+      // be largere than the source and EFI_BUFFER_TOO_SMALL is\r
+      // returned from CompressSection()\r
+      //\r
+      SourceDataSize = ReturnValue;\r
+\r
+      if (!ForceUncompress) {\r
+\r
+        Status = CompressSection (\r
+                  &FileBuffer[Size],\r
+                  &ReturnValue,\r
+                  SourceDataSize,\r
+                  Type\r
+                  );\r
+\r
+        if (Status == EFI_BUFFER_TOO_SMALL) {\r
+          Status = CompressSection (\r
+                    &FileBuffer[Size],\r
+                    &ReturnValue,\r
+                    SourceDataSize,\r
+                    Type\r
+                    );\r
+        }\r
+\r
+        if (EFI_ERROR (Status)) {\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      Size += ReturnValue;\r
+\r
+    } else if (_strcmpi (Buffer, "Tool") == 0) {\r
+\r
+      ZeroMem (ToolName, _MAX_PATH);\r
+      ZeroMem (ToolArgumentsArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
+      ZeroMem (&SignGuid, sizeof (EFI_GUID));\r
+\r
+      //\r
+      // handle signing Tool\r
+      //\r
+      while (Buffer[0] != '(') {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      if (_strcmpi (Buffer, "(") == 0) {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      StripParens (Buffer);\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], ToolName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (ToolName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (ToolName, Buffer);\r
+      }\r
+\r
+      ToolArgumentsArray[0] = ToolName;\r
+\r
+      //\r
+      // read ARGS\r
+      //\r
+      if (GetToolArguments (\r
+            ToolArgumentsArray,\r
+            Package,\r
+            &InputFileName,\r
+            &OutputFileName,\r
+            &SignGuid,\r
+            &GuidedSectionAttributes\r
+            ) == -1) {\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // if the tool need input file,\r
+      // dump the file buffer to the specified input file.\r
+      //\r
+      if (InputFileName != NULL) {\r
+        InputFile = fopen (InputFileName, "wb");\r
+        if (InputFile == NULL) {\r
+          Error (NULL, 0, 0, InputFileName, "failed to open output file for writing");\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+\r
+        fwrite (FileBuffer, sizeof (UINT8), Size, InputFile);\r
+        fclose (InputFile);\r
+        InputFile = NULL;\r
+        free (InputFileName);\r
+        InputFileName = NULL;\r
+      }\r
+      //\r
+      // dispatch signing tool\r
+      //\r
+      returnint = _spawnv (_P_WAIT, ToolName, ToolArgumentsArray);\r
+      if (returnint != 0) {\r
+        Error (NULL, 0, 0, ToolName, "external tool failed");\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // if the tool has output file,\r
+      // dump the output file to the file buffer\r
+      //\r
+      if (OutputFileName != NULL) {\r
+\r
+        OutputFile = fopen (OutputFileName, "rb");\r
+        if (OutputFile == NULL) {\r
+          Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+\r
+        TargetFileBuffer  = &FileBuffer[Size];\r
+        SourceDataSize    = Size;\r
+\r
+        fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
+        while (!feof (OutputFile)) {\r
+          FileBuffer[Size++] = Temp;\r
+          fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
+        }\r
+\r
+        while ((Size & 0x03) != 0) {\r
+          FileBuffer[Size] = 0;\r
+          Size++;\r
+        }\r
+\r
+        SourceDataSize = Size - SourceDataSize;\r
+\r
+        fclose (OutputFile);\r
+        OutputFile = NULL;\r
+        free (OutputFileName);\r
+        OutputFileName = NULL;\r
+\r
+        if (CompareGuid (&SignGuid, &mZeroGuid) != 0) {\r
+          ReturnValue = SourceDataSize;\r
+          Status = GenSimpleGuidSection (\r
+                    TargetFileBuffer,\r
+                    &ReturnValue,\r
+                    SourceDataSize,\r
+                    SignGuid,\r
+                    GuidedSectionAttributes\r
+                    );\r
+          if (EFI_ERROR (Status)) {\r
+            IsError = TRUE;\r
+            goto Done;\r
+          }\r
+\r
+          Size = ReturnValue;\r
+        }\r
+      }\r
+\r
+    } else if (Buffer[0] != '}') {\r
+      //\r
+      // if we are here, we should see either a file name,\r
+      // or a }.\r
+      //\r
+      Index3      = 0;\r
+      FileName[0] = 0;\r
+      //\r
+      // Prepend the build directory to the file name if the\r
+      // file name does not already contain a full path.\r
+      //\r
+      if (!isalpha (Buffer[0]) || (Buffer[1] != ':')) {\r
+        sprintf (FileName, "%s\\", BuildDirectory);\r
+      }\r
+\r
+      while (Buffer[Index3] != '\n') {\r
+        if (Buffer[Index3] == '$') {\r
+          Index3 += ProcessEnvironmentVariable (&Buffer[Index3], NewBuffer);\r
+          strcat (FileName, NewBuffer);\r
+        }\r
+\r
+        if (Buffer[Index3] == 0) {\r
+          break;\r
+        } else {\r
+          Index2              = strlen (FileName);\r
+          FileName[Index2++]  = Buffer[Index3++];\r
+          FileName[Index2]    = 0;\r
+        }\r
+      }\r
+\r
+      InFile = fopen (FileName, "rb");\r
+      if (InFile == NULL) {\r
+        Error (NULL, 0, 0, FileName, "failed to open file for reading");\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+\r
+      fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
+      while (!feof (InFile)) {\r
+        FileBuffer[Size++] = ByteBuffer;\r
+        fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
+      }\r
+\r
+      fclose (InFile);\r
+      InFile = NULL;\r
+\r
+      //\r
+      // Make sure section ends on a DWORD boundary\r
+      //\r
+      while ((Size & 0x03) != 0) {\r
+        FileBuffer[Size] = 0;\r
+        Size++;\r
+      }\r
+\r
+    }\r
+  }\r
+\r
+Done:\r
+  for (Index3 = 1; Index3 < MAX_ARRAY_SIZE; Index3++) {\r
+    if (ToolArgumentsArray[Index3] == NULL) {\r
+      break;\r
+    }\r
+\r
+    free (ToolArgumentsArray[Index3]);\r
+  }\r
+\r
+  if (IsError) {\r
+    return -1;\r
+  }\r
+\r
+  return Size;\r
+\r
+}\r
+\r
+static\r
+UINT8\r
+StringToType (\r
+  IN CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts File Type String to value.  EFI_FV_FILETYPE_ALL indicates that an\r
+  unrecognized file type was specified.\r
+\r
+Arguments:\r
+\r
+  String    - File type string\r
+\r
+Returns:\r
+\r
+  File Type Value\r
+\r
+--*/\r
+{\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_RAW") == 0) {\r
+    return EFI_FV_FILETYPE_RAW;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_FREEFORM") == 0) {\r
+    return EFI_FV_FILETYPE_FREEFORM;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_SECURITY_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_SECURITY_CORE;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_PEI_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_PEI_CORE;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_DXE_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_DXE_CORE;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_PEIM") == 0) {\r
+    return EFI_FV_FILETYPE_PEIM;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_DRIVER") == 0) {\r
+    return EFI_FV_FILETYPE_DRIVER;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER") == 0) {\r
+    return EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_APPLICATION") == 0) {\r
+    return EFI_FV_FILETYPE_APPLICATION;\r
+  }\r
+\r
+  if (_strcmpi (String, "EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE") == 0) {\r
+    return EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;\r
+  }\r
+\r
+  return EFI_FV_FILETYPE_ALL;\r
+}\r
+\r
+static\r
+UINT32\r
+AdjustFileSize (\r
+  IN UINT8  *FileBuffer,\r
+  IN UINT32 FileSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Adjusts file size to insure sectioned file is exactly the right length such\r
+  that it ends on exactly the last byte of the last section.  ProcessScript()\r
+  may have padded beyond the end of the last section out to a 4 byte boundary.\r
+  This padding is stripped.\r
+\r
+Arguments:\r
+  FileBuffer  - Data Buffer - contains a section stream\r
+  FileSize    - Size of FileBuffer as returned from ProcessScript()\r
+\r
+Returns:\r
+  Corrected size of file.\r
+\r
+--*/\r
+{\r
+  UINT32                    TotalLength;\r
+  UINT32                    CurrentLength;\r
+  UINT32                    SectionLength;\r
+  UINT32                    SectionStreamLength;\r
+  EFI_COMMON_SECTION_HEADER *SectionHeader;\r
+  EFI_COMMON_SECTION_HEADER *NextSectionHeader;\r
+\r
+  TotalLength         = 0;\r
+  CurrentLength       = 0;\r
+  SectionStreamLength = FileSize;\r
+\r
+  SectionHeader       = (EFI_COMMON_SECTION_HEADER *) FileBuffer;\r
+\r
+  while (TotalLength < SectionStreamLength) {\r
+    SectionLength = *((UINT32 *) SectionHeader->Size) & 0x00ffffff;\r
+    TotalLength += SectionLength;\r
+\r
+    if (TotalLength == SectionStreamLength) {\r
+      return TotalLength;\r
+    }\r
+    //\r
+    // Move to the next byte following the section...\r
+    //\r
+    SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength);\r
+    CurrentLength = (UINTN) SectionHeader - (UINTN) FileBuffer;\r
+\r
+    //\r
+    // Figure out where the next section begins\r
+    //\r
+    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + 3);\r
+    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) NextSectionHeader &~ (UINTN) 3);\r
+    TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader;\r
+    SectionHeader = NextSectionHeader;\r
+  }\r
+\r
+  return CurrentLength;\r
+}\r
+\r
+static\r
+INT32\r
+MainEntry (\r
+  INT32     argc,\r
+  CHAR8     *argv[],\r
+  BOOLEAN   ForceUncompress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  MainEntry function.\r
+\r
+Arguments:\r
+\r
+  argc            - Number of command line parameters.\r
+  argv            - Array of pointers to command line parameter strings.\r
+  ForceUncompress - If TRUE, force to do not compress the sections even if compression\r
+                    is specified in the script. Otherwise, FALSE.\r
+\r
+Returns:\r
+  STATUS_SUCCESS  - Function exits successfully.\r
+  STATUS_ERROR    - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  FILE                    *PrimaryPackage;\r
+  FILE                    *OverridePackage;\r
+  FILE                    *Out;\r
+  CHAR8                   BaseName[_MAX_PATH];\r
+  EFI_GUID                FfsGuid;\r
+  CHAR8                   GuidString[_MAX_PATH];\r
+  EFI_FFS_FILE_HEADER     FileHeader;\r
+  CHAR8                   FileType[_MAX_PATH];\r
+  EFI_FFS_FILE_ATTRIBUTES FfsAttrib;\r
+  EFI_FFS_FILE_ATTRIBUTES FfsAttribDefined;\r
+  UINT64                  FfsAlignment;\r
+  UINT32                  FfsAlignment32;\r
+  CHAR8                   InputString[_MAX_PATH];\r
+  BOOLEAN                 ImageScriptInOveride;\r
+  UINT32                  FileSize;\r
+  UINT8                   *FileBuffer;\r
+  EFI_STATUS              Status;\r
+  UINT32                  LineNumber;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
+  EFI_FFS_FILE_TAIL       TailValue;\r
+#endif\r
+  BaseName[0]       = 0;\r
+  FileType[0]       = 0;\r
+  FfsAttrib         = 0;\r
+  FfsAttribDefined  = 0;\r
+  FfsAlignment      = 0;\r
+  FfsAlignment32    = 0;\r
+  PrimaryPackage    = NULL;\r
+  Out               = NULL;\r
+  OverridePackage   = NULL;\r
+  FileBuffer        = NULL;\r
+\r
+  strcpy (GuidString, "00000000-0000-0000-0000-000000000000");\r
+  Status = StringToGuid (GuidString, &FfsGuid);\r
+  if (Status != 0) {\r
+    Error (NULL, 0, 0, GuidString, "error parsing GUID string");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  GuidString[0]         = 0;\r
+  ImageScriptInOveride  = FALSE;\r
+  //\r
+  // Initialize the simple file parsing routines. Then open\r
+  // the primary package file for parsing.\r
+  //\r
+  SFPInit ();\r
+  if (SFPOpenFile (mGlobals.PrimaryPackagePath) != STATUS_SUCCESS) {\r
+    Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
+    goto Done;\r
+  }\r
+  //\r
+  // First token in the file must be "PACKAGE.INF"\r
+  //\r
+  if (!SFPIsToken ("PACKAGE.INF")) {\r
+    Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'PACKAGE.INF'", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Find the [.] section\r
+  //\r
+  if (!SFPSkipToToken ("[.]")) {\r
+    Error (mGlobals.PrimaryPackagePath, 1, 0, "could not locate [.] section in package file", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Start parsing the data. The algorithm is essentially the same for each keyword:\r
+  //   1. Identify the keyword\r
+  //   2. Verify that the keyword/value pair has not already been defined\r
+  //   3. Set some flag indicating that the keyword/value pair has been defined\r
+  //   4. Skip over the "="\r
+  //   5. Get the value, which may be a number, TRUE, FALSE, or a string.\r
+  //\r
+  while (1) {\r
+    if (SFPIsToken ("BASE_NAME")) {\r
+      //\r
+      // Found BASE_NAME, format:\r
+      //   BASE_NAME = MyBaseName\r
+      //\r
+      if (BaseName[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "BASE_NAME already defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNextToken (BaseName, sizeof (BaseName))) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid base name", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("IMAGE_SCRIPT")) {\r
+      //\r
+      // Found IMAGE_SCRIPT. Break out and process below.\r
+      //\r
+      break;\r
+    } else if (SFPIsToken ("FFS_FILEGUID")) {\r
+      //\r
+      // found FILEGUID, format:\r
+      //   FFS_FILEGUID = F7845C4F-EDF5-42C5-BD8F-A02AF63DD93A\r
+      //\r
+      if (GuidString[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILEGUID already defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPGetGuidToken (GuidString, sizeof (GuidString)) != TRUE) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected file GUID", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      Status = StringToGuid (GuidString, &FfsGuid);\r
+      if (Status != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid file GUID", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_FILETYPE")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found FFS_FILETYPE, format:\r
+      //  FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION\r
+      //\r
+      if (FileType[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILETYPE previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNextToken (FileType, sizeof (FileType))) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid FFS_FILETYPE", NULL);\r
+        goto Done;\r
+      }\r
+    }\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)    \r
+    else if (SFPIsToken ("FFS_ATTRIB_HEADER_EXTENSION")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_HEADER_EXTENSION = FALSE\r
+      // Spec says the bit is for future expansion, and must be false.\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_HEADER_EXTENSION) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "FFS_ATTRIB_HEADER_EXTENSION previously defined",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_HEADER_EXTENSION;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "only FFS_ATTRIB_HEADER_EXTENSION = FALSE is supported",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    }\r
+#else\r
+    else if (SFPIsToken ("FFS_ATTRIB_FIXED")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_FIXED = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_FIXED) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_FIXED previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_FIXED;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_FIXED;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } \r
+#endif\r
+    else if (SFPIsToken ("FFS_ATTRIB_TAIL_PRESENT")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_TAIL_PRESENT = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_TAIL_PRESENT) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_TAIL_PRESENT previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_TAIL_PRESENT;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_TAIL_PRESENT;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_RECOVERY")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_RECOVERY = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_RECOVERY) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_RECOVERY previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_RECOVERY;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_CHECKSUM")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_CHECKSUM = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_CHECKSUM) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_CHECKSUM previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_CHECKSUM;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ALIGNMENT") || SFPIsToken ("FFS_ATTRIB_DATA_ALIGNMENT")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found FFS_ALIGNMENT, formats:\r
+      //   FFS_ALIGNMENT = 0-7\r
+      //   FFS_ATTRIB_DATA_ALIGNMENT = 0-7\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_DATA_ALIGNMENT) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "FFS_ALIGNMENT/FFS_ATTRIB_DATA_ALIGNMENT previously defined",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_DATA_ALIGNMENT;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNumber (&FfsAlignment32)) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected numeric value for alignment", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (FfsAlignment32 > 7) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 0 <= alignment <= 7", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment32) << 3);\r
+    } else {\r
+      SFPGetNextToken (InputString, sizeof (InputString));\r
+      Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, InputString, "unrecognized/unexpected token");\r
+      goto Done;\r
+    }\r
+  }\r
+  //\r
+  // Close the primary package file\r
+  //\r
+  SFPCloseFile ();\r
+  //\r
+  // TODO: replace code below with basically a copy of the code above. Don't\r
+  // forget to reset the FfsAttribDefined variable first. Also, you'll need\r
+  // to somehow keep track of whether or not the basename is defined multiple\r
+  // times in the override package. Ditto on the file GUID.\r
+  //\r
+  if (mGlobals.OverridePackagePath[0] != 0) {\r
+    OverridePackage = fopen (mGlobals.OverridePackagePath, "r");\r
+    //\r
+    // NOTE: For package override to work correctly, the code below must be modified to\r
+    //       SET or CLEAR bits properly. For example, if the primary package set\r
+    //       FFS_ATTRIB_CHECKSUM = TRUE, and the override set FFS_ATTRIB_CHECKSUM = FALSE, then\r
+    //       we'd need to clear the bit below. Since this is not happening, I'm guessing that\r
+    //       the override functionality is not being used, so should be made obsolete. If I'm\r
+    //       wrong, and it is being used, then it needs to be fixed. Thus emit an error if it is\r
+    //       used, and we'll address it then.  4/10/2003\r
+    //\r
+    Error (__FILE__, __LINE__, 0, "package override functionality is not implemented correctly", NULL);\r
+    goto Done;\r
+  } else {\r
+    OverridePackage = NULL;\r
+  }\r
+\r
+#ifdef OVERRIDE_SUPPORTED\r
+  if (OverridePackage != NULL) {\r
+    //\r
+    // Parse override package file\r
+    //\r
+    fscanf (OverridePackage, "%s", &InputString);\r
+    if (_strcmpi (InputString, "PACKAGE.INF") != 0) {\r
+      Error (mGlobals.OverridePackagePath, 1, 0, "invalid package file", "expected 'PACKAGE.INF'");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Match [dir] to Build Directory\r
+    //\r
+    if (FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber) != 0) {\r
+      Error (mGlobals.OverridePackagePath, 1, 0, mGlobals.BuildDirectory, "section not found in package file");\r
+      goto Done;\r
+    }\r
+\r
+    InputString[0] = 0;\r
+    while ((InputString[0] != '[') && (!feof (OverridePackage))) {\r
+      if (GetNextLine (InputString, OverridePackage, &LineNumber) != -1) {\r
+        if (InputString[0] != '[') {\r
+here:\r
+          if (_strcmpi (InputString, "BASE_NAME") == 0) {\r
+            //\r
+            // found BASE_NAME, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              strcpy (BaseName, InputString);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              strcpy (BaseName, InputString);\r
+            }\r
+          } else if (_strcmpi (InputString, "IMAGE_SCRIPT") == 0) {\r
+            //\r
+            // found IMAGE_SCRIPT, come back later to process it\r
+            //\r
+            ImageScriptInOveride = TRUE;\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+          } else if (_strcmpi (InputString, "FFS_FILEGUID") == 0) {\r
+            //\r
+            // found FILEGUID, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              Status = StringToGuid (InputString, &FfsGuid);\r
+              if (Status != 0) {\r
+                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
+                goto Done;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              Status = StringToGuid (InputString, &FfsGuid);\r
+              if (Status != 0) {\r
+                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
+                goto Done;\r
+              }\r
+            }\r
+          } else if (_strcmpi (InputString, "FFS_FILETYPE") == 0) {\r
+            //\r
+            // found FILETYPE, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              strcpy (FileType, InputString);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              strcpy (FileType, InputString);\r
+            }\r
+\r
+          } else if (_strcmpi (InputString, "FFS_ATTRIB_RECOVERY") == 0) {\r
+            //\r
+            // found FFS_ATTRIB_RECOVERY, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              if (_strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              if (_strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+              }\r
+            }\r
+          } else if (_strcmpi (InputString, "FFS_ATTRIB_CHECKSUM") == 0) {\r
+            //\r
+            // found FFS_ATTRIB_CHECKSUM, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              if (_strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              if (_strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+              }\r
+            }\r
+          } else if (_strcmpi (InputString, "FFS_ALIGNMENT") == 0) {\r
+            //\r
+            // found FFS_ALIGNMENT, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+            }\r
+\r
+            AsciiStringToUint64 (InputString, FALSE, &FfsAlignment);\r
+            if (FfsAlignment > 7) {\r
+              Error (mGlobals.OverridePackagePath, 1, 0, InputString, "invalid FFS_ALIGNMENT value");\r
+              goto Done;\r
+            }\r
+\r
+            FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment) << 3);\r
+          } else if (strchr (InputString, '=') != NULL) {\r
+            BreakString (InputString, String, 1);\r
+            fseek (OverridePackage, (-1 * (strlen (String) + 1)), SEEK_CUR);\r
+            BreakString (InputString, InputString, 0);\r
+            goto here;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+#endif // #ifdef OVERRIDE_SUPPORTED\r
+  //\r
+  // Require that they specified a file GUID at least, since that's how we're\r
+  // naming the file.\r
+  //\r
+  if (GuidString[0] == 0) {\r
+    Error (mGlobals.PrimaryPackagePath, 1, 0, "FFS_FILEGUID must be specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Build Header and process image script\r
+  //\r
+  FileBuffer = (UINT8 *) malloc ((1024 * 1024 * 16) * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  FileSize = 0;\r
+  if (ImageScriptInOveride) {\r
+#ifdef OVERRIDE_SUPPORTED\r
+    rewind (OverridePackage);\r
+    LineNumber = 0;\r
+    FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber);\r
+    while (_strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
+      GetNextLine (InputString, OverridePackage, &LineNumber);\r
+      CheckSlash (InputString, OverridePackage, &LineNumber);\r
+      if (strchr (InputString, '=') != NULL) {\r
+        BreakString (InputString, InputString, 0);\r
+      }\r
+    }\r
+\r
+    while (InputString[0] != '{') {\r
+      GetNextLine (InputString, OverridePackage, &LineNumber);\r
+      CheckSlash (InputString, OverridePackage, &LineNumber);\r
+    }\r
+    //\r
+    // Found start of image script, process it\r
+    //\r
+    FileSize += ProcessScript (FileBuffer, OverridePackage, mGlobals.BuildDirectory, ForceUncompress);\r
+    if (FileSize == -1) {\r
+      Error (NULL, 0, 0, "failed to process script", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
+      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
+    }\r
+\r
+    if (BaseName[0] == '\"') {\r
+      StripQuotes (BaseName);\r
+    }\r
+\r
+    if (BaseName[0] != 0) {\r
+      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    } else {\r
+      strcpy (InputString, GuidString);\r
+    }\r
+\r
+    switch (StringToType (FileType)) {\r
+\r
+    case EFI_FV_FILETYPE_SECURITY_CORE:\r
+      strcat (InputString, ".SEC");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_PEIM:\r
+    case EFI_FV_FILETYPE_PEI_CORE:\r
+    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+      strcat (InputString, ".PEI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_DRIVER:\r
+    case EFI_FV_FILETYPE_DXE_CORE:\r
+      strcat (InputString, ".DXE");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_APPLICATION:\r
+      strcat (InputString, ".APP");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+      strcat (InputString, ".FVI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_RAW:\r
+      strcat (InputString, ".RAW");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_ALL:\r
+      Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+      goto Done;\r
+\r
+    default:\r
+      strcat (InputString, ".FFS");\r
+      break;\r
+    }\r
+\r
+    if (ForceUncompress) {\r
+      strcat (InputString, ".ORG");\r
+    }\r
+\r
+    Out = fopen (InputString, "wb");\r
+    if (Out == NULL) {\r
+      Error (NULL, 0, 0, InputString, "could not open output file for writing");\r
+      goto Done;\r
+    }\r
+    //\r
+    // create ffs header\r
+    //\r
+    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
+    FileHeader.Type       = StringToType (FileType);\r
+    FileHeader.Attributes = FfsAttrib;\r
+    //\r
+    // Now FileSize includes the EFI_FFS_FILE_HEADER\r
+    //\r
+    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
+    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
+    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
+    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
+    //\r
+    // Fill in checksums and state, these must be zero for checksumming\r
+    //\r
+    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
+    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
+    // FileHeader.State = 0;\r
+    //\r
+    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
+                                                  (UINT8 *) &FileHeader,\r
+                                                  sizeof (EFI_FFS_FILE_HEADER)\r
+                                                  );\r
+    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);\r
+    } else {\r
+      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+    }\r
+\r
+    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+    //\r
+    // write header\r
+    //\r
+    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file header to output file", NULL);\r
+      goto Done;\r
+    }\r
+    //\r
+    // write data\r
+    //\r
+    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write all bytes to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    fclose (Out);\r
+    Out = NULL;\r
+#endif // #ifdef OVERRIDE_SUPPORTED\r
+  } else {\r
+    //\r
+    // Open primary package file and process the IMAGE_SCRIPT section\r
+    //\r
+    PrimaryPackage = fopen (mGlobals.PrimaryPackagePath, "r");\r
+    if (PrimaryPackage == NULL) {\r
+      Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
+      goto Done;\r
+    }\r
+\r
+    LineNumber = 1;\r
+    FindSectionInPackage (".", PrimaryPackage, &LineNumber);\r
+    while (_strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
+      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
+      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
+      if (strchr (InputString, '=') != NULL) {\r
+        BreakString (InputString, InputString, 0);\r
+      }\r
+    }\r
+\r
+    while (InputString[0] != '{') {\r
+      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
+      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
+    }\r
+    //\r
+    // Found start of image script, process it\r
+    //\r
+    FileSize += ProcessScript (FileBuffer, PrimaryPackage, mGlobals.BuildDirectory, ForceUncompress);\r
+    if (FileSize == -1) {\r
+      Error (NULL, 0, 0, "failed to process script", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
+      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
+    }\r
+\r
+    if (BaseName[0] == '\"') {\r
+      StripQuotes (BaseName);\r
+    }\r
+\r
+    if (BaseName[0] != 0) {\r
+      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    } else {\r
+      strcpy (InputString, GuidString);\r
+    }\r
+\r
+    switch (StringToType (FileType)) {\r
+\r
+    case EFI_FV_FILETYPE_SECURITY_CORE:\r
+      strcat (InputString, ".SEC");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_PEIM:\r
+    case EFI_FV_FILETYPE_PEI_CORE:\r
+    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+      strcat (InputString, ".PEI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_DRIVER:\r
+    case EFI_FV_FILETYPE_DXE_CORE:\r
+      strcat (InputString, ".DXE");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_APPLICATION:\r
+      strcat (InputString, ".APP");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+      strcat (InputString, ".FVI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_RAW:\r
+      strcat (InputString, ".RAW");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_ALL:\r
+      Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+      goto Done;\r
+\r
+    default:\r
+      strcat (InputString, ".FFS");\r
+      break;\r
+    }\r
+\r
+    if (ForceUncompress) {\r
+      strcat (InputString, ".ORG");\r
+    }\r
+\r
+    Out = fopen (InputString, "wb");\r
+    if (Out == NULL) {\r
+      Error (NULL, 0, 0, InputString, "failed to open output file for writing");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Initialize the FFS file header\r
+    //\r
+    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
+    FileHeader.Type       = StringToType (FileType);\r
+    FileHeader.Attributes = FfsAttrib;\r
+    //\r
+    // From this point on FileSize includes the size of the EFI_FFS_FILE_HEADER\r
+    //\r
+    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
+    //\r
+    // If using a tail, then it adds two bytes\r
+    //\r
+    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      //\r
+      // Tail is not allowed for pad and 0-length files\r
+      //\r
+      if ((FileHeader.Type == EFI_FV_FILETYPE_FFS_PAD) || (FileSize == sizeof (EFI_FFS_FILE_HEADER))) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          1,\r
+          0,\r
+          "FFS_ATTRIB_TAIL_PRESENT=TRUE is invalid for PAD or 0-length files",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FileSize += sizeof (EFI_FFS_FILE_TAIL);\r
+    }\r
+\r
+    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
+    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
+    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
+    //\r
+    // Fill in checksums and state, they must be 0 for checksumming.\r
+    //\r
+    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
+    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
+    // FileHeader.State = 0;\r
+    //\r
+    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
+                                                  (UINT8 *) &FileHeader,\r
+                                                  sizeof (EFI_FFS_FILE_HEADER)\r
+                                                  );\r
+    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      //\r
+      // Cheating here.  Since the header checksums, just calculate the checksum of the body.\r
+      // Checksum does not include the tail\r
+      //\r
+      if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                    FileBuffer,\r
+                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL)\r
+                                                    );\r
+      } else {\r
+        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                    FileBuffer,\r
+                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
+                                                    );\r
+      }\r
+    } else {\r
+      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+    }\r
+    //\r
+    // Set the state now. Spec says the checksum assumes the state is 0\r
+    //\r
+    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+\r
+    //\r
+    // If there is a tail, then set it\r
+    //\r
+    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailValue = FileHeader.IntegrityCheck.TailReference;\r
+      TailValue = (UINT16) (~TailValue);\r
+      memcpy (\r
+        (UINT8 *) FileBuffer + FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL),\r
+        &TailValue,\r
+        sizeof (TailValue)\r
+        );\r
+    }\r
+#endif    \r
+    //\r
+    // Write the FFS file header\r
+    //\r
+    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file header contents", NULL);\r
+      goto Done;\r
+    }\r
+    //\r
+    // Write data\r
+    //\r
+    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file contents", NULL);\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+Done:\r
+  SFPCloseFile ();\r
+  if (Out != NULL) {\r
+    fclose (Out);\r
+  }\r
+\r
+  if (PrimaryPackage != NULL) {\r
+    fclose (PrimaryPackage);\r
+  }\r
+\r
+  if (FileBuffer != NULL) {\r
+    free (FileBuffer);\r
+  }\r
+\r
+  if (OverridePackage != NULL) {\r
+    fclose (OverridePackage);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+int\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to parameter strings.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  //\r
+  // Set the name of our utility for error reporting purposes.\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+  Status = ProcessCommandLineArgs (argc, argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  Status = MainEntry (argc, argv, TRUE);\r
+  if (Status == STATUS_SUCCESS) {\r
+    MainEntry (argc, argv, FALSE);\r
+  }\r
+  //\r
+  // If any errors were reported via the standard error reporting\r
+  // routines, then the status has been saved. Get the value and\r
+  // return it to the caller.\r
+  //\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessCommandLineArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process the command line arguments.\r
+\r
+Arguments:\r
+  Argc - as passed in to main()\r
+  Argv - as passed in to main()\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - arguments all ok\r
+  STATUS_ERROR      - problem with args, so caller should exit\r
+\r
+--*/\r
+{\r
+  //\r
+  // If no args, then print usage instructions and return an error\r
+  //\r
+  if (Argc == 1) {\r
+    PrintUsage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset (&mGlobals, 0, sizeof (mGlobals));\r
+  Argc--;\r
+  Argv++;\r
+  while (Argc > 0) {\r
+    if (_strcmpi (Argv[0], "-b") == 0) {\r
+      //\r
+      // OPTION: -b BuildDirectory\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, "-b option requires the build directory name", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.BuildDirectory[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.BuildDirectory, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_strcmpi (Argv[0], "-p1") == 0) {\r
+      //\r
+      // OPTION: -p1 PrimaryPackageFile\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, Argv[0], "option requires the primary package file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.PrimaryPackagePath[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.PrimaryPackagePath, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_strcmpi (Argv[0], "-p2") == 0) {\r
+      //\r
+      // OPTION: -p2 OverridePackageFile\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, Argv[0], "option requires the override package file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.OverridePackagePath[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OverridePackagePath, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_strcmpi (Argv[0], "-v") == 0) {\r
+      //\r
+      // OPTION: -v       verbose\r
+      //\r
+      mGlobals.Verbose = TRUE;\r
+    } else if (_strcmpi (Argv[0], "-h") == 0) {\r
+      //\r
+      // OPTION: -h      help\r
+      //\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    } else if (_strcmpi (Argv[0], "-?") == 0) {\r
+      //\r
+      // OPTION:  -?      help\r
+      //\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Must have at least specified the package file name\r
+  //\r
+  if (mGlobals.PrimaryPackagePath[0] == 0) {\r
+    Error (NULL, 0, 0, "must specify primary package file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h
new file mode 100644 (file)
index 0000000..d3bcdbb
--- /dev/null
@@ -0,0 +1,35 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFfsFile.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenFfsFile.\r
+\r
+--*/\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_FFSFILE_H\r
+#define _EFI_GEN_FFSFILE_H\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+#include "TianoCommon.h"\r
+#include "EfiImageFormat.h"\r
+#include "MyAlloc.h"\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile
new file mode 100644 (file)
index 0000000..85f9cfd
--- /dev/null
@@ -0,0 +1,88 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  \r
+#\r
+#     makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI GenFfsFile utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+LIBS =  $(LIBS)  $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = GenFfsFile\r
+TARGET_SOURCE_DIR   = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+TARGET_EXE_SOURCE   = "$(TARGET_SOURCE_DIR)\GenFfsFile.c"\r
+TARGET_EXE_INCLUDE  = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \\r
+                      "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \\r
+                      "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \\r
+                      "$(EDK_TOOLS_COMMON)\ParseInf.h" \\r
+                      "$(EDK_TOOLS_COMMON)\MyAlloc.h"\r
+\r
+TARGET_EXE_LIBS     = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+C_FLAGS             = $(C_FLAGS) -W4\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(LIBS) $(TARGET_EXE_LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj  \\r
+        $(TARGET_LIB)  $(TARGET_EXE_LIBS) \r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
new file mode 100644 (file)
index 0000000..ccd1199
--- /dev/null
@@ -0,0 +1,299 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFvImageExe.c\r
+\r
+Abstract:\r
+\r
+  This contains all code necessary to build the GenFvImage.exe utility.       \r
+  This utility relies heavily on the GenFvImage Lib.  Definitions for both\r
+  can be found in the Tiano Firmware Volume Generation Utility \r
+  Specification, review draft.\r
+\r
+--*/\r
+\r
+//\r
+// File included in build\r
+//\r
+#include "GenFvImageExe.h"\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);\r
+  printf ("  Where:\n");\r
+  printf ("\tFvInfFileName is the name of the image description file.\n\n");\r
+}\r
+\r
+EFI_STATUS\r
+main (\r
+  IN INTN   argc,\r
+  IN CHAR8  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This utility uses GenFvImage.Lib to build a firmware volume image.\r
+\r
+Arguments:\r
+\r
+  FvInfFileName      The name of an FV image description file.\r
+\r
+  Arguments come in pair in any order.\r
+    -I FvInfFileName \r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            No error conditions detected.\r
+  EFI_INVALID_PARAMETER  One or more of the input parameters is invalid.\r
+  EFI_OUT_OF_RESOURCES   A resource required by the utility was unavailable.  \r
+                         Most commonly this will be memory allocation \r
+                         or file creation.\r
+  EFI_LOAD_ERROR         GenFvImage.lib could not be loaded.\r
+  EFI_ABORTED            Error executing the GenFvImage lib.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  CHAR8       InfFileName[_MAX_PATH];\r
+  CHAR8       *InfFileImage;\r
+  UINTN       InfFileSize;\r
+  UINT8       *FvImage;\r
+  UINTN       FvImageSize;\r
+  UINT8       Index;\r
+  CHAR8       FvFileNameBuffer[_MAX_PATH];\r
+  CHAR8       *FvFileName;\r
+  FILE        *FvFile;\r
+  FILE        *SymFile;\r
+  CHAR8       SymFileNameBuffer[_MAX_PATH];\r
+  CHAR8       *SymFileName;\r
+  UINT8       *SymImage;\r
+  UINTN       SymImageSize;\r
+  CHAR8       *CurrentSymString;\r
+\r
+  FvFileName  = FvFileNameBuffer;\r
+  SymFileName = SymFileNameBuffer;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Display utility information\r
+  //\r
+  PrintUtilityInfo ();\r
+\r
+  //\r
+  // Verify the correct number of arguments\r
+  //\r
+  if (argc != MAX_ARGS) {\r
+    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
+    PrintUsage ();\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // Initialize variables\r
+  //\r
+  strcpy (InfFileName, "");\r
+\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
+    //\r
+    // Make sure argument pair begin with - or /\r
+    //\r
+    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
+      Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\"");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+    //\r
+    // Make sure argument specifier is only one letter\r
+    //\r
+    if (argv[Index][2] != 0) {\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+    //\r
+    // Determine argument to read\r
+    //\r
+    switch (argv[Index][1]) {\r
+\r
+    case 'I':\r
+    case 'i':\r
+      if (strlen (InfFileName) == 0) {\r
+        strcpy (InfFileName, argv[Index + 1]);\r
+      } else {\r
+        Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once");\r
+        PrintUsage ();\r
+        return GetUtilityStatus ();\r
+      }\r
+      break;\r
+\r
+    default:\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Read the INF file image\r
+  //\r
+  Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);\r
+  if (EFI_ERROR (Status)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Call the GenFvImage lib\r
+  //\r
+  Status = GenerateFvImage (\r
+            InfFileImage,\r
+            InfFileSize,\r
+            &FvImage,\r
+            &FvImageSize,\r
+            &FvFileName,\r
+            &SymImage,\r
+            &SymImageSize,\r
+            &SymFileName\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    switch (Status) {\r
+\r
+    case EFI_INVALID_PARAMETER:\r
+      Error (NULL, 0, 0, "invalid parameter passed to GenFvImage Lib", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_ABORTED:\r
+      Error (NULL, 0, 0, "error detected while creating the file image", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_OUT_OF_RESOURCES:\r
+      Error (NULL, 0, 0, "GenFvImage Lib could not allocate required resources", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_VOLUME_CORRUPTED:\r
+      Error (NULL, 0, 0, "no base address was specified, but the FV.INF included a PEI or BSF file", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_LOAD_ERROR:\r
+      Error (NULL, 0, 0, "could not load FV image generation library", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    default:\r
+      Error (NULL, 0, 0, "GenFvImage Lib returned unknown status", "status returned = 0x%X", Status);\r
+      return GetUtilityStatus ();\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Write file\r
+  //\r
+  FvFile = fopen (FvFileName, "wb");\r
+  if (FvFile == NULL) {\r
+    Error (NULL, 0, 0, FvFileName, "could not open output file");\r
+    free (FvImage);\r
+    free (SymImage);\r
+    return GetUtilityStatus ();\r
+  }\r
+\r
+  if (fwrite (FvImage, 1, FvImageSize, FvFile) != FvImageSize) {\r
+    Error (NULL, 0, 0, FvFileName, "failed to write to output file");\r
+    free (FvImage);\r
+    free (SymImage);\r
+    fclose (FvFile);\r
+    return GetUtilityStatus ();\r
+  }\r
+\r
+  fclose (FvFile);\r
+  free (FvImage);\r
+\r
+  //\r
+  // Write symbol file\r
+  //\r
+  if (strcmp (SymFileName, "")) {\r
+    SymFile = fopen (SymFileName, "wt");\r
+    if (SymFile == NULL) {\r
+      Error (NULL, 0, 0, SymFileName, "could not open output symbol file");\r
+      free (SymImage);\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    fprintf (SymFile, "TEXTSYM format | V1.0\n");\r
+\r
+    CurrentSymString = SymImage;\r
+    while (((UINTN) CurrentSymString - (UINTN) SymImage) < SymImageSize) {\r
+      fprintf (SymFile, "%s", CurrentSymString);\r
+      CurrentSymString = (CHAR8 *) (((UINTN) CurrentSymString) + strlen (CurrentSymString) + 1);\r
+    }\r
+\r
+    fclose (SymFile);\r
+  }\r
+\r
+  free (SymImage);\r
+\r
+  return GetUtilityStatus ();\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
new file mode 100644 (file)
index 0000000..9b97935
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageExe.h\r
+\r
+Abstract:\r
+\r
+  Definitions for the PeimFixup exe utility.\r
+\r
+--*/\r
+\r
+//\r
+// Coded to Tiano Coding Standards\r
+//\r
+#ifndef _EFI_GEN_FV_IMAGE_EXE_H\r
+#define _EFI_GEN_FV_IMAGE_EXE_H\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "GenFvImageLib.h"\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "GenFvImage"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_DATE          __DATE__\r
+\r
+//\r
+// The maximum number of arguments accepted from the command line.\r
+//\r
+#define MAX_ARGS  3\r
+\r
+//\r
+// The function that displays general utility information\r
+//\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that displays the utility usage message.\r
+//\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
new file mode 100644 (file)
index 0000000..3c59184
--- /dev/null
@@ -0,0 +1,3054 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFvImageLib.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware Volume.\r
+\r
+--*/\r
+\r
+//\r
+// Include files\r
+//\r
+#include "GenFvImageLib.h"\r
+#include "GenFvImageLibInternal.h"\r
+#include <string.h>\r
+#include EFI_GUID_DEFINITION (PeiPeCoffLoader)\r
+#include "EfiFirmwareFileSystem.h"\r
+#include "EfiWorkingBlockHeader.h"\r
+#include "EfiVariable.h"\r
+#include <io.h>\r
+#include <assert.h>\r
+#include "CommonLib.h"\r
+#include "FvLib.h"\r
+#include "EfiImage.h"\r
+#include "crc32.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
+#include EFI_GUID_DEFINITION (FirmwareFileSystem2)\r
+\r
+//\r
+// Define the PE/COFF loader\r
+//\r
+extern EFI_PEI_PE_COFF_LOADER_PROTOCOL  mPeCoffLoader;\r
+\r
+//\r
+// Local function prototypes\r
+//\r
+EFI_STATUS\r
+GetPe32Info (\r
+  IN UINT8                  *Pe32,\r
+  OUT UINT32                *EntryPoint,\r
+  OUT UINT32                *BaseOfCode,\r
+  OUT UINT16                *MachineType\r
+  );\r
+\r
+//\r
+// Local function implementations.\r
+//\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+EFI_GUID  FfsGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
+#else\r
+EFI_GUID  FfsGuid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
+#endif\r
+\r
+EFI_GUID  DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f };\r
+\r
+//\r
+// This data array will be located at the base of the Firmware Volume Header (FVH)\r
+// in the boot block.  It must not exceed 14 bytes of code.  The last 2 bytes\r
+// will be used to keep the FVH checksum consistent.\r
+// This code will be run in response to a starutp IPI for HT-enabled systems.\r
+//\r
+#define SIZEOF_STARTUP_DATA_ARRAY 0x10\r
+\r
+UINT8                                   m128kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
+  //\r
+  // EA D0 FF 00 F0               ; far jmp F000:FFD0\r
+  // 0, 0, 0, 0, 0, 0, 0, 0, 0,   ; Reserved bytes\r
+  // 0, 0                         ; Checksum Padding\r
+  //\r
+  0xEA,\r
+  0xD0,\r
+  0xFF,\r
+  0x0,\r
+  0xF0,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00\r
+};\r
+\r
+UINT8                                   m64kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
+  //\r
+  // EB CE                               ; jmp short ($-0x30)\r
+  // ; (from offset 0x0 to offset 0xFFD0)\r
+  // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes\r
+  // 0, 0                                ; Checksum Padding\r
+  //\r
+  0xEB,\r
+  0xCE,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00\r
+};\r
+\r
+EFI_STATUS\r
+ParseFvInf (\r
+  IN MEMORY_FILE  *InfFile,\r
+  IN FV_INFO      *FvInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a FV.INF file and copies info into a FV_INFO structure.\r
+\r
+Arguments:\r
+\r
+  InfFile         Memory file image.\r
+  FvInfo          Information read from INF file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       INF file information successfully retrieved.\r
+  EFI_ABORTED       INF file has an invalid format.\r
+  EFI_NOT_FOUND     A required string was not found in the INF file.\r
+--*/\r
+{\r
+  CHAR8       Value[_MAX_PATH];\r
+  UINT64      Value64;\r
+  UINTN       Index;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initialize FV info\r
+  //\r
+  memset (FvInfo, 0, sizeof (FV_INFO));\r
+\r
+  //\r
+  // Read the FV base address\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_BASE_ADDRESS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Get the base address\r
+    //\r
+    Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "invalid value");\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    FvInfo->BaseAddress = Value64;\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "could not find value");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read the FV Guid\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_GUID_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Get the guid value\r
+    //\r
+    Status = StringToGuid (Value, &FvInfo->FvGuid);\r
+    if (EFI_ERROR (Status)) {\r
+      memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
+    }\r
+  } else {\r
+    memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
+  }\r
+  //\r
+  // Read the FV file name\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_FILE_NAME_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // copy the file name\r
+    //\r
+    strcpy (FvInfo->FvName, Value);\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FV_FILE_NAME_STRING, "value not specified");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read the Sym file name\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_SYM_FILE_NAME_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // copy the file name\r
+    //\r
+    strcpy (FvInfo->SymName, Value);\r
+  } else {\r
+    //\r
+    // Symbols not required, so init to NULL.\r
+    //\r
+    strcpy (FvInfo->SymName, "");\r
+  }\r
+  //\r
+  // Read the read disabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_DISABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_DISABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the read enabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_ENABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_ENABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the read status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write disabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_DISABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_DISABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write enabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_ENABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_ENABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the lock capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_LOCK_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the lock status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_LOCK_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the sticky write attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_STICKY_WRITE_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_STICKY_WRITE;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the memory mapped attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_MEMORY_MAPPED_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_MEMORY_MAPPED;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the erase polarity attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ERASE_POLARITY_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, ONE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ERASE_POLARITY;\r
+    } else if (strcmp (Value, ZERO_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)        \r
+  //\r
+  // Read the read lock capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_LOCK_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_READ_LOCK_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_LOCK_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Read the read lock status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_LOCK_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_READ_LOCK_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_LOCK_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Read the write lock capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_LOCK_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_WRITE_LOCK_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Read the write lock status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_LOCK_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_WRITE_LOCK_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+#endif\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)     \r
+  //\r
+  // Read the alignment capabilities attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Read the word alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  \r
+  //\r
+  // Read the dword alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the word alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the qword alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 32 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 64 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 128 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_128_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_128;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 256 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_256_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_256;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 512 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_512_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_512;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 1K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_1K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_1K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 2K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 4K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 8K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 16K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 32K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 64K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  if (!(FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_CAP) &&\r
+      (\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_128) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_256) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_512) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_1K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64K)\r
+      )\r
+     ){\r
+    Error (\r
+      NULL,\r
+      0,\r
+      0,\r
+      "illegal combination of alignment attributes",\r
+      "if %s is not %s, no individual alignments can be %s",\r
+      EFI_FVB_ALIGNMENT_CAP_STRING,\r
+      TRUE_STRING,\r
+      TRUE_STRING\r
+      );\r
+    return EFI_ABORTED;\r
+  }\r
+#else\r
+  //\r
+  // Read the PI1.0 FVB2 Alignment Capabilities Attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB2_ALIGNMENT_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, EFI_FVB2_ALIGNMENT_1_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_512;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512K_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMNET_512K;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512M_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_512M;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1G_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1G;\r
+    } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2G_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2G;\r
+    } else {\r
+      Error (NULL, 0, 0, EFI_FVB2_ALIGNMENT_STRING, "value not correct!");\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB2_ALIGNMENT_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+#endif  \r
+  //\r
+  // Read block maps\r
+  //\r
+  for (Index = 0; Index < MAX_NUMBER_OF_FV_BLOCKS; Index++) {\r
+    //\r
+    // Read the number of blocks\r
+    //\r
+    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Update the number of blocks\r
+      //\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;\r
+    } else {\r
+      //\r
+      // If there is no number of blocks, but there is a size, then we have a mismatched pair\r
+      // and should return an error.\r
+      //\r
+      Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
+      if (!EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
+        return EFI_ABORTED;\r
+      } else {\r
+        //\r
+        // We are done\r
+        //\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Read the size of blocks\r
+    //\r
+    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Update the number of blocks\r
+      //\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, Value, "invalid value specified for %s", EFI_BLOCK_SIZE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvBlocks[Index].BlockLength = (UINT32) Value64;\r
+    } else {\r
+      //\r
+      // There is a number of blocks, but there is no size, so we have a mismatched pair\r
+      // and should return an error.\r
+      //\r
+      Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // Read files\r
+  //\r
+  for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) {\r
+    //\r
+    // Read the number of blocks\r
+    //\r
+    Status = FindToken (InfFile, FILES_SECTION_STRING, EFI_FILE_NAME_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the file\r
+      //\r
+      strcpy (FvInfo->FvFiles[Index], Value);\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {\r
+    Index = 0;\r
+    //\r
+    // Read component FV_VARIABLE\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_EVENT_LOG\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_FTW_WORKING\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_FTW_SPARE\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);\r
+    }\r
+  }\r
+  //\r
+  // Compute size for easy access later\r
+  //\r
+  FvInfo->Size = 0;\r
+  for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {\r
+    FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+UpdateFfsFileState (\r
+  IN EFI_FFS_FILE_HEADER          *FfsFile,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function changes the FFS file attributes based on the erase polarity\r
+  of the FV.\r
+\r
+Arguments:\r
+\r
+  FfsFile   File header.\r
+  FvHeader  FV header.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    FfsFile->State = (UINT8)~(FfsFile->State);\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+ReadFfsAlignment (\r
+  IN EFI_FFS_FILE_HEADER    *FfsFile,\r
+  IN OUT UINT32             *Alignment\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function determines the alignment of the FFS input file from the file\r
+  attributes.\r
+\r
+Arguments:\r
+\r
+  FfsFile       FFS file to parse\r
+  Alignment     The minimum required alignment of the FFS file, in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FfsFile == NULL || Alignment == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  switch ((FfsFile->Attributes >> 3) & 0x07) {\r
+\r
+  case 0:\r
+    //\r
+    // 1 byte alignment\r
+    //\r
+    *Alignment = (1 << 0);\r
+    break;\r
+\r
+  case 1:\r
+    //\r
+    // 16 byte alignment\r
+    //\r
+    *Alignment = (1 << 4);\r
+    break;\r
+\r
+  case 2:\r
+    //\r
+    // 128 byte alignment\r
+    //\r
+    *Alignment = (1 << 7);\r
+    break;\r
+\r
+  case 3:\r
+    //\r
+    // 512 byte alignment\r
+    //\r
+    *Alignment = (1 << 9);\r
+    break;\r
+\r
+  case 4:\r
+    //\r
+    // 1K byte alignment\r
+    //\r
+    *Alignment = (1 << 10);\r
+    break;\r
+\r
+  case 5:\r
+    //\r
+    // 4K byte alignment\r
+    //\r
+    *Alignment = (1 << 12);\r
+    break;\r
+\r
+  case 6:\r
+    //\r
+    // 32K byte alignment\r
+    //\r
+    *Alignment = (1 << 15);\r
+    break;\r
+\r
+  case 7:\r
+    //\r
+    // 64K byte alignment\r
+    //\r
+    *Alignment = (1 << 16);\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "nvalid file attribute calculated, this is most likely a utility error", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddPadFile (\r
+  IN OUT MEMORY_FILE  *FvImage,\r
+  IN UINT32           DataAlignment\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds a pad file to the FV image if it required to align the\r
+  data of the next file.\r
+\r
+Arguments:\r
+\r
+  FvImage         The memory image of the FV to add it to.  The current offset\r
+                  must be valid.\r
+  DataAlignment   The data alignment of the next FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist in the FV to complete\r
+                           the pad file add.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *PadFile;\r
+  UUID                PadFileGuid;\r
+  UINTN               PadFileSize;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FvImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Basic assumption is we start from an 8 byte aligned address\r
+  // and our file header is a multiple of 8 bytes\r
+  //\r
+  assert ((UINTN) FvImage->CurrentFilePointer % 8 == 0);\r
+  assert (sizeof (EFI_FFS_FILE_HEADER) % 8 == 0);\r
+\r
+  //\r
+  // Check if a pad file is necessary\r
+  //\r
+  if (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER)) % DataAlignment == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Write pad file header\r
+  //\r
+  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
+\r
+  //\r
+  // Verify that we have enough space for the file header\r
+  //\r
+  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  UuidCreate (&PadFileGuid);\r
+  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  memcpy (&PadFile->Name, &PadFileGuid, sizeof (EFI_GUID));\r
+  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
+  PadFile->Attributes = 0;\r
+\r
+  //\r
+  // Calculate the pad file size\r
+  //\r
+  //\r
+  // This is the earliest possible valid offset (current plus pad file header\r
+  // plus the next file header)\r
+  //\r
+  PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);\r
+\r
+  //\r
+  // Add whatever it takes to get to the next aligned address\r
+  //\r
+  while ((PadFileSize % DataAlignment) != 0) {\r
+    PadFileSize++;\r
+  }\r
+  //\r
+  // Subtract the next file header size\r
+  //\r
+  PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
+\r
+  //\r
+  // Subtract the starting offset to get size\r
+  //\r
+  PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;\r
+\r
+  //\r
+  // Write pad file size (calculated size minus next file header size)\r
+  //\r
+  PadFile->Size[0]  = (UINT8) (PadFileSize & 0xFF);\r
+  PadFile->Size[1]  = (UINT8) ((PadFileSize >> 8) & 0xFF);\r
+  PadFile->Size[2]  = (UINT8) ((PadFileSize >> 16) & 0xFF);\r
+\r
+  //\r
+  // Fill in checksums and state, they must be 0 for checksumming.\r
+  //\r
+  PadFile->IntegrityCheck.Checksum.Header = 0;\r
+  PadFile->IntegrityCheck.Checksum.File   = 0;\r
+  PadFile->State                          = 0;\r
+  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
+  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);\r
+  } else {\r
+    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) PadFile,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+\r
+  //\r
+  // Verify that we have enough space (including the padding\r
+  //\r
+  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Update the current FV pointer\r
+  //\r
+  FvImage->CurrentFilePointer += PadFileSize;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+IsVtfFile (\r
+  IN EFI_FFS_FILE_HEADER    *FileBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function checks the header to validate if it is a VTF file\r
+\r
+Arguments:\r
+\r
+  FileBuffer     Buffer in which content of a file has been read.\r
+\r
+Returns:\r
+\r
+  TRUE    If this is a VTF file\r
+  FALSE   If this is not a VTF file\r
+\r
+--*/\r
+{\r
+  EFI_GUID  VtfGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;\r
+  if (!memcmp (&FileBuffer->Name, &VtfGuid, sizeof (EFI_GUID))) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+FfsRebaseImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINT32  *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+\r
+  FileHandle - The handle to the PE/COFF file\r
+\r
+  FileOffset - The offset, in bytes, into the file to read\r
+\r
+  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
+\r
+  Buffer     - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+  CHAR8   *Destination8;\r
+  CHAR8   *Source8;\r
+  UINT32  Length;\r
+\r
+  Destination8  = Buffer;\r
+  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
+  Length        = *ReadSize;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+RebaseFfsFile (\r
+  IN OUT EFI_FFS_FILE_HEADER    *FfsFile,\r
+  IN EFI_PHYSICAL_ADDRESS       BaseAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function determines if a file is XIP and should be rebased.  It will\r
+  rebase any PE32 sections found in the file using the base address.\r
+\r
+Arguments:\r
+\r
+  FfsFile           A pointer to Ffs file image.\r
+  BaseAddress       The base address to use for rebasing the file image.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The image was properly rebased.\r
+  EFI_INVALID_PARAMETER   An input parameter is invalid.\r
+  EFI_ABORTED             An error occurred while rebasing the input file image.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate a required resource.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
+  UINTN                                 MemoryImagePointer;\r
+  UINTN                                 MemoryImagePointerAligned;\r
+\r
+  EFI_PHYSICAL_ADDRESS                  ImageAddress;\r
+  UINT64                                ImageSize;\r
+  EFI_PHYSICAL_ADDRESS                  EntryPoint;\r
+\r
+  UINT32                                Pe32FileSize;\r
+  UINT32                                NewPe32BaseAddress;\r
+\r
+  UINTN                                 Index;\r
+  EFI_FILE_SECTION_POINTER              CurrentPe32Section;\r
+  UINT8                                 FileGuidString[80];\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FfsFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Convert the GUID to a string so we can at least report which file\r
+  // if we find an error.\r
+  //\r
+  PrintGuidToBuffer (&FfsFile->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
+\r
+  //\r
+  // Do some nominal checks on the file, then check for XIP.\r
+  //\r
+  Status = VerifyFfsFile (FfsFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "invalid FFS file", FileGuidString);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE &&\r
+      FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE &&\r
+      FfsFile->Type != EFI_FV_FILETYPE_PEIM\r
+      ) {\r
+    //\r
+    // File is not XIP, so don't rebase\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Rebase each PE32 section\r
+  //\r
+  for (Index = 1;; Index++) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, Index, &CurrentPe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+    //\r
+    // Calculate the PE32 base address, the FFS file base plus the offset of the PE32 section\r
+    //\r
+    NewPe32BaseAddress = ((UINT32) BaseAddress) + ((UINTN) CurrentPe32Section.Pe32Section - (UINTN) FfsFile);\r
+\r
+    //\r
+    // Initialize context\r
+    //\r
+    memset (&ImageContext, 0, sizeof (ImageContext));\r
+    ImageContext.Handle     = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION));\r
+    ImageContext.ImageRead  = (EFI_PEI_PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
+\r
+    Status                  = mPeCoffLoader.GetImageInfo (&mPeCoffLoader, &ImageContext);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "GetImageInfo() failed", FileGuidString);\r
+      return Status;\r
+    }\r
+    //\r
+    // Allocate a buffer for the image to be loaded into.\r
+    //\r
+    Pe32FileSize              = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size);\r
+    MemoryImagePointer        = (UINTN) (malloc (Pe32FileSize + 0x1000));\r
+    MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);\r
+    if (MemoryImagePointerAligned == 0) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    //\r
+    // bugbug\r
+    //\r
+    ImageContext.ImageAddress = MemoryImagePointerAligned;\r
+    Status = mPeCoffLoader.LoadImage (&mPeCoffLoader, &ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "LoadImage() failure", FileGuidString);\r
+      free ((VOID *) MemoryImagePointer);\r
+      return Status;\r
+    }\r
+\r
+    Status = mPeCoffLoader.RelocateImage (&mPeCoffLoader, &ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "RelocateImage() failure", FileGuidString);\r
+      free ((VOID *) MemoryImagePointer);\r
+      return Status;\r
+    }\r
+\r
+    ImageAddress  = ImageContext.ImageAddress;\r
+    ImageSize     = ImageContext.ImageSize;\r
+    EntryPoint    = ImageContext.EntryPoint;\r
+\r
+    if (ImageSize > Pe32FileSize) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "rebased PE32 is larger than original PE32 image",\r
+        "0x%X > 0x%X on file %s",\r
+        ImageSize,\r
+        Pe32FileSize,\r
+        FileGuidString\r
+        );\r
+      free ((VOID *) MemoryImagePointer);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    memcpy (CurrentPe32Section.Pe32Section, (VOID *) MemoryImagePointerAligned, Pe32FileSize);\r
+\r
+    free ((VOID *) MemoryImagePointer);\r
+  }\r
+  //\r
+  // the above for loop will always exit with EFI_NOT_FOUND if it completes\r
+  // normally.  If Index == 1 at exit, then no PE32 sections were found.  If it\r
+  // exits with any other error code, then something broke...\r
+  //\r
+  if (Status != EFI_NOT_FOUND) {\r
+    Error (NULL, 0, 0, "failed to parse PE32 section", FileGuidString);\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddSymFile (\r
+  IN UINT64               BaseAddress,\r
+  IN EFI_FFS_FILE_HEADER  *FfsFile,\r
+  IN OUT MEMORY_FILE      *SymImage,\r
+  IN CHAR8                *SourceFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds the SYM tokens in the source file to the destination file.\r
+  The SYM tokens are updated to reflect the base address.\r
+\r
+Arguments:\r
+\r
+  BaseAddress     The base address for the new SYM tokens.\r
+  FfsFile         Pointer to the beginning of the FFS file in question.\r
+  SymImage        The memory file to update with symbol information.\r
+  SourceFileName  The source file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+\r
+--*/\r
+{\r
+  FILE                      *SourceFile;\r
+\r
+  CHAR8                     Buffer[_MAX_PATH];\r
+  CHAR8                     Type[_MAX_PATH];\r
+  CHAR8                     Address[_MAX_PATH];\r
+  CHAR8                     Section[_MAX_PATH];\r
+  CHAR8                     Token[_MAX_PATH];\r
+  CHAR8                     SymFileName[_MAX_PATH];\r
+  CHAR8                     CodeModuleName[_MAX_PATH];\r
+  CHAR8                     *Ptr;\r
+\r
+  UINT64                    TokenAddress;\r
+\r
+  EFI_STATUS                Status;\r
+  EFI_FILE_SECTION_POINTER  Pe32Section;\r
+  UINT32                    EntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT16                    MachineType;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (BaseAddress == 0 || FfsFile == NULL || SymImage == NULL || SourceFileName == NULL) {\r
+    Error (NULL, 0, 0, "invalid parameter passed to AddSymFile()", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Check if we want to add this file\r
+  //\r
+  //\r
+  // Get the file name\r
+  //\r
+  strcpy (Buffer, SourceFileName);\r
+\r
+  //\r
+  // Copy the file name for the path of the sym file and truncate the name portion.\r
+  //\r
+  strcpy (SymFileName, Buffer);\r
+  Ptr = strrchr (SymFileName, '\\');\r
+  assert (Ptr);\r
+  Ptr[0] = 0;\r
+\r
+  //\r
+  // Find the file extension and make it lower case\r
+  //\r
+  Ptr = strrchr (SymFileName, '.');\r
+  if (Ptr != NULL) {\r
+    _strlwr (Ptr);\r
+  }\r
+  //\r
+  // Check if it is PEI file\r
+  //\r
+  if (strstr (Buffer, ".pei") != NULL) {\r
+    //\r
+    // Find the human readable portion\r
+    //\r
+    if (!strtok (Buffer, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strcpy (Buffer, strtok (NULL, "."))\r
+          ) {\r
+      Error (NULL, 0, 0, "failed to find human readable portion of the file name in AddSymFile()", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Save code module name\r
+    //\r
+    strcpy (CodeModuleName, Buffer);\r
+\r
+    //\r
+    // Add the symbol file name and extension to the file path.\r
+    //\r
+    strcat (Buffer, ".sym");\r
+    strcat (SymFileName, "\\");\r
+    strcat (SymFileName, Buffer);\r
+  } else {\r
+    //\r
+    // Only handle PEIM files.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Find PE32 section\r
+  //\r
+  Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+\r
+  //\r
+  // BUGBUG: Assume if no PE32 section it is PIC and hardcode base address\r
+  //\r
+  if (Status == EFI_NOT_FOUND) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_TE, 1, &Pe32Section);\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    Status = GetPe32Info (\r
+               (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+               &EntryPoint,\r
+               &BaseOfCode,\r
+               &MachineType\r
+               );\r
+  } else {\r
+    if (Status == EFI_NOT_FOUND) {\r
+      BaseOfCode = 0x60;\r
+      Status     = EFI_SUCCESS;\r
+    } else {\r
+      Error (NULL, 0, 0, "could not parse a PE32 section from the PEI file", NULL);\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "GetPe32Info() could not get PE32 entry point for PEI file", NULL);\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Open the source file\r
+  //\r
+  SourceFile = fopen (SymFileName, "r");\r
+  if (SourceFile == NULL) {\r
+    //\r
+    // SYM files are not required.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Read the first line\r
+  //\r
+  if (fgets (Buffer, _MAX_PATH, SourceFile) == NULL) {\r
+    Buffer[0] = 0;\r
+  }\r
+  //\r
+  // Make sure it matches the expected sym format\r
+  //\r
+  if (strcmp (Buffer, "TEXTSYM format | V1.0\n")) {\r
+    fclose (SourceFile);\r
+    Error (NULL, 0, 0, "AddSymFile() found unexpected sym format in input file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read in the file\r
+  //\r
+  while (feof (SourceFile) == 0) {\r
+    //\r
+    // Read a line\r
+    //\r
+    if (fscanf (\r
+          SourceFile,\r
+          "%s | %s | %s | %s\n",\r
+          Type,\r
+          Address,\r
+          Section,\r
+          Token\r
+          ) == 4) {\r
+      //\r
+      // If the token starts with "??" ignore it\r
+      //\r
+      if (Token[0] == '?' && Token[1] == '?') {\r
+        continue;\r
+      }\r
+      //\r
+      // Get the token address\r
+      //\r
+      AsciiStringToUint64 (Address, TRUE, &TokenAddress);\r
+\r
+      //\r
+      // Add the base address\r
+      //\r
+      TokenAddress += BaseAddress;\r
+\r
+      //\r
+      // If PE32 or TE section then find the start of code.  For PIC it is hardcoded.\r
+      //\r
+      if (Pe32Section.Pe32Section) {\r
+        //\r
+        // Add the offset of the PE32 section\r
+        //\r
+        TokenAddress += (UINTN) Pe32Section.Pe32Section - (UINTN) FfsFile;\r
+\r
+        //\r
+        // Add the size of the PE32 section header\r
+        //\r
+        TokenAddress += sizeof (EFI_PE32_SECTION);\r
+      } else {\r
+        //\r
+        // BUGBUG: Don't know why this is 0x28 bytes.\r
+        //\r
+        TokenAddress += 0x28;\r
+      }\r
+      //\r
+      // Add the beginning of the code\r
+      //\r
+      TokenAddress += BaseOfCode;\r
+\r
+      sprintf (\r
+        Buffer,\r
+        "%s | %016I64X | %s | _%s%s\n",\r
+        Type,\r
+        TokenAddress,\r
+        Section,\r
+        CodeModuleName,\r
+        Token\r
+        );\r
+      memcpy (SymImage->CurrentFilePointer, Buffer, strlen (Buffer) + 1);\r
+      SymImage->CurrentFilePointer = (UINT8 *) (((UINTN) SymImage->CurrentFilePointer) + strlen (Buffer) + 1);\r
+    }\r
+  }\r
+\r
+  fclose (SourceFile);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFile (\r
+  IN OUT MEMORY_FILE          *FvImage,\r
+  IN FV_INFO                  *FvInfo,\r
+  IN UINTN                    Index,\r
+  IN OUT EFI_FFS_FILE_HEADER  **VtfFileImage,\r
+  IN OUT MEMORY_FILE          *SymImage\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds a file to the FV image.  The file will pad to the\r
+  appropriate alignment if required.\r
+\r
+Arguments:\r
+\r
+  FvImage       The memory image of the FV to add it to.  The current offset\r
+                must be valid.\r
+  FvInfo        Pointer to information about the FV.\r
+  Index         The file in the FvInfo file list to add.\r
+  VtfFileImage  A pointer to the VTF file within the FvImage.  If this is equal\r
+                to the end of the FvImage then no VTF previously found.\r
+  SymImage      The memory image of the Sym file to update if symbols are present.\r
+                The current offset must be valid.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
+\r
+--*/\r
+{\r
+  FILE                  *NewFile;\r
+  UINTN                 FileSize;\r
+  UINT8                 *FileBuffer;\r
+  UINTN                 NumBytesRead;\r
+  UINT32                CurrentFileAlignment;\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  CurrentFileBaseAddress;\r
+  UINT8                 VtfHeaderChecksum;\r
+  UINT8                 VtfFileChecksum;\r
+  UINT8                 FileState;\r
+  UINT32                TailSize;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  EFI_FFS_FILE_TAIL     TailValue;\r
+#endif\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FvImage == NULL || FvInfo == NULL || FvInfo->FvFiles[Index][0] == 0 || VtfFileImage == NULL || SymImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Read the file to add\r
+  //\r
+  NewFile = fopen (FvInfo->FvFiles[Index], "rb");\r
+\r
+  if (NewFile == NULL) {\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to open file for reading");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the file size\r
+  //\r
+  FileSize = _filelength (_fileno (NewFile));\r
+\r
+  //\r
+  // Read the file into a buffer\r
+  //\r
+  FileBuffer = malloc (FileSize);\r
+  if (FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NumBytesRead = fread (FileBuffer, sizeof (UINT8), FileSize, NewFile);\r
+\r
+  //\r
+  // Done with the file, from this point on we will just use the buffer read.\r
+  //\r
+  fclose (NewFile);\r
+\r
+  //\r
+  // Verify read successful\r
+  //\r
+  if (NumBytesRead != sizeof (UINT8) * FileSize) {\r
+    free (FileBuffer);\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify space exists to add the file\r
+  //\r
+  if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Update the file state based on polarity of the FV.\r
+  //\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) FileBuffer,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+\r
+  //\r
+  // If we have a VTF file, add it at the top.\r
+  //\r
+  if (IsVtfFile ((EFI_FFS_FILE_HEADER *) FileBuffer)) {\r
+    if ((UINTN) *VtfFileImage == (UINTN) FvImage->Eof) {\r
+      //\r
+      // No previous VTF, add this one.\r
+      //\r
+      *VtfFileImage = (EFI_FFS_FILE_HEADER *) (UINTN) ((UINTN) FvImage->FileImage + FvInfo->Size - FileSize);\r
+      //\r
+      // Sanity check. The file MUST align appropriately\r
+      //\r
+      if ((((UINTN) *VtfFileImage) & 0x07) != 0) {\r
+        Error (NULL, 0, 0, "VTF file does not align on 8-byte boundary", NULL);\r
+      }\r
+      //\r
+      // copy VTF File Header\r
+      //\r
+      memcpy (*VtfFileImage, FileBuffer, sizeof (EFI_FFS_FILE_HEADER));\r
+\r
+      //\r
+      // Copy VTF body\r
+      //\r
+      memcpy (\r
+        (UINT8 *) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER),\r
+        FileBuffer + sizeof (EFI_FFS_FILE_HEADER),\r
+        FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
+        );\r
+\r
+      //\r
+      // re-calculate the VTF File Header\r
+      //\r
+      FileState = (*VtfFileImage)->State;\r
+      (*VtfFileImage)->State = 0;\r
+      *(UINT32 *) ((*VtfFileImage)->Size) = FileSize;\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.Header = 0;\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.File = 0;\r
+\r
+      VtfHeaderChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, sizeof (EFI_FFS_FILE_HEADER));\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.Header = VtfHeaderChecksum;\r
+      //\r
+      // Determine if it has a tail\r
+      //\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+      } else {\r
+        TailSize = 0;\r
+      }\r
+\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+        VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);\r
+        (*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;\r
+      } else {\r
+        (*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+      }\r
+    #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+      //\r
+      // If it has a file tail, update it\r
+      //\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        TailValue = (EFI_FFS_FILE_TAIL) (~((*VtfFileImage)->IntegrityCheck.TailReference));\r
+        *(EFI_FFS_FILE_TAIL *) (((UINTN) (*VtfFileImage) + GetLength ((*VtfFileImage)->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+      }\r
+    #endif  \r
+      (*VtfFileImage)->State = FileState;\r
+      free (FileBuffer);\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      //\r
+      // Already found a VTF file.\r
+      //\r
+      Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);\r
+      free (FileBuffer);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // Check if alignment is required\r
+  //\r
+  Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Add pad file if necessary\r
+  //\r
+  Status = AddPadFile (FvImage, CurrentFileAlignment);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not align the file data properly.\n");\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Add file\r
+  //\r
+  if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {\r
+    //\r
+    // Copy the file\r
+    //\r
+    memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
+\r
+    //\r
+    // If the file is XIP, rebase\r
+    //\r
+    CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);\r
+    //\r
+    //    Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);\r
+    //    if (EFI_ERROR(Status)) {\r
+    //      printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);\r
+    //      return EFI_ABORTED;\r
+    //    }\r
+    //\r
+    // Update Symbol file\r
+    //\r
+    Status = AddSymFile (\r
+              CurrentFileBaseAddress,\r
+              (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,\r
+              SymImage,\r
+              FvInfo->FvFiles[Index]\r
+              );\r
+    assert (!EFI_ERROR (Status));\r
+\r
+    //\r
+    // Update the current pointer in the FV image\r
+    //\r
+    FvImage->CurrentFilePointer += FileSize;\r
+  } else {\r
+    printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Make next file start at QWord Boundry\r
+  //\r
+  while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {\r
+    FvImage->CurrentFilePointer++;\r
+  }\r
+  //\r
+  // Free allocated memory.\r
+  //\r
+  free (FileBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddVariableBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  VARIABLE_STORE_HEADER       *VarStoreHeader;\r
+  //\r
+  // Variable block should exclude FvHeader. Since the length of\r
+  // FvHeader depends on the block map, which is variable length,\r
+  // we could only decide the actual variable block length here.\r
+  //\r
+  FvHeader                  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
+  FvImage                   = FvImage + FvHeader->HeaderLength;\r
+\r
+  VarStoreHeader            = (VARIABLE_STORE_HEADER *) FvImage;\r
+\r
+  VarStoreHeader->Signature = VARIABLE_STORE_SIGNATURE;\r
+  VarStoreHeader->Size      = Size - FvHeader->HeaderLength;\r
+  VarStoreHeader->Format    = VARIABLE_STORE_FORMATTED;\r
+  VarStoreHeader->State     = VARIABLE_STORE_HEALTHY;\r
+  VarStoreHeader->Reserved  = 0;\r
+  VarStoreHeader->Reserved1 = 0;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddEventLogBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFTWWorkingBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FTWHeader;\r
+  UINT32                                  Crc32;\r
+\r
+  Crc32     = 0;\r
+  FTWHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) FvImage;\r
+  memcpy (&FTWHeader->Signature, &(FvInfo->FvGuid), sizeof (EFI_GUID));\r
+  FTWHeader->WriteQueueSize = Size - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);\r
+  CalculateCrc32 (FvImage, sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER), &Crc32);\r
+  FTWHeader->Crc = Crc32;\r
+  if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
+    FTWHeader->WorkingBlockValid    = 0;\r
+    FTWHeader->WorkingBlockInvalid  = 1;\r
+  } else {\r
+    FTWHeader->WorkingBlockValid    = 1;\r
+    FTWHeader->WorkingBlockInvalid  = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFTWSpareBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GenNonFFSFv (\r
+  IN UINT8                    *FvImage,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generate the non FFS FV image, such as the working block\r
+  and spare block. How each component of the FV is built is component\r
+  specific.\r
+\r
+Arguments:\r
+\r
+  FvImage       The memory image of the FV to add it to.  The current offset\r
+                must be valid.\r
+  FvInfo        Pointer to information about the FV.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
+\r
+--*/\r
+{\r
+  UINTN                       Index;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  UINT64                      TotalSize;\r
+\r
+  FvHeader  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
+  TotalSize = 0;\r
+\r
+  for (Index = 0; FvInfo->FvComponents[Index].Size != 0; Index++) {\r
+    if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING) == 0) {\r
+      AddVariableBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING) == 0) {\r
+      AddEventLogBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING) == 0) {\r
+      AddFTWWorkingBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {\r
+      AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else {\r
+      printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    FvImage   = FvImage + FvInfo->FvComponents[Index].Size;\r
+    TotalSize = TotalSize + FvInfo->FvComponents[Index].Size;\r
+  }\r
+  //\r
+  // Index and TotalSize is zero mean there's no component, so this is an empty fv\r
+  //\r
+  if ((Index != 0 || TotalSize != 0) && TotalSize != FvInfo->Size) {\r
+    printf ("Error. Component size does not sum up to FV size.\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PadFvImage (\r
+  IN MEMORY_FILE          *FvImage,\r
+  IN EFI_FFS_FILE_HEADER  *VtfFileImage\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function places a pad file between the last file in the FV and the VTF\r
+  file if the VTF file exists.\r
+\r
+Arguments:\r
+\r
+  FvImage       Memory file for the FV memory image\r
+  VtfFileImage  The address of the VTF file.  If this is the end of the FV\r
+                image, no VTF exists and no pad file is needed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the input parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *PadFile;\r
+  UINTN               FileSize;\r
+\r
+  //\r
+  // If there is no VTF or the VTF naturally follows the previous file without a\r
+  // pad file, then there's nothing to do\r
+  //\r
+  if ((UINTN) VtfFileImage == (UINTN) FvImage->Eof || (void *) FvImage->CurrentFilePointer == (void *) VtfFileImage) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Pad file starts at beginning of free space\r
+  //\r
+  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
+\r
+  //\r
+  // write header\r
+  //\r
+  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  memcpy (&PadFile->Name, &DefaultFvPadFileNameGuid, sizeof (EFI_GUID));\r
+  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
+  PadFile->Attributes = 0;\r
+\r
+  //\r
+  // FileSize includes the EFI_FFS_FILE_HEADER\r
+  //\r
+  FileSize          = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer;\r
+  PadFile->Size[0]  = (UINT8) (FileSize & 0x000000FF);\r
+  PadFile->Size[1]  = (UINT8) ((FileSize & 0x0000FF00) >> 8);\r
+  PadFile->Size[2]  = (UINT8) ((FileSize & 0x00FF0000) >> 16);\r
+\r
+  //\r
+  // Fill in checksums and state, must be zero during checksum calculation.\r
+  //\r
+  PadFile->IntegrityCheck.Checksum.Header = 0;\r
+  PadFile->IntegrityCheck.Checksum.File   = 0;\r
+  PadFile->State                          = 0;\r
+  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
+  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);\r
+  } else {\r
+    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) PadFile,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+  //\r
+  // Update the current FV pointer\r
+  //\r
+  FvImage->CurrentFilePointer = FvImage->Eof;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UpdateResetVector (\r
+  IN MEMORY_FILE            *FvImage,\r
+  IN FV_INFO                *FvInfo,\r
+  IN EFI_FFS_FILE_HEADER    *VtfFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This parses the FV looking for the PEI core and then plugs the address into\r
+  the SALE_ENTRY point of the BSF/VTF for IPF and does BUGBUG TBD action to\r
+  complete an IA32 Bootstrap FV.\r
+\r
+Arguments:\r
+\r
+  FvImage       Memory file for the FV memory image\r
+  FvInfo        Information read from INF file.\r
+  VtfFile       Pointer to the VTF file in the FV image.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_NOT_FOUND           PEI Core file not found.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER       *PeiCoreFile;\r
+  EFI_FFS_FILE_HEADER       *SecCoreFile;\r
+  EFI_STATUS                Status;\r
+  EFI_FILE_SECTION_POINTER  Pe32Section;\r
+  UINT32                    EntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT16                    MachineType;\r
+  EFI_PHYSICAL_ADDRESS      PeiCorePhysicalAddress;\r
+  EFI_PHYSICAL_ADDRESS      SecCorePhysicalAddress;\r
+  EFI_PHYSICAL_ADDRESS      *SecCoreEntryAddressPtr;\r
+  UINT32                    *Ia32ResetAddressPtr;\r
+  UINT8                     *BytePointer;\r
+  UINT8                     *BytePointer2;\r
+  UINT16                    *WordPointer;\r
+  UINT16                    CheckSum;\r
+  UINTN                     Index;\r
+  EFI_FFS_FILE_STATE        SavedState;\r
+  UINT32                    TailSize;\r
+  UINT64                    FitAddress;\r
+  FIT_TABLE                 *FitTablePtr;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  EFI_FFS_FILE_TAIL         TailValue;\r
+#endif\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FvImage == NULL || FvInfo == NULL || VtfFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize FV library\r
+  //\r
+  InitializeFvLib (FvImage->FileImage, (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage);\r
+\r
+  //\r
+  // Verify VTF file\r
+  //\r
+  Status = VerifyFfsFile (VtfFile);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Find the PEI Core\r
+  //\r
+  Status = GetFileByType (EFI_FV_FILETYPE_PEI_CORE, 1, &PeiCoreFile);\r
+  if (EFI_ERROR (Status) || PeiCoreFile == NULL) {\r
+    Error (NULL, 0, 0, "could not find the PEI core in the FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // PEI Core found, now find PE32 or TE section\r
+  //\r
+  Status = GetSectionByType (PeiCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+  if (Status == EFI_NOT_FOUND) {\r
+    Status = GetSectionByType (PeiCoreFile, EFI_SECTION_TE, 1, &Pe32Section);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "could not find PE32 or TE section in PEI core file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Status = GetPe32Info (\r
+            (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+            &EntryPoint,\r
+            &BaseOfCode,\r
+            &MachineType\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "could not get PE32 entry point for PEI core", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Physical address is FV base + offset of PE32 + offset of the entry point\r
+  //\r
+  PeiCorePhysicalAddress = FvInfo->BaseAddress;\r
+  PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
+  PeiCorePhysicalAddress += EntryPoint;\r
+\r
+  if (MachineType == EFI_IMAGE_MACHINE_IA64) {\r
+    //\r
+    // Update PEI_CORE address\r
+    //\r
+    //\r
+    // Set the uncached attribute bit in the physical address\r
+    //\r
+    PeiCorePhysicalAddress |= 0x8000000000000000;\r
+\r
+    //\r
+    // Check if address is aligned on a 16 byte boundary\r
+    //\r
+    if (PeiCorePhysicalAddress & 0xF) {\r
+      printf (\r
+        "ERROR: PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
+        PeiCorePhysicalAddress\r
+        );\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // First Get the FIT table address\r
+    //\r
+    FitAddress  = (*(UINT64 *) (FvImage->Eof - IPF_FIT_ADDRESS_OFFSET)) & 0xFFFFFFFF;\r
+\r
+    FitTablePtr = (FIT_TABLE *) (FvImage->FileImage + (FitAddress - FvInfo->BaseAddress));\r
+\r
+    Status      = UpdatePeiCoreEntryInFit (FitTablePtr, PeiCorePhysicalAddress);\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      UpdateFitCheckSum (FitTablePtr);\r
+    }\r
+    //\r
+    // Find the Sec Core\r
+    //\r
+    Status = GetFileByType (EFI_FV_FILETYPE_SECURITY_CORE, 1, &SecCoreFile);\r
+    if (EFI_ERROR (Status) || SecCoreFile == NULL) {\r
+      Error (NULL, 0, 0, "could not find the Sec core in the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Sec Core found, now find PE32 section\r
+    //\r
+    Status = GetSectionByType (SecCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "could not find PE32 section in SEC core file", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    Status = GetPe32Info (\r
+              (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+              &EntryPoint,\r
+              &BaseOfCode,\r
+              &MachineType\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "could not get PE32 entry point for SEC core", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Physical address is FV base + offset of PE32 + offset of the entry point\r
+    //\r
+    SecCorePhysicalAddress = FvInfo->BaseAddress;\r
+    SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
+    SecCorePhysicalAddress += EntryPoint;\r
+\r
+    //\r
+    // Update SEC_CORE address\r
+    //\r
+    //\r
+    // Set the uncached attribute bit in the physical address\r
+    //\r
+    SecCorePhysicalAddress |= 0x8000000000000000;\r
+\r
+    //\r
+    // Update the address\r
+    //\r
+    SecCoreEntryAddressPtr  = (EFI_PHYSICAL_ADDRESS *) ((UINTN) FvImage->Eof - IPF_SALE_ENTRY_ADDRESS_OFFSET);\r
+    *SecCoreEntryAddressPtr = SecCorePhysicalAddress;\r
+\r
+    //\r
+    // Check if address is aligned on a 16 byte boundary\r
+    //\r
+    if (SecCorePhysicalAddress & 0xF) {\r
+      printf (\r
+        "ERROR: SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
+        SecCorePhysicalAddress\r
+        );\r
+      return EFI_ABORTED;\r
+    }\r
+  } else if ((MachineType == EFI_IMAGE_MACHINE_IA32) || \r
+             (MachineType == EFI_IMAGE_MACHINE_X64)) {\r
+    //\r
+    // Get the location to update\r
+    //\r
+    Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - IA32_PEI_CORE_ENTRY_OFFSET);\r
+\r
+    //\r
+    // Write lower 32 bits of physical address\r
+    //\r
+    *Ia32ResetAddressPtr = (UINT32) PeiCorePhysicalAddress;\r
+\r
+    //\r
+    // Update the BFV base address\r
+    //\r
+    Ia32ResetAddressPtr   = (UINT32 *) ((UINTN) FvImage->Eof - 4);\r
+    *Ia32ResetAddressPtr  = (UINT32) (FvInfo->BaseAddress);\r
+\r
+    CheckSum              = 0x0000;\r
+\r
+    //\r
+    // Update the Startup AP in the FVH header block ZeroVector region.\r
+    //\r
+    BytePointer   = (UINT8 *) ((UINTN) FvImage->FileImage);\r
+    BytePointer2  = (FvInfo->Size == 0x10000) ? m64kRecoveryStartupApDataArray : m128kRecoveryStartupApDataArray;\r
+    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY; Index++) {\r
+      *BytePointer++ = *BytePointer2++;\r
+    }\r
+    //\r
+    // Calculate the checksum\r
+    //\r
+    WordPointer = (UINT16 *) ((UINTN) FvImage->FileImage);\r
+    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY / 2; Index++) {\r
+      CheckSum = (UINT16) (CheckSum + ((UINT16) *WordPointer));\r
+      WordPointer++;\r
+    }\r
+    //\r
+    // Update the checksum field\r
+    //\r
+    BytePointer = (UINT8 *) ((UINTN) FvImage->FileImage);\r
+    BytePointer += (SIZEOF_STARTUP_DATA_ARRAY - 2);\r
+    WordPointer   = (UINT16 *) BytePointer;\r
+    *WordPointer  = (UINT16) (0x10000 - (UINT32) CheckSum);\r
+  } else {\r
+    Error (NULL, 0, 0, "invalid machine type in PEI core", "machine type=0x%X", (UINT32) MachineType);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Determine if it has an FFS file tail.\r
+  //\r
+  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+  } else {\r
+    TailSize = 0;\r
+  }\r
+  //\r
+  // Now update file checksum\r
+  //\r
+  SavedState  = VtfFile->State;\r
+  VtfFile->IntegrityCheck.Checksum.File = 0;\r
+  VtfFile->State                        = 0;\r
+  if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                              (UINT8 *) VtfFile,\r
+                                              GetLength (VtfFile->Size) - TailSize\r
+                                              );\r
+  } else {\r
+    VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  VtfFile->State = SavedState;\r
+\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  //\r
+  // Update tail if present\r
+  //\r
+  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailValue = (EFI_FFS_FILE_TAIL) (~(VtfFile->IntegrityCheck.TailReference));\r
+    *(EFI_FFS_FILE_TAIL *) (((UINTN) (VtfFile) + GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+  }\r
+#endif\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetPe32Info (\r
+  IN UINT8                  *Pe32,\r
+  OUT UINT32                *EntryPoint,\r
+  OUT UINT32                *BaseOfCode,\r
+  OUT UINT16                *MachineType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the PE32 entry point offset and machine type from PE image or TE image.\r
+  See EfiImage.h for machine types.  The entry point offset is from the beginning\r
+  of the PE32 buffer passed in.\r
+\r
+Arguments:\r
+\r
+  Pe32          Beginning of the PE32.\r
+  EntryPoint    Offset from the beginning of the PE32 to the image entry point.\r
+  BaseOfCode    Base address of code.\r
+  MachineType   Magic number for the machine type.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_UNSUPPORTED         The operation is unsupported.\r
+\r
+--*/\r
+{\r
+  EFI_IMAGE_DOS_HEADER  *DosHeader;\r
+  EFI_IMAGE_NT_HEADERS  *NtHeader;\r
+  EFI_TE_IMAGE_HEADER   *TeHeader;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (Pe32 == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // First check whether it is one TE Image.\r
+  //\r
+  TeHeader = (EFI_TE_IMAGE_HEADER *) Pe32;\r
+  if (TeHeader->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    //\r
+    // By TeImage Header to get output\r
+    //\r
+    *EntryPoint  = TeHeader->AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
+    *BaseOfCode  = TeHeader->BaseOfCode + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
+    *MachineType = TeHeader->Machine;\r
+  } else {\r
+    //\r
+    // Then check whether\r
+    // is the DOS header\r
+    //\r
+    DosHeader = (EFI_IMAGE_DOS_HEADER *) Pe32;\r
+\r
+    //\r
+    // Verify DOS header is expected\r
+    //\r
+    if (DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+      printf ("ERROR: Unknown magic number in the DOS header, 0x%04X.\n", DosHeader->e_magic);\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    //\r
+    // Immediately following is the NT header.\r
+    //\r
+    NtHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32 + DosHeader->e_lfanew);\r
+    \r
+    //\r
+    // Verify NT header is expected\r
+    //\r
+    if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+      printf ("ERROR: Unrecognized image signature 0x%08X.\n", NtHeader->Signature);\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    //\r
+    // Get output\r
+    //\r
+    *EntryPoint   = NtHeader->OptionalHeader.AddressOfEntryPoint;\r
+    *BaseOfCode   = NtHeader->OptionalHeader.BaseOfCode;\r
+    *MachineType  = NtHeader->FileHeader.Machine;\r
+  }\r
+\r
+  //\r
+  // Verify machine type is supported\r
+  //\r
+  if (*MachineType != EFI_IMAGE_MACHINE_IA32 && \r
+      *MachineType != EFI_IMAGE_MACHINE_IA64 &&\r
+      *MachineType != EFI_IMAGE_MACHINE_X64) {\r
+    printf ("ERROR: Unrecognized machine type in the PE32 file.\n");\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// Exposed function implementations (prototypes are defined in GenFvImageLib.h)\r
+//\r
+EFI_STATUS\r
+GenerateFvImage (\r
+  IN CHAR8    *InfFileImage,\r
+  IN UINTN    InfFileSize,\r
+  OUT UINT8   **FvImage,\r
+  OUT UINTN   *FvImageSize,\r
+  OUT CHAR8   **FvFileName,\r
+  OUT UINT8   **SymImage,\r
+  OUT UINTN   *SymImageSize,\r
+  OUT CHAR8   **SymFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the main function which will be called from application.\r
+\r
+Arguments:\r
+\r
+  InfFileImage  Buffer containing the INF file contents.\r
+  InfFileSize   Size of the contents of the InfFileImage buffer.\r
+  FvImage       Pointer to the FV image created.\r
+  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
+  FvFileName    Requested name for the FV file.\r
+  SymImage      Pointer to the Sym image created.\r
+  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
+  SymFileName   Requested name for the Sym file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  MEMORY_FILE                 InfMemoryFile;\r
+  MEMORY_FILE                 FvImageMemoryFile;\r
+  MEMORY_FILE                 SymImageMemoryFile;\r
+  FV_INFO                     FvInfo;\r
+  UINTN                       Index;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  EFI_FFS_FILE_HEADER         *VtfFileImage;\r
+\r
+  //\r
+  // Check for invalid parameter\r
+  //\r
+  if (InfFileImage == NULL || FvImage == NULL || FvImageSize == NULL || FvFileName == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize file structures\r
+  //\r
+  InfMemoryFile.FileImage           = InfFileImage;\r
+  InfMemoryFile.CurrentFilePointer  = InfFileImage;\r
+  InfMemoryFile.Eof                 = InfFileImage + InfFileSize;\r
+\r
+  //\r
+  // Parse the FV inf file for header information\r
+  //\r
+  Status = ParseFvInf (&InfMemoryFile, &FvInfo);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not parse the input INF file.\n");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Update the file name return values\r
+  //\r
+  strcpy (*FvFileName, FvInfo.FvName);\r
+  strcpy (*SymFileName, FvInfo.SymName);\r
+\r
+  //\r
+  // Calculate the FV size\r
+  //\r
+  *FvImageSize = FvInfo.Size;\r
+\r
+  //\r
+  // Allocate the FV\r
+  //\r
+  *FvImage = malloc (*FvImageSize);\r
+  if (*FvImage == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Allocate space for symbol file storage\r
+  //\r
+  *SymImage = malloc (SYMBOL_FILE_SIZE);\r
+  if (*SymImage == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Initialize the FV to the erase polarity\r
+  //\r
+  if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
+    memset (*FvImage, -1, *FvImageSize);\r
+  } else {\r
+    memset (*FvImage, 0, *FvImageSize);\r
+  }\r
+  //\r
+  // Initialize FV header\r
+  //\r
+  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) *FvImage;\r
+\r
+  //\r
+  // Initialize the zero vector to all zeros.\r
+  //\r
+  memset (FvHeader->ZeroVector, 0, 16);\r
+\r
+  //\r
+  // Copy the FFS GUID\r
+  //\r
+  memcpy (&FvHeader->FileSystemGuid, &FvInfo.FvGuid, sizeof (EFI_GUID));\r
+\r
+  FvHeader->FvLength    = *FvImageSize;\r
+  FvHeader->Signature   = EFI_FVH_SIGNATURE;\r
+  FvHeader->Attributes  = FvInfo.FvAttributes;\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+  FvHeader->Revision    = EFI_FVH_REVISION;\r
+  FvHeader->Reserved[0] = 0;\r
+  FvHeader->Reserved[1] = 0;\r
+  FvHeader->Reserved[2] = 0;\r
+#else\r
+  FvHeader->Revision    = EFI_FVH_PI_REVISION;\r
+  FvHeader->ExtHeaderOffset = 0;\r
+  FvHeader->Reserved[0] = 0;\r
+#endif\r
+  //\r
+  // Copy firmware block map\r
+  //\r
+  for (Index = 0; FvInfo.FvBlocks[Index].NumBlocks != 0; Index++) {\r
+    FvHeader->FvBlockMap[Index].NumBlocks   = FvInfo.FvBlocks[Index].NumBlocks;\r
+    FvHeader->FvBlockMap[Index].BlockLength = FvInfo.FvBlocks[Index].BlockLength;\r
+  }\r
+  //\r
+  // Add block map terminator\r
+  //\r
+  FvHeader->FvBlockMap[Index].NumBlocks   = 0;\r
+  FvHeader->FvBlockMap[Index].BlockLength = 0;\r
+\r
+  //\r
+  // Complete the header\r
+  //\r
+  FvHeader->HeaderLength  = (UINT16) (((UINTN) &(FvHeader->FvBlockMap[Index + 1])) - (UINTN) *FvImage);\r
+  FvHeader->Checksum      = 0;\r
+  FvHeader->Checksum      = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+\r
+  //\r
+  // If there is no FFS file, find and generate each components of the FV\r
+  //\r
+  if (FvInfo.FvFiles[0][0] == 0) {\r
+    Status = GenNonFFSFv (*FvImage, &FvInfo);\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not generate NonFFS FV.\n");\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Initialize our "file" view of the buffer\r
+  //\r
+  FvImageMemoryFile.FileImage           = *FvImage;\r
+  FvImageMemoryFile.CurrentFilePointer  = *FvImage + FvHeader->HeaderLength;\r
+  FvImageMemoryFile.Eof                 = *FvImage +*FvImageSize;\r
+\r
+  //\r
+  // Initialize our "file" view of the symbol file.\r
+  //\r
+  SymImageMemoryFile.FileImage          = *SymImage;\r
+  SymImageMemoryFile.CurrentFilePointer = *SymImage;\r
+  SymImageMemoryFile.Eof                = *FvImage + SYMBOL_FILE_SIZE;\r
+\r
+  //\r
+  // Initialize the FV library.\r
+  //\r
+  InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);\r
+\r
+  //\r
+  // Files start on 8 byte alignments, so move to the next 8 byte aligned\r
+  // address.  For now, just assert if it isn't.  Currently FV header is\r
+  // always a multiple of 8 bytes.\r
+  // BUGBUG: Handle this better\r
+  //\r
+  assert ((((UINTN) FvImageMemoryFile.CurrentFilePointer) % 8) == 0);\r
+\r
+  //\r
+  // Initialize the VTF file address.\r
+  //\r
+  VtfFileImage = (EFI_FFS_FILE_HEADER *) FvImageMemoryFile.Eof;\r
+\r
+  //\r
+  // Add files to FV\r
+  //\r
+  for (Index = 0; FvInfo.FvFiles[Index][0] != 0; Index++) {\r
+    //\r
+    // Add the file\r
+    //\r
+    Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);\r
+\r
+    //\r
+    // Exit if error detected while adding the file\r
+    //\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not add file %s.\n", FvInfo.FvFiles[Index]);\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // If there is a VTF file, some special actions need to occur.\r
+  //\r
+  if ((UINTN) VtfFileImage != (UINTN) FvImageMemoryFile.Eof) {\r
+    //\r
+    // Pad from the end of the last file to the beginning of the VTF file.\r
+    //\r
+    Status = PadFvImage (&FvImageMemoryFile, VtfFileImage);\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not create the pad file between the last file and the VTF file.\n");\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Update reset vector (SALE_ENTRY for IPF)\r
+    // Now for IA32 and IA64 platform, the fv which has bsf file must have the \r
+    // EndAddress of 0xFFFFFFFF. Thus, only this type fv needs to update the   \r
+    // reset vector. If the PEI Core is found, the VTF file will probably get  \r
+    // corrupted by updating the entry point.                                  \r
+    //\r
+    if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {       \r
+      Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);\r
+      if (EFI_ERROR(Status)) {                                               \r
+        printf ("ERROR: Could not update the reset vector.\n");              \r
+        free (*FvImage);                                                     \r
+        return EFI_ABORTED;                                                  \r
+      }                                                                      \r
+    }\r
+  } \r
+  //\r
+  // Determine final Sym file size\r
+  //\r
+  *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UpdatePeiCoreEntryInFit (\r
+  IN FIT_TABLE     *FitTablePtr,\r
+  IN UINT64        PeiCorePhysicalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
+  Sec to Pei Core\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
+  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
+\r
+--*/\r
+{\r
+  FIT_TABLE *TmpFitPtr;\r
+  UINTN     Index;\r
+  UINTN     NumFitComponents;\r
+\r
+  TmpFitPtr         = FitTablePtr;\r
+  NumFitComponents  = TmpFitPtr->CompSize;\r
+\r
+  for (Index = 0; Index < NumFitComponents; Index++) {\r
+    if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) == COMP_TYPE_FIT_PEICORE) {\r
+      TmpFitPtr->CompAddress = PeiCorePhysicalAddress;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    TmpFitPtr++;\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+VOID\r
+UpdateFitCheckSum (\r
+  IN FIT_TABLE   *FitTablePtr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the checksum for FIT.\r
+\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  if ((FitTablePtr->CvAndType & CHECKSUM_BIT_MASK) >> 7) {\r
+    FitTablePtr->CheckSum = 0;\r
+    FitTablePtr->CheckSum = CalculateChecksum8 ((UINT8 *) FitTablePtr, FitTablePtr->CompSize * 16);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h
new file mode 100644 (file)
index 0000000..e1db1b1
--- /dev/null
@@ -0,0 +1,140 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageLib.h\r
+\r
+Abstract:\r
+\r
+  This file contains describes the public interfaces to the GenFvImage Library.\r
+  The basic purpose of the library is to create Firmware Volume images.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_FV_IMAGE_LIB_H\r
+#define _EFI_GEN_FV_IMAGE_LIB_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include "Efi2WinNT.h"\r
+#include "ParseInf.h"\r
+\r
+//\r
+// Following definition is used for FIT in IPF\r
+//\r
+#define COMP_TYPE_FIT_PEICORE 0x10\r
+#define COMP_TYPE_FIT_UNUSED  0x7F\r
+\r
+#define FIT_TYPE_MASK         0x7F\r
+#define CHECKSUM_BIT_MASK     0x80\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT64  CompAddress;\r
+  UINT32  CompSize;\r
+  UINT16  CompVersion;\r
+  UINT8   CvAndType;\r
+  UINT8   CheckSum;\r
+} FIT_TABLE;\r
+\r
+#pragma pack()\r
+//\r
+// Exported function prototypes\r
+//\r
+EFI_STATUS\r
+GenerateFvImage (\r
+  IN CHAR8    *InfFileImage,\r
+  IN UINTN    InfFileSize,\r
+  OUT UINT8   **FvImage,\r
+  OUT UINTN   *FvImageSize,\r
+  OUT CHAR8   **FvFileName,\r
+  OUT UINT8   **SymImage,\r
+  OUT UINTN   *SymImageSize,\r
+  OUT CHAR8   **SymFileName\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the main function which will be called from application.\r
+\r
+Arguments:\r
+\r
+  InfFileImage  Buffer containing the INF file contents.\r
+  InfFileSize   Size of the contents of the InfFileImage buffer.\r
+  FvImage       Pointer to the FV image created.\r
+  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
+  FvFileName    Requested name for the FV file.\r
+  SymImage      Pointer to the Sym image created.\r
+  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
+  SymFileName   Requested name for the Sym file.\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+EFI_STATUS\r
+UpdatePeiCoreEntryInFit (\r
+  IN FIT_TABLE     *FitTablePtr,\r
+  IN UINT64        PeiCorePhysicalAddress\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
+  Sec to Pei Core\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
+  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
+\r
+--*/\r
+VOID\r
+UpdateFitCheckSum (\r
+  IN FIT_TABLE   *FitTablePtr\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the checksum for FIT.\r
+\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
new file mode 100644 (file)
index 0000000..505188b
--- /dev/null
@@ -0,0 +1,212 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageLibInternal.h\r
+\r
+Abstract:\r
+\r
+  This file contains describes the private declarations for the GenFvImage Library.\r
+  The basic purpose of the library is to create Firmware Volume images.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
+#define _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include "GenFvImageLib.h"\r
+#include <stdlib.h>\r
+#include "EfiFirmwareVolumeHeader.h"\r
+\r
+//\r
+// Private data declarations\r
+//\r
+//\r
+// The maximum number of block map entries supported by the library\r
+//\r
+#define MAX_NUMBER_OF_FV_BLOCKS 100\r
+\r
+//\r
+// The maximum number of files in the FV supported by the library\r
+//\r
+#define MAX_NUMBER_OF_FILES_IN_FV       1000\r
+#define MAX_NUMBER_OF_COMPONENTS_IN_FV  10\r
+\r
+//\r
+// INF file strings\r
+//\r
+#define OPTIONS_SECTION_STRING            "[options]"\r
+#define ATTRIBUTES_SECTION_STRING         "[attributes]"\r
+#define FILES_SECTION_STRING              "[files]"\r
+#define COMPONENT_SECTION_STRING          "[components]"\r
+\r
+#define EFI_FV_BASE_ADDRESS_STRING        "EFI_BASE_ADDRESS"\r
+#define EFI_FV_FILE_NAME_STRING           "EFI_FILE_NAME"\r
+#define EFI_SYM_FILE_NAME_STRING          "EFI_SYM_FILE_NAME"\r
+#define EFI_NUM_BLOCKS_STRING             "EFI_NUM_BLOCKS"\r
+#define EFI_BLOCK_SIZE_STRING             "EFI_BLOCK_SIZE"\r
+#define EFI_FV_GUID_STRING                "EFI_FV_GUID"\r
+\r
+#define EFI_FVB_READ_DISABLED_CAP_STRING  "EFI_READ_DISABLED_CAP"\r
+#define EFI_FVB_READ_ENABLED_CAP_STRING   "EFI_READ_ENABLED_CAP"\r
+#define EFI_FVB_READ_STATUS_STRING        "EFI_READ_STATUS"\r
+\r
+#define EFI_FVB_WRITE_DISABLED_CAP_STRING "EFI_WRITE_DISABLED_CAP"\r
+#define EFI_FVB_WRITE_ENABLED_CAP_STRING  "EFI_WRITE_ENABLED_CAP"\r
+#define EFI_FVB_WRITE_STATUS_STRING       "EFI_WRITE_STATUS"\r
+\r
+#define EFI_FVB_LOCK_CAP_STRING           "EFI_LOCK_CAP"\r
+#define EFI_FVB_LOCK_STATUS_STRING        "EFI_LOCK_STATUS"\r
+\r
+#define EFI_FVB_STICKY_WRITE_STRING       "EFI_STICKY_WRITE"\r
+#define EFI_FVB_MEMORY_MAPPED_STRING      "EFI_MEMORY_MAPPED"\r
+#define EFI_FVB_ERASE_POLARITY_STRING     "EFI_ERASE_POLARITY"\r
+\r
+#define EFI_FVB_ALIGNMENT_CAP_STRING      "EFI_ALIGNMENT_CAP"\r
+#define EFI_FVB_ALIGNMENT_2_STRING        "EFI_ALIGNMENT_2"\r
+#define EFI_FVB_ALIGNMENT_4_STRING        "EFI_ALIGNMENT_4"\r
+#define EFI_FVB_ALIGNMENT_8_STRING        "EFI_ALIGNMENT_8"\r
+#define EFI_FVB_ALIGNMENT_16_STRING       "EFI_ALIGNMENT_16"\r
+#define EFI_FVB_ALIGNMENT_32_STRING       "EFI_ALIGNMENT_32"\r
+#define EFI_FVB_ALIGNMENT_64_STRING       "EFI_ALIGNMENT_64"\r
+#define EFI_FVB_ALIGNMENT_128_STRING      "EFI_ALIGNMENT_128"\r
+#define EFI_FVB_ALIGNMENT_256_STRING      "EFI_ALIGNMENT_256"\r
+#define EFI_FVB_ALIGNMENT_512_STRING      "EFI_ALIGNMENT_512"\r
+#define EFI_FVB_ALIGNMENT_1K_STRING       "EFI_ALIGNMENT_1K"\r
+#define EFI_FVB_ALIGNMENT_2K_STRING       "EFI_ALIGNMENT_2K"\r
+#define EFI_FVB_ALIGNMENT_4K_STRING       "EFI_ALIGNMENT_4K"\r
+#define EFI_FVB_ALIGNMENT_8K_STRING       "EFI_ALIGNMENT_8K"\r
+#define EFI_FVB_ALIGNMENT_16K_STRING      "EFI_ALIGNMENT_16K"\r
+#define EFI_FVB_ALIGNMENT_32K_STRING      "EFI_ALIGNMENT_32K"\r
+#define EFI_FVB_ALIGNMENT_64K_STRING      "EFI_ALIGNMENT_64K"\r
+\r
+//\r
+// Add these for PI1.0 new Attributes.\r
+//\r
+#define EFI_FVB_READ_LOCK_CAP_STRING            "EFI_READ_LOCK_CAP"\r
+#define EFI_FVB_READ_LOCK_STATUS_STRING         "EFI_READ_LOCK_STATUS"\r
+#define EFI_FVB_WRITE_LOCK_CAP_STRING           "EFI_WRITE_LOCK_CAP"\r
+#define EFI_FVB_WRITE_LOCK_STATUS_STRING        "EFI_WRITE_LOCK_STATUS"\r
+#define EFI_FVB2_ALIGNMENT_STRING               "EFI_FVB2_ALIGNMENT"\r
+\r
+#define EFI_FVB2_ALIGNMENT_1_STRING             "1"\r
+#define EFI_FVB2_ALIGNMENT_2_STRING             "2"\r
+#define EFI_FVB2_ALIGNMENT_4_STRING             "4"\r
+#define EFI_FVB2_ALIGNMENT_8_STRING             "8"\r
+#define EFI_FVB2_ALIGNMENT_16_STRING            "16"\r
+#define EFI_FVB2_ALIGNMENT_32_STRING            "32"\r
+#define EFI_FVB2_ALIGNMENT_64_STRING            "64"\r
+#define EFI_FVB2_ALIGNMENT_128_STRING           "128"\r
+#define EFI_FVB2_ALIGNMENT_256_STRING           "256"\r
+#define EFI_FVB2_ALIGNMENT_512_STRING           "512"\r
+#define EFI_FVB2_ALIGNMENT_1K_STRING            "1K"\r
+#define EFI_FVB2_ALIGNMENT_2K_STRING            "2K"\r
+#define EFI_FVB2_ALIGNMENT_4K_STRING            "4K"\r
+#define EFI_FVB2_ALIGNMENT_8K_STRING            "8K"\r
+#define EFI_FVB2_ALIGNMENT_16K_STRING           "16K"\r
+#define EFI_FVB2_ALIGNMENT_32K_STRING           "32K"\r
+#define EFI_FVB2_ALIGNMENT_64K_STRING           "64K"\r
+#define EFI_FVB2_ALIGNMENT_128K_STRING          "128K"\r
+#define EFI_FVB2_ALIGNMENT_256K_STRING          "256K"\r
+#define EFI_FVB2_ALIGNMENT_512K_STRING          "512K"\r
+#define EFI_FVB2_ALIGNMENT_1M_STRING            "1M"\r
+#define EFI_FVB2_ALIGNMENT_2M_STRING            "2M"\r
+#define EFI_FVB2_ALIGNMENT_4M_STRING            "4M"\r
+#define EFI_FVB2_ALIGNMENT_8M_STRING            "8M"\r
+#define EFI_FVB2_ALIGNMENT_16M_STRING           "16M"\r
+#define EFI_FVB2_ALIGNMENT_32M_STRING           "32M"\r
+#define EFI_FVB2_ALIGNMENT_64M_STRING           "64M"\r
+#define EFI_FVB2_ALIGNMENT_128M_STRING          "128M"\r
+#define EFI_FVB2_ALIGNMENT_256M_STRING          "256M"\r
+#define EFI_FVB2_ALIGNMENT_512M_STRING          "512M"\r
+#define EFI_FVB2_ALIGNMENT_1G_STRING            "1G"\r
+#define EFI_FVB2_ALIGNMENT_2G_STRING            "2G"\r
+\r
+\r
+//\r
+// Component sections\r
+//\r
+#define EFI_NV_VARIABLE_STRING    "EFI_NV_VARIABLE"\r
+#define EFI_NV_EVENT_LOG_STRING   "EFI_NV_EVENT_LOG"\r
+#define EFI_NV_FTW_WORKING_STRING "EFI_NV_FTW_WORKING"\r
+#define EFI_NV_FTW_SPARE_STRING   "EFI_NV_FTW_SPARE"\r
+\r
+#define EFI_FILE_NAME_STRING      "EFI_FILE_NAME"\r
+\r
+#define ONE_STRING                "1"\r
+#define ZERO_STRING               "0"\r
+#define TRUE_STRING               "TRUE"\r
+#define FALSE_STRING              "FALSE"\r
+#define NULL_STRING               "NULL"\r
+\r
+//\r
+// Defines to calculate the offset for PEI CORE entry points\r
+//\r
+#define IA32_PEI_CORE_ENTRY_OFFSET  0x20\r
+\r
+//\r
+// Defines to calculate the FIT table\r
+//\r
+#define IPF_FIT_ADDRESS_OFFSET  0x20\r
+\r
+//\r
+// Defines to calculate the offset for SALE_ENTRY\r
+//\r
+#define IPF_SALE_ENTRY_ADDRESS_OFFSET 0x18\r
+\r
+//\r
+// Symbol file definitions, current max size if 512K\r
+//\r
+#define SYMBOL_FILE_SIZE  0x80000\r
+\r
+#define FV_IMAGES_TOP_ADDRESS             0x100000000\r
+\r
+//\r
+// Private data types\r
+//\r
+//\r
+// Component information\r
+//\r
+typedef struct {\r
+  UINTN Size;\r
+  CHAR8 ComponentName[_MAX_PATH];\r
+} COMPONENT_INFO;\r
+\r
+//\r
+// FV information holder\r
+//\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+  EFI_GUID                FvGuid;\r
+  UINTN                   Size;\r
+  CHAR8                   FvName[_MAX_PATH];\r
+  CHAR8                   SymName[_MAX_PATH];\r
+  EFI_FV_BLOCK_MAP_ENTRY  FvBlocks[MAX_NUMBER_OF_FV_BLOCKS];\r
+  EFI_FVB_ATTRIBUTES      FvAttributes;\r
+  CHAR8                   FvFiles[MAX_NUMBER_OF_FILES_IN_FV][_MAX_PATH];\r
+  COMPONENT_INFO          FvComponents[MAX_NUMBER_OF_COMPONENTS_IN_FV];\r
+} FV_INFO;\r
+\r
+//\r
+// Private function prototypes\r
+//\r
+EFI_STATUS\r
+ParseFvInf (\r
+  IN MEMORY_FILE  *InfFile,\r
+  IN FV_INFO      *FvInfo\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile
new file mode 100644 (file)
index 0000000..d3b43c0
--- /dev/null
@@ -0,0 +1,109 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC) \\r
+    -I "$(EDK_TOOLS_COMMON)"\r
+\r
+\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=GenFvImage\r
+\r
+TARGET_SOURCE_DIR   = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_LIB          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).lib\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+TARGET_EXE_SOURCE   = "$(TARGET_SOURCE_DIR)\GenFvImageExe.c"\r
+\r
+TARGET_EXE_INCLUDE  = "$(TARGET_SOURCE_DIR)\GenFvImageExe.h" \\r
+                         "$(TARGET_SOURCE_DIR)\GenFvImageLib.h" \\r
+                         "$(EDK_TOOLS_COMMON)\ParseInf.h" \\r
+                         "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h"\r
+\r
+TARGET_EXE_LIBS     = "$(EDK_TOOLS_OUTPUT)\Common.lib" \r
+TARGET_LIB_SOURCE   = "$(TARGET_SOURCE_DIR)\GenFvImageLib.c"\r
+\r
+TARGET_LIB_INCLUDE  = "$(TARGET_SOURCE_DIR)\GenFvImageLib.h" \\r
+                         "$(TARGET_SOURCE_DIR)\GenFvImageLibInternal.h" \\r
+                         "$(EDK_TOOLS_COMMON)\ParseInf.h" \\r
+                         "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \\r
+                         "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \\r
+                         "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \\r
+                         "$(EDK_SOURCE)\Foundation\Framework\Guid\FirmwareFileSystem\FirmwareFileSystem.h"\r
+\r
+TARGET_LIB_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS) $(TARGET_LIB)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB)  $(TARGET_EXE_LIBS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+#\r
+# Build LIB\r
+#\r
+\r
+$(TARGET_LIB): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj $(TARGET_LIB_LIBS)\r
+  $(LIB_EXE) $(LIB_FLAGS) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj $(MSVS_LINK_LIBPATHS) $(TARGET_LIB_LIBS) RPCRT4.lib /OUT:$(TARGET_LIB)\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj:  $(TARGET_LIB_SOURCE) $(TARGET_LIB_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_LIB_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile
new file mode 100644 (file)
index 0000000..8c4addb
--- /dev/null
@@ -0,0 +1,95 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the GenPage utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=GenPage\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenPage.c"\r
+TARGET_EXE_INCLUDE = "$(TARGET_SOURCE_DIR)\VirtualMemory.h"\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h
new file mode 100644 (file)
index 0000000..d9d928f
--- /dev/null
@@ -0,0 +1,127 @@
+/*++ \r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  VirtualMemory.h\r
+  \r
+Abstract:\r
+\r
+  x64 Long Mode Virtual Memory Management Definitions  \r
+\r
+  References:\r
+    1) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 1:Basic Architecture, Intel\r
+    2) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 2:Instruction Set Reference, Intel\r
+    3) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 3:System Programmer's Guide, Intel\r
+    4) AMD64 Architecture Programmer's Manual Volume 2: System Programming\r
+--*/\r
+\r
+#ifndef _VIRTUAL_MEMORY_H_\r
+#define _VIRTUAL_MEMORY_H_\r
+\r
+#include "Tiano.h"\r
+\r
+#pragma pack(1)\r
+\r
+//\r
+// Page-Map Level-4 Offset (PML4) and\r
+// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB\r
+//\r
+\r
+typedef union {\r
+  struct {\r
+    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
+    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
+    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
+    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
+    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
+    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+    UINT64  Reserved:1;               // Reserved\r
+    UINT64  MustBeZero:2;             // Must Be Zero\r
+    UINT64  Available:3;              // Available for use by system software\r
+    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
+    UINT64  AvabilableHigh:11;        // Available for use by system software\r
+    UINT64  Nx:1;                     // No Execute bit\r
+  } Bits;\r
+  UINT64    Uint64;\r
+} X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K;\r
+\r
+//\r
+// Page-Directory Offset 4K\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
+    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
+    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
+    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
+    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
+    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+    UINT64  Reserved:1;               // Reserved\r
+    UINT64  MustBeZero:1;             // Must Be Zero\r
+    UINT64  Reserved2:1;              // Reserved\r
+    UINT64  Available:3;              // Available for use by system software\r
+    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
+    UINT64  AvabilableHigh:11;        // Available for use by system software\r
+    UINT64  Nx:1;                     // No Execute bit\r
+  } Bits;\r
+  UINT64    Uint64;\r
+} X64_PAGE_DIRECTORY_ENTRY_4K;\r
+\r
+//\r
+// Page Table Entry 4K\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
+    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
+    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
+    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
+    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
+    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+    UINT64  Dirty:1;                  // 0 = Not Dirty, 1 = written by processor on access to page\r
+    UINT64  PAT:1;                    // 0 = Ignore Page Attribute Table \r
+    UINT64  Global:1;                 // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
+    UINT64  Available:3;              // Available for use by system software\r
+    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
+    UINT64  AvabilableHigh:11;        // Available for use by system software\r
+    UINT64  Nx:1;                     // 0 = Execute Code, 1 = No Code Execution\r
+  } Bits;\r
+  UINT64    Uint64;\r
+} X64_PAGE_TABLE_ENTRY_4K;\r
+\r
+\r
+//\r
+// Page Table Entry 2MB\r
+//\r
+typedef union {\r
+  struct {\r
+    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
+    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
+    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
+    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
+    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
+    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
+    UINT64  Dirty:1;                  // 0 = Not Dirty, 1 = written by processor on access to page\r
+    UINT64  MustBe1:1;                // Must be 1 \r
+    UINT64  Global:1;                 // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
+    UINT64  Available:3;              // Available for use by system software\r
+    UINT64  PAT:1;                    //\r
+    UINT64  MustBeZero:8;             // Must be zero;\r
+    UINT64  PageTableBaseAddress:31;  // Page Table Base Address\r
+    UINT64  AvabilableHigh:11;        // Available for use by system software\r
+    UINT64  Nx:1;                     // 0 = Execute Code, 1 = No Code Execution\r
+  } Bits;\r
+  UINT64    Uint64;\r
+} X64_PAGE_TABLE_ENTRY_2M;\r
+\r
+#pragma pack()\r
+\r
+#endif \r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c
new file mode 100644 (file)
index 0000000..7085f19
--- /dev/null
@@ -0,0 +1,344 @@
+/*++ \r
+\r
+Copyright 2006 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  GenPage.c\r
+  \r
+Abstract:\r
+  Pre-Create a 4G page table (2M pages).\r
+  It's used in DUET x64 build needed to enter LongMode.\r
\r
+  Create 4G page table (2M pages)\r
\r
+                              Linear Address\r
+    63    48 47   39 38           30 29       21 20                          0\r
+   +--------+-------+---------------+-----------+-----------------------------+\r
+               PML4   Directory-Ptr   Directory                 Offset\r
+\r
+   Paging-Structures :=\r
+                        PML4\r
+                        (\r
+                          Directory-Ptr Directory {512}\r
+                        ) {4}\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include "VirtualMemory.h"\r
+\r
+void\r
+memset (void *, char, long);\r
+\r
+unsigned int\r
+xtoi (char  *);\r
+\r
+#define EFI_PAGE_BASE_OFFSET_IN_LDR 0x70000\r
+#define EFI_PAGE_BASE_ADDRESS       (EFI_PAGE_BASE_OFFSET_IN_LDR + 0x20000)\r
+\r
+unsigned int gPageTableBaseAddress  = EFI_PAGE_BASE_ADDRESS;\r
+unsigned int gPageTableOffsetInFile = EFI_PAGE_BASE_OFFSET_IN_LDR;\r
+\r
+#define EFI_MAX_ENTRY_NUM     512\r
+\r
+#define EFI_PML4_ENTRY_NUM    1\r
+#define EFI_PDPTE_ENTRY_NUM   4\r
+#define EFI_PDE_ENTRY_NUM     EFI_MAX_ENTRY_NUM\r
+\r
+#define EFI_PML4_PAGE_NUM     1\r
+#define EFI_PDPTE_PAGE_NUM    EFI_PML4_ENTRY_NUM\r
+#define EFI_PDE_PAGE_NUM      (EFI_PML4_ENTRY_NUM * EFI_PDPTE_ENTRY_NUM)\r
+\r
+#define EFI_PAGE_NUMBER       (EFI_PML4_PAGE_NUM + EFI_PDPTE_PAGE_NUM + EFI_PDE_PAGE_NUM)\r
+\r
+#define EFI_SIZE_OF_PAGE      0x1000\r
+#define EFI_PAGE_SIZE_2M      0x200000\r
+\r
+#define CONVERT_BIN_PAGE_ADDRESS(a)  ((UINT8 *) a - PageTable + gPageTableBaseAddress)\r
+\r
+\r
+void *\r
+CreateIdentityMappingPageTables (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  To create 4G PAE 2M pagetable\r
+\r
+Return:\r
+  void * - buffer containing created pagetable\r
+\r
+--*/\r
+{\r
+  UINT64                                        PageAddress;\r
+  UINT8                                         *PageTable;\r
+  UINT8                                         *PageTablePtr;\r
+  int                                           PML4Index;\r
+  int                                           PDPTEIndex;\r
+  int                                           PDEIndex;\r
+  X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K     *PageMapLevel4Entry;\r
+  X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K     *PageDirectoryPointerEntry;\r
+  X64_PAGE_TABLE_ENTRY_2M                       *PageDirectoryEntry2MB;\r
+\r
+  PageTable = (void *)malloc (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE);\r
+  memset (PageTable, 0, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE));\r
+  PageTablePtr = PageTable;\r
+\r
+  PageAddress = 0;\r
+\r
+  //\r
+  //  Page Table structure 3 level 2MB.\r
+  //\r
+  //                   Page-Map-Level-4-Table        : bits 47-39\r
+  //                   Page-Directory-Pointer-Table  : bits 38-30\r
+  //\r
+  //  Page Table 2MB : Page-Directory(2M)            : bits 29-21\r
+  //\r
+  //\r
+\r
+  PageMapLevel4Entry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)PageTablePtr;\r
+\r
+  for (PML4Index = 0; PML4Index < EFI_PML4_ENTRY_NUM; PML4Index++, PageMapLevel4Entry++) {\r
+    //\r
+    // Each Page-Map-Level-4-Table Entry points to the base address of a Page-Directory-Pointer-Table Entry\r
+    //  \r
+    PageTablePtr += EFI_SIZE_OF_PAGE;\r
+    PageDirectoryPointerEntry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)PageTablePtr;\r
+\r
+    //\r
+    // Make a Page-Map-Level-4-Table Entry\r
+    //\r
+    PageMapLevel4Entry->Uint64 = (UINT64)(UINT32)(CONVERT_BIN_PAGE_ADDRESS (PageDirectoryPointerEntry));\r
+    PageMapLevel4Entry->Bits.ReadWrite = 1;\r
+    PageMapLevel4Entry->Bits.Present = 1;\r
+\r
+    for (PDPTEIndex = 0; PDPTEIndex < EFI_PDPTE_ENTRY_NUM; PDPTEIndex++, PageDirectoryPointerEntry++) {\r
+      //\r
+      // Each Page-Directory-Pointer-Table Entry points to the base address of a Page-Directory Entry\r
+      //       \r
+      PageTablePtr += EFI_SIZE_OF_PAGE;\r
+      PageDirectoryEntry2MB = (X64_PAGE_TABLE_ENTRY_2M *)PageTablePtr;\r
+\r
+      //\r
+      // Make a Page-Directory-Pointer-Table Entry\r
+      //\r
+      PageDirectoryPointerEntry->Uint64 = (UINT64)(UINT32)(CONVERT_BIN_PAGE_ADDRESS (PageDirectoryEntry2MB));\r
+      PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
+      PageDirectoryPointerEntry->Bits.Present = 1;\r
+\r
+      for (PDEIndex = 0; PDEIndex < EFI_PDE_ENTRY_NUM; PDEIndex++, PageDirectoryEntry2MB++) {\r
+        //\r
+        // Make a Page-Directory Entry\r
+        //\r
+        PageDirectoryEntry2MB->Uint64 = (UINT64)PageAddress;\r
+        PageDirectoryEntry2MB->Bits.ReadWrite = 1;\r
+        PageDirectoryEntry2MB->Bits.Present = 1;\r
+        PageDirectoryEntry2MB->Bits.MustBe1 = 1;\r
+\r
+        PageAddress += EFI_PAGE_SIZE_2M;\r
+      }\r
+    }\r
+  }\r
+\r
+  return PageTable;\r
+}\r
+\r
+int\r
+GenBinPage (\r
+  void *BaseMemory,\r
+  char *NoPageFileName,\r
+  char *PageFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Write the buffer containing page table to file at a specified offset.\r
+  Here the offset is defined as EFI_PAGE_BASE_OFFSET_IN_LDR.\r
+\r
+Arguments:\r
+  BaseMemory     - buffer containing page table\r
+  NoPageFileName - file to write page table\r
+  PageFileName   - file save to after writing\r
+\r
+return:\r
+  0  : successful\r
+  -1 : failed\r
+\r
+--*/\r
+{\r
+  FILE  *PageFile;\r
+  FILE  *NoPageFile;\r
+  UINT8 Data;\r
+  unsigned long FileSize;\r
+\r
+  //\r
+  // Open files\r
+  //\r
+  PageFile = fopen (PageFileName, "w+b");\r
+  if (PageFile == NULL) {\r
+    fprintf (stderr, "GenBinPage: Could not open file %s\n", PageFileName);\r
+    return -1;\r
+  }\r
+\r
+  NoPageFile = fopen (NoPageFileName, "r+b");\r
+  if (NoPageFile == NULL) {\r
+    fprintf (stderr, "GenBinPage: Could not open file %s\n", NoPageFileName);\r
+    fclose (PageFile);\r
+    return -1;\r
+  }\r
+\r
+  //\r
+  // Check size - should not be great than EFI_PAGE_BASE_OFFSET_IN_LDR\r
+  //\r
+  fseek (NoPageFile, 0, SEEK_END);\r
+  FileSize = ftell (NoPageFile);\r
+  fseek (NoPageFile, 0, SEEK_SET);\r
+  if (FileSize > gPageTableOffsetInFile) {\r
+    fprintf (stderr, "GenBinPage: file size too large - 0x%x\n", FileSize);\r
+    fclose (PageFile);\r
+    fclose (NoPageFile);\r
+    return -1;\r
+  }\r
+\r
+  //\r
+  // Write data\r
+  //\r
+  while (fread (&Data, sizeof(UINT8), 1, NoPageFile)) {\r
+    fwrite (&Data, sizeof(UINT8), 1, PageFile);\r
+  }\r
+\r
+  //\r
+  // Write PageTable\r
+  //\r
+  fseek (PageFile, gPageTableOffsetInFile, SEEK_SET);\r
+  fwrite (BaseMemory, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE), 1, PageFile);\r
+\r
+  //\r
+  // Close files\r
+  //\r
+  fclose (PageFile);\r
+  fclose (NoPageFile);\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char **argv\r
+  )\r
+{\r
+  void *BaseMemory;\r
+  int  result;\r
+\r
+  //\r
+  // Check parameter\r
+  //\r
+  if ((argc != 3) && (argc != 5)) {\r
+    printf ("Usage: GenPage.exe NoPageFile PageFile [<PageTableBaseAddrss> <PageTableOffsetInFile>]\n");\r
+    return 1;\r
+  }\r
+\r
+  //\r
+  // Get PageTable parameter, if have\r
+  //\r
+  if (argc == 5) {\r
+    gPageTableBaseAddress  = xtoi (argv[3]);\r
+    gPageTableOffsetInFile = xtoi (argv[4]);\r
+  }\r
+\r
+  //\r
+  // Create X64 page table\r
+  //\r
+  BaseMemory = CreateIdentityMappingPageTables ();\r
+\r
+  //\r
+  // Add page table to binary file\r
+  //\r
+  result = GenBinPage (BaseMemory, argv[1], argv[2]);\r
+  if (result < 0) {\r
+    return 1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+unsigned int\r
+xtoi (\r
+  char  *str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert hex string to uint\r
+\r
+Arguments:\r
+\r
+  Str  -  The string\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  unsigned int u;\r
+  char         c;\r
+  unsigned int m;\r
+  \r
+  if (str == NULL) {\r
+    return 0;\r
+  }\r
+  \r
+  m = (unsigned int) -1 >> 4;\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  while (*str && *str == ' ') {\r
+    str += 1;\r
+  }\r
+  //\r
+  // skip preceeding zeros\r
+  //\r
+  while (*str && *str == '0') {\r
+    str += 1;\r
+  }\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  if (*str && (*str == 'x' || *str == 'X')) {\r
+    str += 1;\r
+  }\r
+  //\r
+  // convert hex digits\r
+  //\r
+  u = 0;\r
+  c = *(str++);\r
+  while (c) {\r
+    if (c >= 'a' && c <= 'f') {\r
+      c -= 'a' - 'A';\r
+    }\r
+\r
+    if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {\r
+      if (u > m) {\r
+        return (unsigned int) -1;\r
+      }\r
+\r
+      u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0');\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    c = *(str++);\r
+  }\r
+\r
+  return u;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
new file mode 100644 (file)
index 0000000..61ce9ca
--- /dev/null
@@ -0,0 +1,1000 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenSection.c\r
+\r
+Abstract:\r
+\r
+  Creates output file that is a properly formed section per the FV spec.\r
+\r
+--*/\r
+\r
+#include "TianoCommon.h"\r
+#include "EfiImageFormat.h"\r
+#include "Compress.h"\r
+#include "EfiCustomizedCompress.h"\r
+#include "Crc32.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include "GenSection.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
+\r
+#define UTILITY_NAME            "GenSection"\r
+\r
+#define PARAMETER_NOT_SPECIFIED "Parameter not specified"\r
+#define MAXIMUM_INPUT_FILE_NUM  10\r
+#define MAX_SECTION_SIZE        0x1000000\r
+\r
+char      *SectionTypeName[] = {\r
+  NULL,                                 // 0x00 - reserved\r
+  "EFI_SECTION_COMPRESSION",            // 0x01\r
+  "EFI_SECTION_GUID_DEFINED",           // 0x02\r
+  NULL,                                 // 0x03 - reserved\r
+  NULL,                                 // 0x04 - reserved\r
+  NULL,                                 // 0x05 - reserved\r
+  NULL,                                 // 0x06 - reserved\r
+  NULL,                                 // 0x07 - reserved\r
+  NULL,                                 // 0x08 - reserved\r
+  NULL,                                 // 0x09 - reserved\r
+  NULL,                                 // 0x0A - reserved\r
+  NULL,                                 // 0x0B - reserved\r
+  NULL,                                 // 0x0C - reserved\r
+  NULL,                                 // 0x0D - reserved\r
+  NULL,                                 // 0x0E - reserved\r
+  NULL,                                 // 0x0F - reserved\r
+  "EFI_SECTION_PE32",                   // 0x10\r
+  "EFI_SECTION_PIC",                    // 0x11\r
+  "EFI_SECTION_TE",                     // 0x12\r
+  "EFI_SECTION_DXE_DEPEX",              // 0x13\r
+  "EFI_SECTION_VERSION",                // 0x14\r
+  "EFI_SECTION_USER_INTERFACE",         // 0x15\r
+  "EFI_SECTION_COMPATIBILITY16",        // 0x16\r
+  "EFI_SECTION_FIRMWARE_VOLUME_IMAGE",  // 0x17\r
+  "EFI_SECTION_FREEFORM_SUBTYPE_GUID",  // 0x18\r
+  "EFI_SECTION_RAW",                    // 0x19\r
+  NULL,                                 // 0x1A\r
+  "EFI_SECTION_PEI_DEPEX"               // 0x1B\r
+};\r
+\r
+char      *CompressionTypeName[]    = { "NONE", "STANDARD" };\r
+char      *GUIDedSectionTypeName[]  = { "CRC32" };\r
+EFI_GUID  gEfiCrc32SectionGuid      = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+static\r
+VOID\r
+PrintUsageMessage (\r
+  VOID\r
+  )\r
+{\r
+  UINTN SectionType;\r
+  UINTN DisplayCount;\r
+\r
+  printf ("Usage: "UTILITY_NAME "  -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");\r
+  printf ("    Where SectionType is one of the following section types:\n\n");\r
+\r
+  DisplayCount = 0;\r
+  for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {\r
+    if (SectionTypeName[SectionType] != NULL) {\r
+      printf ("       %s\n", SectionTypeName[SectionType]);\r
+    }\r
+  }\r
+\r
+  printf ("\n    and SectionType dependent parameters are as follows:\n\n");\r
+  printf (\r
+    "       %s:       -t < %s | %s >\n",\r
+    SectionTypeName[EFI_SECTION_COMPRESSION],\r
+    CompressionTypeName[EFI_NOT_COMPRESSED],\r
+    CompressionTypeName[EFI_STANDARD_COMPRESSION]\r
+    );\r
+  printf (\r
+    "       %s:      -t < %s >\n""                          // Currently only CRC32 is supported\n\n",\r
+    SectionTypeName[EFI_SECTION_GUID_DEFINED],\r
+    GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]\r
+    );\r
+  printf (\r
+    "       %s:           -v VersionNumber\n""                          [-a \"Version string\"]\n\n",\r
+    SectionTypeName[EFI_SECTION_VERSION]\r
+    );\r
+  printf (\r
+    "       %s:    -a \"Human readable name\"\n\n",\r
+    SectionTypeName[EFI_SECTION_USER_INTERFACE]\r
+    );\r
+}\r
+\r
+VOID\r
+Ascii2UnicodeWriteString (\r
+  char    *String,\r
+  FILE    *OutFile,\r
+  BOOLEAN WriteLangCode\r
+  )\r
+{\r
+  UINTN Index;\r
+  UINT8 AsciiNull;\r
+  //\r
+  // BUGBUG need to get correct language code...\r
+  //\r
+  char  *EnglishLangCode = "eng";\r
+  AsciiNull = 0;\r
+  //\r
+  // first write the language code (english only)\r
+  //\r
+  if (WriteLangCode) {\r
+    fwrite (EnglishLangCode, 1, 4, OutFile);\r
+  }\r
+  //\r
+  // Next, write out the string... Convert ASCII to Unicode in the process.\r
+  //\r
+  Index = 0;\r
+  do {\r
+    fwrite (&String[Index], 1, 1, OutFile);\r
+    fwrite (&AsciiNull, 1, 1, OutFile);\r
+  } while (String[Index++] != 0);\r
+}\r
+\r
+STATUS\r
+GenSectionCommonLeafSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate a leaf section of type other than EFI_SECTION_VERSION\r
+  and EFI_SECTION_USER_INTERFACE. Input file must be well formed.\r
+  The function won't validate the input file's contents. For\r
+  common leaf sections, the input file may be a binary file.\r
+  The utility will add section header to the file.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be 1 for leaf section.\r
+\r
+  SectionType    - A valid section type string\r
+\r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  STATUS_ERROR            - can't continue\r
+  STATUS_SUCCESS          - successful return\r
+\r
+--*/\r
+{\r
+  UINT64                    InputFileLength;\r
+  FILE                      *InFile;\r
+  UINT8                     *Buffer;\r
+  INTN                      TotalLength;\r
+  EFI_COMMON_SECTION_HEADER CommonSect;\r
+  STATUS                    Status;\r
+\r
+  if (InputFileNum > 1) {\r
+    Error (NULL, 0, 0, "invalid parameter", "more than one input file specified");\r
+    return STATUS_ERROR;\r
+  } else if (InputFileNum < 1) {\r
+    Error (NULL, 0, 0, "no input file specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the input file\r
+  //\r
+  InFile = fopen (InputFileName[0], "rb");\r
+  if (InFile == NULL) {\r
+    Error (NULL, 0, 0, InputFileName[0], "failed to open input file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Status  = STATUS_ERROR;\r
+  Buffer  = NULL;\r
+  //\r
+  // Seek to the end of the input file so we can determine its size\r
+  //\r
+  fseek (InFile, 0, SEEK_END);\r
+  fgetpos (InFile, &InputFileLength);\r
+  fseek (InFile, 0, SEEK_SET);\r
+  //\r
+  // Fill in the fields in the local section header structure\r
+  //\r
+  CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+  TotalLength     = sizeof (CommonSect) + (INTN) InputFileLength;\r
+  //\r
+  // Size must fit in 3 bytes\r
+  //\r
+  if (TotalLength >= MAX_SECTION_SIZE) {\r
+    Error (NULL, 0, 0, InputFileName[0], "file size (0x%X) exceeds section size limit(%dM).", TotalLength, MAX_SECTION_SIZE>>20);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Now copy the size into the section header and write out the section header\r
+  //\r
+  memcpy (&CommonSect.Size, &TotalLength, 3);\r
+  fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+  //\r
+  // Allocate a buffer to read in the contents of the input file. Then\r
+  // read it in as one block and write it to the output file.\r
+  //\r
+  if (InputFileLength != 0) {\r
+    Buffer = (UINT8 *) malloc ((size_t) InputFileLength);\r
+    if (Buffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, (size_t) InputFileLength, 1, InFile) != 1) {\r
+      Error (NULL, 0, 0, InputFileName[0], "failed to read contents of file");\r
+      goto Done;\r
+    }\r
+\r
+    if (fwrite (Buffer, (size_t) InputFileLength, 1, OutFile) != 1) {\r
+      Error (NULL, 0, 0, "failed to write to output file", NULL);\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  fclose (InFile);\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+GetSectionContents (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINT8   *FileBuffer,\r
+  UINTN   *BufferLength\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Get the contents of all section files specified in InputFileName\r
+  into FileBuffer.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  FileBuffer     - Output buffer to contain data\r
+\r
+  BufferLength   - On input, this is size of the FileBuffer. \r
+                   On output, this is the actual length of the data.\r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1 or BufferLength point is NULL.\r
+  EFI_ABORTED if unable to open input file.\r
+  EFI_BUFFER_TOO_SMALL FileBuffer is not enough to contain all file data.\r
+--*/\r
+{\r
+  UINTN   Size;\r
+  fpos_t  FileSize;\r
+  INTN    Index;\r
+  FILE    *InFile;\r
+\r
+  if (InputFileNum < 1) {\r
+    Error (NULL, 0, 0, "must specify at least one input file", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (BufferLength == NULL) {\r
+    Error (NULL, 0, 0, "BufferLength can't be NULL", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Size = 0;\r
+  //\r
+  // Go through our array of file names and copy their contents\r
+  // to the output buffer.\r
+  //\r
+  for (Index = 0; Index < InputFileNum; Index++) {\r
+    InFile = fopen (InputFileName[Index], "rb");\r
+    if (InFile == NULL) {\r
+      Error (NULL, 0, 0, InputFileName[Index], "failed to open input file");\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    fseek (InFile, 0, SEEK_END);\r
+    fgetpos (InFile, &FileSize);\r
+    fseek (InFile, 0, SEEK_SET);\r
+    //\r
+    // Now read the contents of the file into the buffer\r
+    // Buffer must be enough to contain the file content.\r
+    //\r
+    if (FileSize > 0 && FileBuffer != NULL && (Size + (UINTN) FileSize) <= *BufferLength) {\r
+      if (fread (FileBuffer + Size, (size_t) FileSize, 1, InFile) != 1) {\r
+        Error (NULL, 0, 0, InputFileName[Index], "failed to read contents of input file");\r
+        fclose (InFile);\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    fclose (InFile);\r
+    Size += (UINTN) FileSize;\r
+    //\r
+    // make sure section ends on a DWORD boundary\r
+    //\r
+    while ((Size & 0x03) != 0) {\r
+      if (FileBuffer != NULL && Size < *BufferLength) {\r
+        FileBuffer[Size] = 0;\r
+      }\r
+      Size++;\r
+    }\r
+  }\r
+  \r
+  if (Size > *BufferLength) {\r
+    *BufferLength = Size;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    *BufferLength = Size;\r
+    return EFI_SUCCESS;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+GenSectionCompressionSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  UINTN   SectionSubType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate an encapsulating section of type EFI_SECTION_COMPRESSION\r
+  Input file must be already sectioned. The function won't validate\r
+  the input files' contents. Caller should hand in files already \r
+  with section header.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  SectionType    - Section type to generate. Should be \r
+                   EFI_SECTION_COMPRESSION\r
+\r
+  SectionSubType - Specify the compression algorithm requested. \r
+  \r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS           on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
+  EFI_ABORTED           if unable to open input file.\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+--*/\r
+{\r
+  UINTN                   TotalLength;\r
+  UINTN                   InputLength;\r
+  UINTN                   CompressedLength;\r
+  UINT8                   *FileBuffer;\r
+  UINT8                   *OutputBuffer;\r
+  EFI_STATUS              Status;\r
+  EFI_COMPRESSION_SECTION CompressionSect;\r
+  COMPRESS_FUNCTION       CompressFunction;\r
+\r
+  if (SectionType != EFI_SECTION_COMPRESSION) {\r
+    Error (NULL, 0, 0, "parameter must be EFI_SECTION_COMPRESSION", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  InputLength       = 0;\r
+  FileBuffer        = NULL;\r
+  OutputBuffer      = NULL;\r
+  CompressedLength  = 0;\r
+  //\r
+  // read all input file contents into a buffer\r
+  // first get the size of all file contents\r
+  //\r
+  Status = GetSectionContents (\r
+            InputFileName,\r
+            InputFileNum,\r
+            FileBuffer,\r
+            &InputLength\r
+            );\r
+\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    FileBuffer = (UINT8 *) malloc (InputLength);\r
+    if (FileBuffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    //\r
+    // read all input file contents into a buffer\r
+    //\r
+    Status = GetSectionContents (\r
+              InputFileName,\r
+              InputFileNum,\r
+              FileBuffer,\r
+              &InputLength\r
+              );\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    if (FileBuffer != NULL) {\r
+      free (FileBuffer);\r
+    }\r
+    return Status;\r
+  }\r
+\r
+  CompressFunction = NULL;\r
+\r
+  //\r
+  // Now data is in FileBuffer, compress the data\r
+  //\r
+  switch (SectionSubType) {\r
+  case EFI_NOT_COMPRESSED:\r
+    CompressedLength = InputLength;\r
+    break;\r
+\r
+  case EFI_STANDARD_COMPRESSION:\r
+    CompressFunction = (COMPRESS_FUNCTION) TianoCompress;\r
+    break;\r
+\r
+  case EFI_CUSTOMIZED_COMPRESSION:\r
+    CompressFunction = (COMPRESS_FUNCTION) CustomizedCompress;\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "unknown compression type", NULL);\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  if (CompressFunction != NULL) {\r
+\r
+    Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      OutputBuffer = malloc (CompressedLength);\r
+      if (!OutputBuffer) {\r
+        free (FileBuffer);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
+    }\r
+\r
+    free (FileBuffer);\r
+    FileBuffer = OutputBuffer;\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      if (FileBuffer != NULL) {\r
+        free (FileBuffer);\r
+      }\r
+\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION);\r
+  if (TotalLength >= MAX_SECTION_SIZE) {\r
+    Error (__FILE__, __LINE__, 0, "input error", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20);\r
+    if (FileBuffer != NULL) {\r
+      free (FileBuffer);\r
+    }\r
+    if (OutputBuffer != NULL) {\r
+      free (OutputBuffer);\r
+    }\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Add the section header for the compressed data\r
+  //\r
+  CompressionSect.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
+  CompressionSect.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
+  CompressionSect.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
+  CompressionSect.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
+  CompressionSect.CompressionType       = (UINT8) SectionSubType;\r
+  CompressionSect.UncompressedLength    = InputLength;\r
+\r
+  fwrite (&CompressionSect, sizeof (CompressionSect), 1, OutFile);\r
+  fwrite (FileBuffer, CompressedLength, 1, OutFile);\r
+  free (FileBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GenSectionGuidDefinedSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  UINTN   SectionSubType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate an encapsulating section of type EFI_SECTION_GUID_DEFINED\r
+  Input file must be already sectioned. The function won't validate\r
+  the input files' contents. Caller should hand in files already \r
+  with section header.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  SectionType    - Section type to generate. Should be \r
+                   EFI_SECTION_GUID_DEFINED\r
+\r
+  SectionSubType - Specify the authentication algorithm requested. \r
+  \r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
+  EFI_ABORTED if unable to open input file.\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+\r
+--*/\r
+{\r
+  INTN                  TotalLength;\r
+  INTN                  InputLength;\r
+  UINT8                 *FileBuffer;\r
+  UINT32                Crc32Checksum;\r
+  EFI_STATUS            Status;\r
+  CRC32_SECTION_HEADER  Crc32GuidSect;\r
+\r
+  if (SectionType != EFI_SECTION_GUID_DEFINED) {\r
+    Error (NULL, 0, 0, "parameter must be EFI_SECTION_GUID_DEFINED", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  InputLength = 0;\r
+  FileBuffer  = NULL;\r
+  //\r
+  // read all input file contents into a buffer\r
+  // first get the size of all file contents\r
+  //\r
+  Status = GetSectionContents (\r
+            InputFileName,\r
+            InputFileNum,\r
+            FileBuffer,\r
+            &InputLength\r
+            );\r
+\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    FileBuffer = (UINT8 *) malloc (InputLength);\r
+    if (FileBuffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    //\r
+    // read all input file contents into a buffer\r
+    //\r
+    Status = GetSectionContents (\r
+              InputFileName,\r
+              InputFileNum,\r
+              FileBuffer,\r
+              &InputLength\r
+              );\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    if (FileBuffer != NULL) {\r
+      free (FileBuffer);\r
+    }\r
+    return Status;\r
+  }\r
+  //\r
+  // Now data is in FileBuffer\r
+  //\r
+  switch (SectionSubType) {\r
+  case EFI_SECTION_CRC32_GUID_DEFINED:\r
+    Crc32Checksum = 0;\r
+    CalculateCrc32 (FileBuffer, InputLength, &Crc32Checksum);\r
+    if (EFI_ERROR (Status)) {\r
+      free (FileBuffer);\r
+      return Status;\r
+    }\r
+\r
+    TotalLength = InputLength + CRC32_SECTION_HEADER_SIZE;\r
+    if (TotalLength >= MAX_SECTION_SIZE) {\r
+      Error (__FILE__, __LINE__, 0, "input error", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20);\r
+      free (FileBuffer);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
+    memcpy (&(Crc32GuidSect.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
+    Crc32GuidSect.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+    Crc32GuidSect.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
+    Crc32GuidSect.CRC32Checksum                 = Crc32Checksum;\r
+\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "invalid parameter", "unknown GUID defined type");\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  fwrite (&Crc32GuidSect, sizeof (Crc32GuidSect), 1, OutFile);\r
+  fwrite (FileBuffer, InputLength, 1, OutFile);\r
+\r
+  free (FileBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main\r
+\r
+Arguments:\r
+\r
+  command line parameters\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS    Section header successfully generated and section concatenated.\r
+  EFI_ABORTED    Could not generate the section\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+\r
+--*/\r
+{\r
+  INTN                      Index;\r
+  INTN                      VersionNumber;\r
+  UINTN                     SectionType;\r
+  UINTN                     SectionSubType;\r
+  BOOLEAN                   InputFileRequired;\r
+  BOOLEAN                   SubTypeRequired;\r
+  FILE                      *InFile;\r
+  FILE                      *OutFile;\r
+  INTN                      InputFileNum;\r
+\r
+  char                      **InputFileName;\r
+  char                      *OutputFileName;\r
+  char                      AuxString[500] = { 0 };\r
+\r
+  char                      *ParamSectionType;\r
+  char                      *ParamSectionSubType;\r
+  char                      *ParamLength;\r
+  char                      *ParamVersion;\r
+  char                      *ParamDigitalSignature;\r
+\r
+  EFI_STATUS                Status;\r
+  EFI_COMMON_SECTION_HEADER CommonSect;\r
+\r
+  InputFileName         = NULL;\r
+  OutputFileName        = PARAMETER_NOT_SPECIFIED;\r
+  ParamSectionType      = PARAMETER_NOT_SPECIFIED;\r
+  ParamSectionSubType   = PARAMETER_NOT_SPECIFIED;\r
+  ParamLength           = PARAMETER_NOT_SPECIFIED;\r
+  ParamVersion          = PARAMETER_NOT_SPECIFIED;\r
+  ParamDigitalSignature = PARAMETER_NOT_SPECIFIED;\r
+  Status                = EFI_SUCCESS;\r
+\r
+  VersionNumber         = 0;\r
+  SectionType           = 0;\r
+  SectionSubType        = 0;\r
+  InputFileRequired     = TRUE;\r
+  SubTypeRequired       = FALSE;\r
+  InFile                = NULL;\r
+  OutFile               = NULL;\r
+  InputFileNum          = 0;\r
+  Status                = EFI_SUCCESS;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  if (argc == 1) {\r
+    PrintUsageMessage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Parse command line\r
+  //\r
+  Index = 1;\r
+  while (Index < argc) {\r
+    if (_strcmpi (argv[Index], "-i") == 0) {\r
+      //\r
+      // Input File found\r
+      //\r
+      Index++;\r
+      InputFileName = (char **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (char *));\r
+      if (InputFileName == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
+      InputFileName[InputFileNum] = argv[Index];\r
+      InputFileNum++;\r
+      Index++;\r
+      //\r
+      // Parse subsequent parameters until another switch is encountered\r
+      //\r
+      while ((Index < argc) && (argv[Index][0] != '-')) {\r
+        if ((InputFileNum % MAXIMUM_INPUT_FILE_NUM) == 0) {\r
+          //\r
+          // InputFileName buffer too small, need to realloc\r
+          //\r
+          InputFileName = (char **) realloc (\r
+                                      InputFileName,\r
+                                      (InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (char *)\r
+                                      );\r
+          if (InputFileName == NULL) {\r
+            Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+            return EFI_OUT_OF_RESOURCES;\r
+          }\r
+\r
+          memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
+        }\r
+\r
+        InputFileName[InputFileNum] = argv[Index];\r
+        InputFileNum++;\r
+        Index++;\r
+      }\r
+\r
+    }\r
+\r
+    if (_strcmpi (argv[Index], "-o") == 0) {\r
+      //\r
+      // Output file found\r
+      //\r
+      Index++;\r
+      OutputFileName = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-s") == 0) {\r
+      //\r
+      // Section Type found\r
+      //\r
+      Index++;\r
+      ParamSectionType = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-t") == 0) {\r
+      //\r
+      // Compression or Authentication type\r
+      //\r
+      Index++;\r
+      ParamSectionSubType = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-l") == 0) {\r
+      //\r
+      // Length\r
+      //\r
+      Index++;\r
+      ParamLength = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-v") == 0) {\r
+      //\r
+      // VersionNumber\r
+      //\r
+      Index++;\r
+      ParamVersion = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-a") == 0) {\r
+      //\r
+      // Aux string\r
+      //\r
+      Index++;\r
+      //\r
+      // Note, the MSVC C-Start parses out and consolidates quoted strings from the command\r
+      // line.  Quote characters are stripped.  If this tool is ported to other environments\r
+      // this will need to be taken into account\r
+      //\r
+      strncpy (AuxString, argv[Index], 499);\r
+    } else if (_strcmpi (argv[Index], "-d") == 0) {\r
+      //\r
+      // Digital signature for EFI_TEST_AUTHENTICAION (must be 0 or 1)\r
+      //\r
+      Index++;\r
+      ParamDigitalSignature = argv[Index];\r
+    } else if (_strcmpi (argv[Index], "-?") == 0) {\r
+      PrintUsageMessage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, argv[Index], "unknown option");\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    Index++;\r
+  }\r
+  //\r
+  // At this point, all command line parameters are verified as not being totally\r
+  // bogus.  Next verify the command line parameters are complete and make\r
+  // sense...\r
+  //\r
+  if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPRESSION]) == 0) {\r
+    SectionType     = EFI_SECTION_COMPRESSION;\r
+    SubTypeRequired = TRUE;\r
+    if (_stricmp (ParamSectionSubType, CompressionTypeName[EFI_NOT_COMPRESSED]) == 0) {\r
+      SectionSubType = EFI_NOT_COMPRESSED;\r
+    } else if (_stricmp (ParamSectionSubType, CompressionTypeName[EFI_STANDARD_COMPRESSION]) == 0) {\r
+      SectionSubType = EFI_STANDARD_COMPRESSION;\r
+    } else {\r
+      Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type");\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) {\r
+    SectionType     = EFI_SECTION_GUID_DEFINED;\r
+    SubTypeRequired = TRUE;\r
+    if (_stricmp (ParamSectionSubType, GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]) == 0) {\r
+      SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED;\r
+    } else {\r
+      Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType);\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) {\r
+    SectionType = EFI_SECTION_PE32;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PIC]) == 0) {\r
+    SectionType = EFI_SECTION_PIC;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_TE]) == 0) {\r
+    SectionType = EFI_SECTION_TE;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_DXE_DEPEX]) == 0) {\r
+    SectionType = EFI_SECTION_DXE_DEPEX;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_VERSION]) == 0) {\r
+    SectionType       = EFI_SECTION_VERSION;\r
+    InputFileRequired = FALSE;\r
+    Index             = sscanf (ParamVersion, "%d", &VersionNumber);\r
+    if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) {\r
+      Error (NULL, 0, 0, ParamVersion, "illegal version number");\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
+      AuxString[0] = 0;\r
+    }\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_USER_INTERFACE]) == 0) {\r
+    SectionType       = EFI_SECTION_USER_INTERFACE;\r
+    InputFileRequired = FALSE;\r
+    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
+      Error (NULL, 0, 0, "user interface string not specified", NULL);\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) {\r
+    SectionType = EFI_SECTION_COMPATIBILITY16;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FIRMWARE_VOLUME_IMAGE]) == 0) {\r
+    SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FREEFORM_SUBTYPE_GUID]) == 0) {\r
+    SectionType = EFI_SECTION_FREEFORM_SUBTYPE_GUID;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_RAW]) == 0) {\r
+    SectionType = EFI_SECTION_RAW;\r
+  } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PEI_DEPEX]) == 0) {\r
+    SectionType = EFI_SECTION_PEI_DEPEX;\r
+  } else {\r
+    Error (NULL, 0, 0, ParamSectionType, "unknown section type");\r
+    PrintUsageMessage ();\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // Open output file\r
+  //\r
+  OutFile = fopen (OutputFileName, "wb");\r
+  if (OutFile == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    if (InFile != NULL) {\r
+      fclose (InFile);\r
+    }\r
+\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // At this point, we've fully validated the command line, and opened appropriate\r
+  // files, so let's go and do what we've been asked to do...\r
+  //\r
+  //\r
+  // Within this switch, build and write out the section header including any\r
+  // section type specific pieces.  If there's an input file, it's tacked on later\r
+  //\r
+  switch (SectionType) {\r
+  case EFI_SECTION_COMPRESSION:\r
+    Status = GenSectionCompressionSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              SectionSubType,\r
+              OutFile\r
+              );\r
+    break;\r
+\r
+  case EFI_SECTION_GUID_DEFINED:\r
+    Status = GenSectionGuidDefinedSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              SectionSubType,\r
+              OutFile\r
+              );\r
+    break;\r
+\r
+  case EFI_SECTION_VERSION:\r
+    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+\r
+    Index           = sizeof (CommonSect);\r
+    //\r
+    // 2 characters for the build number\r
+    //\r
+    Index += 2;\r
+    //\r
+    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
+    //\r
+    Index += (strlen (AuxString) * 2) + 2;\r
+    memcpy (&CommonSect.Size, &Index, 3);\r
+    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+    fwrite (&VersionNumber, 2, 1, OutFile);\r
+    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
+    break;\r
+\r
+  case EFI_SECTION_USER_INTERFACE:\r
+    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+    Index           = sizeof (CommonSect);\r
+    //\r
+    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
+    //\r
+    Index += (strlen (AuxString) * 2) + 2;\r
+    memcpy (&CommonSect.Size, &Index, 3);\r
+    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
+    break;\r
+\r
+  default:\r
+    //\r
+    // All other section types are caught by default (they're all the same)\r
+    //\r
+    Status = GenSectionCommonLeafSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              OutFile\r
+              );\r
+    break;\r
+  }\r
+\r
+  if (InputFileName != NULL) {\r
+    free (InputFileName);\r
+  }\r
+\r
+  fclose (OutFile);\r
+  //\r
+  // If we had errors, then delete the output file\r
+  //\r
+  if (GetUtilityStatus () == STATUS_ERROR) {\r
+    remove (OutputFileName);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h
new file mode 100644 (file)
index 0000000..24c1c4e
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenSection.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenSection.\r
+\r
+--*/\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_SECTION_H\r
+#define _EFI_GEN_SECTION_H\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+#include "TianoCommon.h"\r
+#include "EfiImageFormat.h"\r
+\r
+typedef struct {\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT32                    CRC32Checksum;\r
+} CRC32_SECTION_HEADER;\r
+\r
+#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
+#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile
new file mode 100644 (file)
index 0000000..053d237
--- /dev/null
@@ -0,0 +1,82 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#\r
+#  Abstract:\r
+#\r
+#    This file is used to build the EFI utility.\r
+#\r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Common information\r
+#\r
+INC                 = $(INC) -I $(EDK_TOOLS_SOURCE)\Common\r
+\r
+LIBS                = $(LIBS) $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = GenSection\r
+TARGET_SOURCE_DIR   = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+TARGET_EXE_SOURCE   = "$(TARGET_SOURCE_DIR)\GenSection.c"\r
+TARGET_EXE_LIBS     = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+TARGET_EXE_INCLUDE  = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \\r
+                     "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \\r
+                     "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \\r
+                     "$(EDK_TOOLS_COMMON)\ParseInf.h"\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(LIBS) $(TARGET_EXE_LIBS)\r
+  $(LINK) /DEBUG $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h
new file mode 100644 (file)
index 0000000..f7a331e
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  CommonUtils.h\r
+  \r
+Abstract:\r
+\r
+  Common utility defines and structure definitions.\r
+  \r
+--*/\r
+\r
+#ifndef _COMMON_UTILS_H_\r
+#define _COMMON_UTILS_H_\r
+\r
+//\r
+// Basic types\r
+//\r
+typedef unsigned char UINT8;\r
+typedef char INT8;\r
+typedef unsigned short UINT16;\r
+typedef unsigned int UINT32;\r
+\r
+typedef UINT8 BOOLEAN;\r
+typedef UINT32 STATUS;\r
+\r
+#define TRUE            1\r
+#define FALSE           0\r
+\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+\r
+//\r
+// Linked list of strings\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  char                *Str;\r
+} STRING_LIST;\r
+\r
+int\r
+CreateGuidList (\r
+  INT8    *OutFileName\r
+  )\r
+;\r
+\r
+#endif // #ifndef _COMMON_UTILS_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c
new file mode 100644 (file)
index 0000000..dc7c7c5
--- /dev/null
@@ -0,0 +1,285 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  FileSearch.c\r
+  \r
+Abstract:\r
+\r
+  Module used to support file searches on the system.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+\r
+#include "CommonUtils.h"\r
+#include "FileSearch.h"\r
+#include "UtilsMsgs.h"\r
+\r
+//\r
+// Internal file search flag for sanity checks\r
+//\r
+#define FILE_SEARCH_STARTED 0x8000\r
+#define FILE_SEARCH_INITED  0x4000\r
+\r
+static\r
+BOOLEAN\r
+FileSearchMeetsCriteria (\r
+  FILE_SEARCH_DATA    *FSData\r
+  );\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+FileSearchInit (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  memset ((char *) FSData, 0, sizeof (FILE_SEARCH_DATA));\r
+  FSData->Handle          = INVALID_HANDLE_VALUE;\r
+  FSData->FileSearchFlags = FILE_SEARCH_INITED;\r
+  FSData->FileName[0]     = 0;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchStart (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  char                *FileMask,\r
+  UINT32              SearchFlags\r
+  )\r
+{\r
+  BOOLEAN Done;\r
+\r
+  //\r
+  // Save their flags, and set a flag to indicate that they called this\r
+  // start function so we can perform extended checking in the other\r
+  // routines we have in this module.\r
+  //\r
+  FSData->FileSearchFlags |= (SearchFlags | FILE_SEARCH_STARTED);\r
+  FSData->FileName[0] = 0;\r
+\r
+  //\r
+  // Begin the search\r
+  //\r
+  FSData->Handle = FindFirstFile (FileMask, &(FSData->FindData));\r
+  if (FSData->Handle == INVALID_HANDLE_VALUE) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Keep looping through until we find a file meeting the caller's\r
+  // criteria per the search flags\r
+  //\r
+  Done = FALSE;\r
+  while (!Done) {\r
+    //\r
+    // If we're done (we found a match) copy the file name found and return\r
+    //\r
+    Done = FileSearchMeetsCriteria (FSData);\r
+    if (Done) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+    //\r
+    // Go on to next file\r
+    //\r
+    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
+      return STATUS_NOT_FOUND;\r
+    }\r
+  }\r
+  //\r
+  // Not reached\r
+  //\r
+  return STATUS_NOT_FOUND;\r
+}\r
+\r
+//\r
+// Find the next file meeting their criteria and return it.\r
+//\r
+STATUS\r
+FileSearchFindNext (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  BOOLEAN Done;\r
+\r
+  Done = FALSE;\r
+  while (!Done) {\r
+    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
+      return STATUS_NOT_FOUND;\r
+    }\r
+    //\r
+    // See if it matches their criteria\r
+    //\r
+    Done = FileSearchMeetsCriteria (FSData);\r
+    if (Done) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // Not reached\r
+  //\r
+  return STATUS_NOT_FOUND;\r
+}\r
+//\r
+// Perform any cleanup necessary to close down a search\r
+//\r
+STATUS\r
+FileSearchDestroy (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  if (FSData->Handle != INVALID_HANDLE_VALUE) {\r
+    FindClose (FSData->Handle);\r
+    FSData->Handle = INVALID_HANDLE_VALUE;\r
+  }\r
+\r
+  FSData->FileName[0]     = 0;\r
+  FSData->FileSearchFlags = 0;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+FileSearchMeetsCriteria (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  BOOLEAN     Status;\r
+  STRING_LIST *StrList;\r
+  UINT32      ExtLen;\r
+  UINT32      FileNameLen;\r
+\r
+  Status = FALSE;\r
+\r
+  //\r
+  // First clear the flag indicating this is neither a file or a\r
+  // directory.\r
+  //\r
+  FSData->FileFlags &= ~(FILE_SEARCH_DIR | FILE_SEARCH_FILE);\r
+\r
+  //\r
+  // We found a file. See if it matches the user's search criteria. First\r
+  // check for this being a directory, and they want directories, and\r
+  // it's not "." and it's not ".."\r
+  //\r
+  if ((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&\r
+      (FSData->FileSearchFlags & FILE_SEARCH_DIR) &&\r
+      (strcmp (FSData->FindData.cFileName, ".")) &&\r
+      (strcmp (FSData->FindData.cFileName, ".."))\r
+      ) {\r
+    //\r
+    // Assume we'll make it past this check\r
+    //\r
+    Status = TRUE;\r
+    //\r
+    // If they have a list of exclude directories, then check for those\r
+    //\r
+    StrList = FSData->ExcludeDirs;\r
+    while (StrList != NULL) {\r
+      if (_stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
+        Status = FALSE;\r
+        break;\r
+      }\r
+\r
+      StrList = StrList->Next;\r
+    }\r
+    //\r
+    // If we didn't fail due to excluded directories, then set the dir flag\r
+    //\r
+    if (Status) {\r
+      FSData->FileFlags |= FILE_SEARCH_DIR;\r
+    }\r
+    //\r
+    // Else check for a file, and they want files....\r
+    //\r
+  } else if (((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) &&\r
+           (FSData->FileSearchFlags & FILE_SEARCH_FILE)\r
+          ) {\r
+    //\r
+    // See if it's in our list of excluded files\r
+    //\r
+    Status  = TRUE;\r
+    StrList = FSData->ExcludeFiles;\r
+    while (StrList != NULL) {\r
+      if (_stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
+        Status = FALSE;\r
+        break;\r
+      }\r
+\r
+      StrList = StrList->Next;\r
+    }\r
+\r
+    if (Status) {\r
+      //\r
+      // See if it's in our list of excluded file extensions\r
+      //\r
+      FileNameLen = strlen (FSData->FindData.cFileName);\r
+      StrList     = FSData->ExcludeExtensions;\r
+      while (StrList != NULL) {\r
+        ExtLen = strlen (StrList->Str);\r
+        if (_stricmp (\r
+              FSData->FindData.cFileName + FileNameLen - ExtLen,\r
+              StrList->Str\r
+              ) == 0) {\r
+          Status = FALSE;\r
+          break;\r
+        }\r
+\r
+        StrList = StrList->Next;\r
+      }\r
+    }\r
+\r
+    if (Status) {\r
+      FSData->FileFlags |= FILE_SEARCH_FILE;\r
+    }\r
+  }\r
+  //\r
+  // If it's a match, copy the filename into another field of the structure\r
+  // for portability.\r
+  //\r
+  if (Status) {\r
+    strcpy (FSData->FileName, FSData->FindData.cFileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+//\r
+// Exclude a list of subdirectories.\r
+//\r
+STATUS\r
+FileSearchExcludeDirs (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeDirs = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchExcludeFiles (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeFiles = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchExcludeExtensions (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeExtensions = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h
new file mode 100644 (file)
index 0000000..bc40265
--- /dev/null
@@ -0,0 +1,108 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  FileSearch.h\r
+  \r
+Abstract:\r
+\r
+  Header file to support file searching.\r
+  \r
+--*/\r
+\r
+#ifndef _FILE_SEARCH_H_\r
+#define _FILE_SEARCH_H_\r
+\r
+//\r
+// Since the file searching routines are OS dependent, put the\r
+// necessary include paths in this header file so that the non-OS-dependent\r
+// files don't need to include these windows-specific header files.\r
+//\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <direct.h>\r
+#include <windows.h>\r
+\r
+//\r
+// Return codes of some of the file search routines\r
+//\r
+#define STATUS_NOT_FOUND  0x1000\r
+\r
+//\r
+// Flags for what to search for. Also used in the FileFlags return field.\r
+//\r
+#define FILE_SEARCH_DIR   0x0001\r
+#define FILE_SEARCH_FILE  0x0002\r
+\r
+//\r
+// Here's our class definition\r
+//\r
+typedef struct {\r
+  HANDLE          Handle;\r
+  WIN32_FIND_DATA FindData;\r
+  UINT32          FileSearchFlags;    // DIRS, FILES, etc\r
+  UINT32          FileFlags;\r
+  INT8            FileName[MAX_PATH]; // for portability\r
+  STRING_LIST     *ExcludeDirs;\r
+  STRING_LIST     *ExcludeFiles;\r
+  STRING_LIST     *ExcludeExtensions;\r
+} FILE_SEARCH_DATA;\r
+\r
+//\r
+// Here's our member functions\r
+//\r
+STATUS\r
+FileSearchInit (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchDestroy (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchStart (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  char                *FileMask,\r
+  UINT32              SearchFlags\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchFindNext (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchExcludeDirs (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+STATUS\r
+FileSearchExcludeExtensions (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+STATUS\r
+FileSearchExcludeFiles (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
new file mode 100644 (file)
index 0000000..97d5892
--- /dev/null
@@ -0,0 +1,2417 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  GuidChk.c \r
+  \r
+Abstract:\r
+\r
+  Parse files in a directory and subdirectories to find all guid definitions.\r
+  Then check them against each other to make sure there are no duplicates.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "CommonUtils.h"\r
+#include "FileSearch.h"\r
+#include "UtilsMsgs.h"\r
+\r
+#define MAX_LINE_LEN  1024 // we concatenate lines sometimes\r
+// Define a structure that correlates filename extensions to an enumerated\r
+// type.\r
+//\r
+#ifdef MAX_PATH\r
+#undef MAX_PATH\r
+#define MAX_PATH  1024\r
+#endif\r
+\r
+typedef struct {\r
+  INT8  *Extension;\r
+  INT8  ExtensionCode;\r
+} FILE_TYPE_TABLE_ENTRY;\r
+\r
+#define FILE_EXTENSION_UNKNOWN  0\r
+#define FILE_EXTENSION_C        1\r
+#define FILE_EXTENSION_H        2\r
+#define FILE_EXTENSION_IA32_ASM 3\r
+#define FILE_EXTENSION_IA32_INC 4\r
+#define FILE_EXTENSION_IA64_ASM 5\r
+#define FILE_EXTENSION_IA64_INC 6\r
+#define FILE_EXTENSION_PKG      7\r
+#define FILE_EXTENSION_INF      8\r
+\r
+FILE_TYPE_TABLE_ENTRY FileTypeTable[] = {\r
+  ".c",\r
+  FILE_EXTENSION_C,\r
+  ".h",\r
+  FILE_EXTENSION_H,\r
+  ".inc",\r
+  FILE_EXTENSION_IA32_INC,\r
+  ".asm",\r
+  FILE_EXTENSION_IA32_ASM,\r
+  ".s",\r
+  FILE_EXTENSION_IA64_ASM,\r
+  ".pkg",\r
+  FILE_EXTENSION_PKG,\r
+  ".inf",\r
+  FILE_EXTENSION_INF,\r
+  ".i",\r
+  FILE_EXTENSION_IA64_INC,\r
+  NULL,\r
+  0\r
+};\r
+\r
+typedef struct EFI_GUID {\r
+  UINT32  Data1;\r
+  UINT16  Data2;\r
+  UINT16  Data3;\r
+  UINT8   Data4[8];\r
+} EFI_GUID;\r
+\r
+typedef struct {\r
+  INT8  Data[8];\r
+  INT8  DataLen;\r
+} EFI_SIGNATURE;\r
+\r
+typedef struct _GUID_RECORD {\r
+  struct _GUID_RECORD *Next;\r
+  BOOLEAN             Reported;\r
+  INT8                *FileName;\r
+  INT8                *SymName;\r
+  EFI_GUID            Guid;\r
+} GUID_RECORD;\r
+\r
+typedef struct _SIGNATURE_RECORD {\r
+  struct _SIGNATURE_RECORD  *Next;\r
+  BOOLEAN                   Reported;\r
+  INT8                      *FileName;\r
+  EFI_SIGNATURE             Signature;\r
+} SIGNATURE_RECORD;\r
+\r
+//\r
+// Utility options\r
+//\r
+typedef struct {\r
+  INT8        DatabaseOutputFileName[MAX_PATH]; // with -b option\r
+  STRING_LIST *ExcludeDirs;                     // list of directory names not to process\r
+  STRING_LIST *ExcludeSubDirs;                  // list of directory names to not process subdirectories (build)\r
+  STRING_LIST *ExcludeFiles;                    // list of files to exclude (make.inf)\r
+  STRING_LIST *ExcludeExtensions;               // list of filename extensions to exclude (.inf, .pkg)\r
+  BOOLEAN     Verbose;\r
+  BOOLEAN     PrintFound;\r
+  BOOLEAN     CheckGuids;\r
+  BOOLEAN     CheckSignatures;\r
+  BOOLEAN     GuidXReference;\r
+} OPTIONS;\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  );\r
+\r
+static\r
+VOID\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessDirectory (\r
+  INT8        *Path,\r
+  INT8        *DirectoryName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8                *DirectoryName,\r
+  INT8                *FileName\r
+  );\r
+\r
+static\r
+UINT32\r
+GetFileExtension (\r
+  INT8        *FileName\r
+  );\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  INT8    *Str\r
+  );\r
+\r
+static\r
+UINT32\r
+ValidSymbolName (\r
+  INT8    *Name\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddSignature (\r
+  INT8      *FileName,\r
+  INT8      *StrDef,\r
+  UINT32    SigSize\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCFileSigs (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessINFFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessPkgFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIA32FileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIA64FileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsIA64GuidLine (\r
+  INT8      *Line,\r
+  UINT32    *GuidHigh,\r
+  UINT32    *GuidLow,\r
+  BOOLEAN   *Low,\r
+  INT8      *SymName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid11 (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  INT8      *SymName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddPkgGuid (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  UINT64    *Data64\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid16 (\r
+  INT8      *FileName,\r
+  UINT32    *Data\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid64x2 (\r
+  INT8      *FileName,\r
+  UINT32    DataHH,                             // Upper 32-bits of upper 64 bits of guid\r
+  UINT32    DataHL,                             // Lower 32-bits of upper 64 bits\r
+  UINT32    DataLH,\r
+  UINT32    DataLL,\r
+  INT8      *SymName\r
+  );\r
+\r
+static\r
+VOID\r
+FreeGuids (\r
+  VOID\r
+  );\r
+\r
+static\r
+VOID\r
+FreeSigs (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+CheckDuplicates (\r
+  VOID\r
+  );\r
+\r
+//\r
+// static\r
+// VOID\r
+// ReportGuid (\r
+//  INT8        *FileName,\r
+//  GUID_RECORD *FileRecord\r
+//  );\r
+//\r
+static\r
+VOID\r
+FreeOptions (\r
+  VOID\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+CheckGuidData (\r
+  UINT32    *GuidData,\r
+  UINT32    DataCount\r
+  );\r
+\r
+static\r
+VOID\r
+ConcatenateLines (\r
+  FILE        *Fptr, \r
+  INT8        *Line,\r
+  UINT32      Len\r
+  );\r
+  \r
+/**************************** GLOBALS ****************************************/\r
+static GUID_RECORD      *gGuidList      = NULL;\r
+static SIGNATURE_RECORD *gSignatureList = NULL;\r
+static OPTIONS          gOptions;\r
+\r
+/*****************************************************************************/\r
+int\r
+main (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+{\r
+  INT8    *Cwd;\r
+  STATUS  Status;\r
+\r
+  SetUtilityName ("GuidChk");\r
+  //\r
+  // Get the current working directory and then process the command line\r
+  // arguments.\r
+  //\r
+  Cwd     = _getcwd (NULL, 0);\r
+  Status  = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  if (gOptions.CheckGuids || gOptions.CheckSignatures) {\r
+    Status = ProcessDirectory (Cwd, NULL);\r
+    if (Status == STATUS_SUCCESS) {\r
+      //\r
+      // Check for duplicates\r
+      //\r
+      Status = CheckDuplicates ();\r
+    }\r
+  }\r
+\r
+  if (gOptions.DatabaseOutputFileName[0] != 0) {\r
+    CreateGuidList (gOptions.DatabaseOutputFileName);\r
+  }\r
+  //\r
+  // Free up the memory\r
+  //\r
+  free (Cwd);\r
+  FreeGuids ();\r
+  FreeSigs ();\r
+  FreeOptions ();\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+{\r
+  STRING_LIST *StrList;\r
+\r
+  memset ((char *) &gOptions, 0, sizeof (gOptions));\r
+  //\r
+  // skip over program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  while (Argc > 0) {\r
+    //\r
+    // Look for options\r
+    //\r
+    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
+      switch (Argv[0][1]) {\r
+      //\r
+      // Help option\r
+      //\r
+      case 'h':\r
+      case 'H':\r
+      case '?':\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+        break;\r
+\r
+      //\r
+      // Check guids option\r
+      //\r
+      case 'g':\r
+      case 'G':\r
+        gOptions.CheckGuids = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Check signatures option\r
+      //\r
+      case 's':\r
+      case 'S':\r
+        gOptions.CheckSignatures = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Print guids found option\r
+      //\r
+      case 'p':\r
+      case 'P':\r
+        gOptions.PrintFound = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Exclude files option\r
+      //\r
+      case 'f':\r
+      case 'F':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str          = Argv[1];\r
+        StrList->Next         = gOptions.ExcludeFiles;\r
+        gOptions.ExcludeFiles = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // Exclude directories option\r
+      //\r
+      case 'd':\r
+      case 'D':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str          = Argv[1];\r
+        StrList->Next         = gOptions.ExcludeDirs;\r
+        gOptions.ExcludeDirs  = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // -u  exclude all subdirectories of a given directory option\r
+      //\r
+      case 'u':\r
+      case 'U':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str            = Argv[1];\r
+        StrList->Next           = gOptions.ExcludeSubDirs;\r
+        gOptions.ExcludeSubDirs = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // -e  exclude by filename extension option\r
+      //\r
+      case 'e':\r
+      case 'E':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        //\r
+        // Let them put a * in front of the filename extension\r
+        //\r
+        StrList->Str = Argv[1];\r
+        if (StrList->Str[0] == '*') {\r
+          StrList->Str++;\r
+        }\r
+\r
+        StrList->Next               = gOptions.ExcludeExtensions;\r
+        gOptions.ExcludeExtensions  = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // Print guid with matching symbol name for guid definitions found\r
+      //\r
+      case 'x':\r
+      case 'X':\r
+        gOptions.GuidXReference = TRUE;\r
+        break;\r
+\r
+      //\r
+      // -b   Print the internal database list to a file\r
+      //\r
+      case 'b':\r
+      case 'B':\r
+        //\r
+        // Check for one more arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "must specify file name with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (gOptions.DatabaseOutputFileName, Argv[1]);\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      default:\r
+        Error (NULL, 0, 0, Argv[0], "invalid option");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+    } else {\r
+      break;\r
+    }\r
+    //\r
+    // Next arg\r
+    //\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+\r
+  if (Argc > 0) {\r
+    Error (NULL, 0, 0, Argv[0], "invalid argument");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Have to check signatures, GUIDs, or dump the GUID database.\r
+  //\r
+  if ((!gOptions.CheckGuids) && (!gOptions.CheckSignatures) && (gOptions.DatabaseOutputFileName[0] == 0)) {\r
+    Error (NULL, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Print usage instructions\r
+//\r
+static\r
+VOID\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  int   Index;\r
+  char  *Str[] = {\r
+    "GuidChk - scan files for duplicate GUID or signature definitions",\r
+    "",\r
+    "Usage:  GuidChk {options}\n",\r
+    "  Options: ",\r
+    "    -d dirname     exclude searching of a directory",\r
+    "    -f filename    exclude searching of a file",\r
+    "    -e extension   exclude searching of files by extension",\r
+    "    -p             print all GUIDS found",\r
+    "    -g             check for duplicate guids",\r
+    "    -s             check for duplicate signatures",\r
+    "    -x             print guid+defined symbol name",\r
+    "    -b outfile     write internal GUID+basename list to outfile",\r
+    "    -u dirname     exclude searching all subdirectories of a directory",\r
+    "    -h -?          print this help text",\r
+    " ",\r
+    "   Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
+//\r
+// Process an entire directory by name\r
+//\r
+static\r
+STATUS\r
+ProcessDirectory (\r
+  INT8          *Path,\r
+  INT8          *DirectoryName\r
+  )\r
+{\r
+  FILE_SEARCH_DATA  FSData;\r
+  char              *FileMask;\r
+  BOOLEAN           Done;\r
+  UINT32            Len;\r
+  BOOLEAN           NoSubdirs;\r
+  STRING_LIST       *SLPtr;\r
+\r
+  //\r
+  // Root directory may be null\r
+  //\r
+  if (DirectoryName != NULL) {\r
+    //\r
+    // printf ("Processing directory: %s\n", DirectoryName);\r
+    //\r
+  }\r
+  //\r
+  // Initialize our file searching\r
+  //\r
+  FileSearchInit (&FSData);\r
+\r
+  //\r
+  // Exclude some directories, files, and extensions\r
+  //\r
+  FileSearchExcludeDirs (&FSData, gOptions.ExcludeDirs);\r
+  FileSearchExcludeExtensions (&FSData, gOptions.ExcludeExtensions);\r
+  FileSearchExcludeFiles (&FSData, gOptions.ExcludeFiles);\r
+  //\r
+  // See if this directory is in the list of directories that they\r
+  // don't want to process subdirectories of\r
+  //\r
+  NoSubdirs = FALSE;\r
+  if (DirectoryName != NULL) {\r
+    for (SLPtr = gOptions.ExcludeSubDirs; SLPtr != NULL; SLPtr = SLPtr->Next) {\r
+      if (_stricmp (SLPtr->Str, DirectoryName) == 0) {\r
+        //\r
+        // printf ("not processing subdirectories of %s\n", DirectoryName);\r
+        //\r
+        NoSubdirs = TRUE;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Create a filemask of files to search for. We'll append "\*.*" on the\r
+  // end, so allocate some extra bytes.\r
+  //\r
+  Len = strlen (Path) + 10;\r
+  if (DirectoryName != NULL) {\r
+    Len += strlen (DirectoryName);\r
+  }\r
+\r
+  FileMask = malloc (Len);\r
+  if (FileMask == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now put it all together\r
+  //\r
+  strcpy (FileMask, Path);\r
+  if ((DirectoryName != NULL) && (strlen (DirectoryName) > 0)) {\r
+    strcat (FileMask, "\\");\r
+    strcat (FileMask, DirectoryName);\r
+  }\r
+\r
+  strcat (FileMask, "\\*.*");\r
+\r
+  //\r
+  // Start file searching for files and directories\r
+  //\r
+  if (FileSearchStart (&FSData, FileMask, FILE_SEARCH_FILE | FILE_SEARCH_DIR) == STATUS_SUCCESS) {\r
+    Done = FALSE;\r
+  } else {\r
+    Done = TRUE;\r
+  }\r
+\r
+  //\r
+  // Now hack the "\*.*" off the end of the filemask so we can use it to pass\r
+  // the full directory path on recursive calls to process directories.\r
+  //\r
+  FileMask[strlen (FileMask) - 4] = 0;\r
+\r
+  //\r
+  // Loop until no more files\r
+  //\r
+  while (!Done) {\r
+    //\r
+    // printf ("Found %s...", FSData.FileName);\r
+    //\r
+    if (FSData.FileFlags & FILE_SEARCH_DIR) {\r
+      //\r
+      // printf ("directory\n");\r
+      //\r
+      if (!NoSubdirs) {\r
+        ProcessDirectory (FileMask, FSData.FileName);\r
+      }\r
+    } else if (FSData.FileFlags & FILE_SEARCH_FILE) {\r
+      //\r
+      // printf ("file\n");\r
+      //\r
+      ProcessFile (FileMask, FSData.FileName);\r
+    } else {\r
+      //\r
+      // printf ("unknown\n");\r
+      //\r
+    }\r
+\r
+    if (FileSearchFindNext (&FSData) != STATUS_SUCCESS) {\r
+      Done = TRUE;\r
+    }\r
+  }\r
+  //\r
+  // Free up allocated memory\r
+  //\r
+  free (FileMask);\r
+\r
+  //\r
+  // Free up our file searching\r
+  //\r
+  FileSearchDestroy (&FSData);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process a single file.\r
+//\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8                *DirectoryName,\r
+  INT8                *FileName\r
+  )\r
+{\r
+  STATUS  Status;\r
+  UINT32  FileExtension;\r
+  INT8    FullFileName[MAX_PATH];\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  sprintf (FullFileName, "%s\\%s", DirectoryName, FileName);\r
+  //\r
+  // printf ("Found file: %s\n", FullFileName);\r
+  //\r
+  FileExtension = GetFileExtension (FileName);\r
+\r
+  //\r
+  // Process these for GUID checks\r
+  //\r
+  if (gOptions.CheckGuids) {\r
+    switch (FileExtension) {\r
+    case FILE_EXTENSION_C:\r
+    case FILE_EXTENSION_H:\r
+      Status = ProcessCFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_PKG:\r
+      Status = ProcessPkgFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_IA32_INC:\r
+    case FILE_EXTENSION_IA32_ASM:\r
+      Status = ProcessIA32FileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_INF:\r
+      Status = ProcessINFFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_IA64_INC:\r
+    case FILE_EXTENSION_IA64_ASM:\r
+      Status = ProcessIA64FileGuids (FullFileName);\r
+      break;\r
+\r
+    default:\r
+      //\r
+      // No errors anyway\r
+      //\r
+      Status = STATUS_SUCCESS;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (gOptions.CheckSignatures) {\r
+    switch (FileExtension) {\r
+    case FILE_EXTENSION_C:\r
+    case FILE_EXTENSION_H:\r
+      Status = ProcessCFileSigs (FullFileName);\r
+      break;\r
+\r
+    default:\r
+      //\r
+      // No errors anyway\r
+      //\r
+      Status = STATUS_SUCCESS;\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+//\r
+// Return a code indicating the file name extension.\r
+//\r
+static\r
+UINT32\r
+GetFileExtension (\r
+  INT8        *FileName\r
+  )\r
+{\r
+  INT8  *Extension;\r
+  int   Index;\r
+\r
+  //\r
+  // Look back for a filename extension\r
+  //\r
+  for (Extension = FileName + strlen (FileName) - 1; Extension >= FileName; Extension--) {\r
+    if (*Extension == '.') {\r
+      for (Index = 0; FileTypeTable[Index].Extension != NULL; Index++) {\r
+        if (_stricmp (FileTypeTable[Index].Extension, Extension) == 0) {\r
+          return FileTypeTable[Index].ExtensionCode;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FILE_TYPE_UNKNOWN;\r
+}\r
+//\r
+// Process a .pkg file.\r
+//\r
+// Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
+//\r
+static\r
+STATUS\r
+ProcessPkgFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    *Cptr2;\r
+  UINT32  GuidScan[11];\r
+  UINT64  Guid64;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    if (strncmp (Cptr, "FFS_FILEGUID", 12) == 0) {\r
+      Cptr += 12;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr + 1);\r
+        //\r
+        // Blank out dashes on the line.\r
+        //\r
+        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
+          if (*Cptr2 == '-') {\r
+            *Cptr2 = ' ';\r
+          }\r
+        }\r
+\r
+        if (sscanf (\r
+              Cptr,\r
+              "%X %X %X %X %I64X",\r
+              &GuidScan[0],\r
+              &GuidScan[1],\r
+              &GuidScan[2],\r
+              &GuidScan[3],\r
+              &Guid64\r
+              ) == 5) {\r
+          AddPkgGuid (FileName, GuidScan, &Guid64);\r
+        } else {\r
+          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process an IA32 assembly file.\r
+//\r
+// Look for:\r
+// FIND_FD_GUID_VAL equ  01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h\r
+// PEI_GUID_FileNameGuid_Gmch815  equ  081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h\r
+//\r
+static\r
+STATUS\r
+ProcessIA32FileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN];\r
+  INT8    *Cptr;\r
+  INT8    CSave;\r
+  INT8    *CSavePtr;\r
+  UINT32  Len;\r
+  UINT32  GuidData[16];\r
+  UINT32  Index;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...\r
+    //\r
+    Len = ValidSymbolName (Cptr);\r
+    if (Len) {\r
+      //\r
+      // Terminate the line after the symbol name, then look for "guid" in\r
+      // the name.\r
+      //\r
+      CSavePtr  = Cptr + Len;\r
+      CSave     = *CSavePtr;\r
+      *CSavePtr = 0;\r
+      while (*Cptr) {\r
+        if (_strnicmp (Cptr, "guid", 4) == 0) {\r
+          break;\r
+        }\r
+\r
+        Cptr++;\r
+      }\r
+      //\r
+      // If we found the string "guid", continue\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Restore the character on the line where we null-terminated the symbol\r
+        //\r
+        *CSavePtr = CSave;\r
+        Cptr      = CSavePtr;\r
+        Len       = SkipWhiteSpace (Cptr);\r
+        //\r
+        // Had to be some white space\r
+        //\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // now look for "equ"\r
+          //\r
+          if (_strnicmp (Cptr, "equ", 3) == 0) {\r
+            Cptr += 3;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            //\r
+            // Now scan all the data\r
+            //\r
+            for (Index = 0; Index < 16; Index++) {\r
+              if (sscanf (Cptr, "%X", &GuidData[Index]) != 1) {\r
+                break;\r
+              }\r
+              //\r
+              // Skip to next\r
+              //\r
+              while (isxdigit (*Cptr)) {\r
+                Cptr++;\r
+              }\r
+\r
+              if ((*Cptr != 'h') && (*Cptr != 'H')) {\r
+                break;\r
+              } else {\r
+                Cptr++;\r
+                while (*Cptr && (isspace (*Cptr) || (*Cptr == ','))) {\r
+                  Cptr++;\r
+                }\r
+              }\r
+            }\r
+            //\r
+            // Now see which form we had\r
+            //\r
+            if (Index == 16) {\r
+              AddGuid16 (FileName, GuidData);\r
+            } else if (Index == 11) {\r
+              AddGuid11 (FileName, GuidData, NULL);\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list\r
+// of guids.\r
+//\r
+static\r
+STATUS\r
+AddGuid16 (\r
+  INT8      *FileName,\r
+  UINT32    *Data\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if (!CheckGuidData (Data, 16)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate memory for a new guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1  = (UINT32) (Data[0] | (Data[1] << 8) | (Data[2] << 16) | (Data[3] << 24));\r
+  NewRec->Guid.Data2  = (UINT16) (Data[4] | (Data[5] << 8));\r
+  NewRec->Guid.Data3  = (UINT16) (Data[6] | (Data[7] << 8));\r
+  for (Index = 0; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) Data[Index + 8];\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Add a GUID defined as GuidLow: 0x1122334455667788\r
+//                       GuidHi:  0x99AABBCCDDEEFF00\r
+//\r
+// These are equivalent:\r
+// { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }\r
+//    and:\r
+// Low: 00FFEEDDCCBBAA99\r
+// Hi:  7788556611223344\r
+//\r
+static\r
+STATUS\r
+AddGuid64x2 (\r
+  INT8      *FileName,\r
+  UINT32    DataHH, // Upper 32-bits of upper 64 bits of guid\r
+  UINT32    DataHL, // Lower 32-bits of upper 64 bits\r
+  UINT32    DataLH,\r
+  UINT32    DataLL,\r
+  INT8      *SymName\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Allocate memory for a new guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1  = DataHL;\r
+  NewRec->Guid.Data2  = (UINT16) DataHH;\r
+  NewRec->Guid.Data3  = (UINT16) (DataHH >> 16);\r
+  for (Index = 0; Index < 4; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) DataLL;\r
+    DataLL >>= 8;\r
+  }\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    NewRec->Guid.Data4[Index + 4] = (UINT8) DataLH;\r
+    DataLH >>= 8;\r
+  }\r
+\r
+  if (SymName != NULL) {\r
+    NewRec->SymName = malloc (strlen (SymName) + 1);\r
+    if (NewRec->SymName == NULL) {\r
+      free (NewRec);\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    strcpy (NewRec->SymName, SymName);\r
+  }\r
+    \r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process INF files. Look for:\r
+// FILE_GUID            = 240612B6-A063-11d4-9A3A-0090273FC14D\r
+//\r
+static\r
+STATUS\r
+ProcessINFFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    *Cptr2;\r
+  UINT32  GuidScan[11];\r
+  UINT64  Guid64;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    if (strncmp (Cptr, "FILE_GUID", 9) == 0) {\r
+      Cptr += 9;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr + 1);\r
+        //\r
+        // Blank out dashes on the line.\r
+        //\r
+        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
+          if (*Cptr2 == '-') {\r
+            *Cptr2 = ' ';\r
+          }\r
+        }\r
+\r
+        if (sscanf (\r
+              Cptr,\r
+              "%X %X %X %X %I64X",\r
+              &GuidScan[0],\r
+              &GuidScan[1],\r
+              &GuidScan[2],\r
+              &GuidScan[3],\r
+              &Guid64\r
+              ) == 5) {\r
+          AddPkgGuid (FileName, GuidScan, &Guid64);\r
+        } else {\r
+          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Parse ('g','m','a','p','a','b','c','d')\r
+//\r
+static\r
+STATUS\r
+AddSignature (\r
+  INT8      *FileName,\r
+  INT8      *StrDef,\r
+  UINT32    SigSize\r
+  )\r
+{\r
+  SIGNATURE_RECORD  *NewRec;\r
+  INT8              *Cptr;\r
+  UINT32            Index;\r
+  BOOLEAN           Fail;\r
+\r
+  //\r
+  // Allocate memory for the new record\r
+  //\r
+  Fail    = FALSE;\r
+  NewRec  = malloc (sizeof (SIGNATURE_RECORD));\r
+  \r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  memset ((char *) NewRec, 0, sizeof (SIGNATURE_RECORD));\r
+  \r
+  //\r
+  // Allocate memory to save the file name\r
+  //\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    free (NewRec);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Fill in the fields\r
+  //\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Signature.DataLen = (UINT8) SigSize;\r
+  //\r
+  // Skip to open parenthesis\r
+  //\r
+  Cptr = StrDef;\r
+  Cptr += SkipWhiteSpace (Cptr);\r
+  if (*Cptr != '(') {\r
+    Fail = TRUE;\r
+    goto Done;\r
+  }\r
+\r
+  Cptr++;\r
+  //\r
+  // Skip to first ' and start processing\r
+  //\r
+  while (*Cptr && (*Cptr != '\'')) {\r
+    Cptr++;\r
+  }\r
+\r
+  for (Index = 0; Index < SigSize; Index++) {\r
+    if (*Cptr == '\'') {\r
+      Cptr++;\r
+      NewRec->Signature.Data[Index] = (INT8) *Cptr;\r
+      //\r
+      // Skip to closing quote\r
+      //\r
+      Cptr++;\r
+      if (*Cptr != '\'') {\r
+        Fail = TRUE;\r
+        break;\r
+      }\r
+      //\r
+      // Skip over closing quote, go to next one\r
+      //\r
+      Cptr++;\r
+      while (*Cptr && (*Cptr != '\'')) {\r
+        Cptr++;\r
+      }\r
+    } else {\r
+      Fail = TRUE;\r
+      DebugMsg (NULL, 0, 0, FileName, "failed to parse signature");\r
+      break;\r
+    }\r
+  }\r
+\r
+Done:\r
+  if (Fail) {\r
+    free (NewRec->FileName);\r
+    free (NewRec);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  NewRec->Next    = gSignatureList;\r
+  gSignatureList  = NewRec;\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Look for:\r
+// #define POOL_HEAD_SIGNATURE         EFI_SIGNATURE_16('p','h')\r
+// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_32('g','m','a','p')\r
+// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')\r
+//\r
+static\r
+STATUS\r
+ProcessCFileSigs (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  UINT32  Len;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // look for #define EFI_SIGNATURE_xx value\r
+    //\r
+    if (*Cptr == '#') {\r
+      Cptr++;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Look for "define"\r
+      //\r
+      if (!strncmp (Cptr, "define", 6)) {\r
+        Cptr += 6;\r
+        //\r
+        // Better be whitespace\r
+        //\r
+        Len = SkipWhiteSpace (Cptr);\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // See if it's a valid symbol name\r
+          //\r
+          Len = ValidSymbolName (Cptr);\r
+          if (Len) {\r
+            //\r
+            // It is a valid symbol name. See if there's line continuation,\r
+            // and if so, read more lines.\r
+            // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"\r
+            //\r
+            ConcatenateLines (Fptr, Line, sizeof(Line));\r
+\r
+            Cptr += Len;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            if (strncmp (Cptr, "EFI_SIGNATURE_16", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 2);\r
+            } else if (strncmp (Cptr, "EFI_SIGNATURE_32", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 4);\r
+            } else if (strncmp (Cptr, "EFI_SIGNATURE_64", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 8);\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// look for #define xxxGUIDyyy { 0x...}\r
+// xxx EFI_GUID  GuidName = { 0x... };\r
+//\r
+static\r
+STATUS\r
+ProcessCFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    *CSavePtr;\r
+  INT8    *TempCptr;\r
+  INT8    *SymName;\r
+  UINT32  Len;\r
+  UINT32  LineLen;\r
+  UINT32  GuidScan[11];\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // look for #define xxxGUIDxxx value\r
+    //\r
+    if (*Cptr == '#') {\r
+      Cptr++;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Look for "define"\r
+      //\r
+      if (!strncmp (Cptr, "define", 6)) {\r
+DefineLine:\r
+        Cptr += 6;\r
+        //\r
+        // Better be whitespace\r
+        //\r
+        Len = SkipWhiteSpace (Cptr);\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // See if it's a valid symbol name\r
+          //\r
+          Len = ValidSymbolName (Cptr);\r
+          if (Len) {\r
+            //\r
+            // It is a valid symbol name. See if there's line continuation,\r
+            // and if so, read more lines.\r
+            // Then truncate after the symbol name, look for the string "GUID",\r
+            // and continue.\r
+            //\r
+            SymName = Cptr;\r
+            ConcatenateLines (Fptr, Line, sizeof(Line));\r
+\r
+            //\r
+            // Now look for { 0x....... }\r
+            //\r
+            CSavePtr  = Cptr + Len;\r
+            Cptr += Len;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            if (*Cptr == '{') {\r
+              Cptr++;\r
+              //\r
+              // Blank out 'L', 'l', '{', '}', ',' on the line.\r
+              //\r
+              for (TempCptr = Cptr; *TempCptr; TempCptr++) {\r
+                if ((*TempCptr == 'L') || (*TempCptr == 'l') || (*TempCptr == '{') || \r
+                    (*TempCptr == '}') || (*TempCptr == ',')) {\r
+                  *TempCptr       = ' ';\r
+                }\r
+              }\r
+\r
+              if (sscanf (\r
+                    Cptr,\r
+                    "%X %X %X %X %X %X %X %X %X %X %X",\r
+                    &GuidScan[0],\r
+                    &GuidScan[1],\r
+                    &GuidScan[2],\r
+                    &GuidScan[3],\r
+                    &GuidScan[4],\r
+                    &GuidScan[5],\r
+                    &GuidScan[6],\r
+                    &GuidScan[7],\r
+                    &GuidScan[8],\r
+                    &GuidScan[9],\r
+                    &GuidScan[10]\r
+                    ) == 11) {\r
+                *CSavePtr = '\0';\r
+                AddGuid11 (FileName, GuidScan, SymName);\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    //\r
+    // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };\r
+    //\r
+    } else if ((CSavePtr = strstr (Line, "EFI_GUID")) != NULL) {\r
+      //\r
+      // Read more lines until met ';'\r
+      //\r
+      ConcatenateLines (Fptr, Line, sizeof(Line));\r
+      while (strstr (Line, ";") == NULL) {\r
+        LineLen = strlen (Line);\r
+        Len = sizeof(Line) - LineLen;\r
+        if (Len <= 1) {\r
+          break;\r
+        }\r
+        if (Line[LineLen - 1] == '\n') {\r
+          Cptr = Line + LineLen - 1;\r
+          *Cptr = '\0';\r
+          if (fgets (Cptr, Len, Fptr) == NULL){\r
+            break;\r
+          }\r
+          ConcatenateLines (Fptr, Line, sizeof(Line));\r
+        } else {\r
+          Cptr = Line + LineLen;\r
+          *Cptr = '\0';\r
+          if (fgets (Cptr, Len, Fptr) == NULL) {\r
+            break;\r
+          }\r
+          ConcatenateLines (Fptr, Line, sizeof(Line));\r
+        }\r
+        \r
+        //\r
+        // EFI_GUID may appear in comments wihout end of ';' which may cause\r
+        // ignoring of new #define, so handle it here.\r
+        //\r
+        Cptr += SkipWhiteSpace (Cptr);\r
+        if (*Cptr == '#') {\r
+          Cptr++;\r
+          Cptr += SkipWhiteSpace (Cptr);\r
+          if (!strncmp (Cptr, "define", 6)) {\r
+            goto DefineLine;\r
+          }\r
+        }\r
+      }\r
+\r
+      Cptr = CSavePtr + 8;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Should be variable name next\r
+      //\r
+      Len     = ValidSymbolName (Cptr);\r
+      SymName = Cptr;\r
+      Cptr += Len;\r
+      CSavePtr = Cptr;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        *CSavePtr = '\0';\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr);\r
+        //\r
+        // Should be open-brace next to define guid\r
+        //\r
+        if (*Cptr == '{') {\r
+          Cptr++;\r
+          //\r
+          // Blank out 'L', 'l', '{', '}', ',' on the line.\r
+          //\r
+          for (TempCptr = Cptr; *TempCptr; TempCptr++) {\r
+            if ((*TempCptr == 'L') || (*TempCptr == 'l') || (*TempCptr == '{') || \r
+                (*TempCptr == '}') || (*TempCptr == ',')) {\r
+              *TempCptr       = ' ';\r
+            }\r
+          }\r
+\r
+          if (sscanf (\r
+                Cptr,\r
+                "%X %X %X %X %X %X %X %X %X %X %X",\r
+                &GuidScan[0],\r
+                &GuidScan[1],\r
+                &GuidScan[2],\r
+                &GuidScan[3],\r
+                &GuidScan[4],\r
+                &GuidScan[5],\r
+                &GuidScan[6],\r
+                &GuidScan[7],\r
+                &GuidScan[8],\r
+                &GuidScan[9],\r
+                &GuidScan[10]\r
+                ) == 11) {\r
+            AddGuid11 (FileName, GuidScan, SymName);\r
+          } \r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process Intel Itanium(TM) GUID definitions. Look for:\r
+// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
+// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
+// in either order.\r
+// This function assumes no blank lines between definitions.\r
+//\r
+static\r
+STATUS\r
+ProcessIA64FileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN];\r
+  UINT32  Guid1H;\r
+  UINT32  Guid1L;\r
+  UINT32  Guid2H;\r
+  UINT32  Guid2L;\r
+  INT8    SymName1[MAX_LINE_LEN];\r
+  INT8    SymName2[MAX_LINE_LEN];\r
+  BOOLEAN Done;\r
+  BOOLEAN LowFirst;\r
+  BOOLEAN FoundLow;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Done = FALSE;\r
+  if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+    Done = 1;\r
+  }\r
+  //\r
+  // Read lines from the file until done. Since the guid definition takes\r
+  // two lines, we read lines in different places to recover gracefully\r
+  // from mismatches. For example, if you thought you found the first half,\r
+  // but the next line had a symbol mismatch, then you have to process the\r
+  // line again in case it's the start of a new definition.\r
+  //\r
+  while (!Done) {\r
+    //\r
+    // Check current line for GUID definition. Assume low define first.\r
+    //\r
+    if (IsIA64GuidLine (Line, &Guid1H, &Guid1L, &FoundLow, SymName1)) {\r
+      //\r
+      // Might have to swap guids later. Save off if we found the LOW first\r
+      //\r
+      if (FoundLow) {\r
+        LowFirst = TRUE;\r
+      } else {\r
+        LowFirst = FALSE;\r
+      }\r
+      //\r
+      // Read the next line and try for the rest of the guid definition\r
+      //\r
+      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+        Done = 1;\r
+      } else {\r
+        if (IsIA64GuidLine (Line, &Guid2H, &Guid2L, &FoundLow, SymName2)) {\r
+          //\r
+          // Found another. If the symbol names match, then save it off.\r
+          //\r
+          if (strcmp (SymName1, SymName2) == 0) {\r
+            //\r
+            // Yea, found one. Save it off.\r
+            //\r
+            if (LowFirst) {\r
+              AddGuid64x2 (FileName, Guid2H, Guid2L, Guid1H, Guid1L, SymName1);\r
+            } else {\r
+              AddGuid64x2 (FileName, Guid1H, Guid1L, Guid2H, Guid2L, SymName1);\r
+            }\r
+            //\r
+            // Read the next line for processing\r
+            //\r
+            if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+              Done = 1;\r
+            }\r
+          } else {\r
+            //\r
+            // Don't get another line so that we reprocess this line in case it\r
+            // contains the start of a new definition.\r
+            // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",\r
+            //    FileName, SymName1, SymName2);\r
+            //\r
+          }\r
+        } else {\r
+          //\r
+          // Second line was not a guid definition. Get the next line from the\r
+          // file.\r
+          //\r
+          if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+            Done = 1;\r
+          }\r
+        }\r
+      }\r
+    } else {\r
+      //\r
+      // Not a guid define line. Next.\r
+      //\r
+      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+        Done = 1;\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Given a line from an Itanium-based assembly file, check the line for a guid\r
+// defininition. One of either:\r
+// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
+// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
+// Return the defined value as two 32-bit values, and whether it's a high\r
+// or low guid.\r
+//\r
+static\r
+BOOLEAN\r
+IsIA64GuidLine (\r
+  INT8      *Line,\r
+  UINT32    *GuidHigh,\r
+  UINT32    *GuidLow,\r
+  BOOLEAN   *FoundLow,\r
+  INT8      *SymName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    CSave;\r
+  INT8    *CSavePtr;\r
+  INT8    *SymStart;\r
+  UINT32  Len;\r
+\r
+  Cptr = Line;\r
+  Cptr += SkipWhiteSpace (Cptr);\r
+  //\r
+  // look for #define xxxGUID[L|H] 0xHexValue\r
+  //\r
+  if (*Cptr == '#') {\r
+    Cptr++;\r
+    Cptr += SkipWhiteSpace (Cptr);\r
+    //\r
+    // Look for "define"\r
+    //\r
+    if (!strncmp (Cptr, "define", 6)) {\r
+      Cptr += 6;\r
+      //\r
+      // Better be whitespace\r
+      //\r
+      Len = SkipWhiteSpace (Cptr);\r
+      if (Len) {\r
+        Cptr += Len;\r
+        //\r
+        // See if it's a valid symbol name\r
+        //\r
+        Len = ValidSymbolName (Cptr);\r
+        if (Len) {\r
+          //\r
+          // Save the start so we can copy it to their string if later checks are ok\r
+          //\r
+          SymStart = Cptr;\r
+          //\r
+          // It is a valid symbol name, look for the string GuidL or GuidH\r
+          //\r
+          CSavePtr  = Cptr + Len;\r
+          CSave     = *CSavePtr;\r
+          *CSavePtr = 0;\r
+          while (*Cptr) {\r
+            if (strncmp (Cptr, "GuidL", 5) == 0) {\r
+              *FoundLow = 1;\r
+              break;\r
+            } else if (strncmp (Cptr, "GuidH", 5) == 0) {\r
+              *FoundLow = 0;\r
+              break;\r
+            }\r
+\r
+            Cptr++;\r
+          }\r
+          //\r
+          // If we didn't run out of string, then we found the GUID string.\r
+          // Restore the null character we inserted above and continue.\r
+          // Now look for  0x.......\r
+          //\r
+          if (*Cptr) {\r
+            //\r
+            // Return symbol name less the "L" or "H"\r
+            //\r
+            strcpy (SymName, SymStart);\r
+            SymName[strlen (SymName) - 1] = 0;\r
+            Cptr                          = CSavePtr;\r
+            *CSavePtr                     = CSave;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            if ((*Cptr == '0') && (*(Cptr + 1) == 'x')) {\r
+              //\r
+              // skip over "0x"\r
+              //\r
+              Cptr += 2;\r
+              //\r
+              // 0x0123456789ABCDEF -- null terminate after 8 characters,\r
+              // scan, replace the character and scan at that point.\r
+              //\r
+              CSave       = *(Cptr + 8);\r
+              *(Cptr + 8) = 0;\r
+              if (sscanf (Cptr, "%X", GuidHigh) == 1) {\r
+                *(Cptr + 8) = CSave;\r
+                if (sscanf (Cptr + 8, "%X", GuidLow) == 1) {\r
+                  return TRUE;\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+//\r
+// Look at the characters in the string and determine if it's a valid\r
+// symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*\r
+//\r
+static\r
+UINT32\r
+ValidSymbolName (\r
+  INT8    *Name\r
+  )\r
+{\r
+  int Len;\r
+\r
+  Len = 0;\r
+\r
+  //\r
+  // Test first character\r
+  //\r
+  if (((*Name >= 'a') && (*Name <= 'z')) || ((*Name >= 'A') && (*Name <= 'Z')) || (*Name == '_')) {\r
+    Name++;\r
+    Len = 1;\r
+    while (*Name) {\r
+      if (((*Name >= 'a') && (*Name <= 'z')) ||\r
+          ((*Name >= 'A') && (*Name <= 'Z')) ||\r
+          ((*Name >= '0') && (*Name <= '9')) ||\r
+          (*Name == '_')\r
+          ) {\r
+        Name++;\r
+        Len++;\r
+      } else {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  INT8    *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  Len = 0;\r
+  while (isspace (*Str) && *Str) {\r
+    Len++;\r
+    Str++;\r
+  }\r
+\r
+  return Len;\r
+}\r
+//\r
+// found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
+//\r
+static\r
+STATUS\r
+AddPkgGuid (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  UINT64    *Data64\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if ((Data[1] | Data[2] | Data[3]) & 0xFFFF0000) {\r
+    Error (NULL, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // More checks for Data64?\r
+  // Allocate memory for a new one guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1    = Data[0];\r
+  NewRec->Guid.Data2    = (UINT16) Data[1];\r
+  NewRec->Guid.Data3    = (UINT16) Data[2];\r
+  NewRec->Guid.Data4[0] = (UINT8) (Data[3] >> 8);\r
+  NewRec->Guid.Data4[1] = (UINT8) Data[3];\r
+  for (Index = 2; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = ((UINT8*)Data64)[7-Index];\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Add a guid consisting of 11 fields to our list of guids\r
+//\r
+static\r
+STATUS\r
+AddGuid11 (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  INT8      *SymName\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if (!CheckGuidData (Data, 11)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate memory for a new one guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  if (SymName != NULL) {\r
+    NewRec->SymName = malloc (strlen (SymName) + 1);\r
+    if (NewRec->SymName == NULL) {\r
+      free (NewRec);\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    strcpy (NewRec->SymName, SymName);\r
+  }\r
+\r
+  NewRec->Guid.Data1  = Data[0];\r
+  NewRec->Guid.Data2  = (UINT16) Data[1];\r
+  NewRec->Guid.Data3  = (UINT16) Data[2];\r
+  for (Index = 0; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) Data[3 + Index];\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// For debug purposes, print each guid found\r
+//\r
+// static\r
+// VOID\r
+// ReportGuid (\r
+//  INT8        *FileName,\r
+// GUID_RECORD *NewGuid\r
+//  )\r
+// {\r
+//  //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);\r
+// }\r
+//\r
+// Free up memory we allocated to keep track of guids defined.\r
+//\r
+static\r
+VOID\r
+FreeGuids (\r
+  VOID\r
+  )\r
+{\r
+  GUID_RECORD *NextRec;\r
+  while (gGuidList != NULL) {\r
+    NextRec = gGuidList->Next;\r
+    if (gGuidList->FileName != NULL) {\r
+      free (gGuidList->FileName);\r
+    }\r
+\r
+    if (gGuidList->SymName != NULL) {\r
+      free (gGuidList->SymName);\r
+    }\r
+\r
+    free (gGuidList);\r
+    gGuidList = NextRec;\r
+  }\r
+}\r
+\r
+static\r
+VOID\r
+FreeSigs (\r
+  VOID\r
+  )\r
+{\r
+  SIGNATURE_RECORD  *NextRec;\r
+  while (gSignatureList != NULL) {\r
+    NextRec = gSignatureList->Next;\r
+    if (gSignatureList->FileName != NULL) {\r
+      free (gSignatureList->FileName);\r
+    }\r
+\r
+    free (gSignatureList);\r
+    gSignatureList = NextRec;\r
+  }\r
+}\r
+//\r
+// Scan through all guids defined and compare each for duplicates.\r
+//\r
+static\r
+STATUS\r
+CheckDuplicates (\r
+  VOID\r
+  )\r
+{\r
+  GUID_RECORD       *CurrentFile;\r
+\r
+  GUID_RECORD       *TempFile;\r
+  SIGNATURE_RECORD  *CurrentSig;\r
+  SIGNATURE_RECORD  *TempSig;\r
+  STATUS            Status;\r
+  int               Index;\r
+  int               DupCount;\r
+  int               Len;\r
+  BOOLEAN           Same;\r
+  UINT32            GuidSum;\r
+  INT8              *SymName;\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  //\r
+  // If we're checking guids.....\r
+  //\r
+  if (gOptions.CheckGuids) {\r
+    //\r
+    // If -p option, print all guids found\r
+    //\r
+    if (gOptions.PrintFound) {\r
+      CurrentFile = gGuidList;\r
+      while (CurrentFile != NULL) {\r
+        fprintf (\r
+          stdout,\r
+          "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",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7],\r
+          CurrentFile->FileName\r
+          );\r
+        CurrentFile = CurrentFile->Next;\r
+      }\r
+    }\r
+\r
+    if (gOptions.GuidXReference) {\r
+      CurrentFile = gGuidList;\r
+      while (CurrentFile != NULL) {\r
+        //\r
+        // If no symbol name, print FileName\r
+        //\r
+        SymName = CurrentFile->SymName;\r
+        if (SymName == NULL) {\r
+          //\r
+          // Assume file name will not be NULL and strlen > 0\r
+          //\r
+          SymName = CurrentFile->FileName + strlen (CurrentFile->FileName) - 1;\r
+          while ((*SymName != '\\') && (SymName > CurrentFile->FileName)) SymName --;\r
+          if (*SymName == '\\') SymName ++;\r
+        }\r
+\r
+        fprintf (\r
+          stdout,\r
+          "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7],\r
+          SymName\r
+          );\r
+        CurrentFile = CurrentFile->Next;\r
+      }\r
+    }\r
+    //\r
+    // Now go through all guids and report duplicates.\r
+    //\r
+    CurrentFile = gGuidList;\r
+    while (CurrentFile != NULL) {\r
+      DupCount  = 0;\r
+      TempFile  = CurrentFile->Next;\r
+      while (TempFile) {\r
+        //\r
+        // Compare the guids\r
+        //\r
+        if ((CurrentFile->Guid.Data1 == TempFile->Guid.Data1) &&\r
+            (CurrentFile->Guid.Data2 == TempFile->Guid.Data2) &&\r
+            (CurrentFile->Guid.Data3 == TempFile->Guid.Data3)\r
+            ) {\r
+          //\r
+          // OR in all the guid bytes so we can ignore NULL-guid definitions.\r
+          //\r
+          GuidSum = CurrentFile->Guid.Data1 | CurrentFile->Guid.Data2 | CurrentFile->Guid.Data3;\r
+          Same    = TRUE;\r
+          for (Index = 0; Index < 8; Index++) {\r
+            GuidSum |= CurrentFile->Guid.Data4[Index];\r
+            if (CurrentFile->Guid.Data4[Index] != TempFile->Guid.Data4[Index]) {\r
+              Same = FALSE;\r
+              break;\r
+            }\r
+          }\r
+          //\r
+          // If they're the same, and the guid was non-zero, print a message.\r
+          //\r
+          if (Same && GuidSum) {\r
+            if (DupCount == 0) {\r
+              Error (NULL, 0, 0, "duplicate GUIDS found", NULL);\r
+              fprintf (stdout, "   FILE1: %s\n", CurrentFile->FileName);\r
+            }\r
+\r
+            DupCount++;\r
+            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempFile->FileName);\r
+            //\r
+            // Flag it as reported so we don't report it again if there's three or more\r
+            //\r
+            TempFile->Reported = TRUE;\r
+          }\r
+        }\r
+        //\r
+        // Next one\r
+        //\r
+        TempFile = TempFile->Next;\r
+      }\r
+      //\r
+      // Print the guid if we found duplicates\r
+      //\r
+      if (DupCount) {\r
+        fprintf (\r
+          stdout,\r
+          "   GUID:  0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7]\r
+          );\r
+        //\r
+        // return STATUS_ERROR;\r
+        //\r
+      }\r
+      //\r
+      // Find the next one that hasn't been reported\r
+      //\r
+      do {\r
+        CurrentFile = CurrentFile->Next;\r
+      } while ((CurrentFile != NULL) && (CurrentFile->Reported));\r
+    }\r
+  }\r
+\r
+  if (gOptions.CheckSignatures) {\r
+    //\r
+    // Print ones found if specified\r
+    //\r
+    if (gOptions.PrintFound) {\r
+      CurrentSig = gSignatureList;\r
+      while (CurrentSig != NULL) {\r
+        Len = CurrentSig->Signature.DataLen;\r
+        for (Index = 0; Index < Len; Index++) {\r
+          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
+        }\r
+\r
+        fprintf (stdout, "  %s\n", CurrentSig->FileName);\r
+        CurrentSig = CurrentSig->Next;\r
+      }\r
+    }\r
+\r
+    CurrentSig = gSignatureList;\r
+    while (CurrentSig != NULL) {\r
+      DupCount  = 0;\r
+      TempSig   = CurrentSig->Next;\r
+      Len       = CurrentSig->Signature.DataLen;\r
+      while (TempSig) {\r
+        //\r
+        // Check for same length, then do string compare\r
+        //\r
+        if (Len == TempSig->Signature.DataLen) {\r
+          if (strncmp (CurrentSig->Signature.Data, TempSig->Signature.Data, Len) == 0) {\r
+            //\r
+            // Print header message if first failure for this sig\r
+            //\r
+            if (DupCount == 0) {\r
+              Error (NULL, 0, 0, "duplicate signatures found", NULL);\r
+              fprintf (stdout, "   FILE1: %s\n", CurrentSig->FileName);\r
+            }\r
+\r
+            DupCount++;\r
+            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempSig->FileName);\r
+            TempSig->Reported = TRUE;\r
+          }\r
+        }\r
+\r
+        TempSig = TempSig->Next;\r
+      }\r
+\r
+      if (DupCount) {\r
+        fprintf (stdout, "   SIG:   ");\r
+        for (Index = 0; Index < Len; Index++) {\r
+          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
+        }\r
+\r
+        fprintf (stdout, "\n");\r
+      }\r
+      //\r
+      // On to the next one that hasn't been reported\r
+      //\r
+      do {\r
+        CurrentSig = CurrentSig->Next;\r
+      } while ((CurrentSig != NULL) && (CurrentSig->Reported));\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+VOID\r
+FreeOptions (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Free up any memory we allocated when processing command-line options.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  NA\r
+\r
+Notes:\r
+  We don't free up the ->Str fields because we did not allocate them.\r
+  Instead, we just set the pointer to point to the actual parameter\r
+  from the command line.\r
+\r
+--*/\r
+{\r
+  STRING_LIST *Ptr;\r
+  while (gOptions.ExcludeDirs != NULL) {\r
+    Ptr = gOptions.ExcludeDirs->Next;\r
+    //\r
+    // free (gOptions.ExcludeDirs->Str);\r
+    //\r
+    free (gOptions.ExcludeDirs);\r
+    gOptions.ExcludeDirs = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeSubDirs != NULL) {\r
+    Ptr = gOptions.ExcludeSubDirs->Next;\r
+    //\r
+    // free (gOptions.ExcludeSubDirs->Str);\r
+    //\r
+    free (gOptions.ExcludeSubDirs);\r
+    gOptions.ExcludeSubDirs = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeExtensions != NULL) {\r
+    Ptr = gOptions.ExcludeExtensions->Next;\r
+    //\r
+    // free (gOptions.ExcludeExtensions->Str);\r
+    //\r
+    free (gOptions.ExcludeExtensions);\r
+    gOptions.ExcludeExtensions = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeFiles != NULL) {\r
+    Ptr = gOptions.ExcludeFiles->Next;\r
+    //\r
+    // free (gOptions.ExcludeFiles->Str);\r
+    //\r
+    free (gOptions.ExcludeFiles);\r
+    gOptions.ExcludeFiles = Ptr;\r
+  }\r
+}\r
+//\r
+// Given an array of 32-bit data, validate the data for the given number of\r
+// guid data. For example, it might have been scanned as 16 bytes of data, or\r
+// 11 fields of data.\r
+//\r
+static\r
+BOOLEAN\r
+CheckGuidData (\r
+  UINT32    *Data,\r
+  UINT32    DataCount\r
+  )\r
+{\r
+  UINT32  Index;\r
+\r
+  if (DataCount == 16) {\r
+    for (Index = 0; Index < 16; Index++) {\r
+      if (Data[Index] &~0xFF) {\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    return TRUE;\r
+  } else if (DataCount == 11) {\r
+    //\r
+    // Data[0] never out of range (32-bit)\r
+    //\r
+    if ((Data[1] | Data[2]) &~0xFFFF) {\r
+      //\r
+      // Error ("Out of range value for GUID data word(s) [1] and/or [2]");\r
+      //\r
+      return FALSE;\r
+    }\r
+\r
+    for (Index = 0; Index < 8; Index++) {\r
+      if (Data[Index + 3] &~0xFF) {\r
+        //\r
+        // Error ("Out of range value for GUID data byte(s) [4] - [11]");\r
+        //\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+VOID\r
+ConcatenateLines (\r
+  FILE        *Fptr, \r
+  INT8        *Line,\r
+  UINT32      Len\r
+  )\r
+{\r
+  UINT32      LineLen;\r
+  BOOLEAN     NeedCheck;\r
+  \r
+  NeedCheck = TRUE;\r
+  while (NeedCheck) {\r
+    LineLen = strlen (Line);\r
+    if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
+      Line[LineLen - 2] = '\0';\r
+      fgets (Line + LineLen - 2, Len - LineLen, Fptr);\r
+    } else if (Line[LineLen - 1] == '\\') {\r
+      Line[LineLen - 1] = '\0';\r
+      fgets (Line + LineLen - 1, Len - LineLen, Fptr);\r
+    } else {\r
+      NeedCheck = FALSE;\r
+    }\r
+  }\r
+}
\ 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 (file)
index 0000000..83ca51d
--- /dev/null
@@ -0,0 +1,188 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidList.c  \r
+\r
+Abstract:\r
+\r
+  Utility to create a GUID-to-name listing file that can\r
+  be used by other utilities. Basic operation is to take the\r
+  table of name+GUIDs that we have compiled into this utility,\r
+  and create a text file that can be parsed by other utilities\r
+  to do replacement of "name" with "GUID".\r
+\r
+Notes:\r
+  To add a new GUID to this database:\r
+    1. Add a "#include EFI_GUID_DEFINITION(name)" statement below\r
+    2. Modify the mGuidList[] array below to add the new GUID name\r
+\r
+  The only issue that may come up is that, if the source GUID file\r
+  is not in the standard GUID directory, then this utility won't\r
+  compile because the #include fails. In this case you'd need\r
+  to define a new macro (if it's in a standard place) or modify\r
+  this utility's makefile to add the path to your new .h file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#include EFI_GUID_DEFINITION (Apriori)\r
+#include EFI_GUID_DEFINITION (AcpiTableStorage)\r
+#include EFI_GUID_DEFINITION (Bmp)\r
+#include EFI_GUID_DEFINITION (AcpiTableStorage)\r
+#include EFI_GUID_DEFINITION (PeiApriori)\r
+\r
+\r
+#define GUID_XREF(varname, guid) { \\r
+    #varname, #guid, guid \\r
+  }\r
+\r
+#define NULL_GUID \\r
+  { \\r
+    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \\r
+  }\r
+\r
+typedef struct {\r
+  INT8      *VariableName;\r
+  INT8      *DefineName;\r
+  EFI_GUID  Guid;\r
+} GUID_LIST;\r
+\r
+//\r
+// This is our table of all GUIDs we want to print out to create\r
+// a GUID-to-name cross reference.\r
+// Use the #defined name from the GUID definition's source .h file.\r
+//\r
+static GUID_LIST  mGuidList[] = {\r
+  GUID_XREF(gEfiPeiAprioriGuid, EFI_PEI_APRIORI_FILE_NAME_GUID),\r
+  GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID),\r
+  GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID),\r
+  GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r
+  //\r
+  // Terminator\r
+  //\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL_GUID\r
+  }\r
+};\r
+\r
+void\r
+PrintGuidText (\r
+  FILE      *OutFptr,\r
+  INT8      *VariableName,\r
+  INT8      *DefineName,\r
+  EFI_GUID  *Guid\r
+  );\r
+\r
+int\r
+CreateGuidList (\r
+  INT8    *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print our GUID/name list to the specified output file.\r
+  \r
+Arguments:\r
+  OutFileName  - name of the output file to write our results to.\r
+\r
+Returns:\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  FILE  *OutFptr;\r
+  int   Index;\r
+\r
+  //\r
+  // Open output file for writing. If the name is NULL, then write to stdout\r
+  //\r
+  if (OutFileName != NULL) {\r
+    OutFptr = fopen (OutFileName, "w");\r
+    if (OutFptr == NULL) {\r
+      Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+      return STATUS_ERROR;\r
+    }\r
+  } else {\r
+    OutFptr = stdout;\r
+  }\r
+\r
+  for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) {\r
+    PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid);\r
+  }\r
+  //\r
+  // Close the output file if they specified one.\r
+  //\r
+  if (OutFileName != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+void\r
+PrintGuidText (\r
+  FILE      *OutFptr,\r
+  INT8      *VariableName,\r
+  INT8      *DefineName,\r
+  EFI_GUID  *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a GUID/name combo in INF-style format\r
+\r
+  guid-guid-guid-guid DEFINE_NAME gName\r
+\r
+Arguments:\r
+  OutFptr       - file pointer to which to write the output\r
+  VariableName  - the GUID variable's name\r
+  DefineName    - the name used in the #define\r
+  Guid          - pointer to the GUID value\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  if (OutFptr == NULL) {\r
+    OutFptr = stdout;\r
+  }\r
+\r
+  fprintf (\r
+    OutFptr,\r
+    "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n",\r
+    Guid->Data1,\r
+    Guid->Data2,\r
+    Guid->Data3,\r
+    Guid->Data4[0],\r
+    Guid->Data4[1],\r
+    Guid->Data4[2],\r
+    Guid->Data4[3],\r
+    Guid->Data4[4],\r
+    Guid->Data4[5],\r
+    Guid->Data4[6],\r
+    Guid->Data4[7],\r
+    DefineName,\r
+    VariableName\r
+    );\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile
new file mode 100644 (file)
index 0000000..5aeddd8
--- /dev/null
@@ -0,0 +1,96 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the GUID check utility.\r
+#    \r
+#--*/\r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = GuidChk\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\GuidChk.exe\r
+\r
+#LIBS                = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+#\r
+# Build targets\r
+#\r
+all: $(TARGET_EXE)\r
+\r
+INC_DEPS  = $(TARGET_SRC_DIR)\FileSearch.h    $(INC_DEPS)\r
+#INC_DEPS  = $(TARGET_SRC_DIR)\CommonUtils.h   $(INC_DEPS)\r
+#INC_DEPS  = $(TARGET_SRC_DIR)\UtilsMsgs.h     $(INC_DEPS)\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\GuidChk.obj  \\r
+            $(EDK_TOOLS_OUTPUT)\FileSearch.obj \\r
+            $(EDK_TOOLS_OUTPUT)\GuidList.obj \\r
+            $(EDK_TOOLS_OUTPUT)\UtilsMsgs.obj\r
+#\r
+# Compile each source file\r
+#\r
+$(EDK_TOOLS_OUTPUT)\GuidChk.obj : $(TARGET_SRC_DIR)\GuidChk.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\GuidChk.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\FileSearch.obj : $(TARGET_SRC_DIR)\FileSearch.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FileSearch.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\GuidList.obj : $(TARGET_SRC_DIR)\GuidList.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\GuidList.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\UtilsMsgs.obj : $(TARGET_SRC_DIR)\UtilsMsgs.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\UtilsMsgs.c /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\FileSearch.* del $(EDK_TOOLS_OUTPUT)\FileSearch.* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c
new file mode 100644 (file)
index 0000000..2abe621
--- /dev/null
@@ -0,0 +1,489 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  UtilsMsgs.c\r
+  \r
+Abstract:\r
+\r
+  EFI tools utility functions to display warning, error, and informational\r
+  messages.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  200\r
+\r
+//\r
+// Declare module globals for keeping track of the the utility's\r
+// name and other settings.\r
+//\r
+static STATUS mStatus             = STATUS_SUCCESS;\r
+static INT8   mUtilityName[50]    = { 0 };\r
+static INT8   *mSourceFileName    = NULL;\r
+static UINT32 mSourceFileLineNum  = 0;\r
+static UINT32 mErrorCount         = 0;\r
+static UINT32 mWarningCount       = 0;\r
+static UINT32 mDebugMsgMask       = 0;\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  );\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Prints an error message.\r
+  \r
+Arguments:\r
+  All arguments are optional, though the printed message may be useless if\r
+  at least something valid is not specified.\r
+  \r
+  FileName - name of the file or application. If not specified, then the\r
+             utilty name (as set by the utility calling SetUtilityName()\r
+             earlier) is used. Otherwise "Unknown utility" is used.\r
+  \r
+  LineNumber - the line number of error, typically used by parsers. If the\r
+               utility is not a parser, then 0 should be specified. Otherwise\r
+               the FileName and LineNumber info can be used to cause\r
+               MS Visual Studio to jump to the error.\r
+               \r
+  MessageCode - an application-specific error code that can be referenced in\r
+              other documentation. \r
+\r
+  Text        - the text in question, typically used by parsers.\r
+  \r
+  MsgFmt - the format string for the error message. Can contain formatting\r
+           controls for use with the varargs.\r
+           \r
+Returns:\r
+  None.\r
+  \r
+Notes:\r
+  We print the following (similar to the Warn() and Debug() \r
+  W\r
+  Typical error/warning message format:\r
+\r
+  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
+\r
+  BUGBUG -- these three utility functions are almost identical, and\r
+  should be modified to share code.\r
+\r
+  Visual Studio does not find error messages with:\r
+  \r
+     " error :"\r
+     " error 1:"\r
+     " error c1:"\r
+     " error 1000:"\r
+     " error c100:"\r
+\r
+  It does find:\r
+     " error c1000:"     \r
+--*/\r
+{\r
+  va_list List;\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserError (\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser error, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  MessageCode   - application-specific error code\r
+  Text          - text to print in the error message\r
+  MsgFmt        - format string to print at the end of the error message\r
+  ...\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser warning, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  ErrorCode     - application-specific error code\r
+  OffendingText - text to print in the warning message\r
+  MsgFmt        - format string to print at the end of the warning message\r
+  ...\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the warning message. Can contain formatting\r
+                controls for use with varargs.\r
+                \r
+  ...\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgMask,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - typically the name of the utility printing the debug message, but\r
+                can be the name of a file being parsed.\r
+  \r
+  LineNumber  - the line number in FileName (parsers) \r
+               \r
+  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
+                determines if the debug message gets printed.\r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the debug message. Can contain formatting\r
+                controls for use with varargs.\r
+          \r
+  ... \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If the debug mask is not applicable, then do nothing.\r
+  //\r
+  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
+    return ;\r
+  }\r
+\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
+  va_end (List);\r
+}\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Worker routine for all the utility printing services. Prints the message in\r
+  a format that Visual Studio will find when scanning build outputs for\r
+  errors or warnings.\r
+\r
+Arguments:\r
+  Type        - "warning" or "error" string to insert into the message to be\r
+                printed. The first character of this string (converted to uppercase)\r
+                is used to preceed the MessageCode value in the output string.\r
+\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - part of the message to print\r
+  \r
+  MsgFmt      - the format string for the message. Can contain formatting\r
+                controls for use with varargs.\r
+\r
+  List        - Variable function parameter list.           \r
+Returns:\r
+  None.\r
+\r
+Notes:\r
+  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
+  \r
+  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
+  file being parsed.\r
+\r
+  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
+  them both NULL.\r
+\r
+  Output will typically be of the form:\r
+    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
+\r
+    Parser (LineNumber != 0)\r
+      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
+    Generic utility (LineNumber == 0) \r
+      UtilityName : error E1234 : Text string : MsgFmt string and args\r
+\r
+--*/\r
+{\r
+  INT8  Line[MAX_LINE_LEN];\r
+  INT8  Line2[MAX_LINE_LEN];\r
+  INT8  *Cptr;\r
+  //\r
+  // If given a filename, then add it (and the line number) to the string.\r
+  // If there's no filename, then use the program name if provided.\r
+  //\r
+  if (FileName != NULL) {\r
+    Cptr = FileName;\r
+  } else if (mUtilityName[0] != 0) {\r
+    Cptr = mUtilityName;\r
+  } else {\r
+    Cptr = "Unknown utility";\r
+  }\r
+\r
+  strcpy (Line, Cptr);\r
+  if (LineNumber != 0) {\r
+    sprintf (Line2, "(%d)", LineNumber);\r
+    strcat (Line, Line2);\r
+  }\r
+  //\r
+  // Have to print an error code or Visual Studio won't find the\r
+  // message for you. It has to be decimal digits too.\r
+  //\r
+  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
+  strcat (Line, Line2);\r
+  fprintf (stdout, "%s", Line);\r
+  //\r
+  // If offending text was provided, then print it\r
+  //\r
+  if (Text != NULL) {\r
+    fprintf (stdout, ": %s ", Text);\r
+  }\r
+  //\r
+  // Print formatted message if provided\r
+  //\r
+  if (MsgFmt != NULL) {\r
+    vsprintf (Line2, MsgFmt, List);\r
+    fprintf (stdout, ": %s", Line2);\r
+  }\r
+\r
+  fprintf (stdout, "\n");\r
+}\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the position in a file being parsed. This can be used to \r
+  print error messages deeper down in a parser.\r
+\r
+Arguments:\r
+  SourceFileName - name of the source file being parsed\r
+  LineNum        - line number of the source file being parsed\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mSourceFileName     = SourceFileName;\r
+  mSourceFileLineNum  = LineNum;\r
+}\r
+\r
+void\r
+SetUtilityName (\r
+  INT8    *UtilityName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  All printed error/warning/debug messages follow the same format, and\r
+  typically will print a filename or utility name followed by the error\r
+  text. However if a filename is not passed to the print routines, then\r
+  they'll print the utility name if you call this function early in your\r
+  app to set the utility name.\r
+  \r
+Arguments:\r
+  UtilityName  -  name of the utility, which will be printed with all\r
+                  error/warning/debug messags.\r
+\r
+Returns:\r
+  NA\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Save the name of the utility in our local variable. Make sure its\r
+  // length does not exceed our buffer.\r
+  //\r
+  if (UtilityName != NULL) {\r
+    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
+      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
+      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
+      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
+      return ;\r
+    } else {\r
+      strcpy (mUtilityName, UtilityName);\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
+  }\r
+}\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  When you call Error() or Warning(), this module keeps track of it and\r
+  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
+  exits, it can call this function to get the status and use it as a return\r
+  value.\r
+  \r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Worst-case status reported, as defined by which print function was called.\r
+  \r
+--*/\r
+{\r
+  return mStatus;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h
new file mode 100644 (file)
index 0000000..5f6c701
--- /dev/null
@@ -0,0 +1,106 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  UtilsMsgs.h\r
+  \r
+Abstract:\r
+\r
+  Prototypes for the EFI tools utility functions.\r
+  \r
+--*/\r
+\r
+#ifndef _UTILS_MESSAGES_H_\r
+#define _UTILS_MESSAGES_H_\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+;\r
+\r
+//\r
+// If someone prints an error message and didn't specify a source file name,\r
+// then we print the utility name instead. However they must tell us the\r
+// utility name early on via this function.\r
+//\r
+VOID\r
+SetUtilityName (\r
+  INT8 *ProgramName\r
+  )\r
+;\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgLevel,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32    MsgMask\r
+  )\r
+;\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+;\r
+\r
+void\r
+ParserError (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
new file mode 100644 (file)
index 0000000..bf086e6
--- /dev/null
@@ -0,0 +1,1316 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MakeDeps.c  \r
+\r
+Abstract:\r
+\r
+  Recursively scan source files to find include files and emit them to \r
+  create dependency lists.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+//\r
+// Structure to maintain a linked list of strings\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  char                *Str;\r
+} STRING_LIST;\r
+\r
+#define UTILITY_NAME      "MakeDeps"\r
+\r
+#define MAX_LINE_LEN      2048\r
+#define MAX_PATH          2048\r
+#define START_NEST_DEPTH  1\r
+#define MAX_NEST_DEPTH    1000  // just in case we get in an endless loop.\r
+//\r
+// Define the relative paths used by the special #include macros\r
+//\r
+#define PROTOCOL_DIR_PATH       "Protocol\\"\r
+#define GUID_DIR_PATH           "Guid\\"\r
+#define ARCH_PROTOCOL_DIR_PATH  "ArchProtocol\\"\r
+#define PPI_PROTOCOL_DIR_PATH   "Ppi\\"\r
+\r
+//\r
+// Use this structure to keep track of all the special #include forms\r
+//\r
+typedef struct {\r
+  INT8  *IncludeMacroName;\r
+  INT8  *PathName;\r
+} INCLUDE_MACRO_CONVERSION;\r
+\r
+//\r
+// This data is used to convert #include macros like:\r
+//    #include EFI_PROTOCOL_DEFINITION(xxx)\r
+// into\r
+//    #include Protocol/xxx/xxx.h\r
+//\r
+static const INCLUDE_MACRO_CONVERSION mMacroConversion[] = {\r
+  "EFI_PROTOCOL_DEFINITION",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_GUID_DEFINITION",\r
+  GUID_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_DEFINITION",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_PRODUCER",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_CONSUMER",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_DEPENDENCY",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_PRODUCER",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_CONSUMER",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_DEPENDENCY",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_DEFINITION",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_PRODUCER",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_CONSUMER",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_DEPENDENCY",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+typedef struct _SYMBOL {\r
+  struct _SYMBOL  *Next;\r
+  INT8            *Name;\r
+  INT8            *Value;\r
+} SYMBOL;\r
+\r
+//\r
+// Here's all our globals. We need a linked list of include paths, a linked\r
+// list of source files, a linked list of subdirectories (appended to each\r
+// include path when searching), and flags to keep track of command-line options.\r
+//\r
+static struct {\r
+  STRING_LIST *IncludePaths;            // all include paths to search\r
+  STRING_LIST *SourceFiles;             // all source files to parse\r
+  STRING_LIST *SubDirs;                 // appended to each include path when searching\r
+  SYMBOL      *SymbolTable;             // for replacement strings\r
+  FILE        *OutFptr;                 // output dependencies to this file\r
+  BOOLEAN     Verbose;                  // for more detailed output\r
+  BOOLEAN     IgnoreNotFound;           // no warnings if files not found\r
+  BOOLEAN     QuietMode;                // -q - don't print missing file warnings\r
+  BOOLEAN     NoSystem;                 // don't process #include <system> files\r
+  BOOLEAN     NeverFail;                // always return success\r
+  BOOLEAN     NoDupes;                  // to not list duplicate dependency files (for timing purposes)\r
+  BOOLEAN     UseSumDeps;               // use summary dependency files if found\r
+  BOOLEAN     IsAsm;                    // The SourceFiles are assembler files\r
+  INT8        TargetFileName[MAX_PATH]; // target object filename\r
+  INT8        SumDepsPath[MAX_PATH];    // path to summary files\r
+  INT8        *OutFileName;             // -o option\r
+} mGlobals;\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8            *TargetFileName,\r
+  INT8            *FileName,\r
+  UINT32          NestDepth,\r
+  STRING_LIST     *ProcessedFiles\r
+  );\r
+\r
+static\r
+FILE  *\r
+FindFile (\r
+  INT8    *FileName,\r
+  UINT32  FileNameLen\r
+  );\r
+\r
+static\r
+void\r
+PrintDependency (\r
+  INT8    *Target,\r
+  INT8    *DependentFile\r
+  );\r
+\r
+static\r
+void\r
+ReplaceSymbols (\r
+  INT8    *Str,\r
+  UINT32  StrSize\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process each file\r
+  to build dependencies.\r
+  \r
+Arguments:\r
+\r
+  Argc - Standard C main() argc.\r
+  Argv - Standard C main() argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  STRING_LIST *File;\r
+  STRING_LIST ProcessedFiles;\r
+  STRING_LIST *TempList;\r
+  STATUS      Status;\r
+  INT8        *Cptr;\r
+  INT8        TargetFileName[MAX_PATH];\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Go through the list of source files and process each.\r
+  //\r
+  memset (&ProcessedFiles, 0, sizeof (STRING_LIST));\r
+  File = mGlobals.SourceFiles;\r
+  while (File != NULL) {\r
+    //\r
+    // Clear out our list of processed files\r
+    //\r
+    TempList = ProcessedFiles.Next;\r
+    while (ProcessedFiles.Next != NULL) {\r
+      TempList = ProcessedFiles.Next->Next;\r
+      free (ProcessedFiles.Next->Str);\r
+      free (ProcessedFiles.Next);\r
+      ProcessedFiles.Next = TempList;\r
+    }\r
+    //\r
+    // Replace filename extension with ".obj" if they did not\r
+    // specifically specify the target file\r
+    //\r
+    if (mGlobals.TargetFileName[0] == 0) {\r
+      strcpy (TargetFileName, File->Str);\r
+      //\r
+      // Find the .extension\r
+      //\r
+      for (Cptr = TargetFileName + strlen (TargetFileName) - 1;\r
+           (*Cptr != '\\') && (Cptr > TargetFileName) && (*Cptr != '.');\r
+           Cptr--\r
+          )\r
+        ;\r
+      if (Cptr == TargetFileName) {\r
+        Error (NULL, 0, 0, File->Str, "could not locate extension in filename");\r
+        goto Finish;\r
+      }\r
+      //\r
+      // Tack on the ".obj"\r
+      //\r
+      strcpy (Cptr, ".obj");\r
+    } else {\r
+      //\r
+      // Copy the target filename they specified\r
+      //\r
+      strcpy (TargetFileName, mGlobals.TargetFileName);\r
+    }\r
+\r
+    Status = ProcessFile (TargetFileName, File->Str, START_NEST_DEPTH, &ProcessedFiles);\r
+    if (Status != STATUS_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+\r
+    File = File->Next;\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Free up memory\r
+  //\r
+  FreeLists ();\r
+  //\r
+  // Free up our processed files list\r
+  //\r
+  TempList = ProcessedFiles.Next;\r
+  while (ProcessedFiles.Next != NULL) {\r
+    TempList = ProcessedFiles.Next->Next;\r
+    free (ProcessedFiles.Next->Str);\r
+    free (ProcessedFiles.Next);\r
+    ProcessedFiles.Next = TempList;\r
+  }\r
+  //\r
+  // Close our output file\r
+  //\r
+  if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) {\r
+    fclose (mGlobals.OutFptr);\r
+  }\r
+\r
+  if (mGlobals.NeverFail) {\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // If any errors, then delete our output so that it will get created\r
+  // again on a rebuild.\r
+  //\r
+  if ((GetUtilityStatus () == STATUS_ERROR) && (mGlobals.OutFileName != NULL)) {\r
+    remove (mGlobals.OutFileName);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8            *TargetFileName,\r
+  INT8            *FileName,\r
+  UINT32          NestDepth,\r
+  STRING_LIST     *ProcessedFiles\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file name, open the file and parse all #include lines.\r
+  \r
+Arguments:\r
+\r
+  TargetFileName - name of the usually .obj target\r
+  FileName       - name of the file to process\r
+  NestDepth      - how deep we're nested in includes\r
+  ProcessedFiles - list of processed files.\r
+\r
+Returns:\r
+\r
+  standard status.\r
+  \r
+--*/\r
+{\r
+  FILE        *Fptr;\r
+  INT8        Line[MAX_LINE_LEN];\r
+  INT8        *Cptr;\r
+  INT8        *EndPtr;\r
+  INT8        *SaveCptr;\r
+  INT8        EndChar;\r
+  INT8        FileNameCopy[MAX_PATH];\r
+  INT8        MacroIncludeFileName[MAX_LINE_LEN];\r
+  INT8        SumDepsFile[MAX_PATH];\r
+  STATUS      Status;\r
+  UINT32      Index;\r
+  UINT32      LineNum;\r
+  STRING_LIST *ListPtr;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  Fptr    = NULL;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', FileName);\r
+  }\r
+  //\r
+  // If we're using summary dependency files, and a matching .dep file is\r
+  // found for this file, then just emit the summary dependency file as\r
+  // a dependency and return.\r
+  //\r
+  if (mGlobals.UseSumDeps) {\r
+    strcpy (SumDepsFile, mGlobals.SumDepsPath);\r
+    strcat (SumDepsFile, FileName);\r
+    for (Cptr = SumDepsFile + strlen (SumDepsFile) - 1;\r
+         (*Cptr != '\\') && (Cptr > SumDepsFile) && (*Cptr != '.');\r
+         Cptr--\r
+        )\r
+      ;\r
+    if (*Cptr == '.') {\r
+      strcpy (Cptr, ".dep");\r
+    } else {\r
+      strcat (SumDepsFile, ".dep");\r
+    }\r
+    //\r
+    // See if the summary dep file exists. Could use _stat() function, but\r
+    // it's less portable.\r
+    //\r
+    if ((Fptr = fopen (SumDepsFile, "r")) != NULL) {\r
+      PrintDependency (TargetFileName, SumDepsFile);\r
+      fclose (Fptr);\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // If we're not doing duplicates, and we've already seen this filename,\r
+  // then return\r
+  //\r
+  if (mGlobals.NoDupes) {\r
+    for (ListPtr = ProcessedFiles->Next; ListPtr != NULL; ListPtr = ListPtr->Next) {\r
+      if (_stricmp (FileName, ListPtr->Str) == 0) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If we found a match, we're done. If we didn't, create a new element\r
+    // and add it to the list.\r
+    //\r
+    if (ListPtr != NULL) {\r
+      //\r
+      // Print a message if verbose mode\r
+      //\r
+      if (mGlobals.Verbose) {\r
+        DebugMsg (NULL, 0, 0, FileName, "duplicate include -- not processed again");\r
+      }\r
+\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    ListPtr       = malloc (sizeof (STRING_LIST));\r
+    ListPtr->Str  = malloc (strlen (FileName) + 1);\r
+    strcpy (ListPtr->Str, FileName);\r
+    ListPtr->Next         = ProcessedFiles->Next;\r
+    ProcessedFiles->Next  = ListPtr;\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, FileName, "max nesting depth exceeded on file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Make a local copy of the filename. Then we can manipulate it\r
+  // if we have to.\r
+  //\r
+  strcpy (FileNameCopy, FileName);\r
+  //\r
+  // Try to open the file locally\r
+  //\r
+  if ((Fptr = fopen (FileNameCopy, "r")) == NULL) {\r
+    //\r
+    // Try to find it among the paths.\r
+    //\r
+    Fptr = FindFile (FileNameCopy, sizeof (FileNameCopy));\r
+    if (Fptr == NULL) {\r
+      //\r
+      // If this is not the top-level file, and the command-line argument\r
+      // said to ignore missing files, then return ok\r
+      //\r
+      if (NestDepth != START_NEST_DEPTH) {\r
+        if (mGlobals.IgnoreNotFound) {\r
+          if (!mGlobals.QuietMode) {\r
+            DebugMsg (NULL, 0, 0, FileNameCopy, "could not find file");\r
+          }\r
+\r
+          return STATUS_SUCCESS;\r
+        } else {\r
+          Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
+          return STATUS_ERROR;\r
+        }\r
+      } else {\r
+        //\r
+        // Top-level (first) file. Emit an error.\r
+        //\r
+        Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Print the dependency, with string substitution\r
+  //\r
+  PrintDependency (TargetFileName, FileNameCopy);\r
+\r
+  //\r
+  // Now read in lines and find all #include lines. Allow them to indent, and\r
+  // to put spaces between the # and include.\r
+  //\r
+  LineNum = 0;\r
+  while ((fgets (Line, sizeof (Line), Fptr) != NULL) && (Status == STATUS_SUCCESS)) {\r
+    LineNum++;\r
+    Cptr = Line;\r
+    //\r
+    // Skip preceeding spaces on the line\r
+    //\r
+    while (*Cptr && (isspace (*Cptr))) {\r
+      Cptr++;\r
+    }\r
+    //\r
+    // Check for # character, there is no # for asm\r
+    //\r
+    if ((*Cptr == '#') || (mGlobals.IsAsm)) {\r
+      if (*Cptr == '#') {\r
+        Cptr++;\r
+      }\r
+      \r
+      //\r
+      // Check for "include", case insensitive for asm\r
+      //\r
+      while (*Cptr && (isspace (*Cptr))) {\r
+        Cptr++;\r
+      }\r
+      if (((!mGlobals.IsAsm) && (strncmp (Cptr, "include", 7) == 0)) || \r
+          (mGlobals.IsAsm && (_strnicmp (Cptr, "include", 7) == 0))) {\r
+        //\r
+        // Skip over "include" and move on to filename as "file" or <file> or file for asm\r
+        //\r
+        Cptr += 7;\r
+        while (*Cptr && (isspace (*Cptr))) {\r
+          Cptr++;\r
+        }\r
+\r
+        if (*Cptr == '<') {\r
+          EndChar = '>';\r
+        } else if (*Cptr == '"') {\r
+          EndChar = '"';\r
+        } else if (mGlobals.IsAsm) {\r
+          //\r
+          // Handle include file for asm\r
+          // Set EndChar to null so we fall through on processing below.\r
+          //\r
+          EndChar = 0;\r
+          \r
+          //\r
+          // Look for the end of include file name\r
+          //\r
+          EndPtr = Cptr;\r
+          while (*EndPtr && (!isspace (*EndPtr))) {\r
+            EndPtr++;\r
+          }\r
+      \r
+          //\r
+          // Null terminate the filename and try to process it.\r
+          //\r
+          *EndPtr = 0;\r
+          Status  = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles);\r
+        } else {\r
+          //\r
+          // Handle special #include MACRO_NAME(file)\r
+          // Set EndChar to null so we fall through on processing below.\r
+          //\r
+          EndChar = 0;\r
+          //\r
+          // Look for all the special include macros and convert accordingly.\r
+          //\r
+          for (Index = 0; mMacroConversion[Index].IncludeMacroName != NULL; Index++) {\r
+            //\r
+            // Save the start of the string in case some macros are substrings\r
+            // of others.\r
+            //\r
+            SaveCptr = Cptr;\r
+            if (strncmp (\r
+                  Cptr,\r
+                  mMacroConversion[Index].IncludeMacroName,\r
+                  strlen (mMacroConversion[Index].IncludeMacroName)\r
+                  ) == 0) {\r
+              //\r
+              // Skip over the macro name\r
+              //\r
+              Cptr += strlen (mMacroConversion[Index].IncludeMacroName);\r
+              //\r
+              // Skip over open parenthesis, blank spaces, then find closing\r
+              // parenthesis or blank space\r
+              //\r
+              while (*Cptr && (isspace (*Cptr))) {\r
+                Cptr++;\r
+              }\r
+\r
+              if (*Cptr == '(') {\r
+                Cptr++;\r
+                while (*Cptr && (isspace (*Cptr))) {\r
+                  Cptr++;\r
+                }\r
+\r
+                EndPtr = Cptr;\r
+                while (*EndPtr && !isspace (*EndPtr) && (*EndPtr != ')')) {\r
+                  EndPtr++;\r
+                }\r
+\r
+                *EndPtr = 0;\r
+                //\r
+                // Create the path\r
+                //\r
+                strcpy (MacroIncludeFileName, mMacroConversion[Index].PathName);\r
+                strcat (MacroIncludeFileName, Cptr);\r
+                strcat (MacroIncludeFileName, "\\");\r
+                strcat (MacroIncludeFileName, Cptr);\r
+                strcat (MacroIncludeFileName, ".h");\r
+                //\r
+                // Process immediately, then break out of the outside FOR loop.\r
+                //\r
+                Status = ProcessFile (TargetFileName, MacroIncludeFileName, NestDepth + 1, ProcessedFiles);\r
+                break;\r
+              }\r
+            }\r
+            //\r
+            // Restore the start\r
+            //\r
+            Cptr = SaveCptr;\r
+          }\r
+          //\r
+          // Don't recognize the include line? Ignore it. We assume that the\r
+          // file compiles anyway.\r
+          //\r
+          if (mMacroConversion[Index].IncludeMacroName == NULL) {\r
+            //\r
+            // Warning (FileNameCopy, LineNum, 0, "could not parse line", NULL);\r
+            // Status = STATUS_WARNING;\r
+            //\r
+          }\r
+        }\r
+        //\r
+        // Process "normal" includes. If the endchar is 0, then the\r
+        // file has already been processed. Otherwise look for the\r
+        // endchar > or ", and process the include file.\r
+        //\r
+        if (EndChar != 0) {\r
+          Cptr++;\r
+          EndPtr = Cptr;\r
+          while (*EndPtr && (*EndPtr != EndChar)) {\r
+            EndPtr++;\r
+          }\r
+\r
+          if (*EndPtr == EndChar) {\r
+            //\r
+            // If we're processing it, do it\r
+            //\r
+            if ((EndChar != '>') || (!mGlobals.NoSystem)) {\r
+              //\r
+              // Null terminate the filename and try to process it.\r
+              //\r
+              *EndPtr = 0;\r
+              Status  = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles);\r
+            }\r
+          } else {\r
+            Warning (FileNameCopy, LineNum, 0, "malformed include", "missing closing %c", EndChar);\r
+            Status = STATUS_WARNING;\r
+            goto Finish;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (Fptr != NULL) {\r
+    fclose (Fptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+void\r
+PrintDependency (\r
+  INT8    *TargetFileName,\r
+  INT8    *DependentFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a target (.obj) file name, and a dependent file name, do any string\r
+  substitutions (per the command line options) on the file names, then\r
+  print the dependency line of form:\r
+  \r
+  TargetFileName : DependentFile\r
+  \r
+Arguments:\r
+\r
+  TargetFileName - build target file name\r
+  DependentFile  - file on which TargetFileName depends\r
+\r
+Returns:\r
+\r
+  None\r
+  \r
+--*/\r
+{\r
+  INT8  Str[MAX_PATH];\r
+\r
+  //\r
+  // Go through the symbols and do replacements\r
+  //\r
+  strcpy (Str, TargetFileName);\r
+  ReplaceSymbols (Str, sizeof (Str));\r
+  fprintf (mGlobals.OutFptr, "%s : ", Str);\r
+  strcpy (Str, DependentFile);\r
+  ReplaceSymbols (Str, sizeof (Str));\r
+  fprintf (mGlobals.OutFptr, "%s\n", Str);\r
+  //\r
+  // Add pseudo target to avoid incremental build failure when the file is deleted\r
+  //\r
+  fprintf (mGlobals.OutFptr, "%s : \n", Str);\r
+}\r
+\r
+static\r
+void\r
+ReplaceSymbols (\r
+  INT8    *Str,\r
+  UINT32  StrSize\r
+  )\r
+{\r
+  SYMBOL  *Sym;\r
+  INT8    StrCopy[MAX_LINE_LEN];\r
+  INT8    *From;\r
+  INT8    *To;\r
+  BOOLEAN Replaced;\r
+\r
+  //\r
+  // Go through the entire string to look for replacement strings at\r
+  // every position.\r
+  //\r
+  From  = Str;\r
+  To    = StrCopy;\r
+  while (*From) {\r
+    //\r
+    // Copy the character\r
+    //\r
+    *To       = *From;\r
+    Replaced  = FALSE;\r
+    //\r
+    // Go through each symbol and try to find a string substitution\r
+    //\r
+    Sym = mGlobals.SymbolTable;\r
+    while (Sym != NULL) {\r
+      if (_strnicmp (From, Sym->Value, strlen (Sym->Value)) == 0) {\r
+        //\r
+        // Replace the string, then advance the pointers past the\r
+        // replaced strings\r
+        //\r
+        strcpy (To, Sym->Name);\r
+        To += strlen (Sym->Name);\r
+        From += strlen (Sym->Value);\r
+        Replaced = TRUE;\r
+        //\r
+        // Break from the while()\r
+        //\r
+        break;\r
+      } else {\r
+        Sym = Sym->Next;\r
+      }\r
+    }\r
+\r
+    if (!Replaced) {\r
+      From++;\r
+      To++;\r
+    }\r
+  }\r
+  //\r
+  // Null terminate, and return it\r
+  //\r
+  *To = 0;\r
+  if (strlen (StrCopy) < StrSize) {\r
+    strcpy (Str, StrCopy);\r
+  }\r
+}\r
+//\r
+// Given a filename, try to find it along the include paths.\r
+//\r
+static\r
+FILE *\r
+FindFile (\r
+  INT8    *FileName,\r
+  UINT32  FileNameLen\r
+  )\r
+{\r
+  FILE        *Fptr;\r
+  STRING_LIST *List;\r
+  STRING_LIST *SubDir;\r
+  INT8        FullFileName[MAX_PATH * 2];\r
+\r
+  //\r
+  // Traverse the list of paths and try to find the file\r
+  //\r
+  List = mGlobals.IncludePaths;\r
+  while (List != NULL) {\r
+    //\r
+    // Put the path and filename together\r
+    //\r
+    if (strlen (List->Str) + strlen (FileName) + 1 > sizeof (FullFileName)) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "cannot concatenate '%s' + '%s'",\r
+        List->Str,\r
+        FileName\r
+        );\r
+      return NULL;\r
+    }\r
+    //\r
+    // Append the filename to this include path and try to open the file.\r
+    //\r
+    strcpy (FullFileName, List->Str);\r
+    strcat (FullFileName, FileName);\r
+    if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
+      //\r
+      // Return the file name\r
+      //\r
+      if (FileNameLen <= strlen (FullFileName)) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
+        //\r
+        // fprintf (stdout, "File length > %d: %s\n", FileNameLen, FullFileName);\r
+        //\r
+        return NULL;\r
+      }\r
+\r
+      strcpy (FileName, FullFileName);\r
+      return Fptr;\r
+    }\r
+    //\r
+    // Didn't find it there. Now try this directory with every subdirectory\r
+    // the user specified on the command line\r
+    //\r
+    for (SubDir = mGlobals.SubDirs; SubDir != NULL; SubDir = SubDir->Next) {\r
+      strcpy (FullFileName, List->Str);\r
+      strcat (FullFileName, SubDir->Str);\r
+      strcat (FullFileName, FileName);\r
+      if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
+        //\r
+        // Return the file name\r
+        //\r
+        if (FileNameLen <= strlen (FullFileName)) {\r
+          Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
+          return NULL;\r
+        }\r
+\r
+        strcpy (FileName, FullFileName);\r
+        return Fptr;\r
+      }\r
+    }\r
+\r
+    List = List->Next;\r
+  }\r
+  //\r
+  // Not found\r
+  //\r
+  return NULL;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+{\r
+  STRING_LIST *NewList;\r
+  STRING_LIST *LastIncludePath;\r
+  STRING_LIST *LastSourceFile;\r
+  SYMBOL      *Symbol;\r
+  int         Index;\r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
+  mGlobals.NoDupes = TRUE;\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+  //\r
+  // Initialize locals\r
+  //\r
+  LastIncludePath = NULL;\r
+  LastSourceFile  = NULL;\r
+  //\r
+  // Process until no more args\r
+  //\r
+  while (Argc) {\r
+    //\r
+    // -i path    add include search path\r
+    //\r
+    if (_stricmp (Argv[0], "-i") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of include paths. Always make sure it\r
+        // has a "\" on the end of it.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Next = NULL;\r
+        NewList->Str  = malloc (strlen (Argv[1]) + 2);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (NewList->Str[strlen (NewList->Str) - 1] != '\\') {\r
+          strcat (NewList->Str, "\\");\r
+        }\r
+        //\r
+        // Add it to the end of the our list of include paths\r
+        //\r
+        if (mGlobals.IncludePaths == NULL) {\r
+          mGlobals.IncludePaths = NewList;\r
+        } else {\r
+          LastIncludePath->Next = NewList;\r
+        }\r
+\r
+        LastIncludePath = NewList;\r
+        //\r
+        // fprintf (stdout, "Added path: %s\n", NewList->Str);\r
+        //\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires an include path");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-f") == 0) {\r
+      //\r
+      // Check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of source files.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Next = NULL;\r
+        //\r
+        // Allocate space to replace ".c" with ".obj", plus null termination\r
+        //\r
+        NewList->Str = malloc (strlen (Argv[1]) + 5);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (mGlobals.SourceFiles == NULL) {\r
+          mGlobals.SourceFiles = NewList;\r
+        } else {\r
+          LastSourceFile->Next = NewList;\r
+        }\r
+\r
+        LastSourceFile = NewList;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // The C compiler first looks for #include files in the directory where\r
+      // the source file came from. Add the file's source directory to the\r
+      // list of include paths.\r
+      //\r
+      NewList = malloc (sizeof (STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      NewList->Next = NULL;\r
+      NewList->Str  = malloc (strlen (Argv[1]) + 3);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Back up in the source file name to the last backslash and terminate after it.\r
+      //\r
+      for (Index = strlen (NewList->Str) - 1; (Index > 0) && (NewList->Str[Index] != '\\'); Index--)\r
+        ;\r
+      if (Index < 0) {\r
+        strcpy (NewList->Str, ".\\");\r
+      } else {\r
+        NewList->Str[Index + 1] = 0;\r
+      }\r
+      //\r
+      // Add it to the end of the our list of include paths\r
+      //\r
+      if (mGlobals.IncludePaths == NULL) {\r
+        mGlobals.IncludePaths = NewList;\r
+      } else {\r
+        LastIncludePath->Next = NewList;\r
+      }\r
+\r
+      if (mGlobals.Verbose) {\r
+        fprintf (stdout, "Adding include path: %s\n", NewList->Str);\r
+      }\r
+\r
+      LastIncludePath = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-s") == 0) {\r
+      //\r
+      // -s subdir    add subdirectory subdir to list of subdirecties to scan.\r
+      // Check for one more arg first.\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of subdirectory include paths. Always\r
+        // make sure it has a "\" on the end of it.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (NewList->Str[strlen (NewList->Str) - 1] != '\\') {\r
+          strcat (NewList->Str, "\\");\r
+        }\r
+\r
+        NewList->Next     = mGlobals.SubDirs;\r
+        mGlobals.SubDirs  = NewList;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a subdirectory name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-sub") == 0) {\r
+      //\r
+      // -sub symname symvalue  to do string substitution in the output\r
+      //\r
+      if (Argc > 2) {\r
+        //\r
+        // Allocate memory for the symbol object\r
+        //\r
+        Symbol = malloc (sizeof (SYMBOL));\r
+        if (Symbol == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Allocate memory for the symbol name and value, then save copies\r
+        //\r
+        Symbol->Name = malloc (strlen (Argv[1]) + 1);\r
+        if (Symbol->Name == NULL) {\r
+          free (Symbol);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (Symbol->Name, Argv[1]);\r
+        Symbol->Value = malloc (strlen (Argv[2]) + 1);\r
+        if (Symbol->Value == NULL) {\r
+          free (Symbol->Name);\r
+          free (Symbol);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (Symbol->Value, Argv[2]);\r
+        //\r
+        // Add it to the list\r
+        //\r
+        Symbol->Next          = mGlobals.SymbolTable;\r
+        mGlobals.SymbolTable  = Symbol;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a symbol name and value");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Skip over args\r
+      //\r
+      Argc -= 2;\r
+      Argv += 2;\r
+    } else if (_stricmp (Argv[0], "-nosystem") == 0) {\r
+      mGlobals.NoSystem = TRUE;\r
+    } else if (_stricmp (Argv[0], "-nodupes") == 0) {\r
+      mGlobals.NoDupes = TRUE;\r
+    } else if (_stricmp (Argv[0], "-nodups") == 0) {\r
+      mGlobals.NoDupes = TRUE;\r
+    } else if (_stricmp (Argv[0], "-target") == 0) {\r
+      //\r
+      // -target TargetFileName  - Target object file (only one allowed right\r
+      // now) is TargetFileName rather than SourceFile.obj\r
+      //\r
+      if (Argc > 1) {\r
+        strcpy (mGlobals.TargetFileName, Argv[1]);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a target file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-usesumdeps") == 0) {\r
+      //\r
+      // -usesumdeps Path - if we find an included file xxx.h, and file\r
+      // Path/xxx.dep exists, list Path/xxx.dep as a dependency rather than\r
+      // xxx.h and don't parse xxx.h. This allows you to create a dependency\r
+      // file for a commonly included file, and have its dependency file updated\r
+      // only if its included files are updated. Then anyone else including this\r
+      // common include file can simply have a dependency on that file's .dep file\r
+      // rather than on all the files included by it. Confusing enough?\r
+      //\r
+      mGlobals.UseSumDeps = 1;\r
+      if (Argc > 1) {\r
+        strcpy (mGlobals.SumDepsPath, Argv[1]);\r
+        //\r
+        // Add slash on end if not there\r
+        //\r
+        if (mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '\\') {\r
+          strcat (mGlobals.SumDepsPath, "\\");\r
+        }\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires path to summary dependency files");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+\r
+    } else if (_stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // -o OutputFileName    - specify an output filename for dependency list\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Try to open the file\r
+        //\r
+        if ((mGlobals.OutFptr = fopen (Argv[1], "w")) == NULL) {\r
+          Error (NULL, 0, 0, Argv[1], "could not open file for writing");\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        mGlobals.OutFileName = Argv[1];\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires output file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = TRUE;\r
+    } else if (_stricmp (Argv[0], "-neverfail") == 0) {\r
+      mGlobals.NeverFail = TRUE;\r
+    } else if (_stricmp (Argv[0], "-q") == 0) {\r
+      mGlobals.QuietMode = TRUE;\r
+    } else if (_stricmp (Argv[0], "-ignorenotfound") == 0) {\r
+      mGlobals.IgnoreNotFound = TRUE;\r
+    } else if (_stricmp (Argv[0], "-asm") == 0) {\r
+      mGlobals.IsAsm = TRUE;\r
+    } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Had to specify at least one source file\r
+  //\r
+  if (mGlobals.SourceFiles == NULL) {\r
+    Error (NULL, 0, 0, "must specify one source file name", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assume output to stdout if not specified\r
+  //\r
+  if (mGlobals.OutFptr == NULL) {\r
+    mGlobals.OutFptr = stdout;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Free the global string lists we allocated memory for\r
+//\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  )\r
+{\r
+  STRING_LIST *Temp;\r
+  SYMBOL      *NextSym;\r
+\r
+  //\r
+  // printf ("Free lists.....");\r
+  //\r
+  // Traverse the include paths, freeing each\r
+  // printf ("freeing include paths\n");\r
+  //\r
+  while (mGlobals.IncludePaths != NULL) {\r
+    Temp = mGlobals.IncludePaths->Next;\r
+    //\r
+    // printf ("Freeing include path string '%s' at 0x%X\n",\r
+    //  mGlobals.IncludePaths->Str, (int)(mGlobals.IncludePaths->Str));\r
+    //\r
+    free (mGlobals.IncludePaths->Str);\r
+    //\r
+    // printf ("Freeing include path object at 0x%X\n", (int)(mGlobals.IncludePaths));\r
+    //\r
+    free (mGlobals.IncludePaths);\r
+    mGlobals.IncludePaths = Temp;\r
+  }\r
+  //\r
+  // Traverse the source files, freeing each\r
+  //\r
+  while (mGlobals.SourceFiles != NULL) {\r
+    Temp = mGlobals.SourceFiles->Next;\r
+    free (mGlobals.SourceFiles->Str);\r
+    free (mGlobals.SourceFiles);\r
+    mGlobals.SourceFiles = Temp;\r
+  }\r
+  //\r
+  // Traverse the subdirectory list, freeing each\r
+  //\r
+  while (mGlobals.SubDirs != NULL) {\r
+    Temp = mGlobals.SubDirs->Next;\r
+    free (mGlobals.SubDirs->Str);\r
+    free (mGlobals.SubDirs);\r
+    mGlobals.SubDirs = Temp;\r
+  }\r
+  //\r
+  // Free the symbol table\r
+  //\r
+  while (mGlobals.SymbolTable != NULL) {\r
+    NextSym = mGlobals.SymbolTable->Next;\r
+    free (mGlobals.SymbolTable->Name);\r
+    free (mGlobals.SymbolTable->Value);\r
+    mGlobals.SymbolTable = NextSym;\r
+  }\r
+  //\r
+  // printf ("done\n");\r
+  //\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    UTILITY_NAME " -- make dependencies",\r
+    "  Usage: MakeDeps [options]",\r
+    "    Options include:",\r
+    "      -h or -?         for this help information",\r
+    "      -f SourceFile    add SourceFile to list of files to scan",\r
+    "      -i IncludePath   add IncludePath to list of search paths",\r
+    "      -o OutputFile    write output dependencies to OutputFile",\r
+    "      -s SubDir        for each IncludePath, also search IncludePath\\SubDir",\r
+    "      -v               for verbose output",\r
+    "      -ignorenotfound  don't warn for files not found",\r
+    "      -target Target   for single SourceFile, target is Target, not SourceFile.obj",\r
+    "      -q               quiet mode to not report files not found if ignored",\r
+    "      -sub sym str     replace all occurrances of 'str' with 'sym' in the output",\r
+    "      -nosystem        not process system <include> files",\r
+    "      -neverfail       always return a success return code",\r
+    //\r
+    //    "      -nodupes         keep track of include files, don't rescan duplicates",\r
+    //\r
+    "      -usesumdeps path use summary dependency files in 'path' directory.",\r
+    "      -asm             The SourceFile is assembler file",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile
new file mode 100644 (file)
index 0000000..4cd9084
--- /dev/null
@@ -0,0 +1,69 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the MakeDeps utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+TARGET_NAME     = MakeDeps\r
+TARGET_SRC_DIR  = $(EDK_TOOLS_SOURCE)\MakeDeps\r
+TARGET_EXE      = $(EDK_TOOLS_OUTPUT)\MakeDeps.exe\r
+\r
+OBJECTS         = $(EDK_TOOLS_OUTPUT)\MakeDeps.obj  \r
+LIBS            = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Compile each tool source file\r
+#\r
+$(OBJECTS) : $(TARGET_SRC_DIR)\MakeDeps.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MakeDeps.c /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
new file mode 100644 (file)
index 0000000..974c9b4
--- /dev/null
@@ -0,0 +1,79 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#\r
+#  Abstract:\r
+#\r
+#    This file is used to build the EFI build tools.\r
+#\r
+#--*/\r
+\r
+#\r
+# Everything depends on EDK_SOURCE. Make sure it's defined\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set\r
+!ENDIF\r
+\r
+#\r
+# Define our toolchain before we include the master settings file\r
+#\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define all the makefiles we want to call\r
+#\r
+\r
+MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile             \\r
+            $(CUSTOMIZEDCOMPRESS_MAKEFILE)                  \\r
+            $(EDK_TOOLS_SOURCE)\GenCRC32Section\Makefile    \\r
+            $(EDK_TOOLS_SOURCE)\GenSection\Makefile         \\r
+            $(EDK_TOOLS_SOURCE)\GenDepex\Makefile           \\r
+            $(EDK_TOOLS_SOURCE)\GenFfsFile\Makefile         \\r
+            $(EDK_TOOLS_SOURCE)\GenFvImage\Makefile         \\r
+            $(EDK_TOOLS_SOURCE)\FwImage\Makefile            \\r
+            $(EDK_TOOLS_SOURCE)\ProcessDsc\makefile         \\r
+            $(EDK_TOOLS_SOURCE)\GuidChk\makefile            \\r
+            $(EDK_TOOLS_SOURCE)\MakeDeps\makefile           \\r
+            $(EDK_TOOLS_SOURCE)\SetStamp\makefile           \\r
+            $(EDK_TOOLS_SOURCE)\VfrCompile\makefile         \\r
+            $(EDK_TOOLS_SOURCE)\StrGather\makefile          \\r
+            $(EDK_TOOLS_SOURCE)\BootsectImage\Makefile      \\r
+            $(EDK_TOOLS_SOURCE)\GenBootsector\Makefile      \\r
+            $(EDK_TOOLS_SOURCE)\GenPage\Makefile            \\r
+            $(EDK_TOOLS_SOURCE)\SplitFile\Makefile          \\r
+            $(EDK_TOOLS_SOURCE)\EfiCompress\Makefile        \\r
+            $(EDK_TOOLS_SOURCE)\EfildrImage\Makefile        \\r
+            $(EDK_TOOLS_SOURCE)\EfiRom\Makefile             \\r
+            $(EDK_TOOLS_SOURCE)\GenAprioriFile\Makefile     \\r
+            $(EDK_TOOLS_SOURCE)\ModifyInf\Makefile\r
+\r
+\r
+\r
+#\r
+# Define default all target which calls all our makefiles. The special\r
+# bang (!) tells nmake to do the command for each out-of-date dependent.\r
+#\r
+# Create the BIN directory, which will only exist if you pull the source tree\r
+# from version control.\r
+#\r
+all : $(MAKEFILES)\r
+  -if not exist $(EDK_TOOLS_OUTPUT) mkdir $(EDK_TOOLS_OUTPUT)\r
+  !$(MAKE) -f $? TOOLCHAIN=$(TOOLCHAIN) BUILD_DIR=$(BUILD_DIR) all\r
+  \r
+#\r
+# Call all the tools makefiles with a clean target.\r
+#\r
+clean : $(MAKEFILES)\r
+  !$(MAKE) -f $? TOOLCHAIN=$(TOOLCHAIN) clean\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile
new file mode 100644 (file)
index 0000000..f303a54
--- /dev/null
@@ -0,0 +1,82 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2001 - 2006 Intel Corporation.\r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#   \r
+#  Module Name: \r
+#    \r
+#    Makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = ModifyInf\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE   = "$(TARGET_SRC_DIR)\ModifyInf.c"\r
+TARGET_EXE_INCLUDE  = \r
+OBJECTS             = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj  \r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
new file mode 100644 (file)
index 0000000..edfcba0
--- /dev/null
@@ -0,0 +1,322 @@
+/*++\r
+\r
+Copyright (c)  1999 - 2002 Intel Corporation.\r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ModifyInf.c\r
+\r
+Abstract:\r
+\r
+  It is a simple tool to modify some fields in a FV inf file \r
+  and output a new FV inf file.  \r
+\r
+--*/\r
+\r
+#include "stdio.h"\r
+#include "string.h"\r
+\r
+//\r
+// Read a line into buffer including '\r\n'\r
+//\r
+int\r
+ReadLine (\r
+  char *LineBuffer,\r
+  FILE *fp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  LineBuffer  - GC_TODO: add argument description\r
+  fp          - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int   CharC;\r
+  char  *Line;\r
+\r
+  Line = LineBuffer;\r
+\r
+  while ((CharC = fgetc (fp)) != EOF) {\r
+    *Line++ = (char) CharC;\r
+    if (CharC == 0x0a) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *Line = 0;\r
+\r
+  if (CharC == EOF) {\r
+    return 0;\r
+  } else {\r
+    return 1;\r
+  }\r
+\r
+}\r
+//\r
+// Write a line into output file\r
+//\r
+int\r
+WriteLine (\r
+  char *Line,\r
+  FILE *fp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Line  - GC_TODO: add argument description\r
+  fp    - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  fwrite (Line, strlen (Line), 1, fp);\r
+  return 0;\r
+}\r
+//\r
+// Apply patterns to a line\r
+// Currently there are 2 patterns to support\r
+// '==' replace a field value with a new value\r
+// '+=' append a string at the end of original line\r
+// '-'  prevent the line from applying any patterns\r
+//      it has the highest priority\r
+//\r
+int\r
+ApplyPattern (\r
+  char *Line,\r
+  char *argv[],\r
+  int  argc\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Line  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+  argc  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  static char Section[256];\r
+  int         SectionLength;\r
+  char        PatternBuffer[256];\r
+  char        *Pattern;\r
+  char        *Pattern1;\r
+  char        *Pattern2;\r
+  int         PatternNum;\r
+  char        *Ptr;\r
+\r
+  Pattern     = PatternBuffer;\r
+\r
+  PatternNum  = argc;\r
+\r
+  //\r
+  // For section field\r
+  // record current scope section into static buffer\r
+  //\r
+  Ptr = Line;\r
+  if (*Ptr == '[') {\r
+    while (*Ptr != ']') {\r
+      if (!(*Ptr++)) {\r
+        return -1;\r
+      }\r
+    }\r
+    SectionLength = Ptr - Line + 1;\r
+    SectionLength = SectionLength > 255 ? 255 : SectionLength;\r
+    strncpy (Section, Line, SectionLength);\r
+    Section[SectionLength] = 0;\r
+  }\r
+  //\r
+  // Apply each pattern on the line\r
+  //\r
+  while (PatternNum-- > 3) {\r
+\r
+    strcpy (Pattern, argv[PatternNum]);\r
+\r
+    //\r
+    // For pattern '-'\r
+    // keep it unmodified by other patterns\r
+    //\r
+    if (*Pattern == '-') {\r
+      if (strstr (Line, Pattern + 1)) {\r
+        return 0;\r
+      } else {\r
+        continue;\r
+      }\r
+    }\r
+    //\r
+    // For other patterns\r
+    // get its section at first if it has\r
+    //\r
+    if (*Pattern == '[') {\r
+      if (strncmp (Section, Pattern, strlen (Section))) {\r
+        //\r
+        // This pattern can't be appied for current section\r
+        //\r
+        continue;\r
+      }\r
+      //\r
+      // Strip the section field\r
+      //\r
+      while (*Pattern != ']') {\r
+        if (!(*Pattern++)) {\r
+          return -1;\r
+        }\r
+      }\r
+\r
+      Pattern++;\r
+    }\r
+    //\r
+    // Apply patterns\r
+    //\r
+    Pattern1  = strstr (Pattern, "==");\r
+    Pattern2  = strstr (Pattern, "+=");\r
+    if (Pattern1) {\r
+      //\r
+      // For pattern '=='\r
+      // replace the field value with a new string\r
+      //\r
+      if (!strncmp (Line, Pattern, Pattern1 - Pattern)) {\r
+        Pattern1 += 2;\r
+        Ptr = strstr (Line, "=");\r
+        if (!Ptr) {\r
+          return -1;\r
+        }\r
+\r
+        while (*(++Ptr) == ' ')\r
+          ;\r
+        *Ptr = 0;\r
+        strcat (Line, Pattern1);\r
+        strcat (Line, "\r\n");\r
+      }\r
+    } else if (Pattern2) {\r
+      //\r
+      // For pattern '+='\r
+      // append a string at end of the original string\r
+      //\r
+      if (!strncmp (Line, Pattern, Pattern2 - Pattern)) {\r
+        Pattern2 += 2;\r
+        Ptr = Line;\r
+        while (*Ptr != 0x0D && *Ptr != 0x0A) {\r
+          Ptr++;\r
+        }\r
+\r
+        *Ptr = 0;\r
+        strcat (Line, Pattern2);\r
+        strcat (Line, "\r\n");\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+void\r
+Usage (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char*argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  argc  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  char  LineBuffer[256];\r
+  FILE  *fpin;\r
+  FILE  *fpout;\r
+\r
+  if (argc < 3) {\r
+    Usage ();\r
+    return -1;\r
+  }\r
+\r
+  fpin = fopen (argv[1], "rb");\r
+  if (!fpin) {\r
+    printf ("Can't open input file!\r\n");\r
+    return -1;\r
+  }\r
+\r
+  fpout = fopen (argv[2], "wb");\r
+  if (!fpout) {\r
+    fclose (fpin);\r
+    printf ("Can't create output file!\r\n");\r
+    return -1;\r
+  }\r
+\r
+  while (ReadLine (LineBuffer, fpin)) {\r
+    ApplyPattern (LineBuffer, argv, argc);\r
+    WriteLine (LineBuffer, fpout);\r
+  }\r
+\r
+  fclose (fpin);\r
+  fclose (fpout);\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h
new file mode 100644 (file)
index 0000000..b642d09
--- /dev/null
@@ -0,0 +1,123 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Common.h\r
+\r
+Abstract:\r
+\r
+  Common include file for the ProcessDsc utility.\r
+\r
+--*/\r
+\r
+#ifndef _COMMON_H_\r
+#define _COMMON_H_\r
+\r
+typedef char INT8;\r
+typedef unsigned int UINT32;\r
+\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  1024\r
+\r
+#ifdef MAX_PATH\r
+#undef MAX_PATH\r
+#define MAX_PATH  1024\r
+#endif\r
+\r
+//\r
+// Defines for how to expand symbols\r
+//\r
+#define EXPANDMODE_NO_UNDEFS    0x01\r
+#define EXPANDMODE_NO_DESTDIR   0x02\r
+#define EXPANDMODE_NO_SOURCEDIR 0x04\r
+#define EXPANDMODE_RECURSIVE    0x08\r
+\r
+//\r
+// Defines for adding symbols\r
+//\r
+#define SYM_OVERWRITE 0x01      // overwrite existing assignments\r
+#define SYM_GLOBAL    0x02      // global symbol (persistent)\r
+#define SYM_LOCAL     0x04      // symbols at component level\r
+#define SYM_FILE      0x08      // symbols at file level\r
+#define SYM_FILEPATH  0x10      // symbol is a file path\r
+#define SYM_FILENAME  0x20      // symbol is a file name\r
+#define FV_DIR        "FV_DIR"  // symbol for base dir where FV files are\r
+#define DSC_FILENAME  "DSC_FILENAME"\r
+\r
+//\r
+// Smart file for better incremental build support.\r
+// Only re-create .pkg .inf or .apr files when it's content is changed.\r
+//  \r
+//\r
+typedef struct _SMART_FILE {\r
+  char              *FileName;\r
+  char              *FileContent;        // Previous file content\r
+  int               FileLength;            // Previous file string length\r
+  int               FilePosition;        // The offset from FileContent for next comparison\r
+  FILE              *FilePtr;            // New file pointer if the file need to be re-created\r
+} SMART_FILE;\r
+\r
+SMART_FILE *\r
+SmartOpen (\r
+  char        *FileName\r
+  );\r
+\r
+int\r
+SmartWrite (\r
+  SMART_FILE  *SmartFile,\r
+  char        *String\r
+  );\r
+\r
+void\r
+SmartClose (\r
+  SMART_FILE  *SmartFile\r
+  );\r
+    \r
+INT8  *\r
+GetSymbolValue (\r
+  INT8 *SymbolName\r
+  );\r
+\r
+int\r
+AddSymbol (\r
+  INT8  *Name,\r
+  INT8  *Value,\r
+  int   Mode\r
+  );\r
+\r
+int\r
+ExpandSymbols (\r
+  INT8  *SourceLine,\r
+  INT8  *DestLine,\r
+  int   LineLen,\r
+  int   ExpandMode\r
+  );\r
+\r
+void\r
+Message (\r
+  UINT32  PrintMask,\r
+  INT8    *Fmt,\r
+  ...\r
+  );\r
+\r
+int\r
+MakeFilePath (\r
+  INT8 *FileName\r
+  );\r
+\r
+int\r
+IsAbsolutePath (\r
+  INT8    *FileName\r
+  );\r
+\r
+#endif // ifndef _COMMON_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c
new file mode 100644 (file)
index 0000000..345e1a9
--- /dev/null
@@ -0,0 +1,534 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:\r
+\r
+    DscFile.c\r
+\r
+  Abstract:\r
+\r
+    This module is used to process description files at a high level. For the\r
+    most part, it pre-parses the file to find and save off positions of all\r
+    the sections ([section.subsection.subsection]) in a linked list, then\r
+    provides services to find the sections by name, and read the lines from\r
+    the section until you run into the next section.\r
+\r
+  NOTE: DSC file is synonomous with section file. A DSC file is simply a file\r
+    containing bracketed section names [section.subsection.subsection...]\r
+\r
+--*/\r
+\r
+#include <stdio.h>  // for file ops\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdlib.h> // for malloc\r
+#include "Common.h"\r
+#include "DSCFile.h"\r
+\r
+#define MAX_INCLUDE_NEST_LEVEL  20\r
+\r
+static\r
+void\r
+DSCFileFree (\r
+  DSC_FILE *DSC\r
+  );\r
+\r
+static\r
+STATUS\r
+DSCParseInclude (\r
+  DSC_FILE  *DSC,\r
+  char      *FileName,\r
+  int       NestLevel\r
+  );\r
+\r
+//\r
+// Constructor for a DSC file\r
+//\r
+int\r
+DSCFileInit (\r
+  DSC_FILE *DSC\r
+  )\r
+{\r
+  memset ((char *) DSC, 0, sizeof (DSC_FILE));\r
+  DSC->SavedPositionIndex = -1;\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Destructor for a DSC file\r
+//\r
+int\r
+DSCFileDestroy (\r
+  DSC_FILE *DSC\r
+  )\r
+{\r
+  DSC->SavedPositionIndex = -1;\r
+  DSCFileFree (DSC);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Get the next line from a DSC file.\r
+//\r
+char *\r
+DSCFileGetLine (\r
+  DSC_FILE  *DSC,\r
+  char      *Line,\r
+  int       LineLen\r
+  )\r
+{\r
+  char  *Cptr;\r
+\r
+  if (DSC->CurrentLine == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Check for running into next section\r
+  //\r
+  if (DSC->CurrentLine->Line[0] == '[') {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Allow special case where the line starts with backslash-bracket. If we\r
+  // see this, then shift everything left one character.\r
+  //\r
+  if ((DSC->CurrentLine->Line[0] == '\\') && (DSC->CurrentLine->Line[1] == '[')) {\r
+    Cptr = DSC->CurrentLine->Line + 1;\r
+  } else {\r
+    Cptr = DSC->CurrentLine->Line;\r
+  }\r
+\r
+  strncpy (Line, Cptr, LineLen);\r
+  ParserSetPosition (DSC->CurrentLine->FileName, DSC->CurrentLine->LineNum);\r
+  DSC->CurrentLine = DSC->CurrentLine->Next;\r
+  return Line;\r
+}\r
+\r
+int\r
+DSCFileSetFile (\r
+  DSC_FILE  *DSC,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Pre-scan a section file to find all the sections. Then we can speed up\r
+  searching for the different sections.\r
+\r
+Arguments:\r
+\r
+  DSC       - pointer to a DSC structure (this pointer)\r
+  FileName  - name of the file to process\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS if everything went well.\r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+\r
+  //\r
+  // Called to open a new sectioned file.\r
+  //\r
+  Status = DSCParseInclude (DSC, FileName, 1);\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+DSCParseInclude (\r
+  DSC_FILE    *DSC,\r
+  char        *FileName,\r
+  int         NestLevel\r
+  )\r
+{\r
+  SECTION       *NewSect;\r
+  SECTION_LINE  *NewLine;\r
+  DSC_FILE_NAME *NewDscFileName;\r
+  char          Line[MAX_LINE_LEN];\r
+  char          *Start;\r
+  char          *End;\r
+  char          SaveChar;\r
+  char          *TempCptr;\r
+  char          ShortHandSectionName[MAX_LINE_LEN];\r
+  char          ThisSectionName[MAX_LINE_LEN];\r
+  SECTION       *CurrSect;\r
+  SECTION       *TempSect;\r
+  FILE          *FilePtr;\r
+  STATUS        Status;\r
+  UINT32        LineNum;\r
+\r
+  //\r
+  // Make sure we haven't exceeded our maximum nesting level\r
+  //\r
+  if (NestLevel > MAX_INCLUDE_NEST_LEVEL) {\r
+    Error (NULL, 0, 0, "application error", "maximum !include nesting level exceeded");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Try to open the file\r
+  //\r
+  if ((FilePtr = fopen (FileName, "r")) == NULL) {\r
+    //\r
+    // This function is called to handle the DSC file from the command line too,\r
+    // so differentiate whether this file is an include file or the main file\r
+    // by examining the nest level.\r
+    //\r
+    if (NestLevel == 1) {\r
+      Error (NULL, 0, 0, FileName, "could not open DSC file for reading");\r
+    } else {\r
+      Error (NULL, 0, 0, FileName, "could not open !include DSC file for reading");\r
+    }\r
+\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // We keep a linked list of files we parse for error reporting purposes.\r
+  //\r
+  NewDscFileName = malloc (sizeof (DSC_FILE_NAME));\r
+  if (NewDscFileName == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset (NewDscFileName, 0, sizeof (DSC_FILE_NAME));\r
+  NewDscFileName->FileName = (INT8 *) malloc (strlen (FileName) + 1);\r
+  if (NewDscFileName->FileName == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewDscFileName->FileName, FileName);\r
+  if (DSC->FileName == NULL) {\r
+    DSC->FileName = NewDscFileName;\r
+  } else {\r
+    DSC->LastFileName->Next = NewDscFileName;\r
+  }\r
+\r
+  DSC->LastFileName = NewDscFileName;\r
+  //\r
+  // Read lines and process until done\r
+  //\r
+  Status  = STATUS_SUCCESS;\r
+  LineNum = 0;\r
+  for (;;) {\r
+    if (fgets (Line, sizeof (Line), FilePtr) == NULL) {\r
+      break;\r
+    }\r
+\r
+    LineNum++;\r
+    ParserSetPosition (FileName, LineNum);\r
+    //\r
+    // Add the line to our list if it's not a !include line\r
+    //\r
+    if ((strncmp (Line, "!include", 8) == 0) && (isspace (Line[8]))) {\r
+      Start = Line + 9;\r
+      while (*Start && (*Start != '"')) {\r
+        Start++;\r
+      }\r
+\r
+      if (*Start != '"') {\r
+        Error (FileName, LineNum, 0, NULL, "invalid format for !include");\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      Start++;\r
+      for (End = Start; *End && (*End != '"'); End++)\r
+        ;\r
+      if (*End != '"') {\r
+        Error (FileName, LineNum, 0, NULL, "invalid format for !include");\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      *End = 0;\r
+      //\r
+      // Expand symbols. Use 'ThisSectionName' as scratchpad\r
+      //\r
+      ExpandSymbols (Start, ThisSectionName, sizeof (ThisSectionName), EXPANDMODE_NO_UNDEFS);\r
+      Status = DSCParseInclude (DSC, ThisSectionName, NestLevel + 1);\r
+      if (Status != STATUS_SUCCESS) {\r
+        Error (FileName, LineNum, 0, NULL, "failed to parse !include file");\r
+        goto Done;\r
+      }\r
+    } else {\r
+      NewLine = (SECTION_LINE *) malloc (sizeof (SECTION_LINE));\r
+      if (NewLine == NULL) {\r
+        Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      memset ((char *) NewLine, 0, sizeof (SECTION_LINE));\r
+      NewLine->LineNum  = LineNum;\r
+      NewLine->FileName = NewDscFileName->FileName;\r
+      NewLine->Line     = (char *) malloc (strlen (Line) + 1);\r
+      if (NewLine->Line == NULL) {\r
+        Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      strcpy (NewLine->Line, Line);\r
+      if (DSC->Lines == NULL) {\r
+        DSC->Lines = NewLine;\r
+      } else {\r
+        DSC->LastLine->Next = NewLine;\r
+      }\r
+\r
+      DSC->LastLine = NewLine;\r
+      //\r
+      // Parse the line for []. Ignore [] and [----] delimiters. The\r
+      // line may have multiple definitions separated by commas, so\r
+      // take each separately\r
+      //\r
+      Start = Line;\r
+      if ((Line[0] == '[') && ((Line[1] != ']') && (Line[1] != '-'))) {\r
+        //\r
+        // Skip over open bracket and preceeding spaces\r
+        //\r
+        Start++;\r
+        ShortHandSectionName[0] = 0;\r
+\r
+        while (*Start && (*Start != ']')) {\r
+          while (isspace (*Start)) {\r
+            Start++;\r
+          }\r
+          //\r
+          // Hack off closing bracket or trailing spaces or comma separator.\r
+          // Also allow things like [section.subsection1|subsection2], which\r
+          // is shorthand for [section.subsection1,section.subsection2]\r
+          //\r
+          End = Start;\r
+          while (*End && (*End != ']') && !isspace (*End) && (*End != ',') && (*End != '|')) {\r
+            End++;\r
+          }\r
+          //\r
+          // Save the character and null-terminate the string\r
+          //\r
+          SaveChar  = *End;\r
+          *End      = 0;\r
+          //\r
+          // Now allocate space for a new section and add it to the linked list.\r
+          // If the previous section ended with the shorthand indicator, then\r
+          // the section name was saved off. Append this section name to it.\r
+          //\r
+          strcpy (ThisSectionName, ShortHandSectionName);\r
+          if (*Start == '.') {\r
+            strcat (ThisSectionName, Start + 1);\r
+          } else {\r
+            strcat (ThisSectionName, Start);\r
+          }\r
+          //\r
+          // Allocate memory for the section. Then clear it out.\r
+          //\r
+          NewSect = (SECTION *) malloc (sizeof (SECTION));\r
+          if (NewSect == NULL) {\r
+            Error (NULL, 0, 0, NULL, "failed to allocation memory for sections");\r
+            Status = STATUS_ERROR;\r
+            goto Done;\r
+          }\r
+\r
+          memset ((char *) NewSect, 0, sizeof (SECTION));\r
+          NewSect->FirstLine  = NewLine;\r
+          NewSect->Name       = (char *) malloc (strlen (ThisSectionName) + 1);\r
+          if (NewSect->Name == NULL) {\r
+            Error (NULL, 0, 0, NULL, "failed to allocation memory for sections");\r
+            Status = STATUS_ERROR;\r
+            goto Done;\r
+          }\r
+\r
+          strcpy (NewSect->Name, ThisSectionName);\r
+          if (DSC->Sections == NULL) {\r
+            DSC->Sections = NewSect;\r
+          } else {\r
+            DSC->LastSection->Next = NewSect;\r
+          }\r
+\r
+          DSC->LastSection  = NewSect;\r
+          *End              = SaveChar;\r
+          //\r
+          // If the name ended in a shorthand indicator, then save the\r
+          // section name and truncate it at the last dot.\r
+          //\r
+          if (SaveChar == '|') {\r
+            strcpy (ShortHandSectionName, ThisSectionName);\r
+            for (TempCptr = ShortHandSectionName + strlen (ShortHandSectionName) - 1;\r
+                 (TempCptr != ShortHandSectionName) && (*TempCptr != '.');\r
+                 TempCptr--\r
+                )\r
+              ;\r
+            //\r
+            // If we didn't find a dot, then hopefully they have [name1|name2]\r
+            // instead of [name1,name2].\r
+            //\r
+            if (TempCptr == ShortHandSectionName) {\r
+              ShortHandSectionName[0] = 0;\r
+            } else {\r
+              //\r
+              // Truncate after the dot\r
+              //\r
+              *(TempCptr + 1) = 0;\r
+            }\r
+          } else {\r
+            //\r
+            // Kill the shorthand string\r
+            //\r
+            ShortHandSectionName[0] = 0;\r
+          }\r
+          //\r
+          // Skip to next section name or closing bracket\r
+          //\r
+          while (*End && ((*End == ',') || isspace (*End) || (*End == '|'))) {\r
+            End++;\r
+          }\r
+\r
+          Start = End;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Look through all the sections to make sure we don't have any duplicates.\r
+  // Allow [----] and [====] section separators\r
+  //\r
+  CurrSect = DSC->Sections;\r
+  while (CurrSect != NULL) {\r
+    TempSect = CurrSect->Next;\r
+    while (TempSect != NULL) {\r
+      if (isalpha (CurrSect->Name[0]) && (_stricmp (CurrSect->Name, TempSect->Name) == 0)) {\r
+        Error (\r
+          TempSect->FirstLine->FileName,\r
+          TempSect->FirstLine->LineNum,\r
+          0,\r
+          TempSect->Name,\r
+          "duplicate section found"\r
+          );\r
+        Error (\r
+          CurrSect->FirstLine->FileName,\r
+          CurrSect->FirstLine->LineNum,\r
+          0,\r
+          TempSect->Name,\r
+          "first definition of duplicate section"\r
+          );\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      TempSect = TempSect->Next;\r
+    }\r
+\r
+    CurrSect = CurrSect->Next;\r
+  }\r
+\r
+Done:\r
+  fclose (FilePtr);\r
+  return Status;\r
+}\r
+//\r
+// Free up memory allocated for DSC file handling.\r
+//\r
+static\r
+void\r
+DSCFileFree (\r
+  DSC_FILE *DSC\r
+  )\r
+{\r
+  SECTION       *NextSection;\r
+  SECTION_LINE  *NextLine;\r
+  DSC_FILE_NAME *NextName;\r
+\r
+  while (DSC->Sections != NULL) {\r
+    NextSection = DSC->Sections->Next;\r
+    if (DSC->Sections->Name != NULL) {\r
+      free (DSC->Sections->Name);\r
+    }\r
+\r
+    free (DSC->Sections);\r
+    DSC->Sections = NextSection;\r
+  }\r
+\r
+  while (DSC->Lines != NULL) {\r
+    NextLine = DSC->Lines->Next;\r
+    free (DSC->Lines->Line);\r
+    free (DSC->Lines);\r
+    DSC->Lines = NextLine;\r
+  }\r
+\r
+  while (DSC->FileName != NULL) {\r
+    NextName = DSC->FileName->Next;\r
+    free (DSC->FileName->FileName);\r
+    free (DSC->FileName);\r
+    DSC->FileName = NextName;\r
+  }\r
+}\r
+\r
+SECTION *\r
+DSCFileFindSection (\r
+  DSC_FILE  *DSC,\r
+  char      *Name\r
+  )\r
+{\r
+  SECTION *Sect;\r
+\r
+  //\r
+  // Look through all the sections to find one with this name (case insensitive)\r
+  //\r
+  Sect = DSC->Sections;\r
+  while (Sect != NULL) {\r
+    if (_stricmp (Name, Sect->Name) == 0) {\r
+      //\r
+      // Position within file\r
+      //\r
+      DSC->CurrentLine = Sect->FirstLine->Next;\r
+      return Sect;\r
+    }\r
+\r
+    Sect = Sect->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+int\r
+DSCFileSavePosition (\r
+  DSC_FILE *DSC\r
+  )\r
+{\r
+  //\r
+  // Advance to next slot\r
+  //\r
+  DSC->SavedPositionIndex++;\r
+  if (DSC->SavedPositionIndex >= MAX_SAVES) {\r
+    DSC->SavedPositionIndex--;\r
+    Error (NULL, 0, 0, "APP ERROR", "max nesting of saved section file positions exceeded");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  DSC->SavedPosition[DSC->SavedPositionIndex] = DSC->CurrentLine;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+DSCFileRestorePosition (\r
+  DSC_FILE *DSC\r
+  )\r
+{\r
+  if (DSC->SavedPositionIndex < 0) {\r
+    Error (NULL, 0, 0, "APP ERROR", "underflow of saved positions in section file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  DSC->CurrentLine = DSC->SavedPosition[DSC->SavedPositionIndex];\r
+  DSC->SavedPositionIndex--;\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h
new file mode 100644 (file)
index 0000000..4dcad54
--- /dev/null
@@ -0,0 +1,109 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  DscFile.h\r
+  \r
+Abstract:\r
+\r
+  Defines and function prototypes for the ProcessDsc utility.\r
+  \r
+--*/\r
+\r
+#ifndef _DSC_FILE_H_\r
+#define _DSC_FILE_H_\r
+\r
+typedef struct _SECTION_LINE {\r
+  struct _SECTION_LINE  *Next;\r
+  char                  *Line;\r
+  char                  *FileName;\r
+  UINT32                LineNum;\r
+} SECTION_LINE;\r
+\r
+//\r
+// Use this structure to keep track of parsed file names. Then\r
+// if we get a parse error we can figure out the file/line of\r
+// the error and print a useful message.\r
+//\r
+typedef struct _DSC_FILE_NAME {\r
+  struct _DSC_FILE_NAME *Next;\r
+  char                  *FileName;\r
+} DSC_FILE_NAME;\r
+\r
+//\r
+// We create a list of section names when we pre-parse a description file.\r
+// Use this structure.\r
+//\r
+typedef struct _SECTION {\r
+  struct _SECTION *Next;\r
+  char            *Name;\r
+  SECTION_LINE    *FirstLine;\r
+} SECTION;\r
+\r
+#define MAX_SAVES 4\r
+\r
+typedef struct {\r
+  SECTION_LINE  *SavedPosition[MAX_SAVES];\r
+  int           SavedPositionIndex;\r
+  SECTION       *Sections;\r
+  SECTION_LINE  *Lines;\r
+  SECTION       *LastSection;\r
+  SECTION_LINE  *LastLine;\r
+  SECTION_LINE  *CurrentLine;\r
+  DSC_FILE_NAME *FileName;\r
+  DSC_FILE_NAME *LastFileName;\r
+} DSC_FILE;\r
+\r
+//\r
+// Function prototypes\r
+//\r
+int\r
+DSCFileSetFile (\r
+  DSC_FILE *DSC,\r
+  char     *FileName\r
+  )\r
+;\r
+SECTION *\r
+DSCFileFindSection (\r
+  DSC_FILE *DSC,\r
+  char     *Name\r
+  )\r
+;\r
+int\r
+DSCFileSavePosition (\r
+  DSC_FILE *DSC\r
+  )\r
+;\r
+int\r
+DSCFileRestorePosition (\r
+  DSC_FILE *DSC\r
+  )\r
+;\r
+char    *\r
+DSCFileGetLine (\r
+  DSC_FILE *DSC,\r
+  char     *Line,\r
+  int      LineLen\r
+  )\r
+;\r
+int\r
+DSCFileInit (\r
+  DSC_FILE *DSC\r
+  )\r
+;\r
+int\r
+DSCFileDestroy (\r
+  DSC_FILE *DSC\r
+  )\r
+;\r
+\r
+#endif // ifndef _DSC_FILE_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c
new file mode 100644 (file)
index 0000000..bc50183
--- /dev/null
@@ -0,0 +1,141 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Exceptions.c\r
+\r
+Abstract:\r
+\r
+  Exception logging routines.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h> // for memset()\r
+#include "Exceptions.h"\r
+\r
+//\r
+// Max length of a saved exception message\r
+//\r
+#define MAX_EXCEPTION_MSG 200\r
+\r
+//\r
+// We use this structure to track exceptions thrown. We nest deeper on\r
+// TryException() calls, and come back out on CatchException() calls.\r
+// We save off the first exception message for a given exception level,\r
+// but we save the count of how many were thrown.\r
+//\r
+typedef struct {\r
+  int   ExceptionCount;\r
+  char  ExceptionMsg[MAX_EXCEPTION_MSG];\r
+} EXCEPTION_LOG;\r
+\r
+static EXCEPTION_LOG  ExceptionLog[MAX_EXCEPTION_NESTING + 1];\r
+static int            ExceptionLevel;\r
+\r
+//\r
+// Initialize our data and structures for tracking exceptions.\r
+//\r
+int\r
+InitExceptions (\r
+  VOID\r
+  )\r
+{\r
+  ExceptionLevel = -1;\r
+  memset ((char *) &ExceptionLog, 0, sizeof (ExceptionLog));\r
+  return 0;\r
+}\r
+//\r
+// This function replaces the _try() exception macro. It sets the\r
+// nesting level.\r
+//\r
+int\r
+TryException (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Boost our exception level if we would not go out of range\r
+  //\r
+  ExceptionLevel++;\r
+  if (ExceptionLevel >= MAX_EXCEPTION_NESTING) {\r
+    fprintf (stderr, "ERROR: Max exception nesting level exceeded\n");\r
+    ExceptionLevel--;\r
+    return 1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+//\r
+// This function replaces the _catch() exception macro. It's used to decrement\r
+// the nesting level and return any exeption error messages that were\r
+// thrown at the current nesting level.\r
+//\r
+char *\r
+CatchException (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Return a pointer to exception message. NULL if no exceptions at this level\r
+  //\r
+  if (ExceptionLevel >= 0) {\r
+    ExceptionLevel--;\r
+    if (ExceptionLog[ExceptionLevel + 1].ExceptionMsg[0]) {\r
+      return ExceptionLog[ExceptionLevel + 1].ExceptionMsg;\r
+    } else {\r
+      return NULL;\r
+    }\r
+  } else {\r
+    fprintf (stderr, "ERROR: Invalid nesting level call to CatchException()\n");\r
+    return NULL;\r
+  }\r
+}\r
+//\r
+// This function can be used to test for exceptions between the TryException()\r
+// and CatchException() calls in a given function.\r
+//\r
+int\r
+ExceptionThrown (\r
+  VOID\r
+  )\r
+{\r
+  return ExceptionLog[ExceptionLevel].ExceptionCount;\r
+}\r
+//\r
+// This function replaces the _throw() exception macro. It saves off the\r
+// given error message at the current exeption level nesting.\r
+//\r
+int\r
+ThrowException (\r
+  char *Msg\r
+  )\r
+{\r
+  if (ExceptionLevel < 0) {\r
+    //\r
+    // fprintf (stderr, "ERROR: Exception thrown out of scope");\r
+    // Haven't yet enabled handling of exceptions, so just emit the message.\r
+    //\r
+    fprintf (stderr, Msg);\r
+    return 1;\r
+  }\r
+  //\r
+  // Only log the first\r
+  //\r
+  if (ExceptionLog[ExceptionLevel].ExceptionMsg[0] == 0) {\r
+    strncpy (ExceptionLog[ExceptionLevel].ExceptionMsg, Msg, MAX_EXCEPTION_MSG);\r
+  }\r
+\r
+  ExceptionLog[ExceptionLevel].ExceptionCount++;\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h
new file mode 100644 (file)
index 0000000..1425d43
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  Exceptions.h\r
+  \r
+Abstract:\r
+\r
+  Defines and function prototypes for the ProcessDsc utility.\r
+  \r
+--*/\r
+\r
+#ifndef _EXCEPTIONS_H_\r
+#define _EXCEPTIONS_H_\r
+\r
+#define VOID void\r
+#define MAX_EXCEPTION_NESTING 4\r
+\r
+//\r
+// Function prototypes\r
+//\r
+int\r
+InitExceptions (\r
+  VOID\r
+  )\r
+;\r
+int\r
+TryException (\r
+  VOID\r
+  )\r
+;\r
+char  *\r
+CatchException (\r
+  VOID\r
+  )\r
+;\r
+int\r
+ExceptionThrown (\r
+  VOID\r
+  )\r
+;\r
+int\r
+ThrowException (\r
+  char *EMsg\r
+  )\r
+;\r
+\r
+#endif // ifndef _EXCEPTIONS_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
new file mode 100644 (file)
index 0000000..28baf55
--- /dev/null
@@ -0,0 +1,1566 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FWVolume.c\r
+\r
+Abstract:\r
+\r
+  This module contains functionality to keep track of files destined for\r
+  multiple firmware volues. It saves them up, and when told to, dumps the\r
+  file names out to some files used as input to other utilities that\r
+  actually generate the FVs.\r
+\r
+--*/\r
+\r
+#include <windows.h>                        // for max_path definition\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>                         // for malloc()\r
+#include "Common.h"\r
+#include "DSCFile.h"\r
+#include "FWVolume.h"\r
+\r
+#define FV_INF_DIR          "FV_INF_DIR"    // symbol for where we create the FV INF file\r
+#define FV_FILENAME         "FV_FILENAME"   // symbol for the current FV.INF filename\r
+#define EFI_BASE_ADDRESS    "EFI_BASE_ADDRESS"\r
+#define DEFAULT_FV_INF_DIR  "FV"            // default dir for where we create the FV INF file\r
+#define DEFAULT_FV_DIR      "$(BUILD_DIR)"  // where the FV file comes from\r
+#define MALLOC(size)        malloc (size)\r
+#define FREE(ptr)           free (ptr)\r
+\r
+//\r
+// Disable warning for unused function arguments\r
+//\r
+#pragma warning(disable : 4100)\r
+//\r
+// Disable warning for while(1) code\r
+//\r
+// #pragma warning (disable : 4127)\r
+//\r
+typedef struct {\r
+  char  *ComponentType;\r
+  char  *Extension;\r
+} COMP_TYPE_EXTENSION;\r
+\r
+//\r
+// Use a linked list of these to keep track of all the FV names used\r
+//\r
+typedef struct _FV_LIST {\r
+  struct _FV_LIST *Next;\r
+  char            FVFileName[MAX_PATH];\r
+  char            BaseAddress[MAX_LINE_LEN];\r
+  SMART_FILE      *FVFilePtr;\r
+  SMART_FILE      *AprioriFilePtr;\r
+  char            *Processor;\r
+  int             ComponentsInstance; // highest [components.n] section with a file for this FV\r
+} FV_LIST;\r
+\r
+//\r
+// Use a linked list of these to keep track of all FFS files built. When\r
+// we're done, we turn the info into the FV INF files used to build the\r
+// firmware volumes.\r
+//\r
+typedef struct _FILE_LIST {\r
+  struct _FILE_LIST *Next;\r
+  char              *FileName;\r
+  char              *BaseFileName;\r
+  char              *FVs;               // from FV=x,y,z\r
+  char              *BaseName;          // only needed for duplicate basename check\r
+  char              *Processor;         // only needed for duplicate basename check\r
+  char              Apriori[100];       // of format "FVRecovery:1,FVMain:2" from APRIORI define\r
+  char              *Guid;              // guid string\r
+  int               ComponentsInstance; // which [components.n] section it's in\r
+} FILE_LIST;\r
+\r
+typedef struct _LINKED_LIST {\r
+  struct _LINKED_LIST *Next;\r
+  void                *Data;\r
+} LINKED_LIST;\r
+\r
+static FILE_LIST                  *mFileList;\r
+static FILE_LIST                  *mLastFile;\r
+static char                       *mXRefFileName  = NULL;\r
+static FV_LIST                    *mNonFfsFVList  = NULL;\r
+\r
+//\r
+// Whenever an FV name is referenced, then add it to our list of known\r
+// FV's using these.\r
+//\r
+static FV_LIST                    *mFVList      = NULL;\r
+static FV_LIST                    *mFVListLast  = NULL;\r
+\r
+//\r
+// We use this list so that from a given component type, we can determine\r
+// the name of the file on disk. For example, if we're given a file's\r
+// guid and base name, and we know it's a "bs_driver", then we can look\r
+// up "bs_driver" in this array and know that the file (after it's built)\r
+// name is GUID-BASENAME.DXE\r
+//\r
+static const COMP_TYPE_EXTENSION  mCompTypeExtension[] = {\r
+  {\r
+    "bs_driver",\r
+    ".dxe"\r
+  },\r
+  {\r
+    "rt_driver",\r
+    ".dxe"\r
+  },\r
+  {\r
+    "sal_rt_driver",\r
+    ".dxe"\r
+  },\r
+  {\r
+    "security_core",\r
+    ".sec"\r
+  },\r
+  {\r
+    "pei_core",\r
+    ".pei"\r
+  },\r
+  {\r
+    "pic_peim",\r
+    ".pei"\r
+  },\r
+  {\r
+    "pe32_peim",\r
+    ".pei"\r
+  },\r
+  {\r
+    "relocatable_peim",\r
+    ".pei"\r
+  },\r
+  {\r
+    "binary",\r
+    ".ffs"\r
+  },\r
+  {\r
+    "application",\r
+    ".app"\r
+  },\r
+  {\r
+    "file",\r
+    ".ffs"\r
+  },\r
+  {\r
+    "fvimagefile",\r
+    ".fvi"\r
+  },\r
+  {\r
+    "rawfile",\r
+    ".raw"\r
+  },\r
+  {\r
+    "apriori",\r
+    ".ffs"\r
+  },\r
+  {\r
+    "combined_peim_driver",\r
+    ".pei"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+static\r
+void\r
+CFVFreeFileList (\r
+  VOID\r
+  );\r
+\r
+static\r
+char                              *\r
+UpperCaseString (\r
+  char *Str\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+InSameFv (\r
+  char  *FVs1,\r
+  char  *FVs2\r
+);\r
+\r
+static\r
+void\r
+AddFirmwareVolumes (\r
+  char          *FVs,\r
+  int           ComponentsInstance,\r
+  FILE_LIST     *FileListPtr\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+OrderInFvList (\r
+  char    *FvList,\r
+  char    *FvName,\r
+  int     *Order\r
+  );\r
+\r
+int\r
+GetBaseAddress (\r
+  char *Name,\r
+  char *BaseAddress\r
+  )\r
+{\r
+  char  *Start;\r
+  char  *Cptr;\r
+  char  CSave;\r
+  char  *Value;\r
+\r
+  Start = Name;\r
+  while (*Name && isspace (*Name)) {\r
+    Name++;\r
+  }\r
+\r
+  if (!*Name) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Find the end of the name. Either space or a '='.\r
+  //\r
+  for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++)\r
+    ;\r
+  if (!*Value) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Look for the '='\r
+  //\r
+  Cptr = Value;\r
+  while (*Value && (*Value != '=')) {\r
+    Value++;\r
+  }\r
+\r
+  if (!*Value) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now truncate the name\r
+  //\r
+  CSave = *Cptr;\r
+  *Cptr = 0;\r
+  if (_stricmp (Name, EFI_BASE_ADDRESS) != 0) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  *Cptr = CSave;\r
+  //\r
+  // Skip over the = and then any spaces\r
+  //\r
+  Value++;\r
+  while (*Value && isspace (*Value)) {\r
+    Value++;\r
+  }\r
+  //\r
+  // Find end of string, checking for quoted string\r
+  //\r
+  if (*Value == '\"') {\r
+    Value++;\r
+    for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++)\r
+      ;\r
+  } else {\r
+    for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++)\r
+      ;\r
+  }\r
+  //\r
+  // Null terminate the value string\r
+  //\r
+  CSave = *Cptr;\r
+  *Cptr = 0;\r
+  strcpy (BaseAddress, Value);\r
+  *Cptr = CSave;\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+CFVAddFVFile (\r
+  char  *Name,\r
+  char  *ComponentType,\r
+  char  *FVs,\r
+  int   ComponentsInstance,\r
+  char  *FFSExt,\r
+  char  *Processor,\r
+  char  *Apriori,\r
+  char  *BaseName,\r
+  char  *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a file to the list of files in one or more firmware volumes.\r
+\r
+Arguments:\r
+\r
+  Name          - $(FILE_GUID)-$(BASE_NAME), or filename\r
+  ComponentType - type of component being added. Required so we know the\r
+                  resultant file name after it has been built\r
+  FVs           - string of commma-separated FVs that the given file is\r
+                  to be added to. For example, FVs="FV0001,FV0002"\r
+  FFSExt        - FFS filename extension of the file after it has been built.\r
+                  This is passed in to us in case we don't know the default\r
+                  filename extension based on the component type.\r
+  Processor     - the target processor which the FV is being built for\r
+  Apriori       - pointer to the definition of APRIORI. For example APRIORI="FvRecovery:1,FvMain:4"\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS if successful\r
+\r
+--*/\r
+{\r
+  FILE_LIST *Ptr;\r
+  char      FileName[MAX_PATH];\r
+  char      Str[MAX_PATH];\r
+  int       i;\r
+  char      *Sym;\r
+\r
+  // If they provided a filename extension for this type of file, then use it.\r
+  // If they did not provide a filename extension, search our list for a\r
+  // matching component type and use the extension appropriate for this\r
+  // component type.\r
+  //\r
+  if (FFSExt == NULL) {\r
+    //\r
+    // They didn't give us a filename extension. Figure it out from the\r
+    // component type.\r
+    //\r
+    for (i = 0; mCompTypeExtension[i].ComponentType != NULL; i++) {\r
+      if (_stricmp (ComponentType, mCompTypeExtension[i].ComponentType) == 0) {\r
+        FFSExt = mCompTypeExtension[i].Extension;\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If we don't know the file extension, then error out. Just means\r
+    // the need to define "FFS_EXT = raw" in the component INF file.\r
+    //\r
+    if (mCompTypeExtension[i].ComponentType == NULL) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        ComponentType,\r
+        "unknown component type - must define FFS_EXT for built filename extension in component INF file"\r
+        );\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // We now have all the parts to the FFS filename. Prepend the path to it if\r
+  // it's not a full pathname.\r
+  // See if they overrode the default base directory for the FV files.\r
+  //\r
+  if (!IsAbsolutePath (Name)) {\r
+    Sym = GetSymbolValue (FV_DIR);\r
+    if (Sym == NULL) {\r
+      Sym = DEFAULT_FV_DIR;\r
+    }\r
+    //\r
+    // Create the file path. Something like $(BUILD_DIR)\$(PROCESSOR)\$(GUID)-$(BASE_NAME).ext\r
+    // If the extension is non-zero length, then make sure there's a dot in it.\r
+    //\r
+    if ((strlen (FFSExt) > 0) && (FFSExt[0] != '.')) {\r
+      sprintf (Str, "%s\\%s\\%s.%s", Sym, Processor, Name, FFSExt);\r
+    } else {\r
+      sprintf (Str, "%s\\%s\\%s%s", Sym, Processor, Name, FFSExt);\r
+    }\r
+\r
+    ExpandSymbols (Str, FileName, sizeof (FileName), EXPANDMODE_NO_UNDEFS);\r
+  } else {\r
+    strcpy (FileName, Name);\r
+  }\r
+  //\r
+  // Traverse the list of files we have so far and make sure we don't have\r
+  // any duplicate basenames. If the base name and processor match, then we'll\r
+  // have build issues, so don't allow it. We also don't allow the same file GUID\r
+  // in the same FV which will cause boot time error if we allow this.\r
+  //\r
+  Ptr = mFileList;\r
+  while (Ptr != NULL) {\r
+    if ((Ptr->BaseName != NULL) && (BaseName != NULL) && (_stricmp (BaseName, Ptr->BaseName) == 0)) {\r
+      if ((Ptr->Processor != NULL) && (Processor != NULL) && (_stricmp (Processor, Ptr->Processor) == 0)) {\r
+        Error (NULL, 0, 0, BaseName, "duplicate base name specified");\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+    \r
+    if ((Ptr->Guid != NULL) && (Guid != NULL) && (_stricmp (Guid, Ptr->Guid) == 0)) {\r
+      if ((Ptr->FVs != NULL) && (FVs != NULL) && (InSameFv (FVs, Ptr->FVs))) {\r
+        Error (NULL, 0, 0, Guid, "duplicate Guid specified in the same FV for %s and %s", \r
+               (Ptr->BaseName==NULL)?"Unknown":Ptr->BaseName, \r
+               (BaseName==NULL)?"Unknown":BaseName);\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+\r
+    Ptr = Ptr->Next;\r
+  }\r
+  //\r
+  // Allocate a new structure so we can add this file to the list of\r
+  // files.\r
+  //\r
+  Ptr = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
+  if (Ptr == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) Ptr, 0, sizeof (FILE_LIST));\r
+  Ptr->FileName = (char *) malloc (strlen (FileName) + 1);\r
+  if (Ptr->FileName == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (Ptr->FileName, FileName);\r
+  Ptr->ComponentsInstance = ComponentsInstance;\r
+  //\r
+  // Allocate memory to save the FV list if it's going into an FV.\r
+  //\r
+  if ((FVs != NULL) && (FVs[0] != 0)) {\r
+    Ptr->FVs = (char *) malloc (strlen (FVs) + 1);\r
+    if (Ptr->FVs == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (Ptr->FVs, FVs);\r
+  }\r
+\r
+  Ptr->BaseFileName = (char *) malloc (strlen (Name) + 1);\r
+  if (Ptr->BaseFileName == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (Ptr->BaseFileName, Name);\r
+  //\r
+  // Allocate memory for the basename if they gave us one. May not have one\r
+  // if the user is simply adding pre-existing binary files to the image.\r
+  //\r
+  if (BaseName != NULL) {\r
+    Ptr->BaseName = (char *) malloc (strlen (BaseName) + 1);\r
+    if (Ptr->BaseName == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (Ptr->BaseName, BaseName);\r
+  }\r
+  //\r
+  // Allocate memory for the processor name\r
+  //\r
+  if (Processor != NULL) {\r
+    Ptr->Processor = (char *) malloc (strlen (Processor) + 1);\r
+    if (Ptr->Processor == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (Ptr->Processor, Processor);\r
+  }\r
+  //\r
+  // Allocate memory for the guid name\r
+  //\r
+  if (Guid != NULL) {\r
+    Ptr->Guid = (char *) malloc (strlen (Guid) + 1);\r
+    if (Ptr->Guid == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (Ptr->Guid, Guid);\r
+  }\r
+  //\r
+  // If non-null apriori symbol, then save the apriori list for this file\r
+  //\r
+  if (Apriori != NULL) {\r
+    strcpy (Ptr->Apriori, Apriori);\r
+  }\r
+\r
+  if (mFileList == NULL) {\r
+    mFileList = Ptr;\r
+  } else {\r
+    mLastFile->Next = Ptr;\r
+  }\r
+\r
+  mLastFile = Ptr;\r
+  //\r
+  // Add these firmware volumes to the list of known firmware\r
+  // volume names.\r
+  //\r
+  AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+void\r
+CFVConstructor (\r
+  VOID\r
+  )\r
+{\r
+  mFileList = NULL;\r
+  mLastFile = NULL;\r
+}\r
+\r
+void\r
+CFVDestructor (\r
+  VOID\r
+  )\r
+{\r
+  CFVFreeFileList ();\r
+  //\r
+  // Free up our firmware volume list\r
+  //\r
+  while (mFVList != NULL) {\r
+    mFVListLast = mFVList->Next;\r
+    FREE (mFVList);\r
+    mFVList = mFVListLast;\r
+  }\r
+}\r
+\r
+static\r
+void\r
+CFVFreeFileList (\r
+  VOID\r
+  )\r
+{\r
+  FILE_LIST *Next;\r
+  while (mFileList != NULL) {\r
+    if (mFileList->FileName != NULL) {\r
+      free (mFileList->FileName);\r
+    }\r
+\r
+    if (mFileList->FVs != NULL) {\r
+      free (mFileList->FVs);\r
+    }\r
+\r
+    free (mFileList->BaseFileName);\r
+    if (mFileList->BaseName != NULL) {\r
+      free (mFileList->BaseName);\r
+    }\r
+\r
+    if (mFileList->Processor != NULL) {\r
+      free (mFileList->Processor);\r
+    }\r
+\r
+    if (mFileList->Guid != NULL) {\r
+      free (mFileList->Guid);\r
+    }\r
+\r
+    Next = mFileList->Next;\r
+    free (mFileList);\r
+    mFileList = Next;\r
+  }\r
+\r
+  mFileList = NULL;\r
+}\r
+\r
+int\r
+CFVWriteInfFiles (\r
+  DSC_FILE  *DSC,\r
+  FILE      *MakeFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  After processing all components in a DSC file, create the firmware\r
+  volume INF files. We actually do a lot more here.\r
+\r
+  * Create the FVxxx.inf file that is used by GenFvImage\r
+  * Create the Apriori files for each firmware volume that requires one\r
+  * Create makefile.out macros for FVxxx_FILES = FVxxx_FILES AnotherFile\r
+    so you can do incremental builds of firmware volumes.\r
+  * For each FV, emit its build commands to makefile.out\r
+\r
+Arguments:\r
+\r
+  DSC       - pointer to a DSC_FILE object to extract info from\r
+  MakeFptr  - pointer to the output makefile\r
+\r
+Returns:\r
+\r
+  0  if successful\r
+  non-zero otherwise\r
+\r
+--*/\r
+{\r
+  FILE_LIST *FileListPtr;\r
+  FV_LIST   *FVList;\r
+  FV_LIST   *LastFVList;\r
+  FV_LIST   *FVPtr;\r
+  SECTION   *Section;\r
+  char      *StartCptr;\r
+  char      *EndCptr;\r
+  char      CSave;\r
+  char      Str[MAX_PATH];\r
+  char      Line[MAX_LINE_LEN];\r
+  char      ExpandedLine[MAX_LINE_LEN];\r
+  char      FVDir[MAX_PATH];\r
+  FILE      *XRefFptr;\r
+  int       AprioriCounter;\r
+  int       AprioriCount;\r
+  int       AprioriPosition;\r
+  BOOLEAN   AprioriFound;\r
+  int       ComponentsInstance;\r
+  int       ComponentCount;\r
+\r
+  //\r
+  // Use this to keep track of all the firmware volume names\r
+  //\r
+  FVList      = NULL;\r
+  LastFVList  = NULL;\r
+  //\r
+  // See if they specified a FV directory to dump the FV files out to. If not,\r
+  // then use the default. Then create the output directory.\r
+  //\r
+  StartCptr = GetSymbolValue (FV_INF_DIR);\r
+  if (StartCptr == NULL) {\r
+    ExpandSymbols (DEFAULT_FV_INF_DIR, FVDir, sizeof (FVDir), EXPANDMODE_NO_UNDEFS);\r
+  } else {\r
+    strcpy (FVDir, StartCptr);\r
+  }\r
+  //\r
+  // Make sure the fv directory path ends in /\r
+  //\r
+  CSave = FVDir[strlen (FVDir) - 1];\r
+  if ((CSave != '\\') && (CSave != '/')) {\r
+    strcat (FVDir, "\\");\r
+  }\r
+  //\r
+  // Traverse the list of all files, determine which FV each is in, then\r
+  // write out the file's name to the output FVxxx.inf file.\r
+  //\r
+  for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+    //\r
+    // Parse all the "FV1,FV2..." in the FVs\r
+    //\r
+    if (FileListPtr->FVs != NULL) {\r
+      //\r
+      // Process each fv this file is in\r
+      //\r
+      StartCptr = FileListPtr->FVs;\r
+      while (*StartCptr) {\r
+        EndCptr = StartCptr;\r
+        while (*EndCptr && (*EndCptr != ',')) {\r
+          EndCptr++;\r
+        }\r
+\r
+        CSave     = *EndCptr;\r
+        *EndCptr  = 0;\r
+        //\r
+        // Ok, we have a fv name, now see if we've already opened\r
+        // an fv output file of this name.\r
+        //\r
+        for (FVPtr = FVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
+          if (_stricmp (FVPtr->FVFileName, StartCptr) == 0) {\r
+            break;\r
+          }\r
+        }\r
+        //\r
+        // If we didn't find one, then create a new one\r
+        //\r
+        if (FVPtr == NULL) {\r
+          //\r
+          // Create a new one, add it to the list\r
+          //\r
+          FVPtr = (FV_LIST *) malloc (sizeof (FV_LIST));\r
+          if (FVPtr == NULL) {\r
+            Error (NULL, 0, 0, NULL, "failed to allocate memory for FV");\r
+            return STATUS_ERROR;\r
+          }\r
+\r
+          memset ((char *) FVPtr, 0, sizeof (FV_LIST));\r
+          //\r
+          // Add it to the end of our list\r
+          //\r
+          if (FVList == NULL) {\r
+            FVList = FVPtr;\r
+          } else {\r
+            LastFVList->Next = FVPtr;\r
+          }\r
+\r
+          LastFVList = FVPtr;\r
+          //\r
+          // Save the FV name in the FileName pointer so we can compare\r
+          // for any future FV names specified.\r
+          //\r
+          strcpy (FVPtr->FVFileName, StartCptr);\r
+\r
+          //\r
+          // Add a symbol for the FV filename\r
+          //\r
+          UpperCaseString (FVPtr->FVFileName);\r
+          AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE);\r
+          //\r
+          // Now create the FVx.inf filename from the fv name and\r
+          // default filename extension. Dump it in the FV directory\r
+          // as well.\r
+          //\r
+          strcpy (Str, FVDir);\r
+          strcat (Str, FVPtr->FVFileName);\r
+          strcat (Str, ".inf");\r
+          //\r
+          // Create the directory path for our new fv.inf output file.\r
+          //\r
+          MakeFilePath (Str);\r
+          if ((FVPtr->FVFilePtr = SmartOpen (Str)) == NULL) {\r
+            Error (NULL, 0, 0, Str, "could not open FV output file");\r
+            return STATUS_ERROR;\r
+          }\r
+          //\r
+          // Now copy the [fv.$(FV).options] to the fv INF file\r
+          //\r
+          sprintf (Str, "fv.%s.options", StartCptr);\r
+          Section = DSCFileFindSection (DSC, Str);\r
+          if (Section != NULL) {\r
+            SmartWrite (FVPtr->FVFilePtr, "[options]\n");\r
+            while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+              ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0);\r
+              SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+              GetBaseAddress (ExpandedLine, FVPtr->BaseAddress);\r
+            }\r
+          } else {\r
+            Error (NULL, 0, 0, Str, "could not find FV section in description file");\r
+          }\r
+          //\r
+          // Copy the [fv.$(FV).attributes] to the fv INF file\r
+          //\r
+          sprintf (Str, "fv.%s.attributes", StartCptr);\r
+          Section = DSCFileFindSection (DSC, Str);\r
+          if (Section != NULL) {\r
+            SmartWrite (FVPtr->FVFilePtr, "[attributes]\n");\r
+            while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+              ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0);\r
+              SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+            }\r
+          } else {\r
+            Error (NULL, 0, 0, Str, "Could not find FV section in description file");\r
+          }\r
+          //\r
+          // Start the files section\r
+          //\r
+          SmartWrite (FVPtr->FVFilePtr, "\n[files]\n");\r
+        }\r
+        //\r
+        // Now write the FV filename to the FV.inf file. Prepend $(PROCESSOR) on\r
+        // it.\r
+        //\r
+        sprintf (ExpandedLine, "EFI_FILE_NAME = %s\n", FileListPtr->FileName);\r
+        SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+\r
+        //\r
+        // Next FV on the FV list\r
+        //\r
+        *EndCptr  = CSave;\r
+        StartCptr = EndCptr;\r
+        if (*StartCptr) {\r
+          StartCptr++;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Now we walk the list of firmware volumes and create the APRIORI list\r
+  // file for it .\r
+  //\r
+  for (FVPtr = FVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
+    //\r
+    // Run through all the files and count up how many are to be\r
+    // added to the apriori list for this FV. Then when we're done\r
+    // we'll make sure we processed them all. We do this in case they\r
+    // skipped an apriori index for a given FV.\r
+    //\r
+    AprioriCount = 0;\r
+    for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+      if (OrderInFvList (FileListPtr->Apriori, FVPtr->FVFileName, &AprioriPosition)) {\r
+        //\r
+        // Emit an error if the index was 0, or they didn't give one.\r
+        //\r
+        if (AprioriPosition == 0) {\r
+          Error (\r
+            GetSymbolValue (DSC_FILENAME),\r
+            1,\r
+            0,\r
+            "apriori indexes are 1-based",\r
+            "component %s:APRIORI=%s",\r
+            FileListPtr->BaseName,\r
+            FileListPtr->Apriori\r
+            );\r
+        } else {\r
+          AprioriCount++;\r
+        }\r
+\r
+      }\r
+    }\r
+    //\r
+    // Now scan the files as we increment our apriori index\r
+    //\r
+    AprioriCounter = 0;\r
+    do {\r
+      AprioriFound = 0;\r
+      AprioriCounter++;\r
+      for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+        //\r
+        // If in the apriori list for this fv, print the name. Open the\r
+        // file first if we have to.\r
+        //\r
+        if ((FileListPtr->Apriori[0] != 0) &&\r
+            (OrderInFvList (FileListPtr->Apriori, FVPtr->FVFileName, &AprioriPosition))\r
+            ) {\r
+          if (AprioriPosition == AprioriCounter) {\r
+            //\r
+            // If we've already found one for this index, emit an error. Decrement the\r
+            // count of how files we are to process so we don't emit another error for\r
+            // a miscount below.\r
+            //\r
+            if (AprioriFound) {\r
+              Error (\r
+                GetSymbolValue (DSC_FILENAME),\r
+                1,\r
+                0,\r
+                "duplicate apriori index found",\r
+                "%s:%d",\r
+                FVPtr->FVFileName,\r
+                AprioriCounter\r
+                );\r
+              AprioriCount--;\r
+            }\r
+\r
+            AprioriFound = 1;\r
+            //\r
+            // Open the apriori output file if we haven't already\r
+            //\r
+            if (FVPtr->AprioriFilePtr == NULL) {\r
+              strcpy (Str, FVDir);\r
+              strcat (Str, FVPtr->FVFileName);\r
+              strcat (Str, ".apr");\r
+              if ((FVPtr->AprioriFilePtr = SmartOpen (Str)) == NULL) {\r
+                Error (NULL, 0, 0, Str, "could not open output Apriori file for writing");\r
+                return STATUS_ERROR;\r
+              }\r
+            }\r
+            \r
+            sprintf (ExpandedLine, "%s\n", FileListPtr->BaseFileName);\r
+            SmartWrite (FVPtr->AprioriFilePtr, ExpandedLine);\r
+          }\r
+        }\r
+      }\r
+    } while (AprioriFound);\r
+    //\r
+    // See if they skipped an apriori position for this FV\r
+    //\r
+    if (AprioriCount != (AprioriCounter - 1)) {\r
+      Error (\r
+        GetSymbolValue (DSC_FILENAME),\r
+        1,\r
+        0,\r
+        "apriori index skipped",\r
+        "%s:%d",\r
+        FVPtr->FVFileName,\r
+        AprioriCounter\r
+        );\r
+    }\r
+  }\r
+  //\r
+  // Traverse the list of all files again, and create a macro in the output makefile\r
+  // that defines all the files in each fv. For example, for each FV file, create a line:\r
+  // FV0001_FILES = $(FV_0001_FILES) xxxx-yyy.dxe.\r
+  // This can then be used as a dependency in their makefile.\r
+  // Also if they wanted us to dump a cross-reference, do that now.\r
+  //\r
+  if (mXRefFileName != NULL) {\r
+    if ((XRefFptr = fopen (mXRefFileName, "w")) == NULL) {\r
+      Message (\r
+        0,\r
+        "Failed to open cross-reference file '%s' for writing\n",\r
+        mXRefFileName\r
+        );\r
+    }\r
+  } else {\r
+    XRefFptr = NULL;\r
+  }\r
+\r
+  for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+    //\r
+    // Parse all the "FV1,FV2..." in the FV field that came from FV=FVa,FVb,... on the\r
+    // component line in the DSC file.\r
+    //\r
+    if (FileListPtr->FVs != NULL) {\r
+      //\r
+      // If generating a cross-reference file, dump the data\r
+      //\r
+      if (XRefFptr != NULL) {\r
+        if ((FileListPtr->Guid != NULL) && (FileListPtr->BaseName != NULL) && (FileListPtr->Processor)) {\r
+          fprintf (\r
+            XRefFptr,\r
+            "%s %s %s\n",\r
+            FileListPtr->Guid,\r
+            FileListPtr->BaseName,\r
+            FileListPtr->Processor\r
+            );\r
+        }\r
+      }\r
+      //\r
+      // Convert to uppercase since we're going to use the name as a macro variable name\r
+      // in the makefile.\r
+      //\r
+      UpperCaseString (FileListPtr->FVs);\r
+      //\r
+      // Process each FV this file is in to write fvxxx_FILES = $(fvxxx_FILES) Guid-BaseName.ffs\r
+      //\r
+      StartCptr = FileListPtr->FVs;\r
+      while (*StartCptr) {\r
+        EndCptr = StartCptr;\r
+        while (*EndCptr && (*EndCptr != ',')) {\r
+          EndCptr++;\r
+        }\r
+\r
+        CSave     = *EndCptr;\r
+        *EndCptr  = 0;\r
+        fprintf (\r
+          MakeFptr,\r
+          "%s_FILES = $(%s_FILES) %s\n",\r
+          StartCptr,\r
+          StartCptr,\r
+          FileListPtr->FileName\r
+          );\r
+        //\r
+        // Next FV on the FV list\r
+        //\r
+        *EndCptr  = CSave;\r
+        StartCptr = EndCptr;\r
+        if (*StartCptr) {\r
+          StartCptr++;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fprintf (MakeFptr, "\n");\r
+\r
+  //\r
+  // Now go through the list of all NonFFS FVs they specified and search for\r
+  // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the\r
+  // output makefile. Add them to the "fvs" target as well.\r
+  //\r
+  if (mNonFfsFVList != NULL) {\r
+    fprintf (MakeFptr, "fvs ::");\r
+    FVPtr = mNonFfsFVList;\r
+    while (FVPtr != NULL) {\r
+      fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
+      FVPtr = FVPtr->Next;\r
+    }\r
+\r
+    fprintf (MakeFptr, "\n\n");\r
+    FVPtr = mNonFfsFVList;\r
+    while (FVPtr != NULL) {\r
+      //\r
+      // Save the position in the file\r
+      //\r
+      DSCFileSavePosition (DSC);\r
+      //\r
+      // first try to find a build section specific for this fv.\r
+      //\r
+      sprintf (Str, "build.fv.%s", FVPtr->FVFileName);\r
+      Section = DSCFileFindSection (DSC, Str);\r
+      if (Section == NULL) {\r
+        sprintf (Str, "build.fv");\r
+        Section = DSCFileFindSection (DSC, Str);\r
+      }\r
+\r
+      if (Section == NULL) {\r
+        Warning (\r
+          NULL,\r
+          0,\r
+          0,\r
+          NULL,\r
+          "No [build.fv.%s] nor [%s] section found in description file for building %s",\r
+          FVPtr->FVFileName,\r
+          Str,\r
+          FVPtr->FVFileName\r
+          );\r
+      } else {\r
+        //\r
+        // Add a symbol for the FV filename\r
+        //\r
+        UpperCaseString (FVPtr->FVFileName);\r
+        AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE);\r
+        AddSymbol (EFI_BASE_ADDRESS, FVPtr->BaseAddress, SYM_LOCAL | SYM_OVERWRITE);\r
+\r
+        //\r
+        // Now copy the build commands from the section to the makefile\r
+        //\r
+        while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+          ExpandSymbols (\r
+            Line,\r
+            ExpandedLine,\r
+            sizeof (ExpandedLine),\r
+            EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+            );\r
+\r
+          fprintf (MakeFptr, ExpandedLine);\r
+        }\r
+      }\r
+\r
+      FVPtr = FVPtr->Next;\r
+      DSCFileRestorePosition (DSC);\r
+    }\r
+  }\r
+  //\r
+  // Go through our list of firmware volumes and create an "fvs" target that\r
+  // builds everything. It has to be a mix of components and FV's in order.\r
+  // For example:  fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv\r
+  //\r
+  ComponentsInstance  = 0;\r
+  ComponentCount      = 0;\r
+  fprintf (MakeFptr, "fvs ::");\r
+  for (;;) {\r
+    //\r
+    // First see if we have any components for this section. If we don't,\r
+    // then we're done\r
+    //\r
+    for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+      if (FileListPtr->ComponentsInstance == ComponentsInstance) {\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (FileListPtr == NULL) {\r
+      break;\r
+    }\r
+\r
+    fprintf (MakeFptr, " components_%d", ComponentsInstance);\r
+    ComponentCount++;\r
+    //\r
+    // Now print any firmware volumes that match this components instance\r
+    //\r
+    for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
+      if (FVPtr->ComponentsInstance == ComponentsInstance) {\r
+        fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
+      }\r
+    }\r
+\r
+    ComponentsInstance++;\r
+  }\r
+\r
+  fprintf (MakeFptr, "\n\n");\r
+\r
+  //\r
+  // Create a "components" target for build convenience. It should\r
+  // look something like:\r
+  // components : components_0 components_1...\r
+  //\r
+  if (ComponentCount > 0) {\r
+    fprintf (MakeFptr, "components :");\r
+    for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {\r
+      fprintf (MakeFptr, " components_%d", ComponentsInstance);\r
+    }\r
+\r
+    fprintf (MakeFptr, "\n\n");\r
+  }\r
+  //\r
+  // Now go through the list of all FV's defined and search for\r
+  // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the\r
+  // output makefile.\r
+  //\r
+  FVPtr = mFVList;\r
+  while (FVPtr != NULL) {\r
+    if (FVPtr->FVFileName[0]) {\r
+      //\r
+      // Save the position in the file\r
+      //\r
+      DSCFileSavePosition (DSC);\r
+      //\r
+      // First try to find a build section specific for this FV.\r
+      //\r
+      sprintf (Str, "build.fv.%s", FVPtr->FVFileName);\r
+      Section = DSCFileFindSection (DSC, Str);\r
+      if (Section == NULL) {\r
+        sprintf (Str, "build.fv");\r
+        Section = DSCFileFindSection (DSC, Str);\r
+      }\r
+\r
+      if (Section == NULL) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          NULL,\r
+          "no [build.fv.%s] nor [%s] section found in description file for building %s",\r
+          FVPtr->FVFileName,\r
+          Str,\r
+          FVPtr->FVFileName\r
+          );\r
+      } else {\r
+        //\r
+        // Add a symbol for the FV filename\r
+        //\r
+        UpperCaseString (FVPtr->FVFileName);\r
+        AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE);\r
+        AddSymbol (EFI_BASE_ADDRESS, FVPtr->BaseAddress, SYM_LOCAL | SYM_OVERWRITE);\r
+\r
+        //\r
+        // Now copy the build commands from the section to the makefile\r
+        //\r
+        while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+          ExpandSymbols (\r
+            Line,\r
+            ExpandedLine,\r
+            sizeof (ExpandedLine),\r
+            EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+            );\r
+          fprintf (MakeFptr, ExpandedLine);\r
+        }\r
+      }\r
+\r
+      DSCFileRestorePosition (DSC);\r
+    }\r
+\r
+    FVPtr = FVPtr->Next;\r
+  }\r
+  //\r
+  // Close all the files and free up the memory\r
+  //\r
+  while (FVList != NULL) {\r
+    FVPtr = FVList->Next;\r
+    if (FVList->FVFilePtr != NULL) {\r
+      SmartClose (FVList->FVFilePtr);\r
+    }\r
+\r
+    if (FVList->AprioriFilePtr != NULL) {\r
+      SmartClose (FVList->AprioriFilePtr);\r
+    }\r
+\r
+    free (FVList);\r
+    FVList = FVPtr;\r
+  }\r
+\r
+  while (mNonFfsFVList != NULL) {\r
+    FVPtr = mNonFfsFVList->Next;\r
+    free (mNonFfsFVList);\r
+    mNonFfsFVList = FVPtr;\r
+  }\r
+\r
+  if (XRefFptr != NULL) {\r
+    fclose (XRefFptr);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+NonFFSFVWriteInfFiles (\r
+  DSC_FILE  *DSC,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Generate a Non FFS fv file. It can only some variables,\r
+  or simply contains nothing except header.\r
+\r
+Arguments:\r
+\r
+  DSC       - pointer to a DSC_FILE object to extract info from\r
+  FileName  - pointer to the fv file\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  if successful\r
+  non-STATUS_SUCCESS  otherwise\r
+\r
+--*/\r
+{\r
+  FV_LIST *FVPtr;\r
+  SECTION *Section;\r
+  char    *StartCptr;\r
+  char    *EndCptr;\r
+  char    CSave;\r
+  char    Str[MAX_PATH];\r
+  char    Line[MAX_LINE_LEN];\r
+  char    ExpandedLine[MAX_LINE_LEN];\r
+  char    FVDir[MAX_PATH];\r
+\r
+  //\r
+  // See if they specified a FV directory to dump the FV files out to. If not,\r
+  // then use the default. Then create the output directory.\r
+  //\r
+  DSCFileSavePosition (DSC);\r
+  StartCptr = GetSymbolValue (FV_INF_DIR);\r
+  if (StartCptr == NULL) {\r
+    ExpandSymbols (DEFAULT_FV_INF_DIR, FVDir, sizeof (FVDir), EXPANDMODE_NO_UNDEFS);\r
+  } else {\r
+    strcpy (FVDir, StartCptr);\r
+  }\r
+\r
+  //\r
+  // Make sure the fv directory path ends in /\r
+  //\r
+  CSave = FVDir[strlen (FVDir) - 1];\r
+  if ((CSave != '\\') && (CSave != '/')) {\r
+    strcat (FVDir, "\\");\r
+  }\r
+\r
+  StartCptr = FileName;\r
+  while (*StartCptr) {\r
+    EndCptr = StartCptr;\r
+    while (*EndCptr && (*EndCptr != ',')) {\r
+      EndCptr++;\r
+    }\r
+\r
+    CSave     = *EndCptr;\r
+    *EndCptr  = 0;\r
+    //\r
+    // Ok, we have a fv name, now see if we've already opened\r
+    // an fv output file of this name.\r
+    //\r
+    for (FVPtr = mNonFfsFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
+      if (_stricmp (FVPtr->FVFileName, StartCptr) == 0) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If there is already one with the same name, wrong\r
+    //\r
+    if (FVPtr != NULL) {\r
+      DSCFileRestorePosition (DSC);\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Create a new one, add it to the list\r
+    //\r
+    FVPtr = (FV_LIST *) malloc (sizeof (FV_LIST));\r
+    if (FVPtr == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "failed to allocate memory", NULL);\r
+      DSCFileRestorePosition (DSC);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) FVPtr, 0, sizeof (FV_LIST));\r
+    FVPtr->Next   = mNonFfsFVList;\r
+    mNonFfsFVList = FVPtr;\r
+    //\r
+    // Save the FV name in the FileName pointer so we can compare\r
+    // for any future FV names specified.\r
+    //\r
+    strcpy (FVPtr->FVFileName, StartCptr);\r
+    //\r
+    // Add a symbol for the FV filename\r
+    //\r
+    UpperCaseString (FVPtr->FVFileName);\r
+    AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE);\r
+\r
+    //\r
+    // Now create the FVx.inf filename from the fv name and\r
+    // default filename extension. Dump it in the FV directory\r
+    // as well.\r
+    //\r
+    strcpy (Str, FVDir);\r
+    strcat (Str, FVPtr->FVFileName);\r
+    strcat (Str, ".inf");\r
+    //\r
+    // Create the directory path for our new fv.inf output file.\r
+    //\r
+    MakeFilePath (Str);\r
+    if ((FVPtr->FVFilePtr = SmartOpen (Str)) == NULL) {\r
+      Error (NULL, 0, 0, Str, "could not open FV output file");\r
+      DSCFileRestorePosition (DSC);\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Now copy the [fv.fvfile.options] to the fv file\r
+    //\r
+    sprintf (Str, "fv.%s.options", StartCptr);\r
+    Section = DSCFileFindSection (DSC, Str);\r
+    if (Section != NULL) {\r
+      SmartWrite (FVPtr->FVFilePtr, "[options]\n");\r
+      while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+        ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0);\r
+        SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+        GetBaseAddress (ExpandedLine, FVPtr->BaseAddress);\r
+      }\r
+    } else {\r
+      Warning (NULL, 0, 0, NULL, "Could not find FV section '%s' in description file", Str);\r
+    }\r
+    //\r
+    // Copy the [fv.fvfile.attributes] to the fv file\r
+    //\r
+    sprintf (Str, "fv.%s.attributes", StartCptr);\r
+    Section = DSCFileFindSection (DSC, Str);\r
+    if (Section != NULL) {\r
+      SmartWrite (FVPtr->FVFilePtr, "[attributes]\n");\r
+      while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+        ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0);\r
+        SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+      }\r
+    } else {\r
+      Warning (NULL, 0, 0, NULL, "Could not find FV section '%s' in description file", Str);\r
+    }\r
+    //\r
+    // Copy the [fv.fvfile.components] to the fv file\r
+    //\r
+    sprintf (Str, "fv.%s.components", StartCptr);\r
+    Section = DSCFileFindSection (DSC, Str);\r
+    if (Section != NULL) {\r
+      SmartWrite (FVPtr->FVFilePtr, "[components]\n");\r
+      while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) {\r
+        ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0);\r
+        SmartWrite (FVPtr->FVFilePtr, ExpandedLine);\r
+      }\r
+    } else {\r
+      //\r
+      // An empty FV is allowed to contain nothing\r
+      //\r
+    }\r
+    //\r
+    // Close the file\r
+    //\r
+    SmartClose (FVPtr->FVFilePtr);\r
+    //\r
+    // Next FV in FileName\r
+    //\r
+    *EndCptr  = CSave;\r
+    StartCptr = EndCptr;\r
+    if (*StartCptr) {\r
+      StartCptr++;\r
+    }\r
+  }\r
+\r
+  DSCFileRestorePosition (DSC);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+AddFirmwareVolumes (\r
+  char          *FVs,\r
+  int           ComponentsInstance,\r
+  FILE_LIST     *FileListPtr\r
+  )\r
+{\r
+  FV_LIST *FvPtr;\r
+  char    *StartPtr;\r
+  char    *EndPtr;\r
+  char    SaveChar;\r
+\r
+  if ((FVs != NULL) && (FVs[0] != 0)) {\r
+    //\r
+    // Extract each FV name from the string. It's from the DSC file "FV=FvRecover,FvMain"\r
+    //\r
+    StartPtr = FVs;\r
+    while (*StartPtr != 0) {\r
+      EndPtr = StartPtr;\r
+      while (*EndPtr && (*EndPtr != ',')) {\r
+        EndPtr++;\r
+      }\r
+\r
+      SaveChar  = *EndPtr;\r
+      *EndPtr   = 0;\r
+      //\r
+      // Look through our list of known firmware volumes and see if we've\r
+      // already added it.\r
+      //\r
+      for (FvPtr = mFVList; FvPtr != NULL; FvPtr = FvPtr->Next) {\r
+        if (_stricmp (FvPtr->FVFileName, StartPtr) == 0) {\r
+          break;\r
+        }\r
+      }\r
+      //\r
+      // If we didn't find a match, then create a new one\r
+      //\r
+      if (FvPtr == NULL) {\r
+        FvPtr = MALLOC (sizeof (FV_LIST));\r
+        if (FvPtr == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");\r
+          return ;\r
+        }\r
+\r
+        memset (FvPtr, 0, sizeof (FV_LIST));\r
+        strcpy (FvPtr->FVFileName, StartPtr);\r
+        if (mFVList == NULL) {\r
+          mFVList = FvPtr;\r
+        } else {\r
+          mFVListLast->Next = FvPtr;\r
+        }\r
+\r
+        mFVListLast = FvPtr;\r
+      }\r
+      //\r
+      // If this component's section number is higher than that of this\r
+      // FV, then set the FV's to it.\r
+      //\r
+      if (FvPtr->ComponentsInstance < ComponentsInstance) {\r
+        FvPtr->ComponentsInstance = ComponentsInstance;\r
+      }\r
+      //\r
+      // If we found then end of the FVs in the string, then we're done.\r
+      // Always restore the original string's contents.\r
+      //\r
+      if (SaveChar != 0) {\r
+        *EndPtr   = SaveChar;\r
+        StartPtr  = EndPtr + 1;\r
+      } else {\r
+        StartPtr = EndPtr;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+OrderInFvList (\r
+  char    *FvList,\r
+  char    *FvName,\r
+  int     *Order\r
+  )\r
+{\r
+  //\r
+  // Given FvList of format "FV_a,FV_b,FV_c" or "FV_a:1,FV_b:2" and\r
+  // FvName of format "FV_c", determine if FvName is in FvList. If\r
+  // FV_a:1 format, then return the value after the colon.\r
+  //\r
+  while (*FvList) {\r
+    //\r
+    // If it matches for the length of FvName...\r
+    //\r
+    if (_strnicmp (FvList, FvName, strlen (FvName)) == 0) {\r
+      //\r
+      // Then see if the match string in FvList is terminated at the\r
+      // same length.\r
+      //\r
+      if ((FvList[strlen (FvName)] == ',') || (FvList[strlen (FvName)] == 0)) {\r
+        *Order = 0;\r
+        return TRUE;\r
+      } else if (FvList[strlen (FvName)] == ':') {\r
+        *Order = atoi (FvList + strlen (FvName) + 1);\r
+        return TRUE;\r
+      }\r
+    }\r
+    //\r
+    // Skip to next FV in the comma-separated list\r
+    //\r
+    while ((*FvList != ',') && (*FvList != 0)) {\r
+      FvList++;\r
+    }\r
+    //\r
+    // Skip over comma\r
+    //\r
+    if (*FvList == ',') {\r
+      FvList++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+char *\r
+UpperCaseString (\r
+  char *Str\r
+  )\r
+{\r
+  char  *Cptr;\r
+\r
+  for (Cptr = Str; *Cptr; Cptr++) {\r
+    *Cptr = (char) toupper (*Cptr);\r
+  }\r
+\r
+  return Str;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+InSameFv (\r
+  char  *FVs1,\r
+  char  *FVs2\r
+)\r
+{\r
+  char    *StartCptr1;\r
+  char    *StartCptr2;\r
+  char    *EndCptr1;\r
+  char    *EndCptr2;\r
+  char    CSave1;\r
+  char    CSave2;\r
+  \r
+  //\r
+  // Process each FV in first FV list\r
+  //\r
+  StartCptr1 = FVs1;\r
+  while (*StartCptr1) {\r
+    EndCptr1 = StartCptr1;\r
+    while (*EndCptr1 && (*EndCptr1 != ',')) {\r
+      EndCptr1++;\r
+    }\r
+\r
+    CSave1     = *EndCptr1;\r
+    *EndCptr1  = 0;  \r
+    \r
+    if (*StartCptr1) {\r
+      //\r
+      // Process each FV in second FV list\r
+      //\r
+      StartCptr2 = FVs2;\r
+      while (*StartCptr2) {\r
+        EndCptr2 = StartCptr2;\r
+        while (*EndCptr2 && (*EndCptr2 != ',')) {\r
+          EndCptr2++;\r
+        }\r
+    \r
+        CSave2     = *EndCptr2;\r
+        *EndCptr2  = 0;  \r
+        \r
+        if (_stricmp (StartCptr1, StartCptr2) == 0) {\r
+          *EndCptr1  = CSave1;\r
+          *EndCptr2  = CSave2;\r
+          return TRUE;\r
+        }\r
+        \r
+        //\r
+        // Next FV on the second FV list\r
+        //\r
+        *EndCptr2  = CSave2;\r
+        StartCptr2 = EndCptr2;\r
+        if (*StartCptr2) {\r
+          StartCptr2++;\r
+        }\r
+      }    \r
+    }\r
+    \r
+    //\r
+    // Next FV on the first FV list\r
+    //\r
+    *EndCptr1  = CSave1;\r
+    StartCptr1 = EndCptr1;\r
+    if (*StartCptr1) {\r
+      StartCptr1++;\r
+    }\r
+  }        \r
+  \r
+  return FALSE;\r
+}\r
+\r
+int\r
+CFVSetXRefFileName (\r
+  char    *FileName\r
+  )\r
+{\r
+  mXRefFileName = FileName;\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h
new file mode 100644 (file)
index 0000000..4a7af36
--- /dev/null
@@ -0,0 +1,76 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FWVolume.h\r
+\r
+Abstract:\r
+\r
+  Include file for the module that keeps track of files for the firmware\r
+  volumes.\r
+\r
+--*/\r
+\r
+#ifndef _FW_VOLUME_H_\r
+#define _FW_VOLUME_H_\r
+\r
+//\r
+// class CFirmwareVolume\r
+// {\r
+// public:\r
+//\r
+void\r
+CFVConstructor (\r
+  VOID\r
+  )\r
+;\r
+void\r
+CFVDestructor (\r
+  VOID\r
+  )\r
+;\r
+\r
+int\r
+CFVAddFVFile (\r
+  char  *Name,\r
+  char  *ComponentType,\r
+  char  *FVs,\r
+  int   ComponentsInstance,\r
+  char  *FFSExt,\r
+  char  *Processor,\r
+  char  *Apriori,\r
+  char  *BaseName,\r
+  char  *Guid\r
+  )\r
+;\r
+\r
+int\r
+CFVSetXRefFileName (\r
+  char    *FileName\r
+  )\r
+;\r
+\r
+int\r
+CFVWriteInfFiles (\r
+  DSC_FILE  *DSC,\r
+  FILE      *MakeFptr\r
+  )\r
+;\r
+\r
+int\r
+NonFFSFVWriteInfFiles (\r
+  DSC_FILE  *DSC,\r
+  char      *FileName\r
+  )\r
+;\r
+\r
+#endif // ifndef _FW_VOLUME_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
new file mode 100644 (file)
index 0000000..c835a80
--- /dev/null
@@ -0,0 +1,102 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the ProcessDsc utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = ProcessDsc\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+INC_DEPS  = $(TARGET_SRC_DIR)\DSCFile.h    $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\FWVolume.h   $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\Common.h     $(INC_DEPS)\r
+\r
+LIBS      = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\DSCFile.obj  \\r
+            $(EDK_TOOLS_OUTPUT)\FWVolume.obj   \\r
+            $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \\r
+            $(EDK_TOOLS_OUTPUT)\Exceptions.obj\r
+\r
+#\r
+# Compile each source file\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\ProcessDsc.obj : $(TARGET_SRC_DIR)\ProcessDsc.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\ProcessDsc.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\Exceptions.obj : $(TARGET_SRC_DIR)\Exceptions.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\Exceptions.c /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
new file mode 100644 (file)
index 0000000..4833b78
--- /dev/null
@@ -0,0 +1,4726 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  ProcessDsc.c\r
+\r
+Abstract:\r
+\r
+  Main module for the ProcessDsc utility.\r
+\r
+--*/\r
+\r
+#include <windows.h>  // for GetShortPathName()\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+#include <direct.h>   // for _mkdir()\r
+#include <errno.h>\r
+#include <stdlib.h>   // for getenv()\r
+#include "DSCFile.h"\r
+#include "FWVolume.h"\r
+#include "Exceptions.h"\r
+#include "Common.h"\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "TianoBind.h"\r
+//\r
+// Disable warning for while(1) code\r
+//\r
+#pragma warning(disable : 4127)\r
+//\r
+// Disable warning for unreferenced function parameters\r
+//\r
+#pragma warning(disable : 4100)\r
+\r
+extern int  errno;\r
+\r
+#define PROGRAM_NAME  "ProcessDsc"\r
+\r
+//\r
+// Common symbol name definitions. For example, the user can reference\r
+// $(BUILD_DIR) in their DSC file and we will expand it for them (usually).\r
+// I've defined the equivalents here in case we want to change the name the\r
+// user references, in which case we just change the string value here and\r
+// our code still works.\r
+//\r
+#define BUILD_DIR                       "BUILD_DIR"\r
+#define EFI_SOURCE                      "EFI_SOURCE"\r
+#define DEST_DIR                        "DEST_DIR"\r
+#define SOURCE_DIR                      "SOURCE_DIR"\r
+#define LIB_DIR                         "LIB_DIR"\r
+#define BIN_DIR                         "BIN_DIR"\r
+#define OUT_DIR                         "OUT_DIR"\r
+#define INF_FILENAME                    "INF_FILENAME"\r
+#define SOURCE_RELATIVE_PATH            "SOURCE_RELATIVE_PATH"\r
+#define SOURCE_BASE_NAME                "SOURCE_BASE_NAME"\r
+#define SOURCE_FILE_NAME                "SOURCE_FILE_NAME"    // c:\FullPath\File.c\r
+#define PROCESSOR                       "PROCESSOR"\r
+#define FV                              "FV"\r
+#define BASE_NAME                       "BASE_NAME"\r
+#define GUID                            "GUID"\r
+#define FILE_GUID                       "FILE_GUID"\r
+#define COMPONENT_TYPE_FILE             "FILE"\r
+#define BUILD_TYPE                      "BUILD_TYPE"\r
+#define FFS_EXT                         "FFS_EXT"             // FV_EXT is deprecated -- extension of FFS file\r
+#define MAKEFILE_NAME                   "MAKEFILE_NAME"       // name of component's output makefile\r
+#define PLATFORM                        "PLATFORM"            // for more granularity\r
+#define PACKAGE_FILENAME                "PACKAGE_FILENAME"\r
+#define PACKAGE                         "PACKAGE"\r
+#define PACKAGE_TAG                     "PACKAGE_TAG"         // alternate name to PACKAGE\r
+#define SHORT_NAMES                     "SHORT_NAMES"         // for 8.3 names of symbols\r
+#define APRIORI                         "APRIORI"             // to add to apriori list\r
+#define OPTIONAL_COMPONENT              "OPTIONAL"            // define as non-zero for optional INF files\r
+#define SOURCE_SELECT                   "SOURCE_SELECT"       // say SOURCE_SELECT=smm,common to select INF sources\r
+#define NONFFS_FV                       "NONFFS_FV"           // for non-FFS FV such as working & spare block FV\r
+#define SKIP_FV_NULL                    "SKIP_FV_NULL"        // define as nonzero to not build components with FV=NULL\r
+#define SOURCE_COMPILE_TYPE             "SOURCE_COMPILE_TYPE" // to build a source using a custom build section in the DSC file\r
+#define SOURCE_FILE_EXTENSION           "SOURCE_FILE_EXTENSION"\r
+#define COMPILE_SELECT                  "COMPILE_SELECT"\r
+#define SOURCE_OVERRIDE_PATH            "SOURCE_OVERRIDE_PATH"  // get source files from here first\r
+#define MAKEFILE_OUT_SECTION_NAME       "makefile.out"\r
+#define COMMON_SECTION_NAME             "common"                // shared files or functionality\r
+#define NMAKE_SECTION_NAME              "nmake"\r
+#define SOURCES_SECTION_NAME            "sources"\r
+#define COMPONENTS_SECTION_NAME         "components"\r
+#define INCLUDE_SECTION_NAME            "includes"\r
+#define DEFINES_SECTION_NAME            "defines"\r
+#define LIBRARIES_SECTION_NAME          "libraries"\r
+#define LIBRARIES_PLATFORM_SECTION_NAME "libraries.platform"\r
+#define MAKEFILE_SECTION_NAME           "makefile"\r
+#define COMPONENT_TYPE                  "component_type"\r
+#define PLATFORM_STR                    "\\platform\\"          // to determine EFI_SOURCE\r
+#define MAKEFILE_OUT_NAME               "makefile.out"          // if not specified on command line\r
+#define MODULE_MAKEFILE_NAME            "module.mak"            // record all module makefile targets\r
+#define MODULE_NAME_FILE                "module.list"           // record all module names defined in the dsc file\r
+#define GLOBAL_LINK_LIB_NAME            "CompilerStub"          // Lib added in link option, maybe removed in the future\r
+#define MODULE_BASE_NAME_WIDTH          25                      // Width for module name output\r
+\r
+//\r
+// When a symbol is defined as "NULL", it gets saved in the symbol table as a 0-length\r
+// string. Use this macro to detect if a symbol has been defined this way.\r
+//\r
+#define IS_NULL_SYMBOL_VALUE(var) ((var != NULL) && (strlen (var) == 0))\r
+\r
+//\r
+// Defines for file types\r
+//\r
+#define FILETYPE_UNKNOWN  0\r
+#define FILETYPE_C        1\r
+#define FILETYPE_ASM      2\r
+#define FILETYPE_S        3\r
+#define FILETYPE_VFR      4\r
+#define FILETYPE_INC      5\r
+#define FILETYPE_H        6\r
+#define FILETYPE_I        7\r
+\r
+\r
+typedef struct {\r
+  INT8  *Extension;         // file extension\r
+  INT8  *BuiltExtension;\r
+  INT8  FileFlags;\r
+  int   FileType;\r
+} FILETYPE;\r
+\r
+//\r
+// Define masks for the FileFlags field\r
+//\r
+#define FILE_FLAG_INCLUDE 0x01\r
+#define FILE_FLAG_SOURCE  0x02\r
+\r
+//\r
+// This table describes a from-to list of files. For\r
+// example, when a ".c" is built, it results in a ".obj" file.\r
+//\r
+static const FILETYPE mFileTypes[] = {\r
+  {\r
+    ".c",\r
+    ".obj",\r
+    FILE_FLAG_SOURCE,\r
+    FILETYPE_C\r
+  },\r
+  {\r
+    ".asm",\r
+    ".obj",\r
+    FILE_FLAG_SOURCE,\r
+    FILETYPE_ASM\r
+  },\r
+  {\r
+    ".s",\r
+    ".obj",\r
+    FILE_FLAG_SOURCE,\r
+    FILETYPE_S\r
+  },\r
+  {\r
+    ".vfr",\r
+    ".obj",\r
+    FILE_FLAG_SOURCE,\r
+    FILETYPE_VFR\r
+  },  // actually *.vfr -> *.c -> *.obj\r
+  {\r
+    ".h",\r
+    NULL,\r
+    FILE_FLAG_INCLUDE,\r
+    FILETYPE_H\r
+  },\r
+  {\r
+    ".inc",\r
+    NULL,\r
+    FILE_FLAG_INCLUDE,\r
+    FILETYPE_INC\r
+  },\r
+  {\r
+    ".i",\r
+    NULL,\r
+    FILE_FLAG_INCLUDE,\r
+    FILETYPE_I\r
+  },\r
+  {\r
+    NULL,\r
+    NULL,\r
+    0,\r
+    0\r
+  }\r
+};\r
+\r
+//\r
+// Structure to split up a file into its different parts.\r
+//\r
+typedef struct {\r
+  INT8  Drive[3];\r
+  INT8  *Path;\r
+  INT8  *BaseName;\r
+  INT8  *Extension;\r
+  int   ExtensionCode;\r
+} FILE_NAME_PARTS;\r
+\r
+//\r
+// Maximum length for any line in any file after symbol expansion\r
+//\r
+#define MAX_EXP_LINE_LEN  (MAX_LINE_LEN * 2)\r
+\r
+//\r
+// Linked list to keep track of all symbols\r
+//\r
+typedef struct _SYMBOL {\r
+  struct _SYMBOL  *Next;\r
+  int             Type; // local or global symbol\r
+  INT8            *Name;\r
+  INT8            *Value;\r
+} SYMBOL;\r
+\r
+//\r
+// Define new SYMBOL list to record all module name used in the platform.dsc file.\r
+//\r
+SYMBOL *gModuleList = NULL;\r
+\r
+//\r
+// This structure is used to save globals\r
+//\r
+struct {\r
+  INT8    *DscFilename;\r
+  SYMBOL  *Symbol;\r
+  INT8    MakefileName[MAX_PATH]; // output makefile name\r
+  INT8    XRefFileName[MAX_PATH];\r
+  INT8    GuidDatabaseFileName[MAX_PATH];\r
+  INT8    ModuleMakefileName[MAX_PATH];\r
+  FILE    *MakefileFptr;\r
+  FILE    *ModuleMakefileFptr;\r
+  SYMBOL  *ModuleList;\r
+  SYMBOL  *OutdirList;\r
+  UINT32  Verbose;\r
+} gGlobals;\r
+\r
+//\r
+// This gets dumped to the head of makefile.out\r
+//\r
+static const INT8 *MakefileHeader[] = {\r
+  "#/*++",\r
+  "#",\r
+  "#  DO NOT EDIT",\r
+  "#  File auto-generated by build utility",\r
+  "#",\r
+  "#  Module Name:",\r
+  "#",\r
+  "#    makefile",\r
+  "#",\r
+  "#  Abstract:",\r
+  "#",\r
+  "#    Auto-generated makefile for building of EFI components/libraries",\r
+  "#",\r
+  "#--*/",\r
+  "",\r
+  NULL\r
+};\r
+\r
+//\r
+// Function prototypes\r
+//\r
+static\r
+int\r
+ProcessOptions (\r
+  int  Argc,\r
+  INT8 *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+INT8              *\r
+StripLine (\r
+  INT8 *Line\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseGuidDatabaseFile (\r
+  INT8 *FileName\r
+  );\r
+\r
+#define DSC_SECTION_TYPE_COMPONENTS         0\r
+#define DSC_SECTION_TYPE_LIBRARIES          1\r
+#define DSC_SECTION_TYPE_PLATFORM_LIBRARIES 2\r
+\r
+static\r
+int\r
+ProcessSectionComponents (\r
+  DSC_FILE *DscFile,\r
+  int      DscSectionType,\r
+  int      Instance\r
+  );\r
+static\r
+int\r
+ProcessComponentFile (\r
+  DSC_FILE  *DscFile,\r
+  INT8      *Line,\r
+  int       DscSectionType,\r
+  int       Instance\r
+  );\r
+static\r
+int\r
+ProcessIncludeFiles (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  );\r
+static\r
+\r
+int\r
+ProcessIncludeFilesSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  );\r
+\r
+//\r
+// Mode flags for processing source files\r
+//\r
+#define SOURCE_MODE_BUILD_COMMANDS  0x01\r
+#define SOURCE_MODE_SOURCE_FILES    0x02\r
+\r
+static\r
+int\r
+ProcessSourceFiles (\r
+  DSC_FILE  *DSCFile,\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  UINT32    Mode\r
+  );\r
+\r
+static\r
+int\r
+ProcessSourceFilesSection (\r
+  DSC_FILE  *DSCFile,\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName,\r
+  UINT32    Mode\r
+  );\r
+\r
+static\r
+int\r
+ProcessObjects (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  );\r
+\r
+static\r
+int\r
+ProcessObjectsSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  );\r
+\r
+static\r
+int\r
+ProcessLibs (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  );\r
+\r
+static\r
+int\r
+ProcessLibsSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  );\r
+\r
+static\r
+int\r
+ProcessIncludesSection (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  );\r
+\r
+static\r
+int\r
+ProcessIncludesSectionSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  );\r
+\r
+static\r
+int\r
+ProcessINFNMakeSection (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  );\r
+\r
+static\r
+int\r
+ProcessINFDefinesSection (\r
+  DSC_FILE  *ComponentFile\r
+  );\r
+\r
+static\r
+int\r
+ProcessINFDefinesSectionSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  INT8      *SectionName\r
+  );\r
+\r
+static\r
+int\r
+ProcessSectionLibraries (\r
+  DSC_FILE  *DscFile,\r
+  long      Offset\r
+  );\r
+\r
+static\r
+int\r
+ProcessDSCDefinesSection (\r
+  DSC_FILE *DscFile\r
+  );\r
+\r
+static\r
+int\r
+SetSymbolType (\r
+  INT8  *SymbolName,\r
+  INT8  Type\r
+  );\r
+\r
+static\r
+int\r
+RemoveLocalSymbols (\r
+  VOID\r
+  );\r
+\r
+static\r
+int\r
+RemoveFileSymbols (\r
+  VOID\r
+  );\r
+\r
+static\r
+int\r
+RemoveSymbol (\r
+  INT8   *Name,\r
+  INT8   SymbolType\r
+  );\r
+\r
+static\r
+int\r
+SetFileExtension (\r
+  INT8 *FileName,\r
+  INT8 *Extension\r
+  );\r
+\r
+static\r
+int\r
+GetSourceFileType (\r
+  INT8 *FileName\r
+  );\r
+\r
+static\r
+int\r
+IsIncludeFile (\r
+  INT8 *FileName\r
+  );\r
+\r
+static\r
+int\r
+WriteCompileCommands (\r
+  DSC_FILE *DscFile,\r
+  FILE     *MakeFptr,\r
+  INT8     *FileName,\r
+  INT8     *Processor\r
+  );\r
+\r
+static\r
+int\r
+WriteCommonMakefile (\r
+  DSC_FILE *DscFile,\r
+  FILE     *MakeFptr,\r
+  INT8     *Processor\r
+  );\r
+\r
+static\r
+int\r
+WriteComponentTypeBuildCommands (\r
+  DSC_FILE *DscFile,\r
+  FILE     *MakeFptr,\r
+  INT8     *SectionName\r
+  );\r
+\r
+static\r
+void\r
+StripTrailingSpaces (\r
+  INT8 *Str\r
+  );\r
+\r
+static\r
+void\r
+FreeFileParts (\r
+  FILE_NAME_PARTS *FP\r
+  );\r
+\r
+static\r
+FILE_NAME_PARTS   *\r
+GetFileParts (\r
+  INT8 *FileName\r
+  );\r
+\r
+static\r
+SYMBOL            *\r
+FreeSymbols (\r
+  SYMBOL *Syms\r
+  );\r
+\r
+static\r
+int\r
+GetEfiSource (\r
+  VOID\r
+  );\r
+\r
+static\r
+int\r
+CreatePackageFile (\r
+  DSC_FILE          *DSCFile\r
+  );\r
+\r
+static\r
+INT8              *\r
+BuiltFileExtension (\r
+  INT8      *SourceFileName\r
+  );\r
+\r
+static\r
+void\r
+SmartFree (\r
+  SMART_FILE  *SmartFile\r
+  );\r
+\r
+static \r
+int\r
+AddModuleName (\r
+  SYMBOL  **SymbolList,\r
+  INT8    *ModuleName,\r
+  INT8    *InfName\r
+  );\r
+\r
+/*****************************************************************************/\r
+int\r
+main (\r
+  int   Argc,\r
+  INT8  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Main utility entry point.\r
+\r
+Arguments:\r
+\r
+  Argc - Standard app entry point args.\r
+  Argv - Standard app entry point args.\r
+\r
+Returns:\r
+\r
+  0  if successful\r
+  non-zero otherwise\r
+\r
+--*/\r
+{\r
+  int       i;\r
+  DSC_FILE  DSCFile;\r
+  SECTION   *Sect;\r
+  INT8      Line[MAX_LINE_LEN];\r
+  INT8      ExpLine[MAX_LINE_LEN];\r
+  INT8      *EMsg;\r
+  FILE      *FpModule;\r
+  SYMBOL    *TempSymbol;\r
+\r
+  SetUtilityName (PROGRAM_NAME);\r
+\r
+  InitExceptions ();\r
+\r
+  DSCFileInit (&DSCFile);\r
+  //\r
+  // Initialize the firmware volume data\r
+  //\r
+  CFVConstructor ();\r
+  //\r
+  // Exception handling for this block of code.\r
+  //\r
+  TryException ();\r
+  //\r
+  // Process command-line options.\r
+  //\r
+  if (ProcessOptions (Argc, Argv)) {\r
+    EMsg = CatchException ();\r
+    if (EMsg != NULL) {\r
+      fprintf (stderr, "%s\n", EMsg);\r
+    }\r
+\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Parse the GUID database file if specified\r
+  //\r
+  if (gGlobals.GuidDatabaseFileName[0] != 0) {\r
+    ParseGuidDatabaseFile (gGlobals.GuidDatabaseFileName);\r
+  }\r
+  //\r
+  // Set the output cross-reference file if applicable\r
+  //\r
+  if (gGlobals.XRefFileName[0]) {\r
+    CFVSetXRefFileName (gGlobals.XRefFileName);\r
+  }\r
+\r
+  //\r
+  // Now get the EFI_SOURCE directory which we use everywhere.\r
+  //\r
+  if (GetEfiSource ()) {\r
+    return STATUS_ERROR;\r
+  }\r
+    \r
+  //\r
+  // Pre-process the DSC file to get section info.\r
+  //\r
+  if (DSCFileSetFile (&DSCFile, gGlobals.DscFilename) != 0) {\r
+    goto ProcessingError;\r
+  }\r
+\r
+  //\r
+  // Set output makefile name for single module build \r
+  //\r
+  strcpy (gGlobals.ModuleMakefileName, MODULE_MAKEFILE_NAME);\r
+\r
+  //\r
+  // Try to open all final output makefiles\r
+  //\r
+  if ((gGlobals.MakefileFptr = fopen (gGlobals.MakefileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, gGlobals.MakefileName, "failed to open output makefile for writing");\r
+    goto ProcessingError;\r
+  }\r
+  if ((gGlobals.ModuleMakefileFptr = fopen (gGlobals.ModuleMakefileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, gGlobals.ModuleMakefileName, "failed to open output makefile for writing");\r
+    goto ProcessingError;\r
+  }\r
+    \r
+  //\r
+  // Write the header out to the makefiles\r
+  //\r
+  for (i = 0; MakefileHeader[i] != NULL; i++) {\r
+    fprintf (gGlobals.MakefileFptr, "%s\n", MakefileHeader[i]);\r
+    fprintf (gGlobals.ModuleMakefileFptr, "%s\n", MakefileHeader[i]);\r
+  }\r
+\r
+  //\r
+  // Init global potint = NULL\r
+  //\r
+  gGlobals.ModuleList = NULL;\r
+  gGlobals.OutdirList = NULL;\r
+  \r
+  //\r
+  // Process the [defines] section in the DSC file to get any defines we need\r
+  // elsewhere\r
+  //\r
+  ProcessDSCDefinesSection (&DSCFile);\r
+  if (ExceptionThrown ()) {\r
+    goto ProcessingError;\r
+  }\r
+  //\r
+  // Write out the [makefile.out] section data to the output makefiles\r
+  //\r
+  Sect = DSCFileFindSection (&DSCFile, MAKEFILE_OUT_SECTION_NAME);\r
+  if (Sect != NULL) {\r
+    while (DSCFileGetLine (&DSCFile, Line, sizeof (Line)) != NULL) {\r
+      ExpandSymbols (Line, ExpLine, sizeof (ExpLine), 0);\r
+      //\r
+      // Write the line to the output makefiles\r
+      //\r
+      fprintf (gGlobals.MakefileFptr, ExpLine);\r
+      fprintf (gGlobals.ModuleMakefileFptr, ExpLine);\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Add a pseudo target for GLOBAL_LINK_LIB_NAME to avoid single module build \r
+  // failure when this lib is not used.\r
+  //\r
+  fprintf (gGlobals.ModuleMakefileFptr, "%sbuild ::\n\n", GLOBAL_LINK_LIB_NAME);\r
+\r
+  fprintf (gGlobals.MakefileFptr, "libraries : \n");\r
+  //\r
+  // Process [libraries] section in the DSC file\r
+  //\r
+  Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME);\r
+  if (Sect != NULL) {\r
+    ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0);\r
+  }\r
+\r
+  if (ExceptionThrown ()) {\r
+    goto ProcessingError;\r
+  }\r
+  //\r
+  // Process [libraries.platform] section in the DSC file\r
+  //\r
+  Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME);\r
+  if (Sect != NULL) {\r
+    ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0);\r
+  }\r
+\r
+  fprintf (gGlobals.MakefileFptr, "\n");\r
+  if (ExceptionThrown ()) {\r
+    goto ProcessingError;\r
+  }\r
+  \r
+  //\r
+  // Process [components] section in the DSC file\r
+  //\r
+  Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME);\r
+  if (Sect != NULL) {\r
+    fprintf (gGlobals.MakefileFptr, "components_0 : \n");\r
+    ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0);\r
+    fprintf (gGlobals.MakefileFptr, "\n");\r
+  }\r
+\r
+  if (ExceptionThrown ()) {\r
+    goto ProcessingError;\r
+  }\r
+  //\r
+  // Now cycle through all [components.1], [components.2], ....[components.n].\r
+  // This is necessary to support building of firmware volumes that may contain\r
+  // other encapsulated firmware volumes (ala capsules).\r
+  //\r
+  i = 1;\r
+  while (1) {\r
+    RemoveSymbol (FV, SYM_GLOBAL);\r
+    sprintf (Line, "%s.%d", COMPONENTS_SECTION_NAME, i);\r
+    Sect = DSCFileFindSection (&DSCFile, Line);\r
+    if (Sect != NULL) {\r
+      fprintf (gGlobals.MakefileFptr, "components_%d : \n", i);\r
+      ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i);\r
+      fprintf (gGlobals.MakefileFptr, "\n");\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    if (ExceptionThrown ()) {\r
+      goto ProcessingError;\r
+    }\r
+\r
+    i++;\r
+  }\r
+\r
+ProcessingError:\r
+  EMsg = CatchException ();\r
+  if (EMsg != NULL) {\r
+    fprintf (stderr, "%s\n", EMsg);\r
+    fprintf (stderr, "Processing aborted\n");\r
+  }\r
+\r
+  TryException ();\r
+  //\r
+  // Create the FV files if no fatal errors or errors\r
+  //\r
+  if (GetUtilityStatus () < STATUS_ERROR) {\r
+    CFVWriteInfFiles (&DSCFile, gGlobals.MakefileFptr);\r
+  }\r
+\r
+  //\r
+  // Write all module name into MODULE_NAME_FILE file.\r
+  //\r
+  if ((FpModule = fopen (MODULE_NAME_FILE, "w")) != NULL) {\r
+    TempSymbol = gGlobals.ModuleList;\r
+    while (TempSymbol != NULL) {\r
+      fprintf (FpModule, " %-*s %s \n", MODULE_BASE_NAME_WIDTH, TempSymbol->Name, TempSymbol->Value);\r
+      TempSymbol = TempSymbol->Next;\r
+    }\r
+    fclose (FpModule);\r
+    FpModule = NULL;\r
+  }\r
+\r
+  //\r
+  // Close the all the output makefiles\r
+  //\r
+  if (gGlobals.MakefileFptr != NULL) {\r
+    fclose (gGlobals.MakefileFptr);\r
+    gGlobals.MakefileFptr = NULL;\r
+  }\r
+\r
+  if (gGlobals.ModuleMakefileFptr != NULL) {\r
+    fclose (gGlobals.ModuleMakefileFptr);\r
+    gGlobals.ModuleMakefileFptr = NULL;\r
+  }\r
+    \r
+  //\r
+  // Clean up\r
+  //\r
+  FreeSymbols (gGlobals.ModuleList);\r
+  FreeSymbols (gGlobals.OutdirList);\r
+  FreeSymbols (gGlobals.Symbol);\r
+  gGlobals.Symbol = NULL;\r
+  CFVDestructor ();\r
+  DSCFileDestroy (&DSCFile);\r
+\r
+  EMsg = CatchException ();\r
+  if (EMsg != NULL) {\r
+    fprintf (stderr, "%s\n", EMsg);\r
+    fprintf (stderr, "Processing aborted\n");\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+int\r
+ProcessSectionComponents (\r
+  DSC_FILE  *DSCFile,\r
+  int       DscSectionType,\r
+  int       Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process the [components] or [libraries] section in the description file. We\r
+  use this function for both since they're very similar. Here we just\r
+  read each line from the section, and if it's valid, call a function to\r
+  do the actual processing of the component description file.\r
+\r
+Arguments:\r
+\r
+  DSCFile        - structure containing section info on the description file\r
+  DscSectionType - type of description section\r
+\r
+Returns:\r
+\r
+  0     if successful\r
+\r
+--*/\r
+{\r
+  INT8  Line[MAX_LINE_LEN];\r
+  INT8  Line2[MAX_EXP_LINE_LEN];\r
+  INT8  *Cptr;\r
+\r
+  //\r
+  // Read lines while they're valid\r
+  //\r
+  while (DSCFileGetLine (DSCFile, Line, sizeof (Line)) != NULL) {\r
+    //\r
+    // Expand symbols on the line\r
+    //\r
+    if (ExpandSymbols (Line, Line2, sizeof (Line2), 0)) {\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Strip the line\r
+    //\r
+    Cptr = StripLine (Line2);\r
+    if (*Cptr) {\r
+      Message (2, "Processing component line: %s", Line2);\r
+      if (ProcessComponentFile (DSCFile, Line2, DscSectionType, Instance) != 0) {\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+int\r
+ProcessComponentFile (\r
+  DSC_FILE  *DSCFile,\r
+  INT8      *ArgLine,\r
+  int       DscSectionType,\r
+  int       Instance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given a line from the [components] or [libraries] section of the description\r
+  file, process the line to extract the component's INF filename and \r
+  parameters. Then open the INF file and process it to create a corresponding\r
+  makefile.\r
+\r
+Arguments:\r
+\r
+  DSCFile               The project DSC file info structure.\r
+  Libs                  Indicates whether we're processing the [components]\r
+                        section or the [libraries] section.\r
+  ArgLine               The actual line from the DSC file. Looks something like\r
+                        one of the following:\r
+\r
+   dxe\drivers\vm\vm.dsc PROCESSOR=IA32 DEST_DIR=$(DEST_DIR)\xxx FV=FV1,FV2\r
+   $(BUILD_DIR).\FvVariable.ffs COMPONENT_TYPE=FILE\r
+   .\FvVariable.ffs COMPONENT_TYPE=FILE\r
+   define  VAR1=value1 VAR2=value2\r
+\r
+Returns:\r
+\r
+  0 if successful\r
+\r
+--*/\r
+{\r
+  FILE      *MakeFptr;\r
+  FILE      *TempFptr;\r
+  INT8      *Cptr;\r
+  INT8      *name;\r
+  INT8      *End;\r
+  INT8      *TempCptr;\r
+  INT8      FileName[MAX_PATH];\r
+  INT8      ComponentFilePath[MAX_PATH];\r
+  INT8      InLine[MAX_LINE_LEN];\r
+  INT8      Line[MAX_LINE_LEN];\r
+  INT8      *Processor;\r
+  INT8      SymType;\r
+  int       Len;\r
+  int       ComponentCreated;\r
+  int       ComponentFilePathAbsolute;\r
+  int       DefineLine;\r
+  DSC_FILE  ComponentFile;\r
+  INT8      ComponentMakefileName[MAX_PATH];\r
+  BOOLEAN   IsForFv;\r
+\r
+  //\r
+  // Now remove all local symbols\r
+  //\r
+  RemoveLocalSymbols ();\r
+  //\r
+  // Null out the file pointer in case we take an exception somewhere\r
+  // and we need to close it only if we opened it.\r
+  //\r
+  MakeFptr                  = NULL;\r
+  ComponentFilePathAbsolute = 0;\r
+  ComponentCreated          = 0;\r
+  //\r
+  // Skip preceeding spaces on the line\r
+  //\r
+  while (isspace (*ArgLine) && (*ArgLine)) {\r
+    ArgLine++;\r
+  }\r
+  //\r
+  // Find the end of the component's filename and truncate the line at that\r
+  // point. From here on out ArgLine is the name of the component filename.\r
+  //\r
+  Cptr = ArgLine;\r
+  while (!isspace (*Cptr) && *Cptr) {\r
+    Cptr++;\r
+  }\r
+\r
+  End = Cptr;\r
+  if (*Cptr) {\r
+    End++;\r
+    *Cptr = 0;\r
+  }\r
+  //\r
+  // Exception-handle processing of this component description file\r
+  //\r
+  TryException ();\r
+\r
+  //\r
+  // We also allow a component line format for defines of global symbols\r
+  // instead of a component filename. In this case, the line looks like:\r
+  // defines  x=abc y=yyy. Be nice and accept "define" and "defines" in a\r
+  // case-insensitive manner. If it's defines, then make the symbols global.\r
+  //\r
+  if ((_stricmp (ArgLine, "define") == 0) || (_stricmp (ArgLine, "defines") == 0)) {\r
+    SymType     = SYM_OVERWRITE | SYM_GLOBAL;\r
+    DefineLine  = 1;\r
+  } else {\r
+    SymType     = SYM_OVERWRITE | SYM_LOCAL;\r
+    DefineLine  = 0;\r
+  }\r
+  //\r
+  // The rest of the component line from the DSC file should be defines\r
+  //\r
+  while (*End) {\r
+    End = StripLine (End);\r
+    if (*End) {\r
+      //\r
+      // If we're processing a "define abc=1 xyz=2" line, then set symbols\r
+      // as globals per the SymType set above.\r
+      //\r
+      Len = AddSymbol (End, NULL, SymType);\r
+      if (Len > 0) {\r
+        End += Len;\r
+      } else {\r
+        Warning (NULL, 0, 0, ArgLine, "unrecognized option in description file");\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // If DEBUG_BREAK or EFI_BREAKPOINT is defined, then do a debug breakpoint.\r
+  //\r
+  if ((GetSymbolValue ("DEBUG_BREAK") != NULL) || (GetSymbolValue ("EFI_BREAKPOINT") != NULL)) {\r
+    EFI_BREAKPOINT ();\r
+  }\r
+  \r
+  //\r
+  // If it's a define line, then we're done\r
+  //\r
+  if (DefineLine) {\r
+    //\r
+    // If there is NonFFS_FV, create the FVxxx.inf file\r
+    // and include it in makefile.out. Remove the symbol\r
+    // in order not to process it again next time\r
+    //\r
+    Cptr = GetSymbolValue (NONFFS_FV);\r
+    if (Cptr != NULL) {\r
+      NonFFSFVWriteInfFiles (DSCFile, Cptr);\r
+      RemoveSymbol (NONFFS_FV, SYM_GLOBAL);\r
+    }\r
+\r
+    goto ComponentDone;\r
+  }\r
+\r
+  //\r
+  // Expand symbols in the component description filename to expand the newly \r
+  // added local symbols\r
+  //\r
+  ExpandSymbols (ArgLine, Line, sizeof (Line), EXPANDMODE_NO_UNDEFS);\r
+\r
+  //\r
+  // If we have "c:\path\filename"\r
+  //\r
+  if (IsAbsolutePath (Line)) {\r
+    ComponentFilePathAbsolute = 1;\r
+  } else if (Line[0] == '.') {\r
+    //\r
+    // or if the path starts with ".", then it's build-dir relative.\r
+    // Prepend $(BUILD_DIR) on the file name\r
+    //\r
+    sprintf (InLine, "%s\\%s", GetSymbolValue (BUILD_DIR), Line);\r
+    strcpy (Line, InLine);\r
+    ComponentFilePathAbsolute = 1;\r
+  }\r
+  \r
+  //\r
+  // Save the path from the component name for later. It may be relative or\r
+  // absolute.\r
+  //\r
+  strcpy (ComponentFilePath, Line);\r
+  Cptr = ComponentFilePath + strlen (ComponentFilePath) - 1;\r
+  while ((*Cptr != '\\') && (*Cptr != '/') && (Cptr != ComponentFilePath)) {\r
+    Cptr--;\r
+  }\r
+  //\r
+  // Terminate the path.\r
+  //\r
+  *Cptr = 0;\r
+  \r
+  //\r
+  // Typically the given line is a component description filename. However we\r
+  // also allow a FV filename (fvvariable.ffs COMPONENT_TYPE=FILE). If the\r
+  // component type is "FILE", then add it to the FV list, create a package\r
+  // file, and we're done.\r
+  //\r
+  Cptr = GetSymbolValue (COMPONENT_TYPE);\r
+  if ((Cptr != NULL) && (strncmp (\r
+                          Cptr,\r
+                          COMPONENT_TYPE_FILE,\r
+                          strlen (COMPONENT_TYPE_FILE)\r
+                          ) == 0)) {\r
+    if (ComponentFilePathAbsolute) {\r
+      strcpy (InLine, Line);\r
+    } else {\r
+      sprintf (InLine, "%s\\%s", GetSymbolValue (EFI_SOURCE), Line);\r
+    }\r
+    CFVAddFVFile (\r
+      InLine,\r
+      Cptr,\r
+      GetSymbolValue (FV),\r
+      Instance,\r
+      NULL,\r
+      NULL,\r
+      GetSymbolValue (APRIORI),\r
+      NULL,\r
+      NULL\r
+      );\r
+    goto ComponentDone;\r
+  }\r
+\r
+  //\r
+  // Better have defined processor by this point.\r
+  //\r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  if (Processor == NULL) {\r
+    Error (NULL, 0, 0, NULL, "PROCESSOR not defined for component %s", Line);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // The bin, out, and lib dirs are now = $(BUILD_DIR)/$(PROCESSOR). Set them.\r
+  // Don't flag them as file paths (required for short 8.3 filenames) since\r
+  // they're defined using the BUILD_DIR macro.\r
+  //\r
+  sprintf (InLine, "$(BUILD_DIR)\\%s", Processor);\r
+  AddSymbol (BIN_DIR, InLine, SYM_LOCAL);\r
+  AddSymbol (OUT_DIR, InLine, SYM_LOCAL);\r
+  AddSymbol (LIB_DIR, InLine, SYM_LOCAL);\r
+  //\r
+  // See if it's been destined for an FV. It's possible to not be in an\r
+  // FV if they just want to build it.\r
+  //\r
+  Cptr = GetSymbolValue (FV);\r
+  if ((Cptr != NULL) && !IS_NULL_SYMBOL_VALUE (Cptr)) {\r
+    IsForFv = TRUE;\r
+  } else {\r
+    IsForFv = FALSE;\r
+  }\r
+  //\r
+  // As an optimization, if they've defined SKIP_FV_NULL as non-zero, and\r
+  // the component is not destined for an FV, then skip it.\r
+  // Since libraries are never intended for firmware volumes, we have to\r
+  // build all of them.\r
+  //\r
+  if ((DscSectionType == DSC_SECTION_TYPE_COMPONENTS) && (IsForFv == FALSE)) {\r
+    if ((GetSymbolValue (SKIP_FV_NULL) != NULL) && (atoi (GetSymbolValue (SKIP_FV_NULL)) != 0)) {\r
+      Message (0, "%s not being built (FV=NULL)", FileName);\r
+      goto ComponentDone;\r
+    }\r
+  }\r
+  //\r
+  // Prepend EFI_SOURCE to the component description file to get the\r
+  // full path. Only do this if the path is not a full path already.\r
+  //\r
+  if (ComponentFilePathAbsolute == 0) {\r
+    name = GetSymbolValue (EFI_SOURCE);\r
+    sprintf (FileName, "%s\\%s", name, Line);\r
+  } else {\r
+    strcpy (FileName, Line);\r
+  }\r
+  //\r
+  // Print a message, depending on verbose level.\r
+  //\r
+  if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) {\r
+    Message (1, "Processing component         %s", FileName);\r
+  } else {\r
+    Message (1, "Processing library           %s", FileName);\r
+  }\r
+  //\r
+  // Open the component's description file and get the sections. If we fail\r
+  // to open it, see if they defined "OPTIONAL=1, in which case we'll just\r
+  // ignore the component.\r
+  //\r
+  TempFptr = fopen (FileName, "r");\r
+  if (TempFptr == NULL) {\r
+    //\r
+    // Better have defined OPTIONAL\r
+    //\r
+    if (GetSymbolValue (OPTIONAL_COMPONENT) != NULL) {\r
+      if (atoi (GetSymbolValue (OPTIONAL_COMPONENT)) != 0) {\r
+        Message (0, "Optional component '%s' not found", FileName);\r
+        goto ComponentDone;\r
+      }\r
+    }\r
+\r
+    ParserError (0, FileName, "failed to open component file");\r
+    return STATUS_ERROR;\r
+  } else {\r
+    fclose (TempFptr);\r
+  }\r
+\r
+  DSCFileInit (&ComponentFile);\r
+  ComponentCreated = 1;\r
+  if (DSCFileSetFile (&ComponentFile, FileName)) {\r
+    Error (NULL, 0, 0, NULL, "failed to preprocess component file '%s'", FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Add a symbol for the INF filename so users can create dependencies\r
+  // in makefiles.\r
+  //\r
+  AddSymbol (INF_FILENAME, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME);\r
+  //\r
+  // Process the [defines], [defines.$(PROCESSOR)], and [defines.$(PROCESSOR).$(PLATFORM)]\r
+  // sections in the INF file\r
+  //\r
+  ProcessINFDefinesSection (&ComponentFile);\r
+  //\r
+  // Better have defined FILE_GUID if not a library\r
+  //\r
+  if ((GetSymbolValue (GUID) == NULL) &&\r
+      (GetSymbolValue (FILE_GUID) == NULL) &&\r
+      (DscSectionType == DSC_SECTION_TYPE_COMPONENTS)\r
+      ) {\r
+    Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing FILE_GUID definition in component file");\r
+    DSCFileDestroy (&ComponentFile);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Better have defined base name\r
+  //\r
+  if (GetSymbolValue (BASE_NAME) == NULL) {\r
+    Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing BASE_NAME definition in INF file");\r
+    DSCFileDestroy (&ComponentFile);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Better have defined COMPONENT_TYPE, since it's used to find named sections.\r
+  //\r
+  if (GetSymbolValue (COMPONENT_TYPE) == NULL) {\r
+    Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing COMPONENT_TYPE definition in INF file");\r
+    DSCFileDestroy (&ComponentFile);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Create the source directory path from the component file's path. If the component\r
+  // file's path is absolute, we may have problems here. Try to account for it though.\r
+  //\r
+  if (ComponentFilePathAbsolute == 0) {\r
+    sprintf (\r
+      FileName,\r
+      "%s\\%s",\r
+      GetSymbolValue (EFI_SOURCE),\r
+      ComponentFilePath\r
+      );\r
+  } else {\r
+    strcpy (FileName, ComponentFilePath);\r
+  }\r
+  AddSymbol (SOURCE_DIR, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILEPATH);\r
+\r
+  //\r
+  // Create the destination path. \r
+  // They may have defined DEST_DIR on the component INF line, so it's already\r
+  // been defined, If that's the case, then don't set it to the path of this file.\r
+  //\r
+  if (GetSymbolValue (DEST_DIR) == NULL) {\r
+    if (ComponentFilePathAbsolute == 0) {\r
+      //\r
+      // The destination path is $(BUILD_DIR)\$(PROCESSOR)\component_path\r
+      //\r
+      sprintf (\r
+        FileName,\r
+        "%s\\%s\\%s",\r
+        GetSymbolValue (BUILD_DIR),\r
+        Processor,\r
+        ComponentFilePath\r
+        );\r
+    } else {\r
+      //\r
+      // The destination path is $(BUILD_DIR)\$(PROCESSOR)\$(BASE_NAME)\r
+      //\r
+      sprintf (\r
+        FileName,\r
+        "%s\\%s\\%s",\r
+        GetSymbolValue (BUILD_DIR),\r
+        Processor,\r
+        GetSymbolValue (BASE_NAME)\r
+        );\r
+    }\r
+    AddSymbol (DEST_DIR, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILEPATH);\r
+  }\r
+  \r
+  //\r
+  // Create the output directory, then open the output component's makefile\r
+  // we're going to create. Allow them to override the makefile name.\r
+  //\r
+  TempCptr = GetSymbolValue (MAKEFILE_NAME);\r
+  if (TempCptr != NULL) {\r
+    ExpandSymbols (TempCptr, ComponentMakefileName, sizeof (ComponentMakefileName), EXPANDMODE_NO_UNDEFS);\r
+    TempCptr = ComponentMakefileName;\r
+  } else {\r
+    TempCptr = "makefile";\r
+  }\r
+\r
+  sprintf (FileName, "%s\\%s", GetSymbolValue (DEST_DIR), TempCptr);\r
+  //\r
+  // Save it now with path info\r
+  //\r
+  AddSymbol (MAKEFILE_NAME, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME);\r
+\r
+  if (MakeFilePath (FileName)) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if ((MakeFptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not create makefile");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // At this point we should have all the info we need to create a package\r
+  // file if setup to do so. Libraries don't use package files, so\r
+  // don't do this for libs.\r
+  //\r
+  if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) {\r
+    CreatePackageFile (DSCFile);\r
+  }\r
+\r
+  //\r
+  // Add Module name to the global module list\r
+  //\r
+  AddModuleName (&gGlobals.ModuleList, GetSymbolValue (BASE_NAME), GetSymbolValue (INF_FILENAME));\r
+  //\r
+  // Write an nmake line to makefile.out\r
+  //\r
+  fprintf (gGlobals.MakefileFptr, "  @cd %s\n", Processor);\r
+  fprintf (gGlobals.MakefileFptr, "  $(MAKE) -f %s all\n", FileName);\r
+  fprintf (gGlobals.MakefileFptr, "  @cd ..\n");\r
+\r
+  //\r
+  // Copy the common makefile section from the description file to\r
+  // the component's makefile\r
+  //\r
+  WriteCommonMakefile (DSCFile, MakeFptr, Processor);\r
+  //\r
+  // Process the component's [nmake.common] and [nmake.$(PROCESSOR)] sections\r
+  //\r
+  ProcessINFNMakeSection (&ComponentFile, MakeFptr);\r
+  //\r
+  // Create the SOURCE_FILES macro that includes the names of all source\r
+  // files in this component. This macro can then be used elsewhere to\r
+  // process all the files making up the component. Required for scanning\r
+  // files for string localization.\r
+  //\r
+  ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES);\r
+  //\r
+  // Create the include paths. Process [includes.common] and\r
+  // [includes.$(PROCESSOR)] and [includes.$(PROCESSOR).$(PLATFORM)] sections.\r
+  //\r
+  ProcessIncludesSection (&ComponentFile, MakeFptr);\r
+  //\r
+  // Process all include source files to create a dependency list that can\r
+  // be used in the makefile.\r
+  //\r
+  ProcessIncludeFiles (&ComponentFile, MakeFptr);\r
+  //\r
+  // Process the [sources.common], [sources.$(PROCESSOR)], and\r
+  // [sources.$(PROCESSOR).$(PLATFORM)] files and emit their build commands\r
+  //\r
+  ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_BUILD_COMMANDS);\r
+  //\r
+  // Process sources again to create an OBJECTS macro\r
+  //\r
+  ProcessObjects (&ComponentFile, MakeFptr);\r
+\r
+  //\r
+  // Add Single Module target : build and clean in top level makefile\r
+  //\r
+  fprintf (gGlobals.ModuleMakefileFptr, "%sbuild ::", GetSymbolValue (BASE_NAME));\r
+  if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) {\r
+    fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", GLOBAL_LINK_LIB_NAME);\r
+  }\r
+  \r
+  //\r
+  // Process all the libraries to define "LIBS = x.lib y.lib..."\r
+  // Be generous and append ".lib" if they forgot.\r
+  // Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib...\r
+  // Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...\r
+  //\r
+  ProcessLibs (&ComponentFile, MakeFptr);\r
+\r
+  fprintf (gGlobals.ModuleMakefileFptr, "\n");\r
+  \r
+  fprintf (gGlobals.ModuleMakefileFptr, "  @cd %s\n", Processor);\r
+  fprintf (gGlobals.ModuleMakefileFptr, "  $(MAKE) -f %s all\n", FileName);\r
+  fprintf (gGlobals.ModuleMakefileFptr, "  @cd ..\n\n");\r
+\r
+  fprintf (gGlobals.ModuleMakefileFptr, "%sclean ::\n", GetSymbolValue (BASE_NAME));\r
+  fprintf (gGlobals.ModuleMakefileFptr, "  $(MAKE) -f %s clean\n\n", FileName);\r
+  \r
+  //\r
+  // Emit commands to create the component. These are simply copied from\r
+  // the description file to the component's makefile. First look for\r
+  // [build.$(PROCESSOR).$(BUILD_TYPE)]. If not found, then look for if\r
+  // find a [build.$(PROCESSOR).$(COMPONENT_TYPE)] line.\r
+  //\r
+  Cptr = GetSymbolValue (BUILD_TYPE);\r
+  if (Cptr != NULL) {\r
+    sprintf (InLine, "build.%s.%s", Processor, Cptr);\r
+    WriteComponentTypeBuildCommands (DSCFile, MakeFptr, InLine);\r
+  } else {\r
+    sprintf (InLine, "build.%s.%s", Processor, GetSymbolValue (COMPONENT_TYPE));\r
+    WriteComponentTypeBuildCommands (DSCFile, MakeFptr, InLine);\r
+  }\r
+  //\r
+  // Add it to the FV if not a library\r
+  //\r
+  if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) {\r
+    //\r
+    // Create the FV filename and add it to the FV.\r
+    // By this point we know it's in FV.\r
+    //\r
+    Cptr = GetSymbolValue (FILE_GUID);\r
+    if (Cptr == NULL) {\r
+      Cptr = GetSymbolValue (GUID);\r
+    }\r
+\r
+    sprintf (InLine, "%s-%s", Cptr, GetSymbolValue (BASE_NAME));\r
+    //\r
+    // We've deprecated FV_EXT, which should be FFS_EXT, the extension\r
+    // of the FFS file generated by GenFFSFile.\r
+    //\r
+    TempCptr = GetSymbolValue (FFS_EXT);\r
+    if (TempCptr == NULL) {\r
+      TempCptr = GetSymbolValue ("FV_EXT");\r
+    }\r
+\r
+    CFVAddFVFile (\r
+      InLine,\r
+      GetSymbolValue (COMPONENT_TYPE),\r
+      GetSymbolValue (FV),\r
+      Instance,\r
+      TempCptr,\r
+      Processor,\r
+      GetSymbolValue (APRIORI),\r
+      GetSymbolValue (BASE_NAME),\r
+      Cptr\r
+      );\r
+  }\r
+  //\r
+  // Catch any failures and print the name of the component file\r
+  // being processed to assist debugging.\r
+  //\r
+ComponentDone:\r
+\r
+  Cptr = CatchException ();\r
+  if (Cptr != NULL) {\r
+    fprintf (stderr, "%s\n", Cptr);\r
+    sprintf (InLine, "Processing of component %s failed", ArgLine);\r
+    ThrowException (InLine);\r
+  }\r
+\r
+  if (MakeFptr != NULL) {\r
+    fclose (MakeFptr);\r
+  }\r
+\r
+  if (ComponentCreated) {\r
+    DSCFileDestroy (&ComponentFile);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+CreatePackageFile (\r
+  DSC_FILE          *DSCFile\r
+  )\r
+{\r
+  INT8       *Package;\r
+  SECTION    *TempSect;\r
+  INT8       Str[MAX_LINE_LEN];\r
+  INT8       StrExpanded[MAX_LINE_LEN];\r
+  SMART_FILE *PkgFptr;\r
+  int        Status;\r
+\r
+  PkgFptr = NULL;\r
+\r
+  //\r
+  // First find out if PACKAGE_FILENAME or PACKAGE is defined. PACKAGE_FILENAME\r
+  // is used to specify the exact package file to use. PACKAGE is used to\r
+  // specify the package section name.\r
+  //\r
+  Package = GetSymbolValue (PACKAGE_FILENAME);\r
+  if (Package != NULL) {\r
+    //\r
+    // Use existing file. We're done.\r
+    //\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // See if PACKAGE or PACKAGE_TAG is defined\r
+  //\r
+  Package = GetSymbolValue (PACKAGE);\r
+  if (Package == NULL) {\r
+    Package = GetSymbolValue (PACKAGE_TAG);\r
+  }\r
+\r
+  if (Package == NULL) {\r
+    //\r
+    // Not defined either. Assume they are not using the package functionality\r
+    // of this utility. However define the PACKAGE_FILENAME macro to the\r
+    // best-guess value.\r
+    //\r
+    sprintf (\r
+      Str,\r
+      "%s\\%s.pkg",\r
+      GetSymbolValue (SOURCE_DIR),\r
+      GetSymbolValue (BASE_NAME)\r
+      );\r
\r
+    //\r
+    // Expand symbols in the package filename\r
+    //\r
+    ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_NO_UNDEFS);    \r
\r
+    AddSymbol (PACKAGE_FILENAME, StrExpanded, SYM_LOCAL | SYM_FILENAME);\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // Save the position in the DSC file.\r
+  // Find the [package.$(COMPONENT_TYPE).$(PACKAGE)] section in the DSC file\r
+  //\r
+  Status = STATUS_SUCCESS;\r
+  DSCFileSavePosition (DSCFile);\r
+  sprintf (Str, "%s.%s.%s", PACKAGE, GetSymbolValue (COMPONENT_TYPE), Package);\r
+  TempSect = DSCFileFindSection (DSCFile, Str);\r
+  if (TempSect != NULL) {\r
+    //\r
+    // So far so good. Create the name of the package file, then open it up\r
+    // for writing. File name is c:\...\oem\platform\nt32\ia32\...\BaseName.pkg.\r
+    //\r
+    sprintf (\r
+      Str,\r
+      "%s\\%s.pkg",\r
+      GetSymbolValue (DEST_DIR),\r
+      GetSymbolValue (BASE_NAME)\r
+      );\r
+    \r
+    //\r
+    // Expand symbols in the package filename\r
+    //\r
+    ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_NO_UNDEFS);    \r
+    \r
+    //\r
+    // Try to open the file, then save the file name as the PACKAGE_FILENAME\r
+    // symbol for use elsewhere.\r
+    //\r
+    if ((PkgFptr = SmartOpen (StrExpanded)) == NULL) {\r
+      Error (NULL, 0, 0, Str, "could not open package file for writing");\r
+      Status = STATUS_ERROR;\r
+      goto Finish;\r
+    }\r
+\r
+    AddSymbol (PACKAGE_FILENAME, StrExpanded, SYM_LOCAL | SYM_FILENAME);\r
+    //\r
+    // Now read lines in from the DSC file and write them back out to the\r
+    // package file (with string substitution).\r
+    //\r
+    while (DSCFileGetLine (DSCFile, Str, sizeof (Str)) != NULL) {\r
+      //\r
+      // Expand symbols, then write the line out to the package file\r
+      //\r
+      ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_RECURSIVE);\r
+      SmartWrite (PkgFptr, StrExpanded);\r
+    }\r
+  } else {\r
+    Warning (\r
+      NULL,\r
+      0,\r
+      0,\r
+      NULL,\r
+      "cannot locate package section [%s] in DSC file for %s",\r
+      Str,\r
+      GetSymbolValue (INF_FILENAME)\r
+      );\r
+    Status = STATUS_WARNING;\r
+    goto Finish;\r
+  }\r
+\r
+  if (PkgFptr != NULL) {\r
+    SmartClose (PkgFptr);\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Restore the position in the DSC file\r
+  //\r
+  DSCFileRestorePosition (DSCFile);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessINFDefinesSection (\r
+  DSC_FILE   *ComponentFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the [defines.xxx] sections of the component description file. Process\r
+  platform first, then processor. In this way, if a platform wants and override,\r
+  that one gets parsed first, and later assignments do not overwrite the value.\r
+  \r
+Arguments:\r
+\r
+  ComponentFile     - section info on the component file being processed\r
+\r
+Returns:\r
+\r
\r
+--*/\r
+{\r
+  INT8  *Cptr;\r
+  INT8  Str[MAX_LINE_LEN];\r
+\r
+  //\r
+  // Find a [defines.$(PROCESSOR).$(PLATFORM)] section and process it\r
+  //\r
+  Cptr = GetSymbolValue (PLATFORM);\r
+  if (Cptr != NULL) {\r
+    sprintf (\r
+      Str,\r
+      "%s.%s.%s",\r
+      DEFINES_SECTION_NAME,\r
+      GetSymbolValue (PROCESSOR),\r
+      Cptr\r
+      );\r
+    ProcessINFDefinesSectionSingle (ComponentFile, Str);\r
+  }\r
+  //\r
+  // Find a [defines.$(PROCESSOR)] section and process it\r
+  //\r
+  sprintf (Str, "%s.%s", DEFINES_SECTION_NAME, GetSymbolValue (PROCESSOR));\r
+  ProcessINFDefinesSectionSingle (ComponentFile, Str);\r
+\r
+  //\r
+  // Find a [defines] section and process it\r
+  //\r
+  if (ProcessINFDefinesSectionSingle (ComponentFile, DEFINES_SECTION_NAME) != STATUS_SUCCESS) {\r
+    Error (NULL, 0, 0, NULL, "missing [defines] section in component file %s", GetSymbolValue (INF_FILENAME));\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessINFDefinesSectionSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  INT8      *SectionName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    ExpandedLine[MAX_LINE_LEN];\r
+  SECTION *TempSect;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0);\r
+      Cptr = StripLine (ExpandedLine);\r
+      //\r
+      // Don't process blank lines.\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Add without overwriting macros specified on the component line\r
+        // in the description file\r
+        //\r
+        AddSymbol (Cptr, NULL, SYM_LOCAL);\r
+      }\r
+    }\r
+  } else {\r
+    return STATUS_WARNING;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessINFNMakeSection (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the [nmake.common] and [nmake.$(PROCESSOR)] sections of the component\r
+  description file and write and copy them to the component's makefile.\r
+  \r
+Arguments:\r
+\r
+  ComponentFile     - section info on the component file being processed\r
+  MakeFptr          - file pointer to the component' makefile we're creating\r
+\r
+Returns:\r
+\r
+  Always STATUS_SUCCESS right now, since the sections are optional.\r
+  \r
+--*/\r
+{\r
+  INT8    *Cptr;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    ExpandedLine[MAX_LINE_LEN];\r
+  SECTION *TempSect;\r
+\r
+  //\r
+  // Copy the [nmake.common] and [nmake.$(PROCESSOR)] sections from the\r
+  // component file directly to the output file.\r
+  // The line will be stripped and don't print blank lines\r
+  //\r
+  sprintf (Str, "%s.%s", NMAKE_SECTION_NAME, COMMON_SECTION_NAME);\r
+  TempSect = DSCFileFindSection (ComponentFile, Str);\r
+  if (TempSect != NULL) {\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      ExpandSymbols (\r
+        Str,\r
+        ExpandedLine,\r
+        sizeof (ExpandedLine),\r
+        EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+        );\r
+      Cptr = StripLine (ExpandedLine);\r
+      if (*Cptr) {\r
+        fprintf (MakeFptr, "%s\n", Cptr);\r
+      }\r
+    }\r
+\r
+    fprintf (MakeFptr, "\n");\r
+  } else {\r
+    Error (GetSymbolValue (INF_FILENAME), 1, 0, Str, "section not found in component INF file");\r
+  }\r
+\r
+  sprintf (Str, "%s.%s", NMAKE_SECTION_NAME, GetSymbolValue (PROCESSOR));\r
+  TempSect = DSCFileFindSection (ComponentFile, Str);\r
+  if (TempSect != NULL) {\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      ExpandSymbols (\r
+        Str,\r
+        ExpandedLine,\r
+        sizeof (ExpandedLine),\r
+        EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+        );\r
+      Cptr = StripLine (ExpandedLine);\r
+      if (*Cptr) {\r
+        fprintf (MakeFptr, "%s\n", Cptr);\r
+      }\r
+    }\r
+\r
+    fprintf (MakeFptr, "\n");\r
+  }\r
+  //\r
+  // Do the same for [nmake.$(PROCESSOR).$(PLATFORM)]\r
+  //\r
+  Cptr = GetSymbolValue (PLATFORM);\r
+  if (Cptr != NULL) {\r
+    sprintf (Str, "%s.%s.%s", NMAKE_SECTION_NAME, GetSymbolValue (PROCESSOR), Cptr);\r
+    TempSect = DSCFileFindSection (ComponentFile, Str);\r
+    if (TempSect != NULL) {\r
+      while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+        ExpandSymbols (\r
+          Str,\r
+          ExpandedLine,\r
+          sizeof (ExpandedLine),\r
+          EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+          );\r
+        Cptr = StripLine (ExpandedLine);\r
+        if (*Cptr) {\r
+          fprintf (MakeFptr, "%s\n", Cptr);\r
+        }\r
+      }\r
+\r
+      fprintf (MakeFptr, "\n");\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessIncludesSection (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the [includes.common], [includes.processor], and \r
+  [includes.processor.platform] section of the component description file \r
+  and write the appropriate macros to the component's makefile.\r
+\r
+  Process in reverse order to allow overrides on platform basis.\r
+    \r
+Arguments:\r
+\r
+  ComponentFile     - section info on the component file being processed\r
+  MakeFptr          - file pointer to the component' makefile we're creating\r
+\r
+Returns:\r
+\r
+  Always STATUS_SUCCESS right now, since the sections are optional.\r
+  \r
+--*/\r
+{\r
+  INT8  *Cptr;\r
+  INT8  Str[MAX_LINE_LEN];\r
+  INT8  *Processor;\r
+  INT8  *OverridePath;\r
+\r
+  //\r
+  // Write a useful comment to the output makefile so the user knows where\r
+  // the data came from.\r
+  //\r
+  fprintf (MakeFptr, "#\n# Tool-generated list of include paths that are created\n");\r
+  fprintf (MakeFptr, "# from the list of include paths in the [includes.*] sections\n");\r
+  fprintf (MakeFptr, "# of the component INF file.\n#\n");\r
+\r
+  //\r
+  // We use this a lot here, so get the value only once.\r
+  //\r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  //\r
+  // If they're using an override source path, then add OverridePath and\r
+  // OverridePath\$(PROCESSOR) to the list of include paths.\r
+  //\r
+  OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);\r
+  if (OverridePath != NULL) {\r
+    fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath);\r
+    fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor);\r
+  }\r
+  //\r
+  // Try for an [includes.$(PROCESSOR).$(PLATFORM)]\r
+  //\r
+  Cptr = GetSymbolValue (PLATFORM);\r
+  if (Cptr != NULL) {\r
+    sprintf (Str, "%s.%s.%s", INCLUDE_SECTION_NAME, Processor, Cptr);\r
+    ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str);\r
+  }\r
+  //\r
+  // Now the [includes.$(PROCESSOR)] section\r
+  //\r
+  sprintf (Str, "%s.%s", INCLUDE_SECTION_NAME, Processor);\r
+  ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str);\r
+\r
+  //\r
+  // Now the [includes.common] section\r
+  //\r
+  sprintf (Str, "%s.%s", INCLUDE_SECTION_NAME, COMMON_SECTION_NAME);\r
+  ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str);\r
+\r
+  //\r
+  // Done\r
+  //\r
+  fprintf (MakeFptr, "\n");\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process one of the [includes.xxx] sections to create a list of all\r
+// the include paths.\r
+//\r
+static\r
+int\r
+ProcessIncludesSectionSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  SECTION *TempSect;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    ExpandedLine[MAX_LINE_LEN];\r
+  INT8    *Processor;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    //\r
+    // Add processor subdirectory on every include path\r
+    //\r
+    Processor = GetSymbolValue (PROCESSOR);\r
+    //\r
+    // Copy lines directly\r
+    //\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0);\r
+      Cptr = StripLine (ExpandedLine);\r
+      //\r
+      // Don't process blank lines\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Strip off trailing slash\r
+        //\r
+        if (Cptr[strlen (Cptr) - 1] == '\\') {\r
+          Cptr[strlen (Cptr) - 1] = 0;\r
+        }\r
+        //\r
+        // Special case of ".". Replace it with source path\r
+        // and the rest of the line (for .\$(PROCESSOR))\r
+        //\r
+        if (*Cptr == '.') {\r
+          //\r
+          // Handle case of just a "."\r
+          //\r
+          if (Cptr[1] == 0) {\r
+            fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n");\r
+            fprintf (\r
+              MakeFptr,\r
+              "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",\r
+              Processor\r
+              );\r
+          } else {\r
+            //\r
+            // Handle case of ".\path\path\path" or "..\path\path\path"\r
+            //\r
+            fprintf (\r
+              MakeFptr,\r
+              "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",\r
+              Cptr\r
+              );\r
+            fprintf (\r
+              MakeFptr,\r
+              "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n",\r
+              Cptr,\r
+              Processor\r
+              );\r
+          }\r
+        } else if ((Cptr[1] != ':') && isalpha (*Cptr)) {\r
+          fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr);\r
+          fprintf (\r
+            MakeFptr,\r
+            "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n",\r
+            Cptr,\r
+            Processor\r
+            );\r
+        } else {\r
+          //\r
+          // The line is something like: $(EFI_SOURCE)\dxe\include. Add it to\r
+          // the existing $(INC) definition. Add user includes before any\r
+          // other existing paths.\r
+          //\r
+          fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr);\r
+          fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor);\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessSourceFiles (\r
+  DSC_FILE  *DSCFile,\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  UINT32    Mode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the [sources.common], [sources.$(PROCESSOR)], and \r
+  [sources.$(PROCESSOR).$(PLATFORM] sections of the component\r
+  description file and write the appropriate build commands out to the \r
+  component's makefile. If $(SOURCE_SELECT) is defined, then it overrides\r
+  the source selections. We use this functionality for SMM.\r
+  \r
+Arguments:\r
+\r
+  ComponentFile     - section info on the component file being processed\r
+  MakeFptr          - file pointer to the component' makefile we're creating\r
+  DSCFile           - section info on the description file we're processing\r
+  Mode              - to write build commands, or just create a list\r
+                      of sources.\r
+\r
+Returns:\r
+\r
+  Always STATUS_SUCCESS right now, since the sections are optional.\r
+  \r
+--*/\r
+{\r
+  INT8  Str[MAX_LINE_LEN];\r
+  INT8  *Processor;\r
+  INT8  *Platform;\r
+  INT8  *SourceSelect;\r
+  INT8  *CStart;\r
+  INT8  *CEnd;\r
+  INT8  CSave;\r
+  INT8  *CopySourceSelect;\r
+\r
+  if (Mode & SOURCE_MODE_SOURCE_FILES) {\r
+    //\r
+    // Write a useful comment to the output makefile so the user knows where\r
+    // the data came from.\r
+    //\r
+    fprintf (MakeFptr, "#\n# Tool-generated list of source files that are created\n");\r
+    fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n");\r
+    fprintf (MakeFptr, "# of the component INF file.\n#\n");\r
+  }\r
+  \r
+  //\r
+  // We use this a lot here, so get the value only once.\r
+  //\r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  //\r
+  // See if they defined SOURCE_SELECT=xxx,yyy in which case we'll\r
+  // select each [sources.xxx] and [sources.yyy] files and process\r
+  // them.\r
+  //\r
+  SourceSelect = GetSymbolValue (SOURCE_SELECT);\r
+\r
+  if (SourceSelect != NULL) {\r
+    //\r
+    // Make a copy of the string and break it up (comma-separated) and\r
+    // select each [sources.*] file from the INF.\r
+    //\r
+    CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1);\r
+    if (CopySourceSelect == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (CopySourceSelect, SourceSelect);\r
+    CStart  = CopySourceSelect;\r
+    CEnd    = CStart;\r
+    while (*CStart) {\r
+      CEnd = CStart + 1;\r
+      while (*CEnd && *CEnd != ',') {\r
+        CEnd++;\r
+      }\r
+\r
+      CSave = *CEnd;\r
+      *CEnd = 0;\r
+      sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart);\r
+      ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode);\r
+      //\r
+      // Restore the terminator and advance\r
+      //\r
+      *CEnd   = CSave;\r
+      CStart  = CEnd;\r
+      if (*CStart) {\r
+        CStart++;\r
+      }\r
+    }\r
+\r
+    free (CopySourceSelect);\r
+\r
+  } else {\r
+    //\r
+    // Process all the [sources.common] source files to make them build\r
+    //\r
+    sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME);\r
+    ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode);\r
+    //\r
+    // Now process the [sources.$(PROCESSOR)] files.\r
+    //\r
+    sprintf (Str, "sources.%s", Processor);\r
+    ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode);\r
+    //\r
+    // Now process the [sources.$(PROCESSOR).$(PLATFORM)] files.\r
+    //\r
+    Platform = GetSymbolValue (PLATFORM);\r
+    if (Platform != NULL) {\r
+      sprintf (Str, "sources.%s.%s", Processor, Platform);\r
+      ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode);\r
+    }\r
+  }\r
+\r
+  fprintf (MakeFptr, "\n");\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Given a source file line from an INF file, parse it to see if there are\r
+  any defines on it. If so, then add them to the symbol table.\r
+  Also, terminate the line after the file name.\r
+  \r
+Arguments:\r
+  SourceFileLine - a line from a [sources.?] section of the INF file. Likely\r
+  something like:\r
+  \r
+  MySourceFile.c   BUILT_NAME=$(BUILD_DIR)\MySourceFile.obj\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+static\r
+void\r
+AddFileSymbols (\r
+  INT8    *SourceFileLine\r
+  )\r
+{\r
+  int Len;\r
+  //\r
+  // Skip spaces\r
+  //\r
+  for (; *SourceFileLine && isspace (*SourceFileLine); SourceFileLine++)\r
+    ;\r
+  for (; *SourceFileLine && !isspace (*SourceFileLine); SourceFileLine++)\r
+    ;\r
+  if (*SourceFileLine) {\r
+    *SourceFileLine = 0;\r
+    SourceFileLine++;\r
+    //\r
+    // AddSymbol() will parse it for us, and return the length. Keep calling\r
+    // it until it reports an error or is done.\r
+    //\r
+    do {\r
+      Len = AddSymbol (SourceFileLine, NULL, SYM_FILE);\r
+      SourceFileLine += Len;\r
+    } while (Len > 0);\r
+  }\r
+}\r
+//\r
+// Process a single section of source files in the component INF file\r
+//\r
+static\r
+int\r
+ProcessSourceFilesSection (\r
+  DSC_FILE  *DSCFile,\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName,\r
+  UINT32    Mode\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    FileName[MAX_EXP_LINE_LEN];\r
+  INT8    FilePath[MAX_PATH];\r
+  INT8    TempFileName[MAX_PATH];\r
+  SECTION *TempSect;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    *Processor;\r
+  INT8    *OverridePath;\r
+  FILE    *FPtr;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    Processor = GetSymbolValue (PROCESSOR);\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      Cptr = StripLine (Str);\r
+      //\r
+      // Don't process blank lines\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Expand symbols in the filename, then parse the line for symbol\r
+        // definitions. AddFileSymbols() will null-terminate the line\r
+        // after the file name. Save a copy for override purposes, in which\r
+        // case we'll need to know the file name and path (in case it's in\r
+        // a subdirectory).\r
+        //\r
+        ExpandSymbols (Cptr, FileName, sizeof (FileName), 0);\r
+        AddFileSymbols (FileName);\r
+        //\r
+        // Set the SOURCE_FILE_NAME symbol. What we have now is the name of\r
+        // the file, relative to the location of the INF file. So prepend\r
+        // $(SOURCE_DIR) to it first.\r
+        //\r
+        if (IsAbsolutePath (FileName)) {\r
+          strcpy (TempFileName, FileName);\r
+        } else {\r
+          strcpy (TempFileName, "$(SOURCE_DIR)\\");\r
+          strcat (TempFileName, FileName);\r
+        }\r
+        AddSymbol (SOURCE_FILE_NAME, TempFileName, SYM_FILE | SYM_OVERWRITE);\r
+        //\r
+        // Extract path information from the source file and set internal\r
+        // variable SOURCE_RELATIVE_PATH. Only do this if the path\r
+        // contains a backslash.\r
+        //\r
+        strcpy (FilePath, FileName);\r
+        for (Cptr = FilePath + strlen (FilePath) - 1; (Cptr > FilePath) && (*Cptr != '\\'); Cptr--)\r
+          ;\r
+        if (*Cptr == '\\') {\r
+          *(Cptr + 1) = 0;\r
+          AddSymbol (SOURCE_RELATIVE_PATH, FilePath, SYM_FILE);\r
+        }\r
+        //\r
+        // Define another internal symbol for the name of the file without\r
+        // the path and extension.\r
+        //\r
+        for (Cptr = FileName + strlen (FileName) - 1; (Cptr > FileName) && (*Cptr != '\\'); Cptr--)\r
+          ;\r
+        if (*Cptr == '\\') {\r
+          Cptr++;\r
+        }\r
+\r
+        strcpy (FilePath, Cptr);\r
+        //\r
+        // We now have a file name with no path information. Before we do anything else,\r
+        // see if OVERRIDE_PATH is set, and if so, see if file $(OVERRIDE_PATH)FileName\r
+        // exists. If it does, then recursive call this function to use the override file\r
+        // instead of the one from the INF file.\r
+        //\r
+        if (IsAbsolutePath (FileName)) {\r
+          OverridePath = NULL;\r
+        } else {\r
+          OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);\r
+        }\r
+        if (OverridePath != NULL) {\r
+          //\r
+          // See if the file exists. If it does, reset the SOURCE_FILE_NAME symbol.\r
+          //\r
+          strcpy (TempFileName, OverridePath);\r
+          strcat (TempFileName, "\\");\r
+          strcat (TempFileName, FileName);\r
+          if ((FPtr = fopen (TempFileName, "rb")) != NULL) {\r
+            fclose (FPtr);\r
+            AddSymbol (SOURCE_FILE_NAME, TempFileName, SYM_FILE | SYM_OVERWRITE);\r
+            //\r
+            // Print a message. This function is called to create build commands\r
+            // for source files, and to create a macro of all source files. Therefore\r
+            // do this check so we don't print the override message multiple times.\r
+            //\r
+            if (Mode & SOURCE_MODE_BUILD_COMMANDS) {\r
+              fprintf (stdout, "Override: %s\n", TempFileName);\r
+            }\r
+          } else {\r
+            //\r
+            // Set override path to null to use as a flag below\r
+            //\r
+            OverridePath = NULL;\r
+          }\r
+        }\r
+\r
+        //\r
+        // Start at the end and work back\r
+        //\r
+        for (Cptr = FilePath + strlen (FilePath) - 1; (Cptr > FilePath) && (*Cptr != '\\') && (*Cptr != '.'); Cptr--)\r
+          ;\r
+        if (*Cptr == '.') {\r
+          *Cptr = 0;\r
+          AddSymbol (SOURCE_FILE_EXTENSION, Cptr + 1, SYM_FILE);\r
+        }\r
+\r
+        AddSymbol (SOURCE_BASE_NAME, FilePath, SYM_FILE);\r
+        //\r
+        // If we're just creating the SOURCE_FILES macro, then write the\r
+        // file name out to the makefile.\r
+        //\r
+        if (Mode & SOURCE_MODE_SOURCE_FILES) {\r
+          //\r
+          // If we're processing an override file, then use the file name as-is\r
+          //\r
+          if (OverridePath != NULL) {\r
+            //\r
+            // SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c\r
+            //\r
+            fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName);\r
+          } else if (IsAbsolutePath (FileName)) {\r
+            //\r
+            // For Absolute path, don't print $(SOURCE_FILE) directory.\r
+            //\r
+            fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName);\r
+          } else {\r
+            //\r
+            // SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c\r
+            //\r
+            fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName);\r
+          }\r
+        } else if (Mode & SOURCE_MODE_BUILD_COMMANDS) {\r
+          //\r
+          // Write the build commands for this file per the build commands\r
+          // for this file type as defined in the description file.\r
+          // Also create the directory for it in the build path.\r
+          //\r
+          WriteCompileCommands (DSCFile, MakeFptr, FileName, Processor);\r
+          if (!IsAbsolutePath (FileName)) {\r
+            sprintf (Str, "%s\\%s", GetSymbolValue (DEST_DIR), FileName);\r
+            MakeFilePath (Str);\r
+            //\r
+            // Get all output directory for build output files.\r
+            //\r
+            Cptr = FileName + strlen (FileName) - 1;\r
+            for (; (Cptr > FileName) && (*Cptr != '\\'); Cptr--);\r
+            if (*Cptr == '\\') {\r
+              *Cptr = '\0';\r
+              AddModuleName (&gGlobals.OutdirList, FileName, NULL);\r
+            }\r
+          }\r
+        }\r
+        //\r
+        // Remove file-level symbols\r
+        //\r
+        RemoveFileSymbols ();\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process the INF [sources.*] sections and emit the OBJECTS = .....\r
+// lines to the component's makefile.\r
+//\r
+static\r
+int\r
+ProcessObjects (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  )\r
+{\r
+  INT8  Str[MAX_LINE_LEN];\r
+  INT8  *Processor;\r
+  INT8  *Platform;\r
+  INT8  *SourceSelect;\r
+  INT8  *CStart;\r
+  INT8  *CEnd;\r
+  INT8  CSave;\r
+  INT8  *CopySourceSelect;\r
+  SYMBOL *TempSymbol;\r
+\r
+  //\r
+  // Write a useful comment to the output makefile so the user knows where\r
+  // the data came from.\r
+  //\r
+  fprintf (MakeFptr, "#\n# Tool-generated list of object files that are created\n");\r
+  fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n");\r
+  fprintf (MakeFptr, "# of the component INF file.\n#\n");\r
+  //\r
+  // We use this a lot here, so get the value only once.\r
+  //\r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  //\r
+  // Now define the OBJECTS variable and assign it to be all the object files we're going\r
+  // to create. Afterwards create a pseudo-target objects to let the user quickly just compile\r
+  // the source files. This means we need to process all the common objects and\r
+  // processor-specific objects again.\r
+  //\r
+  fprintf (MakeFptr, "OBJECTS = $(OBJECTS) ");\r
+  //\r
+  // See if they defined SOURCE_SELECT=xxx,yyy in which case well\r
+  // select each [sources.xxx] and [sources.yyy] files and process\r
+  // them.\r
+  //\r
+  SourceSelect = GetSymbolValue (SOURCE_SELECT);\r
+\r
+  if (SourceSelect != NULL) {\r
+    //\r
+    // Make a copy of the string and break it up (comma-separated) and\r
+    // select each [sources.*] file from the INF.\r
+    //\r
+    CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1);\r
+    if (CopySourceSelect == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (CopySourceSelect, SourceSelect);\r
+    CStart  = CopySourceSelect;\r
+    CEnd    = CStart;\r
+    while (*CStart) {\r
+      CEnd = CStart + 1;\r
+      while (*CEnd && *CEnd != ',') {\r
+        CEnd++;\r
+      }\r
+\r
+      CSave = *CEnd;\r
+      *CEnd = 0;\r
+      sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart);\r
+      ProcessObjectsSingle (ComponentFile, MakeFptr, Str);\r
+      //\r
+      // Restore the terminator and advance\r
+      //\r
+      *CEnd   = CSave;\r
+      CStart  = CEnd;\r
+      if (*CStart) {\r
+        CStart++;\r
+      }\r
+    }\r
+\r
+    free (CopySourceSelect);\r
+  \r
+  } else {\r
+    //\r
+    // Now process all the [sources.common] files and emit build commands for them\r
+    //\r
+    sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME);\r
+    if (ProcessObjectsSingle (ComponentFile, MakeFptr, Str) != STATUS_SUCCESS) {\r
+      Warning (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "no [%s] section found in component description", Str);\r
+    }\r
+    //\r
+    // Now process any processor-specific source files in [sources.$(PROCESSOR)]\r
+    //\r
+    sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, Processor);\r
+    ProcessObjectsSingle (ComponentFile, MakeFptr, Str);\r
+\r
+    //\r
+    // Now process any [sources.$(PROCESSOR).$(PLATFORM)] files\r
+    //\r
+    Platform = GetSymbolValue (PLATFORM);\r
+    if (Platform != NULL) {\r
+      sprintf (Str, "sources.%s.%s", Processor, Platform);\r
+      ProcessObjectsSingle (ComponentFile, MakeFptr, Str);\r
+    }\r
+  }\r
+\r
+  fprintf (MakeFptr, "\n\n");\r
+\r
+  //\r
+  // Write a useful comment to the output makefile so the user knows where\r
+  // the data came from.\r
+  //\r
+  fprintf (MakeFptr, "#\n# Tool-generated list of dest output dirs that are created\n");\r
+  fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n");\r
+  fprintf (MakeFptr, "# of the component INF file.\n#\n");\r
+  //\r
+  // Create output directory list \r
+  // for clean target to delete all build output files.\r
+  //\r
+  fprintf (MakeFptr, "DEST_OUTPUT_DIRS = $(%s) ", DEST_DIR);\r
+\r
+  TempSymbol = gGlobals.OutdirList;\r
+  while (TempSymbol != NULL) {\r
+    fprintf (MakeFptr, "\\\n                   $(%s)\\%s   ", \r
+             DEST_DIR, TempSymbol->Name);\r
+    TempSymbol = TempSymbol->Next;\r
+  }\r
+  fprintf (MakeFptr, "\n\n");\r
+  \r
+  //\r
+  // clean up for the next module\r
+  //\r
+  FreeSymbols (gGlobals.OutdirList);\r
+  gGlobals.OutdirList = NULL;\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+INT8 *\r
+BuiltFileExtension (\r
+  INT8      *SourceFileName\r
+  )\r
+{\r
+  int   i;\r
+  INT8  *Cptr;\r
+  //\r
+  // Find the dot in the filename extension\r
+  //\r
+  for (Cptr = SourceFileName + strlen (SourceFileName) - 1;\r
+       (Cptr > SourceFileName) && (*Cptr != '\\') && (*Cptr != '.');\r
+       Cptr--\r
+      ) {\r
+    //\r
+    // Do nothing\r
+    //\r
+  }\r
+\r
+  if (*Cptr != '.') {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Look through our list of known file types and return a pointer to\r
+  // its built file extension.\r
+  //\r
+  for (i = 0; mFileTypes[i].Extension != NULL; i++) {\r
+    if (_stricmp (Cptr, mFileTypes[i].Extension) == 0) {\r
+      return mFileTypes[i].BuiltExtension;\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+int\r
+ProcessObjectsSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    *Cptr2;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    FileName[MAX_EXP_LINE_LEN];\r
+  SECTION *TempSect;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      Cptr = StripLine (Str);\r
+      //\r
+      // Don't process blank lines\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Expand symbols then create the output filename. We'll do a lookup\r
+        // on the source file's extension to determine what the extension of\r
+        // the built version of the file is. For example, .c -> .obj.\r
+        //\r
+        if (!IsIncludeFile (Cptr)) {\r
+          ExpandSymbols (Cptr, FileName, sizeof (FileName), 0);\r
+          Cptr2 = BuiltFileExtension (FileName);\r
+          if (Cptr2 != NULL) {\r
+            SetFileExtension (FileName, Cptr2);\r
+            if (!IsAbsolutePath (FileName)) {\r
+              fprintf (MakeFptr, "\\\n          $(%s)\\%s   ", DEST_DIR, FileName);\r
+            } else {\r
+              fprintf (MakeFptr, "\\\n          %s   ", FileName);\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+    return STATUS_WARNING;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process all [libraries.*] sections in the component INF file to create a\r
+// macro to the component's output makefile: LIBS = Lib1 Lib2, ...\r
+//\r
+static\r
+int\r
+ProcessLibs (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr\r
+  )\r
+{\r
+  INT8  Str[MAX_LINE_LEN];\r
+  INT8  *Processor;\r
+  INT8  *Platform;\r
+\r
+  //\r
+  // Print a useful comment to the component's makefile so the user knows\r
+  // where the data came from.\r
+  //\r
+  fprintf (MakeFptr, "#\n# Tool-generated list of libraries that are generated\n");\r
+  fprintf (MakeFptr, "# from the list of libraries listed in the [libraries.*] sections\n");\r
+  fprintf (MakeFptr, "# of the component INF file.\n#\n");\r
+  \r
+  fprintf (MakeFptr, "LIBS = $(LIBS) ");\r
+  \r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  //\r
+  // Process [libraries.common] files\r
+  //\r
+  sprintf (Str, "%s.%s", LIBRARIES_SECTION_NAME, COMMON_SECTION_NAME);\r
+  ProcessLibsSingle (ComponentFile, MakeFptr, Str);\r
+  //\r
+  // Process the [libraries.$(PROCESSOR)] libraries to define "LIBS = x.lib y.lib..."\r
+  //\r
+  sprintf (Str, "%s.%s", LIBRARIES_SECTION_NAME, Processor);\r
+  ProcessLibsSingle (ComponentFile, MakeFptr, Str);\r
+  //\r
+  // Now process any [libraries.$(PROCESSOR).$(PLATFORM)] files\r
+  //\r
+  Platform = GetSymbolValue (PLATFORM);\r
+  if (Platform != NULL) {\r
+    sprintf (Str, "%s.%s.%s", LIBRARIES_SECTION_NAME, Processor, Platform);\r
+    ProcessLibsSingle (ComponentFile, MakeFptr, Str);\r
+  }\r
+  //\r
+  // Process any [libraries.platform] files\r
+  //\r
+  ProcessLibsSingle (ComponentFile, MakeFptr, LIBRARIES_PLATFORM_SECTION_NAME);\r
+\r
+  fprintf (MakeFptr, "\n\n");\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessLibsSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    Str[MAX_LINE_LEN];\r
+  INT8    ExpandedLine[MAX_LINE_LEN];\r
+  SECTION *TempSect;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0);\r
+      Cptr = StripLine (ExpandedLine);\r
+      //\r
+      // Don't process blank lines\r
+      //\r
+      if (*Cptr) {\r
+        if (Cptr[strlen (Cptr) - 4] != '.') {\r
+          fprintf (MakeFptr, "    \\\n       $(LIB_DIR)\\%s.lib", Cptr);\r
+          //\r
+          // Add lib dependency for single module build\r
+          //\r
+          fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);\r
+        } else {\r
+          fprintf (MakeFptr, "    \\\n       $(LIB_DIR)\\%s", Cptr);\r
+          //\r
+          // Add lib dependency for single module build\r
+          //\r
+          Cptr[strlen (Cptr) - 4] = 0;\r
+          fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ProcessIncludeFiles (\r
+  DSC_FILE *ComponentFile,\r
+  FILE     *MakeFptr\r
+  )\r
+{\r
+  INT8  Str[MAX_LINE_LEN];\r
+  INT8  *Processor;\r
+  INT8  *Platform;\r
+  INT8  *SourceSelect;\r
+  INT8  *CStart;\r
+  INT8  *CEnd;\r
+  INT8  CSave;\r
+  INT8  *CopySourceSelect;\r
+\r
+  //\r
+  // Print a useful comment to the output makefile so the user knows where\r
+  // the info came from\r
+  //\r
+  //fprintf (MakeFptr, "#\n# Tool-generated include dependencies from any include files in the\n");\r
+  //fprintf (MakeFptr, "# [sources.*] sections of the component INF file\n#\n");\r
+\r
+  Processor = GetSymbolValue (PROCESSOR);\r
+  \r
+  //\r
+  // See if they defined SOURCE_SELECT=xxx,yyy in which case we'll\r
+  // select each [sources.xxx] and [sources.yyy] files and process\r
+  // them.\r
+  //\r
+  SourceSelect = GetSymbolValue (SOURCE_SELECT);\r
+\r
+  if (SourceSelect != NULL) {\r
+    //\r
+    // Make a copy of the string and break it up (comma-separated) and\r
+    // select each [sources.*] file from the INF.\r
+    //\r
+    CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1);\r
+    if (CopySourceSelect == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (CopySourceSelect, SourceSelect);\r
+    CStart  = CopySourceSelect;\r
+    CEnd    = CStart;\r
+    while (*CStart) {\r
+      CEnd = CStart + 1;\r
+      while (*CEnd && *CEnd != ',') {\r
+        CEnd++;\r
+      }\r
+\r
+      CSave = *CEnd;\r
+      *CEnd = 0;\r
+      sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart);\r
+      ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str);\r
+      //\r
+      // Restore the terminator and advance\r
+      //\r
+      *CEnd   = CSave;\r
+      CStart  = CEnd;\r
+      if (*CStart) {\r
+        CStart++;\r
+      }\r
+    }\r
+\r
+    free (CopySourceSelect);\r
+\r
+  } else {\r
+    //\r
+    // Find all the include files in the [sources.common] sections.\r
+    //\r
+    sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME);\r
+    ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str);\r
+    //\r
+    // Now process the [sources.$(PROCESSOR)] files.\r
+    //\r
+    sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, Processor);\r
+    ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str);\r
+    //\r
+    // Now process the [sources.$(PROCESSOR).$(PLATFORM)] files.\r
+    //\r
+    Platform = GetSymbolValue (PLATFORM);\r
+    if (Platform != NULL) {\r
+      sprintf (Str, "sources.%s.%s", Processor, Platform);\r
+      ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str);\r
+    }\r
+  }\r
+  \r
+  fprintf (MakeFptr, "\n");\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+ProcessIncludeFilesSingle (\r
+  DSC_FILE  *ComponentFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *SectionName\r
+  )\r
+{\r
+  INT8            *Cptr;\r
+  INT8            FileName[MAX_EXP_LINE_LEN];\r
+  INT8            TempFileName[MAX_PATH];\r
+  SECTION         *TempSect;\r
+  INT8            Str[MAX_LINE_LEN];\r
+  INT8            *OverridePath;\r
+  FILE            *FPtr;\r
+\r
+  TempSect = DSCFileFindSection (ComponentFile, SectionName);\r
+  if (TempSect != NULL) {\r
+    //\r
+    // See if the SOURCE_OVERRIDE_PATH has been set. If it has, and\r
+    // they have an include file that is overridden, then add the path\r
+    // to it to the list of include paths (prepend).\r
+    //\r
+    OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);\r
+    while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) {\r
+      Cptr = StripLine (Str);\r
+      //\r
+      // Don't process blank lines\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Expand symbols in the filename, then get its parts\r
+        //\r
+        ExpandSymbols (Cptr, FileName, sizeof (FileName), 0);\r
+        AddFileSymbols (FileName);\r
+        if (IsIncludeFile (FileName)) {\r
+          if ((OverridePath != NULL) && (!IsAbsolutePath (FileName))) {\r
+            strcpy (TempFileName, OverridePath);\r
+            strcat (TempFileName, "\\");\r
+            strcat (TempFileName, FileName);\r
+            if ((FPtr = fopen (TempFileName, "rb")) != NULL) {\r
+              fclose (FPtr);\r
+              //\r
+              // Null-terminate the file name at the last backslash and add that\r
+              // to the beginning of the list of include paths.\r
+              //\r
+              for (Cptr = TempFileName + strlen (TempFileName) - 1;\r
+                   (Cptr >= TempFileName) && (*Cptr != '\\') && (*Cptr != '/');\r
+                   Cptr--\r
+                  )\r
+                ;\r
+              if (Cptr >= TempFileName) {\r
+                *Cptr = 0;\r
+              }\r
+\r
+              fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName);\r
+            }\r
+          }\r
+          //\r
+          // If absolute path already, don't prepend source directory\r
+          //\r
+          // if (IsAbsolutePath (FileName)) {\r
+          //   fprintf (MakeFptr, "INC_DEPS = $(INC_DEPS) %s\n", FileName);\r
+          // } else {\r
+          //   fprintf (MakeFptr, "INC_DEPS = $(INC_DEPS) $(SOURCE_DIR)\\%s\n", FileName);\r
+          // }\r
+        }\r
+\r
+        RemoveFileSymbols ();\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+FreeFileParts (\r
+  FILE_NAME_PARTS *FP\r
+  )\r
+{\r
+  if (FP != NULL) {\r
+    if (FP->Path != NULL) {\r
+      free (FP->Path);\r
+    }\r
+\r
+    if (FP->BaseName != NULL) {\r
+      free (FP->BaseName);\r
+    }\r
+\r
+    if (FP->Extension != NULL) {\r
+      free (FP->Extension);\r
+    }\r
+  }\r
+}\r
+\r
+static\r
+FILE_NAME_PARTS *\r
+GetFileParts (\r
+  INT8 *FileName\r
+  )\r
+{\r
+  FILE_NAME_PARTS *FP;\r
+  INT8            *Cptr;\r
+  INT8            CopyFileName[MAX_PATH];\r
+  INT8            *FileNamePtr;\r
+\r
+  strcpy (CopyFileName, FileName);\r
+  FP = (FILE_NAME_PARTS *) malloc (sizeof (FILE_NAME_PARTS));\r
+  if (FP == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return NULL;\r
+  }\r
+\r
+  memset ((INT8 *) FP, 0, sizeof (FILE_NAME_PARTS));\r
+  //\r
+  // Get extension code\r
+  //\r
+  FP->ExtensionCode = GetSourceFileType (CopyFileName);\r
+  //\r
+  // Get drive if there\r
+  //\r
+  FileNamePtr = CopyFileName;\r
+  if (FileNamePtr[1] == ':') {\r
+    FP->Drive[0]  = FileNamePtr[0];\r
+    FP->Drive[1]  = ':';\r
+    FileNamePtr += 2;\r
+  }\r
+  //\r
+  // Start at the end and work back\r
+  //\r
+  for (Cptr = FileNamePtr + strlen (FileNamePtr) - 1; (Cptr > FileNamePtr) && (*Cptr != '.'); Cptr--)\r
+    ;\r
+\r
+  if (*Cptr == '.') {\r
+    //\r
+    // Don't copy the dot\r
+    //\r
+    FP->Extension = (char *) malloc (strlen (Cptr));\r
+    strcpy (FP->Extension, Cptr + 1);\r
+    *Cptr = 0;\r
+    Cptr--;\r
+    StripTrailingSpaces (FP->Extension);\r
+  } else {\r
+    //\r
+    // Create empty string for extension\r
+    //\r
+    FP->Extension     = (char *) malloc (1);\r
+    FP->Extension[0]  = 0;\r
+  }\r
+  //\r
+  // Now back up and get the base name (include the preceding '\' or '/')\r
+  //\r
+  for (; (Cptr > FileNamePtr) && (*Cptr != '\\') && (*Cptr != '/'); Cptr--)\r
+    ;\r
+  FP->BaseName = (char *) malloc (strlen (Cptr) + 1);\r
+  strcpy (FP->BaseName, Cptr);\r
+  *Cptr = 0;\r
+  Cptr--;\r
+  //\r
+  // Rest is path\r
+  //\r
+  if (Cptr >= FileNamePtr) {\r
+    Cptr      = FileNamePtr;\r
+    FP->Path  = (char *) malloc (strlen (Cptr) + 1);\r
+    strcpy (FP->Path, Cptr);\r
+  } else {\r
+    FP->Path    = (char *) malloc (1);\r
+    FP->Path[0] = 0;\r
+  }\r
+\r
+  return FP;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+int\r
+WriteCommonMakefile (\r
+  DSC_FILE  *DSCFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *Processor\r
+  )\r
+{\r
+  INT8    InLine[MAX_LINE_LEN];\r
+  INT8    OutLine[MAX_EXP_LINE_LEN];\r
+  SECTION *Sect;\r
+  INT8    *Sym;\r
+  int     i;\r
+  //\r
+  // Don't mess up the original file pointer, since we're processing it at a higher\r
+  // level.\r
+  //\r
+  DSCFileSavePosition (DSCFile);\r
+  //\r
+  // Write the header to the file\r
+  //\r
+  for (i = 0; MakefileHeader[i] != NULL; i++) {\r
+    fprintf (MakeFptr, "%s\n", MakefileHeader[i]);\r
+  }\r
+\r
+  fprintf (MakeFptr, "#\n# Hard-coded defines output by the tool\n#\n");\r
+  //\r
+  // First write the basics to the component's makefile. These includes\r
+  // EFI_SOURCE, BIN_DIR, OUT_DIR, LIB_DIR, SOURCE_DIR, DEST_DIR.\r
+  //\r
+  Sym = GetSymbolValue (EFI_SOURCE);\r
+  fprintf (MakeFptr, "%s       = %s\n", EFI_SOURCE, Sym);\r
+  Sym = GetSymbolValue (BUILD_DIR);\r
+  fprintf (MakeFptr, "%s        = %s\n", BUILD_DIR, Sym);\r
+  Sym = GetSymbolValue (BIN_DIR);\r
+  fprintf (MakeFptr, "%s          = %s\n", BIN_DIR, Sym);\r
+  Sym = GetSymbolValue (OUT_DIR);\r
+  fprintf (MakeFptr, "%s          = %s\n", OUT_DIR, Sym);\r
+  Sym = GetSymbolValue (LIB_DIR);\r
+  fprintf (MakeFptr, "%s          = %s\n", LIB_DIR, Sym);\r
+  Sym = GetSymbolValue (SOURCE_DIR);\r
+  fprintf (MakeFptr, "%s       = %s\n", SOURCE_DIR, Sym);\r
+  Sym = GetSymbolValue (DEST_DIR);\r
+  fprintf (MakeFptr, "%s         = %s\n", DEST_DIR, Sym);\r
+  fprintf (MakeFptr, "\n");\r
+  //\r
+  // If there was a [makefile.common] section in the description file,\r
+  // copy it (after symbol expansion) to the output file.\r
+  //\r
+  sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, COMMON_SECTION_NAME);\r
+  Sect = DSCFileFindSection (DSCFile, InLine);\r
+  if (Sect != NULL) {\r
+    //\r
+    // fprintf (MakeFptr, "# From the [makefile.common] section of the DSC file\n");\r
+    // Read lines, expand, then dump out\r
+    //\r
+    while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) {\r
+      //\r
+      // Replace symbols\r
+      //\r
+      ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE);\r
+      fprintf (MakeFptr, OutLine);\r
+    }\r
+  }\r
+  //\r
+  // If there was a [makefile.platform] section in the description file,\r
+  // copy it (after symbol expansion) to the output file.\r
+  //\r
+  sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, "Platform");\r
+  Sect = DSCFileFindSection (DSCFile, InLine);\r
+  if (Sect != NULL) {\r
+    //\r
+    // Read lines, expand, then dump out\r
+    //\r
+    while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) {\r
+      //\r
+      // Replace symbols\r
+      //\r
+      ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE);\r
+      fprintf (MakeFptr, OutLine);\r
+    }\r
+  }\r
+  //\r
+  // Do the same for any [makefile.$(PROCESSOR)]\r
+  //\r
+  sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, Processor);\r
+  Sect = DSCFileFindSection (DSCFile, InLine);\r
+  if (Sect != NULL) {\r
+    //\r
+    // Read lines, expand, then dump out\r
+    //\r
+    while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) {\r
+      ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE);\r
+      fprintf (MakeFptr, OutLine);\r
+    }\r
+  }\r
+  //\r
+  // Same thing for [makefile.$(PROCESSOR).$(PLATFORM)]\r
+  //\r
+  Sym = GetSymbolValue (PLATFORM);\r
+  if (Sym != NULL) {\r
+    sprintf (InLine, "%s.%s.%s", MAKEFILE_SECTION_NAME, Processor, Sym);\r
+    Sect = DSCFileFindSection (DSCFile, InLine);\r
+    if (Sect != NULL) {\r
+      //\r
+      // Read lines, expand, then dump out\r
+      //\r
+      while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) {\r
+        ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE);\r
+        fprintf (MakeFptr, OutLine);\r
+      }\r
+    }\r
+  }\r
+  \r
+  fprintf (MakeFptr, "\n");\r
+  DSCFileRestorePosition (DSCFile);\r
+  return 0;\r
+}\r
+\r
+static\r
+int\r
+WriteComponentTypeBuildCommands (\r
+  DSC_FILE *DSCFile,\r
+  FILE     *MakeFptr,\r
+  INT8     *SectionName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+   Given a section name such as [build.ia32.library], find the section in\r
+   the description file and copy the build commands.\r
+\r
+Arguments:\r
+\r
+  DSCFile     - section information on the main description file\r
+  MakeFptr    - file pointer to the makefile we're writing to\r
+  SectionName - name of the section we're to copy out to the makefile.\r
+\r
+Returns:\r
+\r
+  Always successful, since the section may be optional.\r
+\r
+--*/\r
+{\r
+  SECTION *Sect;\r
+  INT8    InLine[MAX_LINE_LEN];\r
+  INT8    OutLine[MAX_EXP_LINE_LEN];\r
+  \r
+  //\r
+  // Don't mess up the original file pointer, since we're processing it at a higher\r
+  // level.\r
+  //\r
+  DSCFileSavePosition (DSCFile);\r
+  Sect = DSCFileFindSection (DSCFile, SectionName);\r
+  if (Sect != NULL) {\r
+    //\r
+    // Read lines, expand, then dump out\r
+    //\r
+    while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) {\r
+      ExpandSymbols (\r
+        InLine, \r
+        OutLine, \r
+        sizeof(OutLine), \r
+        EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+        );\r
+      fprintf (MakeFptr, OutLine);\r
+    }\r
+  } else {\r
+    Warning (\r
+      NULL,\r
+      0,\r
+      0,\r
+      GetSymbolValue (INF_FILENAME),\r
+      "no [%s] build commands found in DSC file for component",\r
+      SectionName\r
+      );\r
+  }\r
+\r
+  DSCFileRestorePosition (DSCFile);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************\r
+\r
+******************************************************************************/\r
+static\r
+int\r
+WriteCompileCommands (\r
+  DSC_FILE  *DscFile,\r
+  FILE      *MakeFptr,\r
+  INT8      *FileName,\r
+  INT8      *Processor\r
+  )\r
+{\r
+  FILE_NAME_PARTS *File;\r
+  SECTION         *Sect;\r
+  INT8            BuildSectionName[40];\r
+  INT8            InLine[MAX_LINE_LEN];\r
+  INT8            OutLine[MAX_EXP_LINE_LEN];\r
+  INT8            *SourceCompileType;\r
+  char            *CPtr;\r
+  char            *CPtr2;\r
+  //\r
+  // Determine the filename, then chop it up into its parts\r
+  //\r
+  File = GetFileParts (FileName);\r
+  if (File != NULL) {\r
+    //\r
+    // Don't mess up the original file pointer, since we're processing it at a higher\r
+    // level.\r
+    //\r
+    DSCFileSavePosition (DscFile);\r
+    //\r
+    // Option 1: SOURCE_COMPILE_TYPE=MyCompileSection\r
+    //           Find a section of that name from which to get the compile\r
+    //           commands for this source file. \r
+    //           Look for [compile.$(PROCESSOR).$(SOURCE_COMPILE_TYPE]\r
+    // Option 2: COMPILE_SELECT=.c=MyCCompile,.asm=MyAsm\r
+    //           Find a [compile.$(PROCESSOR).MyCompile] section from which to\r
+    //           get the compile commands for this source file. \r
+    //           Look for [compile.$(PROCESSOR).MyCompile]\r
+    // Option 3: Look for standard section types to compile the file by extension.\r
+    //           Look for [compile.$(PROCESSOR).<extension>]\r
+    //\r
+    Sect = NULL;\r
+    //\r
+    // Option 1 - use SOURCE_COMPILE_TYPE variable\r
+    //\r
+    SourceCompileType = GetSymbolValue (SOURCE_COMPILE_TYPE);\r
+    if (SourceCompileType != NULL) {\r
+      sprintf (BuildSectionName, "compile.%s.%s", Processor, SourceCompileType);\r
+      Sect = DSCFileFindSection (DscFile, BuildSectionName);\r
+    }\r
+    //\r
+    // Option 2 - use COMPILE_SELECT variable\r
+    //\r
+    if (Sect == NULL) {\r
+      SourceCompileType = GetSymbolValue (COMPILE_SELECT);\r
+      if (SourceCompileType != NULL) {\r
+        //\r
+        // Parse the variable, which looks like COMPILE_SELECT=.c=MyCCompiler;.asm=MyAsm;\r
+        // to find an entry with a matching file name extension. If you find one,\r
+        // then use that name to find the section name.\r
+        //\r
+        CPtr = SourceCompileType;\r
+        while (*CPtr && (Sect == NULL)) {\r
+          //\r
+          // See if we found a match with this source file name extension. File->Extension\r
+          // does not include the dot, so skip the dot in the COMPILE_SELECT variable if there\r
+          // is one.\r
+          //\r
+          if (*CPtr == '.') {\r
+            CPtr++;\r
+          }\r
+\r
+          if (_strnicmp (CPtr, File->Extension, strlen (File->Extension)) == 0) {\r
+            //\r
+            // Found a file name extension match -- extract the name from the variable, for\r
+            // example "MyCCompiler"\r
+            //\r
+            while (*CPtr && (*CPtr != '=')) {\r
+              CPtr++;\r
+            }\r
+\r
+            if ((*CPtr != '=') || (CPtr[1] == 0)) {\r
+              Error (NULL, 0, 0, SourceCompileType, "malformed COMPILE_SELECT variable");\r
+              break;\r
+            }\r
+\r
+            CPtr++;\r
+            sprintf (BuildSectionName, "compile.%s.", Processor);\r
+            for (CPtr2 = BuildSectionName + strlen (BuildSectionName);\r
+                 *CPtr && (*CPtr != ',') && (*CPtr != ';');\r
+                 CPtr++\r
+                ) {\r
+              *CPtr2 = *CPtr;\r
+              CPtr2++;\r
+            }\r
+\r
+            *CPtr2  = 0;\r
+            Sect    = DSCFileFindSection (DscFile, BuildSectionName);\r
+            if (Sect == NULL) {\r
+              ParserError (\r
+                0,\r
+                BuildSectionName,\r
+                "could not find section in DSC file - selected by COMPILE_SELECT variable"\r
+                );\r
+            }\r
+          }\r
+\r
+          //\r
+          // Skip to next file name extension in the COMPILE_SELECT variable\r
+          //\r
+          while (*CPtr && (*CPtr != ';') && (*CPtr != ',')) {\r
+            CPtr++;\r
+          }\r
+\r
+          if (*CPtr) {\r
+            CPtr++;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    //\r
+    // Option 3 - use "Compile.$(PROCESSOR).<Extension>" section\r
+    //\r
+    if (Sect == NULL) {\r
+      sprintf (BuildSectionName, "compile.%s.%s", Processor, File->Extension);\r
+      Sect = DSCFileFindSection (DscFile, BuildSectionName);\r
+    }\r
+    //\r
+    // Should have found something by now unless it's an include (.h) file\r
+    //\r
+    if (Sect != NULL) {\r
+      //\r
+      // Temporarily add a FILE variable to the global symbol table. Omit the\r
+      // extension.\r
+      //\r
+      sprintf (InLine, "%s%s%s", File->Drive, File->Path, File->BaseName);\r
+      AddSymbol ("FILE", InLine, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME);\r
+      //\r
+      // Read lines, expand (except SOURCE_DIR and DEST_DIR), then dump out\r
+      //\r
+      while (DSCFileGetLine (DscFile, InLine, sizeof (InLine)) != NULL) {\r
+        ExpandSymbols (\r
+          InLine,\r
+          OutLine,\r
+          sizeof (OutLine),\r
+          EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR\r
+          );\r
+        fprintf (MakeFptr, OutLine);\r
+      }\r
+      fprintf (MakeFptr, "\n");\r
+    } else {\r
+      //\r
+      // Be nice and ignore include files\r
+      //\r
+      if (!IsIncludeFile (FileName)) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          NULL,\r
+          "no compile commands section [%s] found in DSC file for %s",\r
+          BuildSectionName,\r
+          FileName\r
+          );\r
+      }\r
+    }\r
+\r
+    DSCFileRestorePosition (DscFile);\r
+    FreeFileParts (File);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+int\r
+SetFileExtension (\r
+  INT8 *FileName,\r
+  INT8 *Extension\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+\r
+  Cptr = FileName + strlen (FileName) - 1;\r
+  while ((Cptr > FileName) && (*Cptr != '.')) {\r
+    Cptr--;\r
+\r
+  }\r
+  //\r
+  // Better be a dot\r
+  //\r
+  if (*Cptr != '.') {\r
+    Message (2, "Missing filename extension: %s", FileName);\r
+    return STATUS_WARNING;\r
+  }\r
+\r
+  Cptr++;\r
+  if (*Extension == '.') {\r
+    Extension++;\r
+  }\r
+\r
+  strcpy (Cptr, Extension);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+int\r
+MakeFilePath (\r
+  INT8 *FileName\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+  INT8  SavedChar;\r
+  INT8  BuildDir[MAX_PATH];\r
+  INT8  CopyFileName[MAX_PATH];\r
+\r
+  //\r
+  // Expand symbols in the filename\r
+  //\r
+  if (ExpandSymbols (FileName, CopyFileName, sizeof (CopyFileName), EXPANDMODE_NO_UNDEFS)) {\r
+    Error (NULL, 0, 0, NULL, "undefined symbols in file path: %s", FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Copy it back\r
+  //\r
+  strcpy (FileName, CopyFileName);\r
+  //\r
+  // To avoid creating $(BUILD_DIR) path, see if this path is the same as\r
+  // $(BUILD_DIR), and if it is, see if build dir exists and skip over that\r
+  // portion if it does\r
+  //\r
+  Cptr = GetSymbolValue (BUILD_DIR);\r
+  if (Cptr != NULL) {\r
+    if (_strnicmp (Cptr, FileName, strlen (Cptr)) == 0) {\r
+      //\r
+      // BUILD_DIR path. See if it exists\r
+      //\r
+      strcpy (BuildDir, FileName);\r
+      BuildDir[strlen (Cptr)] = 0;\r
+      if ((_mkdir (BuildDir) != 0) && (errno != EEXIST)) {\r
+        Cptr = FileName;\r
+      } else {\r
+        //\r
+        // Already done. Shortcut. Skip to next path so that we don't create\r
+        // the BUILD_DIR as well.\r
+        //\r
+        Cptr = FileName + strlen (Cptr);\r
+        if (*Cptr == '\\') {\r
+          Cptr++;\r
+        }\r
+      }\r
+    } else {\r
+      //\r
+      // Not build dir\r
+      //\r
+      Cptr = FileName;\r
+    }\r
+  } else {\r
+    Cptr = FileName;\r
+  }\r
+  //\r
+  // Create directories until done. Skip over "c:\" in the path if it exists\r
+  //\r
+  if (*Cptr && (*(Cptr + 1) == ':') && (*(Cptr + 2) == '\\')) {\r
+    Cptr += 3;\r
+  }\r
+\r
+  for (;;) {\r
+    for (; *Cptr && (*Cptr != '/') && (*Cptr != '\\'); Cptr++)\r
+      ;\r
+    if (*Cptr) {\r
+      SavedChar = *Cptr;\r
+      *Cptr     = 0;\r
+      if ((_mkdir (FileName) != 0)) {\r
+        //\r
+        //        Error (NULL, 0, 0, FileName, "failed to create directory");\r
+        //        return 1;\r
+        //\r
+      }\r
+\r
+      *Cptr = SavedChar;\r
+      Cptr++;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+int\r
+ExpandSymbols (\r
+  INT8  *SourceLine,\r
+  INT8  *DestLine,\r
+  int   LineLen,\r
+  int   ExpandMode\r
+  )\r
+{\r
+  static int  NestDepth = 0;\r
+  INT8        *FromPtr;\r
+  INT8        *ToPtr;\r
+  INT8        *SaveStart;\r
+  INT8        *Cptr;\r
+  INT8        *value;\r
+  int         Expanded;\r
+  int         ExpandedCount;\r
+  INT8        *LocalDestLine;\r
+  STATUS      Status;\r
+  int         LocalLineLen;\r
+\r
+  NestDepth++;\r
+  Status        = STATUS_SUCCESS;\r
+  LocalDestLine = (INT8 *) malloc (LineLen);\r
+  if (LocalDestLine == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");\r
+    NestDepth = 0;\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  FromPtr = SourceLine;\r
+  ToPtr   = LocalDestLine;\r
+  //\r
+  // Walk the entire line, replacing $(SYMBOL_NAME).\r
+  //\r
+  LocalLineLen  = LineLen;\r
+  ExpandedCount = 0;\r
+  while (*FromPtr && (LocalLineLen > 0)) {\r
+    if ((*FromPtr == '$') && (*(FromPtr + 1) == '(')) {\r
+      //\r
+      // Save the start in case it's undefined, in which case we copy it as-is.\r
+      //\r
+      SaveStart = FromPtr;\r
+      Expanded  = 0;\r
+      //\r
+      // Symbol expansion time. Find the end (no spaces allowed)\r
+      //\r
+      FromPtr += 2;\r
+      for (Cptr = FromPtr; *Cptr && (*Cptr != ')'); Cptr++)\r
+        ;\r
+      if (*Cptr) {\r
+        //\r
+        // Truncate the string at the closing parenthesis for ease-of-use.\r
+        // Then copy the string directly to the destination line in case we don't find\r
+        // a definition for it.\r
+        //\r
+        *Cptr = 0;\r
+        strcpy (ToPtr, SaveStart);\r
+        if ((_stricmp (SOURCE_DIR, FromPtr) == 0) && (ExpandMode & EXPANDMODE_NO_SOURCEDIR)) {\r
+          //\r
+          // excluded this expansion\r
+          //\r
+        } else if ((_stricmp (DEST_DIR, FromPtr) == 0) && (ExpandMode & EXPANDMODE_NO_DESTDIR)) {\r
+          //\r
+          // excluded this expansion\r
+          //\r
+        } else if ((value = GetSymbolValue (FromPtr)) != NULL) {\r
+          strcpy (ToPtr, value);\r
+          LocalLineLen -= strlen (value);\r
+          ToPtr += strlen (value);\r
+          Expanded = 1;\r
+          ExpandedCount++;\r
+        } else if (ExpandMode & EXPANDMODE_NO_UNDEFS) {\r
+          Error (NULL, 0, 0, "undefined symbol", "$(%s)", FromPtr);\r
+          Status = STATUS_ERROR;\r
+          goto Done;\r
+        }\r
+        \r
+        //\r
+        // Restore closing parenthesis, and advance to next character\r
+        //\r
+        *Cptr   = ')';\r
+        if (!Expanded) {\r
+          FromPtr = SaveStart + 1;\r
+          ToPtr++;\r
+        } else {\r
+          FromPtr = Cptr + 1;\r
+        }\r
+      } else {\r
+        Error (NULL, 0, 0, SourceLine, "missing closing parenthesis on symbol");\r
+        strcpy (ToPtr, FromPtr);\r
+        Status = STATUS_WARNING;\r
+        goto Done;\r
+      }\r
+    } else {\r
+      *ToPtr = *FromPtr;\r
+      FromPtr++;\r
+      ToPtr++;\r
+      LocalLineLen--;\r
+    }\r
+  }\r
+\r
+  if (*FromPtr == 0) {\r
+    *ToPtr = 0;\r
+  }\r
+\r
+  //\r
+  // If we're in recursive mode, and we expanded at least one string successfully,\r
+  // then make a recursive call to try again.\r
+  //\r
+  if ((ExpandedCount != 0) && (Status == STATUS_SUCCESS) && (ExpandMode & EXPANDMODE_RECURSIVE) && (NestDepth < 2)) {\r
+    Status = ExpandSymbols (LocalDestLine, DestLine, LineLen, ExpandMode);\r
+    free (LocalDestLine);\r
+    NestDepth = 0;\r
+    return Status;\r
+  }\r
+\r
+Done:\r
+  if (Status != STATUS_ERROR) {\r
+    strcpy (DestLine, LocalDestLine);\r
+  }\r
+\r
+  NestDepth = 0;\r
+  free (LocalDestLine);\r
+  return Status;\r
+}\r
+\r
+INT8 *\r
+GetSymbolValue (\r
+  INT8 *SymbolName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Look up a symbol in our symbol table.\r
+\r
+Arguments:\r
+\r
+  SymbolName - The name of symbol.\r
+\r
+Returns:\r
+\r
+  Pointer to the value of the symbol if found\r
+  NULL if the symbol is not found\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Symbol;\r
+\r
+  //\r
+  // Scan once for file-level symbols\r
+  //\r
+  Symbol = gGlobals.Symbol;\r
+  while (Symbol) {\r
+    if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_FILE)) {\r
+      return Symbol->Value;\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+  //\r
+  // Scan once for local symbols\r
+  //\r
+  Symbol = gGlobals.Symbol;\r
+  while (Symbol) {\r
+    if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_LOCAL)) {\r
+      return Symbol->Value;\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+  //\r
+  // No local value found. Scan for globals.\r
+  //\r
+  Symbol = gGlobals.Symbol;\r
+  while (Symbol) {\r
+    if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_GLOBAL)) {\r
+      return Symbol->Value;\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+  //\r
+  // For backwards-compatibility, if it's "GUID", return FILE_GUID value\r
+  //\r
+  if (_stricmp (SymbolName, GUID) == 0) {\r
+    return GetSymbolValue (FILE_GUID);\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+static\r
+int\r
+RemoveLocalSymbols (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Remove all local symbols from the symbol table. Local symbols are those\r
+  that are defined typically by the component's INF file.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Right now, never fails.\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Sym;\r
+  int     FoundOne;\r
+\r
+  do {\r
+    FoundOne  = 0;\r
+    Sym       = gGlobals.Symbol;\r
+    while (Sym) {\r
+      if (Sym->Type & SYM_LOCAL) {\r
+        //\r
+        // Going to delete it out from under ourselves, so break and restart\r
+        //\r
+        FoundOne = 1;\r
+        RemoveSymbol (Sym->Name, SYM_LOCAL);\r
+        break;\r
+      }\r
+\r
+      Sym = Sym->Next;\r
+    }\r
+  } while (FoundOne);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+RemoveFileSymbols (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Remove all file-level symbols from the symbol table. File-level symbols are \r
+  those that are defined on a source file line in an INF file.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Right now, never fails.\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Sym;\r
+  int     FoundOne;\r
+\r
+  do {\r
+    FoundOne  = 0;\r
+    Sym       = gGlobals.Symbol;\r
+    while (Sym) {\r
+      if (Sym->Type & SYM_FILE) {\r
+        //\r
+        // Going to delete it out from under ourselves, so break and restart\r
+        //\r
+        FoundOne = 1;\r
+        RemoveSymbol (Sym->Name, SYM_FILE);\r
+        break;\r
+      }\r
+\r
+      Sym = Sym->Next;\r
+    }\r
+  } while (FoundOne);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ParseGuidDatabaseFile (\r
+  INT8 *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function parses a GUID-to-basename text file (perhaps output by\r
+  the GuidChk utility) to define additional symbols. The format of the \r
+  file should be:\r
+\r
+  7BB28B99-61BB-11D5-9A5D-0090273FC14D EFI_DEFAULT_BMP_LOGO_GUID gEfiDefaultBmpLogoGuid\r
+  \r
+  This function parses the line and defines global symbol:\r
+\r
+    EFI_DEFAULT_BMP_LOGO_GUID=7BB28B99-61BB-11D5-9A5D-0090273FC14D \r
+  \r
+  This symbol (rather than the actual GUID) can then be used in INF files to \r
+  fix duplicate GUIDs\r
+\r
+Arguments:\r
+  FileName  - the name of the file to parse.\r
+\r
+Returns:\r
+  STATUS_ERROR    - could not open FileName\r
+  STATUS_SUCCESS  - we opened the file\r
+\r
+--*/\r
+{\r
+  FILE  *Fptr;\r
+  INT8  Line[100];\r
+  INT8  Guid[100];\r
+  INT8  DefineName[80];\r
+\r
+  Fptr = fopen (FileName, "r");\r
+  if (Fptr == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open input GUID database input file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    //\r
+    // Get the GUID string, skip the defined name (EFI_XXX_GUID), and get the\r
+    // variable name (gWhateverProtocolGuid)\r
+    //\r
+    if (sscanf (Line, "%s %s %*s", Guid, DefineName) == 2) {\r
+      AddSymbol (DefineName, Guid, SYM_GLOBAL);\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************\r
+\r
+  Returns:\r
+     0 if successful standard add\r
+    length of the parsed string if passed in " name = value  "\r
+    < 0 on error\r
+\r
+******************************************************************************/\r
+int\r
+AddSymbol (\r
+  INT8    *Name,\r
+  INT8    *Value,\r
+  int     Mode\r
+  )\r
+{\r
+  SYMBOL  *Symbol;\r
+  SYMBOL  *NewSymbol;\r
+  int     Len;\r
+  INT8    *Start;\r
+  INT8    *Cptr;\r
+  INT8    CSave1;\r
+  INT8    *SaveCptr1;\r
+  INT8    CSave2;\r
+  INT8    *SaveCptr2;\r
+  INT8    ShortName[MAX_PATH];\r
+\r
+  Len           = 0;\r
+  SaveCptr1     = NULL;\r
+  CSave1        = 0;\r
+  SaveCptr2     = NULL;\r
+  CSave2        = 0;\r
+\r
+  ShortName[0]  = 0;\r
+  //\r
+  // Mode better be local or global symbol\r
+  //\r
+  if ((Mode & (SYM_LOCAL | SYM_GLOBAL | SYM_FILE)) == 0) {\r
+    Error (NULL, 0, 0, "APP ERROR", "adding symbol '%s' that is not local, global, nor file level", Name);\r
+    return -1;\r
+  }\r
+  //\r
+  // If value pointer is null, then they passed us a line something like:\r
+  //    varname = value, or simply var =\r
+  //\r
+  if (Value == NULL) {\r
+    Start = Name;\r
+    while (*Name && isspace (*Name)) {\r
+      Name++;\r
+\r
+    }\r
+\r
+    if (!*Name) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Find the end of the name. Either space or a '='.\r
+    //\r
+    for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++)\r
+      ;\r
+    if (!*Value) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Look for the '='\r
+    //\r
+    Cptr = Value;\r
+    while (*Value && (*Value != '=')) {\r
+      Value++;\r
+    }\r
+\r
+    if (!*Value) {\r
+      return -1;\r
+    }\r
+\r
+    //\r
+    // Now truncate the name\r
+    //\r
+    CSave1    = *Cptr;\r
+    SaveCptr1 = Cptr;\r
+    *Cptr     = 0;    \r
+\r
+    //\r
+    // Skip over the = and then any spaces\r
+    //\r
+    Value++;\r
+    while (*Value && isspace (*Value)) {\r
+      Value++;\r
+\r
+    }\r
+    //\r
+    // Find end of string, checking for quoted string\r
+    //\r
+    if (*Value == '\"') {\r
+      Value++;\r
+      for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++)\r
+        ;\r
+    } else {\r
+      for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++)\r
+        ;\r
+    }\r
+    //\r
+    // Null terminate the value string\r
+    //\r
+    if (*Cptr) {\r
+      Len = (int) (Cptr - Start) + 1;\r
+      CSave2    = *Cptr;\r
+      SaveCptr2 = Cptr;\r
+      *Cptr     = 0;\r
+    } else {\r
+      Len = (int) (Cptr - Start);\r
+    }\r
+  }\r
+\r
+  //\r
+  // If file name or file path, and we're shortening, then print it\r
+  //\r
+  if ((Mode & (SYM_FILEPATH | SYM_FILENAME)) && (GetSymbolValue (SHORT_NAMES) != NULL)) {\r
+    if (GetShortPathName (Value, ShortName, sizeof (ShortName)) > 0) {\r
+      //\r
+      // fprintf (stdout, "String value '%s' shortened to '%s'\n",\r
+      //    Value, ShortName);\r
+      //\r
+      Value = ShortName;\r
+    } else {\r
+      //\r
+      // fprintf (stdout, "WARNING: Failed to get short name for %s\n", Value);\r
+      //\r
+    }\r
+  }\r
+  //\r
+  // We now have a symbol name and a value. Look for an existing variable of\r
+  // the same type (global or local) and overwrite it.\r
+  //\r
+  Symbol = gGlobals.Symbol;\r
+  while (Symbol) {\r
+    //\r
+    // Check for symbol name match\r
+    //\r
+    if (_stricmp (Name, Symbol->Name) == 0) {\r
+      //\r
+      // See if this symbol is of the same type (global or local) as what\r
+      // they're requesting\r
+      //\r
+      if ((Symbol->Type & (SYM_LOCAL | SYM_GLOBAL)) == (Mode & (SYM_LOCAL | SYM_GLOBAL))) {\r
+        //\r
+        // Did they say we could overwrite it?\r
+        //\r
+        if (Mode & SYM_OVERWRITE) {\r
+          free (Symbol->Value);\r
+          Symbol->Value = (INT8 *) malloc (strlen (Value) + 1);\r
+          if (Symbol->Value == NULL) {\r
+            Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+            return -1;\r
+          }\r
+\r
+          strcpy (Symbol->Value, Value);\r
+          //\r
+          // If value == "NULL", then make it a 0-length string\r
+          //\r
+          if (_stricmp (Symbol->Value, "NULL") == 0) {\r
+            Symbol->Value[0] = 0;\r
+          }\r
+\r
+          return Len;\r
+        } else {\r
+          return STATUS_ERROR;\r
+        }\r
+      }\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+  //\r
+  // Does not exist, create a new one\r
+  //\r
+  NewSymbol = (SYMBOL *) malloc (sizeof (SYMBOL));\r
+  if (NewSymbol == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return -1;\r
+  }\r
+\r
+  memset ((INT8 *) NewSymbol, 0, sizeof (SYMBOL));\r
+  NewSymbol->Name   = (INT8 *) malloc (strlen (Name) + 1);\r
+  NewSymbol->Value  = (INT8 *) malloc (strlen (Value) + 1);\r
+  //\r
+  // Simply use the mode bits as the type.\r
+  //\r
+  NewSymbol->Type = Mode;\r
+  if ((NewSymbol->Name == NULL) || (NewSymbol->Value == NULL)) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    return -1;\r
+  }\r
+\r
+  strcpy (NewSymbol->Name, Name);\r
+  strcpy (NewSymbol->Value, Value);\r
+  //\r
+  // Remove trailing spaces\r
+  //\r
+  Cptr = NewSymbol->Value + strlen (NewSymbol->Value) - 1;\r
+  while (Cptr > NewSymbol->Value) {\r
+    if (isspace (*Cptr)) {\r
+      *Cptr = 0;\r
+      Cptr--;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Add it to the head of the list.\r
+  //\r
+  NewSymbol->Next = gGlobals.Symbol;\r
+  gGlobals.Symbol = NewSymbol;\r
+  //\r
+  // If value == "NULL", then make it a 0-length string\r
+  //\r
+  if (_stricmp (NewSymbol->Value, "NULL") == 0) {\r
+    NewSymbol->Value[0] = 0;\r
+  }\r
+  //\r
+  // Restore the terminator we inserted if they passed in var=value\r
+  //\r
+  if (SaveCptr1 != NULL) {\r
+    *SaveCptr1 = CSave1;\r
+  }\r
+  if (SaveCptr2 != NULL) {\r
+    *SaveCptr2 = CSave2;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+int\r
+RemoveSymbol (\r
+  INT8 *Name,\r
+  INT8 SymbolType\r
+  )\r
+{\r
+  SYMBOL  *Symbol;\r
+  SYMBOL  *PrevSymbol;\r
+\r
+  PrevSymbol  = NULL;\r
+  Symbol      = gGlobals.Symbol;\r
+  while (Symbol) {\r
+    if ((_stricmp (Name, Symbol->Name) == 0) && (Symbol->Type & SymbolType)) {\r
+      if (Symbol->Value) {\r
+        free (Symbol->Value);\r
+      }\r
+\r
+      free (Symbol->Name);\r
+      if (PrevSymbol) {\r
+        PrevSymbol->Next = Symbol->Next;\r
+      } else {\r
+        gGlobals.Symbol = Symbol->Next;\r
+      }\r
+\r
+      free (Symbol);\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    PrevSymbol  = Symbol;\r
+    Symbol      = Symbol->Next;\r
+  }\r
+\r
+  return STATUS_WARNING;\r
+}\r
+\r
+#if 0\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+void\r
+FreeSections (\r
+  SECTION *Sect\r
+  )\r
+{\r
+  SECTION *Next;\r
+\r
+  while (Sect != NULL) {\r
+    Next = Sect->Next;\r
+    if (Sect->Name != NULL) {\r
+      delete[] Sect->Name;\r
+    }\r
+\r
+    delete Sect;\r
+    Sect = Next;\r
+  }\r
+}\r
+#endif\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+INT8 *\r
+StripLine (\r
+  INT8 *Line\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+  int   Len;\r
+\r
+  Cptr = Line;\r
+  //\r
+  // Look for '#' comments in first character of line\r
+  //\r
+  if (*Cptr == '#') {\r
+    *Cptr = 0;\r
+    return Cptr;\r
+  }\r
+\r
+  while (isspace (*Cptr)) {\r
+    Cptr++;\r
+  }\r
+  //\r
+  // Hack off newlines\r
+  //\r
+  Len = strlen (Cptr);\r
+  if ((Len > 0) && (Cptr[Len - 1] == '\n')) {\r
+    Cptr[Len - 1] = 0;\r
+  }\r
+  //\r
+  // Hack off trailing spaces\r
+  //\r
+  StripTrailingSpaces (Cptr);\r
+  return Cptr;\r
+}\r
+\r
+/*****************************************************************************\r
+  FUNCTION:  ProcessOptions()\r
+  \r
+  DESCRIPTION: Process the command-line options.  \r
+******************************************************************************/\r
+static\r
+int\r
+ProcessOptions (\r
+  int   Argc,\r
+  INT8  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process the command line options to this utility.\r
+\r
+Arguments:\r
+\r
+  Argc   - Standard Argc.\r
+  Argv[] - Standard Argv.\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  INT8  *Cptr;\r
+  int   FreeCwd;\r
+\r
+  //\r
+  // Clear out the options\r
+  //\r
+  memset ((INT8 *) &gGlobals, 0, sizeof (gGlobals));\r
+\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now process the arguments\r
+  //\r
+  while (Argc > 0) {\r
+\r
+    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
+      switch (Argv[0][1]) {\r
+      //\r
+      // -? or -h help option\r
+      //\r
+      case '?':\r
+      case 'h':\r
+      case 'H':\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+\r
+      //\r
+      // /d symbol=name\r
+      //\r
+      case 'd':\r
+      case 'D':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, NULL, "missing symbol definition with %c%c", Argv[0][0], Argv[0][1]);\r
+          return STATUS_ERROR;\r
+        } else {\r
+          if (AddSymbol (Argv[0], NULL, SYM_OVERWRITE | SYM_GLOBAL) <= 0) {\r
+            Warning (NULL, 0, 0, Argv[0], "failed to add symbol: %s");\r
+          }\r
+        }\r
+        break;\r
+\r
+      //\r
+      // output makefile name\r
+      //\r
+      case 'm':\r
+      case 'M':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "missing output makefile name with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        } else {\r
+          strcpy (gGlobals.MakefileName, Argv[0]);\r
+        }\r
+        break;\r
+\r
+      //\r
+      // Print a cross-reference file containing guid/basename/processor\r
+      //\r
+      case 'x':\r
+      case 'X':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "missing cross-reference output filename with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        } else {\r
+          strcpy (gGlobals.XRefFileName, Argv[0]);\r
+        }\r
+        break;\r
+\r
+      //\r
+      // GUID database file to preparse\r
+      //\r
+      case 'g':\r
+      case 'G':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "missing input GUID database filename with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        } else {\r
+          strcpy (gGlobals.GuidDatabaseFileName, Argv[0]);\r
+        }\r
+        break;\r
+\r
+      case 'v':\r
+      case 'V':\r
+        gGlobals.Verbose = 1;\r
+        break;\r
+\r
+      default:\r
+        Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+        return STATUS_ERROR;\r
+      }\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Must be at least one arg left\r
+  //\r
+  if (Argc > 0) {\r
+    gGlobals.DscFilename = Argv[0];\r
+  }\r
+\r
+  if (gGlobals.DscFilename == NULL) {\r
+    Error (NULL, 0, 0, NULL, "must specify DSC filename on command line");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Make a global symbol for the DSC filename\r
+  //\r
+  AddSymbol (DSC_FILENAME, gGlobals.DscFilename, SYM_GLOBAL | SYM_FILENAME);\r
+  //\r
+  // If no output makefile specified, take the default\r
+  //\r
+  if (gGlobals.MakefileName[0] == 0) {\r
+    strcpy (gGlobals.MakefileName, MAKEFILE_OUT_NAME);\r
+  }\r
+  //\r
+  // Get the current working directory and use it for the build directory.\r
+  // Only do this if they have not defined it on the command line. Do the\r
+  // same for the bin dir, output dir, and library directory.\r
+  //\r
+  Cptr = GetSymbolValue (BUILD_DIR);\r
+  if (Cptr == NULL) {\r
+    Cptr    = _getcwd (NULL, 0);\r
+    FreeCwd = 1;\r
+    AddSymbol (BUILD_DIR, Cptr, SYM_OVERWRITE | SYM_GLOBAL | SYM_FILEPATH);\r
+  } else {\r
+    FreeCwd = 0;\r
+  }\r
+\r
+  if (FreeCwd) {\r
+    free (Cptr);\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+SYMBOL *\r
+FreeSymbols (\r
+  SYMBOL *Syms\r
+  )\r
+{\r
+  SYMBOL  *Next;\r
+  while (Syms) {\r
+\r
+    if (Syms->Name != NULL) {\r
+      free (Syms->Name);\r
+    }\r
+\r
+    if (Syms->Value != NULL) {\r
+      free (Syms->Value);\r
+    }\r
+\r
+    Next = Syms->Next;\r
+    free (Syms);\r
+    Syms = Next;\r
+  }\r
+\r
+  return Syms;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+int\r
+GetSourceFileType (\r
+  INT8 *FileName\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+  int   len;\r
+  int   i;\r
+\r
+  len = strlen (FileName);\r
+  if (len == 0) {\r
+    return FILETYPE_UNKNOWN;\r
+\r
+  }\r
+\r
+  Cptr = FileName + len - 1;\r
+  while ((*Cptr != '.') && (Cptr >= FileName)) {\r
+    Cptr--;\r
+\r
+  }\r
+\r
+  if (*Cptr == '.') {\r
+\r
+    for (i = 0; mFileTypes[i].Extension != NULL; i++) {\r
+      len = strlen (mFileTypes[i].Extension);\r
+      if (_strnicmp (mFileTypes[i].Extension, Cptr, len) == 0) {\r
+        if ((*(Cptr + len) == 0) || isspace (*(Cptr + len))) {\r
+          return mFileTypes[i].FileType;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FILETYPE_UNKNOWN;\r
+}\r
+//\r
+// Determine if a given file is a standard include file. If we don't know,\r
+// then assume it's not.\r
+//\r
+static\r
+int\r
+IsIncludeFile (\r
+  INT8 *FileName\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+  int   len;\r
+  int   i;\r
+\r
+  len = strlen (FileName);\r
+  if (len == 0) {\r
+    return 0;\r
+  }\r
+\r
+  Cptr = FileName + len - 1;\r
+  while ((*Cptr != '.') && (Cptr >= FileName)) {\r
+    Cptr--;\r
+  }\r
+\r
+  if (*Cptr == '.') {\r
+    //\r
+    // Now go through the list of filename extensions and try to find\r
+    // a match for this file extension.\r
+    //\r
+    for (i = 0; mFileTypes[i].Extension != NULL; i++) {\r
+      len = strlen (mFileTypes[i].Extension);\r
+      if (_strnicmp (mFileTypes[i].Extension, Cptr, len) == 0) {\r
+        //\r
+        // Make sure that's all there is to the filename extension.\r
+        //\r
+        if ((*(Cptr + len) == 0) || isspace (*(Cptr + len))) {\r
+          return mFileTypes[i].FileFlags & FILE_FLAG_INCLUDE;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+void\r
+StripTrailingSpaces (\r
+  INT8 *Str\r
+  )\r
+{\r
+  INT8  *Cptr;\r
+  Cptr = Str + strlen (Str) - 1;\r
+  while (Cptr > Str) {\r
+    if (isspace (*Cptr)) {\r
+      *Cptr = 0;\r
+      Cptr--;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+}\r
+\r
+/*****************************************************************************\r
+******************************************************************************/\r
+static\r
+int\r
+GetEfiSource (\r
+  VOID\r
+  )\r
+{\r
+  INT8  *EfiSource;\r
+\r
+  //\r
+  // Don't set it if the user specified it on the command line.\r
+  //\r
+  EfiSource = GetSymbolValue (EFI_SOURCE);\r
+  if ( EfiSource != NULL) {\r
+    if (EfiSource[strlen (EfiSource) - 1] == '\\') {\r
+      EfiSource[strlen (EfiSource) - 1] = 0;\r
+    }    \r
+    return STATUS_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Get the environmental variable setting of EFI_SOURCE. \r
+  //\r
+  EfiSource = getenv (EFI_SOURCE);\r
+  if (EfiSource != NULL) {\r
+    if (EfiSource[strlen (EfiSource) - 1] == '\\') {\r
+      EfiSource[strlen (EfiSource) - 1] = 0;\r
+    }\r
+    AddSymbol (EFI_SOURCE, EfiSource, SYM_GLOBAL | SYM_FILEPATH); \r
+    return STATUS_SUCCESS;\r
+  }\r
+\r
+  Error (NULL, 0, 0, NULL, "could not determine EFI_SOURCE");\r
+  return STATUS_ERROR;\r
+}\r
+\r
+void\r
+Message (\r
+  UINT32  PrintMask,\r
+  INT8    *Fmt,\r
+  ...\r
+  )\r
+{\r
+  INT8    Line[MAX_LINE_LEN];\r
+  va_list List;\r
+\r
+  va_start (List, Fmt);\r
+  vsprintf (Line, Fmt, List);\r
+  if (PrintMask & gGlobals.Verbose) {\r
+    fprintf (stdout, "%s\n", Line);\r
+  }\r
+\r
+  va_end (List);\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  int               i;\r
+  static const INT8 *Help[] = {\r
+    "Usage:  ProcessDsc {options} [Dsc Filename]",\r
+    "    Options:",\r
+    "       -d var=value        to define symbol 'var' to 'value'",\r
+    "       -v                  for verbose mode",\r
+    "       -g filename         to preparse GUID listing file",\r
+    "       -x filename         to create a cross-reference file",\r
+    NULL\r
+  };\r
+  for (i = 0; Help[i] != NULL; i++) {\r
+    fprintf (stdout, "%s\n", Help[i]);\r
+  }\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process the [defines] section in the DSC file.\r
+\r
+Arguments:\r
+\r
+  DscFile - pointer to the DSCFile class that contains the relevant info.\r
+\r
+Returns:\r
+\r
+  0 if not necessarily an absolute path\r
+  1 otherwise\r
+\r
+--*/\r
+static\r
+int\r
+ProcessDSCDefinesSection (\r
+  DSC_FILE *DscFile\r
+  )\r
+{\r
+  INT8    Line[MAX_LINE_LEN];\r
+  INT8    Line2[MAX_EXP_LINE_LEN];\r
+  INT8    *Cptr;\r
+  SECTION *Sect;\r
+\r
+  //\r
+  // Look for a [defines] section and process it\r
+  //\r
+  Sect = DSCFileFindSection (DscFile, DEFINES_SECTION_NAME);\r
+  if (Sect == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines while they're valid\r
+  //\r
+  while (DSCFileGetLine (DscFile, Line, sizeof (Line)) != NULL) {\r
+    //\r
+    // Expand symbols on the line\r
+    //\r
+    if (ExpandSymbols (Line, Line2, sizeof (Line2), 0)) {\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Strip the line\r
+    //\r
+    Cptr = StripLine (Line2);\r
+    if (*Cptr) {\r
+      //\r
+      // Make the assignment\r
+      //\r
+      AddSymbol (Line2, NULL, SYM_OVERWRITE | SYM_GLOBAL);\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+IsAbsolutePath (\r
+  char    *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Determine if a given filename contains the full path information.\r
+\r
+Arguments:\r
+\r
+  FileName - the name of the file, with symbol expanded.\r
+\r
+Returns:\r
+\r
+  0 if not necessarily an absolute path\r
+  1 otherwise\r
+\r
+--*/\r
+{\r
+  //\r
+  // If the first character is a-z, and the second character is a colon, then\r
+  // it is an absolute path.\r
+  //\r
+  if (isalpha (FileName[0]) && (FileName[1] == ':')) {\r
+    return 1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+SMART_FILE *\r
+SmartOpen (\r
+  char        *FileName\r
+  )\r
+{\r
+  SMART_FILE     *SmartFile;\r
+  FILE           *Fptr;\r
+  int            FileSize;\r
+  \r
+  SmartFile = malloc (sizeof (SMART_FILE));\r
+  if (SmartFile == NULL) { \r
+    return NULL;\r
+  }\r
+  memset (SmartFile, 0, sizeof (SMART_FILE));\r
+  \r
+  SmartFile->FileName = malloc (strlen (FileName) + 1);\r
+  if (SmartFile->FileName == NULL){\r
+    SmartFree (SmartFile); \r
+    return NULL;\r
+  }\r
+  strcpy (SmartFile->FileName, FileName);\r
+\r
+  if ((Fptr = fopen (FileName, "r")) != NULL) {\r
+    fseek (Fptr, 0, SEEK_END);\r
+    FileSize = ftell (Fptr);\r
+    fseek (Fptr, 0, SEEK_SET);\r
+    SmartFile->FileContent = malloc (FileSize + 1);\r
+    if (SmartFile->FileContent != NULL) {\r
+      memset (SmartFile->FileContent, 0, FileSize + 1);\r
+      //\r
+      // Usually FileLength < FileSize, because in text mode, carriage return¨Clinefeed\r
+      // combinations are translated into single linefeeds on input\r
+      //       \r
+      SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr);\r
+    }\r
+    fclose (Fptr);\r
+  }\r
+  \r
+  //\r
+  // No previous output file content, re-create the file\r
+  //\r
+  if (SmartFile->FileContent == NULL) {\r
+    if ((SmartFile->FilePtr = fopen (FileName, "w")) == NULL) {\r
+      SmartFree (SmartFile);\r
+      return NULL;\r
+    }    \r
+  }\r
+  \r
+  return SmartFile;\r
+}\r
+\r
+int\r
+SmartWrite (\r
+  SMART_FILE  *SmartFile,\r
+  char        *String\r
+  )\r
+{\r
+  int  StrLen;\r
+  \r
+  if (SmartFile->FilePtr != NULL) {\r
+    return fprintf (SmartFile->FilePtr, "%s", String);\r
+  } else {\r
+    StrLen = strlen (String);\r
+    if ((StrLen > SmartFile->FileLength - SmartFile->FilePosition) || \r
+       (_strnicmp (&SmartFile->FileContent[SmartFile->FilePosition], String, StrLen) != 0)) {\r
+      //\r
+      // file changed, need to re-create.\r
+      //\r
+      if ((SmartFile->FilePtr = fopen (SmartFile->FileName, "w")) == NULL) {\r
+        Error (NULL, 0, 0, SmartFile->FileName, "could not open file for writing when SmartWrite");\r
+        return -1;\r
+      } else {\r
+        SmartFile->FileContent[SmartFile->FilePosition] = 0;\r
+        fprintf (SmartFile->FilePtr, "%s%s", SmartFile->FileContent, String);\r
+        return StrLen;\r
+      }      \r
+    } else {\r
+      SmartFile->FilePosition += StrLen;\r
+      return StrLen;\r
+    }\r
+  }\r
+}\r
+\r
+void\r
+SmartClose (\r
+  SMART_FILE  *SmartFile\r
+  )\r
+{\r
+  if ((SmartFile->FilePtr == NULL) && (SmartFile->FilePosition < SmartFile->FileLength)) {\r
+    //\r
+    // The new file is smaller than before, re-create it.\r
+    //\r
+    if ((SmartFile->FilePtr = fopen (SmartFile->FileName, "w")) == NULL) {\r
+      Error (NULL, 0, 0, SmartFile->FileName, "could not open file for writing when SmartClose");\r
+    } else {\r
+      SmartFile->FileContent[SmartFile->FilePosition] = 0;\r
+      fprintf (SmartFile->FilePtr, "%s", SmartFile->FileContent);\r
+    }\r
+  }\r
+  \r
+  SmartFree(SmartFile);\r
+}\r
+  \r
+static\r
+void\r
+SmartFree (\r
+  SMART_FILE  *SmartFile\r
+  )\r
+{\r
+  if (SmartFile == NULL) {\r
+    return;\r
+  }\r
+  \r
+  if (SmartFile->FileName != NULL ) {\r
+    free (SmartFile->FileName);\r
+  }\r
+  \r
+  if (SmartFile->FileContent != NULL ) {\r
+    free (SmartFile->FileContent);\r
+  }\r
+\r
+  if (SmartFile->FilePtr != NULL ) {\r
+    fclose (SmartFile->FilePtr);\r
+  } \r
+\r
+  free (SmartFile);\r
+  \r
+  return;\r
+}\r
+\r
+static \r
+int\r
+AddModuleName (\r
+  SYMBOL  **SymbolList,\r
+  INT8    *ModuleName,\r
+  INT8    *InfName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add module name in the global module list. \r
+  For the same module names, it is only added once.\r
+\r
+Arguments:\r
+  SymbolList : add name into this list\r
+  ModuleName : point to one module name char string.\r
+  InfName    : point to this module inf file name with path.\r
+\r
+Returns:\r
+\r
+  0 : Successfully add input name into the global list.\r
+  other value : allocate memory failed.\r
+\r
+--*/\r
+{\r
+  SYMBOL *CurrentSymbol;\r
+  SYMBOL *LastSymbol;\r
+  \r
+  //\r
+  // Get the global module list.\r
+  //\r
+  CurrentSymbol = *SymbolList;\r
+  LastSymbol    = *SymbolList;\r
+  \r
+  //\r
+  // Search whether this module name has been added into the global list.\r
+  //\r
+  while (CurrentSymbol != NULL) {\r
+    if (_stricmp (CurrentSymbol->Name, ModuleName) == 0) {\r
+      if ((CurrentSymbol->Value == NULL) && (InfName == NULL)) {\r
+        break;\r
+      } else if ((CurrentSymbol->Value != NULL) && (InfName != NULL) && \\r
+        (_stricmp (CurrentSymbol->Value, InfName) == 0)) {\r
+        break;\r
+      }\r
+    }\r
+    LastSymbol    = CurrentSymbol;\r
+    CurrentSymbol = CurrentSymbol->Next;\r
+  }\r
+  \r
+  //\r
+  // Add new module name in list.\r
+  //\r
+  if (CurrentSymbol == NULL) {\r
+    CurrentSymbol = (SYMBOL *) malloc (sizeof (SYMBOL));\r
+    if (CurrentSymbol == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+      return -1;\r
+    }\r
+    memset ((INT8 *) CurrentSymbol, 0, sizeof (SYMBOL));\r
+\r
+    if (ModuleName != NULL) {\r
+      CurrentSymbol->Name   = (INT8 *) malloc (strlen (ModuleName) + 1);\r
+      strcpy (CurrentSymbol->Name, ModuleName);\r
+    }\r
+\r
+    if (InfName != NULL) {\r
+      CurrentSymbol->Value  = (INT8 *) malloc (strlen (InfName) + 1);\r
+      strcpy (CurrentSymbol->Value, InfName);\r
+    }\r
+    \r
+    if (LastSymbol == NULL) {   \r
+      *SymbolList      = CurrentSymbol;\r
+    } else {\r
+      LastSymbol->Next = CurrentSymbol;\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile
new file mode 100644 (file)
index 0000000..39750fb
--- /dev/null
@@ -0,0 +1,88 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#\r
+#  Module Name:  \r
+#\r
+#    makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=SetStamp\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\SetStamp.c"\r
+TARGET_EXE_INCLUDE =\r
+OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).*\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
new file mode 100644 (file)
index 0000000..539aced
--- /dev/null
@@ -0,0 +1,475 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  SetStamp.c\r
+\r
+Abstract:\r
+  Set Date/Time Stamp of Portable Executable (PE) format file\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <time.h>\r
+\r
+#define LINE_MAXLEN 80\r
+\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+/*++\r
+Routine Description:\r
+  print usage of setstamp command\r
+\r
+Arguments:\r
+  void\r
+\r
+Returns:\r
+  None\r
+--*/\r
+{\r
+  //\r
+  // print usage of command\r
+  //\r
+  printf ("Usage: SetStamp <PE-File> <TIME-File>\n");\r
+}\r
+\r
+int\r
+GetDateTime (\r
+  FILE      *fp,\r
+  time_t    *ltime\r
+  )\r
+/*++\r
+Routine Description:\r
+  Read the date and time from TIME file. If the date/time string is\r
+"NOW NOW", write the current date and time to TIME file and set it to\r
+ltime. Else, set the date and time of TIME file to ltime.\r
+\r
+Arguments:\r
+  fp              - The pointer of TIME file\r
+  ltime           - Date and time\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  char      buffer[LINE_MAXLEN];\r
+  struct tm stime;\r
+  struct tm *now;\r
+\r
+  if (fgets (buffer, LINE_MAXLEN, fp) == NULL) {\r
+    printf ("Error: Cannot read TIME file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // compare the value with "NOW NOW", write TIME file if equal\r
+  //\r
+  if (strncmp (buffer, "NOW NOW", 7) == 0) {\r
+    //\r
+    // get system current time and date\r
+    //\r
+    time (ltime);\r
+\r
+    now = localtime (ltime);\r
+    if (now == NULL) {\r
+      printf ("Error: Cannot get local time.\n");\r
+      return -1;\r
+    }\r
+\r
+    if (strftime (buffer, LINE_MAXLEN, "%Y-%m-%d %H:%M:%S", now) == 0) {\r
+      printf ("Error: Cannot format time string.\n");\r
+      return -1;\r
+    }\r
+    //\r
+    // write TIME file\r
+    //\r
+    if (fseek (fp, 0, SEEK_SET) != 0) {\r
+      printf ("Error: Cannot move location of TIME file.\n");\r
+      return -1;\r
+    }\r
+\r
+    if (fputs (buffer, fp) == EOF) {\r
+      printf ("Error: Cannot write time string to TIME file.\n");\r
+      return -1;\r
+    }\r
+    //\r
+    // ltime has been set as current time and date, return\r
+    //\r
+    return 0;\r
+  }\r
+  //\r
+  // get the date and time from buffer\r
+  //\r
+  if (6 != sscanf (\r
+            buffer,\r
+            "%d-%d-%d %d:%d:%d",\r
+            &stime.tm_year,\r
+            &stime.tm_mon,\r
+            &stime.tm_mday,\r
+            &stime.tm_hour,\r
+            &stime.tm_min,\r
+            &stime.tm_sec\r
+            )) {\r
+    printf ("Error: Invaild date or time!\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // in struct, Month (0 - 11; Jan = 0). So decrease 1 from it\r
+  //\r
+  stime.tm_mon -= 1;\r
+\r
+  //\r
+  // in struct, Year (current year minus 1900)\r
+  // and only the dates can be handled from Jan 1, 1970 to Jan 18, 2038\r
+  //\r
+  //\r
+  // convert 0 -> 100 (2000), 1 -> 101 (2001), ..., 38 -> 138 (2038)\r
+  //\r
+  if (stime.tm_year <= 38) {\r
+    stime.tm_year += 100;\r
+  }\r
+  //\r
+  // convert 1970 -> 70, 2000 -> 100, ...\r
+  //\r
+  else if (stime.tm_year >= 1970) {\r
+    stime.tm_year -= 1900;\r
+  }\r
+  //\r
+  // convert the date and time to time_t format\r
+  //\r
+  *ltime = mktime (&stime);\r
+  if (*ltime == (time_t) - 1) {\r
+    printf ("Error: Invalid date or time!\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+ReadFromFile (\r
+  FILE      *fp,\r
+  long      offset,\r
+  void      *buffer,\r
+  int       size\r
+  )\r
+/*++\r
+Routine Description:\r
+  read data from a specified location of file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  offset          - number of bytes from beginning of file\r
+  buffer          - buffer used to store data\r
+  size            - size of buffer\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  //\r
+  // set file pointer to the specified location of file\r
+  //\r
+  if (fseek (fp, offset, SEEK_SET) != 0) {\r
+    printf ("Error: Cannot move the current location of the file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // read data from the file\r
+  //\r
+  if (fread (buffer, size, 1, fp) != 1) {\r
+    printf ("Error: Cannot read data from the file.\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+WriteToFile (\r
+  FILE      *fp,\r
+  long      offset,\r
+  void      *buffer,\r
+  int       size\r
+  )\r
+/*++\r
+Routine Description:\r
+  write data to a specified location of file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  offset          - number of bytes from beginning of file\r
+  buffer          - buffer used to store data\r
+  size            - size of buffer\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  //\r
+  // set file pointer to the specified location of file\r
+  //\r
+  if (fseek (fp, offset, SEEK_SET) != 0) {\r
+    printf ("Error: Cannot move the current location of the file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // write data to the file\r
+  //\r
+  if (fwrite (buffer, size, 1, fp) != 1) {\r
+    perror ("Error: Cannot write data to the file.\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+SetStamp (\r
+  FILE      *fp,\r
+  time_t    ltime\r
+  )\r
+/*++\r
+Routine Description:\r
+  set Date/Time Stamp of the file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  ltime           - time and date\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  unsigned char header[4];\r
+  unsigned long offset;\r
+  unsigned long NumberOfRvaAndSizes;\r
+  unsigned int  nvalue;\r
+  unsigned long lvalue;\r
+\r
+  //\r
+  // read the header of file\r
+  //\r
+  if (ReadFromFile (fp, 0, header, 2) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // "MZ" -- the header of image file (PE)\r
+  //\r
+  if (strncmp ((char *) header, "MZ", 2) != 0) {\r
+    printf ("Error: Invalid Image file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // At location 0x3C, the stub has the file offset to the\r
+  // PE signature.\r
+  //\r
+  if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // read the header of optional\r
+  //\r
+  if (ReadFromFile (fp, offset, header, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // "PE\0\0" -- the signature of optional header\r
+  //\r
+  if (strncmp ((char *) header, "PE\0\0", 4) != 0) {\r
+    printf ("Error: Invalid PE format file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // Add 8 to skip PE signature (4-byte), Machine (2-byte) and\r
+  // NumberOfSection (2-byte)\r
+  //\r
+  offset += 8;\r
+\r
+  if (WriteToFile (fp, offset, &ltime, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // Add 16 to skip COFF file header, and get to optional header.\r
+  //\r
+  offset += 16;\r
+\r
+  //\r
+  // Check the magic field, 0x10B for PE32 and 0x20B for PE32+\r
+  //\r
+  if (ReadFromFile (fp, offset, &nvalue, 2) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92.\r
+  // Else it is 108.\r
+  //\r
+  switch (nvalue & 0xFFFF) {\r
+  case 0x10B:\r
+    offset += 92;\r
+    break;\r
+\r
+  case 0x20B:\r
+    offset += 108;\r
+    break;\r
+\r
+  default:\r
+    printf ("Error: Sorry! The Magic value is unknown.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // get the value of NumberOfRvaAndSizes\r
+  //\r
+  if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // Date/time stamp exists in Export Table, Import Table, Resource Table,\r
+  // Debug Table and Delay Import Table. And in Import Table and Delay Import\r
+  // Table, it will be set when bound. So here only set the date/time stamp\r
+  // of Export Table, Resource Table and Debug Table.\r
+  //\r
+  //\r
+  // change date/time stamp of Export Table, the offset of Export Table\r
+  // is 4 + 0 * 8 = 4. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 1) {\r
+    if (ReadFromFile (fp, offset + 4, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // change date/time stamp of Resource Table, the offset of Resource Table\r
+  // is 4 + 2 * 8 = 20. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 3) {\r
+    if (ReadFromFile (fp, offset + 20, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // change date/time stamp of Debug Table, offset of Debug Table\r
+  // is 4 + 6 * 8 = 52. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 7) {\r
+    if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+    //\r
+    // change the date/time stamp of Debug Data\r
+    //\r
+    if (ReadFromFile (fp, lvalue + 24, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+    //\r
+    // get the signature of debug data\r
+    //\r
+    if (ReadFromFile (fp, lvalue, header, 2) != 0) {\r
+      return -1;\r
+    }\r
+    //\r
+    // "NB" - the signature of Debug Data\r
+    // Need Review: (From Spec. is "NB05", From .dll is "NB10")\r
+    //\r
+    if (strncmp ((char *) header, "NB", 2) == 0) {\r
+      if (WriteToFile (fp, lvalue + 8, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+main (\r
+  int       argc,\r
+  char      *argv[]\r
+  )\r
+{\r
+  FILE    *fp;\r
+  time_t  ltime;\r
+\r
+  //\r
+  // check the number of parameters\r
+  //\r
+  if (argc != 3) {\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+  //\r
+  // open the TIME file, if not exists, return\r
+  //\r
+  fp = fopen (argv[2], "r+");\r
+  if (fp == NULL) {\r
+    return 0;\r
+  }\r
+  //\r
+  // get time and date from file\r
+  //\r
+  if (GetDateTime (fp, &ltime) != 0) {\r
+    fclose (fp);\r
+    return -1;\r
+  }\r
+  //\r
+  // close the TIME file\r
+  //\r
+  fclose (fp);\r
+\r
+  //\r
+  // open the PE file\r
+  //\r
+  fp = fopen (argv[1], "r+b");\r
+  if (fp == NULL) {\r
+    printf ("Error: Cannot open the PE file!\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // set time and date stamp to the PE file\r
+  //\r
+  if (SetStamp (fp, ltime) != 0) {\r
+    fclose (fp);\r
+    return -1;\r
+  }\r
+\r
+  printf ("Set Date/Time Stamp to %s", ctime (&ltime));\r
+\r
+  //\r
+  // close the PE file\r
+  //\r
+  fclose (fp);\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile
new file mode 100644 (file)
index 0000000..a90e133
--- /dev/null
@@ -0,0 +1,94 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the SplitFile utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=SplitFile\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\SplitFile.c"\r
+TARGET_EXE_INCLUDE = \r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
new file mode 100644 (file)
index 0000000..860093c
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    splitfile.c\r
+    \r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "stdio.h"\r
+#include "string.h"\r
+#include "stdlib.h"\r
+\r
+void\r
+helpmsg (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "SplitFile Filename Offset\n""   Filename = Input file to split\n""   Offset = offset at which to split file\n"\r
+    "\n\n""SplitFile will break a file in two pieces at the requested offset\n"\r
+    "  outputting Filename1 and Filename2\n"\r
+    );\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char*argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  argc  - GC_TODO: add argument description\r
+  argv  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  FILE          *In;\r
+\r
+  FILE          *Out1;\r
+\r
+  FILE          *Out2;\r
+  char          OutName1[512];\r
+  char          OutName2[512];\r
+  unsigned long Index;\r
+  unsigned long splitpoint;\r
+  char          CharC;\r
+\r
+  if (argc != 3) {\r
+    helpmsg ();\r
+    return -1;\r
+  }\r
+\r
+  In = fopen (argv[1], "rb");\r
+  if (In == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", argv[1]);\r
+    return -1;\r
+  }\r
+\r
+  strncpy (OutName1, argv[1], 510);\r
+  strncpy (OutName2, argv[1], 510);\r
+  strcat (OutName1, "1");\r
+  strcat (OutName2, "2");\r
+\r
+  Out1 = fopen (OutName1, "wb");\r
+  if (Out1 == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", OutName1);\r
+    return -1;\r
+  }\r
+\r
+  Out2 = fopen (OutName2, "wb");\r
+  if (Out2 == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", OutName2);\r
+    return -1;\r
+  }\r
+\r
+  splitpoint = atoi (argv[2]);\r
+\r
+  for (Index = 0; Index < splitpoint; Index++) {\r
+    CharC = (char) fgetc (In);\r
+    if (feof (In)) {\r
+      break;\r
+    }\r
+\r
+    fputc (CharC, Out1);\r
+  }\r
+\r
+  for (;;) {\r
+    CharC = (char) fgetc (In);\r
+    if (feof (In)) {\r
+      break;\r
+    }\r
+\r
+    fputc (CharC, Out2);\r
+  }\r
+\r
+  fclose (In);\r
+  fclose (Out1);\r
+  fclose (Out2);\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile
new file mode 100644 (file)
index 0000000..dce81b0
--- /dev/null
@@ -0,0 +1,89 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    Makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    makefile for building the StrGather utility.\r
+#    \r
+#--*/  \r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+TARGET_NAME         = StrGather\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\StrGather.exe\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+\r
+LIBS      = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\StrGather.obj  \\r
+            $(EDK_TOOLS_OUTPUT)\StringDB.obj   \r
+\r
+INC_DEPS  = $(TARGET_SRC_DIR)\StrGather.h $(TARGET_SRC_DIR)\StringDB.h \r
+\r
+C_FLAGS = $(C_FLAGS) /W4\r
+\r
+#\r
+# Compile each source file\r
+#\r
+$(EDK_TOOLS_OUTPUT)\StrGather.obj : $(TARGET_SRC_DIR)\StrGather.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC_PATHS) $(TARGET_SRC_DIR)\StrGather.c /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\StringDB.obj : $(TARGET_SRC_DIR)\StringDB.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC_PATHS) $(TARGET_SRC_DIR)\StringDB.c /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tools.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  \r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
new file mode 100644 (file)
index 0000000..107a463
--- /dev/null
@@ -0,0 +1,2574 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StrGather.c  \r
+\r
+Abstract:\r
+\r
+  Parse a strings file and create or add to a string database file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "StrGather.h"\r
+#include "StringDB.h"\r
+\r
+#define TOOL_VERSION  "0.31"\r
+\r
+typedef UINT16  WCHAR;\r
+\r
+#define MAX_PATH                    1024\r
+#define MAX_NEST_DEPTH              20  // just in case we get in an endless loop.\r
+#define MAX_STRING_IDENTIFIER_NAME  100 // number of wchars\r
+#define MAX_LINE_LEN                400\r
+#define STRING_TOKEN                "STRING_TOKEN"\r
+#define DEFAULT_BASE_NAME           "BaseName"\r
+//\r
+// Operational modes for this utility\r
+//\r
+#define MODE_UNKNOWN  0\r
+#define MODE_PARSE    1\r
+#define MODE_SCAN     2\r
+#define MODE_DUMP     3\r
+\r
+//\r
+// We keep a linked list of these for the source files we process\r
+//\r
+typedef struct _SOURCE_FILE {\r
+  FILE                *Fptr;\r
+  WCHAR               *FileBuffer;\r
+  WCHAR               *FileBufferPtr;\r
+  UINT32              FileSize;\r
+  INT8                FileName[MAX_PATH];\r
+  UINT32              LineNum;\r
+  BOOLEAN             EndOfFile;\r
+  BOOLEAN             SkipToHash;\r
+  struct _SOURCE_FILE *Previous;\r
+  struct _SOURCE_FILE *Next;\r
+  WCHAR               ControlCharacter;\r
+} SOURCE_FILE;\r
+\r
+#define DEFAULT_CONTROL_CHARACTER UNICODE_SLASH\r
+\r
+//\r
+// Here's all our globals. We need a linked list of include paths, a linked\r
+// list of source files, a linked list of subdirectories (appended to each\r
+// include path when searching), and a couple other fields.\r
+//\r
+static struct {\r
+  SOURCE_FILE                 SourceFiles;\r
+  TEXT_STRING_LIST            *IncludePaths;                    // all include paths to search\r
+  TEXT_STRING_LIST            *LastIncludePath;\r
+  TEXT_STRING_LIST            *ScanFileName;\r
+  TEXT_STRING_LIST            *LastScanFileName;\r
+  TEXT_STRING_LIST            *SkipExt;                         // if -skipext .uni\r
+  TEXT_STRING_LIST            *LastSkipExt;\r
+  TEXT_STRING_LIST            *IndirectionFileName;\r
+  TEXT_STRING_LIST            *LastIndirectionFileName;\r
+  TEXT_STRING_LIST            *DatabaseFileName;\r
+  TEXT_STRING_LIST            *LastDatabaseFileName;\r
+  WCHAR_STRING_LIST           *Language;\r
+  WCHAR_STRING_LIST           *LastLanguage;\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList;                 // from indirection file(s)\r
+  WCHAR_MATCHING_STRING_LIST  *LastIndirectionList;\r
+  BOOLEAN                     Verbose;                          // for more detailed output\r
+  BOOLEAN                     VerboseDatabaseWrite;             // for more detailed output when writing database\r
+  BOOLEAN                     VerboseDatabaseRead;              // for more detailed output when reading database\r
+  BOOLEAN                     NewDatabase;                      // to start from scratch\r
+  BOOLEAN                     IgnoreNotFound;                   // when scanning\r
+  BOOLEAN                     VerboseScan;\r
+  BOOLEAN                     UnquotedStrings;                  // -uqs option\r
+  INT8                        OutputDatabaseFileName[MAX_PATH];\r
+  INT8                        StringHFileName[MAX_PATH];\r
+  INT8                        StringCFileName[MAX_PATH];        // output .C filename\r
+  INT8                        DumpUFileName[MAX_PATH];          // output unicode dump file name\r
+  INT8                        HiiExportPackFileName[MAX_PATH];  // HII export pack file name\r
+  INT8                        BaseName[MAX_PATH];               // base filename of the strings file\r
+  INT8                        OutputDependencyFileName[MAX_PATH];\r
+  FILE                        *OutputDependencyFptr;\r
+  UINT32                      Mode;\r
+} mGlobals;\r
+\r
+static\r
+BOOLEAN\r
+IsValidIdentifierChar (\r
+  INT8      Char,\r
+  BOOLEAN   FirstChar\r
+  );\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE *SourceFile,\r
+  WCHAR       WChar,\r
+  BOOLEAN     StopAfterNewline\r
+  );\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+UINT32\r
+GetStringIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *StringIdentifierName,\r
+  IN UINT32       StringIdentifierNameLen\r
+  );\r
+\r
+static\r
+UINT32\r
+GetLanguageIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *LanguageIdentifierName,\r
+  IN UINT32       LanguageIdentifierNameLen,\r
+  IN BOOLEAN      Optional\r
+  );\r
+\r
+static\r
+WCHAR *\r
+GetPrintableLanguageName (\r
+  IN SOURCE_FILE  *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+AddCommandLineLanguage (\r
+  IN INT8          *Language\r
+  );\r
+\r
+static\r
+WCHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+FILE  *\r
+FindFile (\r
+  IN INT8     *FileName,\r
+  OUT INT8    *FoundFileName,\r
+  IN UINT32   FoundFileNameLen\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+UINT32\r
+wstrcmp (\r
+  WCHAR *Buffer,\r
+  WCHAR *Str\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenString (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenScope (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenLanguage (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenLangDef (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ScanFiles (\r
+  TEXT_STRING_LIST *ScanFiles\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseIndirectionFiles (\r
+  TEXT_STRING_LIST    *Files\r
+  );\r
+\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  INT8                *OutputFileName\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process the file.\r
+  \r
+Arguments:\r
+\r
+  Argc - Standard C main() argc and argv.\r
+  Argv - Standard C main() argc and argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  STATUS  Status;\r
+\r
+  SetUtilityName (PROGRAM_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Initialize the database manager\r
+  //\r
+  StringDBConstructor ();\r
+  //\r
+  // We always try to read in an existing database file. It may not\r
+  // exist, which is ok usually.\r
+  //\r
+  if (mGlobals.NewDatabase == 0) {\r
+    //\r
+    // Read all databases specified.\r
+    //\r
+    for (mGlobals.LastDatabaseFileName = mGlobals.DatabaseFileName;\r
+         mGlobals.LastDatabaseFileName != NULL;\r
+         mGlobals.LastDatabaseFileName = mGlobals.LastDatabaseFileName->Next\r
+        ) {\r
+      Status = StringDBReadDatabase (mGlobals.LastDatabaseFileName->Str, TRUE, mGlobals.VerboseDatabaseRead);\r
+      if (Status != STATUS_SUCCESS) {\r
+        return Status;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Read indirection file(s) if specified\r
+  //\r
+  if (ParseIndirectionFiles (mGlobals.IndirectionFileName) != STATUS_SUCCESS) {\r
+    goto Finish;\r
+  }\r
+  //\r
+  // If scanning source files, do that now\r
+  //\r
+  if (mGlobals.Mode == MODE_SCAN) {\r
+    ScanFiles (mGlobals.ScanFileName);\r
+  } else if (mGlobals.Mode == MODE_PARSE) {\r
+    //\r
+    // Parsing a unicode strings file\r
+    //\r
+    mGlobals.SourceFiles.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
+    if (mGlobals.OutputDependencyFileName[0] != 0) {\r
+      if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) {\r
+        Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file");\r
+        goto Finish;\r
+      }    \r
+    }\r
+    Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);\r
+    if (mGlobals.OutputDependencyFptr != NULL) {\r
+      fclose (mGlobals.OutputDependencyFptr);\r
+    }    \r
+    if (Status != STATUS_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Create the string defines header file if there have been no errors.\r
+  //\r
+  ParserSetPosition (NULL, 0);\r
+  if ((mGlobals.StringHFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    Status = StringDBDumpStringDefines (mGlobals.StringHFileName, mGlobals.BaseName);\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Dump the strings to a .c file if there have still been no errors.\r
+  //\r
+  if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    Status = StringDBDumpCStrings (\r
+              mGlobals.StringCFileName,\r
+              mGlobals.BaseName,\r
+              mGlobals.Language,\r
+              mGlobals.IndirectionList\r
+              );\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Dump the database if requested\r
+  //\r
+  if ((mGlobals.DumpUFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    StringDBDumpDatabase (NULL, mGlobals.DumpUFileName, FALSE);\r
+  }\r
+  //\r
+  // Dump the string data as HII binary string pack if requested\r
+  //\r
+  if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);\r
+  }\r
+  //\r
+  // Always update the database if no errors and not in dump mode. If they specified -od\r
+  // for an output database file name, then use that name. Otherwise use the name of\r
+  // the first database file specified with -db\r
+  //\r
+  if ((mGlobals.Mode != MODE_DUMP) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    if (mGlobals.OutputDatabaseFileName[0]) {\r
+      Status = StringDBWriteDatabase (mGlobals.OutputDatabaseFileName, mGlobals.VerboseDatabaseWrite);\r
+    } else {\r
+      Status = StringDBWriteDatabase (mGlobals.DatabaseFileName->Str, mGlobals.VerboseDatabaseWrite);\r
+    }\r
+\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Free up memory\r
+  //\r
+  FreeLists ();\r
+  StringDBDestructor ();\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file, open the file and parse it\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - name of file to parse\r
+  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  static UINT32 NestDepth = 0;\r
+  INT8          FoundFileName[MAX_PATH];\r
+  STATUS        Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  NestDepth++;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Try to open the file locally, and if that fails try along our include paths.\r
+  //\r
+  strcpy (FoundFileName, SourceFile->FileName);\r
+  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
+    //\r
+    // Try to find it among the paths if it has a parent (that is, it is included\r
+    // by someone else).\r
+    //\r
+    if (ParentSourceFile == NULL) {\r
+      Error (NULL, 0, 0, SourceFile->FileName, "file not found");\r
+      Status = STATUS_ERROR;\r
+      goto Finish;\r
+    }\r
+\r
+    SourceFile->Fptr = FindFile (SourceFile->FileName, FoundFileName, sizeof (FoundFileName));\r
+    if (SourceFile->Fptr == NULL) {\r
+      Error (ParentSourceFile->FileName, ParentSourceFile->LineNum, 0, SourceFile->FileName, "include file not found");\r
+      Status = STATUS_ERROR;\r
+      goto Finish;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Output the dependency \r
+  //\r
+  if (mGlobals.OutputDependencyFptr != NULL) {\r
+    fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);    \r
+    //\r
+    // Add pseudo target to avoid incremental build failure when the file is deleted\r
+    //\r
+    fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName); \r
+  }\r
+   \r
+  //\r
+  // Process the file found\r
+  //\r
+  ProcessFile (SourceFile);\r
+\r
+Finish:\r
+  NestDepth--;\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (SourceFile->Fptr != NULL) {\r
+    fclose (SourceFile->Fptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // Get the file size, and then read the entire thing into memory.\r
+  // Allocate space for a terminator character.\r
+  //\r
+  fseek (SourceFile->Fptr, 0, SEEK_END);\r
+  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
+  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
+  SourceFile->FileBuffer = (WCHAR *) malloc (SourceFile->FileSize + sizeof (WCHAR));\r
+  if (SourceFile->FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
+  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (WCHAR))] = UNICODE_NULL;\r
+  //\r
+  // Pre-process the file to replace comments with spaces\r
+  //\r
+  PreprocessFile (SourceFile);\r
+  //\r
+  // Parse the file\r
+  //\r
+  ParseFile (SourceFile);\r
+  free (SourceFile->FileBuffer);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  BOOLEAN InComment;\r
+  UINT32  Len;\r
+\r
+  //\r
+  // First character of a unicode file is special. Make sure\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_FILE_START) {\r
+    Error (SourceFile->FileName, 1, 0, SourceFile->FileName, "file does not appear to be a unicode file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  InComment = FALSE;\r
+  //\r
+  // Print the first line if in verbose mode\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+  }\r
+  //\r
+  // Since the syntax is relatively straightforward, just switch on the next char\r
+  //\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // Check for whitespace\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_SPACE) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_TAB) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (mGlobals.Verbose) {\r
+        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+      }\r
+\r
+      InComment = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == 0) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
+      SourceFile->FileBufferPtr += 2;\r
+      InComment = TRUE;\r
+    } else if (SourceFile->SkipToHash && (SourceFile->FileBufferPtr[0] != SourceFile->ControlCharacter)) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else {\r
+      SourceFile->SkipToHash = FALSE;\r
+      if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+          ((Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"include")) > 0)\r
+          ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenInclude (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"scope")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenScope (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"language")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenLanguage (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"langdef")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenLangDef (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"string")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenString (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"EFI_BREAKPOINT()")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len;\r
+        EFI_BREAKPOINT ();\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (SourceFile->FileBufferPtr[1] == UNICODE_EQUAL_SIGN)\r
+              ) {\r
+        SourceFile->ControlCharacter = SourceFile->FileBufferPtr[2];\r
+        SourceFile->FileBufferPtr += 3;\r
+      } else {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "unrecognized token", "%S", SourceFile->FileBufferPtr);\r
+        //\r
+        // Treat rest of line as a comment.\r
+        //\r
+        InComment = TRUE;\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Preprocess a file to replace all carriage returns with NULLs so\r
+  we can print lines from the file to the screen.\r
+  \r
+Arguments:\r
+  SourceFile - structure that we use to keep track of an input file.\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  BOOLEAN InComment;\r
+\r
+  RewindFile (SourceFile);\r
+  InComment = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // If a line-feed, then no longer in a comment\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      InComment = 0;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      //\r
+      // Replace all carriage returns with a NULL so we can print stuff\r
+      //\r
+      SourceFile->FileBufferPtr[0] = 0;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr[0] = UNICODE_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
+      SourceFile->FileBufferPtr += 2;\r
+      InComment = TRUE;\r
+    } else {\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // Could check for end-of-file and still in a comment, but\r
+  // should not be necessary. So just restore the file pointers.\r
+  //\r
+  RewindFile (SourceFile);\r
+}\r
+\r
+static\r
+WCHAR *\r
+GetPrintableLanguageName (\r
+  IN SOURCE_FILE  *SourceFile\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *Start;\r
+  WCHAR   *Ptr;\r
+  UINT32  Len;\r
+\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "expected quoted printable language name",\r
+      "%S",\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    SourceFile->SkipToHash = TRUE;\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start = Ptr = SourceFile->FileBufferPtr;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
+      break;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Warning (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "missing closing quote on printable language name string",\r
+      "%S",\r
+      Start\r
+      );\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  //\r
+  // Now format the string to convert \wide and \narrow controls\r
+  //\r
+  StringDBFormatString (String);\r
+  return String;\r
+}\r
+\r
+static\r
+WCHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *Start;\r
+  WCHAR   *Ptr;\r
+  UINT32  Len;\r
+  BOOLEAN PreviousBackslash;\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    if (!Optional) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start             = Ptr = SourceFile->FileBufferPtr;\r
+  PreviousBackslash = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) && (!PreviousBackslash)) {\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      PreviousBackslash = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_BACKSLASH) {\r
+      PreviousBackslash = TRUE;\r
+    } else {\r
+      PreviousBackslash = FALSE;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return String;\r
+}\r
+//\r
+// Parse:\r
+//    #string STR_ID_NAME\r
+//\r
+// All we can do is call the string database to add the string identifier. Unfortunately\r
+// he'll have to keep track of the last identifier we added.\r
+//\r
+static\r
+void\r
+ProcessTokenString (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  UINT16  StringId;\r
+  //\r
+  // Extract the string identifier name and add it to the database.\r
+  //\r
+  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
+    StringId = STRING_ID_INVALID;\r
+    StringDBAddStringIdentifier (StringIdentifier, &StringId, 0);\r
+  } else {\r
+    //\r
+    // Error recovery -- skip to the next #\r
+    //\r
+    SourceFile->SkipToHash = TRUE;\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
+  // source file structure, so check it first.\r
+  //\r
+  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (WCHAR)) {\r
+    SourceFile->EndOfFile = TRUE;\r
+    return TRUE;\r
+  }\r
+\r
+  if (SourceFile->EndOfFile) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+UINT32\r
+GetStringIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *StringIdentifierName,\r
+  IN UINT32       StringIdentifierNameLen\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *From;\r
+  WCHAR   *Start;\r
+\r
+  //\r
+  // Skip whitespace\r
+  //\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->EndOfFile) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-file encountered", "expected string identifier");\r
+    return 0;\r
+  }\r
+  //\r
+  // Verify first character of name is [A-Za-z]\r
+  //\r
+  Len = 0;\r
+  StringIdentifierNameLen /= 2;\r
+  From  = SourceFile->FileBufferPtr;\r
+  Start = SourceFile->FileBufferPtr;\r
+  if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
+      ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))\r
+      ) {\r
+    //\r
+    // Do nothing\r
+    //\r
+  } else {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid character in string identifier name", "%S", Start);\r
+    return 0;\r
+  }\r
+\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
+        ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z)) ||\r
+        ((SourceFile->FileBufferPtr[0] >= UNICODE_0) && (SourceFile->FileBufferPtr[0] <= UNICODE_9)) ||\r
+        (SourceFile->FileBufferPtr[0] == UNICODE_UNDERSCORE)\r
+        ) {\r
+      Len++;\r
+      if (Len >= StringIdentifierNameLen) {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "string identifier name too long", "%S", Start);\r
+        return 0;\r
+      }\r
+\r
+      *StringIdentifierName = SourceFile->FileBufferPtr[0];\r
+      StringIdentifierName++;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SkipWhiteSpace (SourceFile) == 0) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid string identifier name", "%S", Start);\r
+      return 0;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Terminate the copy of the string.\r
+  //\r
+  *StringIdentifierName = 0;\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+GetLanguageIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *LanguageIdentifierName,\r
+  IN UINT32       LanguageIdentifierNameLen,\r
+  IN BOOLEAN      Optional\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *From;\r
+  WCHAR   *Start;\r
+  //\r
+  // Skip whitespace\r
+  //\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->EndOfFile) {\r
+    if (!Optional) {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        "end-of-file encountered",\r
+        "expected language identifier"\r
+        );\r
+    }\r
+\r
+    return 0;\r
+  }\r
+  //\r
+  // This function is called to optionally get a language identifier name in:\r
+  //   #string STR_ID eng "the string"\r
+  // If it's optional, and we find a double-quote, then return now.\r
+  //\r
+  if (Optional) {\r
+    if (*SourceFile->FileBufferPtr == UNICODE_DOUBLE_QUOTE) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  Len = 0;\r
+  LanguageIdentifierNameLen /= 2;\r
+  //\r
+  // Internal error if we weren't given at least 4 WCHAR's to work with.\r
+  //\r
+  if (LanguageIdentifierNameLen < LANGUAGE_IDENTIFIER_NAME_LEN + 1) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "app error -- language identifier name length is invalid",\r
+      NULL\r
+      );\r
+  }\r
+\r
+  From  = SourceFile->FileBufferPtr;\r
+  Start = SourceFile->FileBufferPtr;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (((SourceFile->FileBufferPtr[0] >= UNICODE_a) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))) {\r
+      Len++;\r
+      if (Len > LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "language identifier name too long", "%S", Start);\r
+        return 0;\r
+      }\r
+\r
+      *LanguageIdentifierName = SourceFile->FileBufferPtr[0];\r
+      SourceFile->FileBufferPtr++;\r
+      LanguageIdentifierName++;\r
+    } else if (!IsWhiteSpace (SourceFile)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid language identifier name", "%S", Start);\r
+      return 0;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Terminate the copy of the string.\r
+  //\r
+  *LanguageIdentifierName = 0;\r
+  return Len;\r
+}\r
+\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  INT8        IncludeFileName[MAX_PATH];\r
+  INT8        *To;\r
+  UINT32      Len;\r
+  BOOLEAN     ReportedError;\r
+  SOURCE_FILE IncludedSourceFile;\r
+\r
+  ReportedError = FALSE;\r
+  if (SkipWhiteSpace (SourceFile) == 0) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
+  }\r
+  //\r
+  // Should be quoted file name\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  //\r
+  // Copy the filename as ascii to our local string\r
+  //\r
+  To  = IncludeFileName;\r
+  Len = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == UNICODE_CR) || (SourceFile->FileBufferPtr[0] == UNICODE_LF)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
+      goto FailDone;\r
+    }\r
+\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+    }\r
+    //\r
+    // If too long, then report the error once and process until the closing quote\r
+    //\r
+    Len++;\r
+    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
+      ReportedError = TRUE;\r
+    }\r
+\r
+    if (!ReportedError) {\r
+      *To = UNICODE_TO_ASCII (SourceFile->FileBufferPtr[0]);\r
+      To++;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+\r
+  if (!ReportedError) {\r
+    *To = 0;\r
+    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
+    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
+    IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
+    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
+    //\r
+    // printf ("including file '%s'\n", IncludeFileName);\r
+    //\r
+  }\r
+\r
+  return ;\r
+FailDone:\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+\r
+static\r
+void\r
+ProcessTokenScope (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  //\r
+  // Extract the scope name\r
+  //\r
+  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
+    StringDBSetScope (StringIdentifier);\r
+  }\r
+}\r
+//\r
+// Parse:  #langdef eng "English"\r
+//         #langdef chn "\wideChinese"\r
+//\r
+static\r
+void\r
+ProcessTokenLangDef (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   LanguageIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  UINT32  Len;\r
+  WCHAR   *PrintableName;\r
+  //\r
+  // Extract the 3-character language identifier\r
+  //\r
+  Len = GetLanguageIdentifierName (SourceFile, LanguageIdentifier, sizeof (LanguageIdentifier), FALSE);\r
+  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", NULL);\r
+  } else {\r
+    //\r
+    // Extract the printable name\r
+    //\r
+    PrintableName = GetPrintableLanguageName (SourceFile);\r
+    if (PrintableName != NULL) {\r
+      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
+      StringDBAddLanguage (LanguageIdentifier, PrintableName);\r
+      free (PrintableName);\r
+      return ;\r
+    }\r
+  }\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+ApparentQuotedString (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR *Ptr;\r
+  //\r
+  // See if the first and last nonblank characters on the line are double quotes\r
+  //\r
+  for (Ptr = SourceFile->FileBufferPtr; *Ptr && (*Ptr == UNICODE_SPACE); Ptr++)\r
+    ;\r
+  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
+    return FALSE;\r
+  }\r
+\r
+  while (*Ptr) {\r
+    Ptr++;\r
+  }\r
+\r
+  Ptr--;\r
+  for (; *Ptr && (*Ptr == UNICODE_SPACE); Ptr--)\r
+    ;\r
+  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+//\r
+// Parse:\r
+//   #language eng "some string " "more string"\r
+//\r
+static\r
+void\r
+ProcessTokenLanguage (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *SecondString;\r
+  WCHAR   *TempString;\r
+  WCHAR   *From;\r
+  WCHAR   *To;\r
+  WCHAR   Language[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
+  UINT32  Len;\r
+  BOOLEAN PreviousNewline;\r
+  //\r
+  // Get the language identifier\r
+  //\r
+  Language[0] = 0;\r
+  Len         = GetLanguageIdentifierName (SourceFile, Language, sizeof (Language), TRUE);\r
+  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", "%S", Language);\r
+    SourceFile->SkipToHash = TRUE;\r
+    return ;\r
+  }\r
+  //\r
+  // Extract the string value. It's either a quoted string that starts on the current line, or\r
+  // an unquoted string that starts on the following line and continues until the next control\r
+  // character in column 1.\r
+  // Look ahead to find a quote or a newline\r
+  //\r
+  if (SkipTo (SourceFile, UNICODE_DOUBLE_QUOTE, TRUE)) {\r
+    String = GetQuotedString (SourceFile, FALSE);\r
+    if (String != NULL) {\r
+      //\r
+      // Set the position in the file of where we are parsing for error\r
+      // reporting purposes. Then start looking ahead for additional\r
+      // quoted strings, and concatenate them until we get a failure\r
+      // back from the string parser.\r
+      //\r
+      Len = wcslen (String) + 1;\r
+      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
+      do {\r
+        SkipWhiteSpace (SourceFile);\r
+        SecondString = GetQuotedString (SourceFile, TRUE);\r
+        if (SecondString != NULL) {\r
+          Len += wcslen (SecondString);\r
+          TempString = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
+          if (TempString == NULL) {\r
+            Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
+            return ;\r
+          }\r
+\r
+          wcscpy (TempString, String);\r
+          wcscat (TempString, SecondString);\r
+          free (String);\r
+          free (SecondString);\r
+          String = TempString;\r
+        }\r
+      } while (SecondString != NULL);\r
+      StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
+      free (String);\r
+    } else {\r
+      //\r
+      // Error was reported at lower level. Error recovery mode.\r
+      //\r
+      SourceFile->SkipToHash = TRUE;\r
+    }\r
+  } else {\r
+    if (!mGlobals.UnquotedStrings) {\r
+      //\r
+      // They're using unquoted strings. If the next non-blank character is a double quote, and the\r
+      // last non-blank character on the line is a double quote, then more than likely they're using\r
+      // quotes, so they need to put the quoted string on the end of the previous line\r
+      //\r
+      if (ApparentQuotedString (SourceFile)) {\r
+        Warning (\r
+          SourceFile->FileName,\r
+          SourceFile->LineNum,\r
+          0,\r
+          "unexpected quoted string on line",\r
+          "specify -uqs option if necessary"\r
+          );\r
+      }\r
+    }\r
+    //\r
+    // Found end-of-line (hopefully). Skip over it and start taking in characters\r
+    // until we find a control character at the start of a line.\r
+    //\r
+    Len             = 0;\r
+    From            = SourceFile->FileBufferPtr;\r
+    PreviousNewline = FALSE;\r
+    while (!EndOfFile (SourceFile)) {\r
+      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+        PreviousNewline = TRUE;\r
+        SourceFile->LineNum++;\r
+      } else {\r
+        Len++;\r
+        if (PreviousNewline && (SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter)) {\r
+          break;\r
+        }\r
+\r
+        PreviousNewline = FALSE;\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+\r
+    if ((Len == 0) && EndOfFile (SourceFile)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "unexpected end of file", NULL);\r
+      SourceFile->SkipToHash = TRUE;\r
+      return ;\r
+    }\r
+    //\r
+    // Now allocate a buffer, copy the characters, and add the string.\r
+    //\r
+    String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+    if (String == NULL) {\r
+      Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
+      return ;\r
+    }\r
+\r
+    To = String;\r
+    while (From < SourceFile->FileBufferPtr) {\r
+      switch (*From) {\r
+      case UNICODE_LF:\r
+      case 0:\r
+        break;\r
+\r
+      default:\r
+        *To = *From;\r
+        To++;\r
+        break;\r
+      }\r
+\r
+      From++;\r
+    }\r
+\r
+    //\r
+    // String[Len] = 0;\r
+    //\r
+    *To = 0;\r
+    StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  switch (SourceFile->FileBufferPtr[0]) {\r
+  case UNICODE_NULL:\r
+  case UNICODE_CR:\r
+  case UNICODE_SPACE:\r
+  case UNICODE_TAB:\r
+  case UNICODE_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  UINT32  Count;\r
+\r
+  Count = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    Count++;\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case UNICODE_NULL:\r
+    case UNICODE_CR:\r
+    case UNICODE_SPACE:\r
+    case UNICODE_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case UNICODE_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (mGlobals.Verbose) {\r
+        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return Count - 1;\r
+    }\r
+  }\r
+  //\r
+  // Some tokens require trailing whitespace. If we're at the end of the\r
+  // file, then we count that as well.\r
+  //\r
+  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
+    Count++;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+static\r
+UINT32\r
+wstrcmp (\r
+  WCHAR *Buffer,\r
+  WCHAR *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+\r
+  Len = 0;\r
+  while (*Str == *Buffer) {\r
+    Buffer++;\r
+    Str++;\r
+    Len++;\r
+  }\r
+\r
+  if (*Str) {\r
+    return 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+//\r
+// Given a filename, try to find it along the include paths.\r
+//\r
+static\r
+FILE *\r
+FindFile (\r
+  IN INT8    *FileName,\r
+  OUT INT8   *FoundFileName,\r
+  IN UINT32  FoundFileNameLen\r
+  )\r
+{\r
+  FILE              *Fptr;\r
+  TEXT_STRING_LIST  *List;\r
+\r
+  //\r
+  // Traverse the list of paths and try to find the file\r
+  //\r
+  List = mGlobals.IncludePaths;\r
+  while (List != NULL) {\r
+    //\r
+    // Put the path and filename together\r
+    //\r
+    if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
+      return NULL;\r
+    }\r
+    //\r
+    // Append the filename to this include path and try to open the file.\r
+    //\r
+    strcpy (FoundFileName, List->Str);\r
+    strcat (FoundFileName, FileName);\r
+    if ((Fptr = fopen (FoundFileName, "rb")) != NULL) {\r
+      //\r
+      // Return the file pointer\r
+      //\r
+      return Fptr;\r
+    }\r
+\r
+    List = List->Next;\r
+  }\r
+  //\r
+  // Not found\r
+  //\r
+  FoundFileName[0] = 0;\r
+  return NULL;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+{\r
+  TEXT_STRING_LIST  *NewList;\r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
+  strcpy (mGlobals.BaseName, DEFAULT_BASE_NAME);\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  mGlobals.Mode = MODE_UNKNOWN;\r
+  //\r
+  // Process until no more -args.\r
+  //\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    //\r
+    // -parse option\r
+    //\r
+    if (_stricmp (Argv[0], "-parse") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_PARSE;\r
+      //\r
+      // -scan option\r
+      //\r
+    } else if (_stricmp (Argv[0], "-scan") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_SCAN;\r
+      //\r
+      // -vscan verbose scanning option\r
+      //\r
+    } else if (_stricmp (Argv[0], "-vscan") == 0) {\r
+      mGlobals.VerboseScan = TRUE;\r
+      //\r
+      // -dump option\r
+      //\r
+    } else if (_stricmp (Argv[0], "-dump") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_DUMP;\r
+    } else if (_stricmp (Argv[0], "-uqs") == 0) {\r
+      mGlobals.UnquotedStrings = TRUE;\r
+      //\r
+      // -i path    add include search path when parsing\r
+      //\r
+    } else if (_stricmp (Argv[0], "-i") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of include paths. Always make sure it\r
+      // has a "\" on the end of it.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      if (NewList->Str[strlen (NewList->Str) - 1] != '\\') {\r
+        strcat (NewList->Str, "\\");\r
+      }\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.IncludePaths == NULL) {\r
+        mGlobals.IncludePaths = NewList;\r
+      } else {\r
+        mGlobals.LastIncludePath->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastIncludePath = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-if") == 0) {\r
+      //\r
+      // Indirection file -- check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of include paths. Always make sure it\r
+      // has a "\" on the end of it.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.IndirectionFileName == NULL) {\r
+        mGlobals.IndirectionFileName = NewList;\r
+      } else {\r
+        mGlobals.LastIndirectionFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastIndirectionFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-db") == 0) {\r
+      //\r
+      // -db option to specify a database file.\r
+      // Check for one more arg (the database file name)\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.DatabaseFileName == NULL) {\r
+        mGlobals.DatabaseFileName = NewList;\r
+      } else {\r
+        mGlobals.LastDatabaseFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastDatabaseFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-ou") == 0) {\r
+      //\r
+      // -ou option to specify an output unicode file to\r
+      // which we can dump our database.\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.DumpUFileName[0] == 0) {\r
+        strcpy (mGlobals.DumpUFileName, Argv[1]);\r
+      } else {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-hpk") == 0) {\r
+      //\r
+      // -hpk option to create an HII export pack of the input database file\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.HiiExportPackFileName[0] == 0) {\r
+        strcpy (mGlobals.HiiExportPackFileName, Argv[1]);\r
+      } else {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if ((_stricmp (Argv[0], "-?") == 0) || (_stricmp (Argv[0], "-h") == 0)) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else if (_stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = 1;\r
+    } else if (_stricmp (Argv[0], "-vdbw") == 0) {\r
+      mGlobals.VerboseDatabaseWrite = 1;\r
+    } else if (_stricmp (Argv[0], "-vdbr") == 0) {\r
+      mGlobals.VerboseDatabaseRead = 1;\r
+    } else if (_stricmp (Argv[0], "-newdb") == 0) {\r
+      mGlobals.NewDatabase = 1;\r
+    } else if (_stricmp (Argv[0], "-ignorenotfound") == 0) {\r
+      mGlobals.IgnoreNotFound = 1;\r
+    } else if (_stricmp (Argv[0], "-oc") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.StringCFileName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-bn") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.BaseName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-oh") == 0) {\r
+      //\r
+      // -oh to specify output .h defines file name\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.StringHFileName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-dep") == 0) {\r
+      //\r
+      // -dep to specify output dependency file name\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OutputDependencyFileName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-skipext") == 0) {\r
+      //\r
+      // -skipext to skip scanning of files with certain filename extensions\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of excluded extensions. Always make sure it\r
+      // has a "." as the first character.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (Argv[1][0] == '.') {\r
+        strcpy (NewList->Str, Argv[1]);\r
+      } else {\r
+        NewList->Str[0] = '.';\r
+        strcpy (NewList->Str + 1, Argv[1]);\r
+      }\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.SkipExt == NULL) {\r
+        mGlobals.SkipExt = NewList;\r
+      } else {\r
+        mGlobals.LastSkipExt->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastSkipExt = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-lang") == 0) {\r
+      //\r
+      // "-lang eng" or "-lang spa+cat" to only output certain languages\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (AddCommandLineLanguage (Argv[1]) != STATUS_SUCCESS) {\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (_stricmp (Argv[0], "-od") == 0) {\r
+      //\r
+      // Output database file name -- check for another arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);\r
+      Argv++;\r
+      Argc--;\r
+    } else {\r
+      //\r
+      // Unrecognized arg\r
+      //\r
+      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Make sure they specified the mode parse/scan/dump\r
+  //\r
+  if (mGlobals.Mode == MODE_UNKNOWN) {\r
+    Error (NULL, 0, 0, "must specify one of -parse/-scan/-dump", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // All modes require a database filename\r
+  //\r
+  if (mGlobals.DatabaseFileName == 0) {\r
+    Error (NULL, 0, 0, "must specify a database filename using -db DbFileName", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If dumping the database file, then return immediately if all\r
+  // parameters check out.\r
+  //\r
+  if (mGlobals.Mode == MODE_DUMP) {\r
+    //\r
+    // Not much use if they didn't specify -oh or -oc or -ou or -hpk\r
+    //\r
+    if ((mGlobals.DumpUFileName[0] == 0) &&\r
+        (mGlobals.StringHFileName[0] == 0) &&\r
+        (mGlobals.StringCFileName[0] == 0) &&\r
+        (mGlobals.HiiExportPackFileName[0] == 0)\r
+        ) {\r
+      Error (NULL, 0, 0, "-dump without -oc/-oh/-ou/-hpk is a NOP", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // Had to specify source string file and output string defines header filename.\r
+  //\r
+  if (mGlobals.Mode == MODE_SCAN) {\r
+    if (Argc < 1) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Get the list of filenames\r
+    //\r
+    while (Argc > 0) {\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset (NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[0]);\r
+      if (mGlobals.ScanFileName == NULL) {\r
+        mGlobals.ScanFileName = NewList;\r
+      } else {\r
+        mGlobals.LastScanFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastScanFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    }\r
+  } else {\r
+    //\r
+    // Parse mode -- must specify an input unicode file name\r
+    //\r
+    if (Argc < 1) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (mGlobals.SourceFiles.FileName, Argv[0]);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Found "-lang eng,spa+cat" on the command line. Parse the\r
+// language list and save the setting for later processing.\r
+//\r
+static\r
+STATUS\r
+AddCommandLineLanguage (\r
+  IN INT8          *Language\r
+  )\r
+{\r
+  WCHAR_STRING_LIST *WNewList;\r
+  WCHAR             *From;\r
+  WCHAR             *To;\r
+  //\r
+  // Keep processing the input string until we find the end.\r
+  //\r
+  while (*Language) {\r
+    //\r
+    // Allocate memory for a new list element, fill it in, and\r
+    // add it to our list.\r
+    //\r
+    WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));\r
+    if (WNewList == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));\r
+    WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));\r
+    if (WNewList->Str == NULL) {\r
+      free (WNewList);\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Copy it as unicode to our new structure. Then remove the\r
+    // plus signs in it, and verify each language name is 3 characters\r
+    // long. If we find a comma, then we're done with this group, so\r
+    // break out.\r
+    //\r
+#ifdef USE_VC8\r
+    swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language);\r
+#else\r
+    swprintf (WNewList->Str, L"%S", Language);\r
+#endif\r
+    From = To = WNewList->Str;\r
+    while (*From) {\r
+      if (*From == L',') {\r
+        break;\r
+      }\r
+\r
+      if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||\r
+            (\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')\r
+            )\r
+          ) {\r
+        Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");\r
+        FREE (WNewList->Str);\r
+        FREE (WNewList);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);\r
+      To += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      From += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      if (*From == L'+') {\r
+        From++;\r
+      }\r
+    }\r
+\r
+    *To = 0;\r
+    //\r
+    // Add it to our linked list\r
+    //\r
+    if (mGlobals.Language == NULL) {\r
+      mGlobals.Language = WNewList;\r
+    } else {\r
+      mGlobals.LastLanguage->Next = WNewList;\r
+    }\r
+\r
+    mGlobals.LastLanguage = WNewList;\r
+    //\r
+    // Skip to next entry (comma-separated list)\r
+    //\r
+    while (*Language) {\r
+      if (*Language == L',') {\r
+        Language++;\r
+        break;\r
+      }\r
+\r
+      Language++;\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// The contents of the text file are expected to be (one per line)\r
+//   STRING_IDENTIFIER_NAME   ScopeName\r
+// For example:\r
+//   STR_ID_MY_FAVORITE_STRING   IBM\r
+//\r
+static\r
+STATUS\r
+ParseIndirectionFiles (\r
+  TEXT_STRING_LIST    *Files\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  INT8                        Line[200];\r
+  INT8                        *StringName;\r
+  INT8                        *ScopeName;\r
+  INT8                        *End;\r
+  UINT32                      LineCount;\r
+  WCHAR_MATCHING_STRING_LIST  *NewList;\r
+\r
+  Line[sizeof (Line) - 1] = 0;\r
+  Fptr                    = NULL;\r
+  while (Files != NULL) {\r
+    Fptr      = fopen (Files->Str, "r");\r
+    LineCount = 0;\r
+    if (Fptr == NULL) {\r
+      Error (NULL, 0, 0, Files->Str, "failed to open input indirection file for reading");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+      //\r
+      // remove terminating newline for error printing purposes.\r
+      //\r
+      if (Line[strlen (Line) - 1] == '\n') {\r
+        Line[strlen (Line) - 1] = 0;\r
+      }\r
+\r
+      LineCount++;\r
+      if (Line[sizeof (Line) - 1] != 0) {\r
+        Error (Files->Str, LineCount, 0, "line length exceeds maximum supported", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      StringName = Line;\r
+      while (*StringName && (isspace (*StringName))) {\r
+        StringName++;\r
+      }\r
+\r
+      if (*StringName) {\r
+        if ((*StringName == '_') || isalpha (*StringName)) {\r
+          End = StringName;\r
+          while ((*End) && (*End == '_') || (isalnum (*End))) {\r
+            End++;\r
+          }\r
+\r
+          if (isspace (*End)) {\r
+            *End = 0;\r
+            End++;\r
+            while (isspace (*End)) {\r
+              End++;\r
+            }\r
+\r
+            if (*End) {\r
+              ScopeName = End;\r
+              while (*End && !isspace (*End)) {\r
+                End++;\r
+              }\r
+\r
+              *End = 0;\r
+              //\r
+              // Add the string name/scope pair\r
+              //\r
+              NewList = malloc (sizeof (WCHAR_MATCHING_STRING_LIST));\r
+              if (NewList == NULL) {\r
+                Error (NULL, 0, 0, "memory allocation error", NULL);\r
+                goto Done;\r
+              }\r
+\r
+              memset (NewList, 0, sizeof (WCHAR_MATCHING_STRING_LIST));\r
+              NewList->Str1 = (WCHAR *) malloc ((strlen (StringName) + 1) * sizeof (WCHAR));\r
+              NewList->Str2 = (WCHAR *) malloc ((strlen (ScopeName) + 1) * sizeof (WCHAR));\r
+              if ((NewList->Str1 == NULL) || (NewList->Str2 == NULL)) {\r
+                Error (NULL, 0, 0, "memory allocation error", NULL);\r
+                goto Done;\r
+              }\r
+\r
+#ifdef USE_VC8\r
+              swprintf (NewList->Str1, (strlen (StringName) + 1) * sizeof (WCHAR), L"%S", StringName);\r
+              swprintf (NewList->Str2, (strlen (ScopeName) + 1) * sizeof (WCHAR), L"%S", ScopeName);\r
+#else\r
+              swprintf (NewList->Str1, L"%S", StringName);\r
+              swprintf (NewList->Str2, L"%S", ScopeName);\r
+#endif\r
+              if (mGlobals.IndirectionList == NULL) {\r
+                mGlobals.IndirectionList = NewList;\r
+              } else {\r
+                mGlobals.LastIndirectionList->Next = NewList;\r
+              }\r
+\r
+              mGlobals.LastIndirectionList = NewList;\r
+            } else {\r
+              Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
+              goto Done;\r
+            }\r
+          } else {\r
+            Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
+            goto Done;\r
+          }\r
+        } else {\r
+          Error (Files->Str, LineCount, 0, StringName, "invalid string identifier");\r
+          goto Done;\r
+        }\r
+      }\r
+    }\r
+\r
+    fclose (Fptr);\r
+    Fptr  = NULL;\r
+    Files = Files->Next;\r
+  }\r
+\r
+Done:\r
+  if (Fptr != NULL) {\r
+    fclose (Fptr);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ScanFiles (\r
+  TEXT_STRING_LIST *ScanFiles\r
+  )\r
+{\r
+  char              Line[MAX_LINE_LEN];\r
+  FILE              *Fptr;\r
+  UINT32            LineNum;\r
+  char              *Cptr;\r
+  char              *SavePtr;\r
+  char              *TermPtr;\r
+  char              *StringTokenPos;\r
+  TEXT_STRING_LIST  *SList;\r
+  BOOLEAN           SkipIt;\r
+\r
+  //\r
+  // Put a null-terminator at the end of the line. If we read in\r
+  // a line longer than we support, then we can catch it.\r
+  //\r
+  Line[MAX_LINE_LEN - 1] = 0;\r
+  //\r
+  // Process each file. If they gave us a skip extension list, then\r
+  // skip it if the extension matches.\r
+  //\r
+  while (ScanFiles != NULL) {\r
+    SkipIt = FALSE;\r
+    for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {\r
+      if ((strlen (ScanFiles->Str) > strlen (SList->Str)) &&\r
+          (strcmp (ScanFiles->Str + strlen (ScanFiles->Str) - strlen (SList->Str), SList->Str) == 0)\r
+          ) {\r
+        SkipIt = TRUE;\r
+        //\r
+        // printf ("Match: %s : %s\n", ScanFiles->Str, SList->Str);\r
+        //\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (!SkipIt) {\r
+      if (mGlobals.VerboseScan) {\r
+        printf ("Scanning %s\n", ScanFiles->Str);\r
+      }\r
+\r
+      Fptr = fopen (ScanFiles->Str, "r");\r
+      if (Fptr == NULL) {\r
+        Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      LineNum = 0;\r
+      while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+        LineNum++;\r
+        if (Line[MAX_LINE_LEN - 1] != 0) {\r
+          Error (ScanFiles->Str, LineNum, 0, "line length exceeds maximum supported by tool", NULL);\r
+          fclose (Fptr);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Remove the newline from the input line so we can print a warning message\r
+        //\r
+        if (Line[strlen (Line) - 1] == '\n') {\r
+          Line[strlen (Line) - 1] = 0;\r
+        }\r
+        //\r
+        // Terminate the line at // comments\r
+        //\r
+        Cptr = strstr (Line, "//");\r
+        if (Cptr != NULL) {\r
+          *Cptr = 0;\r
+        }\r
+\r
+        Cptr = Line;\r
+        while ((Cptr = strstr (Cptr, STRING_TOKEN)) != NULL) {\r
+          //\r
+          // Found "STRING_TOKEN". Make sure we don't have NUM_STRING_TOKENS or\r
+          // something like that. Then make sure it's followed by\r
+          // an open parenthesis, a string identifier, and then a closing\r
+          // parenthesis.\r
+          //\r
+          if (mGlobals.VerboseScan) {\r
+            printf (" %d: %s", LineNum, Cptr);\r
+          }\r
+\r
+          if (((Cptr == Line) || (!IsValidIdentifierChar (*(Cptr - 1), FALSE))) &&\r
+              (!IsValidIdentifierChar (*(Cptr + sizeof (STRING_TOKEN) - 1), FALSE))\r
+              ) {\r
+            StringTokenPos  = Cptr;\r
+            SavePtr         = Cptr;\r
+            Cptr += strlen (STRING_TOKEN);\r
+            while (*Cptr && isspace (*Cptr) && (*Cptr != '(')) {\r
+              Cptr++;\r
+            }\r
+\r
+            if (*Cptr != '(') {\r
+              Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
+            } else {\r
+              //\r
+              // Skip over the open-parenthesis and find the next non-blank character\r
+              //\r
+              Cptr++;\r
+              while (isspace (*Cptr)) {\r
+                Cptr++;\r
+              }\r
+\r
+              SavePtr = Cptr;\r
+              if ((*Cptr == '_') || isalpha (*Cptr)) {\r
+                while ((*Cptr == '_') || (isalnum (*Cptr))) {\r
+                  Cptr++;\r
+                }\r
+\r
+                TermPtr = Cptr;\r
+                while (*Cptr && isspace (*Cptr)) {\r
+                  Cptr++;\r
+                }\r
+\r
+                if (*Cptr != ')') {\r
+                  Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
+                }\r
+\r
+                if (*TermPtr) {\r
+                  *TermPtr  = 0;\r
+                  Cptr      = TermPtr + 1;\r
+                } else {\r
+                  Cptr = TermPtr;\r
+                }\r
+                //\r
+                // Add the string identifier to the list of used strings\r
+                //\r
+                ParserSetPosition (ScanFiles->Str, LineNum);\r
+                StringDBSetStringReferenced (SavePtr, mGlobals.IgnoreNotFound);\r
+                if (mGlobals.VerboseScan) {\r
+                  printf ("...referenced %s", SavePtr);\r
+                }\r
+              } else {\r
+                Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected valid string identifier name");\r
+              }\r
+            }\r
+          } else {\r
+            //\r
+            // Found it, but it's a substring of something else. Advance our pointer.\r
+            //\r
+            Cptr++;\r
+          }\r
+\r
+          if (mGlobals.VerboseScan) {\r
+            printf ("\n");\r
+          }\r
+        }\r
+      }\r
+\r
+      fclose (Fptr);\r
+    } else {\r
+      //\r
+      // Skipping this file type\r
+      //\r
+      if (mGlobals.VerboseScan) {\r
+        printf ("Skip scanning of %s\n", ScanFiles->Str);\r
+      }\r
+    }\r
+\r
+    ScanFiles = ScanFiles->Next;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Free the global string lists we allocated memory for\r
+//\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  )\r
+{\r
+  TEXT_STRING_LIST  *Temp;\r
+  WCHAR_STRING_LIST *WTemp;\r
+\r
+  //\r
+  // Traverse the include paths, freeing each\r
+  //\r
+  while (mGlobals.IncludePaths != NULL) {\r
+    Temp = mGlobals.IncludePaths->Next;\r
+    free (mGlobals.IncludePaths->Str);\r
+    free (mGlobals.IncludePaths);\r
+    mGlobals.IncludePaths = Temp;\r
+  }\r
+  //\r
+  // If we did a scan, then free up our\r
+  // list of files to scan.\r
+  //\r
+  while (mGlobals.ScanFileName != NULL) {\r
+    Temp = mGlobals.ScanFileName->Next;\r
+    free (mGlobals.ScanFileName->Str);\r
+    free (mGlobals.ScanFileName);\r
+    mGlobals.ScanFileName = Temp;\r
+  }\r
+  //\r
+  // If they gave us a list of filename extensions to\r
+  // skip on scan, then free them up.\r
+  //\r
+  while (mGlobals.SkipExt != NULL) {\r
+    Temp = mGlobals.SkipExt->Next;\r
+    free (mGlobals.SkipExt->Str);\r
+    free (mGlobals.SkipExt);\r
+    mGlobals.SkipExt = Temp;\r
+  }\r
+  //\r
+  // Free up any languages specified\r
+  //\r
+  while (mGlobals.Language != NULL) {\r
+    WTemp = mGlobals.Language->Next;\r
+    free (mGlobals.Language->Str);\r
+    free (mGlobals.Language);\r
+    mGlobals.Language = WTemp;\r
+  }\r
+  //\r
+  // Free up our indirection list\r
+  //\r
+  while (mGlobals.IndirectionList != NULL) {\r
+    mGlobals.LastIndirectionList = mGlobals.IndirectionList->Next;\r
+    free (mGlobals.IndirectionList->Str1);\r
+    free (mGlobals.IndirectionList->Str2);\r
+    free (mGlobals.IndirectionList);\r
+    mGlobals.IndirectionList = mGlobals.LastIndirectionList;\r
+  }\r
+\r
+  while (mGlobals.IndirectionFileName != NULL) {\r
+    mGlobals.LastIndirectionFileName = mGlobals.IndirectionFileName->Next;\r
+    free (mGlobals.IndirectionFileName->Str);\r
+    free (mGlobals.IndirectionFileName);\r
+    mGlobals.IndirectionFileName = mGlobals.LastIndirectionFileName;\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsValidIdentifierChar (\r
+  INT8      Char,\r
+  BOOLEAN   FirstChar\r
+  )\r
+{\r
+  //\r
+  // If it's the first character of an identifier, then\r
+  // it must be one of [A-Za-z_].\r
+  //\r
+  if (FirstChar) {\r
+    if (isalpha (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    //\r
+    // If it's not the first character, then it can\r
+    // be one of [A-Za-z_0-9]\r
+    //\r
+    if (isalnum (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  SourceFile->LineNum       = 1;\r
+  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
+  SourceFile->EndOfFile     = 0;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE *SourceFile,\r
+  WCHAR       WChar,\r
+  BOOLEAN     StopAfterNewline\r
+  )\r
+{\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // Check for the character of interest\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == WChar) {\r
+      return TRUE;\r
+    } else {\r
+      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+        SourceFile->LineNum++;\r
+        if (StopAfterNewline) {\r
+          SourceFile->FileBufferPtr++;\r
+          if (SourceFile->FileBufferPtr[0] == 0) {\r
+            SourceFile->FileBufferPtr++;\r
+          }\r
+\r
+          return FALSE;\r
+        }\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    "",\r
+    PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",\r
+    "  Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",\r
+    "         "PROGRAM_NAME " -scan {scan options} [FileName]",\r
+    "         "PROGRAM_NAME " -dump {dump options}",\r
+    "    Common options include:",\r
+    "      -h or -?         for this help information",\r
+    "      -db Database     required name of output/input database file",\r
+    "      -bn BaseName     for use in the .h and .c output files",\r
+    "                       Default = "DEFAULT_BASE_NAME,\r
+    "      -v               for verbose output",\r
+    "      -vdbw            for verbose output when writing database",\r
+    "      -vdbr            for verbose output when reading database",\r
+    "      -od FileName     to specify an output database file name",\r
+    "    Parse options include:",\r
+    "      -i IncludePath   add IncludePath to list of search paths",\r
+    "      -dep FileName    to specify an output dependency file name",\r
+    "      -newdb           to not read in existing database file",\r
+    "      -uqs             to indicate that unquoted strings are used",\r
+    "      FileNames        name of one or more unicode files to parse",\r
+    "    Scan options include:",\r
+    "      -scan            scan text file(s) for STRING_TOKEN() usage",\r
+    "      -skipext .ext    to skip scan of files with .ext filename extension",\r
+    "      -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
+    "                       found in the database",\r
+    "      FileNames        one or more files to scan",\r
+    "    Dump options include:",\r
+    "      -oc FileName     write string data to FileName",\r
+    "      -oh FileName     write string defines to FileName",\r
+    "      -ou FileName     dump database to unicode file FileName",\r
+    "      -lang Lang       only dump for the language 'Lang'",\r
+    "      -if FileName     to specify an indirection file",\r
+    "      -hpk FileName    to create an HII export pack of the strings",\r
+    "",\r
+    "  The expected process is to parse a unicode string file to create an initial",\r
+    "  database of string identifier names and string definitions. Then text files",\r
+    "  should be scanned for STRING_TOKEN() usages, and the referenced",\r
+    "  strings will be tagged as used in the database. After all files have been",\r
+    "  scanned, then the database should be dumped to create the necessary output",\r
+    "  files.",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
new file mode 100644 (file)
index 0000000..df175c2
--- /dev/null
@@ -0,0 +1,84 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StrGather.h\r
+\r
+Abstract:\r
+\r
+  Common defines and prototypes for StrGather.\r
+  \r
+--*/\r
+\r
+#ifndef _STR_GATHER_H_\r
+#define _STR_GATHER_H_\r
+\r
+#define MALLOC(size)  malloc (size)\r
+#define FREE(ptr)     free (ptr)\r
+\r
+#define PROGRAM_NAME  "StrGather"\r
+\r
+typedef CHAR16  WCHAR;\r
+\r
+#define UNICODE_TO_ASCII(w)   (INT8) ((w) & 0xFF)\r
+#define ASCII_TO_UNICODE(a)   (WCHAR) ((UINT8) (a))\r
+\r
+#define UNICODE_HASH          L'#'\r
+#define UNICODE_BACKSLASH     L'\\'\r
+#define UNICODE_SLASH         L'/'\r
+#define UNICODE_EQUAL_SIGN    L'='\r
+#define UNICODE_PLUS_SIGN     L'+'\r
+\r
+#define UNICODE_FILE_START    0xFEFF\r
+#define UNICODE_CR            0x000D\r
+#define UNICODE_LF            0x000A\r
+#define UNICODE_NULL          0x0000\r
+#define UNICODE_SPACE         L' '\r
+#define UNICODE_SLASH         L'/'\r
+#define UNICODE_DOUBLE_QUOTE  L'"'\r
+#define UNICODE_Z             L'Z'\r
+#define UNICODE_z             L'z'\r
+#define UNICODE_A             L'A'\r
+#define UNICODE_a             L'a'\r
+#define UNICODE_F             L'F'\r
+#define UNICODE_f             L'f'\r
+#define UNICODE_UNDERSCORE    L'_'\r
+#define UNICODE_0             L'0'\r
+#define UNICODE_9             L'9'\r
+#define UNICODE_TAB           L'\t'\r
+#define UNICODE_NBR_STRING    L"\\nbr"\r
+#define UNICODE_BR_STRING     L"\\br"\r
+#define UNICODE_WIDE_STRING   L"\\wide"\r
+#define UNICODE_NARROW_STRING L"\\narrow"\r
+\r
+//\r
+// This is the length of a valid string identifier\r
+//\r
+#define LANGUAGE_IDENTIFIER_NAME_LEN  3\r
+\r
+typedef struct _TEXT_STRING_LIST {\r
+  struct _TEXT_STRING_LIST  *Next;\r
+  UINT8                     *Str;\r
+} TEXT_STRING_LIST;\r
+\r
+typedef struct _WCHAR_STRING_LIST {\r
+  struct _WCHAR_STRING_LIST *Next;\r
+  WCHAR                     *Str;\r
+} WCHAR_STRING_LIST;\r
+\r
+typedef struct _WCHAR_MATCHING_STRING_LIST {\r
+  struct _WCHAR_MATCHING_STRING_LIST  *Next;\r
+  WCHAR                               *Str1;\r
+  WCHAR                               *Str2;\r
+} WCHAR_MATCHING_STRING_LIST;\r
+\r
+#endif // #ifndef _STR_GATHER_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
new file mode 100644 (file)
index 0000000..8fa01e8
--- /dev/null
@@ -0,0 +1,2808 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StringDB.c\r
+\r
+Abstract:\r
+\r
+  String database implementation\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <ctype.h>  // for tolower()\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "StrGather.h"\r
+#include "StringDb.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+typedef CHAR16  WCHAR;\r
+#define STRING_OFFSET RELOFST\r
+\r
+#define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K')\r
+//\r
+// Version supported by this tool\r
+//\r
+#define STRING_DB_VERSION             0x00010000\r
+\r
+#define STRING_DB_MAJOR_VERSION_MASK  0xFFFF0000\r
+#define STRING_DB_MINOR_VERSION_MASK  0x0000FFFF\r
+\r
+#define DEFINE_STR                    L"// #define"\r
+\r
+#define LANGUAGE_CODE_WIDTH           4\r
+//\r
+// This is the header that gets written to the top of the\r
+// output binary database file.\r
+//\r
+typedef struct {\r
+  UINT32  Key;\r
+  UINT32  HeaderSize;\r
+  UINT32  Version;\r
+  UINT32  NumStringIdenfiers;\r
+  UINT32  StringIdentifiersSize;\r
+  UINT32  NumLanguages;\r
+} STRING_DB_HEADER;\r
+\r
+//\r
+// When we write out data to the database, we have a UINT16 identifier, which\r
+// indicates what follows, followed by the data. Here's the structure.\r
+//\r
+typedef struct {\r
+  UINT16  DataType;\r
+  UINT16  Reserved;\r
+} DB_DATA_ITEM_HEADER;\r
+\r
+#define DB_DATA_TYPE_INVALID              0x0000\r
+#define DB_DATA_TYPE_STRING_IDENTIFIER    0x0001\r
+#define DB_DATA_TYPE_LANGUAGE_DEFINITION  0x0002\r
+#define DB_DATA_TYPE_STRING_DEFINITION    0x0003\r
+#define DB_DATA_TYPE_LAST                 DB_DATA_TYPE_STRING_DEFINITION\r
+\r
+//\r
+// We have to keep track of a list of languages, each of which has its own\r
+// list of strings. Define a structure to keep track of all languages and\r
+// their list of strings.\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  UINT32              Size;         // number of bytes in string, including null terminator\r
+  WCHAR               *LanguageName;\r
+  WCHAR               *StringName;  // for example STR_ID_TEXT1\r
+  WCHAR               *Scope;       //\r
+  WCHAR               *Str;         // the actual string\r
+  UINT16              Flags;        // properties of this string (used, undefined)\r
+} STRING_LIST;\r
+\r
+typedef struct _LANGUAGE_LIST {\r
+  struct _LANGUAGE_LIST *Next;\r
+  WCHAR                 LanguageName[4];\r
+  WCHAR                 *PrintableLanguageName;\r
+  STRING_LIST           *String;\r
+  STRING_LIST           *LastString;\r
+} LANGUAGE_LIST;\r
+\r
+//\r
+// We also keep track of all the string identifier names, which we assign unique\r
+// values to. Create a structure to keep track of them all.\r
+//\r
+typedef struct _STRING_IDENTIFIER {\r
+  struct _STRING_IDENTIFIER *Next;\r
+  UINT32                    Index;  // only need 16 bits, but makes it easier with UINT32\r
+  WCHAR                     *StringName;\r
+  UINT16                    Flags;  // if someone referenced it via STRING_TOKEN()\r
+} STRING_IDENTIFIER;\r
+//\r
+// Keep our globals in this structure to be as modular as possible.\r
+//\r
+typedef struct {\r
+  FILE              *StringDBFptr;\r
+  LANGUAGE_LIST     *LanguageList;\r
+  LANGUAGE_LIST     *LastLanguageList;\r
+  LANGUAGE_LIST     *CurrentLanguage;         // keep track of the last language they used\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_IDENTIFIER *LastStringIdentifier;\r
+  UINT8             *StringDBFileName;\r
+  UINT32            NumStringIdentifiers;\r
+  UINT32            NumStringIdentifiersReferenced;\r
+  STRING_IDENTIFIER *CurrentStringIdentifier; // keep track of the last string identifier they added\r
+  WCHAR             *CurrentScope;\r
+} STRING_DB_DATA;\r
+\r
+static STRING_DB_DATA mDBData;\r
+\r
+static const char     *mSourceFileHeader[] = {\r
+  "//",\r
+  "//  DO NOT EDIT -- auto-generated file",\r
+  "//",\r
+  "//  This file is generated by the string gather utility",\r
+  "//",\r
+  NULL\r
+};\r
+\r
+static\r
+STRING_LIST           *\r
+StringDBFindString (\r
+  WCHAR                       *LanguageName,\r
+  WCHAR                       *StringName,\r
+  WCHAR                       *Scope,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  );\r
+\r
+static\r
+STRING_IDENTIFIER     *\r
+StringDBFindStringIdentifierByName (\r
+  WCHAR *Name\r
+  );\r
+\r
+static\r
+STRING_IDENTIFIER     *\r
+StringDBFindStringIdentifierByIndex (\r
+  UINT32    Index\r
+  );\r
+\r
+static\r
+LANGUAGE_LIST         *\r
+StringDBFindLanguageList (\r
+  WCHAR *LanguageName\r
+  );\r
+\r
+static\r
+void\r
+StringDBWriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  );\r
+\r
+static\r
+WCHAR                 *\r
+AsciiToWchar (\r
+  INT8 *Str\r
+  );\r
+\r
+static\r
+WCHAR                 *\r
+DuplicateString (\r
+  WCHAR   *Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteStringIdentifier (\r
+  FILE                *DBFptr,\r
+  UINT16              StringId,\r
+  UINT16              Flags,\r
+  WCHAR               *IdentifierName\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadStringIdentifier (\r
+  FILE                *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteLanguageDefinition (\r
+  FILE            *DBFptr,\r
+  WCHAR           *LanguageName,\r
+  WCHAR           *PrintableLanguageName\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadLanguageDefinition (\r
+  FILE            *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteString (\r
+  FILE            *DBFptr,\r
+  UINT16          Flags,\r
+  WCHAR           *Language,\r
+  WCHAR           *StringName,\r
+  WCHAR           *Scope,\r
+  WCHAR           *Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadString (\r
+  FILE            *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadGenericString (\r
+  FILE      *DBFptr,\r
+  UINT16    *Size,\r
+  WCHAR     **Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteGenericString (\r
+  FILE      *DBFptr,\r
+  WCHAR     *Str\r
+  );\r
+\r
+static\r
+void\r
+StringDBAssignStringIndexes (\r
+  VOID\r
+  );\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Constructor function for the string database handler.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+void\r
+StringDBConstructor (\r
+  VOID\r
+  )\r
+{\r
+  memset ((char *) &mDBData, 0, sizeof (STRING_DB_DATA));\r
+  mDBData.CurrentScope = DuplicateString (L"NULL");\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Destructor function for the string database handler.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+void\r
+StringDBDestructor (\r
+  VOID\r
+  )\r
+{\r
+  LANGUAGE_LIST     *NextLang;\r
+  STRING_LIST       *NextStr;\r
+  STRING_IDENTIFIER *NextIdentifier;\r
+  //\r
+  // Close the database file if it's open\r
+  //\r
+  if (mDBData.StringDBFptr != NULL) {\r
+    fclose (mDBData.StringDBFptr);\r
+    mDBData.StringDBFptr = NULL;\r
+  }\r
+  //\r
+  // If we've allocated any strings/languages, free them up\r
+  //\r
+  while (mDBData.LanguageList != NULL) {\r
+    NextLang = mDBData.LanguageList->Next;\r
+    //\r
+    // Free up all strings for this language\r
+    //\r
+    while (mDBData.LanguageList->String != NULL) {\r
+      NextStr = mDBData.LanguageList->String->Next;\r
+      FREE (mDBData.LanguageList->String->Str);\r
+      FREE (mDBData.LanguageList->String);\r
+      mDBData.LanguageList->String = NextStr;\r
+    }\r
+\r
+    FREE (mDBData.LanguageList->PrintableLanguageName);\r
+    FREE (mDBData.LanguageList);\r
+    mDBData.LanguageList = NextLang;\r
+  }\r
+  //\r
+  // Free up string identifiers\r
+  //\r
+  while (mDBData.StringIdentifier != NULL) {\r
+    NextIdentifier = mDBData.StringIdentifier->Next;\r
+    FREE (mDBData.StringIdentifier->StringName);\r
+    FREE (mDBData.StringIdentifier);\r
+    mDBData.StringIdentifier = NextIdentifier;\r
+  }\r
+  //\r
+  // Free the filename\r
+  //\r
+  if (mDBData.StringDBFileName != NULL) {\r
+    FREE (mDBData.StringDBFileName);\r
+    mDBData.StringDBFileName = NULL;\r
+  }\r
+  //\r
+  // We save a copy of the scope, so free it up if we\r
+  // have one.\r
+  //\r
+  if (mDBData.CurrentScope != NULL) {\r
+    FREE (mDBData.CurrentScope);\r
+    mDBData.CurrentScope = NULL;\r
+  }\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of a database to an output C file.\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+  BaseName        - used for the name of the C array defined\r
+  Languages       - list of languages of interest\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  Languages is a pointer to a linked list of languages specified on\r
+  the command line. Format is "eng" and "spa+cat". For this, print\r
+  the strings for eng. Print the strings for spa too, but if one is\r
+  missing look for a cat string and print if it it exists.\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpCStrings (\r
+  INT8                        *FileName,\r
+  INT8                        *BaseName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  STRING_LIST                 EmptyString;\r
+  UINT32                      Offset;\r
+  UINT32                      StringIndex;\r
+  UINT32                      TempIndex;\r
+  UINT32                      BytesThisLine;\r
+  EFI_HII_STRING_PACK_HEADER  StringPack;\r
+  UINT8                       *Ptr;\r
+  UINT32                      Len;\r
+  WCHAR                       ZeroString[1];\r
+  WCHAR_STRING_LIST           *LOIPtr;\r
+  BOOLEAN                     LanguageOk;\r
+  WCHAR                       *TempStringPtr;\r
+  WCHAR                       *LangName;\r
+  STRING_IDENTIFIER           *StringIdentifier;\r
+\r
+  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output C string file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // Write the standard header to the output file, then the structure\r
+  // definition header.\r
+  //\r
+  StringDBWriteStandardFileHeader (Fptr);\r
+  fprintf (Fptr, "\nunsigned char %s[] = {\n", BaseName);\r
+  //\r
+  // If a given string is not defined, then we'll use this one.\r
+  //\r
+  memset (&EmptyString, 0, sizeof (EmptyString));\r
+  EmptyString.Size  = sizeof (ZeroString);\r
+  EmptyString.Str   = ZeroString;\r
+  //\r
+  // Process each language, then each string for each langage\r
+  //\r
+  ZeroString[0] = 0;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    //\r
+    // If we have a language list, then make sure this language is in that\r
+    // list.\r
+    //\r
+    LanguageOk  = TRUE;\r
+    LangName    = Lang->LanguageName;\r
+    if (LanguagesOfInterest != NULL) {\r
+      LanguageOk = FALSE;\r
+      for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
+        if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
+          LangName    = LOIPtr->Str;\r
+          LanguageOk  = TRUE;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    if (!LanguageOk) {\r
+      continue;\r
+    }\r
+    //\r
+    // Process each string for this language. We have to make 3 passes on the strings:\r
+    //   Pass1: computes sizes and fill in the string pack header\r
+    //   Pass2: write the array of offsets\r
+    //   Pass3: write the strings\r
+    //\r
+    //\r
+    // PASS 1: Fill in and print the HII string pack header\r
+    //\r
+    // Compute the size for this language package and write\r
+    // the header out. Each string package contains:\r
+    //   Header\r
+    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
+    //   String[]  -- the actual strings themselves\r
+    //\r
+    fprintf (\r
+      Fptr,\r
+      "\n//******************************************************************************"\r
+      "\n// Start of string definitions for %S/%S",\r
+      Lang->LanguageName,\r
+      Lang->PrintableLanguageName\r
+      );\r
+    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));\r
+    StringPack.Header.Type        = EFI_HII_STRING;\r
+    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
+    //\r
+    // First string is the language name. If we're printing all languages, then\r
+    // it's just the "spa". If we were given a list of languages to print, then it's\r
+    // the "spacat" string. Compute its offset and fill in\r
+    // the info in the header. Since we know the language name string's length,\r
+    // and the printable language name follows it, use that info to fill in the\r
+    // entry for the printable language name as well.\r
+    //\r
+    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK_HEADER) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
+    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (wcslen (LangName) + 1) * sizeof (WCHAR));\r
+    //\r
+    // Add up the size of all strings so we can fill in our header.\r
+    //\r
+    Len = 0;\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Len += (wcslen (LangName) + 1) * sizeof (WCHAR);\r
+      } else {\r
+        //\r
+        // Find a string with this language.stringname\r
+        //\r
+        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+        if (StringIdentifier == NULL) {\r
+          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        CurrString        = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+          if (NULL == CurrString) {\r
+            //\r
+            // If string for Lang->LanguageName is not found, try to get an English version\r
+            //\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL,\r
+                          LanguagesOfInterest,\r
+                          IndirectionList\r
+                          );\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+          EmptyString.Flags |= StringIdentifier->Flags;\r
+        }\r
+\r
+        Len += CurrString->Size;\r
+      }\r
+    }\r
+    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK_HEADER) \r
+                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
+                                + Len;\r
+    //\r
+    // Write out the header one byte at a time\r
+    //\r
+    Ptr = (UINT8 *) &StringPack;\r
+    for (TempIndex = 0; TempIndex < sizeof (EFI_HII_STRING_PACK_HEADER); TempIndex++, Ptr++) {\r
+      if ((TempIndex & 0x07) == 0) {\r
+        fprintf (Fptr, "\n  ");\r
+      }\r
+\r
+      fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
+    }\r
+\r
+    fprintf (Fptr, "\n  // offset 0x%X\n", sizeof (StringPack));\r
+    //\r
+    // PASS2 : write the offsets\r
+    //\r
+    // Traverse the list of strings again and write the array of offsets. The\r
+    // offset to the first string is the size of the string pack header\r
+    // plus the size of the offsets array. The other strings follow it.\r
+    //\r
+    StringIndex = 0;\r
+    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // Write the offset, followed by a useful comment\r
+      //\r
+      fprintf (Fptr, "  ");\r
+      Ptr = (UINT8 *) &Offset;\r
+      for (TempIndex = 0; TempIndex < sizeof (STRING_OFFSET); TempIndex++) {\r
+        fprintf (Fptr, "0x%02X, ", (UINT32) Ptr[TempIndex]);\r
+      }\r
+      //\r
+      // Find the string name\r
+      //\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      fprintf (Fptr, " // offset to string %S (0x%04X)", StringIdentifier->StringName, StringIndex);\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Offset += (wcslen (LangName) + 1) * sizeof (WCHAR);\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL,\r
+                      NULL\r
+                      );\r
+      } else {\r
+        //\r
+        // Find a matching string\r
+        //\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL,   // scope\r
+                      LanguagesOfInterest,\r
+                      IndirectionList\r
+                      );\r
+\r
+        if (NULL == CurrString) {\r
+          CurrString = StringDBFindString (\r
+                        L"eng",\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+        }\r
+\r
+        EmptyString.LanguageName = Lang->LanguageName;\r
+        if (CurrString == NULL) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = 0;\r
+        }\r
+\r
+        Offset += CurrString->Size;\r
+      }\r
+      //\r
+      // Print useful info about this string\r
+      //\r
+      if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+        fprintf (Fptr, " - not referenced");\r
+      }\r
+\r
+      if (CurrString->Flags & STRING_FLAGS_UNDEFINED) {\r
+        fprintf (Fptr, " - not defined for this language");\r
+      } else if (wcscmp (CurrString->LanguageName, Lang->LanguageName) != 0) {\r
+        fprintf (\r
+          Fptr,\r
+          " - not defined for this language -- using secondary language %S definition",\r
+          CurrString->LanguageName\r
+          );\r
+      }\r
+\r
+      fprintf (Fptr, "\n");\r
+    }\r
+    //\r
+    // For unreferenced string identifiers, print a message that they are not referenced anywhere\r
+    //\r
+    while (StringIndex < mDBData.NumStringIdentifiers) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier != NULL) {\r
+        fprintf (Fptr, "  // %S not referenced\n", StringIdentifier->StringName);\r
+      }\r
+\r
+      StringIndex++;\r
+    }\r
+\r
+    //\r
+    // PASS 3: write the strings themselves.\r
+    // Keep track of how many bytes we write per line because some editors\r
+    // (Visual Studio for instance) can't handle too long of lines.\r
+    //\r
+    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      fprintf (Fptr, "  // string %S offset 0x%08X\n  ", StringIdentifier->StringName, Offset);\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        TempStringPtr = LangName;\r
+      } else {\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        CurrString = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,   // scope\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+          if (NULL == CurrString) {\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL, // scope\r
+                          LanguagesOfInterest,\r
+                          IndirectionList\r
+                          );\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+        }\r
+\r
+        TempStringPtr = CurrString->Str;\r
+      }\r
+\r
+      BytesThisLine = 0;\r
+      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
+        fprintf (\r
+          Fptr,\r
+          "0x%02X, 0x%02X, ",\r
+          (UINT32) TempStringPtr[TempIndex] & 0xFF,\r
+          (UINT32) ((TempStringPtr[TempIndex] >> 8) & 0xFF)\r
+          );\r
+        BytesThisLine += 2;\r
+        Offset += 2;\r
+        //\r
+        // Let's say we only allow 14 per line\r
+        //\r
+        if (BytesThisLine > 14) {\r
+          fprintf (Fptr, "\n  ");\r
+          BytesThisLine = 0;\r
+        }\r
+      }\r
+      //\r
+      // Print NULL WCHAR at the end of this string.\r
+      //\r
+      fprintf (Fptr, "0x00, 0x00,\n");\r
+      Offset += 2;\r
+    }\r
+    //\r
+    // Sanity check the offset. Make sure our running offset is what we put in the\r
+    // string pack header.\r
+    //\r
+    if (StringPack.Header.Length != Offset) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "stringpack size 0x%X does not match final size 0x%X",\r
+        StringPack.Header.Length,\r
+        Offset\r
+        );\r
+    }\r
+  }\r
+  //\r
+  // Print terminator string pack, closing brace and close the file.\r
+  // The size of 0 triggers to the consumer that this is the end.\r
+  //\r
+  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));\r
+  StringPack.Header.Type  = EFI_HII_STRING;\r
+  Ptr                     = (UINT8 *) &StringPack;\r
+  fprintf (Fptr, "\n  // strings terminator pack");\r
+  for (TempIndex = 0; TempIndex < sizeof (StringPack); TempIndex++, Ptr++) {\r
+    if ((TempIndex & 0x0F) == 0) {\r
+      fprintf (Fptr, "\n  ");\r
+    }\r
+\r
+    fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
+  }\r
+\r
+  fprintf (Fptr, "\n};\n");\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the #define string names\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+  BaseName        - used for the protection #ifndef/#endif \r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpStringDefines (\r
+  INT8 *FileName,\r
+  INT8 *BaseName\r
+  )\r
+{\r
+  FILE              *Fptr;\r
+  STRING_IDENTIFIER *Identifier;\r
+  INT8              CopyBaseName[100];\r
+  UINT32            Index;\r
+  const INT8        *StrDefHeader[] = {\r
+    "#ifndef _%s_STRINGS_DEFINE_H_\n",\r
+    "#define _%s_STRINGS_DEFINE_H_\n\n",\r
+    NULL\r
+  };\r
+\r
+  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output string defines file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the base source filename and convert to uppercase.\r
+  //\r
+  if (sizeof (CopyBaseName) <= strlen (BaseName) + 1) {\r
+    Error (NULL, 0, 0, "application error", "StringDBDumpStringDefines() string length insufficient");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (CopyBaseName, BaseName);\r
+  for (Index = 0; CopyBaseName[Index] != 0; Index++) {\r
+    if (islower (CopyBaseName[Index])) {\r
+      CopyBaseName[Index] = (INT8) toupper (CopyBaseName[Index]);\r
+    }\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // Write the standard header to the output file, and then the\r
+  // protective #ifndef.\r
+  //\r
+  StringDBWriteStandardFileHeader (Fptr);\r
+  for (Index = 0; StrDefHeader[Index] != NULL; Index++) {\r
+    fprintf (Fptr, StrDefHeader[Index], CopyBaseName);\r
+  }\r
+  //\r
+  // Print all the #defines for the string identifiers. Print identifiers\r
+  // whose names start with '$' as comments. Add comments for string\r
+  // identifiers not used as well.\r
+  //\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (Identifier->StringName[0] == L'$') {\r
+      fprintf (Fptr, "// ");\r
+    }\r
+\r
+    if (Identifier->Flags & STRING_FLAGS_REFERENCED) {\r
+      fprintf (Fptr, "#define %-40S 0x%04X\n", Identifier->StringName, Identifier->Index);\r
+    } else {\r
+      fprintf (Fptr, "//#define %-40S 0x%04X // not referenced\n", Identifier->StringName, Identifier->Index);\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  fprintf (Fptr, "\n#endif\n");\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a string identifier to the database.\r
+\r
+Arguments:\r
+\r
+  StringName      - name of the string identifier. For example "STR_MY_STRING"\r
+  NewId           - if an ID has been assigned\r
+  Flags           - characteristics for the identifier\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBAddStringIdentifier (\r
+  WCHAR     *StringName,\r
+  UINT16    *NewId,\r
+  UINT16    Flags\r
+  )\r
+{\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STATUS            Status;\r
+  //\r
+  // If it was already used for some other language, then we don't\r
+  // need to add it. But set it to the current string identifier.\r
+  // The referenced bit is sticky.\r
+  //\r
+  Status            = STATUS_SUCCESS;\r
+  StringIdentifier  = StringDBFindStringIdentifierByName (StringName);\r
+  if (StringIdentifier != NULL) {\r
+    if (Flags & STRING_FLAGS_REFERENCED) {\r
+      StringIdentifier->Flags |= STRING_FLAGS_REFERENCED;\r
+    }\r
+\r
+    mDBData.CurrentStringIdentifier = StringIdentifier;\r
+    *NewId                          = (UINT16) StringIdentifier->Index;\r
+    return Status;\r
+  }\r
+\r
+  StringIdentifier = (STRING_IDENTIFIER *) MALLOC (sizeof (STRING_IDENTIFIER));\r
+  if (StringIdentifier == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) StringIdentifier, 0, sizeof (STRING_IDENTIFIER));\r
+  StringIdentifier->StringName = (WCHAR *) malloc ((wcslen (StringName) + 1) * sizeof (WCHAR));\r
+  if (StringIdentifier->StringName == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  wcscpy (StringIdentifier->StringName, StringName);\r
+  if (*NewId != STRING_ID_INVALID) {\r
+    StringIdentifier->Index = *NewId;\r
+    StringIdentifier->Flags |= STRING_FLAGS_INDEX_ASSIGNED;\r
+    if (mDBData.NumStringIdentifiers <= StringIdentifier->Index) {\r
+      mDBData.NumStringIdentifiers = StringIdentifier->Index + 1;\r
+    }\r
+  } else {\r
+    StringIdentifier->Index = mDBData.NumStringIdentifiers++;\r
+  }\r
+\r
+  StringIdentifier->Flags |= Flags;\r
+  //\r
+  // Add it to our list of string identifiers\r
+  //\r
+  if (mDBData.StringIdentifier == NULL) {\r
+    mDBData.StringIdentifier = StringIdentifier;\r
+  } else {\r
+    mDBData.LastStringIdentifier->Next = StringIdentifier;\r
+  }\r
+\r
+  mDBData.LastStringIdentifier    = StringIdentifier;\r
+  mDBData.CurrentStringIdentifier = StringIdentifier;\r
+  *NewId                          = (UINT16) StringIdentifier->Index;\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a new string to the database.\r
+\r
+Arguments:\r
+\r
+  LanguageName    - "eng" or "spa" language name\r
+  StringName      - "STR_MY_TEXT" string name\r
+  Scope           - from the #scope statements in the string file\r
+  Format          - if we should format the string\r
+  Flags           - characteristic flags for the string\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  Several of the fields can be "inherited" from the previous calls to\r
+  our database functions. For example, if scope is NULL here, then\r
+  we'll use the previous setting.\r
+\r
+--*/\r
+STATUS\r
+StringDBAddString (\r
+  WCHAR   *LanguageName,\r
+  WCHAR   *StringName,\r
+  WCHAR   *Scope,\r
+  WCHAR   *String,\r
+  BOOLEAN Format,\r
+  UINT16  Flags\r
+  )\r
+{\r
+  LANGUAGE_LIST     *Lang;\r
+  UINT32            Size;\r
+  STRING_LIST       *Str;\r
+  UINT16            StringIndex;\r
+  WCHAR             TempLangName[4];\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+\r
+  //\r
+  // Check that language name is exactly 3 characters, or emit an error.\r
+  // Truncate at 3 if it's longer, or make it 3 if it's shorter.\r
+  //\r
+  if (LanguageName != NULL) {\r
+    Size = wcslen (LanguageName);\r
+    if (Size != 3) {\r
+      ParserError (0, "invalid length for language name", "%S", LanguageName);\r
+      if (Size > 3) {\r
+        LanguageName[3] = 0;\r
+      } else {\r
+        //\r
+        // Make a local copy of the language name string, and extend to\r
+        // 3 characters since we make assumptions elsewhere in this program\r
+        // on the length.\r
+        //\r
+        wcscpy (TempLangName, LanguageName);\r
+        for (; Size < 3; Size++) {\r
+          TempLangName[Size] = L'?';\r
+        }\r
+\r
+        TempLangName[3] = 0;\r
+        LanguageName    = TempLangName;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // If they specified a language, make sure they've defined it already\r
+  // via a #langdef statement. Otherwise use the current default language.\r
+  //\r
+  if (LanguageName != NULL) {\r
+    Lang = StringDBFindLanguageList (LanguageName);\r
+    if (Lang == NULL) {\r
+      ParserError (0, "language not defined", "%S", LanguageName);\r
+      return STATUS_ERROR;\r
+    } else {\r
+      StringDBSetCurrentLanguage (LanguageName);\r
+    }\r
+  } else {\r
+    Lang = mDBData.CurrentLanguage;\r
+    if (Lang == NULL) {\r
+      //\r
+      // Have to call SetLanguage() first\r
+      //\r
+      ParserError (0, "no language defined", "%S", StringName);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // If they didn't define a string identifier, use the last string identifier\r
+  // added.\r
+  //\r
+  if (StringName == NULL) {\r
+    StringName = mDBData.CurrentStringIdentifier->StringName;\r
+    if (StringName == NULL) {\r
+      ParserError (0, "no string identifier previously specified", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // If scope was not specified, use the default setting\r
+  //\r
+  if (Scope != NULL) {\r
+    Scope = DuplicateString (Scope);\r
+  } else {\r
+    Scope = DuplicateString (mDBData.CurrentScope);\r
+  }\r
+  //\r
+  // printf ("Adding string: %S.%S.%S\n", Lang->LanguageName, StringName, Scope);\r
+  //\r
+  // Check for duplicates for this Language.StringName.Scope. Allow multiple\r
+  // definitions of the language name and printable language name, since the\r
+  // user does not specifically define them.\r
+  //\r
+  if (StringDBFindString (Lang->LanguageName, StringName, Scope, NULL, NULL) != NULL) {\r
+    if ((wcscmp (StringName, LANGUAGE_NAME_STRING_NAME) == 0) &&\r
+        (wcscmp (StringName, PRINTABLE_LANGUAGE_NAME_STRING_NAME) == 0)\r
+        ) {\r
+      ParserError (\r
+        0,\r
+        "string multiply defined",\r
+        "Language.Name.Scope = %S.%S.%S",\r
+        Lang->LanguageName,\r
+        StringName,\r
+        Scope\r
+        );\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+\r
+  StringIndex = STRING_ID_INVALID;\r
+  if (StringDBAddStringIdentifier (StringName, &StringIndex, Flags) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  StringIdentifier = StringDBFindStringIdentifierByName (StringName);\r
+  //\r
+  // Add this string to the end of the strings for this language.\r
+  //\r
+  Str = (STRING_LIST *) malloc (sizeof (STRING_LIST));\r
+  if (Str == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) Str, 0, sizeof (STRING_LIST));\r
+  Size              = (wcslen (String) + 1) * sizeof (WCHAR);\r
+  Str->Flags        = Flags;\r
+  Str->Scope        = Scope;\r
+  Str->StringName   = StringIdentifier->StringName;\r
+  Str->LanguageName = DuplicateString (LanguageName);\r
+  Str->Str          = (WCHAR *) MALLOC (Size);\r
+  if (Str->Str == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If not formatting, just copy the string.\r
+  //\r
+  wcscpy (Str->Str, String);\r
+  if (Format) {\r
+    StringDBFormatString (Str->Str);\r
+  }\r
+  //\r
+  // Size may change after formatting. We set the size to\r
+  // the actual size of the string, including the null for\r
+  // easier processing later.\r
+  //\r
+  Str->Size = (wcslen (Str->Str) + 1) * sizeof (WCHAR);\r
+  if (Lang->String == NULL) {\r
+    Lang->String = Str;\r
+  } else {\r
+    Lang->LastString->Next = Str;\r
+  }\r
+\r
+  Lang->LastString = Str;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a language name, see if a language list for it has been defined\r
+\r
+Arguments:\r
+\r
+  LanguageName    - like "eng"\r
+\r
+Returns:\r
+\r
+  A pointer to the language list\r
+\r
+--*/\r
+static\r
+LANGUAGE_LIST *\r
+StringDBFindLanguageList (\r
+  WCHAR *LanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+\r
+  Lang = mDBData.LanguageList;\r
+  while (Lang != NULL) {\r
+    if (wcscmp (LanguageName, Lang->LanguageName) == 0) {\r
+      break;\r
+    }\r
+\r
+    Lang = Lang->Next;\r
+  }\r
+\r
+  return Lang;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBSetCurrentLanguage (\r
+  WCHAR *LanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+\r
+  Lang = StringDBFindLanguageList (LanguageName);\r
+  if (Lang == NULL) {\r
+    ParserError (0, "language not previously defined", "%S", LanguageName);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  mDBData.CurrentLanguage = Lang;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBAddLanguage (\r
+  WCHAR *LanguageName,\r
+  WCHAR *PrintableLanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+  //\r
+  // Check for redefinitions\r
+  //\r
+  Lang = StringDBFindLanguageList (LanguageName);\r
+  if (Lang != NULL) {\r
+    //\r
+    // Better be the same printable name\r
+    //\r
+    if (wcscmp (PrintableLanguageName, Lang->PrintableLanguageName) != 0) {\r
+      ParserError (\r
+        0,\r
+        "language redefinition",\r
+        "%S:%S != %S:%S",\r
+        Lang->LanguageName,\r
+        Lang->PrintableLanguageName,\r
+        LanguageName,\r
+        PrintableLanguageName\r
+        );\r
+      return STATUS_ERROR;\r
+      //\r
+      //    } else {\r
+      //      ParserWarning (0, "benign language redefinition", "%S", PrintableLanguageName);\r
+      //      return STATUS_WARNING;\r
+      //\r
+    }\r
+  } else {\r
+    //\r
+    // Allocate memory to keep track of this new language\r
+    //\r
+    Lang = (LANGUAGE_LIST *) malloc (sizeof (LANGUAGE_LIST));\r
+    if (Lang == NULL) {\r
+      Error (NULL, 0, 0, NULL, "memory allocation error");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) Lang, 0, sizeof (LANGUAGE_LIST));\r
+    //\r
+    // Save the language name, then allocate memory to save the\r
+    // printable language name\r
+    //\r
+    Lang->LanguageName[3] = 0;\r
+    wcsncpy (Lang->LanguageName, LanguageName, 3);\r
+    Lang->PrintableLanguageName = (WCHAR *) malloc ((wcslen (PrintableLanguageName) + 1) * sizeof (WCHAR));\r
+    if (Lang->PrintableLanguageName == NULL) {\r
+      Error (NULL, 0, 0, NULL, "memory allocation error");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    wcscpy (Lang->PrintableLanguageName, PrintableLanguageName);\r
+\r
+    if (mDBData.LanguageList == NULL) {\r
+      mDBData.LanguageList = Lang;\r
+    } else {\r
+      mDBData.LastLanguageList->Next = Lang;\r
+    }\r
+\r
+    mDBData.LastLanguageList = Lang;\r
+  }\r
+  //\r
+  // Default is to make our active language this new one\r
+  //\r
+  StringDBSetCurrentLanguage (LanguageName);\r
+  //\r
+  // The first two strings for any language are the language name,\r
+  // followed by the printable language name. Add them and set them\r
+  // to referenced so they never get stripped out.\r
+  //\r
+  StringDBAddString (\r
+    LanguageName,\r
+    LANGUAGE_NAME_STRING_NAME,\r
+    NULL,\r
+    LanguageName,\r
+    FALSE,\r
+    STRING_FLAGS_REFERENCED\r
+    );\r
+  StringDBAddString (\r
+    LanguageName,\r
+    PRINTABLE_LANGUAGE_NAME_STRING_NAME,\r
+    NULL,\r
+    PrintableLanguageName,\r
+    FALSE,\r
+    STRING_FLAGS_REFERENCED\r
+    );\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+static\r
+STRING_IDENTIFIER *\r
+StringDBFindStringIdentifierByName (\r
+  WCHAR *StringName\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Identifier;\r
+\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (wcscmp (StringName, Identifier->StringName) == 0) {\r
+      return Identifier;\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+static\r
+STRING_IDENTIFIER *\r
+StringDBFindStringIdentifierByIndex (\r
+  UINT32    StringIndex\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Identifier;\r
+\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (Identifier->Index == StringIndex) {\r
+      return Identifier;\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/*****************************************************************************/\r
+static\r
+void\r
+StringDBWriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  )\r
+{\r
+  UINT32  TempIndex;\r
+  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
+    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
+  }\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given a Unicode string from an input file, reformat the string to replace\r
+  backslash control sequences with the appropriate encoding.\r
+\r
+Arguments:\r
+\r
+  String        - pointer to string to reformat\r
+\r
+Returns:\r
+\r
+  Nothing\r
+\r
+--*/\r
+void\r
+StringDBFormatString (\r
+  WCHAR   *String\r
+  )\r
+{\r
+  WCHAR *From;\r
+  WCHAR *To;\r
+  int   HexNibbles;\r
+  WCHAR HexValue;\r
+  //\r
+  // Go through the string and process any formatting characters\r
+  //\r
+  From  = String;\r
+  To    = String;\r
+  while (*From) {\r
+    if (*From == UNICODE_BACKSLASH) {\r
+      //\r
+      // First look for \wide and replace with the appropriate control character. Note that\r
+      // when you have "define STR L"ABC"", then sizeof(ABC) is 8 because the null char is\r
+      // counted. Make adjustments for this. We advance From below, so subtract 2 each time.\r
+      //\r
+      if (wcsncmp (From, UNICODE_WIDE_STRING, sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        *To = WIDE_CHAR;\r
+        From += sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (wcsncmp (From, UNICODE_NARROW_STRING, sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \narrow\r
+        //\r
+        *To = NARROW_CHAR;\r
+        From += sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (wcsncmp (From, UNICODE_NBR_STRING, sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \nbr\r
+        //\r
+        *To = NON_BREAKING_CHAR;\r
+        From += sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (wcsncmp (From, UNICODE_BR_STRING, sizeof (UNICODE_BR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \br -- pass through untouched\r
+        //\r
+        *To = *From;\r
+      } else {\r
+        //\r
+        // Standard one-character control sequences such as \n, \r, \\, or \x\r
+        //\r
+        From++;\r
+        switch (*From) {\r
+        case ASCII_TO_UNICODE ('n'):\r
+          *To = UNICODE_CR;\r
+          To++;\r
+          *To = UNICODE_LF;\r
+          break;\r
+\r
+        //\r
+        // carriage return\r
+        //\r
+        case ASCII_TO_UNICODE ('r'):\r
+          *To = UNICODE_CR;\r
+          break;\r
+\r
+        //\r
+        // backslash\r
+        //\r
+        case UNICODE_BACKSLASH:\r
+          *To = UNICODE_BACKSLASH;\r
+          break;\r
+\r
+        //\r
+        // Tab\r
+        //\r
+        case ASCII_TO_UNICODE ('t'):\r
+          *To = UNICODE_TAB;\r
+          break;\r
+\r
+        //\r
+        // embedded double-quote\r
+        //\r
+        case UNICODE_DOUBLE_QUOTE:\r
+          *To = UNICODE_DOUBLE_QUOTE;\r
+          break;\r
+\r
+        //\r
+        // Hex Unicode character \x1234. We'll process up to 4 hex characters\r
+        //\r
+        case ASCII_TO_UNICODE ('x'):\r
+          HexValue = 0;\r
+          for (HexNibbles = 0; HexNibbles < 4; HexNibbles++) {\r
+            if ((From[1] >= UNICODE_0) && (From[1] <= UNICODE_9)) {\r
+              HexValue = (HexValue << 4) | (From[1] - UNICODE_0);\r
+            } else if ((From[1] >= UNICODE_a) && (From[1] <= UNICODE_f)) {\r
+              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_a);\r
+            } else if ((From[1] >= UNICODE_A) && (From[1] <= UNICODE_F)) {\r
+              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_A);\r
+            } else {\r
+              break;\r
+            }\r
+\r
+            From++;\r
+          }\r
+\r
+          if (HexNibbles == 0) {\r
+            ParserWarning (\r
+              0,\r
+              "expected at least one valid hex digit with \\x escaped character in string",\r
+              "\\%C",\r
+              *From\r
+              );\r
+          } else {\r
+            *To = HexValue;\r
+          }\r
+          break;\r
+\r
+        default:\r
+          *To = UNICODE_SPACE;\r
+          ParserWarning (0, "invalid escaped character in string", "\\%C", *From);\r
+          break;\r
+        }\r
+      }\r
+    } else {\r
+      *To = *From;\r
+    }\r
+\r
+    From++;\r
+    To++;\r
+  }\r
+\r
+  *To = 0;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBReadDatabase (\r
+  INT8    *DBFileName,\r
+  BOOLEAN IgnoreIfNotExist,\r
+  BOOLEAN Verbose\r
+  )\r
+{\r
+  STRING_DB_HEADER    DbHeader;\r
+  STATUS              Status;\r
+  FILE                *DBFptr;\r
+  DB_DATA_ITEM_HEADER DataItemHeader;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  DBFptr  = NULL;\r
+  //\r
+  //  if (Verbose) {\r
+  //    fprintf (stdout, "Reading database file %s\n", DBFileName);\r
+  //  }\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((DBFptr = fopen (DBFileName, "rb")) == NULL) {\r
+    if (IgnoreIfNotExist) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    Error (NULL, 0, 0, DBFileName, "failed to open input database file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read and verify the database header\r
+  //\r
+  if (fread ((void *) &DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, DBFileName, "failed to read header from database file");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+\r
+  if (DbHeader.Key != STRING_DB_KEY) {\r
+    Error (NULL, 0, 0, DBFileName, "invalid header in database file");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+\r
+  if ((DbHeader.Version & STRING_DB_MAJOR_VERSION_MASK) != (STRING_DB_VERSION & STRING_DB_MAJOR_VERSION_MASK)) {\r
+    Error (NULL, 0, 0, DBFileName, "incompatible database file version -- rebuild clean");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read remaining items\r
+  //\r
+  while (fread (&DataItemHeader, sizeof (DataItemHeader), 1, DBFptr) == 1) {\r
+    switch (DataItemHeader.DataType) {\r
+    case DB_DATA_TYPE_STRING_IDENTIFIER:\r
+      StringDBReadStringIdentifier (DBFptr);\r
+      break;\r
+\r
+    case DB_DATA_TYPE_LANGUAGE_DEFINITION:\r
+      StringDBReadLanguageDefinition (DBFptr);\r
+      break;\r
+\r
+    case DB_DATA_TYPE_STRING_DEFINITION:\r
+      StringDBReadString (DBFptr);\r
+      break;\r
+\r
+    default:\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "database corrupted",\r
+        "invalid data item type 0x%X at offset 0x%X",\r
+        (UINT32) DataItemHeader.DataType,\r
+        ftell (DBFptr) - sizeof (DataItemHeader)\r
+        );\r
+      Status = STATUS_ERROR;\r
+      goto Finish;\r
+    }\r
+  }\r
+\r
+Finish:\r
+  if (DBFptr != NULL) {\r
+    fclose (DBFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Write everything we know to the output database file. Write:\r
+\r
+  Database header\r
+  String identifiers[]\r
+  StringPacks[]\r
+\r
+Arguments:\r
+\r
+  DBFileName    - name of the file to write to\r
+  Verbose       - for debug purposes, print info messages along the way.\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBWriteDatabase (\r
+  INT8    *DBFileName,\r
+  BOOLEAN Verbose\r
+  )\r
+{\r
+  STRING_DB_HEADER  DbHeader;\r
+  UINT32            Counter;\r
+  UINT32            StrLen;\r
+  LANGUAGE_LIST     *Lang;\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_LIST       *StrList;\r
+  FILE              *DBFptr;\r
+\r
+  if (Verbose) {\r
+    fprintf (stdout, "Writing database %s\n", DBFileName);\r
+  }\r
+\r
+  if ((DBFptr = fopen (DBFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, DBFileName, "failed to open output database file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Fill in and write the database header\r
+  //\r
+  memset (&DbHeader, 0, sizeof (STRING_DB_HEADER));\r
+  DbHeader.HeaderSize = sizeof (STRING_DB_HEADER);\r
+  DbHeader.Key        = STRING_DB_KEY;\r
+  DbHeader.Version    = STRING_DB_VERSION;\r
+  //\r
+  // Count the number of languages we have\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    DbHeader.NumLanguages++;\r
+  }\r
+  //\r
+  // Count up how many string identifiers we have, and total up the\r
+  // size of the names plus the size of the flags field we will\r
+  // write out too.\r
+  //\r
+  DbHeader.NumStringIdenfiers = mDBData.NumStringIdentifiers;\r
+  StringIdentifier            = mDBData.StringIdentifier;\r
+  for (Counter = 0; Counter < mDBData.NumStringIdentifiers; Counter++) {\r
+    StrLen = wcslen (StringIdentifier->StringName) + 1;\r
+    DbHeader.StringIdentifiersSize += StrLen * sizeof (WCHAR) + sizeof (StringIdentifier->Flags);\r
+    StringIdentifier = StringIdentifier->Next;\r
+  }\r
+\r
+  //\r
+  // Write the header\r
+  //\r
+  fwrite (&DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr);\r
+  if (Verbose) {\r
+    fprintf (stdout, "  Number of string identifiers  0x%04X\n", DbHeader.NumStringIdenfiers);\r
+    fprintf (stdout, "  Number of languages           %d\n", DbHeader.NumLanguages);\r
+  }\r
+  //\r
+  // Write the string identifiers\r
+  //\r
+  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
+    StringDBWriteStringIdentifier (\r
+      DBFptr,\r
+      (UINT16) StringIdentifier->Index,\r
+      StringIdentifier->Flags,\r
+      StringIdentifier->StringName\r
+      );\r
+  }\r
+  //\r
+  // Now write all the strings for each language\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    StringDBWriteLanguageDefinition (DBFptr, Lang->LanguageName, Lang->PrintableLanguageName);\r
+    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
+      StringDBWriteString (\r
+        DBFptr,\r
+        StrList->Flags,\r
+        Lang->LanguageName,\r
+        StrList->StringName,\r
+        StrList->Scope,\r
+        StrList->Str\r
+        );\r
+    }\r
+  }\r
+\r
+  fclose (DBFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+StringDBSetStringReferenced (\r
+  INT8      *StringIdentifierName,\r
+  BOOLEAN   IgnoreNotFound\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Id;\r
+  WCHAR             *WName;\r
+  STATUS            Status;\r
+  //\r
+  // See if it's already been defined.\r
+  //\r
+  Status  = STATUS_SUCCESS;\r
+  WName   = (WCHAR *) malloc ((strlen (StringIdentifierName) + 1) * sizeof (WCHAR));\r
+#ifdef USE_VC8\r
+  swprintf (WName, (strlen (StringIdentifierName) + 1) * sizeof (WCHAR), L"%S", StringIdentifierName);\r
+#else\r
+  swprintf (WName, L"%S", StringIdentifierName);\r
+#endif\r
+  Id = StringDBFindStringIdentifierByName (WName);\r
+  if (Id != NULL) {\r
+    Id->Flags |= STRING_FLAGS_REFERENCED;\r
+  } else {\r
+    if (IgnoreNotFound == 0) {\r
+      ParserWarning (0, StringIdentifierName, "string identifier not found in database");\r
+      Status = STATUS_WARNING;\r
+    }\r
+  }\r
+\r
+  free (WName);\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of a database to an output unicode file.\r
+\r
+Arguments:\r
+\r
+  DBFileName        - name of the pre-existing database file to read\r
+  OutputFileName    - name of the file to dump the database contents to\r
+  Verbose           - for printing of additional info useful for debugging\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  There's some issue with the unicode printing routines. Therefore to \r
+  write to the output file properly, open it as binary and use fwrite.\r
+  Ideally we could open it with just L"w" and use fwprintf().\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpDatabase (\r
+  INT8                *DBFileName,\r
+  INT8                *OutputFileName,\r
+  BOOLEAN             Verbose\r
+  )\r
+{\r
+  LANGUAGE_LIST     *Lang;\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_LIST       *StrList;\r
+  FILE              *OutFptr;\r
+  WCHAR             WChar;\r
+  WCHAR             *WOutputFileName;\r
+  WCHAR             CrLf[2];\r
+  WCHAR             Line[200];\r
+  WCHAR             *Scope;\r
+  //\r
+  // This function assumes the database has already been read, and\r
+  // we're just dumping our internal data structures to a unicode file.\r
+  //\r
+  if (Verbose) {\r
+    fprintf (stdout, "Dumping database file %s\n", DBFileName);\r
+  }\r
+\r
+  WOutputFileName = AsciiToWchar (OutputFileName);\r
+  OutFptr         = _wfopen (WOutputFileName, L"wb");\r
+  free (WOutputFileName);\r
+  if (OutFptr == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  WChar = UNICODE_FILE_START;\r
+  fwrite (&WChar, sizeof (WCHAR), 1, OutFptr);\r
+  CrLf[1] = UNICODE_LF;\r
+  CrLf[0] = UNICODE_CR;\r
+  //\r
+  // The default control character is '/'. Make it '#' by writing\r
+  // "/=#" to the output file.\r
+  //\r
+#ifdef USE_VC8\r
+  swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"/=#");\r
+#else\r
+  swprintf (Line, L"/=#");\r
+#endif\r
+  fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  //\r
+  // Dump all the string identifiers and their values\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
+    //\r
+    // Write the "#define " string\r
+    //\r
+    if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+#ifdef USE_VC8\r
+      swprintf (\r
+        Line,\r
+        wcslen(Line) * sizeof (WCHAR),\r
+        L"%s %-60.60s 0x%04X",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+#else\r
+      swprintf (\r
+        Line,\r
+        L"%s %-60.60s 0x%04X",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+#endif\r
+    } else {\r
+#ifdef USE_VC8\r
+      swprintf (\r
+        Line,\r
+        wcslen(Line) * sizeof (WCHAR), \r
+        L"%s %-60.60s 0x%04X  // NOT REFERENCED",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+#else\r
+      swprintf (\r
+        Line,\r
+        L"%s %-60.60s 0x%04X  // NOT REFERENCED",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+#endif\r
+    }\r
+\r
+    fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  }\r
+\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  //\r
+  // Now write all the strings for each language.\r
+  //\r
+  WChar = UNICODE_DOUBLE_QUOTE;\r
+  Scope = NULL;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+#ifdef USE_VC8\r
+    swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName);\r
+#else\r
+    swprintf (Line, L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName);\r
+#endif\r
+    fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    //\r
+    // Now the strings (in double-quotes) for this language. Write\r
+    // #string STR_NAME  #language eng "string"\r
+    //\r
+    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
+      //\r
+      // Print the internal flags for debug\r
+      //\r
+#ifdef USE_VC8\r
+      swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"// flags=0x%02X", (UINT32) StrList->Flags);\r
+#else\r
+      swprintf (Line, L"// flags=0x%02X", (UINT32) StrList->Flags);\r
+#endif\r
+      fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+      //\r
+      // Print the scope if changed\r
+      //\r
+      if ((Scope == NULL) || (wcscmp (Scope, StrList->Scope) != 0)) {\r
+#ifdef USE_VC8\r
+        swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"#scope %s", StrList->Scope);\r
+#else\r
+        swprintf (Line, L"#scope %s", StrList->Scope);\r
+#endif\r
+        fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+        fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+        Scope = StrList->Scope;\r
+      }\r
+\r
+#ifdef USE_VC8\r
+      swprintf (\r
+        Line,\r
+        wcslen(Line) * sizeof (WCHAR), \r
+        L"#string %-50.50s #language %s \"",\r
+        StrList->StringName,\r
+        Lang->LanguageName\r
+        );\r
+#else\r
+      swprintf (\r
+        Line,\r
+        L"#string %-50.50s #language %s \"",\r
+        StrList->StringName,\r
+        Lang->LanguageName\r
+        );\r
+#endif\r
+      fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (StrList->Str, StrList->Size - sizeof (WCHAR), 1, OutFptr);\r
+#ifdef USE_VC8\r
+      swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"\"");\r
+#else\r
+      swprintf (Line, L"\"");\r
+#endif\r
+      fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    }\r
+  }\r
+\r
+  fclose (OutFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a primary language, a string identifier number, and a list of\r
+  languages, find a secondary string.\r
+\r
+Arguments:\r
+\r
+  LanguageName      - primary language, like "spa"\r
+  StringId          - string index value\r
+  LanguageList      - linked list of "eng", "spa+cat",...\r
+\r
+Returns:\r
+\r
+  Pointer to a secondary string if found. NULL otherwise.\r
+\r
+Notes:\r
\r
+  Given: LanguageName "spa"   and  LanguageList "spa+cat", match the\r
+  "spa" and extract the "cat" and see if there is a string defined\r
+  for "cat".StringId.\r
+\r
+--*/\r
+static\r
+STATUS\r
+StringDBWriteStringIdentifier (\r
+  FILE                *DBFptr,\r
+  UINT16              StringId,\r
+  UINT16              Flags,\r
+  WCHAR               *IdentifierName\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_STRING_IDENTIFIER;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write StringId to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write StringId flags to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, IdentifierName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadStringIdentifier (\r
+  FILE                *DBFptr\r
+  )\r
+{\r
+  WCHAR   *IdentifierName;\r
+  UINT16  Flags;\r
+  UINT16  StringId;\r
+  UINT16  Size;\r
+\r
+  if (fread (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read StringId from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read StringId flags from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &IdentifierName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  StringDBAddStringIdentifier (IdentifierName, &StringId, Flags);\r
+  //\r
+  // printf ("STRID:  0x%04X %S\n", (UINT32)StringId, IdentifierName);\r
+  //\r
+  FREE (IdentifierName);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteString (\r
+  FILE            *DBFptr,\r
+  UINT16          Flags,\r
+  WCHAR           *Language,\r
+  WCHAR           *StringName,\r
+  WCHAR           *Scope,\r
+  WCHAR           *Str\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_STRING_DEFINITION;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string header to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string flags to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Language) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, StringName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Scope) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Str) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf ("DBWriteString: %S.%S.%S\n", Language, StringName, Scope);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadString (\r
+  FILE            *DBFptr\r
+  )\r
+{\r
+  UINT16  Flags;\r
+  UINT16  Size;\r
+  WCHAR   *Language;\r
+  WCHAR   *StringName;\r
+  WCHAR   *Scope;\r
+  WCHAR   *Str;\r
+\r
+  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read string flags from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Language) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &StringName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Scope) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Str) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If the first or second string (language name and printable language name),\r
+  // then skip them. They're added via language definitions data items in\r
+  // the database.\r
+  //\r
+  if (StringName[0] != L'$') {\r
+    StringDBAddString (Language, StringName, Scope, Str, FALSE, Flags);\r
+  }\r
+  //\r
+  // printf ("DBReadString: %S.%S.%S\n", Language, StringName, Scope);\r
+  //\r
+  FREE (Language);\r
+  FREE (StringName);\r
+  if (Str != NULL) {\r
+    FREE (Str);\r
+  }\r
+\r
+  if (Scope != NULL) {\r
+    FREE (Scope);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteLanguageDefinition (\r
+  FILE            *DBFptr,\r
+  WCHAR           *LanguageName,\r
+  WCHAR           *PrintableLanguageName\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_LANGUAGE_DEFINITION;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, LanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, PrintableLanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadLanguageDefinition (\r
+  FILE            *DBFptr\r
+  )\r
+{\r
+  WCHAR   *LanguageName;\r
+  WCHAR   *PrintableLanguageName;\r
+  UINT16  Size;\r
+  STATUS  Status;\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &LanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &PrintableLanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf("LANG: %S %S\n", LanguageName, PrintableLanguageName);\r
+  //\r
+  Status = StringDBAddLanguage (LanguageName, PrintableLanguageName);\r
+  FREE (LanguageName);\r
+  FREE (PrintableLanguageName);\r
+  return Status;\r
+}\r
+//\r
+// All unicode strings in the database consist of a UINT16 length\r
+// field, followed by the string itself. This routine reads one\r
+// of those and returns the info.\r
+//\r
+static\r
+STATUS\r
+StringDBReadGenericString (\r
+  FILE      *DBFptr,\r
+  UINT16    *Size,\r
+  WCHAR     **Str\r
+  )\r
+{\r
+  UINT16  LSize;\r
+  UINT16  Flags;\r
+  WCHAR   *LStr;\r
+\r
+  if (fread (&LSize, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read a string length field from the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read a string flags field from the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  LStr = MALLOC (LSize);\r
+  if (LStr == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed reading the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (LStr, sizeof (WCHAR), (UINT32) LSize / sizeof (WCHAR), DBFptr) != (UINT32) LSize / sizeof (WCHAR)) {\r
+    Error (NULL, 0, 0, "failed to read string from database", NULL);\r
+    Error (NULL, 0, 0, "database read failure", "offset 0x%X", ftell (DBFptr));\r
+    free (LStr);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf ("DBR: %S\n", LStr);\r
+  //\r
+  // If the flags field indicated we were asked to write a NULL string, then\r
+  // return them a NULL pointer.\r
+  //\r
+  if (Flags & STRING_FLAGS_UNDEFINED) {\r
+    *Size = 0;\r
+    *Str  = NULL;\r
+  } else {\r
+    *Size = LSize;\r
+    *Str  = LStr;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteGenericString (\r
+  FILE      *DBFptr,\r
+  WCHAR     *Str\r
+  )\r
+{\r
+  UINT16  Size;\r
+  UINT16  Flags;\r
+  WCHAR   ZeroString[1];\r
+  //\r
+  // Strings in the database consist of a size UINT16 followed\r
+  // by the string itself.\r
+  //\r
+  if (Str == NULL) {\r
+    ZeroString[0] = 0;\r
+    Str           = ZeroString;\r
+    Size          = sizeof (ZeroString);\r
+    Flags         = STRING_FLAGS_UNDEFINED;\r
+  } else {\r
+    Flags = 0;\r
+    Size  = (UINT16) ((wcslen (Str) + 1) * sizeof (WCHAR));\r
+  }\r
+\r
+  if (fwrite (&Size, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string size to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string flags to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (Str, sizeof (WCHAR), Size / sizeof (WCHAR), DBFptr) != Size / sizeof (WCHAR)) {\r
+    Error (NULL, 0, 0, "failed to write string to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STRING_LIST *\r
+StringDBFindString (\r
+  WCHAR                       *LanguageName,\r
+  WCHAR                       *StringName,\r
+  WCHAR                       *Scope,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+{\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  WCHAR_MATCHING_STRING_LIST  *IndListPtr;\r
+  WCHAR                       TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
+  WCHAR                       *WCharPtr;\r
+\r
+  //\r
+  // If we were given an indirection list, then see if one was specified for this\r
+  // string identifier. That is to say, if the indirection says "STR_ID_MY_FAVORITE MyScope",\r
+  // then if this string name matches one in the list, then do a lookup with the\r
+  // specified scope and return that value.\r
+  //\r
+  if (IndirectionList != NULL) {\r
+    for (IndListPtr = IndirectionList; IndListPtr != NULL; IndListPtr = IndListPtr->Next) {\r
+      if (wcscmp (StringName, IndListPtr->Str1) == 0) {\r
+        CurrString = StringDBFindString (LanguageName, StringName, IndListPtr->Str2, LanguagesOfInterest, NULL);\r
+        if (CurrString != NULL) {\r
+          return CurrString;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // First look for exact match language.stringname\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    if (wcscmp (LanguageName, Lang->LanguageName) == 0) {\r
+      //\r
+      // Found language match. Try to find string name match\r
+      //\r
+      for (CurrString = Lang->String; CurrString != NULL; CurrString = CurrString->Next) {\r
+        if (wcscmp (StringName, CurrString->StringName) == 0) {\r
+          //\r
+          // Found a string name match. See if we're supposed to find\r
+          // a scope match.\r
+          //\r
+          if (Scope != NULL) {\r
+            if (wcscmp (CurrString->Scope, Scope) == 0) {\r
+              return CurrString;\r
+            }\r
+          } else {\r
+            return CurrString;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // If we got here, then we didn't find a match. Look for secondary string\r
+  // matches. That is to say, if we're processing "spa", and they requested\r
+  // "spa+cat", then recursively call with "cat"\r
+  //\r
+  while (LanguagesOfInterest != NULL) {\r
+    //\r
+    // If this is the language we're looking for, then process the\r
+    // languages of interest list for it.\r
+    //\r
+    if (wcsncmp (LanguageName, LanguagesOfInterest->Str, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
+      WCharPtr = LanguagesOfInterest->Str + LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      while (*WCharPtr) {\r
+        //\r
+        // Double-check the length, though it should have been checked on the\r
+        // command line.\r
+        //\r
+        if (wcslen (WCharPtr) < LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+          Error (NULL, 0, 0, "malformed alternate language list", "%S", LanguagesOfInterest->Str);\r
+          return NULL;\r
+        }\r
+\r
+        wcsncpy (TempLangName, WCharPtr, LANGUAGE_IDENTIFIER_NAME_LEN);\r
+        TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN]  = 0;\r
+        CurrString = StringDBFindString (TempLangName, StringName, NULL, NULL, IndirectionList);\r
+        if (CurrString != NULL) {\r
+          return CurrString;\r
+        }\r
+\r
+        WCharPtr += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      }\r
+    }\r
+\r
+    LanguagesOfInterest = LanguagesOfInterest->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATUS\r
+StringDBSetScope (\r
+  WCHAR   *Scope\r
+  )\r
+{\r
+  //\r
+  // Free up existing scope memory.\r
+  //\r
+  if (mDBData.CurrentScope != NULL) {\r
+    FREE (mDBData.CurrentScope);\r
+  }\r
+\r
+  mDBData.CurrentScope = DuplicateString (Scope);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// We typically don't assign index values to string identifiers\r
+// until we're ready to write out files. To reduce the size of\r
+// the output file, re-order the string identifiers to move any\r
+// unreferenced ones to the end. Then we'll walk the list\r
+// again to assign string indexes, keeping track of the last\r
+// one referenced.\r
+//\r
+static\r
+void\r
+StringDBAssignStringIndexes (\r
+  VOID\r
+  )\r
+{\r
+  STRING_IDENTIFIER *StrId;\r
+  STRING_IDENTIFIER *FirstUsed;\r
+  STRING_IDENTIFIER *LastUsed;\r
+  STRING_IDENTIFIER *FirstUnused;\r
+  STRING_IDENTIFIER *LastUnused;\r
+  UINT32            Index;\r
+  UINT32            MaxReferenced;\r
+\r
+  //\r
+  // Create two lists -- used and unused. Then put them together with\r
+  // the unused ones on the end.\r
+  //\r
+  FirstUsed   = NULL;\r
+  LastUsed    = NULL;\r
+  FirstUnused = NULL;\r
+  LastUnused  = NULL;\r
+  StrId       = mDBData.StringIdentifier;\r
+  while (StrId != NULL) {\r
+    if ((StrId->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+      //\r
+      // Put it on the unused list\r
+      //\r
+      if (FirstUnused == NULL) {\r
+        FirstUnused = StrId;\r
+      } else {\r
+        LastUnused->Next = StrId;\r
+      }\r
+\r
+      LastUnused        = StrId;\r
+      StrId             = StrId->Next;\r
+      LastUnused->Next  = NULL;\r
+    } else {\r
+      //\r
+      // Put it on the used list\r
+      //\r
+      if (FirstUsed == NULL) {\r
+        FirstUsed = StrId;\r
+      } else {\r
+        LastUsed->Next = StrId;\r
+      }\r
+\r
+      LastUsed        = StrId;\r
+      StrId           = StrId->Next;\r
+      LastUsed->Next  = NULL;\r
+    }\r
+  }\r
+  //\r
+  // Join the lists\r
+  //\r
+  if (FirstUsed != NULL) {\r
+    mDBData.StringIdentifier  = FirstUsed;\r
+    LastUsed->Next            = FirstUnused;\r
+  } else {\r
+    mDBData.StringIdentifier = FirstUnused;\r
+  }\r
+\r
+  MaxReferenced = 0;\r
+  Index         = 0;\r
+  for (StrId = mDBData.StringIdentifier; StrId != NULL; StrId = StrId->Next) {\r
+    StrId->Index = Index;\r
+    Index++;\r
+    if (StrId->Flags & STRING_FLAGS_REFERENCED) {\r
+      mDBData.NumStringIdentifiersReferenced = Index;\r
+    }\r
+  }\r
+\r
+  mDBData.NumStringIdentifiers = Index;\r
+}\r
+\r
+static\r
+WCHAR *\r
+DuplicateString (\r
+  WCHAR   *Str\r
+  )\r
+{\r
+  WCHAR *NewStr;\r
+  if (Str == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  NewStr = MALLOC ((wcslen (Str) + 1) * sizeof (WCHAR));\r
+  if (NewStr == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return NULL;\r
+  }\r
+\r
+  wcscpy (NewStr, Str);\r
+  return NewStr;\r
+}\r
+\r
+static\r
+WCHAR *\r
+AsciiToWchar (\r
+  INT8 *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *NewStr;\r
+  WCHAR   *Ptr;\r
+\r
+  Len     = strlen (Str) + 1;\r
+  NewStr  = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
+  for (Ptr = NewStr; *Str != 0; Str++, Ptr++) {\r
+    *Ptr = (UINT16) (UINT8) *Str;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return NewStr;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create an HII export string pack for the strings in our database.\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+\r
+--*/\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  INT8                        *FileName\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  STRING_LIST                 EmptyString;\r
+  UINT32                      Offset;\r
+  UINT32                      StringIndex;\r
+  UINT32                      TempIndex;\r
+  EFI_HII_STRING_PACK_HEADER  StringPack;\r
+  UINT32                      Len;\r
+  WCHAR                       ZeroString[1];\r
+  WCHAR                       *TempStringPtr;\r
+  WCHAR                       *LangName;\r
+  STRING_IDENTIFIER           *StringIdentifier;\r
+\r
+  if ((Fptr = fopen (FileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output HII export file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // If a given string is not defined, then we'll use this one.\r
+  //\r
+  memset (&EmptyString, 0, sizeof (EmptyString));\r
+  EmptyString.Size  = sizeof (ZeroString);\r
+  EmptyString.Str   = ZeroString;\r
+  //\r
+  // Process each language, then each string for each langage\r
+  //\r
+  ZeroString[0] = 0;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    //\r
+    // Process each string for this language. We have to make 3 passes on the strings:\r
+    //   Pass1: computes sizes and fill in the string pack header\r
+    //   Pass2: write the array of offsets\r
+    //   Pass3: write the strings\r
+    //\r
+    //\r
+    // PASS 1: Fill in and print the HII string pack header\r
+    //\r
+    // Compute the size for this language package and write\r
+    // the header out. Each string package contains:\r
+    //   Header\r
+    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
+    //   String[]  -- the actual strings themselves\r
+    //\r
+    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));\r
+    StringPack.Header.Type        = EFI_HII_STRING;\r
+    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
+    LangName                      = Lang->LanguageName;\r
+    //\r
+    // First string is the language name. If we're printing all languages, then\r
+    // it's just the "spa". If we were given a list of languages to print, then it's\r
+    // the "spacat" string. Compute its offset and fill in\r
+    // the info in the header. Since we know the language name string's length,\r
+    // and the printable language name follows it, use that info to fill in the\r
+    // entry for the printable language name as well.\r
+    //\r
+    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK_HEADER) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
+    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (wcslen (LangName) + 1) * sizeof (WCHAR));\r
+    //\r
+    // Add up the size of all strings so we can fill in our header.\r
+    //\r
+    Len = 0;\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Len += (wcslen (LangName) + 1) * sizeof (WCHAR);\r
+      } else {\r
+        //\r
+        // Find a string with this language.stringname\r
+        //\r
+        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+        if (StringIdentifier == NULL) {\r
+          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        CurrString        = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+          if (NULL == CurrString) {\r
+            //\r
+            // If string for Lang->LanguageName is not found, try to get an English version\r
+            //\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL,\r
+                          NULL, // LanguagesOfInterest,\r
+                          NULL\r
+                          );\r
+            //\r
+            // IndirectionList);\r
+            //\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+          EmptyString.Flags |= StringIdentifier->Flags;\r
+        }\r
+\r
+        Len += CurrString->Size;\r
+      }\r
+    }\r
+    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK_HEADER) \r
+                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
+                                + Len;\r
+    //\r
+    // Write out the string pack header\r
+    //\r
+    fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
+    //\r
+    // PASS2 : write the offsets\r
+    //\r
+    // Traverse the list of strings again and write the array of offsets. The\r
+    // offset to the first string is the size of the string pack header\r
+    // plus the size of the offsets array. The other strings follow it.\r
+    //\r
+    StringIndex = 0;\r
+    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // Write the offset\r
+      //\r
+      fwrite (&Offset, sizeof (STRING_OFFSET), 1, Fptr);\r
+      //\r
+      // Find the string name\r
+      //\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Offset += (wcslen (LangName) + 1) * sizeof (WCHAR);\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL,\r
+                      NULL\r
+                      );\r
+      } else {\r
+        //\r
+        // Find a matching string\r
+        //\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL, // LanguagesOfInterest,\r
+                      NULL\r
+                      );\r
+        //\r
+        // IndirectionList);\r
+        //\r
+        if (NULL == CurrString) {\r
+          CurrString = StringDBFindString (\r
+                        L"eng",\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+        }\r
+\r
+        EmptyString.LanguageName = Lang->LanguageName;\r
+        if (CurrString == NULL) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = 0;\r
+        }\r
+\r
+        Offset += CurrString->Size;\r
+      }\r
+    }\r
+\r
+    //\r
+    // PASS 3: write the strings themselves.\r
+    //\r
+    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        TempStringPtr = LangName;\r
+      } else {\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        CurrString = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+          if (NULL == CurrString) {\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL, // scope\r
+                          NULL, // LanguagesOfInterest,\r
+                          NULL\r
+                          );\r
+            //\r
+            // IndirectionList);\r
+            //\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+        }\r
+\r
+        TempStringPtr = CurrString->Str;\r
+      }\r
+\r
+      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
+        fwrite (&TempStringPtr[TempIndex], sizeof (CHAR16), 1, Fptr);\r
+        Offset += 2;\r
+      }\r
+      //\r
+      // Print NULL WCHAR at the end of this string.\r
+      //\r
+      TempIndex = 0;\r
+      fwrite (&TempIndex, sizeof (CHAR16), 1, Fptr);\r
+      Offset += 2;\r
+    }\r
+    //\r
+    // Sanity check the offset. Make sure our running offset is what we put in the\r
+    // string pack header.\r
+    //\r
+    if (StringPack.Header.Length != Offset) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "stringpack size 0x%X does not match final size 0x%X",\r
+        StringPack.Header.Length,\r
+        Offset\r
+        );\r
+    }\r
+  }\r
+  //\r
+  // Print terminator string pack, closing brace and close the file.\r
+  // The size of 0 triggers to the consumer that this is the end.\r
+  //\r
+  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));\r
+  StringPack.Header.Type = EFI_HII_STRING;\r
+  fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
new file mode 100644 (file)
index 0000000..4dc05a3
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StringDB.h\r
+\r
+Abstract:\r
+\r
+  Common defines and prototypes for string database management\r
+  \r
+--*/\r
+\r
+#ifndef _STRING_DB_H_\r
+#define _STRING_DB_H_\r
+\r
+#define LANGUAGE_NAME_STRING_NAME           L"$LANGUAGE_NAME"\r
+#define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME"\r
+\r
+void\r
+StringDBConstructor (\r
+  void\r
+  )\r
+;\r
+void\r
+StringDBDestructor (\r
+  void\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBAddString (\r
+  WCHAR   *LanguageName,\r
+  WCHAR   *StringIdentifier,\r
+  WCHAR   *Scope,\r
+  WCHAR   *String,\r
+  BOOLEAN Format,\r
+  UINT16  Flags\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetScope (\r
+  WCHAR   *Scope\r
+  )\r
+;\r
+\r
+#define STRING_FLAGS_REFERENCED           0x0001  // if referenced somewhere\r
+#define STRING_FLAGS_UNDEFINED            0x0002  // if we added it for padding purposes\r
+#define STRING_FLAGS_INDEX_ASSIGNED       0x0004  // so don't change the index value\r
+#define STRING_ID_INVALID                 0xFFFF\r
+#define STRING_ID_LANGUAGE_NAME           0x0000\r
+#define STRING_ID_PRINTABLE_LANGUAGE_NAME 0x0001\r
+\r
+STATUS\r
+StringDBAddStringIdentifier (\r
+  WCHAR     *StringIdentifier,\r
+  UINT16    *NewId,\r
+  UINT16    Flags\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBReadDatabase (\r
+  INT8    *DBFileName,\r
+  BOOLEAN IgnoreIfNotExist,\r
+  BOOLEAN Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBWriteDatabase (\r
+  INT8    *DBFileName,\r
+  BOOLEAN Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpDatabase (\r
+  INT8                *DBFileName,\r
+  INT8                *OutputFileName,\r
+  BOOLEAN             Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBAddLanguage (\r
+  WCHAR *LanguageName,\r
+  WCHAR *PrintableLanguageName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpCStrings (\r
+  INT8                        *FileName,\r
+  INT8                        *BaseName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpStringDefines (\r
+  INT8                *FileName,\r
+  INT8                *BaseName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetCurrentLanguage (\r
+  WCHAR *LanguageName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetStringReferenced (\r
+  INT8      *StringIdentifierName,\r
+  BOOLEAN   IgnoreNotFound\r
+  )\r
+;\r
+\r
+void\r
+StringDBFormatString (\r
+  WCHAR   *String\r
+  )\r
+;\r
+\r
+#endif // #ifndef _STRING_DB_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c
new file mode 100644 (file)
index 0000000..32f1c33
--- /dev/null
@@ -0,0 +1,121 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VcCheck.c\r
+\r
+Abstract:\r
+\r
+  We have found problems with the Visual C++ SP4 and the /O1 flag.\r
+  If this tests ask a question you have the wrong version of Visual C++\r
+  on your system\r
+\r
+  This test assumes the tools are being compiled with the same complier\r
+  as the Tiano code. \r
+\r
+  Please see $(EFI_SOURCE)\EFI2.0 Developer's Manual.doc to get the\r
+  correct version of Visual C++\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+\r
+_int16  gGloba16;\r
+\r
+int\r
+CheckLostCode (\r
+  int Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This routine is used to test for compiler isseus with /O1.\r
+  If the /O1 compiler option, and C2.dll is got from Visual C++ SP5\r
+  (version: 6.00.8168.0), the assember codes after default branch will be\r
+  losted. (Execute "cl Visual Ccheck.c /O1 /FAsc" to get detail information)\r
+\r
+Arguments:\r
+  Value - Test case\r
+\r
+Returns: \r
+  Test to see if comiler error is present.\r
+\r
+--*/\r
+{\r
+  switch (Value) {\r
+  case 0:\r
+    break;\r
+\r
+  default:\r
+    _asm\r
+    {\r
+      mov bx, 1\r
+      mov gGloba16, bx\r
+    }\r
+\r
+    return 1;\r
+  }\r
+\r
+  _asm\r
+  {\r
+    mov bx, 0\r
+    mov gGloba16, bx\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+main (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This utility is checking for a known Visual C++ compiler issues. To remove this \r
+  question from the build follow the steps in the developers manual.\r
+\r
+Arguments:\r
+  NONE\r
+\r
+Returns: \r
+  0 - Compiler version is O.K.\r
+  1 - Compiler version is Bad\r
+\r
+--*/\r
+{\r
+  int   result;\r
+  char  select;\r
+\r
+  gGloba16  = 0xFF;\r
+  result    = 0;\r
+\r
+  CheckLostCode (0);\r
+  result += (gGloba16 == 0) ? 0 : 1;\r
+\r
+  CheckLostCode (1);\r
+  result += (gGloba16 == 1) ? 0 : 1;\r
+\r
+  if (result != 0) {\r
+    printf ("Warning: C2.dll is incorrect.\n Please see $(EFI_SOURCE)\\EFI2.0 Developer's Manual.doc for corrective action.\n");\r
+    printf ("Would you want to continue?(Y/N)");\r
+\r
+    scanf ("%c", &select);\r
+    if ((select == 'Y') || (select == 'y')) {\r
+      return 0;\r
+    } else {\r
+      return 1;\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile
new file mode 100644 (file)
index 0000000..d0a680c
--- /dev/null
@@ -0,0 +1,92 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:  makefile\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to build the EFI utility.\r
+#   \r
+#--*/\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Define some macros we use here. Should get rid of them someday and \r
+# get rid of the extra level of indirection.\r
+#\r
+COMMON_SOURCE      = $(EDK_TOOLS_COMMON)\r
+\r
+#\r
+# Common information\r
+#\r
+\r
+INC=$(INC)\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME=VcCheck\r
+\r
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+\r
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\VcCheck.c"\r
+TARGET_EXE_INCLUDE =\r
+OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Replace /Od with "" to fix the Command line warning D4025\r
+#\r
+C_FLAGS = $(C_FLAGS:/Od=) /O1\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj\r
+\r
+#\r
+# Add Binary Build description for this tools.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
new file mode 100644 (file)
index 0000000..d686211
--- /dev/null
@@ -0,0 +1,178 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiVfr.h\r
+\r
+Abstract:\r
+\r
+  Defines and prototypes for the EFI internal forms representation\r
+  setup protocol and drivers\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_VFR_H_\r
+#define _EFI_VFR_H_\r
+\r
+#include "Tiano.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+#include <string.h>\r
+\r
+//\r
+// This number should be incremented with each change to the VFR compiler.\r
+// We write the version to the output list file for debug purposes.\r
+//\r
+#define VFR_COMPILER_VERSION  "1.88"\r
+\r
+//\r
+// Maximum file path for filenames\r
+//\r
+#define MAX_PATH        255\r
+#define MAX_QUEUE_COUNT 255\r
+#define MAX_LINE_LEN    1024\r
+#define PROGRAM_NAME    "VfrCompile"\r
+\r
+//\r
+// We parse C-style structure definitions which can then be referenced\r
+// in VFR statements.\r
+// We need to define an internal structure that can be used to\r
+// track the fields in a structure definition, and another structure\r
+// to keep track of the structure name and subfields.\r
+//\r
+typedef struct _STRUCT_FIELD_DEFINITION {\r
+  struct _STRUCT_FIELD_DEFINITION *Next;\r
+  int                             DataSize;\r
+  int                             Offset;     // from the start of the structure\r
+  int                             ArrayLength;\r
+  char                            IsArray;\r
+  char                            *Name;\r
+} STRUCT_FIELD_DEFINITION;\r
+\r
+typedef struct _STRUCT_DEFINITION {\r
+  struct _STRUCT_DEFINITION *Next;\r
+  int                       Size;\r
+  int                       LineNum;          // line number where the structure was defined\r
+  int                       IsNonNV;          // if this is the non-NV data structure definition\r
+  int                       Referenced;       // if it's referenced anywhere in the VFR\r
+  int                       VarStoreIdValid;  // found a 'varstore' statement for it in the VFR\r
+  unsigned short            VarStoreId;       // key from a varstore IFR statement\r
+  int                       VarStoreLineNum;  // line number where VARSTORE was defined\r
+  char                      *Name;\r
+  STRUCT_FIELD_DEFINITION   *Field;\r
+  STRUCT_FIELD_DEFINITION   *LastField;\r
+} STRUCT_DEFINITION;\r
+\r
+//\r
+// For the IdEqValList variable list of UINT16's, keep track of them using\r
+// a linked list until we know how many there are.\r
+// We also use a linked list of these to keep track of labels used in\r
+// the VFR script so we can catch duplicates.\r
+// We'll also use it to keep track of defined varstore id's so we can\r
+// detect duplicate definitions.\r
+//\r
+typedef struct _UINT16_LIST {\r
+  struct _UINT16_LIST *Next;\r
+  UINT16              Value;\r
+  UINT32              LineNum;\r
+} UINT16_LIST;\r
+\r
+typedef struct _GOTO_REFERENCE {\r
+  struct _GOTO_REFERENCE  *Next;\r
+  UINT32                  RefLineNum; // line number of source file where referenced\r
+  UINT16                  Value;\r
+} GOTO_REFERENCE;\r
+\r
+typedef struct _FORM_ID_VALUE {\r
+  struct _FORM_ID_VALUE *Next;\r
+  UINT32                LineNum;\r
+  UINT16                Value;\r
+} FORM_ID_VALUE;\r
+\r
+//\r
+// We keep track in the parser of all "#line 4 "x.y"" strings so we\r
+// can cross-reference the line numbers in the preprocessor output .i file\r
+// to the original input files.\r
+//\r
+typedef struct _PARSER_LINE_DEFINITION {\r
+  struct _PARSER_LINE_DEFINITION  *Next;\r
+  UINT32                          HashLineNum;  // from the #line stmt\r
+  UINT32                          TokenLineNum; // line number in the .i file\r
+  INT8                            *FileName;    // from the #line stmt\r
+} PARSER_LINE_DEFINITION;\r
+\r
+extern PARSER_LINE_DEFINITION *gLineDefinition;\r
+extern PARSER_LINE_DEFINITION *gLastLineDefinition;\r
+\r
+extern\r
+char                          *\r
+ConvertLineNumber (\r
+  UINT32 *LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given the line number in the preprocessor-output file, use the line number\r
+  information we've saved to determine the source file name and line number\r
+  where the code originally came from. This is required for error reporting.\r
+\r
+Arguments:\r
+  LineNum - the line number in the preprocessor-output file.\r
+\r
+Returns:\r
+  Returns a pointer to the source file name. Also returns the line number \r
+  in the provided LineNum argument\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _IFR_BYTE {\r
+  struct _IFR_BYTE  *Next;\r
+  UINT32            LineNum;\r
+  UINT8             OpcodeByte;\r
+  UINT8             KeyByte;\r
+} IFR_BYTE;\r
+\r
+typedef struct {\r
+  INT8  VfrFileName[MAX_PATH];\r
+  INT8  VfrListFileName[MAX_PATH];\r
+  INT8  CreateListFile;\r
+  INT8  CreateIfrBinFile;\r
+  INT8  IfrOutputFileName[MAX_PATH];\r
+  INT8  OutputDirectory[MAX_PATH];\r
+  INT8  PreprocessorOutputFileName[MAX_PATH];\r
+  INT8  VfrBaseFileName[MAX_PATH];  // name of input VFR file with no path or extension\r
+  INT8  *IncludePaths;\r
+  INT8  *CPreprocessorOptions;\r
+} OPTIONS;\r
+\r
+extern OPTIONS  gOptions;\r
+\r
+VOID\r
+WriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to emit a standard header to an\r
+  output text file.\r
+  \r
+Arguments:\r
+  OutFptr - file to write the header to\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+#endif // #ifndef _EFI_VFR_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
new file mode 100644 (file)
index 0000000..cba6fa6
--- /dev/null
@@ -0,0 +1,3463 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrCompile.g\r
+\r
+Abstract:\r
+\r
+  PCCTS parser and lexer definitions for the EFI VFR forms compiler\r
+  \r
+--*/  \r
+\r
+#header<<\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiVfr.h"\r
+#include "VfrServices.h"\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+#include <ctype.h>\r
+#include <direct.h>\r
+#include <process.h> // for spawn functions\r
+\r
+>>\r
+\r
+<<\r
+\r
+//\r
+// Base info for DLG-generated scanner\r
+//\r
+#include "DLexerBase.h"    \r
+\r
+//\r
+// Include the scanner file generated by DLG\r
+//\r
+#include "DLGLexer.h"    \r
+\r
+class DLGLexerVfr : public DLGLexer\r
+{\r
+public:\r
+  DLGLexerVfr (DLGFileInput *F) : DLGLexer (F) {};\r
+  INT32 errstd (char *Text) \r
+  { \r
+    printf ("unrecognized input '%s'\n", Text); \r
+  }\r
+};\r
+\r
+//\r
+// Base token definitions for ANTLR\r
+//\r
+#include "AToken.h"\r
+\r
+//\r
+// This is how we invoke the C preprocessor on the VFR source file\r
+// to resolve #defines, #includes, etc. To make C source files\r
+// shareable between VFR and drivers, define VFRCOMPILE so that\r
+// #ifdefs can be used in shared .h files.\r
+//\r
+#define PREPROCESSOR_COMMAND        "cl.exe "\r
+#define PREPROCESSOR_OPTIONS        "/nologo /E /TC /DVFRCOMPILE "\r
+\r
+typedef ANTLRCommonToken ANTLRToken;\r
+\r
+//\r
+// Specify the filename extensions for the files we generate.\r
+//\r
+#define VFR_BINARY_FILENAME_EXTENSION       ".c"\r
+#define VFR_LIST_FILENAME_EXTENSION         ".lst"\r
+#define VFR_PREPROCESS_FILENAME_EXTENSION   ".i"\r
+\r
+static \r
+VOID \r
+Usage ();\r
+\r
+static \r
+STATUS \r
+ProcessArgs (\r
+  int         Argc, \r
+  char        *Argv[]\r
+  );\r
+\r
+static \r
+VOID \r
+Cleanup ();\r
+\r
+//\r
+// Globals\r
+//\r
+OPTIONS gOptions;\r
+\r
+int \r
+main (\r
+  int   argc, \r
+  char  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Application entry point function. Parse command-line arguments, \r
+  invoke the parser, clean up, and return.\r
+\r
+Arguments:\r
+  argc - standard argc passed to main() per C conventions\r
+  argv - standard argv passed to main() per C conventions\r
+\r
+Returns:\r
+  STATUS_SUCCESS - program executed with no errors or warnings\r
+  STATUS_WARNING - program executed with warnings\r
+  STATUS_ERROR   - non-recoverable errors encountered while processing\r
+\r
+--*/\r
+{\r
+  FILE      *VfrFptr;\r
+  char      *Cmd;\r
+  char      *Cptr;\r
+  int       Len;\r
+  STATUS    Status;\r
+    \r
+  //\r
+  // Set our program name for the error printing routines.\r
+  // Then set printing limits.\r
+  //\r
+  SetUtilityName (PROGRAM_NAME);\r
+  SetPrintLimits (20, 20, 30);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  if (ProcessArgs (argc, argv) != STATUS_SUCCESS) {\r
+    Usage ();\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  VfrFptr = NULL;\r
+  //\r
+  // Verify the VFR script file exists\r
+  //\r
+  if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now close the file and make a system call to run the preprocessor\r
+  // on it.\r
+  //\r
+  fclose (VfrFptr);\r
+  Len = strlen (PREPROCESSOR_OPTIONS) + strlen (gOptions.VfrFileName) + 10 +\r
+        strlen (PREPROCESSOR_COMMAND) + strlen (gOptions.PreprocessorOutputFileName);\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    Len += strlen (gOptions.CPreprocessorOptions) + 1;\r
+  }\r
+  if (gOptions.IncludePaths != NULL) {\r
+    Len += strlen (gOptions.IncludePaths) + 1;\r
+  }\r
+  Cmd = (char *)malloc (Len);\r
+  if (Cmd == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }  \r
+  strcpy (Cmd, PREPROCESSOR_COMMAND PREPROCESSOR_OPTIONS);\r
+  if (gOptions.IncludePaths != NULL) {\r
+    strcat (Cmd, gOptions.IncludePaths);\r
+    strcat (Cmd, " ");\r
+  }\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    strcat (Cmd, gOptions.CPreprocessorOptions);\r
+    strcat (Cmd, " ");\r
+  }\r
+  strcat (Cmd, gOptions.VfrFileName);\r
+  strcat (Cmd, " > ");\r
+  strcat (Cmd, gOptions.PreprocessorOutputFileName);\r
+  Status = system (Cmd);\r
+  if (Status != 0) {\r
+    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");\r
+    printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  free (Cmd);\r
+  //\r
+  // Open the preprocessor output file\r
+  //\r
+  if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file", \r
+      gOptions.PreprocessorOutputFileName);\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Define input VFR file\r
+  //\r
+  DLGFileInput InputFile (VfrFptr);\r
+  //\r
+  // Define an instance of the scanner    \r
+  //\r
+  DLGLexerVfr Scanner (&InputFile);\r
+  //\r
+  // Define token buffer between scanner and parser\r
+  //\r
+  ANTLRTokenBuffer Pipe (&Scanner);    \r
+  //\r
+  // Create a token to use as a model\r
+  //\r
+  ANTLRToken Tok;     \r
+  //\r
+  // Tell the scanner what type the token is\r
+  //\r
+  Scanner.setToken (&Tok);    \r
+  //\r
+  // Create an instance of our parser\r
+  //\r
+  EfiVfrParser Parser (&Pipe);    \r
+  //\r
+  // Initialize the parser    \r
+  //\r
+  Parser.init ();\r
+  Status = GetUtilityStatus ();\r
+  if (Status != STATUS_SUCCESS) {\r
+    Cleanup();\r
+    return Status;\r
+  }  \r
+  //\r
+  // Start the first rule    \r
+  //\r
+  Parser.program ();\r
+  //\r
+  // Close the input script file\r
+  //\r
+  fclose (VfrFptr);\r
+  Parser.WriteIfrBytes ();\r
+  //\r
+  // Call cleanup, which does some extra checking of the script\r
+  //\r
+  Parser.Cleanup ();\r
+  Cleanup();\r
+  //\r
+  // If we had an error somewhere, delete our output files so that\r
+  // a subsequent build will rebuild them.\r
+  //\r
+  Status = GetUtilityStatus ();\r
+  if (Status == STATUS_ERROR) {\r
+    remove (gOptions.IfrOutputFileName);\r
+  }\r
+  return Status;\r
+}\r
+static\r
+VOID\r
+Cleanup ()\r
+/*++\r
+\r
+Routine Description:\r
+  Free up memory allocated during parsing.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Free up our string we allocated to track the include paths\r
+  //\r
+  if (gOptions.IncludePaths != NULL) {\r
+    free (gOptions.IncludePaths);\r
+    gOptions.IncludePaths = NULL;\r
+  }\r
+  //\r
+  // Free up our string we allocated to track preprocessor options\r
+  //\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    free (gOptions.CPreprocessorOptions);\r
+    gOptions.CPreprocessorOptions = NULL;\r
+  }\r
+}  \r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int         Argc, \r
+  char        *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process the command-line arguments.\r
+\r
+Arguments:\r
+  Argc - standard argc passed to main()\r
+  Argv - standard argv passed to main()\r
+\r
+Returns:\r
+  STATUS_SUCCESS - program should continue (all args ok)\r
+\r
+--*/\r
+{\r
+  char    *IncludePaths;\r
+  char    *CPreprocessorOptions;\r
+  int     Len;  \r
+  char    CopyStr[MAX_PATH];\r
+  char    *Cptr;\r
+\r
+  //\r
+  // Put options in known state.\r
+  //\r
+  memset ((char *)&gOptions, 0, sizeof (OPTIONS));\r
+  //\r
+  // Go through all the arguments that start with '-'\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    //\r
+    // -? or -h help option -- return an error for printing usage\r
+    //\r
+    if ((_stricmp (Argv[0], "-?") == 0) || (_stricmp (Argv[0], "-h") == 0)) {\r
+      return STATUS_ERROR;\r
+      break;\r
+    //\r
+    // -l to create a listing output file\r
+    //\r
+    } else if (_stricmp (Argv[0], "-l") == 0) {\r
+      gOptions.CreateListFile = 1;\r
+    //\r
+    // -I include_path option for finding include files. We'll pass this\r
+    // to the preprocessor. Turn them all into a single include string.\r
+    //\r
+    } else if (_stricmp (Argv[0], "-i") == 0) {\r
+      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      Len = strlen (" -I ");\r
+      Len += strlen (Argv[0]) + 2;\r
+      if (gOptions.IncludePaths != NULL) {\r
+        Len += strlen (gOptions.IncludePaths);\r
+      }\r
+      IncludePaths = (INT8 *)malloc (Len);\r
+      if (IncludePaths == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+      IncludePaths[0] = 0;\r
+      if (gOptions.IncludePaths != NULL) {\r
+        strcpy (IncludePaths, gOptions.IncludePaths);\r
+        free (gOptions.IncludePaths);\r
+      }\r
+      strcat (IncludePaths, " -I ");\r
+      strcat (IncludePaths, Argv[0]);\r
+      gOptions.IncludePaths = IncludePaths;\r
+    //\r
+    // -od OutputDirectory to define a common directory for output files\r
+    //\r
+    } else if (_stricmp (Argv[0], "-od") == 0) {\r
+      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      strcpy (gOptions.OutputDirectory, Argv[0]);\r
+    } else if (_stricmp (Argv[0], "-ibin") == 0) {\r
+      gOptions.CreateIfrBinFile = 1;\r
+    } else if (_stricmp (Argv[0], "-nostrings") == 0) {\r
+      // deprecated option\r
+    //\r
+    // -ppflag C-preprocessor-flag option for passing options to the C preprocessor.\r
+    // Turn them all into a single string.\r
+    //\r
+    } else if (_stricmp (Argv[0], "-ppflag") == 0) {\r
+      if (Argc < 2) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      Len = strlen (Argv[0]) + 2;\r
+      if (gOptions.CPreprocessorOptions != NULL) {\r
+        Len += strlen (gOptions.CPreprocessorOptions);\r
+      }\r
+      CPreprocessorOptions = (INT8 *)malloc (Len);\r
+      if (CPreprocessorOptions == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+      CPreprocessorOptions[0] = 0;\r
+      if (gOptions.CPreprocessorOptions != NULL) {\r
+        strcpy (CPreprocessorOptions, gOptions.CPreprocessorOptions);\r
+        free (gOptions.CPreprocessorOptions);\r
+      }\r
+      strcat (CPreprocessorOptions, " ");\r
+      strcat (CPreprocessorOptions, Argv[0]);\r
+      gOptions.CPreprocessorOptions = CPreprocessorOptions;\r
+    } else {\r
+      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      return STATUS_ERROR;\r
+    }\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Must specify at least the vfr file name\r
+  //\r
+  if (Argc > 1) {\r
+    Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");\r
+    return STATUS_ERROR;\r
+  } else if (Argc < 1) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");\r
+    return STATUS_ERROR;\r
+  }\r
+  strcpy (gOptions.VfrFileName, Argv[0]);\r
+  \r
+  strcpy (CopyStr, gOptions.VfrFileName);\r
+  Cptr = CopyStr + strlen (CopyStr) - 1;\r
+  for (;(Cptr > CopyStr) && (*Cptr != '\\') && (*Cptr != ':'); Cptr--);\r
+  if (Cptr == CopyStr) {\r
+    strcpy (gOptions.VfrBaseFileName, Cptr);\r
+  } else {\r
+    strcpy (gOptions.VfrBaseFileName, Cptr+1);\r
+  }\r
+  //\r
+  // Terminate the vfr file basename at the extension\r
+  //\r
+  for (Cptr = gOptions.VfrBaseFileName; *Cptr && (*Cptr != '.'); Cptr++) {\r
+  }\r
+  *Cptr = 0; \r
+  //\r
+  // If they defined an output directory, prepend all output files\r
+  // with the working directory. Output files of interest:\r
+  //    VfrListFileName             -- list file\r
+  //    IfrOutputFileName           -- IFR bytes \r
+  //    StringOutputFileName        -- string bytes\r
+  //    StringListFileName          -- not used\r
+  //    StringDefineFileName        -- #defines of string identifiers\r
+  //\r
+  // We have two cases:\r
+  //   1. Output directory (-od) not specified, in which case output files\r
+  //      go to the current working directory.\r
+  //   2. Output directory specified, in which case the output files\r
+  //      go directly to the specified directory.\r
+  //\r
+  if (gOptions.OutputDirectory[0] == 0) {\r
+    CopyStr[0] = 0;\r
+    _getcwd (CopyStr, sizeof (CopyStr));\r
+    strcpy (gOptions.OutputDirectory, CopyStr);\r
+  }\r
+  //\r
+  // Make sure output directory has a trailing backslash\r
+  //\r
+  if (gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '\\') {\r
+    strcat (gOptions.OutputDirectory, "\\");\r
+  }\r
+  //\r
+  // Create the base output file name as: path\base, copy it to all the output\r
+  // filenames, and then add the appropriate extension to each.\r
+  //\r
+  strcpy (gOptions.VfrListFileName, gOptions.OutputDirectory);\r
+  strcat (gOptions.VfrListFileName, gOptions.VfrBaseFileName);\r
+  strcpy (gOptions.IfrOutputFileName, gOptions.VfrListFileName);\r
+  strcpy (gOptions.PreprocessorOutputFileName, gOptions.VfrListFileName);\r
+  strcat (gOptions.VfrListFileName, VFR_LIST_FILENAME_EXTENSION);\r
+  strcat (gOptions.IfrOutputFileName, VFR_BINARY_FILENAME_EXTENSION);\r
+  strcat (gOptions.PreprocessorOutputFileName, VFR_PREPROCESS_FILENAME_EXTENSION);\r
+  \r
+  //\r
+  // We set a default list file name, so if they do not\r
+  // want a list file, null out the name now.\r
+  //\r
+  if (gOptions.CreateListFile == 0) {\r
+    gOptions.VfrListFileName[0] = 0;\r
+  }\r
+  return STATUS_SUCCESS;\r
+}\r
+static \r
+VOID \r
+Usage ()\r
+/*++\r
+\r
+Routine Description:\r
+  Print utility usage instructions\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  int Index;\r
+  const char *Help[] = {\r
+    " ", \r
+    "VfrCompile version " VFR_COMPILER_VERSION,\r
+    " ",\r
+    "  Usage: VfrCompile {options} [VfrFile]",\r
+    " ",\r
+    "    where options include:",\r
+    "      -? or -h       prints this help",\r
+    "      -l             create an output IFR listing file",\r
+    "      -i IncPath     add IncPath to the search path for VFR included files",\r
+    "      -od OutputDir  deposit all output files to directory OutputDir (default=cwd)",\r
+    "      -ibin          create an IFR HII pack file",\r
+    "    where parameters include:",\r
+    "      VfrFile        name of the input VFR script file",\r
+    " ",\r
+    NULL\r
+    };\r
+  for (Index = 0; Help[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Help[Index]);\r
+  }\r
+}\r
+    \r
+>>\r
+\r
+\r
+#lexaction\r
+<<\r
+\r
+#include "EfiVfr.h"\r
+\r
+PARSER_LINE_DEFINITION  *gLineDefinition = NULL;\r
+PARSER_LINE_DEFINITION  *gLastLineDefinition = NULL;\r
+\r
+VOID\r
+AddFileLine (\r
+  char      *TokenString,\r
+  UINT32    TokenLine\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During the lexer phase, if we encounter a #line statement output by\r
+  the preprocessor, this function gets called. We'll save off the info \r
+  for error reporting purposes. The preprocessor line information has the\r
+  form:\r
+    \r
+    #line 3 "FileName.c"  \r
+\r
+Arguments:\r
+  TokenString - the parsed string as shown above\r
+  TokenLine   - the line number in the preprocessed output file \r
+  \r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  PARSER_LINE_DEFINITION  *LineDef;\r
+  INT8                    *Cptr;\r
+  \r
+  //\r
+  // Allocate a structure in which we can keep track of this line information.\r
+  //\r
+  LineDef = (PARSER_LINE_DEFINITION *)malloc (sizeof (PARSER_LINE_DEFINITION));\r
+  memset ((char *)LineDef, 0, sizeof (PARSER_LINE_DEFINITION));\r
+  LineDef->TokenLineNum = TokenLine;\r
+  LineDef->HashLineNum = atoi (TokenString + 6);\r
+  //\r
+  // Find the quotes in the filename, then allocate space in the line\r
+  // def structure for a copy of the filename. Finally, copy it without\r
+  // quotes to the line def.\r
+  //\r
+  for (Cptr = TokenString + 7; *Cptr && (*Cptr != '"'); Cptr++);\r
+  if (*Cptr == '"') {\r
+    LineDef->FileName = (INT8 *)malloc (strlen (Cptr));\r
+    Cptr++;\r
+    strcpy (LineDef->FileName, Cptr);\r
+    for (Cptr = LineDef->FileName; *Cptr && (*Cptr != '"'); Cptr++);\r
+    *Cptr = 0;   \r
+    //\r
+    // Now add this new one to the list\r
+    //\r
+    if (gLineDefinition == NULL) {\r
+      gLineDefinition = LineDef;\r
+    } else {\r
+      gLastLineDefinition->Next = LineDef;\r
+    }\r
+    gLastLineDefinition = LineDef;\r
+  } else {\r
+    Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);\r
+    free (LineDef);\r
+    return;\r
+  }\r
+}\r
+char *\r
+ConvertLineNumber (\r
+  UINT32 *LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given the line number in the preprocessor-output file, use the line number\r
+  information we've saved to determine the source file name and line number\r
+  where the code originally came from. This is required for error reporting.\r
+\r
+Arguments:\r
+  LineNum - the line number in the preprocessor-output file.\r
+\r
+Returns:\r
+  Returns a pointer to the source file name. Also returns the line number \r
+  in the provided LineNum argument\r
+\r
+--*/\r
+{\r
+  PARSER_LINE_DEFINITION  *LineDef;\r
+  //\r
+  // Step through our linked list of #line information we saved off. \r
+  // For each one, look at its line number, and the line number of the\r
+  // next record, and see if the passed-in line number is in the range.\r
+  // If it is, then convert the line number to the appropriate line number\r
+  // of the original source file.\r
+  //\r
+  for (LineDef = gLineDefinition; LineDef != NULL; LineDef = LineDef->Next) {\r
+    //\r
+    // The given LineNum is the line number from the .i file.\r
+    // Find a line definition whose range includes this line number,\r
+    // convert the line number, and return the filename.\r
+    //\r
+    if (LineDef->TokenLineNum <= *LineNum) {\r
+      if (LineDef->Next != NULL) {\r
+        if (LineDef->Next->TokenLineNum > *LineNum) {\r
+          *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
+          return LineDef->FileName;\r
+        }\r
+      } else {\r
+        //\r
+        // Last one in the list of line definitions, so has to be right\r
+        //\r
+        *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
+        return LineDef->FileName;\r
+      }\r
+    }\r
+  }\r
+  return NULL;\r
+}\r
+\r
+>>\r
+\r
+//\r
+// Define a lexical class for parsing quoted strings. Basically\r
+// starts with a double quote, and ends with a double quote that\r
+// is not preceeded with a backslash.\r
+//\r
+#lexclass QUOTED_STRING\r
+#token TheString            "~[\"]*\"" << mode (START); >>     \r
+\r
+//\r
+// Define a lexical class for parsing "#pragma pack" statements. \r
+// We do this just for convenience (since we skip them here) so\r
+// that users can include some minimal .h files.\r
+//\r
+#lexclass PRAGMA_PACK\r
+#token "pack"     << skip (); >>\r
+#token "[\ \t]"   << skip (); >> \r
+#token "\("       << skip (); >>\r
+#token "[0-9]*"   << skip (); >>\r
+#token "\)"       << skip (); mode (START); >>\r
+\r
+//\r
+// Define a lexclass for skipping over C++ style comments\r
+//\r
+#lexclass CPP_COMMENT\r
+#token "~[\n]*"       << skip (); >>\r
+#token "\n"           << skip (); mode (START); newline (); >>\r
+\r
+//\r
+// Standard lexclass is START\r
+//\r
+#lexclass START\r
+\r
+//\r
+// Find start of C++ style comments\r
+//\r
+#token "//"     << skip (); mode (CPP_COMMENT); >>\r
+\r
+//\r
+// Skip whitespace\r
+//\r
+#token "[\ \t]"   << skip (); >> \r
+\r
+//\r
+// Skip over newlines, but count them\r
+//\r
+#token "\n"       << skip (); newline (); >>\r
+\r
+//\r
+// Skip pragma pack statements\r
+//\r
+#token "\#pragma" << skip (); mode(PRAGMA_PACK); >>\r
+\r
+//\r
+// Skip over 'extern' in any included .H file\r
+//\r
+#token "extern"   << skip (); >>\r
+\r
+//\r
+// Tokens for the different keywords. Syntax is:\r
+// TokenName("ErrorMessageText")    "TokenString"\r
+//   where:\r
+//     TokenName is the token name (must be capitalized) that is used in the rules\r
+//     ErrorMessageText is the string the compiler emits when it detects a syntax error\r
+//     TokenString is the actual matching string used in the user script\r
+//\r
+#token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << AddFileLine (begexpr (), line ()); skip (); >>\r
+#token FormSet("formset")                       "formset"\r
+#token EndFormSet("endformset")                 "endformset"\r
+#token Title("title")                           "title"\r
+#token FormId("formid")                         "formid"\r
+#token OneOf("oneof")                           "oneof"\r
+#token Prompt("prompt")                         "prompt"\r
+#token OrderedList("orderedlist")               "orderedlist"\r
+#token EndList("endlist")                       "endlist"\r
+#token EndForm("endform")                       "endform"\r
+#token EndOneOf("endoneof")                     "endoneof"\r
+#token Form("form")                             "form"\r
+#token Subtitle("subtitle")                     "subtitle"\r
+#token Help("help")                             "help"\r
+#token VarId("varid")                           "varid"\r
+#token Text("text")                             "text"\r
+#token Option("option")                         "option"\r
+#token Value("value")                           "value"\r
+#token Flags("flags")                           "flags"\r
+#token Date("date")                             "date"\r
+#token EndDate("enddate")                       "enddate"\r
+#token Year("year")                             "year"\r
+#token Month("month")                           "month"\r
+#token Day("day")                               "day"\r
+#token Time("time")                             "time"\r
+#token EndTime("endtime")                       "endtime"\r
+#token Hour("hour")                             "hour"\r
+#token Minute("minute")                         "minute"\r
+#token Second("second")                         "second"\r
+#token AND("AND")                               "AND"\r
+#token OR("OR")                                 "OR"\r
+#token GrayOutIf("grayoutif")                   "grayoutif"\r
+#token NOT("NOT")                               "NOT"\r
+#token Label("label")                           "label"\r
+#token Timeout("timeout")                       "timeout"\r
+#token Inventory("inventory")                   "inventory"\r
+#token StringToken("STRING_TOKEN")              "STRING_TOKEN"\r
+#token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
+#token Struct("struct")                         "struct"\r
+#token Uint64("UINT64")                         "UINT64"\r
+#token Uint32("UINT32")                         "UINT32"\r
+#token Uint16("UINT16")                         "UINT16"\r
+#token Char16("CHAR16")                         "CHAR16"\r
+#token Uint8("UINT8")                           "UINT8"\r
+#token Guid("guid")                             "guid"\r
+#token CheckBox("checkbox")                     "checkbox"\r
+#token EndCheckBox("endcheckbox")               "endcheckbox"\r
+#token Numeric("numeric")                       "numeric"\r
+#token EndNumeric("endnumeric")                 "endnumeric"            \r
+#token Minimum("minimum")                       "minimum"         \r
+#token Maximum("maximum")                       "maximum"         \r
+#token Step("step")                             "step"      \r
+#token Default("default")                       "default"         \r
+#token Password("password")                     "password"          \r
+#token EndPassword("endpassword")               "endpassword"             \r
+#token String("string")                         "string"        \r
+#token EndString("endstring")                   "endstring"           \r
+#token MinSize("minsize")                       "minsize"         \r
+#token MaxSize("maxsize")                       "maxsize"         \r
+#token Encoding("encoding")                     "encoding"\r
+#token SuppressIf("suppressif")                 "suppressif"\r
+#token Hidden("hidden")                         "hidden"\r
+#token Goto("goto")                             "goto"\r
+#token InconsistentIf                           "inconsistentif"\r
+#token EndIf("endif")                           "endif"\r
+#token IdEqId("ideqid")                         "ideqid"\r
+#token IdEqVal("ideqval")                       "ideqval"\r
+#token VarEqVal("vareqval")                     "vareqval"\r
+#token Var("var")                               "var"\r
+#token IdEqValList("ideqvallist")               "ideqvallist"\r
+#token Length("length")                         "length"\r
+#token Values("values")                         "values"\r
+#token Key("key")                               "key"\r
+#token DefaultFlag("DEFAULT")                   "DEFAULT"\r
+#token ManufacturingFlag("MANUFACTURING")       "MANUFACTURING"\r
+#token InteractiveFlag("INTERACTIVE")           "INTERACTIVE"\r
+#token NVAccessFlag("NV_ACCESS")                "NV_ACCESS"\r
+#token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
+#token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
+#token Class("class")                           "class"\r
+#token Subclass("subclass")                     "subclass"\r
+#token TypeDef("typedef")                       "typedef"\r
+#token Restore("restore")                       "restore"\r
+#token Save("save")                             "save"\r
+#token Defaults("defaults")                     "defaults"\r
+#token Banner("banner")                         "banner"\r
+#token Align("align")                           "align"\r
+#token Left("left")                             "left"\r
+#token Right("right")                           "right"\r
+#token Center("center")                         "center"\r
+#token Line("line")                             "line"\r
+#token VarStore("varstore")                     "varstore"\r
+#token Name("name")                             "name"\r
+#token Oem("oem")                               "oem"\r
+#token True("TRUE")                             "TRUE"\r
+#token False("FALSE")                           "FALSE"\r
+#token GreaterThan(">")                         ">"\r
+#token GreaterEqual(">=")                       ">="\r
+#token LessThan("<")                          "<"\r
+#token LessEqual("<=")                        "<="\r
+\r
+//\r
+// Define the class and subclass tokens\r
+//\r
+#token ClassNonDevice("NONDEVICE")                        "NON_DEVICE"\r
+#token ClassDiskDevice("DISK_DEVICE")                     "DISK_DEVICE"\r
+#token ClassVideoDevice("VIDEO_DEVICE")                   "VIDEO_DEVICE"\r
+#token ClassNetworkDevice("NETWORK_DEVICE")               "NETWORK_DEVICE"\r
+#token ClassInputDevice("INPUT_DEVICE")                   "INPUT_DEVICE"\r
+#token ClassOnBoardDevice("ONBOARD_DEVICE")               "ONBOARD_DEVICE"\r
+#token ClassOtherDevice("OTHER_DEVICE")                   "OTHER_DEVICE"\r
+\r
+#token SubclassSetupApplication("SETUP_APPLICATION")      "SETUP_APPLICATION"\r
+#token SubclassGeneralApplication("GENERAL_APPLICATION")  "GENERAL_APPLICATION"\r
+#token SubclassFrontPage("FRONT_PAGE")                    "FRONT_PAGE"\r
+#token SubclassSingleUse("SINGLE_USE")                    "SINGLE_USE"\r
+\r
+#token LanguageIdentifier("language identifier") "[a-z][a-z][a-z]"   // 3 lowercase characters\r
+#token StringIdentifier("string identifier")    "[A-Za-z_][A-Za-z_0-9]*"\r
+#token Number("numeric value")                  "(0x[0-9A-Fa-f]+) | [0-9]+"\r
+#token OpenBrace("{")                           "\{"\r
+#token CloseBrace("}")                          "\}"\r
+#token OpenParen("(")                           "\("\r
+#token CloseParen(")")                          "\)"\r
+#token OpenBracket("[")                         "\["\r
+#token CloseBracket("]")                        "\]"\r
+\r
+//\r
+// Define all other invalid characters so that they get through the lexical phase\r
+// and we can catch them during the parse phase. We get much better error\r
+// messages then. \r
+//\r
+#token InvalidCharacters("invalid characters")  "~[;:=,\.\|]"  \r
+\r
+//\r
+// This is the overall definition of a VFR form definition script.\r
+//\r
+program :\r
+  ( dataStructDefinition )*\r
+  formSetStatement   \r
+  ( vfrStatementVarStore )*\r
+  ( formDefinition )*\r
+  EFS:EndFormSet  ";"                   << WriteOpByte (EFS->getLine(), EFI_IFR_END_FORM_SET_OP); >>\r
+  "@" // end of file\r
+  ;\r
+    \r
+formSetStatement :\r
+  FS:FormSet                            << WriteOpByte (FS->getLine(), EFI_IFR_FORM_SET_OP); >>\r
+  Guid "=" \r
+  OpenBrace \r
+  G1:Number ","\r
+  G2:Number ","\r
+  G3:Number ","\r
+  G4:Number ","\r
+  G5:Number ","\r
+  G6:Number ","\r
+  G7:Number ","\r
+  G8:Number ","\r
+  G9:Number ","\r
+  G10:Number ","\r
+  G11:Number \r
+  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
+                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
+                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
+                                                          );\r
+                                         >>\r
+  ","\r
+  Title "=" getStringId ","\r
+  Help  "=" getStringId ","\r
+  //\r
+  // insert padding for an EFI_PHYSICAL_ADDRESS (UINT64)\r
+  //\r
+                                            << WriteDWord (0, 0); WriteDWord (0, 0); >>\r
+  Class "=" CVAL:classDefinition ","        << WriteClass (); >>\r
+  Subclass "=" SVAL:subclassDefinition ","  << WriteSubclass (); >>\r
+                                            << WriteWord (mNvDataStructSize); >>\r
+  ;  \r
+\r
+//\r
+// A form can be of multiple classes, thus allow CLASS_A | CLASS_B | CLASS_C\r
+//\r
+classDefinition :\r
+  validClassNames ( "\|" validClassNames )*\r
+  ;\r
+  \r
+validClassNames :\r
+    CND:ClassNonDevice          << SetClass (CND->getLine(), EFI_NON_DEVICE_CLASS); >>\r
+  | CDD:ClassDiskDevice         << SetClass (CDD->getLine(), EFI_DISK_DEVICE_CLASS); >>\r
+  | CVD:ClassVideoDevice        << SetClass (CVD->getLine(), EFI_VIDEO_DEVICE_CLASS); >>\r
+  | CNW:ClassNetworkDevice      << SetClass (CNW->getLine(), EFI_NETWORK_DEVICE_CLASS); >>\r
+  | CID:ClassInputDevice        << SetClass (CID->getLine(), EFI_INPUT_DEVICE_CLASS); >>\r
+  | COB:ClassOnBoardDevice      << SetClass (COB->getLine(), EFI_ON_BOARD_DEVICE_CLASS); >>\r
+  | COD:ClassOtherDevice        << SetClass (COD->getLine(), EFI_OTHER_DEVICE_CLASS); >>\r
+  | CNUM:Number                 << SetClass (CNUM->getLine(), GetNumber (CNUM->getText(), CNUM->getLine(), 4)); >>\r
+  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid class"); >>\r
+\r
+//\r
+// A form can only be of one subclass type.\r
+//\r
+subclassDefinition :\r
+    SSA:SubclassSetupApplication    << SetSubclass (SSA->getLine(), EFI_SETUP_APPLICATION_SUBCLASS); >>\r
+  | SGA:SubclassGeneralApplication  << SetSubclass (SGA->getLine(), EFI_GENERAL_APPLICATION_SUBCLASS); >>\r
+  | SFP:SubclassFrontPage           << SetSubclass (SFP->getLine(), EFI_FRONT_PAGE_SUBCLASS); >>\r
+  | SSU:SubclassSingleUse           << SetSubclass (SSU->getLine(), EFI_SINGLE_USE_SUBCLASS); >>\r
+  | SNUM:Number                     << SetSubclass (SNUM->getLine(), GetNumber (SNUM->getText(), SNUM->getLine(), 4)); >>\r
+  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid subclass"); >>\r
+\r
+//\r
+// Parse a C type data structure for storing VFR setup data. Allow:\r
+//  typedef struct _XXX_ {\r
+//     (fields)\r
+//  } MY_NV_DATA;\r
+//\r
+dataStructDefinition :\r
+  << int IsNonNV = 0; >>\r
+  { TypeDef } \r
+  S:Struct                          \r
+  (\r
+    NonNvDataMap                    << IsNonNV = 1; >>\r
+  |\r
+    { StringIdentifier }\r
+  )                                 << StartStructDefinition (IsNonNV, S->getLine()); >>\r
+  OpenBrace \r
+  dataStructFields \r
+  CloseBrace NAME:StringIdentifier  << EndStructDefinition (NAME->getText(), NAME->getLine()); >>\r
+  ";"\r
+  ;\r
+\r
+dataStructFields :\r
+  ( dataStructField64 | dataStructField32 | dataStructField16 | dataStructField8 ) *\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT64 Name[4];\r
+//   UINT64 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField64 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT64" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 8, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT32 Name[4];\r
+//   UINT32 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField32 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT32" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> )  \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 4, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT16 Name[4];\r
+//   UINT16 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField16 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  ( "UINT16" | "CHAR16" )\r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 2, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT8 Name[4];\r
+//   UINT8 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField8 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT8" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 1, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    form formid = 1,\r
+//      title  = STRING_TOKEN(STR_FORM_TITLE);\r
+//      -- form statements --\r
+//    endform;\r
+//\r
+//  The Form ID cannot be 0\r
+//\r
+formDefinition :\r
+  FRM:Form FormId                << WriteOpByte (FRM->getLine(), EFI_IFR_FORM_OP); >> \r
+  "=" \r
+  VAL:Number                     << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); AddFormId (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); >>\r
+  ","\r
+  Title "=" getStringId ";"      // writes string identifier\r
+  ( vfrStatements )*\r
+  ENDF:EndForm  ";"              << WriteOpByte (ENDF->getLine(), EFI_IFR_END_FORM_OP); >>\r
+  ;\r
+\r
+//\r
+// VFR statements in a formset\r
+//\r
+vfrStatements :\r
+  vfrStatementSubTitle        | \r
+  vfrStatementOneOf           |\r
+  vfrStatementTextText        |\r
+  vfrStatementCheckBox        |\r
+  vfrStatementNumeric         |\r
+  vfrStatementDate            |\r
+  vfrStatementTime            |\r
+  vfrStatementPassword        |\r
+  vfrStatementString          |\r
+  vfrStatementSuppressIf      |\r
+  vfrStatementHidden          |\r
+  vfrStatementGoto            | \r
+  vfrStatementGrayOutIf       |\r
+  vfrStatementInconsistentIf  |\r
+  vfrStatementLabel           |\r
+  vfrStatementBanner          |\r
+  vfrStatementInventory       |\r
+  vfrStatementOrderedList     |\r
+  vfrStatementOem             |\r
+  vfrStatementSaveRestoreDefaults\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   label 100;\r
+//\r
+vfrStatementLabel :\r
+  OPID:Label                              << WriteOpByte (OPID->getLine(), EFI_IFR_LABEL_OP); >>\r
+  VAL:Number                              << \r
+                                              WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
+                                              AddLabel (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
+                                          >>\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   oem 0x12, 0x34, 0x56;\r
+//\r
+vfrStatementOem :\r
+  OPID:Oem                              << WriteOpByte (OPID->getLine(), EFI_IFR_OEM_DEFINED_OP); >>\r
+  ( VAL1:Number << WriteByte (GetNumber (VAL1->getText(), VAL1->getLine(), 1), 0); >> )\r
+  ( "," VAL2:Number << WriteByte (GetNumber (VAL2->getText(), VAL2->getLine(), 1), 0); >> )*\r
+  ";"\r
+  ;\r
+  \r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   inconsistentif NOT .... AND NOT .... OR ... endif;\r
+//\r
+vfrStatementInconsistentIf : \r
+  << ResetFlags (); >>\r
+  IIFOP:InconsistentIf                  << WriteOpByte (IIFOP->getLine(), EFI_IFR_INCONSISTENT_IF_OP); >>\r
+  Prompt "=" getStringId ","\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  EOP:EndIf ";"                         << WriteOpByte (EOP->getLine(), EFI_IFR_END_IF_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+// \r
+// PARSE:\r
+//   TRUE AND (ideqval SomeStruct.SomeMember >= 0x10 OR \r
+//               ideqid SomeStruct.SomeMember < SomeStruct.SomeOtherMember) AND\r
+//            (ideqlist SomeStruct.SomeOtherMember == 0x10, 0x20, 0x30 OR\r
+//               vareqval var(VAR_EQ_TEST_NAME) == 0x1)\r
+//\r
+// For supporting complex express, divide the vfrBooleanExpression to two parts\r
+// so that pred-LL(k) parser can parse incrementally.\r
+//\r
+vfrBooleanExpression :\r
+  leftPartVfrBooleanExp { rightPartVfrBooleanExp }\r
+  ;\r
+  \r
+leftPartVfrBooleanExp :\r
+  OpenParen vfrBooleanExpression CloseParen                                                        |\r
+  (ideqval | ideqid | ideqvallist | vareqval | truefalse)                                          |\r
+  NOPID:NOT leftPartVfrBooleanExp           << WriteOpByte (NOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ;\r
+\r
+rightPartVfrBooleanExp :\r
+  AOPID:AND vfrBooleanExpression            << WriteOpByte (AOPID->getLine(), EFI_IFR_AND_OP); >>  |\r
+  OOPID:OR vfrBooleanExpression             << WriteOpByte (OOPID->getLine(), EFI_IFR_OR_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   TRUE\r
+//\r
+truefalse :\r
+  TOPID:True                                << WriteOpByte (TOPID->getLine(), EFI_IFR_TRUE_OP); >> |\r
+  FOPID:False                               << WriteOpByte (FOPID->getLine(), EFI_IFR_FALSE_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   varstore MY_STRUCT_NAME, key = 0x1234, name = "MyVariableName", guid = {...};\r
+//\r
+vfrStatementVarStore : \r
+  OP:VarStore                           << WriteOpByte (OP->getLine(), EFI_IFR_VARSTORE_OP); >>\r
+  STRUCT_NAME:StringIdentifier ","\r
+  Key   "=" KNUM:Number ","\r
+  Name  "=" VAR_NAME:StringIdentifier ","  \r
+  Guid "=" \r
+  OpenBrace \r
+  G1:Number ","\r
+  G2:Number ","\r
+  G3:Number ","\r
+  G4:Number ","\r
+  G5:Number ","\r
+  G6:Number ","\r
+  G7:Number ","\r
+  G8:Number ","\r
+  G9:Number ","\r
+  G10:Number ","\r
+  G11:Number \r
+  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
+                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
+                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
+                                                          );\r
+                                           WriteWord (GetNumber (KNUM->getText(), KNUM->getLine(), 2)); \r
+                                           AddVarStore (STRUCT_NAME->getText(), VAR_NAME->getText(), GetNumber (KNUM->getText(), KNUM->getLine(), 2), STRUCT_NAME->getLine());\r
+                                         >>\r
+  \r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:  \r
+//   vareqval var(0x100) == 0x20\r
+//\r
+vareqval : \r
+  OPID:VarEqVal                           << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_VAR_VAL_OP); >>\r
+  Var OpenParen \r
+  VAR:Number                              << WriteWord (GetNumber (VAR->getText(), VAR->getLine(), 2)); >>\r
+  CloseParen\r
+  compareNumber\r
+  ;\r
+\r
+ideqval : \r
+  OPID:IdEqVal                            << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_VAL_OP); >>\r
+  vfrStructFieldName[0]\r
+  compareNumber\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   ideqid MyNVData3.Field16A == MyNVData3.Field16B\r
+//\r
+// NOTE: Before processing the second variable store in the ideqid statement, set a global flag\r
+//       so that when we parse the second variable we set the secondary variable store id.\r
+//\r
+ideqid : \r
+  OPID:IdEqId                             << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_ID_OP);  >>\r
+  vfrStructFieldName[0]\r
+  compareVfrStructFieldNameNL0\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// compareNumber is the combination of compare operation and Number\r
+//\r
+compareNumber :\r
+  (\r
+  "=="\r
+  VAL1:Number                             << WriteWord (GetNumber (VAL1->getText(), VAL1->getLine(), 2)); >>\r
+  ) |\r
+  (\r
+  GTOPID:GreaterThan\r
+  VAL2:Number                             << WriteWord (GetNumber (VAL2->getText(), VAL2->getLine(), 2));\r
+                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
+  ) |\r
+  (\r
+  GEOPID:GreaterEqual\r
+  VAL3:Number                             << WriteWord (GetNumber (VAL3->getText(), VAL3->getLine(), 2));\r
+                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
+  ) |\r
+  (\r
+  LTOPID:LessThan\r
+  VAL4:Number                             << WriteWord (GetNumber (VAL4->getText(), VAL4->getLine(), 2));\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ) |\r
+  (\r
+  LEOPID:LessEqual\r
+  VAL5:Number                             << WriteWord (GetNumber (VAL5->getText(), VAL5->getLine(), 2));\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  )\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// compareVfrStructFieldNameNL0 is the combination of compare operation and  vfrStructFieldNameNL[0]\r
+//\r
+compareVfrStructFieldNameNL0 :\r
+  (\r
+  "=="                                    << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0; >>\r
+  ) |\r
+  (\r
+  GTOPID:GreaterThan                      << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
+  ) |\r
+  (\r
+  GEOPID:GreaterEqual                     << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
+  ) |\r
+  (\r
+  LTOPID:LessThan                       << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ) |\r
+  (\r
+  LEOPID:LessEqual                      << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  )\r
+  ;\r
+  \r
+\r
+ideqvallist : \r
+  OPID:IdEqValList                        << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_LIST_OP); >>\r
+  vfrStructFieldName[0] \r
+  "=="\r
+  ( VAL:Number                            << QueueIdEqValList (GetNumber (VAL->getText(), VAL->getLine(), 2)); >> ) +\r
+                                          << FlushQueueIdEqValList(); >>\r
+  ;\r
+    \r
+vfrStatementGoto : \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDG:Goto                          << WriteOpByte (IDG->getLine(), EFI_IFR_REF_OP); >>\r
+  VAL:Number  ","                   << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
+                                       AddGotoReference (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
+                                    >>\r
+  KP:Prompt   "=" getStringId ","   << LineNum = KP->getLine();  >>\r
+  Help        "=" getStringId\r
+  { \r
+    "," \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    "," Key   "=" KNUM:Number       << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                    << WriteFlagsKey (KeyValue, LineNum); >>\r
+  ";"\r
+  ;\r
+    \r
+vfrStatementHidden : \r
+  IDH:Hidden                  << WriteOpByte (IDH->getLine(), EFI_IFR_HIDDEN_OP); >>\r
+  Value "="\r
+  VAL:Number ","              << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); >>\r
+  Key "="\r
+  KVAL:Number                 << WriteWord (GetNumber (KVAL->getText(), KVAL->getLine(), 2)); >>\r
+  ";"\r
+  ;    \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   suppressif <boolean_expression> { grayoutif } <statements>+ endif;\r
+// Note:\r
+//   You can have: suppressif:grayoutif:statements:endif\r
+//                 suppressif:grayoutif:endif                  -- serves no purpose\r
+//                 suppressif:statements:endif\r
+//                 suppressif:endif                            -- serves no purpose\r
+//\r
+vfrStatementSuppressIf : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field \r
+  vfrBooleanExpression\r
+  ";"\r
+  { suppressIfGrayOutIf } ( suppressIfAndGrayoutIfSubstatements )+\r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+//\r
+// This is the form for a grayoutif nested in a suppressif statement\r
+//\r
+suppressIfGrayOutIf :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  ; \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   grayoutif { flags = n, } <boolean_expression> endif;\r
+// Note:\r
+//   You can have: grayoutif:suppressif:statements:endif\r
+//                 grayoutif:statements:endif\r
+//\r
+//\r
+vfrStatementGrayOutIf :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  { grayoutIfSuppressIf } ( suppressIfAndGrayoutIfSubstatements )+ \r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+//\r
+// This is the format for a suppressif nested in a grayoutif\r
+//\r
+grayoutIfSuppressIf : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  ;\r
+\r
+//\r
+// These are the VFR statements that are valid inside a suppressif or grayoutif statement.\r
+//\r
+suppressIfAndGrayoutIfSubstatements :\r
+  vfrStatementOneOf           |\r
+  vfrStatementTextText        |\r
+  vfrStatementCheckBox        |\r
+  vfrStatementNumeric         |\r
+  vfrStatementDate            |\r
+  vfrStatementTime            |\r
+  vfrStatementPassword        |\r
+  vfrStatementString          |\r
+  vfrStatementHidden          |\r
+  vfrStatementGoto            | \r
+  vfrStatementLabel           |\r
+  vfrStatementInventory       |\r
+  vfrStatementOrderedList     |\r
+  vfrStatementSaveRestoreDefaults\r
+  ; \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    password  varid    = MyNvData.Password,\r
+//              prompt   = STRING_TOKEN(STR_PASSWORD_PROMPT),\r
+//              help     = STRING_TOKEN(STR_PASSWORD_HELP),\r
+//              minsize  = 6,\r
+//              maxsize  = 20,\r
+//              encoding = 1,\r
+//    endpassword; \r
+  \r
+vfrStatementPassword : \r
+  << UINT32 KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  IDPW:Password                       << WriteOpByte (IDPW->getLine(), EFI_IFR_PASSWORD_OP); >>\r
+  VarId       "=" vfrStructFieldNameArray[0] ","\r
+  Prompt      "=" getStringId ","\r
+  KH:Help     "=" getStringId ","    << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    Key "=" KNUM:Number ","           << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
+  MinSize   "=" MIN:Number ","        << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0); >>\r
+  MaxSize   "=" MAX:Number ","        << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
+  Encoding  "=" ENC:Number ","        << WriteWord (GetNumber (ENC->getText(), ENC->getLine(), 2)); >>\r
+  EndPassword  ";"              \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+//  PARSE:\r
+//\r
+//    string    varid    = MyNv.String,\r
+//              prompt   = STRING_TOKEN(STR_STRING_PROMPT),\r
+//              help     = STRING_TOKEN(STR_STRING_HELP),\r
+//              flags    = INTERACTIVE,\r
+//              key      = 0x1234,\r
+//              minsize  = 6,\r
+//              maxsize  = 0x14,\r
+//    endstring; \r
+//\r
+// Since flags and key are optional, we can't use Flags->getLine(). Therefore for error\r
+// reporting we save the line number of the "help" keyword.\r
+//\r
+vfrStatementString : \r
+  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  IDS:String                                << WriteOpByte (IDS->getLine(), EFI_IFR_STRING_OP); >>\r
+  VarId     "=" vfrStructFieldNameArray[0] ","\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId ","             << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags "=" \r
+    flagsField ( "\|" flagsField )*         << LineNum = FF->getLine(); >>\r
+    "," \r
+  }\r
+  {\r
+    Key "=" KNUM:Number ","                 << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                            << WriteFlagsKey (KeyValue, LineNum); >>\r
+  MinSize   "=" MIN:Number ","              << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0);  >>\r
+  MaxSize   "=" MAX:Number ","              << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
+  EndString  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    numeric varid   = MyIfrNVData.HowOldAreYouInYears, \r
+//            prompt  = STRING_TOKEN(STR_NUMERIC_PROMPT),\r
+//            help    = STRING_TOKEN(STR_NUMERIC_HELP),\r
+//            flags   = INTERACTIVE,  // flags is optional\r
+//            key     = 0x1234,       // key is optional if (flags & INTERACTIVE = 0)\r
+//            minimum = 0x0,\r
+//            maximum = 0xf0,\r
+//            step    = 1,            // step is option, and step=1 if not specified\r
+//            default = 0;            // default is optional, and default=minimum if not specified\r
+//    endnumeric;\r
+//\r
+// Make flags and key optional. However if flags includes INTERACTIVE, then a key is required.\r
+// That check is done in WriteFlagsKey() function.\r
+//\r
+vfrStatementNumeric :  \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDN:Numeric                         << WriteOpByte (IDN->getLine(), EFI_IFR_NUMERIC_OP); >>\r
+  VarId     "=" vfrStructFieldName[2] ","\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId ","       << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags "=" flagsField ( "\|" flagsField )* ","     << LineNum = FF->getLine (); >>\r
+  }\r
+  {\r
+    Key "=" KNUM:Number  ","          << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
+  minMaxStepDefault                   \r
+  EndNumeric ";"                      << WriteMinMaxStepDefault (); >>\r
+  ;\r
+\r
+//\r
+// Parse minimum/maximum/step/default statements. Special cases:\r
+//   - if step not specified, then the value is 1\r
+//   - if default not specified, then the value is the min value specified\r
+//   - if max < min, print a warning and swap the values (changes default too)\r
+//\r
+minMaxStepDefault :\r
+  << InitMinMaxStepDefault (); >>\r
+  Minimum   "=" MIN:Number ","        << SetMinMaxStepDefault (GetNumber (MIN->getText(),  MIN->getLine(), 2), 0, MIN->getLine()); >>\r
+  Maximum   "=" MAX:Number ","        << SetMinMaxStepDefault (GetNumber (MAX->getText(),  MAX->getLine(), 2), 1, MAX->getLine()); >>\r
+  { Step    "=" STEP:Number ","       << SetMinMaxStepDefault (GetNumber (STEP->getText(), STEP->getLine(), 2), 2, STEP->getLine()); >> }\r
+  { Default "=" DEF:Number ","        << SetMinMaxStepDefault (GetNumber (DEF->getText(),  DEF->getLine(), 2), 3, DEF->getLine()); >> }\r
+  ;\r
+\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    date    year varid  = Date.Year,                        // "Date.Year" is a special case we recognize\r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_YEAR_HELP),\r
+//            minimum     = 1939,\r
+//            maximum     = 2101,\r
+//            step        = 1,\r
+//            default     = 1964,\r
+//\r
+//            month varid = Date.Month,    \r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_MONTH_HELP),\r
+//            minimum     = 1,\r
+//            maximum     = 12,\r
+//            step        = 1,\r
+//            default     = 1,\r
+//\r
+//            day varid   = Date.Day,\r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_DAY_HELP),\r
+//            minimum     = 1,\r
+//            maximum     = 31,\r
+//            step        = 0x1,\r
+//            default     = 1,\r
+//\r
+//    enddate;\r
+//  \r
+vfrStatementDate :  \r
+  Date                            \r
+  IDY:Year VarId "="                  << WriteOpByte (IDY->getLine(), EFI_IFR_DATE_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDM:Month VarId "="                 << WriteOpByte (IDM->getLine(), EFI_IFR_DATE_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDD:Day VarId "="                   << WriteOpByte (IDD->getLine(), EFI_IFR_DATE_OP); >> \r
+  vfrStructFieldName[2] ","  \r
+  dateTimeSubStatement    \r
+  EndDate ";"\r
+  ;\r
+  \r
+vfrStatementTime :  \r
+  Time                            \r
+  IDH:Hour VarId "="                  << WriteOpByte (IDH->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] ","  \r
+  dateTimeSubStatement                    \r
+  IDM:Minute VarId "="                << WriteOpByte (IDM->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDS:Second VarId "="                << WriteOpByte (IDS->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement\r
+  EndTime ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   text  text = STRING_ID;\r
+//   text  text = STRING_ID, text = STRING_ID;\r
+//   text  text = STRING_ID, text = STRING_ID, flags = x, key = y;\r
+//\r
+vfrStatementTextText :\r
+  << ResetFlags (); >>\r
+  IDT:Text                            << WriteOpByte (IDT->getLine(), EFI_IFR_TEXT_OP); >>\r
+  Help "=" getStringId ","\r
+  Text "=" \r
+  getStringId                         // writes string identifier\r
+  { "," Text "=" getStringId\r
+    "," Flags "=" flagsField ( "\|" flagsField )*  << WriteFlags (); >>\r
+    "," \r
+    Key "=" KNUM:Number               << WriteWord (GetNumber(KNUM->getText(), KNUM->getLine(), 2)); >>\r
+  }\r
+  ";" \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   inventory help = ID, text = ID;\r
+//   inventory help = ID, text = id, text = ID;\r
+//\r
+vfrStatementInventory :\r
+  IDI:Inventory                        << WriteOpByte (IDI->getLine(), EFI_IFR_INVENTORY_OP); >>\r
+  Help        "=" getStringId ","\r
+  Text        "=" getStringId                 // writes string identifier\r
+  { "," Text  "=" getStringId\r
+  }\r
+  ";" \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    restore defaults,\r
+//      formid  = 4,\r
+//      prompt  = STRING_TOKEN(STR_RESTORE_DEFAULTS_PROMPT),\r
+//      help    = STRING_TOKEN(STR_RESTORE_DEFAULTS_HELP),\r
+//      flags   = 0,\r
+//      key     = 0;\r
+//\r
+//    save defaults,\r
+//      formid  = 4,\r
+//      prompt  = STRING_TOKEN(STR_SAVE_DEFAULTS_PROMPT),\r
+//      help    = STRING_TOKEN(STR_SAVE_DEFAULTS_HELP),\r
+//      flags   = 0,\r
+//      key     = 0;\r
+//\r
+vfrStatementSaveRestoreDefaults : \r
+  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  ( IDS:Save                            << WriteOpByte (IDS->getLine(), EFI_IFR_SAVE_DEFAULTS_OP); >>\r
+  | IDR:Restore                         << WriteOpByte (IDR->getLine(), EFI_IFR_RESTORE_DEFAULTS_OP); >>\r
+  )\r
+  Defaults ","\r
+  FormId    "=" FRMID:Number  ","       << WriteWord (GetNumber (FRMID->getText(), FRMID->getLine(), 2)); \r
+                                           AddGotoReference (GetNumber (FRMID->getText(), FRMID->getLine(), 2), FRMID->getLine());\r
+                                        >>\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId             << LineNum = KH->getLine(); >>\r
+  { \r
+    "," FF:Flags "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    "," Key "=" KNUM:Number             << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                        << WriteFlagsKey (KeyValue, LineNum); >>\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
+//\r
+// \r
+flagsField :\r
+  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
+  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
+  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
+  | DF:DefaultFlag                    << SetFlags (EFI_IFR_FLAG_DEFAULT, DF->getLine());        >>\r
+  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
+  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
+  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
+  ;\r
+\r
+dateTimeSubStatement :\r
+  Prompt  "=" getStringId ","\r
+  Help    "=" getStringId ","\r
+                                      << WriteByte (0, 0); WriteWord (0); >> // bogus flags and key\r
+  minMaxStepDefault                   << WriteMinMaxStepDefault (); >>\r
+  ;\r
+  \r
+vfrStatementCheckBox :  \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDCB:CheckBox                       << WriteOpByte (IDCB->getLine(), EFI_IFR_CHECKBOX_OP); >>\r
+  VarId     "=" vfrStructFieldName[1] ","\r
+  Prompt    "=" getStringId ","\r
+  Help      "=" getStringId ","\r
+  FF:Flags  "=" flagsField ( "\|" flagsField )*  "," << LineNum = FF->getLine(); >>\r
+  { \r
+    Key "=" KV:Number  ","           << LineNum = KV->getLine(); KeyValue = GetNumber(KV->getText(), LineNum, 2); >>\r
+  }\r
+                                     << WriteFlagsKey (KeyValue, LineNum); >>\r
+  EndCheckBox ";"\r
+  ;\r
+     \r
+vfrStatementSubTitle :\r
+  IDS:Subtitle Text "="               << WriteOpByte (IDS->getLine(), EFI_IFR_SUBTITLE_OP); >>\r
+  getStringId                         // writes string indentifier\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    banner \r
+//      title = STRING_TOKEN(STR_BANNER_TITLE),\r
+//      line  1,\r
+//      align center;     // or left or right\r
+//\r
+//    banner, \r
+//      title = STRING_TOKEN(STR_BANNER_TITLE), timeout = 100;\r
+//\r
+vfrStatementBanner :\r
+  IDB:Banner { "," }                    << WriteOpByte (IDB->getLine(), EFI_IFR_BANNER_OP); >>\r
+  Title "=" getStringId ","\r
+  ( \r
+    Line VAL:Number ","                 << WriteWord (GetNumber(VAL->getText(), VAL->getLine(), 2)); >>\r
+    Align \r
+    ( Left                              << WriteByte (EFI_IFR_BANNER_ALIGN_LEFT, 0); >>\r
+    | Center                            << WriteByte (EFI_IFR_BANNER_ALIGN_CENTER, 0); >>\r
+    | Right                             << WriteByte (EFI_IFR_BANNER_ALIGN_RIGHT, 0); >>\r
+    ) ";"\r
+  |\r
+    Timeout "=" TO:Number ";"           << WriteWord (GetNumber(TO->getText(), TO->getLine(), 2)); >>\r
+                                        << WriteByte (EFI_IFR_BANNER_TIMEOUT, 0); >>\r
+  )\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   oneof  varid       = MyNv.OneOfData,\r
+//          prompt      = STRING_TOKEN(STR_ONE_OF_PROMPT),\r
+//          help        = STRING_TOKEN(STR_ONE_OF_HELP),\r
+//          option text = STRING_TOKEN(STR_ONE_OF_TEXT), \r
+//          value       = 0, \r
+//          flags       = DEFAULT | INTERACTIVE;\r
+//\r
+// supressif/grayoutif are supported inside oneof stmt.\r
+// We do not restrict the number of oneOfOptionText to >=2, but >=1.\r
+// The situation that all oneOfOptionText are suppressed is also possiable.\r
+//\r
+vfrStatementOneOf :\r
+  << ResetFlags (); >>\r
+  IDOO:OneOf                              << WriteOpByte (IDOO->getLine(), EFI_IFR_ONE_OF_OP); >>\r
+  VarId   "=" vfrStructFieldName[2] ","       \r
+  Prompt  "=" getStringId  ","           // writes string identifier\r
+  Help    "=" getStringId  ","           // writes string identifier\r
+  ( oneOfOptionText )+                   // there must be at least 1 option to be choosed, not 2.\r
+  IDEOO:EndOneOf   ";"                    << TestOneOfFlags (IDEOO->getLine()); WriteOpByte (IDEOO->getLine(), EFI_IFR_END_ONE_OF_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//  \r
+//   orderedlist  varid       = MyNv.OrderedListData,\r
+//                prompt      = STRING_TOKEN(STR_ORDERED_LIST_PROMPT),\r
+//                help        = STRING_TOKEN(STR_ORDERED_LIST_HELP),  \r
+//                option text = STRING_TOKEN(STR_ORDERED_LIST_TEXT), value = 0, flags = INTERACTIVE;\r
+//                -- additional option text -- \r
+//   endlist;\r
+//\r
+vfrStatementOrderedList :\r
+  << ResetFlags (); InitOrderedList(); >>\r
+  IDOL:OrderedList                       << WriteOpByte (IDOL->getLine(), EFI_IFR_ORDERED_LIST_OP); >>\r
+  VarId   "=" vfrStructFieldNameArray[1] ","       \r
+  Prompt  "=" getStringId  ","           // writes string identifier\r
+  Help    "=" getStringId  ","           // writes string identifier\r
+  orderedListOptionText ( orderedListOptionText )+\r
+  IDEOL:EndList   ";"                    << WriteOpByte (IDEOL->getLine(), EFI_IFR_END_OP); EndOrderedList(IDEOL->getLine()); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
+//\r
+// Differs from the oneOfOptionText in that we don't allow the DEFAULT flag to\r
+// be set, and value cannot be 0.\r
+//\r
+orderedListOptionText :\r
+  << UINT32 KeyValue = 0; >>\r
+  IDO:Option                          << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
+  Text      "=" getStringId ","       // writes string identifier\r
+  Value     "=" WVAL:Number ","       << \r
+                                          if (GetNumber(WVAL->getText(), WVAL->getLine(), 2) == 0) {\r
+                                            PrintErrorMessage (WVAL->getLine(), "value=0 is invalid for ordered lists", NULL); \r
+                                          } else {\r
+                                            WriteWord (GetNumber(WVAL->getText(), WVAL->getLine(), 2)); \r
+                                          }\r
+                                      >>\r
+  FF:Flags  "=" orderedListFlagsField  \r
+                ("\|" orderedListFlagsField )*                   \r
+  { \r
+    "," Key "=" KV:Number             << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
+  }\r
+                                      << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
+  ";"                                 << mOptionCount++; >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
+//\r
+// The ordered list flags field cannot have a default.\r
+//\r
+orderedListFlagsField :\r
+  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
+  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
+  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
+  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
+  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
+  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
+  | DF:DefaultFlag                    << PrintWarningMessage (DF->getLine(), "DEFAULT flag not valid for ordered lists", NULL); >>\r
+  ;\r
+\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field". \r
+// This implementation is specific to strings, passwords, and references in an \r
+// ordered list statement because we want to specify the size of the entire \r
+// field, rather than just one element. Then call a function to write out its \r
+// offset and length.\r
+//\r
+vfrStructFieldNameArray[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (1, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  1\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
+// then call a function to write out its offset and length.\r
+//\r
+vfrStructFieldName[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (1, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  0\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   MyNvStructure.FieldName[4]\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
+// then call a function to write out the offset with no length.\r
+//\r
+vfrStructFieldNameNL[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket   << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (0, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  0\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   suppressif TRUE OR FALSE;\r
+//   grayoutif FALSE OR TRUE;\r
+//     option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
+//     option text = STRING_TOKEN(STRING_ID2), value = 1 flags = 98;\r
+//   endif;\r
+//\r
+oneOfOptionText :\r
+  suppressIfOptionText    |\r
+  grayOutIfOptionText     |\r
+  commonOptionText\r
+  ;\r
+\r
+suppressIfOptionText : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field \r
+  vfrBooleanExpression\r
+  ";"\r
+  { suppressIfGrayOutIf } ( commonOptionText )+\r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+grayOutIfOptionText :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  { grayoutIfSuppressIf } ( commonOptionText )+ \r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+commonOptionText : \r
+  << UINT32 KeyValue = 0; >>\r
+  IDO:Option                      << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
+  Text      "=" getStringId ","   // writes string identifier\r
+  Value     "=" WVal:Number ","   << WriteWord (GetNumber(WVal->getText(), WVal->getLine(), 2)); >>\r
+  FF:Flags  "=" flagsField  ("\|" flagsField )*                   \r
+  { \r
+    "," Key "=" KV:Number         << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
+  }\r
+                                  << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
+  ";"                             << mOptionCount++; >>\r
+  ;\r
+\r
+//\r
+// Gets a string identifier. It must be a numeric value of form:\r
+// \r
+//   STRING_TOKEN(100)\r
+//\r
+getStringId :\r
+  << unsigned short StrId; >>\r
+  StringToken OpenParen\r
+  IdVal:Number             << StrId = GetNumber (IdVal->getText(), IdVal->getLine(), 2); WriteStringIdWord (StrId); >> \r
+  CloseParen\r
+  ;\r
+\r
+//******************************************************************************\r
+//\r
+// Parser class definition. \r
+//  \r
+class EfiVfrParser {\r
+<<\r
+//\r
+// Parser definitions go here    \r
+//\r
+private:\r
+  STRUCT_DEFINITION   *mFirstStructDefinition;\r
+  STRUCT_DEFINITION   *mLastStructDefinition;\r
+  INT32               mNvDataStructSize;                    \r
+  INT32               mNonNvDataStructSize;\r
+  //\r
+  // Flag to indicate that we're processing a ideqid VFR statement so that\r
+  // we can do late checks on the statement.\r
+  //\r
+  INT32               mIdEqIdStmt;\r
+  INT32               mLastNVVariableDataSize;\r
+  GOTO_REFERENCE      *mGotoReferences;\r
+  FORM_ID_VALUE       *mFormIdValues;\r
+  VfrOpcodeHandler    mOpcodeHandler;\r
+  UINT16_LIST         *mUint16List;\r
+  UINT16_LIST         *mLastUint16;\r
+  UINT16_LIST         *mDefinedLabels;\r
+  UINT16_LIST         *mDefinedVarStoreId;\r
+  UINT16_LIST         *mLastDefinedVarStoreId;\r
+  UINT32              mMinimumValue, mMaximumValue, mStepValue, mDefaultValue;\r
+  UINT32              mStmtFlags;\r
+  UINT32              mSubStmtFlags;\r
+  UINT32              mSubStmtFlagsLineNum;\r
+  EFI_GUID            mFormSetGuid;\r
+  UINT8               mNvDataStructDefined;\r
+  UINT16              mClass, mSubclass;\r
+  UINT32              mIfStart;\r
+  UINT32              mOptionCount;  // how many "option" fields in a given statement\r
+  UINT32              mLastVarIdSize;\r
+  UINT8               mOutput;\r
+public:        \r
+\r
+VOID \r
+EfiVfrParser::SetIfStart (\r
+  UINT32 LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when an "if" is encountered. Save the\r
+  source line number so we can point to it if we don't find a \r
+  corresponding endif later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the "if" was parsed.\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mIfStart = LineNum;\r
+}\r
+VOID \r
+EfiVfrParser::SetClass (\r
+  UINT32 LineNum, \r
+  UINT32 Value\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when a "class" statement is found. Check the\r
+  range on the class value and save it for later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the class statement was parsed.\r
+  Value   - the class value\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Value & 0xFFFF0000) {\r
+    PrintWarningMessage (LineNum, NULL, "class value exceeds maximum allowed");\r
+  }\r
+  mClass |= (UINT16)Value;\r
+}\r
+VOID \r
+EfiVfrParser::SetSubclass (\r
+  UINT32 LineNum, \r
+  UINT32 Value\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when a subclass statement is found. Check the\r
+  range on the value and save it for later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the class statement was parsed.\r
+  Value   - the subclass value from the VFR statement\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Value & 0xFFFF0000) {\r
+    PrintWarningMessage (LineNum, NULL, "subclass value exceeds maximum allowed");\r
+  }\r
+  mSubclass |= (UINT16)Value;\r
+}\r
+VOID EfiVfrParser::WriteClass ()\r
+{\r
+  WriteWord (mClass);\r
+  mClass = 0;\r
+}\r
+VOID EfiVfrParser::WriteSubclass ()\r
+{\r
+  WriteWord (mSubclass);\r
+  mSubclass = 0;\r
+}\r
+VOID EfiVfrParser::WriteIfrBytes ()\r
+{\r
+  mOpcodeHandler.WriteIfrBytes ();\r
+}\r
+VOID \r
+EfiVfrParser::WriteFlagsKey (\r
+  UINT32 KeyValue, \r
+  UINT32 LineNum\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Write out the flags and key values from the previous VFR statement.\r
+  Many statements take a flags/key pair. If not specified, then 0\r
+  values are written out. However do not allow an interactive flags field\r
+  to be specified if no key value is specified. Also, if NV_ACCESS flag\r
+  is set but INTERACTIVE is not, then set interactive and issue a warning.\r
+\r
+Arguments:\r
+  KeyValue  - the key value from the VFR statement\r
+  LineNum   - source line number where the statement was parsed\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if ((mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE) && (KeyValue == 0)) {\r
+    PrintErrorMessage (LineNum, NULL, "invalid or missing key value - required with INTERACTIVE");\r
+  }\r
+  if ((mSubStmtFlags & EFI_IFR_FLAG_NV_ACCESS) && !(mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE)) {\r
+    PrintWarningMessage (LineNum, NULL, "NV_ACCESS without INTERACTIVE has no effect -- setting INTERACTIVE");\r
+    mSubStmtFlags |= EFI_IFR_FLAG_INTERACTIVE;\r
+  }\r
+  WriteFlags ();\r
+  WriteWord (KeyValue);\r
+}\r
+VOID \r
+EfiVfrParser::InitOrderedList ()\r
+{\r
+  mOptionCount = 0;\r
+}  \r
+VOID \r
+EfiVfrParser::EndOrderedList (\r
+  UINT32 LineNum\r
+  )\r
+{\r
+  if (mLastVarIdSize < mOptionCount) {\r
+    PrintErrorMessage (LineNum, NULL, "number of options exceeds the variable store size");\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::ResetFlags ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flags are set for each substatement in a given one-of statement.\r
+  To make sure there are no conflicts, for example setting DEFAULT on\r
+  more than one substatement, we keep track of the flags at a statement\r
+  level and a substatement level. This function resets the flags so \r
+  we get a fresh start.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mStmtFlags = 0;\r
+  mSubStmtFlagsLineNum = 0;\r
+  mSubStmtFlags = 0;\r
+}\r
+//\r
+// Test validity of flags value for a one-of statement.\r
+//\r
+VOID \r
+EfiVfrParser::TestOneOfFlags (\r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  //\r
+  // One of the fields must have had the default bit set\r
+  //\r
+  if ((mStmtFlags & EFI_IFR_FLAG_DEFAULT) == 0) {\r
+    PrintWarningMessage (LineNum, "default value must be specified", NULL);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::SetFlags (\r
+  UINT32 Flags, \r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  //\r
+  // Check for redefinitions and invalid combinations\r
+  //\r
+  if (mStmtFlags & Flags & EFI_IFR_FLAG_MANUFACTURING) {\r
+    PrintErrorMessage (LineNum, "MANUFACTURING", "a field with this flag already defined");\r
+  }\r
+  if (mStmtFlags & Flags & EFI_IFR_FLAG_DEFAULT) {\r
+    PrintErrorMessage (LineNum, "DEFAULT", "a field with this flag already defined");\r
+  }\r
+  mSubStmtFlags |= Flags;\r
+  mSubStmtFlagsLineNum = LineNum;\r
+}\r
+VOID \r
+EfiVfrParser::WriteFlags ()\r
+{\r
+  //\r
+  // Check value for validity\r
+  //\r
+  if (mSubStmtFlags & ~(EFI_IFR_FLAG_DEFAULT | \r
+                        EFI_IFR_FLAG_MANUFACTURING | \r
+                        EFI_IFR_FLAG_INTERACTIVE | \r
+                        EFI_IFR_FLAG_NV_ACCESS | \r
+                        EFI_IFR_FLAG_RESET_REQUIRED | \r
+                        EFI_IFR_FLAG_LATE_CHECK )) {\r
+    PrintWarningMessage (mSubStmtFlagsLineNum, "invalid bits defined in flag", NULL);\r
+  }\r
+  WriteByte ((UINT8)mSubStmtFlags, 'F');\r
+  //\r
+  // We can now clear the substatement flags\r
+  //\r
+  mStmtFlags |= mSubStmtFlags;\r
+  mSubStmtFlags = 0;\r
+}\r
+//\r
+// When we parse a min/max/step/default sequence, save off the values for\r
+// later use. Call this first to init the values.\r
+//\r
+VOID \r
+EfiVfrParser::InitMinMaxStepDefault ()\r
+{\r
+  mMinimumValue         = 0;\r
+  mMaximumValue         = 0;\r
+  mStepValue            = 1;\r
+  mDefaultValue         = 0;\r
+}  \r
+VOID \r
+EfiVfrParser::WriteMinMaxStepDefault ()\r
+{\r
+  WriteWord (mMinimumValue);\r
+  WriteWord (mMaximumValue);\r
+  WriteWord (mStepValue);\r
+  WriteWord (mDefaultValue);\r
+}  \r
+VOID \r
+EfiVfrParser::SetMinMaxStepDefault (\r
+  UINT16  Value, \r
+  INT32   MMSD, \r
+  INT32   LineNum\r
+  ) \r
+{\r
+  UINT16 TempValue;\r
+  //\r
+  // Min specified\r
+  //\r
+  if (MMSD == 0) {\r
+    mMinimumValue = Value;\r
+    mDefaultValue = Value;\r
+  //\r
+  // Max specified\r
+  //\r
+  } else if (MMSD == 1) {\r
+    mMaximumValue = Value;\r
+    //\r
+    // If min > max, then swap the values. That includes resetting the default\r
+    // value as well.\r
+    //\r
+    if (mMinimumValue > mMaximumValue) {\r
+      PrintWarningMessage (LineNum, NULL, "maximum < minimum");      \r
+      TempValue = Value;\r
+      mMaximumValue = mMinimumValue;\r
+      mMinimumValue = TempValue;\r
+      mDefaultValue = mMinimumValue;\r
+    }\r
+  //\r
+  // Step specified\r
+  //\r
+  } else if (MMSD == 2) { \r
+    mStepValue = Value;\r
+  //\r
+  // Default specified. Make sure min <= default <= max.\r
+  //\r
+  } else if (MMSD == 3) {\r
+    mDefaultValue = Value;\r
+    if (mMinimumValue > Value) {\r
+      PrintErrorMessage (LineNum, NULL, "default value < minimum value");\r
+    } else if (Value > mMaximumValue) {\r
+      PrintErrorMessage (LineNum, NULL, "default value > maximum value");\r
+    }\r
+  } else {\r
+    PrintErrorMessage (LineNum, "application error", "internal MMSD error");    \r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::AddLabel (\r
+  UINT32 LabelNumber, \r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  UINT16_LIST *Label;\r
+\r
+  //\r
+  // Added a label from the user VFR script. Make sure they haven't already \r
+  // defined the same label elsewhere\r
+  //\r
+  for (Label = mDefinedLabels; Label != NULL; Label = Label->Next) {\r
+    if (Label->Value == LabelNumber) {\r
+      PrintErrorMessage (LineNum, NULL, "label already defined");\r
+      PrintErrorMessage (Label->LineNum, NULL, "previous definition of redefined label");\r
+      break;\r
+    }\r
+  }\r
+  Label = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
+  if (Label == NULL) {\r
+    PrintErrorMessage (0, NULL, "memory allocation error");\r
+    return;\r
+  }\r
+  memset ((char *)Label, 0, sizeof (UINT16_LIST));\r
+  Label->Value = LabelNumber;\r
+  Label->LineNum = LineNum;\r
+  Label->Next = mDefinedLabels;\r
+  mDefinedLabels = Label;\r
+}\r
+VOID \r
+EfiVfrParser::QueueIdEqValList (\r
+  UINT16 Value\r
+  )\r
+{\r
+  UINT16_LIST   *U16;\r
+  \r
+  U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
+  if (U16 == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");\r
+  } else {\r
+    memset ((char *)U16, 0, sizeof (UINT16_LIST));\r
+    U16->Value = Value;\r
+    if (mUint16List == NULL) {\r
+      mUint16List = U16;\r
+    } else {\r
+      mLastUint16->Next = U16;\r
+    } \r
+    mLastUint16 = U16;\r
+  }\r
+}    \r
+VOID \r
+EfiVfrParser::FlushQueueIdEqValList ()\r
+{\r
+  UINT32 Count;\r
+  \r
+  //\r
+  // We queued up a list of IdEqValList items. The IFR requires a count\r
+  // followed by the actual values. Do it.\r
+  //\r
+  Count = 0;\r
+  mLastUint16 = mUint16List;\r
+  while (mLastUint16 != NULL) {\r
+    Count++;\r
+    mLastUint16 = mLastUint16->Next;\r
+  }\r
+  // BUGBUG -- check for more than 16K items?\r
+  WriteWord (Count);\r
+  //\r
+  // Now write the values.\r
+  //\r
+  mLastUint16 = mUint16List;\r
+  while (mLastUint16 != NULL) {\r
+    WriteWord ((UINT32)mLastUint16->Value);\r
+    mLastUint16 = mLastUint16->Next;\r
+  }\r
+  //\r
+  // Free up the list\r
+  //  \r
+  mLastUint16 = mUint16List;\r
+  while (mUint16List != NULL) {\r
+    mLastUint16 = mUint16List->Next;\r
+    free (mUint16List);\r
+    mUint16List = mLastUint16;\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::PrintErrorMessage (\r
+  UINT32              LineNum,\r
+  INT8                *Msg1,\r
+  INT8                *Msg2\r
+  )\r
+{\r
+  char *FileName;\r
+  \r
+  if (LineNum != 0) {\r
+    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+    Error (FileName, LineNum, 0, Msg1, Msg2);\r
+  } else {\r
+    Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::PrintWarningMessage (\r
+  UINT32              LineNum,\r
+  INT8                *Msg1,\r
+  INT8                *Msg2\r
+  )\r
+{\r
+  char *FileName;\r
+  \r
+  if (LineNum != 0) {\r
+    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+    Warning (FileName, LineNum, 0, Msg1, Msg2);\r
+  } else {\r
+    Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::syn (\r
+  ANTLRAbstractToken  *Tok, \r
+  ANTLRChar           *Egroup, \r
+  SetWordType         *Eset, \r
+  ANTLRTokenType      ETok, \r
+  INT32               Huh\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called by the parser base class as a result of parse syntax errors.\r
+\r
+Arguments:\r
+  Tok     - token that caused the error\r
+  Egroup  - not sure\r
+  Eset    - index in token table of the expected token\r
+  Huh     - not sure\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  char    *FileName;\r
+  UINT32  LineNum;\r
+  \r
+  LineNum = Tok->getLine ();\r
+  FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+  //\r
+  // Sometimes the token number is 0, in which case I don't know what to\r
+  // print.\r
+  //\r
+  if (ETok == 0) {\r
+    Error (FileName, LineNum, 0, Tok->getText (), "unexpected token");\r
+  } else {\r
+    //\r
+    // If we were expecting an endif, then report the line where the corresponding\r
+    // IF began.\r
+    //\r
+    if ((strcmp (_token_tbl[ETok], "endif") == 0) && (mIfStart != 0)) {\r
+      LineNum = mIfStart;\r
+      FileName = ConvertLineNumber (&LineNum);\r
+      Error (FileName, LineNum, 0, "statement missing corresponding endif", NULL);\r
+    } else {\r
+      Error (FileName, LineNum, 0, Tok->getText (), "expected %s", _token_tbl[ETok]);\r
+    }\r
+  }\r
+}\r
+\r
+VOID \r
+EfiVfrParser::init()        \r
+/*++\r
+\r
+Routine Description:\r
+  Initializations function for our parser.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  ANTLRParser::init();\r
+\r
+  //\r
+  // Used for queuing a variable list of UINT16's\r
+  //\r
+  mUint16List               = NULL;\r
+  mLastUint16               = NULL;\r
+  mFirstStructDefinition    = NULL;\r
+  mLastStructDefinition     = NULL;\r
+  mNvDataStructSize         = 0;\r
+  mNonNvDataStructSize      = 0;\r
+  mNvDataStructDefined      = 0;\r
+  mGotoReferences           = NULL;\r
+  mFormIdValues             = NULL;\r
+  mDefinedLabels            = NULL;\r
+  mClass                    = 0;\r
+  mSubclass                 = 0;\r
+  mIfStart                  = 0;\r
+  mDefinedVarStoreId        = NULL;\r
+  mLastDefinedVarStoreId    = NULL;\r
+  mIdEqIdStmt               = 0;\r
+  mLastNVVariableDataSize   = 0;\r
+    \r
+  memset ((char *)&mFormSetGuid, 0, sizeof (EFI_GUID));\r
+}\r
+//\r
+// Destructor for the parser.\r
+//\r
+EfiVfrParser::~EfiVfrParser(VOID)\r
+{\r
+  Cleanup();\r
+}\r
+VOID\r
+EfiVfrParser::Cleanup (VOID)\r
+/*++\r
+\r
+Routine Description:\r
+  Free memory allocated during parsing\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION         *NextStruct;\r
+  STRUCT_FIELD_DEFINITION   *NextField;\r
+  UINT8                     Buff[6];\r
+  UINT16_LIST               *NextU16List;\r
+  \r
+  //\r
+  // Free up the structure definitions if any\r
+  //\r
+  while (mFirstStructDefinition != NULL) {\r
+    //\r
+    // Free up all the fields for this struct\r
+    //\r
+    while (mFirstStructDefinition->Field != NULL) {\r
+      NextField = mFirstStructDefinition->Field->Next;\r
+      free (mFirstStructDefinition->Field->Name);\r
+      free (mFirstStructDefinition->Field);\r
+      mFirstStructDefinition->Field = NextField;\r
+    }\r
+    NextStruct = mFirstStructDefinition->Next;\r
+    free (mFirstStructDefinition->Name);\r
+    free (mFirstStructDefinition);\r
+    mFirstStructDefinition = NextStruct;\r
+  }\r
+  //\r
+  // Free up the goto references and form id defines\r
+  //\r
+  FreeGotoReferences ();\r
+  //\r
+  // Free up label list\r
+  //\r
+  while (mDefinedLabels != NULL) {\r
+    NextU16List = mDefinedLabels->Next;\r
+    delete (mDefinedLabels);\r
+    mDefinedLabels = NextU16List;\r
+  }\r
+  //\r
+  // Free up the list of defined variable storage IDs\r
+  //\r
+  while (mDefinedVarStoreId != NULL) {\r
+    NextU16List = mDefinedVarStoreId->Next;\r
+    delete (mDefinedVarStoreId);\r
+    mDefinedVarStoreId = NextU16List;\r
+  }\r
+}\r
+\r
+INT32 \r
+EfiVfrParser::AtoX (\r
+  INT8    *HexString, \r
+  INT32   NumBytes, \r
+  UINT32  *HexValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given a pointer to a ascii hex string, convert to a number with the given\r
+  number of bytes.\r
+\r
+Arguments:\r
+  HexString   - pointer to a string of format 30BCA\r
+  Size        - number of bytes to convert\r
+  HexValue    - return result\r
+\r
+Returns:\r
+  The number of bytes converted.\r
+\r
+--*/\r
+{\r
+  INT32 Count;\r
+  INT32 Value;\r
+\r
+  *HexValue = 0;\r
+  Count = 0;\r
+  while (Count < NumBytes) {\r
+    if ((*HexString >= '0') && (*HexString <= '9')) {\r
+      Value = *HexString - '0';\r
+    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
+      Value = *HexString - 'a' + 10;\r
+    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
+      Value = *HexString - 'A' + 10;\r
+    } else {\r
+      return Count;\r
+    }\r
+    HexString++;\r
+    *HexValue = (*HexValue << 4) | Value;\r
+    if ((*HexString >= '0') && (*HexString <= '9')) {\r
+      Value = *HexString - '0';\r
+    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
+      Value = *HexString - 'a' + 10;\r
+    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
+      Value = *HexString - 'A' + 10;\r
+    } else {\r
+      return Count;\r
+    }\r
+    *HexValue = (*HexValue << 4) | Value;\r
+    HexString++;\r
+    Count++;\r
+  }\r
+  return Count;\r
+}\r
+VOID \r
+EfiVfrParser::WriteGuidValue (\r
+  UINT32       TokenLineNum,\r
+  INT8         *G1, \r
+  INT8         *G2,\r
+  INT8         *G3,\r
+  INT8         *G4,\r
+  INT8         *G5,\r
+  INT8         *G6,\r
+  INT8         *G7,\r
+  INT8         *G8,\r
+  INT8         *G9,\r
+  INT8         *G10,\r
+  INT8         *G11\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  A Guid was parsed, likely of format:\r
+  #define MY_GUID { 0x12345678, 0xAABB, 0xCCDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }\r
+\r
+  Write out the value.\r
+\r
+Arguments:\r
+  TokenLineNum   - line number where the guid was used\r
+  G1-G11         - the 11 fields of the guid value\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  UINT32        Value;\r
+  INT32         Loop;\r
+  INT8          *Cptr;\r
+\r
+  mFormSetGuid.Data1 = GetNumber (G1, TokenLineNum, 4);\r
+  mFormSetGuid.Data2 = (UINT16)GetNumber (G2, TokenLineNum, 2);\r
+  mFormSetGuid.Data3 = (UINT16)GetNumber (G3, TokenLineNum, 2);\r
+  mFormSetGuid.Data4[0] = (UINT8)GetNumber (G4, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[1] = (UINT8)GetNumber (G5, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[2] = (UINT8)GetNumber (G6, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[3] = (UINT8)GetNumber (G7, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[4] = (UINT8)GetNumber (G8, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[5] = (UINT8)GetNumber (G9, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[6] = (UINT8)GetNumber (G10, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[7] = (UINT8)GetNumber (G11, TokenLineNum, 1);\r
+  \r
+  WriteDWord (mFormSetGuid.Data1, 'G');\r
+  WriteWord (mFormSetGuid.Data2);\r
+  WriteWord (mFormSetGuid.Data3);\r
+  WriteByte (mFormSetGuid.Data4[0], 0);\r
+  WriteByte (mFormSetGuid.Data4[1], 0);\r
+  WriteByte (mFormSetGuid.Data4[2], 0);\r
+  WriteByte (mFormSetGuid.Data4[3], 0);\r
+  WriteByte (mFormSetGuid.Data4[4], 0);\r
+  WriteByte (mFormSetGuid.Data4[5], 0);\r
+  WriteByte (mFormSetGuid.Data4[6], 0);\r
+  WriteByte (mFormSetGuid.Data4[7], 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteFieldOffset (\r
+  INT8    WriteLength,\r
+  INT8    *StructName, \r
+  INT32   LineNum1, \r
+  INT8    *FieldName, \r
+  INT32   LineNum2,\r
+  INT32   ArrayIndex,\r
+  INT8    IsArrayIndex,\r
+  INT32   FieldWidth,\r
+  INT8    WriteArraySize\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  A VFR script referenced the NV store structure. Given the structure's name\r
+  and the field's name, write the offset of the field to the output file.\r
+\r
+Arguments:\r
+  WriteLength     - write the field length byte out\r
+  StructName      - name of the NV store structure\r
+  LineNum1        - line number in the VFR where we are (for error printing)\r
+  FieldName       - the name of the field within the NV store structure\r
+  LineNum2        - line number in the VFR where FieldName is referenced \r
+  ArrayIndex      - the index specified, for example NV_DATA.Field[ArrayIndex]\r
+  IsArrayIndex    - non-zero if an array index was specified\r
+  FieldWidth      - expected size for the Field (1 byte? 2 bytes?)\r
+  WriteArraySize  - write the size of the entire field, not the size of a single element\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION         *StructDef;\r
+  STRUCT_FIELD_DEFINITION   *FieldDef;\r
+  UINT32                    Offset;\r
+  UINT32                    VarSize;\r
+  INT8                      Msg[100];\r
+  //\r
+  // If we're writing an array size, then they better have referenced the field without an\r
+  // index. \r
+  //\r
+  if (WriteArraySize && IsArrayIndex) {\r
+    sprintf (Msg, "array index specified where an array is required");\r
+    PrintErrorMessage (LineNum2, FieldName, Msg);\r
+    return;\r
+  }\r
+\r
+  //\r
+  // The reference index starts at 1 not 0\r
+  //\r
+  if (IsArrayIndex && (ArrayIndex < 1)) {\r
+    printf ("WARNING: array index shouldn't be less than 1");\r
+  }\r
+  //\r
+  // Look through our list of known structures for a match\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    //\r
+    // Check for matching structure name\r
+    //\r
+    if (strcmp (StructDef->Name, StructName) == 0) {\r
+      //\r
+      // Mark it as referenced (for debug purposes only). Check the\r
+      // flag that indicates that we have already found a varstore VFR\r
+      // statement for it.\r
+      //\r
+      StructDef->Referenced++;\r
+      if (StructDef->VarStoreIdValid == 0) {\r
+        //\r
+        // Set it valid so we don't flag it multiple times, then emit the error\r
+        //\r
+        StructDef->VarStoreIdValid = 1;\r
+        PrintErrorMessage (LineNum1, StructName, "varstore statement missing for this variable store");\r
+      }\r
+      //\r
+      // Let the opcode-handler know which variable storage we're now using\r
+      //\r
+      if (mIdEqIdStmt) {\r
+        mOpcodeHandler.SetSecondaryVarStoreId (StructDef->VarStoreId);\r
+      } else {\r
+        mOpcodeHandler.SetVarStoreId (StructDef->VarStoreId);\r
+      }\r
+      //\r
+      // Found matching structure name. Now find the matching field name\r
+      //\r
+      for (FieldDef = StructDef->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+        if (strcmp (FieldDef->Name, FieldName) == 0) {\r
+          //\r
+          // Make sure the variable size is valid\r
+          //\r
+          if ((FieldWidth != 0) && (FieldDef->DataSize > FieldWidth)) {\r
+            sprintf (Msg, "field width exceeds %d byte%c", FieldWidth, FieldWidth == 1 ? ' ' : 's');\r
+            PrintErrorMessage (LineNum2, FieldName, Msg);\r
+          }\r
+          //\r
+          // If they specified an index (MyVfrData.FieldX[10]), then make sure that the\r
+          // data structure was declared as an array, and that the index is in bounds.\r
+          // If they did not specify an index, then we'll assume 0. This is required for\r
+          // strings.\r
+          //\r
+          if (IsArrayIndex) {\r
+            VarSize = FieldDef->DataSize;\r
+            if (FieldDef->IsArray == 0) {\r
+              PrintErrorMessage (LineNum2, FieldName, "field is not declared as an array");\r
+              return;\r
+            }\r
+            if (FieldDef->ArrayLength < ArrayIndex) {\r
+              PrintErrorMessage (LineNum2, FieldName, "array index exceeds declared size of field");\r
+              return;\r
+            }\r
+          } else {\r
+            if (FieldDef->IsArray) {\r
+              VarSize = FieldDef->DataSize * FieldDef->ArrayLength;\r
+            } else {\r
+              VarSize = FieldDef->DataSize;\r
+            }\r
+          }\r
+          //\r
+          // If we're in the middle of a ideqid VFR statement, then this is the second\r
+          // variable ID that we're now processing. Make sure that its size is the same\r
+          // as the first variable.\r
+          // \r
+          if (mIdEqIdStmt) {\r
+            if (mLastVarIdSize != VarSize) {\r
+              PrintErrorMessage (LineNum2, FieldName, "variables must have the same size");\r
+              return;\r
+            }\r
+          }\r
+          mLastVarIdSize = VarSize;\r
+          //\r
+          // If we're supposed to write an array size, then require it to be an array\r
+          //\r
+          if (WriteArraySize && !FieldDef->IsArray) {\r
+            PrintErrorMessage (LineNum2, FieldName, "array required");\r
+            return;\r
+          }\r
+          //\r
+          // Write the variable offset and size. If we're in the non-NV structure, then\r
+          // set the offset beyond the NV data structure size.\r
+          //\r
+          Offset = FieldDef->Offset + FieldDef->DataSize * (ArrayIndex - 1);\r
+          if (StructDef->IsNonNV) Offset += mNvDataStructSize; \r
+          WriteWord (Offset);\r
+          if (WriteLength) {\r
+            if (WriteArraySize) {\r
+              if (FieldDef->DataSize * FieldDef->ArrayLength > 255) {\r
+                PrintErrorMessage (LineNum2, FieldName, "array size exceeds 255 maximum encoding limit");\r
+                return;\r
+              }\r
+              WriteByte (FieldDef->DataSize * FieldDef->ArrayLength, 0);\r
+            } else {\r
+              WriteByte (FieldDef->DataSize, 0);\r
+            }\r
+          }\r
+          return;\r
+        }\r
+      }\r
+      sprintf (Msg, "structure %s does not have a field named '%s'", StructName, FieldName);\r
+      PrintErrorMessage (LineNum2, Msg, NULL);\r
+      PrintErrorMessage (StructDef->LineNum, "see structure definition", NULL);\r
+      return;\r
+    }\r
+  }\r
+  //\r
+  // The structure was not found in the defined list. See if it's the "Date" structure\r
+  //\r
+  if (strcmp (StructName, "Date") == 0) {\r
+    //\r
+    // BUGBUG -- remove support for Date and Time as valid structure \r
+    // names. They should use the NON_NV_DATA_MAP structure for this.\r
+    //\r
+    // Someone specified Date.Years|Months|Days\r
+    // BUGBUG -- define some constants for the IDs used here\r
+    // Length == 0 implies that this is not user NV data storage.\r
+    //\r
+    if (strcmp (FieldName, "Year") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 0);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Month") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 2);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Day") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 4);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else {\r
+      PrintErrorMessage (LineNum1, FieldName, "expected valid field name TheYear/TheMonth/TheDay");\r
+    }\r
+    return;\r
+  } else if (strcmp (StructName, "Time") == 0) {\r
+    //\r
+    // Someone specified Time.Hours|Minutes|Seconds\r
+    // BUGBUG -- define some constants for the IDs used here\r
+    //\r
+    if (strcmp (FieldName, "Hours") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 6);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Minutes") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 8);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Seconds") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 10);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else {\r
+      PrintErrorMessage (LineNum1, FieldName, "expected valid field name Hours/Minutes/Seconds");\r
+    }\r
+    return;\r
+  } else {\r
+    PrintErrorMessage (LineNum1, StructName, "undefined structure");\r
+    return;\r
+  }\r
+}\r
+VOID\r
+EfiVfrParser::StartStructDefinition (\r
+  INT32  IsNonNV,\r
+  INT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called when we encounter a new "struct _MY_STRUCT..." statement while parsing. \r
+  Initialize internal data and structures for parsing the fields of the structure.\r
+\r
+Arguments:\r
+  LineNum  - line number in the source file (for error reporting purposes)\r
+  IsNonNv  - flag indicating (if nonzero) that the variable referred to is not in\r
+             the standard NV store.\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION *StructDef;\r
+  //\r
+  // Allocate memory for the structure record\r
+  //\r
+  StructDef = (STRUCT_DEFINITION *)malloc (sizeof (STRUCT_DEFINITION));\r
+  memset (StructDef, 0, sizeof (STRUCT_DEFINITION));\r
+  StructDef->LineNum = LineNum;\r
+  //\r
+  // Set flag indicating non-NV data structure or not\r
+  //\r
+  StructDef->IsNonNV = IsNonNV;\r
+  //\r
+  // Add it to the end of our linked list. If it's the first one\r
+  // defined, then it's the default varstore ID, so set it valid.\r
+  //\r
+  if (mFirstStructDefinition == NULL) {\r
+    mFirstStructDefinition = StructDef;\r
+    StructDef->VarStoreIdValid = 1;\r
+  } else {\r
+    mLastStructDefinition->Next = StructDef;\r
+  }\r
+  mLastStructDefinition = StructDef;\r
+}\r
+VOID\r
+EfiVfrParser::EndStructDefinition (\r
+  INT8   *StructName,\r
+  INT32  LineNum\r
+  )\r
+{\r
+  STRUCT_DEFINITION         *StructDef;\r
+  STRUCT_FIELD_DEFINITION   *FieldDef;\r
+  UINT32                    Offset;\r
+  //\r
+  // Make sure they have not already defined a structure with this name\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    if ((StructDef->Name != NULL) && (strcmp (StructDef->Name, StructName) == 0)) {\r
+      PrintErrorMessage (LineNum, StructName, "structure with this name already defined");\r
+      //\r
+      // Fall through and fill in the rest of the structure information. We do\r
+      // this because the structure has already been added to our global list,\r
+      // so will be used elsewhere, so we want it to contain valid fields.\r
+      //\r
+    }\r
+  }    \r
+  //\r
+  // Allocate memory for the structure name \r
+  //\r
+  mLastStructDefinition->Name = (char *)malloc (strlen (StructName) + 1);\r
+  strcpy (mLastStructDefinition->Name, StructName);\r
+  //\r
+  // Compute the structure size, and the offsets to each field\r
+  //\r
+  Offset = 0;\r
+  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+    FieldDef->Offset = Offset;\r
+    Offset += FieldDef->ArrayLength * FieldDef->DataSize;\r
+  }\r
+  mLastStructDefinition->Size = Offset;\r
+  //\r
+  // Go through all the structure we have so far and figure out (if we can)\r
+  // the size of the non-NV storage. We also assume that the first structure\r
+  // definition is the primary/default storage for the VFR form.\r
+  //\r
+  if (mNonNvDataStructSize == 0) {\r
+    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+      if (StructDef->IsNonNV) {\r
+        mNonNvDataStructSize = StructDef->Size;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  if (mNvDataStructSize == 0) {\r
+    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+      if (StructDef->IsNonNV == 0) {\r
+        mNvDataStructSize = StructDef->Size;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::AddStructField (\r
+  INT8    *FieldName, \r
+  INT32   LineNum, \r
+  INT32   DataSize,\r
+  INT32   ArrayLength,\r
+  INT8    IsArray\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  We're parsing the VFR structure definition. Add another defined field to \r
+  our definition.\r
+\r
+Arguments:\r
+  FieldName   - name of the field in the structure.\r
+  LineNum     - the line number from the input (preprocessor output) file\r
+  DataSize    - the size of the field (1, 2, or 4 bytes)\r
+  ArrayLength - the number of elements (for array)\r
+  IsArray     - non-zero if the field is an array\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_FIELD_DEFINITION *FieldDef;\r
+  STRUCT_FIELD_DEFINITION *Temp;\r
+  //\r
+  // Make sure we don't already have a field of this name in our structure\r
+  //\r
+  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+    if (strcmp (FieldDef->Name, FieldName) == 0) {\r
+      PrintErrorMessage (LineNum, FieldName, "field with this name already defined");\r
+      return;\r
+    }\r
+  } \r
+  //\r
+  // If it's an array, then they better not have a size of 0. For example:\r
+  //   UINT8 MyBytes[0];\r
+  //\r
+  if (IsArray && (ArrayLength <= 0)) {\r
+    PrintErrorMessage (LineNum, FieldName, "invalid array size");\r
+    return;\r
+  }    \r
+  //\r
+  // Allocate memory for a new structure field definition\r
+  //    \r
+  FieldDef = (STRUCT_FIELD_DEFINITION *)malloc (sizeof (STRUCT_FIELD_DEFINITION));\r
+  memset ((char *)FieldDef, 0, sizeof (STRUCT_FIELD_DEFINITION));\r
+  FieldDef->ArrayLength  = ArrayLength;\r
+  FieldDef->DataSize     = DataSize;\r
+  FieldDef->IsArray      = IsArray;\r
+  FieldDef->Name = (char *)malloc (strlen (FieldName) + 1);\r
+  strcpy (FieldDef->Name, FieldName);\r
+  //\r
+  // Add it to the end of the field list for the currently active structure\r
+  //\r
+  if (mLastStructDefinition->Field == NULL) {\r
+    mLastStructDefinition->Field = FieldDef;\r
+  } else {\r
+    mLastStructDefinition->LastField->Next = FieldDef;\r
+  }\r
+  mLastStructDefinition->LastField = FieldDef;\r
+}\r
+VOID\r
+EfiVfrParser::AddVarStore (\r
+  INT8   *StructName,       // actual name of the structure\r
+  INT8   *VarName,          // actual NV variable name\r
+  UINT16 VarStoreId,        // key value\r
+  INT32  LineNum            // parse line number (for error reporting)\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called while parsing a varstore statement. Add the variable store \r
+  to our linked list.\r
+\r
+Arguments:\r
+  StructName    - the name of the typedef'ed structure to use\r
+  VarName       - the NV variable name as specified in the varstore statement\r
+  VarStoreId    - the variable store ID as specified in the varstore statememt\r
+  LineNum       - the line number from the input (preprocessor output) file\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION *StructDef;\r
+  UINT16_LIST       *L16Ptr;\r
+  //\r
+  // Go through our list of previously-defined variable store IDs and\r
+  // make sure this one is not a duplicate in name or key value.\r
+  //\r
+  for (L16Ptr = mDefinedVarStoreId; L16Ptr != NULL; L16Ptr = L16Ptr->Next) {\r
+    if (L16Ptr->Value == VarStoreId) {\r
+      PrintErrorMessage (LineNum, "variable storage key already used", NULL);\r
+      PrintErrorMessage (L16Ptr->LineNum, "previous usage of storage key", NULL);\r
+    }\r
+  }\r
+  // \r
+  // Key value of 0 is invalid since that's assigned by default to the default\r
+  // variable store (the first structure parsed).\r
+  //\r
+  if (VarStoreId == 0) {\r
+    PrintErrorMessage (LineNum, "variable storage key of 0 is invalid", NULL);\r
+  }\r
+  //\r
+  // Create a new element to add to the list\r
+  //\r
+  L16Ptr = (UINT16_LIST *)malloc(sizeof (UINT16_LIST));\r
+  memset (L16Ptr, 0, sizeof (UINT16_LIST));\r
+  L16Ptr->LineNum = LineNum;\r
+  L16Ptr->Value = VarStoreId;\r
+  if (mDefinedVarStoreId == NULL) {\r
+    mDefinedVarStoreId = L16Ptr;\r
+  } else {\r
+    mLastDefinedVarStoreId->Next = L16Ptr;\r
+  }\r
+  mLastDefinedVarStoreId = L16Ptr;\r
+  //\r
+  // Find the structure definition with this name\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    if (strcmp (StructDef->Name, StructName) == 0) {\r
+      //\r
+      // Make sure they did not already define a variable storage ID \r
+      // for this structure.\r
+      //\r
+      if (StructDef->VarStoreId != 0) {\r
+        PrintErrorMessage (LineNum, StructName, "variable storage already defined for this structure");\r
+        PrintErrorMessage (StructDef->VarStoreLineNum, StructName, "previous definition for variable storage");\r
+      }\r
+      StructDef->VarStoreId       = VarStoreId;\r
+      StructDef->VarStoreIdValid  = 1;\r
+      StructDef->VarStoreLineNum  = LineNum;\r
+      WriteWord (StructDef->Size);\r
+      while (*VarName) {\r
+        WriteByte(*VarName, 0);\r
+        VarName++;\r
+      }\r
+      WriteByte(0,0);\r
+      return;\r
+    }\r
+  }    \r
+  PrintErrorMessage (LineNum, StructName, "structure with this name not defined");\r
+}\r
+VOID \r
+EfiVfrParser::WriteDWord (\r
+  UINT32    Value, \r
+  UINT8     KeyByte\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During parsing, we came upon some code that requires a 32-bit value be\r
+  written to the VFR binary file. Queue up the 4 bytes.\r
+\r
+Arguments:\r
+  Value   - the 32-bit value to write\r
+  KeyByte - a single character which gets written out beside the first byte.\r
+            This is used to tag the data in the output file so that during \r
+            debug you have an idea what the value is.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Write 4 bytes, little endian. Specify a key byte only on the first one\r
+  //\r
+  mOpcodeHandler.AddByte ((UINT8)Value, KeyByte);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteOpByte (\r
+  UINT32    LineNum,\r
+  UINT8     ByteValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  During parsing, we came upon a new VFR opcode. At this point we flush\r
+  the output queue and then queue up this byte (with 'O' for opcode tag).\r
+\r
+Arguments:\r
+\r
+  ByteValue   - opcode value\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddOpcodeByte (ByteValue, LineNum);\r
+}\r
+VOID \r
+EfiVfrParser::WriteByte (\r
+  UINT8   ByteValue, \r
+  UINT8   Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  During parsing of the VFR we spoonfeed this function with bytes to write to\r
+  the output VFR binary file. This function simply queues up the bytes, and\r
+  the queue gets flushed each time a new VFR opcode is encountered.\r
+\r
+Arguments:\r
+\r
+  ByteValue   - raw byte to write\r
+  Key         - character to tag the byte with when we write ByteValue to the\r
+                output file.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddByte (ByteValue, Key);\r
+}\r
+VOID \r
+EfiVfrParser::WriteWord (\r
+  UINT32  Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During VFR parsing we came upon a case where we need to write out a \r
+  16-bit value. Queue it up.\r
+\r
+Arguments:\r
+  Value - value to write.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  mOpcodeHandler.AddByte ((UINT8)((Value \>> 8) & 0xFF), 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteStringIdWord (\r
+  UINT16 WordValue\r
+  )\r
+{\r
+  mOpcodeHandler.AddByte ((UINT8)WordValue, 'S');\r
+  mOpcodeHandler.AddByte ((UINT8)((WordValue \>> 8) & 0xFF), 0);\r
+}\r
+VOID\r
+EfiVfrParser::FreeGotoReferences ()\r
+/*++\r
+\r
+Routine Description:\r
+  Called during cleanup to free up the memory we allocated when\r
+  keeping track of VFR goto statements.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  GOTO_REFERENCE  *CurrRef;\r
+  GOTO_REFERENCE  *NextRef;\r
+  FORM_ID_VALUE   *CurrFormId;\r
+  FORM_ID_VALUE   *NextFormId;\r
+  UINT8           Found;\r
+  INT8            Name[20];\r
+\r
+  //\r
+  // Go through all the "goto" references and make sure there was a \r
+  // form ID of that value defined.\r
+  //\r
+  for (CurrRef = mGotoReferences; CurrRef != NULL; CurrRef = CurrRef->Next) {\r
+    Found = 0;\r
+    for (CurrFormId = mFormIdValues; CurrFormId != NULL; CurrFormId = CurrFormId->Next) {\r
+      if (CurrRef->Value == CurrFormId->Value) {\r
+        Found = 1;\r
+        break;\r
+      }\r
+    }\r
+    if (!Found) {\r
+      sprintf (Name, "%d", (UINT32)CurrRef->Value);\r
+      PrintErrorMessage (CurrRef->RefLineNum, Name, "undefined form ID");\r
+    }  \r
+  }  \r
+  //\r
+  // Now free up the form id and goto references\r
+  //\r
+  CurrFormId = mFormIdValues;\r
+  while (CurrFormId != NULL) {\r
+    NextFormId = CurrFormId->Next;\r
+    free (CurrFormId);\r
+    CurrFormId = NextFormId;\r
+  }\r
+  mFormIdValues = NULL;\r
+  CurrRef = mGotoReferences;\r
+  while (CurrRef != NULL) {\r
+    NextRef = CurrRef->Next;\r
+    free (CurrRef);\r
+    CurrRef = NextRef;\r
+  }  \r
+  mGotoReferences = NULL;\r
+}\r
+VOID\r
+EfiVfrParser::AddGotoReference (\r
+  UINT32  GotoNumber,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During VFR parsing we came upon a goto statement. Since we support\r
+  forward references, save the referenced label and at the end of parsing\r
+  we'll check that the label was actually defined somewhere.\r
+\r
+Arguments:\r
+  GotoNumber  - the label number referenced\r
+  LineNum     - the line number where the reference was made (used for\r
+                error reporting)\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  GOTO_REFERENCE *NewRef;\r
+  \r
+  NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));\r
+  if (NewRef == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    return;\r
+  }\r
+  memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));\r
+  NewRef->Value = (UINT16)GotoNumber;\r
+  NewRef->RefLineNum = LineNum;\r
+  NewRef->Next = mGotoReferences;\r
+  mGotoReferences = NewRef;\r
+}\r
+VOID\r
+EfiVfrParser::AddFormId (\r
+  INT32   FormIdValue,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is called when we parse "form formid = 3" statements.\r
+  We save the form ID valud so we can verify that duplicates are not\r
+  defined. Also, these are the targets of goto statements, so when we're\r
+  done parsing the script we also go through all the goto statements to\r
+  check that there was a target FormId defined as referenced by each\r
+  goto statement.\r
+  \r
+  Note that formid = 0 is invalid.\r
+\r
+Arguments:\r
+  FormIdValue  - the parsed value for the Form ID\r
+  LineNum      - line number of the source file we're parsing\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  FORM_ID_VALUE *NewFormId;\r
+  char          *FileName;\r
+  char          *FileName2;\r
+  UINT32        LineNum2;  \r
+  //\r
+  // Verify that FormId != 0\r
+  //\r
+  if (FormIdValue == 0) {\r
+    FileName = ConvertLineNumber (&LineNum);\r
+    Error (FileName, LineNum, 0, "form ID cannot be 0", NULL);\r
+    return;\r
+  }\r
+  //\r
+  // First go through all previously defined form IDs and make sure they have not defined\r
+  // duplicates.\r
+  //\r
+  for (NewFormId = mFormIdValues; NewFormId != NULL; NewFormId = NewFormId->Next) {\r
+    if ((UINT16)FormIdValue == NewFormId->Value) {\r
+      FileName = ConvertLineNumber (&LineNum);\r
+      LineNum2 = NewFormId->LineNum;\r
+      FileName2 = ConvertLineNumber (&LineNum2);\r
+      Error (FileName, LineNum, 0, NULL, "form ID %d already defined", FormIdValue);\r
+      Error (FileName2, LineNum2, 0, NULL, "form ID %d previous definition", FormIdValue);\r
+      return;\r
+    }\r
+  }\r
+  //\r
+  // Allocate memory for a new one \r
+  //\r
+  NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));\r
+  if (NewFormId == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    return;\r
+  }\r
+  memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));\r
+  NewFormId->LineNum = LineNum;\r
+  NewFormId->Next = mFormIdValues;\r
+  NewFormId->Value = (UINT16)FormIdValue;\r
+  mFormIdValues = NewFormId;\r
+}\r
+UINT32\r
+EfiVfrParser::GetNumber (\r
+  INT8    *NumStr,\r
+  UINT32  LineNum,\r
+  UINT32  NumBytes\r
+  )\r
+{\r
+  UINT32 Value;\r
+  \r
+  if ((NumStr[0] == '0') && (NumStr[1] == 'x')) {\r
+    AtoX (NumStr + 2, 4, &Value);\r
+  } else {\r
+    Value = (UINT32)atoi (NumStr);\r
+  }\r
+  //\r
+  // Check range\r
+  //\r
+  if ((NumBytes < 4) && (Value & ((UINT32)0xFFFFFFFF << (NumBytes * 8)))) {\r
+    PrintErrorMessage (LineNum, NumStr, "value out of range");\r
+    return 0;\r
+  }\r
+  return Value;\r
+}\r
+\r
+>>\r
+\r
+} // end grammar class\r
+\r
+\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
new file mode 100644 (file)
index 0000000..e9c54d3
--- /dev/null
@@ -0,0 +1,754 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrServices.cpp\r
+\r
+Abstract:\r
+\r
+  Support routines for the VFR compiler\r
+  \r
+--*/  \r
+\r
+#include <stdio.h>    // for FILE routines\r
+#include <stdlib.h>   // for malloc() and free()\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiVfr.h"\r
+#include "VfrServices.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (Hii)\r
+\r
+static const char *mSourceFileHeader[] = {\r
+  "//",\r
+  "//  DO NOT EDIT -- auto-generated file",\r
+  "//",\r
+  "//  This file is generated by the VFR compiler.",\r
+  "//",\r
+  NULL\r
+};\r
+\r
+typedef struct {\r
+   INT8     *Name;\r
+   INT32    Size;\r
+} IFR_OPCODE_SIZES;\r
+\r
+//\r
+// Create a table that can be used to do internal checking on the IFR\r
+// bytes we emit.\r
+//\r
+static const IFR_OPCODE_SIZES mOpcodeSizes[] = {\r
+  { 0, 0 },     // invalid\r
+  { "EFI_IFR_FORM",                       sizeof (EFI_IFR_FORM) },\r
+  { "EFI_IFR_SUBTITLE",                   sizeof (EFI_IFR_SUBTITLE) }, \r
+  { "EFI_IFR_TEXT",                       -6 }, //sizeof (EFI_IFR_TEXT) }, \r
+  { "unused 0x04 opcode",                 0 }, // EFI_IFR_GRAPHIC_OP\r
+  { "EFI_IFR_ONE_OF",                     sizeof (EFI_IFR_ONE_OF) }, \r
+  { "EFI_IFR_CHECK_BOX",                  sizeof (EFI_IFR_CHECK_BOX) }, \r
+  { "EFI_IFR_NUMERIC",                    sizeof (EFI_IFR_NUMERIC) }, \r
+  { "EFI_IFR_PASSWORD",                   sizeof (EFI_IFR_PASSWORD) }, \r
+  { "EFI_IFR_ONE_OF_OPTION",              sizeof (EFI_IFR_ONE_OF_OPTION) }, \r
+  { "EFI_IFR_SUPPRESS",                   sizeof (EFI_IFR_SUPPRESS) }, \r
+  { "EFI_IFR_END_FORM",                   sizeof (EFI_IFR_END_FORM) }, \r
+  { "EFI_IFR_HIDDEN",                     sizeof (EFI_IFR_HIDDEN) }, \r
+  { "EFI_IFR_END_FORM_SET",               sizeof (EFI_IFR_END_FORM_SET) }, \r
+  { "EFI_IFR_FORM_SET",                   sizeof (EFI_IFR_FORM_SET) }, \r
+  { "EFI_IFR_REF",                        sizeof (EFI_IFR_REF) }, \r
+  { "EFI_IFR_END_ONE_OF",                 sizeof (EFI_IFR_END_ONE_OF) }, \r
+  { "EFI_IFR_INCONSISTENT",               sizeof (EFI_IFR_INCONSISTENT) }, \r
+  { "EFI_IFR_EQ_ID_VAL",                  sizeof (EFI_IFR_EQ_ID_VAL) }, \r
+  { "EFI_IFR_EQ_ID_ID",                   sizeof (EFI_IFR_EQ_ID_ID) }, \r
+  { "EFI_IFR_EQ_ID_LIST",                 -sizeof (EFI_IFR_EQ_ID_LIST) }, \r
+  { "EFI_IFR_AND",                        sizeof (EFI_IFR_AND) }, \r
+  { "EFI_IFR_OR",                         sizeof (EFI_IFR_OR) }, \r
+  { "EFI_IFR_NOT",                        sizeof (EFI_IFR_NOT) }, \r
+  { "EFI_IFR_END_IF",                     sizeof (EFI_IFR_END_IF) }, \r
+  { "EFI_IFR_GRAYOUT",                    sizeof (EFI_IFR_GRAYOUT) }, \r
+  { "EFI_IFR_DATE",                       sizeof (EFI_IFR_DATE) / 3 }, \r
+  { "EFI_IFR_TIME",                       sizeof (EFI_IFR_TIME) / 3 }, \r
+  { "EFI_IFR_STRING",                     sizeof (EFI_IFR_STRING) }, \r
+  { "EFI_IFR_LABEL",                      sizeof (EFI_IFR_LABEL) }, \r
+  { "EFI_IFR_SAVE_DEFAULTS",              sizeof (EFI_IFR_SAVE_DEFAULTS) }, \r
+  { "EFI_IFR_RESTORE_DEFAULTS",           sizeof (EFI_IFR_RESTORE_DEFAULTS) }, \r
+  { "EFI_IFR_BANNER",                     sizeof (EFI_IFR_BANNER) },\r
+  { "EFI_IFR_INVENTORY",                  sizeof (EFI_IFR_INVENTORY) },\r
+  { "EFI_IFR_EQ_VAR_VAL_OP",              sizeof (EFI_IFR_EQ_VAR_VAL) },\r
+  { "EFI_IFR_ORDERED_LIST_OP",            sizeof (EFI_IFR_ORDERED_LIST) },\r
+  { "EFI_IFR_VARSTORE_OP",                -sizeof (EFI_IFR_VARSTORE) },\r
+  { "EFI_IFR_VARSTORE_SELECT_OP",         sizeof (EFI_IFR_VARSTORE_SELECT) },\r
+  { "EFI_IFR_VARSTORE_SELECT_PAIR_OP",    sizeof (EFI_IFR_VARSTORE_SELECT_PAIR) },\r
+  { "EFI_IFR_TRUE",                       sizeof (EFI_IFR_TRUE)},\r
+  { "EFI_IFR_FALSE",                      sizeof (EFI_IFR_FALSE)},\r
+  { "EFI_IFR_GT",                         sizeof (EFI_IFR_GT)},\r
+  { "EFI_IFR_GE",                         sizeof (EFI_IFR_GE)},\r
+  { "EFI_IFR_OEM_DEFINED_OP",             -2 },\r
+};\r
+\r
+\r
+VfrOpcodeHandler::VfrOpcodeHandler (\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Constructor for the VFR opcode handling class.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{ \r
+  mIfrBytes                       = NULL; \r
+  mLastIfrByte                    = NULL;\r
+  mBytesWritten                   = 0;\r
+  mQueuedByteCount                = 0;\r
+  mQueuedOpcodeByteValid          = 0;\r
+  mPrimaryVarStoreId              = 0;\r
+  mSecondaryVarStoreId            = 0;\r
+  mSecondaryVarStoreIdSet         = 0;\r
+  mPrimaryVarStoreIdSet           = 0;\r
+  mDefaultVarStoreId              = 0;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::SetVarStoreId (\r
+  UINT16 VarStoreId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a variable is referenced in the \r
+  VFR. Save the variable store (and set a flag) so that we can later determine \r
+  if we need to emit a varstore-select or varstore-select-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mPrimaryVarStoreId    = VarStoreId;\r
+  mPrimaryVarStoreIdSet = 1;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::SetSecondaryVarStoreId (\r
+  UINT16 VarStoreId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a secondary variable is \r
+  referenced in the VFR. Save the variable store (and set a flag) so \r
+  that we can later determine if we need to emit a varstore-select or \r
+  varstore-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mSecondaryVarStoreId    = VarStoreId;\r
+  mSecondaryVarStoreIdSet = 1;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::WriteIfrBytes (\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked at the end of parsing. Its purpose\r
+  is to write out all the IFR bytes that were queued up while\r
+  parsing.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{ \r
+  IFR_BYTE                  *Curr;\r
+  IFR_BYTE                  *Next;\r
+  UINT32                    Count;\r
+  UINT32                    LineCount;\r
+  UINT32                    PoundLines;\r
+  UINT32                    ByteCount;\r
+  INT8                      Line[MAX_LINE_LEN];\r
+  INT8                      *Cptr;\r
+  FILE                      *InFptr;\r
+  FILE                      *OutFptr;\r
+  UINT32                    ListFile;\r
+  EFI_HII_IFR_PACK_HEADER   IfrHeader;\r
+  UINT8                     *Ptr;\r
+  FILE                      *IfrBinFptr;\r
+  UINT32                    BytesLeftThisOpcode;\r
+  //\r
+  // If someone added a new opcode and didn't update our opcode sizes structure, error out.\r
+  //\r
+  if (sizeof(mOpcodeSizes) / sizeof (mOpcodeSizes[0]) != EFI_IFR_LAST_OPCODE + 1) {\r
+    Error (__FILE__, __LINE__, 0, "application error", "internal IFR binary table size is incorrect");\r
+    return;\r
+  }\r
+  //\r
+  // Flush the queue\r
+  //\r
+  FlushQueue ();    \r
+  //\r
+  // If there have been any errors to this point, then skip dumping the IFR\r
+  // binary data. This way doing an nmake again will try to build it again, and\r
+  // the build will fail if they did not fix the problem.\r
+  //\r
+  if (GetUtilityStatus () != STATUS_ERROR) {\r
+    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      return;\r
+    }\r
+    //\r
+    // Write the standard file header to the output file\r
+    //\r
+    WriteStandardFileHeader (IfrBinFptr);\r
+    //\r
+    // Write the structure header\r
+    //\r
+    fprintf (IfrBinFptr, "\nunsigned char %sBin[] = {", gOptions.VfrBaseFileName);\r
+    //\r
+    // Write the header\r
+    //\r
+    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
+    IfrHeader.Header.Type = EFI_HII_IFR;\r
+    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
+    Ptr = (UINT8 *)&IfrHeader;\r
+    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
+      if ((Count & 0x03) == 0) {\r
+        fprintf (IfrBinFptr, "\n  ");\r
+      }\r
+      fprintf (IfrBinFptr, "0x%02X, ", *Ptr);      \r
+    }\r
+    //\r
+    //\r
+    // Write all the IFR bytes\r
+    //\r
+    fprintf (IfrBinFptr, "\n  // start of IFR data");\r
+    Curr = mIfrBytes;\r
+    Count = 0;\r
+    while (Curr != NULL) {\r
+      if ((Count & 0x0F) == 0) {\r
+        fprintf (IfrBinFptr, "\n  ");\r
+      }\r
+      if (Curr->KeyByte != 0) {\r
+        fprintf (IfrBinFptr, "/*%c*/ ", Curr->KeyByte);\r
+      }\r
+      fprintf (IfrBinFptr, "0x%02X, ", Curr->OpcodeByte);\r
+      Count++;\r
+      Curr = Curr->Next;\r
+    }\r
+    fprintf (IfrBinFptr, "\n};\n\n");\r
+    //\r
+    //\r
+    // Close the file\r
+    //\r
+    fclose (IfrBinFptr); \r
+    IfrBinFptr = NULL;\r
+  }\r
+  //\r
+  // Write the bytes as binary data if the user specified to do so\r
+  //\r
+  if ((GetUtilityStatus () != STATUS_ERROR) &&  (gOptions.CreateIfrBinFile != 0)) {\r
+    //\r
+    // Use the Ifr output file name with a ".hpk" extension.\r
+    //\r
+    for (Cptr = gOptions.IfrOutputFileName + strlen (gOptions.IfrOutputFileName) - 1;\r
+         (*Cptr != '.') && (Cptr > gOptions.IfrOutputFileName) && (*Cptr != '\\');\r
+         Cptr--) {\r
+      //\r
+      // do nothing\r
+      //\r
+    }\r
+    if (*Cptr == '.') {\r
+      strcpy (Cptr, ".hpk");\r
+    } else {\r
+      strcat (gOptions.IfrOutputFileName, ".hpk");\r
+    }\r
+    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      return;\r
+    }\r
+    //\r
+    // Write the structure header\r
+    //\r
+    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
+    IfrHeader.Header.Type = EFI_HII_IFR;\r
+    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
+    Ptr = (UINT8 *)&IfrHeader;\r
+    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
+      fwrite (Ptr, 1, 1, IfrBinFptr);\r
+    }\r
+    //\r
+    //\r
+    // Write all the IFR bytes\r
+    //\r
+    Curr = mIfrBytes;\r
+    Count = 0;\r
+    while (Curr != NULL) {\r
+      fwrite (&Curr->OpcodeByte, 1, 1, IfrBinFptr);\r
+      Curr = Curr->Next;\r
+    }\r
+    //\r
+    //\r
+    // Close the file\r
+    //\r
+    fclose (IfrBinFptr); \r
+    IfrBinFptr = NULL;\r
+  }\r
+  //\r
+  // If creating a listing file, then open the input and output files\r
+  //\r
+  ListFile = 0;\r
+  if (gOptions.CreateListFile) {\r
+    //\r
+    // Open the input VFR file and the output list file\r
+    //\r
+    if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
+      Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");\r
+    } else {\r
+      if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {\r
+        Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");\r
+        fclose (InFptr);\r
+        InFptr = NULL;\r
+      } else {\r
+        LineCount   = 0;\r
+        ListFile    = 1;\r
+        PoundLines  = 0;\r
+        ByteCount   = 0;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Write the list file\r
+  //\r
+  if (ListFile) {\r
+    //\r
+    // Write out the VFR compiler version\r
+    //\r
+    fprintf (OutFptr, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+    Curr = mIfrBytes;\r
+    while (Curr != NULL) {\r
+      //\r
+      // Print lines until we reach the line of the current opcode\r
+      //\r
+      while (LineCount < PoundLines + Curr->LineNum) {\r
+        if (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
+          //\r
+          // We should check for line length exceeded on the fgets(). Otherwise it\r
+          // throws the listing file output off. Future enhancement perhaps.\r
+          //\r
+          fprintf (OutFptr, "%s", Line);\r
+          if (strncmp (Line, "#line", 5) == 0) {\r
+            PoundLines++;\r
+          }\r
+        }\r
+        LineCount++;\r
+      }\r
+      //\r
+      // Print all opcodes with line numbers less than where we are now\r
+      //\r
+      BytesLeftThisOpcode = 0;\r
+      while ((Curr != NULL) && ((Curr->LineNum == 0) || (LineCount >= PoundLines + Curr->LineNum))) {\r
+        if (BytesLeftThisOpcode == 0) {\r
+          fprintf (OutFptr, ">%08X: ", ByteCount);\r
+          if (Curr->Next != NULL) {\r
+            BytesLeftThisOpcode = (UINT32)Curr->Next->OpcodeByte;\r
+          }\r
+        }\r
+        fprintf (OutFptr, "%02X ", (UINT32)Curr->OpcodeByte);\r
+        ByteCount++;\r
+        BytesLeftThisOpcode--;\r
+        if (BytesLeftThisOpcode == 0) {\r
+          fprintf (OutFptr, "\n");\r
+        }\r
+        Curr = Curr->Next;\r
+      }\r
+    }\r
+    //\r
+    // Dump any remaining lines from the input file\r
+    //\r
+    while (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
+      fprintf (OutFptr, "%s", Line);\r
+    }\r
+    fclose (InFptr);\r
+    fclose (OutFptr);\r
+  }\r
+  //\r
+  // Debug code to make sure that each opcode we write out has as many\r
+  // bytes as the IFR structure requires. If there were errors, then\r
+  // don't do this step.\r
+  //\r
+  if (GetUtilityStatus () != STATUS_ERROR) {\r
+    Curr = mIfrBytes;\r
+    ByteCount = 0;\r
+    while (Curr != NULL) {\r
+      //\r
+      // First byte is the opcode, second byte is the length\r
+      //\r
+      if (Curr->Next == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "last opcode written does not contain a length byte");\r
+        break;\r
+      }\r
+      Count = (UINT32)Curr->Next->OpcodeByte;\r
+      if (Count == 0) {\r
+        Error (\r
+          __FILE__, \r
+          __LINE__, \r
+          0, \r
+          "application error", \r
+          "opcode with 0 length specified in output at offset 0x%X", \r
+          ByteCount\r
+          );\r
+        break;\r
+      }\r
+      //\r
+      // Check the length\r
+      //\r
+      if ((Curr->OpcodeByte > EFI_IFR_LAST_OPCODE) || (Curr->OpcodeByte == 0)) {\r
+        Error (\r
+          __FILE__, \r
+          __LINE__, \r
+          0, \r
+          "application error", \r
+          "invalid opcode 0x%X in output at offset 0x%X", \r
+          (UINT32) Curr->OpcodeByte, ByteCount\r
+          );\r
+      } else if (mOpcodeSizes[Curr->OpcodeByte].Size < 0) {\r
+        //\r
+        // For those cases where the length is variable, the size is negative, and indicates\r
+        // the miniumum size.\r
+        //\r
+        if ((mOpcodeSizes[Curr->OpcodeByte].Size * -1) > Count) {\r
+          Error (\r
+            __FILE__, \r
+            __LINE__, \r
+            0, \r
+            "application error", \r
+            "insufficient number of bytes written for %s at offset 0x%X",\r
+            mOpcodeSizes[Curr->OpcodeByte].Name, \r
+            ByteCount\r
+            );\r
+        }\r
+      } else {\r
+        //\r
+        // Check for gaps\r
+        //\r
+        if (mOpcodeSizes[Curr->OpcodeByte].Size == 0) {\r
+          Error (\r
+            __FILE__, \r
+            __LINE__, \r
+            0, \r
+            "application error", \r
+            "invalid opcode 0x%X in output at offset 0x%X", \r
+            (UINT32)Curr->OpcodeByte, \r
+            ByteCount\r
+            );\r
+        } else {\r
+          //\r
+          // Check size\r
+          //\r
+          if (mOpcodeSizes[Curr->OpcodeByte].Size != Count) {\r
+            Error (\r
+              __FILE__, \r
+              __LINE__, \r
+              0, \r
+              "application error", \r
+              "invalid number of bytes (%d written s/b %d) written for %s at offset 0x%X",\r
+              Count, \r
+              mOpcodeSizes[Curr->OpcodeByte].Size, \r
+              mOpcodeSizes[Curr->OpcodeByte].Name, \r
+              ByteCount\r
+              );\r
+          }\r
+        }\r
+      }\r
+      //\r
+      // Skip to next opcode\r
+      //\r
+      while (Count > 0) {\r
+        ByteCount++;\r
+        if (Curr == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "application error", "last opcode written has invalid length");\r
+          break;\r
+        }\r
+        Curr = Curr->Next;\r
+        Count--;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+VfrOpcodeHandler::~VfrOpcodeHandler(\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Destructor for the VFR opcode handler. Free up memory allocated\r
+  while parsing the VFR script.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  IFR_BYTE    *Curr;\r
+  IFR_BYTE    *Next;\r
+  //\r
+  // Free up the IFR bytes\r
+  //\r
+  Curr = mIfrBytes;\r
+  while (Curr != NULL) {\r
+    Next = Curr->Next;\r
+    free (Curr);\r
+    Curr = Next;\r
+  }\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::AddOpcodeByte (\r
+  UINT8 OpcodeByte, \r
+  UINT32 LineNum\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a new IFR\r
+  opcode should be emitted.\r
+  \r
+Arguments:\r
+  OpcodeByte  - the IFR opcode\r
+  LineNum     - the line number from the source file that resulted\r
+                in the opcode being emitted.\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+{\r
+  UINT32 Count;\r
+\r
+  FlushQueue();\r
+  //\r
+  // Now add this new byte\r
+  //\r
+  mQueuedOpcodeByte       = OpcodeByte;\r
+  mQueuedLineNum          = LineNum;\r
+  mQueuedOpcodeByteValid  = 1;\r
+  return 0;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::AddByte (\r
+  UINT8 ByteVal, \r
+  UINT8 KeyByte\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when it determines\r
+  that more raw IFR bytes should be emitted to the output stream.\r
+  Here we just queue them up into an output buffer.\r
+  \r
+Arguments:\r
+  ByteVal   - the raw byte to emit to the output IFR stream\r
+  KeyByte   - a value that can be used for debug. \r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Check for buffer overflow\r
+  //\r
+  if (mQueuedByteCount >= MAX_QUEUE_COUNT) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");\r
+  } else {\r
+    mQueuedBytes[mQueuedByteCount]    = ByteVal;\r
+    mQueuedKeyBytes[mQueuedByteCount] = KeyByte;\r
+    mQueuedByteCount++;\r
+  }\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::FlushQueue (\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to flush the internal IFR buffer.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+{\r
+  UINT32 Count;\r
+  UINT32 EmitNoneOnePair;\r
+\r
+  EmitNoneOnePair = 0;\r
+  //\r
+  // If the secondary varstore was specified, then we have to emit\r
+  // a varstore-select-pair opcode, which only applies to the following\r
+  // statement. \r
+  //\r
+  if (mSecondaryVarStoreIdSet) {\r
+    mSecondaryVarStoreIdSet = 0;\r
+    //\r
+    // If primary and secondary are the same as the current default\r
+    // varstore, then we don't have to do anything.\r
+    // Note that the varstore-select-pair only applies to the following\r
+    // opcode.\r
+    //\r
+    if ((mPrimaryVarStoreId != mSecondaryVarStoreId) || (mPrimaryVarStoreId != mDefaultVarStoreId)) {\r
+      IAddByte (EFI_IFR_VARSTORE_SELECT_PAIR_OP, 'O', mQueuedLineNum);\r
+      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT_PAIR), 'L', 0);\r
+      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
+      IAddByte ((UINT8)mSecondaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mSecondaryVarStoreId >> 8), 0, 0);\r
+    }\r
+  } else if (mPrimaryVarStoreIdSet != 0) {\r
+    mPrimaryVarStoreIdSet = 0;\r
+    if (mDefaultVarStoreId != mPrimaryVarStoreId) {\r
+      //\r
+      // The VFR statement referenced a different variable store \r
+      // than the last one we reported. Insert a new varstore select \r
+      // statement. \r
+      //\r
+      IAddByte (EFI_IFR_VARSTORE_SELECT_OP, 'O', mQueuedLineNum);\r
+      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT), 'L', 0);\r
+      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
+      mDefaultVarStoreId = mPrimaryVarStoreId;\r
+    }\r
+  }\r
+  //\r
+  // Likely a new opcode is being added. Since each opcode item in the IFR has \r
+  // a header that specifies the size of the opcode item (which we don't\r
+  // know until we find the next opcode in the VFR), we queue up bytes\r
+  // until we know the size. Then we write them out. So flush the queue\r
+  // now.\r
+  //\r
+  if (mQueuedOpcodeByteValid != 0) {\r
+    // \r
+    // Add the previous opcode byte, the length byte, and the binary\r
+    // data.\r
+    //\r
+    IAddByte (mQueuedOpcodeByte, 'O', mQueuedLineNum);\r
+    IAddByte ((UINT8)(mQueuedByteCount + 2), 'L', 0);\r
+    for (Count = 0; Count < mQueuedByteCount; Count++) {\r
+      IAddByte (mQueuedBytes[Count], mQueuedKeyBytes[Count], 0);          \r
+    }\r
+    mQueuedByteCount = 0;\r
+    mQueuedOpcodeByteValid = 0;\r
+  }    \r
+  return 0;\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::IAddByte (\r
+  UINT8   ByteVal, \r
+  UINT8   KeyByte, \r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This internal function is used to add actual IFR bytes to\r
+  the output stream. Most other functions queue up the bytes\r
+  in an internal buffer. Once they come here, there's no\r
+  going back.\r
+\r
+  \r
+Arguments:\r
+  ByteVal   - value to write to output \r
+  KeyByte   - key value tied to the byte -- useful for debug\r
+  LineNum   - line number from source file the byte resulted from\r
+\r
+Returns:\r
+  0 - if successful\r
+  1 - failed due to memory allocation failure\r
+\r
+--*/\r
+{\r
+  IFR_BYTE    *NewByte;\r
+  NewByte = (IFR_BYTE *)malloc (sizeof (IFR_BYTE));\r
+  if (NewByte == NULL) {\r
+    return 1;\r
+  }\r
+  memset ((char *)NewByte, 0, sizeof (IFR_BYTE));\r
+  NewByte->OpcodeByte = ByteVal;\r
+  NewByte->KeyByte = KeyByte;\r
+  NewByte->LineNum = LineNum;\r
+  //\r
+  // Add to the list\r
+  //\r
+  if (mIfrBytes == NULL) {\r
+    mIfrBytes = NewByte;\r
+  } else {\r
+    mLastIfrByte->Next = NewByte;\r
+  } \r
+  mLastIfrByte = NewByte;\r
+  mBytesWritten++;\r
+  return 0;\r
+}\r
+\r
+VOID \r
+WriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to emit a standard header to an\r
+  output text file.\r
+  \r
+Arguments:\r
+  OutFptr - file to write the header to\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT32 TempIndex;\r
+  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
+    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
+  }\r
+  //\r
+  // Write out the VFR compiler version\r
+  //\r
+  fprintf (OutFptr, "//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h
new file mode 100644 (file)
index 0000000..6b8c560
--- /dev/null
@@ -0,0 +1,227 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrServices.h\r
+\r
+Abstract:\r
+\r
+  Prototypes and defines for routines and classes used by the\r
+  EFI VFR compiler.\r
+  \r
+--*/\r
+\r
+#ifndef _VFR_SERVICES_H_\r
+#define _VFR_SERVICES_H_\r
+\r
+class VfrOpcodeHandler\r
+{\r
+public:\r
+  VfrOpcodeHandler (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  Constructor for the VFR opcode handling class.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  ~VfrOpcodeHandler (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  Destructor for the VFR opcode handler. Free up memory allocated\r
+  while parsing the VFR script.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  WriteIfrBytes (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked at the end of parsing. Its purpose\r
+  is to write out all the IFR bytes that were queued up while\r
+  parsing.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  int\r
+  AddOpcodeByte (\r
+    UINT8  OpcodeByte,\r
+    UINT32 LineNum\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a new IFR\r
+  opcode should be emitted.\r
+  \r
+Arguments:\r
+  OpcodeByte  - the IFR opcode\r
+  LineNum     - the line number from the source file that resulted\r
+                in the opcode being emitted.\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+  ;\r
+  void\r
+  AddByte (\r
+    UINT8 ByteVal,\r
+    UINT8 KeyByte\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when it determines\r
+  that more raw IFR bytes should be emitted to the output stream.\r
+  Here we just queue them up into an output buffer.\r
+  \r
+Arguments:\r
+  ByteVal   - the raw byte to emit to the output IFR stream\r
+  KeyByte   - a value that can be used for debug. \r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  SetVarStoreId (\r
+    UINT16 VarStoreId\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a variable is referenced in the \r
+  VFR. Save the variable store (and set a flag) so that we can later determine \r
+  if we need to emit a varstore-select or varstore-select-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  SetSecondaryVarStoreId (\r
+    UINT16 VarStoreId\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a secondary variable is \r
+  referenced in the VFR. Save the variable store (and set a flag) so \r
+  that we can later determine if we need to emit a varstore-select or \r
+  varstore-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+\r
+/* */\r
+private:\r
+  int\r
+  FlushQueue (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked to flush the internal IFR buffer.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+  ;\r
+  int\r
+  IAddByte (\r
+    UINT8  ByteVal,\r
+    UINT8  KeyByte,\r
+    UINT32 LineNum\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This internal function is used to add actual IFR bytes to\r
+  the output stream. Most other functions queue up the bytes\r
+  in an internal buffer. Once they come here, there's no\r
+  going back.\r
+\r
+  \r
+Arguments:\r
+  ByteVal   - value to write to output \r
+  KeyByte   - key value tied to the byte -- useful for debug\r
+  LineNum   - line number from source file the byte resulted from\r
+\r
+Returns:\r
+  0 - if successful\r
+  1 - failed due to memory allocation failure\r
+\r
+--*/\r
+  ;\r
+\r
+/* */\r
+private:\r
+  IFR_BYTE  *mIfrBytes;\r
+  IFR_BYTE  *mLastIfrByte;\r
+  UINT32    mQueuedByteCount;\r
+  UINT32    mBytesWritten;\r
+  UINT32    mQueuedLineNum;\r
+  UINT8     mQueuedBytes[MAX_QUEUE_COUNT];\r
+  UINT8     mQueuedKeyBytes[MAX_QUEUE_COUNT];\r
+  UINT8     mQueuedOpcodeByte;\r
+  UINT32    mQueuedOpcodeByteValid;\r
+  UINT16    mPrimaryVarStoreId;\r
+  UINT8     mPrimaryVarStoreIdSet;\r
+  UINT16    mSecondaryVarStoreId;\r
+  UINT8     mSecondaryVarStoreIdSet;\r
+  UINT16    mDefaultVarStoreId;\r
+};\r
+\r
+#endif // #ifndef _VFR_SERVICES_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
new file mode 100644 (file)
index 0000000..d703b02
--- /dev/null
@@ -0,0 +1,172 @@
+#/*++\r
+#  \r
+#  Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#  \r
+#    makefile\r
+#  \r
+#  Abstract:\r
+#  \r
+#    Makefile for building the EFI VFR compiler\r
+#    \r
+#--*/  \r
+\r
+\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set \r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+.SUFFIXES :\r
+\r
+TARGET_NAME       = VfrCompile\r
+ANTLR_H           = $(PCCTS_DIR)\h\r
+C_FLAGS_PCCTS     = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)\r
+C_FLAGS_PCCTS     = $(C_FLAGS_PCCTS)  \r
+\r
+LINK_FLAGS_PCCTS  =\r
+LIBS              = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+# \r
+# Define the EFI output and source directories.\r
+#\r
+ETO               = $(EDK_TOOLS_OUTPUT)\r
+SRC               = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE        = $(ETO)\$(TARGET_NAME).exe\r
+\r
+#\r
+# Add deeper lookahead with -ck 3\r
+#\r
+ANTLR_FLAGS       = -CC -e3 -ck 3\r
+DLG_FLAGS         = -C2 -i -CC\r
+\r
+#\r
+# Define paths for include files\r
+#\r
+INC = -I $(SRC) \r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\Ia32\r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\Efi\Include\r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\Framework\Include\r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard\r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\         \\r
+             -I $(EDK_SOURCE)\Foundation\Core\Dxe \\r
+             -I $(EDK_SOURCE)\Foundation\Efi      \\r
+             -I $(EDK_SOURCE)\Foundation\Framework\r
+INC = $(INC) -I $(EDK_TOOLS_SOURCE)\Common\r
+INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include \r
+\r
+DLG_FILE          = Parser.dlg\r
+SCAN_FILE         = DLGLexer\r
+PARSER_FILE       = EfiVfrParser\r
+\r
+#\r
+# Create a list of include dependencies \r
+#\r
+INC_DEPS = $(INC_DEPS) $(SRC)\EfiVfr.h\r
+INC_DEPS = $(INC_DEPS) $(EDK_SOURCE)\Foundation\Framework\Include\EfiInternalFormRepresentation.h\r
+\r
+#\r
+# This is the grammer file for our project\r
+#\r
+GRAMMER_FILE  = $(SRC)\$(TARGET_NAME).g\r
+\r
+#\r
+# If we utilize a separate token file, define it here.\r
+#\r
+#TOKEN_FILE    = \r
+\r
+    \r
+OBJECTS =       $(ETO)\$(TARGET_NAME).obj \\r
+                $(ETO)\$(PARSER_FILE).obj \\r
+                $(ETO)\AParser.obj \\r
+                $(ETO)\DLexerBase.obj \\r
+                $(ETO)\ATokenBuffer.obj \\r
+                $(ETO)\$(SCAN_FILE).obj  \\r
+                $(ETO)\VfrServices.obj\r
+\r
+#\r
+# Per the Language Translation Using PCCTS and C++ Reference Guide, page 109,\r
+# these are the outputs of ANTLR and DLG\r
+#                \r
+ANTLR_SPAWN =   $(ETO)\$(TARGET_NAME).cpp \\r
+                $(ETO)\$(PARSER_FILE).cpp \\r
+                     $(ETO)\$(PARSER_FILE).h \\r
+                $(ETO)\$(DLG_FILE) \\r
+                $(ETO)\tokens.h \r
+\r
+DLG_SPAWN =     $(ETO)\$(SCAN_FILE).cpp \\r
+                $(ETO)\$(SCAN_FILE).h\r
+\r
+\r
+#\r
+# Default target\r
+#\r
+all : $(TARGET_EXE)\r
+\r
+#\r
+# All antlr-generated files depend on the .g grammer file. Use the -o\r
+# option to emit them to the appropriate output directory.\r
+#\r
+$(ANTLR_SPAWN) : $(GRAMMER_FILE) $(INC_DEPS)\r
+       $(ANTLR) $(ANTLR_FLAGS) -o $(ETO) $(GRAMMER_FILE)\r
+\r
+$(ETO)\$(TARGET_NAME).obj : $(ETO)\$(TARGET_NAME).cpp $(DLG_SPAWN) $(INC_DEPS)\r
+       $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(TARGET_NAME).cpp\r
+\r
+$(ETO)\$(SCAN_FILE).obj : $(ETO)\$(SCAN_FILE).cpp $(DLG_SPAWN) $(INC_DEPS)\r
+       $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(SCAN_FILE).cpp\r
+\r
+$(ETO)\$(PARSER_FILE).obj : $(ETO)\$(PARSER_FILE).cpp $(ETO)\$(PARSER_FILE).h $(DLG_SPAWN) $(INC_DEPS)\r
+  $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(PARSER_FILE).cpp\r
+\r
+$(DLG_SPAWN) : $(ETO)\$(DLG_FILE) $(INC_DEPS)\r
+       $(DLG) $(DLG_FLAGS) -o $(ETO) $(ETO)\$(DLG_FILE)\r
+\r
+$(ETO)\AParser.obj : $(ANTLR_H)/AParser.cpp\r
+       $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/AParser.cpp\r
+\r
+$(ETO)\ATokenBuffer.obj : $(ANTLR_H)/ATokenBuffer.cpp\r
+       $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/ATokenBuffer.cpp\r
+\r
+$(ETO)\DLexerBase.obj : $(ANTLR_H)/DLexerBase.cpp\r
+       $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/DLexerBase.cpp\r
+\r
+$(ETO)\VfrServices.obj : $(SRC)\VfrServices.cpp $(SRC)\VfrServices.h $(INC_DEPS)\r
+       $(CC) -c $(C_FLAGS_PCCTS) $(INC) /Fo$@ $(SRC)\VfrServices.cpp\r
+\r
+#\r
+# Add Binary Build description for this tools.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+       $(LINK) $(MSVS_LINK_LIBPATHS) $(LIBS) /DEBUG /OUT:$(TARGET_EXE) $(LINK_FLAGS_PCCTS) $(OBJECTS) /PDB:$*.pdb\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+\r
+clean:\r
+  \r
diff --git a/EdkCompatibilityPkg/Sample/Version.env b/EdkCompatibilityPkg/Sample/Version.env
new file mode 100644 (file)
index 0000000..dde7a7d
--- /dev/null
@@ -0,0 +1,34 @@
+#/*++\r
+#   \r
+#  Copyright (c) 2006, Intel Corporation                                                         \r
+#  All rights reserved. This program and the accompanying materials                          \r
+#  are licensed and made available under the terms and conditions of the BSD License         \r
+#  which accompanies this distribution.  The full text of the license may be found at        \r
+#  http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                            \r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  \r
+#  Module Name:\r
+#\r
+#    Version.env\r
+#   \r
+#  Abstract:\r
+#   \r
+#    This file is used to define EDK related version info.\r
+#   \r
+#--*/\r
+\r
+!IF "$(UEFI_MODE)" == "YES"\r
+EFI_SPECIFICATION_VERSION = 0x00020000\r
+!ELSE\r
+EFI_SPECIFICATION_VERSION = 0x0001000A\r
+!ENDIF\r
+\r
+!IF "$(PI_MODE)" == "YES"\r
+PI_SPECIFICATION_VERSION = 0x00010000\r
+!ELSE\r
+PI_SPECIFICATION_VERSION = 0x00000009\r
+!ENDIF\r
+\r
+TIANO_RELEASE_VERSION     = 0x00080006\r